Package org.xdams.page.view.bean

Examples of org.xdams.page.view.bean.ManagingBean


  @RequestMapping(value = "/{archive}/managing")
  public String managing(@ModelAttribute("userBean") UserBean userBean, @ModelAttribute("confBean") ConfBean confBean, @PathVariable String archive, ModelMap modelMap, HttpServletRequest request, HttpServletResponse response) throws Exception {
    common(confBean, userBean, archive, modelMap, request, response);
    ManagingFactory managingFactory = new ManagingFactory(request.getParameterMap(), modelMap);
    ManagingBean managingBean = managingFactory.execute();
    System.out.println("xDamsController.managing() " + managingBean);
    return "managing/" + managingBean.getDispatchView();
  }
View Full Code Here


  @RequestMapping(value = "/{archive}/pdfView")
  public void pdfView(@ModelAttribute("userBean") UserBean userBean, @ModelAttribute("confBean") ConfBean confBean, @PathVariable String archive, ModelMap modelMap, HttpServletRequest request, HttpServletResponse response) throws Exception {
    common(confBean, userBean, archive, modelMap, request, response);
    ManagingFactory managingFactory = new ManagingFactory(request.getParameterMap(), modelMap);
    ManagingBean managingBean = managingFactory.execute();
    // return "managing/" + managingBean.getDispatchView();
  }
View Full Code Here

  public ManagingBean execute() throws Exception {
    XWConnection xwconn = null;
    ConnectionManager connectionManager = new ConnectionManager();
    ConfBean confBean = null;
    ManagingBean managingBean = null;
    String physDoc = MyRequest.getParameter("physDoc", parameterMap); // myRequest.getParameter("physDoc");
    String makeAction = MyRequest.getParameter("makeAction", parameterMap); // myRequest.getParameter("makeAction");
    String theValue = MyRequest.getParameter("theValue", parameterMap); // myRequest.getParameter("theValue");
    String theXpath = MyRequest.getParameter("theXpath", parameterMap); // myRequest.getParameter("theXpath");
    String applyTo = MyRequest.getParameter("applyTo", parameterMap); // myRequest.getParameter("applyTo");
    String selid = MyRequest.getParameter("selid", parameterMap); // myRequest.getParameter("selid");
    HttpSession httpSession = null;
    List<String> confControl = new ArrayList<String>();
    confControl.add("titleManager");
    confControl.add("valoriControllati");
    confControl.add("docEdit");
    try {
      managingBean = new ManagingBean();
      UserBean userBean = (UserBean) modelMap.get("userBean");
      confBean = (ConfBean) modelMap.get("confBean");
      WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      httpSession = workFlowBean.getRequest().getSession(false);
      xwconn = connectionManager.getConnection(workFlowBean.getArchive());
      MultiEditingManager editingManager = new MultiEditingManager(parameterMap, confBean, userBean, workFlowBean);
      editingManager.setTheXML(new XMLBuilder(xwconn.getSingleXMLFromNumDoc(Integer.parseInt(physDoc)), "ISO-8859-1"));
      confBean = editingManager.rewriteMultipleConf(confControl);
      managingBean.setSelid(selid);
      if (!physDoc.equals("") && makeAction.equals("")) {
        managingBean.setPhysDoc(Integer.parseInt(physDoc));
        managingBean.setDocLowerBrother(xwconn.getNumDocNextBrother(managingBean.getPhysDoc()));
        managingBean.setDocUpperBrother(xwconn.getNumDocPreviousBrother(managingBean.getPhysDoc()));
        it.highwaytech.db.QueryResult qrSons = xwconn.getSonsFromNumDoc(managingBean.getPhysDoc());
        managingBean.setNumElementiSons(qrSons.elements);
        it.highwaytech.db.QueryResult qrHier = xwconn.getQRFromHier(managingBean.getPhysDoc(), false);
        managingBean.setNumElementiHier(qrHier.elements);
        if (!selid.equals("")) {
          it.highwaytech.db.QueryResult qr = xwconn.getQRFromSelId(selid);
          managingBean.setNumElementi(qr.elements);
        }
        managingBean.setTitle((xwconn.getTitle(xwconn.connection, xwconn.getTheDb(), managingBean.getPhysDoc())).getTitle());
        managingBean.setDocXML(xwconn.getSingleXMLFromNumDoc(managingBean.getPhysDoc()));
        managingBean.setDispatchView("multiModMenu");
        if (httpSession.getAttribute(workFlowBean.getManagingBeanName()) != null) {
          ArrayList listDocs = ((ManagingBean) httpSession.getAttribute(workFlowBean.getManagingBeanName())).getListPhysDoc();
          if (listDocs != null && listDocs.size() > 0) {
            managingBean.setListPhysDoc(listDocs);
          }
        }

      } else if (!physDoc.equals("") && makeAction.equals("true")) { // DO
        managingBean.setPhysDoc(Integer.parseInt(physDoc));
        ArrayList elementiNum = ExtractDocument.extractDocument(httpSession, xwconn, managingBean, workFlowBean, applyTo, selid);
        managingBean.setNumElementi(elementiNum.size());
        managingBean.setTitle((xwconn.getTitle(xwconn.connection, xwconn.getTheDb(), Integer.parseInt(physDoc))).getTitle());
        managingBean.setDispatchView("multiModResult");
        int totElementi = elementiNum.size();
        int processati = 0;
        int errori = 0;
        SharpIncrementTool sharpIncrementTool = new SharpIncrementTool();
        for (int i = 0; i < totElementi; i++) {
          int docCorrente = 0;
          try {
            docCorrente = ((Integer) elementiNum.get(i)).intValue();
          } catch (Exception e) {
            docCorrente = (Integer.parseInt((String) elementiNum.get(i)));
          }
          try {
            // gestire con framework
            String docXML = xwconn.getSingleXMLFromNumDoc(docCorrente);
            XMLBuilder xmlBuilder = new XMLBuilder(docXML, "ISO-8859-1");
            String ilValore = theValue;
            String ilNome = theXpath;
            // if (ilValore.indexOf("[#") > 0 && ilValore.indexOf("#]") > 0 && totElementi > 1) {
            if ((ilValore.indexOf("[#") != -1) && (ilValore.indexOf("#]") > 0) && (totElementi > 1)) {
              ilValore = sharpIncrementTool.incrementValue(ilNome, ilValore);
            }
            xmlBuilder.insertValueAt(ilNome, ilValore);
            xwconn.executeUpdateByDocNumber(xmlBuilder.getXML("ISO-8859-1", false), docCorrente);
            processati++;
          } catch (Exception e) {
            managingBean.addErrorMsg(e.getMessage());
            errori++;
          }
        }
        managingBean.setDocSuccessi(processati);
        managingBean.setDocErrori(errori);
      }

      modelMap.put("confBean", confBean);
      modelMap.put("managingBean", managingBean);
    } catch (Exception e) {
View Full Code Here

  public ManagingBean execute() throws Exception {
    XWConnection xwconn = null;
    ConnectionManager connectionManager = new ConnectionManager();
    ConfBean confBean = null;
    ManagingBean managingBean = null;
    String physDoc = MyRequest.getParameter("physDoc", parameterMap);// myRequest.getParameter("physDoc");
    String makeAction = MyRequest.getParameter("makeAction", parameterMap); // myRequest.getParameter("makeAction");
    String applyTo = MyRequest.getParameter("applyTo", parameterMap); // myRequest.getParameter("applyTo");
    String selid = MyRequest.getParameter("selid", parameterMap); // myRequest.getParameter("selid");
    String whichTo = MyRequest.getParameter("whichTo", parameterMap); // myRequest.getParameter("whichTo");
    boolean menuFlag = true;
    HttpSession httpSession = null;
    List<String> confControl = new ArrayList<String>();
    confControl.add("titleManager");
    confControl.add("docEdit");
    try {
      managingBean = new ManagingBean();
      UserBean userBean = (UserBean) modelMap.get("userBean");
      confBean = (ConfBean) modelMap.get("confBean");
      WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      httpSession = workFlowBean.getRequest().getSession(false);

      xwconn = connectionManager.getConnection(workFlowBean.getArchive());
      MultiEditingManager editingManager = new MultiEditingManager(parameterMap, confBean, userBean, workFlowBean);
      editingManager.setTheXML(new XMLBuilder(xwconn.getSingleXMLFromNumDoc(Integer.parseInt(physDoc)), "ISO-8859-1"));
      confBean = editingManager.rewriteMultipleConf(confControl);
      if (httpSession.getAttribute(workFlowBean.getManagingBeanName()) != null) {
        managingBean = ((ManagingBean) httpSession.getAttribute(workFlowBean.getManagingBeanName()));
      } else {
        managingBean = new ManagingBean();
      }
      // mi serve per contare i successi e no
      managingBean.setDocSuccessi(0);
      managingBean.setDocErrori(0);

      managingBean.setPhysDoc(Integer.parseInt(physDoc));
      managingBean.setTitle((xwconn.getTitle(xwconn.connection, xwconn.getTheDb(), managingBean.getPhysDoc())).getTitle());

      it.highwaytech.db.QueryResult qr = null;
      if (!selid.equals("")) {
        qr = xwconn.getQRFromSelId(selid);
        managingBean.setNumElementi(qr.elements);
      }

      if (!whichTo.equals("") && whichTo.equals("selected")) {
        // eseguo il taglia multiplo come figlio
        if (managingBean != null && managingBean.getListPhysDoc().size() > 0 && makeAction != null && makeAction.equals("true") && applyTo != null && applyTo.equals("cut_as_son")) {
          menuFlag = false;
          ArrayList arrayList = managingBean.getListPhysDoc();
          for (int i = 0; i < arrayList.size(); i++) {
            try {
              int physDocToCut = Integer.parseInt((String) arrayList.get(i));
              xwconn.cut_paste(physDocToCut, Integer.parseInt(physDoc), it.highwaytech.broker.ServerCommand.navigarel_FIGLIOPADRE);
              managingBean.setDocSuccessi(managingBean.getDocSuccessi() + 1);
            } catch (Exception e) {
              managingBean.addErrorMsg("Errore in Sposta per il documento  " + arrayList.get(i) + " " + e.getMessage());
              managingBean.setDocErrori(managingBean.getDocErrori() + 1);
            }
          }
          managingBean.setDispatchView("multiMoveResult");
        }
        // eseguo il taglia multiplo come fratello precedente
        if (managingBean != null && managingBean.getListPhysDoc().size() > 0 && makeAction != null && makeAction.equals("true") && applyTo != null && applyTo.equals("cut_as_before")) {
          menuFlag = false;
          ArrayList arrayList = managingBean.getListPhysDoc();
          for (int i = 0; i < arrayList.size(); i++) {
            try {
              int physDocToCut = Integer.parseInt((String) arrayList.get(i));
              xwconn.cut_paste(physDocToCut, Integer.parseInt(physDoc), it.highwaytech.broker.ServerCommand.navigarel_MINOREMAGGIORE);
              managingBean.setDocSuccessi(managingBean.getDocSuccessi() + 1);
            } catch (Exception e) {
              managingBean.addErrorMsg("Errore in Sposta per il documento  " + arrayList.get(i) + " " + e.getMessage());
              managingBean.setDocErrori(managingBean.getDocErrori() + 1);
            }
          }
          managingBean.setDispatchView("multiMoveResult");
        }
        // eseguo il taglia multiplo come fratello successivo
        if (managingBean != null && managingBean.getListPhysDoc().size() > 0 && makeAction != null && makeAction.equals("true") && applyTo != null && applyTo.equals("cut_as_after")) {
          menuFlag = false;
          ArrayList arrayList = managingBean.getListPhysDoc();
          for (int i = arrayList.size() - 1; i >= 0; i--) {
            // for (int i = 0; i < arrayList.size(); i++) {
            try {
              int physDocToCut = Integer.parseInt((String) arrayList.get(i));
              xwconn.cut_paste(physDocToCut, Integer.parseInt(physDoc), it.highwaytech.broker.ServerCommand.navigarel_MAGGIOREMINORE);
              managingBean.setDocSuccessi(managingBean.getDocSuccessi() + 1);
            } catch (Exception e) {
              managingBean.addErrorMsg("Errore in Sposta per il documento  " + arrayList.get(i) + " " + e.getMessage());
              managingBean.setDocErrori(managingBean.getDocErrori() + 1);
            }
          }
          managingBean.setDispatchView("multiMoveResult");
        }
      } else if (!whichTo.equals("") && whichTo.equals("selid")) {

        if (managingBean != null && managingBean.getNumElementi() > 0 && makeAction != null && makeAction.equals("true") && applyTo != null && applyTo.equals("cut_as_son") && qr != null) {
          menuFlag = false;
          // ArrayList arrayList = managingBean.getListPhysDoc();
          for (int i = 0; i < qr.elements; i++) {
            int physDocToCut = -1;
            try {
              physDocToCut = xwconn.getNumDocFromQRElement(qr, i);// Integer.parseInt((String) arrayList.get(i));
              if (physDocToCut != Integer.parseInt(physDoc)) {
                xwconn.cut_paste(physDocToCut, Integer.parseInt(physDoc), it.highwaytech.broker.ServerCommand.navigarel_FIGLIOPADRE);
                managingBean.setDocSuccessi(managingBean.getDocSuccessi() + 1);
              }

            } catch (Exception e) {
              managingBean.addErrorMsg("Errore in Sposta per il documento  " + physDocToCut + " " + e.getMessage());
              managingBean.setDocErrori(managingBean.getDocErrori() + 1);
            }
          }
          managingBean.setDispatchView("multiMoveResult");
        }
        // eseguo il taglia multiplo come fratello precedente
        if (managingBean != null && managingBean.getNumElementi() > 0 && makeAction != null && makeAction.equals("true") && applyTo != null && applyTo.equals("cut_as_before") && qr != null) {
          menuFlag = false;
          managingBean.setDispatchView("multiMoveResult");
        }
        // eseguo il taglia multiplo come fratello successivo
        if (managingBean != null && managingBean.getNumElementi() > 0 && makeAction != null && makeAction.equals("true") && applyTo != null && applyTo.equals("cut_as_after") && qr != null) {
          menuFlag = false;
          managingBean.setDispatchView("multiMoveResult");
        }

      }

      // se e false allora il jspDispatch e gia stato settato per la risposta
      if (menuFlag) {
        managingBean.setDispatchView("multiMoveMenu");
      }
      managingBean.setNumElementi(managingBean.getDocErrori() + managingBean.getDocSuccessi());
      modelMap.put("confBean", confBean);
      modelMap.put("managingBean", managingBean);
    } catch (Exception e) {
      modelMap.put("confBean", confBean);
      modelMap.put("managingBean", managingBean);
View Full Code Here

  }

  public AjaxBean execute() throws Exception {
    AjaxBean ajaxBean = new AjaxBean();
    HttpSession httpSession = null;
    ManagingBean managingBean = null;
    String valori = "";
    try {
      UserBean userBean = (UserBean) modelMap.get("userBean");
      WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      httpSession = workFlowBean.getRequest().getSession(false);
      if (httpSession.getAttribute(workFlowBean.getManagingBeanName()) == null) {
        managingBean = new ManagingBean();
        if (aReq.getParameter("physDoc") != null) {
          managingBean.addListPhysDoc(aReq.getParameter("physDoc"));
        }
        httpSession.setAttribute(workFlowBean.getManagingBeanName(), managingBean);
      } else {
        managingBean = (ManagingBean) httpSession.getAttribute(workFlowBean.getManagingBeanName());
        if (aReq.getParameter("action") != null && aReq.getParameter("action").equals("addElement")) {
          if (!(managingBean.getListPhysDoc()).contains(aReq.getParameter("physDoc"))) {
            managingBean.addListPhysDoc(aReq.getParameter("physDoc"));
          }
        } else if (aReq.getParameter("action") != null && aReq.getParameter("action").equals("removeElement")) {
          if ((managingBean.getListPhysDoc()).contains(aReq.getParameter("physDoc"))) {
            managingBean.removePhysDoc(aReq.getParameter("physDoc"));
          }
        }
        System.out.println("AjaxSessionCommand.execute()" + aReq.getParameter("action"));
        System.out.println("AjaxSessionCommand.execute()" + managingBean.getMultipleChoise() + " managingBean.getMultipleChoise()");
        if (aReq.getParameter("action").equals("switch")) {
          System.out.println("AjaxSessionCommand.execute()1" + aReq.getParameter("action"));
          System.out.println("AjaxSessionCommand.execute()2" + managingBean.getMultipleChoise() + " managingBean.getMultipleChoise()");
          if ((managingBean.getMultipleChoise()).equals("")) {
            managingBean.setMultipleChoise("none");
          } else {
            managingBean.setMultipleChoise("");
          }
          if (aReq.getParameter("svuota") != null && aReq.getParameter("svuota").equals("ok")) {
            managingBean.setListPhysDoc(new ArrayList());
          }
        }
        httpSession.setAttribute(workFlowBean.getManagingBeanName(), managingBean);
      }
      Enumeration enumeration = httpSession.getAttributeNames();
      while (enumeration.hasMoreElements()) {
        String element = (String) enumeration.nextElement();
        valori += "<sessionDoc><text>" + element + "</text><value>" + httpSession.getAttribute(element) + "</value></sessionDoc>\n";
      }
      for (int i = 0; i < managingBean.getListPhysDoc().size(); i++) {
        valori += "<sessionDoc><text>numeroDocumento</text><value>" + managingBean.getListPhysDoc().get(i) + "</value></sessionDoc>\n";
      }
    } catch (Exception e) {
      e.printStackTrace();
      ajaxBean.setStrXmlOutput("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<sessionList>\n<sessionDoc><text>Errore Caricamento</text><value></value></sessionDoc>\n</sessionList>");
    }
View Full Code Here

    AjaxBean ajaxBean = new AjaxBean();
    HttpSession httpSession = null;
    String actionType = MyRequest.getParameter("action", req.getParameterMap());
    String physDoc = MyRequest.getParameter("physDoc", req.getParameterMap());
    String physDocToPaste = MyRequest.getParameter("physDocToPaste", req.getParameterMap());
    ManagingBean managingBean = null;
    String valori = "";
    ConnectionManager connectionManager = new ConnectionManager();
    XWConnection xwconn = null;
    ConfBean confBean = null;
    WorkFlowBean workFlowBean = null;
    List<String> confControl = new ArrayList<String>();
    confControl.add("titleManager");
    confControl.add("docEdit");

    try {
      UserBean userBean = (UserBean) modelMap.get("userBean");
      confBean = (ConfBean) modelMap.get("confBean");
      workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      httpSession = workFlowBean.getRequest().getSession(false);
      if (httpSession.getAttribute(workFlowBean.getManagingBeanName()) == null) {
        managingBean = new ManagingBean();
        managingBean.setMultipleChoise("none");
      } else {
        managingBean = (ManagingBean) httpSession.getAttribute(workFlowBean.getManagingBeanName());
      }

      xwconn = connectionManager.getConnection(workFlowBean.getArchive());
      MultiEditingManager editingManager = new MultiEditingManager(req.getParameterMap(), confBean, userBean, workFlowBean);
      editingManager.setTheXML(new XMLBuilder(xwconn.getSingleXMLFromNumDoc(Integer.parseInt(physDoc)), "ISO-8859-1"));
      confBean = editingManager.rewriteMultipleConf(confControl);

      if (actionType.equals("cut") || actionType.equals("paste") || actionType.equals("no_rel") || actionType.equals("only_hier")) {
        TitleManager titleManager = new TitleManager(confBean.getTheXMLConfTitle());
      //  System.out.println("AjaxCutPasteCopyCommand.execute() getTheXMLConfTitle " + confBean.getTheXMLConfTitle().getXML("ISO-8859-1"));
        try {
          managingBean.setCutPhysDoc(Integer.parseInt(physDoc));
          String titoloDoc = xwconn.getTitleFromNumDoc(Integer.parseInt(physDoc));
          System.out.println("AjaxCutPasteCopyCommand.execute() titoloDoc " + titoloDoc);
          managingBean.setCutTitle(titoloDoc);
        } catch (Exception e) {
          e.printStackTrace();
        }
        String azioneDescr = "";
        if (actionType.equals("cut")) {
          azioneDescr = "tagliato";
        } else if (actionType.equals("paste")) {
          azioneDescr = "copiato";
        } else if (actionType.equals("no_rel")) {
          azioneDescr = "copiato";
        } else if (actionType.equals("only_hier")) {
          azioneDescr = "copiato";
        }

        String contenitoreIni = "\n<div class=\"cont_ul2\"><ul class=\"bottoniMenu\">";
        String string0 = "";
        String string1 = "";
        String string2 = "";
        if (!actionType.equals("no_rel")) {
          string0 = "<li><a href=\"#\" target=\"\" onclick=\"ajaxSetSessionDocsToCut('" + managingBean.getCutPhysDoc() + "','@@physDocToPaste@@','" + actionType + "_as_son','" + workFlowBean.getAlias() + "');\" >INC.FIGLIO</a></li>";
          string1 = "<li><a href=\"#\" target=\"\" onclick=\"ajaxSetSessionDocsToCut('" + managingBean.getCutPhysDoc() + "','@@physDocToPaste@@','" + actionType + "_as_before','" + workFlowBean.getAlias() + "');\" >INC.PRIMA</a></li>";
          string2 = "<li><a href=\"#\" target=\"\" onclick=\"ajaxSetSessionDocsToCut('" + managingBean.getCutPhysDoc() + "','@@physDocToPaste@@','" + actionType + "_as_after','" + workFlowBean.getAlias() + "');\" >INC.DOPO</a></li>";
        }

        String string3 = "";
        // if(actionType.equals("paste") || actionType.equals("no_rel")){
        if (actionType.equals("no_rel")) {
          actionType = "paste";
          string3 = "<li><a href=\"#\" target=\"\" onclick=\"ajaxSetSessionDocsToCut('" + managingBean.getCutPhysDoc() + "','@@physDocToPaste@@','" + actionType + "_as_norel','" + workFlowBean.getAlias() + "');\" >NO REL</a></li>";
        }

        String string4 = "<li><a href=\"#\" target=\"\" onclick=\"ajaxSetSessionDocsToCut('" + managingBean.getCutPhysDoc() + "','@@physDocToPaste@@','" + actionType + "_delete','" + workFlowBean.getAlias() + "');\" >ANNULLA</a></li>";
        String contenitoreEnd = "</ul></div><div class=\"cutPasteClazz\">elemento " + azioneDescr + " " + (titleManager.defaultParsedTitle(managingBean.getCutTitle(), "hierTitle")) + "</div>";
        String string = contenitoreIni + string0 + string1 + string2 + string3 + string4 + contenitoreEnd;
        ajaxBean.setStrXmlOutput(string);
        managingBean.setCutHtmlOutput(string);
        // managingBean.setCutHtmlOutput(managingBean.getCutHtmlOutput(String.valueOf(managingBean.getCutPhysDoc())));
      }

      boolean cutTest = true;
      boolean pasteTest = true;
      try {
        if (actionType.startsWith("cut_as")) {
          HierPath hierPath = xwconn.getHierPath(Integer.parseInt(physDocToPaste));
          int numeroLivelli = hierPath.depth();
          for (int i = 1; i < numeroLivelli; i++) {
            int theFatherTemp = hierPath.docNumber(i);
            if (theFatherTemp == Integer.parseInt(physDoc) || Integer.parseInt(physDoc) == Integer.parseInt(physDocToPaste)) {
              cutTest = false;
              break;
            }
          }
        }
      } catch (Exception e) {
        cutTest = false;
      }

      if (!cutTest) {
        ajaxBean.setStrXmlOutput("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<error>" + StringEscapeUtils.escapeXml("Attenzione:\nNon e possibile effettuare l'operazione richiesta") + "</error>");
      }

      if (actionType.equals("cut_as_son")) {
        // elemento da tagliare physDoc
        if (cutTest) {
          xwconn.cut_paste(Integer.parseInt(physDoc), Integer.parseInt(physDocToPaste), it.highwaytech.broker.ServerCommand.navigarel_FIGLIOPADRE);
          ajaxBean.setStrXmlOutput("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<succes>reloadLocation()</succes>");
        }
        // elemento in cui spostare il documento tagliato physDocToPaste
      } else if (actionType.equals("cut_as_before")) {
        // elemento da tagliare physDoc
        if (cutTest) {
          xwconn.cut_paste(Integer.parseInt(physDoc), Integer.parseInt(physDocToPaste), it.highwaytech.broker.ServerCommand.navigarel_MINOREMAGGIORE);
          ajaxBean.setStrXmlOutput("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<succes>reloadLocation()</succes>");
        }
        // elemento in cui spostare il documento tagliato physDocToPaste
      } else if (actionType.equals("cut_as_after")) {
        // elemento da tagliare physDoc
        if (cutTest) {
          xwconn.cut_paste(Integer.parseInt(physDoc), Integer.parseInt(physDocToPaste), it.highwaytech.broker.ServerCommand.navigarel_MAGGIOREMINORE);
          ajaxBean.setStrXmlOutput("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<succes>reloadLocation()</succes>");
        }
        // elemento in cui spostare il documento tagliato physDocToPaste
      } else if (actionType.equals("cut_delete")) {
        managingBean.setCutTitle("");
        managingBean.setCutHtmlOutput("<div id=\"scriviQui\"></div>");
        ajaxBean.setStrXmlOutput("<div id=\"scriviQui\"></div>");
        managingBean.setCutPhysDoc(-1);
      } else if (actionType.equals("paste_as_son")) {
        // elemento da tagliare physDoc
        String xmlDoc = xwconn.getSingleXMLFromNumDoc(Integer.parseInt(physDoc));
        String newXML = XMLCopy.xmlCopy(confBean.getTheXMLConfEditing(), new XMLBuilder(xmlDoc, "ISO-8859-1"), userBean);
        int recordNum = xwconn.insert(newXML);
        int toPaste = -1;
        try {
          toPaste = Integer.parseInt(physDocToPaste);
        } catch (Exception e) {
          toPaste = Integer.parseInt(physDoc);
        }
        System.out.println("AjaxCutPasteCopyCommand.execute() " + newXML);
        int esitoAzione = xwconn.docRelInsert(xwconn.connection, xwconn.getTheDb(), it.highwaytech.broker.ServerCommand.navigarel_FIGLIOPADRE, recordNum, toPaste);
        ajaxBean.setStrXmlOutput("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<succes>reloadLocation()</succes>");
        // elemento in cui spostare il documento tagliato physDocToPaste
      } else if (actionType.equals("paste_as_before")) {
        // elemento da tagliare physDoc
        String xmlDoc = xwconn.getSingleXMLFromNumDoc(Integer.parseInt(physDoc));
        String newXML = XMLCopy.xmlCopy(confBean.getTheXMLConfEditing(), new XMLBuilder(xmlDoc, "ISO-8859-1"), userBean);
        int recordNum = xwconn.insert(newXML);
        int toPaste = -1;
        try {
          toPaste = Integer.parseInt(physDocToPaste);
        } catch (Exception e) {
          toPaste = Integer.parseInt(physDoc);
        }
        int esitoAzione = xwconn.docRelInsert(xwconn.connection, xwconn.getTheDb(), it.highwaytech.broker.ServerCommand.navigarel_MINOREMAGGIORE, recordNum, toPaste);
        ajaxBean.setStrXmlOutput("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<succes>reloadLocation()</succes>");
        // elemento in cui spostare il documento tagliato physDocToPaste
      } else if (actionType.equals("paste_as_after")) {
        // elemento da tagliare physDoc
        String xmlDoc = xwconn.getSingleXMLFromNumDoc(Integer.parseInt(physDoc));
        String newXML = XMLCopy.xmlCopy(confBean.getTheXMLConfEditing(), new XMLBuilder(xmlDoc, "ISO-8859-1"), userBean);
        int recordNum = xwconn.insert(newXML);
        int toPaste = -1;
        try {
          toPaste = Integer.parseInt(physDocToPaste);
        } catch (Exception e) {
          toPaste = Integer.parseInt(physDoc);
        }
        System.out.println("AjaxCutPasteCopyCommand.execute() " + newXML);
        int esitoAzione = xwconn.docRelInsert(xwconn.connection, xwconn.getTheDb(), it.highwaytech.broker.ServerCommand.navigarel_MAGGIOREMINORE, recordNum, toPaste);
        ajaxBean.setStrXmlOutput("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<succes>reloadLocation()</succes>");
        // elemento in cui spostare il documento tagliato physDocToPaste
      } else if (actionType.equals("paste_as_norel")) {
        // elemento da tagliare physDoc
        String xmlDoc = xwconn.getSingleXMLFromNumDoc(Integer.parseInt(physDoc));
        String newXML = XMLCopy.xmlCopy(confBean.getTheXMLConfEditing(), new XMLBuilder(xmlDoc, "ISO-8859-1"), userBean);
        int recordNum = xwconn.insert(newXML);
        /*
         * int toPaste = -1; try { toPaste = Integer.parseInt(physDocToPaste); } catch (Exception e) { toPaste = Integer.parseInt(physDoc); } System.out.println("AjaxCutPasteCopyCommand.execute() " + newXML); int esitoAzione = xwconn.docRelInsert(xwconn.connection, xwconn.getTheDb(),
         * it.highwaytech.broker.ServerCommand.navigarel_MAGGIOREMINORE, recordNum, toPaste);
         */
        ajaxBean.setStrXmlOutput("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<succes>reloadLocation()</succes>");
        // elemento in cui spostare il documento tagliato physDocToPaste
      } else if (actionType.equals("paste_delete")) {
        managingBean.setCutTitle("");
        managingBean.setCutHtmlOutput("<div id=\"scriviQui\"></div>");
        ajaxBean.setStrXmlOutput("<div id=\"scriviQui\"></div>");
        managingBean.setCutPhysDoc(-1);
      }

    } catch (Exception e) {
      e.printStackTrace();
      ajaxBean.setStrXmlOutput("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<error>" + StringEscapeUtils.escapeXml("Attenzione:\nimpossibile effettuare l'operazione, il documento selezionato potrebbe non essere pi� in gerarchia") + "\n" + e.getMessage() + "</error>");
View Full Code Here

  public ManagingBean execute() throws Exception {
    XWConnection xwconn = null;
    ConnectionManager connectionManager = new ConnectionManager();
    ConfBean confBean = null;
    ManagingBean managingBean = null;
    String physDoc = MyRequest.getParameter("physDoc", parameterMap);
    String makeAction = MyRequest.getParameter("makeAction", parameterMap);
    String applyTo = MyRequest.getParameter("applyTo", parameterMap);
    String selid = MyRequest.getParameter("selid", parameterMap);
    String formattedText = MyRequest.getParameter("formattedText", parameterMap);
    HttpSession httpSession = null;
    String PDFType = ""; // 4 SELEZIONE
    // 1 UN DOCUMENTO
    // 2 FIGLI DI PRIMO LIVELLO
    // 3 TUTTA LA GERARCHIA
    List<String> confControl = new ArrayList<String>();
    confControl.add("titleManager");
    confControl.add("upload");
    confControl.add("media");

    String PDFXSLType = MyRequest.getParameter("PDFXSLType", parameterMap); // NOME FILE XSL
    InputStream xsltInputStream = null;
    InputStream xmlInputStream = null;
    try {
      // ManagingBean esiste in sessione ma io uso uno nuovo per le funzioni di gestione
      managingBean = new ManagingBean();
      UserBean userBean = (UserBean) modelMap.get("userBean");
      confBean = (ConfBean) modelMap.get("confBean");
      WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      httpSession = workFlowBean.getRequest().getSession(false);
      xwconn = connectionManager.getConnection(workFlowBean.getArchive());
      XMLBuilder theXMLDoc = null;
      if (!applyTo.equals("fromQuery")) {
        managingBean.setPhysDoc(Integer.parseInt(physDoc));
        String docXML = xwconn.getSingleXMLFromNumDoc(managingBean.getPhysDoc());
        managingBean.setDocXML(docXML);
        theXMLDoc = new XMLBuilder(managingBean.getDocXML(), "ISO-8859-1");
      } else {
        theXMLDoc = new XMLBuilder("root");
      }
      MultiEditingManager editingManager = new MultiEditingManager(parameterMap, confBean, userBean, workFlowBean);
      editingManager.setTheXML(theXMLDoc);
      confBean = editingManager.rewriteMultipleConf(confControl);
      XSLDir = findXSLPath(userBean, workFlowBean);
      if (XSLDir != null) {
        modelMap.put("XSLBeanArrayList", XSLLoader.loadXSL(XSLDir));
      } else {
        throw new Exception("Impostare pdfPrint.");
      }
      managingBean.setSelid(selid);
      // System.out.println("aaaaaaaaaaaaaaaaa 04");
      if (!physDoc.equals("") && makeAction.equals("")) {
        managingBean.setDocLowerBrother(xwconn.getNumDocNextBrother(managingBean.getPhysDoc()));
        managingBean.setDocUpperBrother(xwconn.getNumDocPreviousBrother(managingBean.getPhysDoc()));
        it.highwaytech.db.QueryResult qrHier = xwconn.getQRFromHier(managingBean.getPhysDoc(), true);
        managingBean.setNumElementiHier(qrHier.elements);
        it.highwaytech.db.QueryResult qrSons = xwconn.getSonsFromNumDoc(managingBean.getPhysDoc());
        managingBean.setNumElementiSons(qrSons.elements);
        if (!selid.equals("")) {
          it.highwaytech.db.QueryResult qr = xwconn.getQRFromSelId(selid);
          managingBean.setNumElementi(qr.elements);
        }
        managingBean.setTitle((xwconn.getTitle(xwconn.connection, xwconn.getTheDb(), managingBean.getPhysDoc())).getTitle());
        managingBean.setDispatchView("pdfMenu");
        if (httpSession.getAttribute(workFlowBean.getManagingBeanName()) != null) {
          ArrayList listDocs = ((ManagingBean) httpSession.getAttribute(workFlowBean.getManagingBeanName())).getListPhysDoc();
          if (listDocs != null && listDocs.size() > 0) {
            managingBean.setListPhysDoc(listDocs);
          }
        }
        // System.out.println("aaaaaaaaaaaaaaaaa 05");
      } else if (!physDoc.equals("") && makeAction.equals("true")) { // DO
        String PDFPhrase = null;
        String PDFNdoc = null;
        ArrayList elementiNum = new ArrayList();
        if (applyTo.equals("selected") || applyTo.equals("prevSibling") || applyTo.equals("nextSibling") || applyTo.equals("this")) {
          if (applyTo.equals("nextSibling")) {
            int theBrother = managingBean.getPhysDoc();
            while (theBrother > 0) {
              theBrother = xwconn.getNumDocNextBrother(theBrother);
              if (theBrother > 0) {
                elementiNum.add(new Integer(theBrother));
              }
            }
          } else if (applyTo.equals("prevSibling")) {
            int theBrother = managingBean.getPhysDoc();
            while (theBrother > 0) {
              theBrother = xwconn.getNumDocPreviousBrother(theBrother);
              if (theBrother > 0) {
                elementiNum.add(new Integer(theBrother));
              }
            }
          } else if (applyTo.equals("this")) {
            elementiNum.add(new Integer(physDoc));
          } else {// DA SELEZIONE MULTIPLA
            elementiNum = ((ManagingBean) httpSession.getAttribute(workFlowBean.getManagingBeanName())).getListPhysDoc();
          }

          // System.out.println("aaaaaaaaaaaaaaaaa 07");
          if (elementiNum.size() > 0) {
            String idXpath = MyRequest.getParameter("idXpath", parameterMap);// "/c/@id";
            if (idXpath == null) {
              throw new Exception("Impostare idXpath");
            }
            xwconn.setTitleRole("XML," + idXpath);
            QueryResult qrTempTo = new QueryResult();
            for (int a = 0; a < elementiNum.size(); a++) {
              try {
                int docCorrente = 0;
                try {
                  docCorrente = ((Integer) elementiNum.get(a)).intValue();
                } catch (Exception e) {
                  docCorrente = (Integer.parseInt((String) elementiNum.get(a)));
                }
                String idValue = ((xwconn.getTitle(xwconn.connection, xwconn.getTheDb(), docCorrente)).getTitle()).trim();
                if (!idValue.equals("")) {
                  QueryResult qrTempFrom = xwconn.getQRfromPhrase("[XML," + idXpath + "]=\"" + idValue + "\"");
                  // System.out.println("xdams - [INFO]  :::::::: phrase " + "[XML," + idXpath + "]=\"" + idValue + "\"");
                  // System.out.println("qrTempFrom.elements: " + qrTempFrom.elements);
                  if (qrTempFrom.elements > 0) {
                    xwconn.addToQueryResult(qrTempTo, qrTempFrom);
                  }

                }

              } catch (Exception e) {
                e.printStackTrace();
              }
            }
            xwconn.restoreTitleRole();
            PDFType = "4";
            if (qrTempTo != null && qrTempTo.elements > 0)
              PDFPhrase = qrTempTo.id;
          }

        } else {
          // System.out.println("aaaaaaaaaaaaaaaaa 08");
          if (applyTo.equals("selid")) {
            PDFPhrase = (xwconn.getQRFromSelId(selid)).id;
            PDFType = "4";
          } else if (applyTo.equals("hier")) {
            PDFType = "3";
            PDFNdoc = MyRequest.getParameter("physDoc", parameterMap);
          } else if (applyTo.equals("single")) {
            PDFType = "1";
            PDFNdoc = MyRequest.getParameter("physDoc", parameterMap);
          } else if (applyTo.equals("sons")) {
            PDFType = "2";
            PDFNdoc = MyRequest.getParameter("physDoc", parameterMap);
          } else if (applyTo.equals("fromQuery")) {
            if (MyRequest.getParameter("fromQuery", parameterMap).trim().equals("")) {
              throw new Exception("Impostare fromQuery");
            }
            PDFPhrase = (xwconn.getQRfromPhrase(MyRequest.getParameter("fromQuery", parameterMap), MyRequest.getParameter("sortQuery", parameterMap))).id;
            PDFType = "4";
          }
        }

        // System.out.println("aaaaaaaaaaaaaaaaa 09");
        managingBean.setExportXML(executePDFPrint(workFlowBean, xwconn, PDFPhrase, PDFNdoc, PDFType, PDFXSLType));

        String headerPDF = MyRequest.getParameter("headerPDF", parameterMap).trim();
        String footerPDF = MyRequest.getParameter("footerPDF", parameterMap).trim();
        String subtitlePDF = MyRequest.getParameter("subtitlePDF", parameterMap).trim();
        if (!headerPDF.equals("") || !footerPDF.equals("") || !subtitlePDF.equals("")) {
          try {
            StringBuffer stringBuffer = new StringBuffer(managingBean.getExportXML());
            String stringInsert = "<pdfPrint>" + "<header></header>" + "<footer></footer>" + "<subtitle></subtitle>" + "</pdfPrint>";
            stringInsert = StringUtils.replace(stringInsert, "<header></header>", "<header>" + headerPDF + "</header>");
            stringInsert = StringUtils.replace(stringInsert, "<footer></footer>", "<footer>" + footerPDF + "</footer>");
            stringInsert = StringUtils.replace(stringInsert, "<subtitle></subtitle>", "<subtitle>" + subtitlePDF + "</subtitle>");
            // questo indexOf fa cagare
            stringBuffer.insert(managingBean.getExportXML().indexOf("\">") + 2, stringInsert);
            managingBean.setExportXML(stringBuffer.toString());
          } catch (Exception e) {
            e.printStackTrace();
          }

        }
        // System.out.println("aaaaaaaaaaaaaaaaa 10 "+managingBean.getExportXML());
        ManagingBean sessionMenaging = (ManagingBean) httpSession.getAttribute(workFlowBean.getManagingBeanName());
        System.out.println("aaaaaaaaaaaaaaaaa 11");
        // sessionMenaging.setListPhysDoc(new ArrayList()); // SVUOTO GLI ELEMENTI SELEZIONATI
        if (managingBean.getExportXML() != null && !(managingBean.getExportXML()).equals("")) { // STAMPO PDF
          // InputStream
          xsltInputStream = new FileInputStream(new File((XSLDir) + "/" + MyRequest.getParameter("PDFXSLType", parameterMap)));
View Full Code Here

  public ManagingBean execute() throws Exception {
    XWConnection xwconn = null;
    ConnectionManager connectionManager = new ConnectionManager();
    ConfBean confBean = null;
    ManagingBean managingBean = null;
   
    String physDoc = MyRequest.getParameter("physDoc", parameterMap);
     String makeAction = MyRequest.getParameter("makeAction", parameterMap);
    String sortingCriteria = MyRequest.getParameter("sortingCriteria", parameterMap);
    
    List<String> confControl = new ArrayList<String>();
    confControl.add("titleManager");
    confControl.add("docEdit");
    try {
      UserBean userBean = (UserBean) modelMap.get("userBean");
      confBean = (ConfBean) modelMap.get("confBean");
      WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      xwconn = connectionManager.getConnection(workFlowBean.getArchive());
      MultiEditingManager editingManager = new MultiEditingManager(parameterMap, confBean, userBean, workFlowBean);
      editingManager.setTheXML(new XMLBuilder(xwconn.getSingleXMLFromNumDoc(Integer.parseInt(physDoc)), "ISO-8859-1"));     
      confBean = editingManager.rewriteMultipleConf(confControl);
      managingBean = new ManagingBean();
      if (!physDoc.equals("") && makeAction.equals("")) {
        it.highwaytech.db.QueryResult qr = xwconn.getSonsFromNumDoc(Integer.parseInt(physDoc));
        managingBean.setTitle((xwconn.getTitle(xwconn.connection, xwconn.getTheDb(), Integer.parseInt(physDoc))).getTitle());
        managingBean.setNumElementi(qr.elements);
        managingBean.setDispatchView("sortingMenu");
        managingBean.setPhysDoc(Integer.parseInt(physDoc));
      } else if (!physDoc.equals("") && makeAction.equals("true")) {
        it.highwaytech.db.QueryResult qr = xwconn.getSonsFromNumDoc(Integer.parseInt(physDoc));
        qr = xwconn.selectQR("[?SEL]=\"" + qr.id + "\"", sortingCriteria, it.highwaytech.broker.ServerCommand.find_SORT, 0);
        managingBean.setTitle((xwconn.getTitle(xwconn.connection, xwconn.getTheDb(), Integer.parseInt(physDoc))).getTitle());
        managingBean.setNumElementi(qr.elements);
        managingBean.setDispatchView("sortingResult");
        managingBean.setPhysDoc(Integer.parseInt(physDoc));
        int totElementi = qr.elements;
        int processati = 0;
        int errori = 0;
        for (int i = 0; i < totElementi; i++) {
          int docCorrente = xwconn.getNumDocFromQRElement(qr, i);
          try {
            // gestire con framework
            xwconn.docRelDelete(xwconn.connection, workFlowBean.getAlias(), it.highwaytech.broker.ServerCommand.navigarel_FIGLIOPADRE, docCorrente, managingBean.getPhysDoc());
            xwconn.docRelInsert(xwconn.connection, workFlowBean.getAlias(), it.highwaytech.broker.ServerCommand.navigarel_FIGLIOPADRE, docCorrente, managingBean.getPhysDoc());
            processati++;
          } catch (Exception e) {
            xwconn.docRelInsert(xwconn.connection, workFlowBean.getAlias(), it.highwaytech.broker.ServerCommand.navigarel_FIGLIOPADRE, docCorrente, 1);
            managingBean.addErrorMsg(e.getMessage());
            errori++;
          }
        }
        managingBean.setDocSuccessi(processati);
        managingBean.setDocErrori(errori);
      }

      modelMap.put("confBean", confBean);
      modelMap.put("managingBean", managingBean);
    } catch (Exception e) {
View Full Code Here

  public ManagingBean execute() throws Exception {
    XWConnection xwconn = null;
    ConnectionManager connectionManager = new ConnectionManager();
    ConfBean confBean = null;
    ManagingBean managingBean = null;
    String physDoc =  MyRequest.getParameter("physDoc", parameterMap);//myRequest.getParameter("physDoc");
    String makeAction = MyRequest.getParameter("makeAction", parameterMap);//myRequest.getParameter("makeAction");
    String codiceId = MyRequest.getParameter("codiceId", parameterMap);//myRequest.getParameter("codiceId");
    String numZeri = MyRequest.getParameter("numZeri", parameterMap);//myRequest.getParameter("numZeri");
    String theValue = MyRequest.getParameter("theValue", parameterMap);//myRequest.getParameter("theValue");
    String applyTo = MyRequest.getParameter("applyTo", parameterMap);//myRequest.getParameter("applyTo");
    String selid = MyRequest.getParameter("selid", parameterMap);//myRequest.getParameter("selid");
    boolean countBlock = false;
    try {
      if (MyRequest.getParameter("countBlock", parameterMap).equals("on")) {
        countBlock = true;
      }
    } catch (Exception e) {
      // TODO: handle exception
    }
    HttpSession httpSession = null; //aReq.getSession(false);
    List<String> confControl = new ArrayList<String>();
    confControl.add("titleManager");
    confControl.add("docEdit");
    try {

      managingBean = new ManagingBean();
      UserBean userBean = (UserBean) modelMap.get("userBean");
      confBean = (ConfBean) modelMap.get("confBean");
      WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      httpSession = workFlowBean.getRequest().getSession(false);
      xwconn = connectionManager.getConnection(workFlowBean.getArchive());

      MultiEditingManager editingManager = new MultiEditingManager(parameterMap, confBean, userBean, workFlowBean);
      editingManager.setTheXML(new XMLBuilder(xwconn.getSingleXMLFromNumDoc(Integer.parseInt(physDoc)), "ISO-8859-1"));
      confBean = editingManager.rewriteMultipleConf(confControl);
      managingBean.setSelid(selid);
      if (!physDoc.equals("") && makeAction.equals("true")) { // DO
        managingBean.setPhysDoc(Integer.parseInt(physDoc));
        ArrayList elementiNum = new ArrayList();
        if (applyTo.equals("selected") || applyTo.equals("prevSibling") || applyTo.equals("nextSibling")) {
          if (applyTo.equals("nextSibling")) {
            int theBrother = managingBean.getPhysDoc();
            RenumberUtils.Renumber rn = RenumberUtils.getSiblingRenumber(theValue, 1);
            while (theBrother > 0) {
              theBrother = xwconn.getNumDocNextBrother(theBrother);
              if (theBrother > 0) {
                Object[] value = new Object[2];
                value[0] = new Integer(theBrother);
                value[1] = rn.renumber();
                elementiNum.add(value);
              }
            }
          } else if (applyTo.equals("prevSibling")) {
            int theBrother = managingBean.getPhysDoc();
            RenumberUtils.Renumber rn = RenumberUtils.getSiblingRenumber(theValue, -1, Integer.parseInt(numZeri));
            while (theBrother > 0) {
              theBrother = xwconn.getNumDocPreviousBrother(theBrother);
              if (theBrother > 0) {
                Object[] value = new Object[2];
                value[0] = new Integer(theBrother);
                value[1] = rn.renumber();
                // elementiNum.add(new Integer(theBrother));
                elementiNum.add(value);
              }
            }
          } else {// DA SELEZIONE MULTIPLA
            RenumberUtils.Renumber rn = RenumberUtils.getSiblingRenumber(theValue, 1, Integer.parseInt(numZeri));
            ArrayList elementiNumTemp = ((ManagingBean) httpSession.getAttribute(workFlowBean.getManagingBeanName())).getListPhysDoc();
            for (int i = 0; i < elementiNumTemp.size(); i++) {
              Object[] value = new Object[2];
              value[0] = (Integer) (elementiNumTemp.get(i));
              value[1] = rn.renumber();
              elementiNum.add(value);
            }
          }
        } else {
          it.highwaytech.db.QueryResult qr = null;
          if (applyTo.equals("selid")) {
            qr = xwconn.getQRFromSelId(selid);
            RenumberUtils.Renumber rn = RenumberUtils.getSiblingRenumber(theValue, 1, Integer.parseInt(numZeri));

            for (int z = 0; z < qr.elements; z++) {
              int theNumber = xwconn.getNumDocFromQRElement(qr, z);
              Object[] value = new Object[2];
              value[0] = new Integer(theNumber);
              value[1] = rn.renumber();

              elementiNum.add(value);
            }
          } else if (applyTo.equals("sons")) {
            qr = xwconn.getSonsFromNumDoc(managingBean.getPhysDoc());
            RenumberUtils.Renumber rn = RenumberUtils.getSonsRenumber(theValue, Integer.parseInt(numZeri));

            for (int z = 0; z < qr.elements; z++) {
              int theNumber = xwconn.getNumDocFromQRElement(qr, z);
              Object[] value = new Object[2];
              value[0] = new Integer(theNumber);
              value[1] = rn.renumber();

              elementiNum.add(value);
            }
          } else if (applyTo.equals("hier")) {
            RenumberUtils.Renumber rn = RenumberUtils.getHierRenumber(theValue, Integer.parseInt(numZeri));

            qr = xwconn.getQRFromHier(managingBean.getPhysDoc(), true);
            for (int i = 0; i < qr.elements; i++) {
              int theNumber = xwconn.getNumDocFromQRElement(qr, i);
              int tmpLevel = (xwconn.getHierPath(theNumber)).depth();
              System.out.println("MultiModRenumberCommand.execute() " + tmpLevel);
              Object[] value = new Object[2];
              value[0] = new Integer(theNumber);
              value[1] = rn.renumber(tmpLevel, countBlock);
              elementiNum.add(value);
            }
          }
        }
        managingBean.setNumElementi(elementiNum.size());
        managingBean.setTitle((xwconn.getTitle(xwconn.connection, xwconn.getTheDb(), Integer.parseInt(physDoc))).getTitle());
        managingBean.setDispatchView("multiModResult");
        int totElementi = elementiNum.size();
        int processati = 0;
        int errori = 0;
        // HashMap laMappa = new HashMap();
        for (int i = 0; i < totElementi; i++) {
          int docCorrente = 0;
          try {
            docCorrente = ((Integer) (((Object[]) elementiNum.get(i))[0])).intValue();
          } catch (Exception e) {
            docCorrente = (Integer.parseInt((String) elementiNum.get(i)));
          }
          try {
             String docXML = xwconn.getSingleXMLFromNumDoc(docCorrente);
            XMLBuilder xmlBuilder = new XMLBuilder(docXML, "ISO-8859-1");
            String codiceGenerato = ((String) (((Object[]) elementiNum.get(i))[1]));
            xmlBuilder.insertValueAt(codiceId, codiceGenerato);
            xwconn.executeUpdateByDocNumber(xmlBuilder.getXML("ISO-8859-1"), docCorrente);
            processati++;
          } catch (Exception e) {
            managingBean.addErrorMsg(e.getMessage());
            errori++;
          }
        }
        managingBean.setDocSuccessi(processati);
        managingBean.setDocErrori(errori);
      }
      modelMap.put("confBean", confBean);
      modelMap.put("managingBean", managingBean);
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

    String pos = MyRequest.getParameter("pos", parameterMap);
    String docXML = MyRequest.getParameter("docXML", parameterMap);
    XWConnection xwconn = null;
    ConnectionManager connectionManager = new ConnectionManager();
    ConfBean confBean = null;
    ManagingBean managingBean = null;
    List<String> confControl = new ArrayList<String>();
    confControl.add("titleManager");
    try {
      managingBean = new ManagingBean();
      // TODO Da rivedere
      managingBean.setXmlInteraction(xmlInteraction);
      managingBean.setSelid(selid);
      UserBean userBean = (UserBean) modelMap.get("userBean");
      confBean = (ConfBean) modelMap.get("confBean");
      WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      if (!physDoc.equals("") && makeAction.equals("")) {
        xwconn = connectionManager.getConnection(workFlowBean.getArchive());
        managingBean.setPhysDoc(Integer.parseInt(physDoc));
        managingBean.setTitle((xwconn.getTitle(xwconn.connection, xwconn.getTheDb(), Integer.parseInt(physDoc))).getTitle());
        String docXmlToSet = xwconn.getSingleXMLFromNumDoc(managingBean.getPhysDoc());
        docXmlToSet = XMLCleaner.clearXwXML(docXmlToSet, true);
        if (xmlInteraction.equals("view")) {
          XMLBuilder parsedBuilder = new XMLBuilder(docXmlToSet, "ISO-8859-1");
          docXmlToSet = parsedBuilder.getXML("ISO-8859-1");
          docXmlToSet = docXmlToSet.replaceAll("<", "&#60;");
          docXmlToSet = docXmlToSet.replaceAll(">", "&#62;");
          docXmlToSet = docXmlToSet.replaceAll("\t", "&#160;&#160;&#160;");
          docXmlToSet = docXmlToSet.replaceAll("\n", "<br>");
        } else {
          XMLBuilder parsedBuilder = new XMLBuilder(docXmlToSet, "ISO-8859-1");
          docXmlToSet = parsedBuilder.getXML("ISO-8859-1");
        }
        managingBean.setDocXML(docXmlToSet);
        managingBean.setDocLowerBrother(xwconn.getNumDocNextBrother(managingBean.getPhysDoc()));
        managingBean.setDocUpperBrother(xwconn.getNumDocPreviousBrother(managingBean.getPhysDoc()));
        managingBean.setDocFather(xwconn.getNumDocFather(managingBean.getPhysDoc()));
        managingBean.setDocFirstSon(xwconn.getNumDocFirstSon(managingBean.getPhysDoc()));
        managingBean.setPos(pos);
        if (!selid.equals("")) {
          it.highwaytech.db.QueryResult qr = xwconn.getQRFromSelId(selid);
          managingBean.setNumElementi(qr.elements);
        }
        int posInt = -1;
        try {
          posInt = Integer.parseInt(managingBean.getPos());
        } catch (Exception e) {
          posInt = -1;
        }
        if (posInt > 0) {
          managingBean.setDocPrev(posInt - 1);
        } else {
          managingBean.setDocPrev(-1);
        }
        if (posInt < (managingBean.getNumElementi() - 1)) {
          managingBean.setDocNext(posInt + 1);
        } else {
          managingBean.setDocNext(-1);
        }
        managingBean.setDispatchView("xmlMenu");

      } else if (!physDoc.equals("") && makeAction.equals("true")) { // DO
        xwconn = connectionManager.getConnection(workFlowBean.getArchive());
        managingBean.setPhysDoc(Integer.parseInt(physDoc));
        managingBean.setDispatchView("xmlResult");
        int processati = 0;
        int errori = 0;
        try {
          docXML = docXML.replaceAll("&", "&amp;");
          docXML = docXML.replaceAll("&amp;#", "&#");
          XMLBuilder xmlBuilder = new XMLBuilder(docXML, "ISO-8859-1");
          OutputFormat outputFormat = new OutputFormat();
          outputFormat.setEncoding("ISO-8859-1");
          outputFormat.setIndent(true);
          outputFormat.setIndentSize(0);
          outputFormat.setNewlines(true);
          // outputFormat.setTrimText(true);
          xwconn.executeUpdateByDocNumber(XMLCleaner.clearXwXML(xmlBuilder.getXML(outputFormat), false), managingBean.getPhysDoc());
          processati++;
        } catch (Exception e) {
          managingBean.addErrorMsg(e.getMessage());
          errori++;
        }
        managingBean.setTitle((xwconn.getTitle(xwconn.connection, xwconn.getTheDb(), managingBean.getPhysDoc())).getTitle());
        managingBean.setDocSuccessi(processati);
        managingBean.setDocErrori(errori);
      }

      MultiEditingManager editingManager = new MultiEditingManager(parameterMap, confBean, userBean, workFlowBean);
      editingManager.setTheXML(new XMLBuilder(xwconn.getSingleXMLFromNumDoc(managingBean.getPhysDoc()), "ISO-8859-1"));
      confBean = editingManager.rewriteMultipleConf(confControl);

      modelMap.put("confBean", confBean);
      modelMap.put("managingBean", managingBean);
    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.xdams.page.view.bean.ManagingBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.