Package org.xdams.xw

Examples of org.xdams.xw.XWConnection


    this.parameterMap = parameterMap;
    this.modelMap = modelMap;
  }

  public void execute() throws Exception {
    XWConnection xwconn = null;
    ConnectionManager connectionManager = new ConnectionManager();
    ConfBean confBean = null;
    String physDoc = MyRequest.getParameter("physDoc", parameterMap);
    String titleRule = "";
    List<String> confControl = new ArrayList<String>();
    confControl.add("docEdit");
    confControl.add("valoriControllati");
    try {
      UserBean userBean = (UserBean) modelMap.get("userBean");
      confBean = (ConfBean) modelMap.get("confBean");
      WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      xwconn = connectionManager.getConnection(workFlowBean.getArchive());
      XMLBuilder builderDoc = null;
      if (physDoc == null || physDoc.equals("") || physDoc.equals("-1")) {
        builderDoc = new XMLBuilder("root");
      } else {
        builderDoc = new XMLBuilder(xwconn.getSingleXMLFromNumDoc(Integer.parseInt(physDoc)), "ISO-8859-1");
      }

      MultiEditingManager editingManager = new MultiEditingManager(parameterMap, confBean, userBean, workFlowBean);
      editingManager.setTheXML(builderDoc);
      confBean = editingManager.rewriteMultipleConf(confControl);

      int newNrecord = 0;
      int relation = 0;
      int firstRecord = -1;
      if (!(MyRequest.getParameter("relation", parameterMap)).equals("")) {
        relation = Integer.parseInt(MyRequest.getParameter("relation", parameterMap));
      }

      // String theArch = myRequest.getParameter("db");
      String pne = workFlowBean.getArchive().getPne();
      String dataCompilatoreCMPN = DateUtil.getDataSystem("dd/MM/yyyy");
      String nomeCompilatoreCMPN = userBean.getName() + " " + userBean.getLastName();

      int relatedPhysDoc = 0;
      int elementiMultipli = 0;

      if (MyRequest.getParameter("elementiMultipli", parameterMap).equals("")) {
        elementiMultipli = 1;
      } else {
        elementiMultipli = Integer.parseInt(MyRequest.getParameter("elementiMultipli", parameterMap));
      }
      if (!MyRequest.getParameter("relatedPhysDoc", parameterMap).equals("")) {
        relatedPhysDoc = Integer.parseInt(MyRequest.getParameter("relatedPhysDoc", parameterMap));
      }
      String[] nomiRequest = MyRequest.ordinaRequest(workFlowBean.getRequest(), "." + pne + ".");
      // HashMap laMappa = new HashMap();
      SharpIncrementTool sharpIncrementTool = new SharpIncrementTool();
      for (int cicli = 0; cicli < elementiMultipli; cicli++) {
        /* ordino la request e creo l'XML */
        XMLBuilder builder = new XMLBuilder(pne);
        for (int i = 0; i < nomiRequest.length; i++) {
          String ilNome = nomiRequest[i].replace('.', '/');
          String ilValore = (workFlowBean.getRequest().getParameter(nomiRequest[i])).trim();
          // System.out.println("ilNome=" + ilNome + " -- ilValore=" + ilValore + " ---");
          // System.out.println("elementiMultipli=" + elementiMultipli + " ---");
          // System.out.println("ilValore.indexOf(\"[#\") > 0 " + (ilValore.indexOf("[#") > 0));
          // System.out.println("ilValore.indexOf(\"#]\") > 0 " + (ilValore.indexOf("#]") > 0));
          // System.out.println("elementiMultipli > 1 " + (elementiMultipli > 1));
          if (!ilValore.equals("")) {
            try {
              if ((ilValore.indexOf("[#") != -1) && (ilValore.indexOf("#]") > 0) && (elementiMultipli > 0)) {
                ilValore = sharpIncrementTool.incrementValue(ilNome, ilValore);// ilValoreIni + contatoreMultiplo + ilValoreFin;
              }
            } catch (Exception eee) {

            } finally {
              if (ilNome.endsWith("/@cdata")) {
                ilNome = StringUtils.chomp(ilNome, "/@cdata");
                builder.insertNode(ilNome, ilValore, true);
              } else {
                builder.insertNode(ilNome, ilValore); // QUI INSERISCO IL VERO VALORE
              }

            }
          }
        }

        /* fine ordino la request e creo l'XML */
        XMLBuilder theXMLconf = confBean.getTheXMLConfEditing();

        for (int a = 0; a < theXMLconf.contaNodi("/root/fixedValues/cdata/elemento"); a++) {
          String ilNodoCorrente = theXMLconf.valoreNodo("/root/fixedValues/cdata/elemento[" + (a + 1) + "]/@path");
          String ilValoreCorrente = theXMLconf.valoreNodo("/root/fixedValues/cdata/elemento[" + (a + 1) + "]/text()");
          ilValoreCorrente = ilValoreCorrente.replaceAll(" ", "_");
          ilValoreCorrente = ilValoreCorrente.replaceAll("<", "-");
          ilValoreCorrente = ilValoreCorrente.replaceAll(">", "-");
          if (ilNodoCorrente.endsWith("/@cdata")) {
            ilNodoCorrente = StringUtils.chomp(ilNodoCorrente, "/@cdata");
            builder.insertNode(ilNodoCorrente, ilValoreCorrente, true);
          } else {
            builder.insertNode(ilNodoCorrente, ilValoreCorrente); // QUI INSERISCO IL VERO VALORE
          }
          // builder.insertNode(ilNodoCorrente, ilValoreCorrente);
        }
        if (!(theXMLconf.valoreNodo("/root/fixedValues/text()")).equals("")) {
          builder.insertNode("/" + xwconn.getPne() + "/text()", theXMLconf.valoreNodo("/root/fixedValues/text()"));
        }

        titleRule = theXMLconf.valoreNodo("/root/param/elemento[@id='codice_identificativo' and @auto_increment='true']/@titleRule");
        // gestione generazione unitid
        if (!titleRule.equals("")) {
          String unitid = "";
          String newUnitid = "";
          String fatherUnitid = "";
          try {

            it.highwaytech.db.QueryResult qr = null;
            int docFather = 0;
            if ((MyRequest.getParameter("relation", parameterMap)).equals("1")) {
              docFather = Integer.parseInt(MyRequest.getParameter("relatedPhysDoc", parameterMap));
            }
            if ((MyRequest.getParameter("relation", parameterMap)).equals("2") || (MyRequest.getParameter("relation", parameterMap)).equals("4")) {
              docFather = Integer.parseInt(MyRequest.getParameter("relatedPhysDoc", parameterMap));
              docFather = xwconn.getNumDocFather(docFather);
            }
            qr = xwconn.findSons(xwconn.connection, xwconn.getTheDb(), docFather);
            xwconn.setTitleRule(xwconn.connection, xwconn.getTheDb(), titleRule);
            fatherUnitid = xwconn.getTitle(xwconn.connection, xwconn.getTheDb(), docFather).getTitle();

            if (qr.elements > 0) {
              int prossimoNumero = 0;
              int precedenteNumero = 0;

              if (true || MyRequest.getParameter("generaUnitidMode", parameterMap).equals("1")) {
                it.highwaytech.db.Title ilTitoloElemento = xwconn.getTitle(xwconn.connection, xwconn.getTheDb(), xwconn.getNumDocFromQRElement(qr, qr.elements - 1));
                unitid = ilTitoloElemento.getTitle();
                newUnitid = unitid.substring(unitid.lastIndexOf(".") + 1);
                prossimoNumero = qr.elements + 1;
              }
              /*
               * if (myRequest.getParameter("generaUnitidMode").equals("2")) { for (int z = 0; z < qr.elements; z++) { it.highwaytech.db.Title ilTitoloElemento = xwconn.getTitle(xwconn.connection, xwconn.getTheDb(), xwconn.getNumDocFromQRElement(qr, z)); unitid =
               * ilTitoloElemento.getTitle(); newUnitid = unitid.substring(unitid.lastIndexOf(".") + 1); prossimoNumero = Integer.parseInt(newUnitid); prossimoNumero++; if (prossimoNumero == (precedenteNumero + 1)) { precedenteNumero = prossimoNumero; if (z == qr.elements - 1) {
               * prossimoNumero = qr.elements + 1; break; } else { prossimoNumero = qr.elements + 1; break; } } else { if (prossimoNumero > precedenteNumero) { prossimoNumero++; break; } else { prossimoNumero = qr.elements + 1; break; } } } }
               */

              newUnitid = String.valueOf(prossimoNumero);
              for (int x = (String.valueOf(prossimoNumero)).length(); x < 5; x++) {
                newUnitid = "0" + newUnitid;
              }
              unitid = fatherUnitid + "." + newUnitid;
            } else {
              if (!fatherUnitid.equals("")) {
                unitid = fatherUnitid + ".00001";
              } else {
                unitid = "00001";
              }

            }

          } catch (Exception e) {
            xwconn.restoreTitleRole();
            e.printStackTrace();
          }

          try {
            if (!(theXMLconf.valoreNodo("/root/param/elemento[@id='codice_identificativo' and @auto_increment='true']/text()")).equals(""))
              builder.insertNode(theXMLconf.valoreNodo("/root/param/elemento[@id='codice_identificativo' and @auto_increment='true']/text()"), unitid);
          } catch (Exception e) {
            e.printStackTrace();
          }
        }

        /*
         * for (int a = 0; a < theXMLconf.contaNodi("//fixedValues/elemento"); a++) { String ilNodoCorrente = theXMLconf.valoreNodo("//fixedValues/elemento[" + (a + 1) + "]/text()"); String ilValoreCorrente = theXMLconf.valoreNodo("//fixedValues/elemento[" + (a + 1) + "]/@value");
         * builder.insertNode(ilNodoCorrente, ilValoreCorrente); }
         */

        String theXML = builder.getXML("ISO-8859-1");

        for (int a = 0; a < theXMLconf.contaNodi("/root/fixedValues/cdata/elemento"); a++) {
          String ilValoreCorrente = theXMLconf.valoreNodo("/root/fixedValues/cdata/elemento[" + (a + 1) + "]/text()");
          ilValoreCorrente = ilValoreCorrente.replaceAll(" ", "_");
          ilValoreCorrente = ilValoreCorrente.replaceAll("<", "-");
          ilValoreCorrente = ilValoreCorrente.replaceAll(">", "-");
          theXML = theXML.replaceAll(ilValoreCorrente, theXMLconf.valoreNodo("//fixedValues/cdata/elemento[" + (a + 1) + "]/text()"));
        }
        // gestione del nome del fondo
        theXML = theXML.replaceAll("@nomeFondo@", workFlowBean.getArchive().getArchiveDescr());
        // ArchiviBean archiviBean = userBean.getArchiviBeanFromAliasDb(MyRequest.getParameter("db_name_orig", parameterMap));
        // System.out.println("INSERT RECORD myRequest.getParameter(\"db_name_orig\") " + myRequest.getParameter("db_name_orig"));
        // System.out.println("INSERT RECORD archiviBean " + archiviBean);
        // System.out.println("INSERT RECORD archiviBean.getAliasDb() " + archiviBean.getAliasDb());
        // System.out.println("INSERT RECORD archiviBean.getDescrArchivio() " + archiviBean.getDescrArchivio());
        String archivioDaCuiInserisce = "";
        String archivioAbbreviatoDaCuiInserisce = "";

        if (!MyRequest.getParameter("srcArchive", parameterMap).equals("")) {
          Archive srcArchive = ServiceUser.getArchive(userBean, MyRequest.getParameter("srcArchive", parameterMap));
          archivioAbbreviatoDaCuiInserisce = srcArchive.getArchiveDescr();
          archivioDaCuiInserisce = srcArchive.getAlias();
        }

        // gestione di processinfo
        theXML = theXML.replaceAll("@coluiCheInserisce@", nomeCompilatoreCMPN);
        theXML = theXML.replaceAll("@quandoColuiInserisce@", dataCompilatoreCMPN);
        theXML = theXML.replaceAll("@archivioAbbreviatoDaCuiInserisce@", archivioAbbreviatoDaCuiInserisce);
        theXML = theXML.replaceAll("@archivioDaCuiInserisce@", archivioDaCuiInserisce);
        // inizio inserimento del record
        try {
          System.out.println("insert " + theXML);
          newNrecord = xwconn.insert(theXML);
          if (firstRecord == -1) {
            firstRecord = newNrecord;
          }
          if (relatedPhysDoc > 0 && relation > 0) {

            if ((MyRequest.getParameter("relation", parameterMap)).equals("4")) {
              xwconn.docRelInsert(xwconn.connection, xwconn.getTheDb(), relation, relatedPhysDoc, newNrecord);
              relatedPhysDoc = newNrecord;
            } else {
              xwconn.docRelInsert(xwconn.connection, xwconn.getTheDb(), relation, relatedPhysDoc, newNrecord);
            }
          }

          /**/

        } catch (Exception e) {
          e.printStackTrace();
        }

      }

      modelMap.put("confBean", confBean);
      modelMap.put("physDoc", String.valueOf(firstRecord));
    } catch (Exception e) {
      e.printStackTrace();
      throw new Exception(e.toString());
    } finally {
      if (!titleRule.equals("")) {
        try {
          xwconn.restoreTitleRule(xwconn.connection, xwconn.getTheDb());
        } catch (Exception e) {
          // TODO: handle exception
        }
      }
      connectionManager.closeConnection(xwconn);
View Full Code Here


    this.parameterMap = parameterMap;
    this.modelMap = modelMap;
  }

  public void execute() throws Exception {
    XWConnection xwconn = null;
    ConnectionManager connectionManager = new ConnectionManager();
    ConfBean confBean = null;
    QueryResult queryResult = null;
    HttpSession httpSession = null;
    String titleRole = "";
    List<String> confControl = new ArrayList<String>();
    confControl.add("titleManager");
    confControl.add("valoriControllati");
    confControl.add("query");
    String[] multiArchivedbNames = parameterMap.get("multiArchivedbName");
    try {
      UserBean userBean = (UserBean) modelMap.get("userBean");
      confBean = (ConfBean) modelMap.get("confBean");
      WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      httpSession = workFlowBean.getRequest().getSession(false);
      MultiEditingManager editingManager = new MultiEditingManager(parameterMap, confBean, userBean, workFlowBean);
      editingManager.setTheXML(new XMLBuilder("root"));
      confBean = editingManager.rewriteMultipleConf(confControl);
      // mettere queryBean
      System.out.println("QueryParserCommand.execute() workFlowBean.getAlias() " + workFlowBean.getAlias());
      System.out.println("QueryParserCommand.execute() aReq.getParameter(\"fromId\") " + workFlowBean.getRequest().getParameter("fromId") + "aaaaaaa");
      List<MultiArchiveBean> multiArchiveBeans = new ArrayList<MultiArchiveBean>();
      if (multiArchivedbNames != null) {
        for (int i = 0; i < multiArchivedbNames.length; i++) {
          try {
            MultiArchiveBean multiArchiveBean = new MultiArchiveBean();
            xwconn = connectionManager.getConnection(ServiceUser.getArchive(userBean, multiArchivedbNames[i]));
            FindDocumentCommand findDocumentCommand = null;
            findDocumentCommand = new FindDocumentCommand(parameterMap, modelMap);
            queryResult = findDocumentCommand.execute(workFlowBean, xwconn);
            QueryBean queryBean = new QueryBean();
            queryBean.setDb(workFlowBean.getAlias());
            System.out.println("findDocumentCommand.getLaFrase() " + findDocumentCommand.getLaFrase());
            System.out.println("findDocumentCommand.getLaFrase() " + findDocumentCommand.getLaFrase());
            System.out.println("findDocumentCommand.getLaFrase() " + findDocumentCommand.getLaFrase());
            System.out.println("findDocumentCommand.getLaFrase() " + findDocumentCommand.getLaFrase());
            System.out.println("findDocumentCommand.getLaFrase() " + findDocumentCommand.getLaFrase());
            queryBean.setQuery(findDocumentCommand.getLaFrase());
            queryBean.setTot(String.valueOf(queryResult.elements));
            multiArchiveBean.setArchive(ServiceUser.getArchive(userBean, multiArchivedbNames[i]));
            multiArchiveBean.setRecordFound((queryResult.elements));
            multiArchiveBeans.add(multiArchiveBean);
            if (httpSession.getAttribute("arrQueryBean" + multiArchivedbNames[i]) == null) {
              ArrayList arrQueryBean = new ArrayList();
              arrQueryBean.add(queryBean);
              httpSession.setAttribute("arrQueryBean" + multiArchivedbNames[i], arrQueryBean);
            } else {
              ArrayList arrQueryBean = (ArrayList) httpSession.getAttribute("arrQueryBean" + multiArchivedbNames[i]);
              boolean insert = true;
              int indexQr = 0;
              for (int z = 0; z < arrQueryBean.size(); z++) {
                QueryBean ilBean = (QueryBean) arrQueryBean.get(z);
                System.out.println("ilBean " + ilBean);
                System.out.println("queryBean " + queryBean);
                if (ilBean.getQuery().equals(queryBean.getQuery())) {
                  insert = false;
                  arrQueryBean.remove(z);
                  arrQueryBean.add(queryBean);
                  break;
                }
              }
              if (insert) {
                arrQueryBean.add(queryBean);
                httpSession.setAttribute("arrQueryBean" + multiArchivedbNames[i], arrQueryBean);
              }
              System.out.println("arrQueryBean " + arrQueryBean);
            }
            System.out.println("queryResult.elements: " + queryResult.elements + " " + xwconn.getTheDb());
          } catch (Exception e) {
            // TODO: handle exception
          } finally {
            connectionManager.closeConnection(xwconn);
          }
View Full Code Here

    this.parameterMap = parameterMap;
    this.modelMap = modelMap;
  }

  public void execute() throws Exception {
    XWConnection xwconn = null;
    ConfBean confBean = null;
    ConnectionManager connectionManager = new ConnectionManager();
    // questa lista pu essere presa da un file di configurazione
    List<String> confControl = new ArrayList<String>();
    confControl.add("query-multiarchive");
    confControl.add("valoriControllati");
    try {
      UserBean userBean = (UserBean) modelMap.get("userBean");
      confBean = (ConfBean) modelMap.get("confBean");
      WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      MultiEditingManager editingManager = new MultiEditingManager(parameterMap, confBean, userBean, workFlowBean);
      editingManager.setTheXML(new XMLBuilder("root"));
      confBean = editingManager.rewriteMultipleConf(confControl);
     
      confBean.setTheXMLConfQuery(confBean.getTheXMLConfQueryMultiArchive());
      QueryBean queryBean = new QueryBean();
      try {
        xwconn = connectionManager.getConnection(workFlowBean.getArchive());
        XMLBuilder theXMLconf = confBean.getTheXMLConfQuery();
        // System.out.println("theXMLconftheXMLconftheXMLconftheXMLconf " + theXMLconf);
        it.highwaytech.db.QueryResult qr = null;
        if (theXMLconf.valoreNodo("/root/query/@numDocInfoQuery").equals("")) {
          qr = xwconn.selectQR("([UD,/xw/@UdType/]=\"" + workFlowBean.getArchive().getPne() + "\")");
        } else {
          qr = xwconn.selectQR(theXMLconf.valoreNodo("/root/query/@numDocInfoQuery", false));
        }
        queryBean.setTotNumDoc(qr.elements);
        queryBean.setLastUpdate(xwconn.getLastUpdate());
      } catch (Exception e) {
        // TODO: handle exception
      }

      // System.out.println("QueryPageCommand.execute() " + confBean.getTheXMLConfQuery().getXML("ISO-8859-1"));
View Full Code Here

TOP

Related Classes of org.xdams.xw.XWConnection

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.