Package org.xdams.xw

Examples of org.xdams.xw.XWConnection


    this.res = res;
    this.modelMap = modelMap;
  }

  public AjaxBean execute() throws Exception {
    XWConnection xwconn = null;
    ConnectionManager connectionManager = new ConnectionManager();
    ConfBean confBean = null;
    WorkFlowBean workFlowBean = null;
    AjaxBean ajaxBean = new AjaxBean();
    String valori = "";
    List<String> confControl = new ArrayList<String>();
    confControl.add("titleManager");
    confControl.add("query");
    try {
      String physDoc = MyRequest.getParameter("numDoc", req.getParameterMap());
      UserBean userBean = (UserBean) modelMap.get("userBean");
      confBean = (ConfBean) modelMap.get("confBean");
      workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");

      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 (MyRequest.getParameter("calcButtons", req.getParameterMap()).equals("true")) {
        calcolaBottoni(xwconn, ajaxBean, physDoc);
        return ajaxBean;
      }
      QueryResult qr = xwconn.getQRFromHier(Integer.parseInt(physDoc), false);
      String extraQuery = confBean.getTheXMLConfQuery().valoreNodoNoEscape("/root/infoDoc/element[@type='extraQuery']/text()");
      // System.out.println("AjaxDocInfoCommand.execute() extraQuery " + extraQuery);
      if (!extraQuery.equals("")) {
        try {
          // System.out.println("AjaxDocInfoCommand.execute() extraQuery " + "([?SEL]=\"" + qr.id + "\") " + extraQuery);
          qr = xwconn.getQRfromPhrase("([?SEL]=\"" + qr.id + "\") " + extraQuery);
        } catch (Exception e) {
          System.out.println("ERRORE IN AjaxDocInfoCommand extraQuery " + "([?SEL]=\"" + qr.id + "\") " + extraQuery);
          System.out.println("ERRORE IN AjaxDocInfoCommand error " + e.getMessage());
        }

      }

      // ELEMENTI INFERIORI COLLEGATI
      if (qr.elements > 0) { /* se ha dei figli */
        valori += "<li>Elementi inferiori collegati: <strong>" + qr.elements + "</strong></li>";
        // QueryResult queryResult = xwconn.getQRFromHier(Integer.parseInt(physDoc),false);
        // // ELEMENTI INFERIORI COLLEGATI
        // if (queryResult.elements > 0) { /* se ha dei figli */
        // valori += "<li>Elementi figli di primo livello: <strong>" + queryResult.elements + "</strong></li>";
        // }
      }

      int numDocFather = xwconn.getNumDocFather(Integer.parseInt(physDoc));

      if (numDocFather > 0) {
        // POSIZIONE NEL RAMO
        int numDocSon = xwconn.getNumDocFirstSon(numDocFather);
        int count = 0;
        while (numDocSon != Integer.parseInt(physDoc)) {
          ++count;
          numDocSon = xwconn.getNumDocNextBrother(numDocSon);
        }
        valori += "<li>Posizione all'interno del ramo: <strong>" + (count + 1) + "</strong></li>";

        // LIVELLO DI PROFONDITA
        int depthLevel = 1;

        while ((numDocFather = xwconn.getNumDocFather(numDocFather)) > 0) {
          ++depthLevel;
        }

        valori += "<li>Livello di profondit&agrave;: <strong>" + depthLevel + "</strong></li>";
      }

      if (qr.elements > 0) { /*
                   * se ha dei figli CALCOLO ESTREMI CRONOLOGICI
                   */
        try {
          TitleManager titleManager = new TitleManager(confBean.getTheXMLConfTitle());
          String normalDatePath = confBean.getTheXMLConfQuery().valoreNodoNoEscape("/root/infoDoc/element[@type='normalDatePath']/text()");
          if (normalDatePath.equals("")) {
            normalDatePath = "/c/did/unittitle/unitdate";
          }
          String laSel = qr.id;
          String ilMaggiore = "";
          String ilMinore = "";
          String laFrase = "([?SEL]=\"" + laSel + "\") and not ([XML," + normalDatePath + "]=\"s.d.\")";
          String ordinamento = "";
          qr = xwconn.selectQR(laFrase);
          laSel = qr.id;
          java.util.Vector chiaviFrom = xwconn.selectFilteredKey(qr, "XML," + normalDatePath + "/#from", qr.elements, "down", "0");
          java.util.Vector chiaviTo = xwconn.selectFilteredKey(qr, "XML," + normalDatePath + "/#to", qr.elements, "up", "0");
          // System.out.println("chiaviFromchiaviFromchiaviFromchiaviFrom
          // "+chiaviFrom);
          // System.out.println("chiaviTochiaviTochiaviTochiaviTochiaviTo
          // "+chiaviTo);
          for (int i = 0; i < chiaviFrom.size(); i++) {
            Key key = (Key) chiaviFrom.elementAt(i);
            ilMinore = key.key.toString();
            if (!ilMinore.equals("00000000")) {
              break;
            }
          }

          for (int i = 0; i < chiaviTo.size(); i++) {
            Key key = (Key) chiaviTo.elementAt(i);
            ilMaggiore = key.key.toString();
          }

          laFrase = "([?SEL]=\"" + laSel + "\") and ([XML," + normalDatePath + "/#from]=\"" + ilMinore + "\")";
          ordinamento = "XML(xpart:" + normalDatePath + "/@normal)";
          qr = xwconn.selectQR(laFrase, ordinamento, it.highwaytech.broker.ServerCommand.find_SORT, -1);

          for (int i = 0; i < qr.elements; i++) {
            it.highwaytech.db.Title ilTitolo = xwconn.getTitle(xwconn.connection, xwconn.getTheDb(), qr, i);
            String ilTitoloString = ilTitolo.getTitle();
            String laData = titleManager.defaultParsedTitle(ilTitoloString, "dataTitle");
            if (!(laData.trim()).equals("")) {
              ilMinore = titleManager.defaultParsedTitle(ilTitoloString, "defaultTitle");
              break;
            }
          }

          laFrase = "([?SEL]=\"" + laSel + "\") and ([XML," + normalDatePath + "/#to]=\"" + ilMaggiore + "\")";
          ordinamento = "xml(xpart:" + normalDatePath + "/@normal)";
          qr = xwconn.selectQR(laFrase, ordinamento, it.highwaytech.broker.ServerCommand.find_SORT, -1);

          it.highwaytech.db.Title ilTitolo = xwconn.getTitle(xwconn.connection, xwconn.getTheDb(), qr, qr.elements - 1);
          String ilTitoloString = ilTitolo.getTitle();

          String laData = titleManager.defaultParsedTitle(ilTitoloString, "dataTitle");
          if (!(laData.trim()).equals("")) {
            ilMaggiore = titleManager.defaultParsedTitle(ilTitoloString, "defaultTitle");
View Full Code Here


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

  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 selid = MyRequest.getParameter("selid", parameterMap);
    String makeAction = MyRequest.getParameter("makeAction", parameterMap);
    String applyTo = MyRequest.getParameter("applyTo", parameterMap);
    String pos = MyRequest.getParameter("pos", parameterMap);
 
    HttpSession httpSession = null;
    List<String> confControl = new ArrayList<String>();
    confControl.add("titleManager");
    confControl.add("valoriControllati");
    confControl.add("managing");
    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);
      managingBean.setSelid(selid);
      MultiEditingManager editingManager = new MultiEditingManager(parameterMap, confBean, userBean, workFlowBean);
      // prendo i riferimenti al record
      if (!physDoc.equals("") && makeAction.equals("")) {
        xwconn = connectionManager.getConnection(workFlowBean.getArchive());
        managingBean.setPhysDoc(Integer.parseInt(physDoc));
        editingManager.setTheXML(new XMLBuilder(xwconn.getSingleXMLFromNumDoc(managingBean.getPhysDoc()), "ISO-8859-1"));
        confBean = editingManager.rewriteMultipleConf(confControl);
        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);

        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("eraseMenu");
        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
        xwconn = connectionManager.getConnection(workFlowBean.getArchive());
        managingBean.setPhysDoc(Integer.parseInt(physDoc));
        editingManager.setTheXML(new XMLBuilder(xwconn.getSingleXMLFromNumDoc(managingBean.getPhysDoc()), "ISO-8859-1"));
        confBean = editingManager.rewriteMultipleConf(confControl);
        ArrayList elementiNum = new ArrayList();
        if (applyTo.equals("selected") || applyTo.equals("prevSibling") || applyTo.equals("nextSibling")) {
          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 {// DA SELEZIONE MULTIPLA
            elementiNum = ((ManagingBean) httpSession.getAttribute(workFlowBean.getManagingBeanName())).getListPhysDoc();
          }

        } else {
          it.highwaytech.db.QueryResult qr = null;
          if (applyTo.equals("selid")) {
            qr = xwconn.getQRFromSelId(selid);
            for (int z = 0; z < qr.elements; z++) {
              int theNumber = xwconn.getNumDocFromQRElement(qr, z);
              elementiNum.add(new Integer(theNumber));
            }
          } else if (applyTo.equals("hier") || applyTo.equals("hierfalse")) {
            boolean includeFather = true;
            if (applyTo.equals("hierfalse")) {
              includeFather = false;
            }
            qr = xwconn.getQRFromHier(managingBean.getPhysDoc(), includeFather);
            managingBean.setNumElementi(qr.elements);
            xwconn.deleteHier(managingBean.getPhysDoc());
            managingBean.setDocSuccessi(-100);
            managingBean.setDocErrori(-100);
          }

        }
        if (!applyTo.equals("hier") && !applyTo.equals("hierfalse")) {
          for (int i = 0; i < elementiNum.size(); i++) {
            QueryResult qrTemp = null;
            try {
              qrTemp = xwconn.getQRFromHier(((Integer) elementiNum.get(i)).intValue(), false);
            } catch (Exception e) {
              qrTemp = xwconn.getQRFromHier(Integer.parseInt((String) elementiNum.get(i)), false);
            }
            if (qrTemp != null && qrTemp.elements > 0) {
              for (int z = 0; z < qrTemp.elements; z++) {
                int theNumber = xwconn.getNumDocFromQRElement(qrTemp, z);
                elementiNum.add(new Integer(theNumber));
              }
            }
          }
          managingBean.setNumElementi(elementiNum.size());
          int totElementi = elementiNum.size();
          int processati = 0;
          int errori = 0;

          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 {
              xwconn.delete(docCorrente);
              processati++;
            } catch (Exception e) {
              managingBean.addErrorMsg(e.getMessage());
              errori++;
            }
View Full Code Here

    this.res = res;
    this.modelMap = modelMap;
  }

  public AjaxBean execute() throws Exception {
    XWConnection xwconn = null;
    ConnectionManager connectionManager = new ConnectionManager();
    ConfBean confBean = null;
    AjaxBean ajaxBean = new AjaxBean();
    String laChiave = MyRequest.getParameter("key", req.getParameterMap());
    String ilValore = MyRequest.getParameter("value", req.getParameterMap());
    String filterQuery = MyRequest.getParameter("filterQuery", req.getParameterMap());
    WorkFlowBean workFlowBean = null;
    // System.out.println("AjaxCommandVocabolarioJson.execute() !!!" + ilValore+"!!!");
    // System.out.println("AjaxCommandVocabolarioJson.execute() " + ilValore);
    // System.out.println("AjaxCommandVocabolarioJson.execute() " + ilValore);
    // System.out.println("AjaxCommandVocabolarioJson.execute() " + ilValore);
    if (ilValore.trim().startsWith("\" ") && ilValore.trim().length() > 2) {
      ilValore = ilValore.substring(2, ilValore.length() - 1);
    }

    if (ilValore.trim().equals("") || ilValore.equals("*")) {
      ilValore = MyRequest.getParameter("attrFirstIdx", req.getParameterMap());
    }

    int numKeys = 10;
    try {
      numKeys = Integer.parseInt(MyRequest.getParameter("numKeys", req.getParameterMap()));
    } catch (Exception e) {
      // TODO: handle exception
    }
    boolean isQuery = false;

    String laTipologia = MyRequest.getParameter("typology", req.getParameterMap());
    String common = "";
    laChiave = laChiave.replaceAll("\\[", "").replaceAll("\\]", "");
    java.util.Vector result = null;
    byte ilByte = it.highwaytech.broker.ServerCommand.btree_FREQUENZE;
    byte ilByteVerso = it.highwaytech.broker.ServerCommand.btree_NEXTKEY;
    String verso = "up";

    boolean reverseMode = false;
    String valori = "";

    if (laTipologia.startsWith("double")) {
      common = " ";
    }
    if (laTipologia.startsWith("doubleQuery")) {
      isQuery = true;
    }

    if (laTipologia.indexOf("Reverse") > -1) {
      ilByteVerso = it.highwaytech.broker.ServerCommand.btree_PREVKEY;
      reverseMode = true;
      verso = "down";
    }

    try {
      workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      xwconn = connectionManager.getConnection(workFlowBean.getArchive());
      if (!filterQuery.equals("")) {
        filterQuery = URLDecoder.decode(filterQuery, "ISO-8859-1");
        QueryResult qr = xwconn.getQRfromPhrase(filterQuery);
        xwconn.setCurrentSet(qr);
        ilByte |= it.highwaytech.broker.ServerCommand.btree_SPETTRALE;
        // result = xwconn.getSingleKeys(laChiave, qr.elements, verso, common + ilValore, 1, qr.elements, "", "frequenze|spettrale");
        result = xwconn.getIdxKeys(xwconn.connection, workFlowBean.getAlias(), "TABELLA", laChiave, common + ilValore, common, numKeys, ilByteVerso, ilByte, 1, 99999999, null);
      } else {
        result = xwconn.getIdxKeys(xwconn.connection, workFlowBean.getAlias(), "TABELLA", laChiave, common + ilValore, common, numKeys, ilByteVerso, ilByte, 1, 99999999, null);

      }
      if (result != null && result.size() > 0) {
        for (int i = 0; i < result.size(); i++) {

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;
    PreInsertBean preInsertBean = null;
    List<String> confControl = new ArrayList<String>();
    confControl.add("docEdit");
    confControl.add("valoriControllati");
    confControl.add("titleManager");
    String physDoc = MyRequest.getParameter("physDoc", parameterMap);
    try {
      UserBean userBean = (UserBean) modelMap.get("userBean");
      confBean = (ConfBean) modelMap.get("confBean");
      WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      preInsertBean = new PreInsertBean();
      // serve quando sono in preinsert dalla lookup
      if(modelMap.containsAttribute("srcArchive")){
        preInsertBean.setSrcArchive((String)modelMap.get("srcArchive"));
      }
      xwconn = connectionManager.getConnection(workFlowBean.getArchive());
      // Mi carico il file selezionato per l'inserimento se il physDoc e diverso da null
      if (!physDoc.equals("")) {
        // System.out.println("PreInsertPageCommand.execute() INIZIO CARICAMENTO DOCUMENTO SELEZIONATO");
        preInsertBean.setPhysDocSelected(Integer.parseInt(physDoc));
        String docXML = xwconn.getSingleXMLFromNumDoc(preInsertBean.getPhysDocSelected());
        preInsertBean.setDocXmlSelected(docXML);
        HierPath hierPath = xwconn.getHierPath(Integer.parseInt(physDoc));
        XMLBuilder theXMLDoc = new XMLBuilder(preInsertBean.getDocXmlSelected(), "ISO-8859-1");
        preInsertBean.setXmlBuilderSelected(theXMLDoc);
        preInsertBean.setDepthSelected(hierPath.depth());
        preInsertBean.setTitleSelected((xwconn.getTitle(xwconn.connection, xwconn.getTheDb(), Integer.parseInt(physDoc))).getTitle());
        MultiEditingManager editingManager = new MultiEditingManager(parameterMap, confBean, userBean, workFlowBean);
        editingManager.setTheXML(theXMLDoc);
        confBean = editingManager.rewriteMultipleConf(confControl);
        // System.out.println("PreInsertPageCommand.execute() FINE CARICAMENTO DOCUMENTO SELEZIONATO");
        // prendo il documento padre ma controllo che non sono il padre stesso...
        String ilPath = "/hierValues";
        preInsertBean.setXPathHierValues(ilPath);
        // System.out.println("aaaaaaaaaa " + "/" + ilPath + "/macroarea");
        int numeroMacroarea = (confBean.getTheXMLConfEditing()).contaNodi("/" + ilPath + "/macroarea");
        // System.out.println("numeroMacroarea " + numeroMacroarea);
        if (numeroMacroarea > 0) {
          int iLivelli = Integer.parseInt((confBean.getTheXMLConfEditing()).valoreNodo("/" + ilPath + "/@level"));
          int docFather = Integer.parseInt(physDoc);
          if (iLivelli > 0) {
            for (int i = 0; i < iLivelli; i++) {
              if (xwconn.getNumDocFather(docFather) > 0) {
                docFather = xwconn.getNumDocFather(docFather);
              }
            }
          }
          // System.out.println("PreInsertPageCommand.execute() INIZIO CARICAMENTO DOCUMENTO PADRE");
          preInsertBean.setPhysDocFather(docFather);
          docXML = xwconn.getSingleXMLFromNumDoc(preInsertBean.getPhysDocFather());
          preInsertBean.setDocXmlFather(docXML);
          theXMLDoc = new XMLBuilder(preInsertBean.getDocXmlFather(), "ISO-8859-1");
          preInsertBean.setXmlBuilderFather(theXMLDoc);
          preInsertBean.setDepthFather(hierPath.depth() - 1);
          preInsertBean.setTitleFather((xwconn.getTitle(xwconn.connection, xwconn.getTheDb(), preInsertBean.getPhysDocFather())).getTitle());
          // System.out.println("PreInsertPageCommand.execute() FINE CARICAMENTO DOCUMENTO PADRE");

        }

        // prendo il documento root dell'archivio quello con detph==1
        if ((hierPath.depth()) - (hierPath.depth() - 1) == 1) {
          // System.out.println("PreInsertPageCommand.execute() INIZIO CARICAMENTO DOCUMENTO ROOT");
          preInsertBean.setPhysDocRoot(hierPath.docNumber(1));
          docXML = xwconn.getSingleXMLFromNumDoc(preInsertBean.getPhysDocRoot());
          preInsertBean.setDocXmlRoot(docXML);
          theXMLDoc = new XMLBuilder(preInsertBean.getDocXmlRoot(), "ISO-8859-1");
          preInsertBean.setXmlBuilderRoot(theXMLDoc);
          preInsertBean.setDepthRoot(1);
          preInsertBean.setTitleRoot((xwconn.getTitle(xwconn.connection, xwconn.getTheDb(), preInsertBean.getPhysDocRoot())).getTitle());
          // System.out.println("PreInsertPageCommand.execute() FINE CARICAMENTO DOCUMENTO ROOT");
        }

      } else {
        // in caso di nuovo documento senza il phisDoc, come ad esempio un inserimento da lookup
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;
    EditingBean editingBean = null;
    String physDoc = MyRequest.getParameter("physDoc", "", parameterMap);
    //vuol dire che vengo dal preinsert
    if(modelMap.get("physDoc")!=null){
      physDoc = (String) modelMap.get("physDoc");
    }
   
    List<String> confControl = new ArrayList<String>();
    confControl.add("docEdit");
    confControl.add("valoriControllati");
    try {
      UserBean userBean = (UserBean) modelMap.get("userBean");
      //confBean = (ConfBean) modelMap.get("confBean");
      confBean = new ConfBean();
      WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      if (physDoc.equals("")) {
        physDoc = (String) workFlowBean.getRequest().getAttribute("physDoc");
      }
      editingBean = new EditingBean();
      editingBean.setPhysDoc(Integer.parseInt(physDoc));
      xwconn = connectionManager.getConnection(workFlowBean.getArchive());
      editingBean.setDocXml(xwconn.getSingleXMLFromNumDoc(editingBean.getPhysDoc()));
      XMLBuilder theXMLDoc = new XMLBuilder(editingBean.getDocXml(), "ISO-8859-1");
      editingBean.setXmlBuilder(theXMLDoc);

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

      int docFather = xwconn.docRelNavigate(xwconn.connection, workFlowBean.getAlias(), it.highwaytech.broker.ServerCommand.navigarel_FIGLIOPADRE, editingBean.getPhysDoc());
      editingBean.setDocFather(docFather);
      int docSon = xwconn.docRelNavigate(xwconn.connection, workFlowBean.getAlias(), it.highwaytech.broker.ServerCommand.navigarel_PADREFIGLIO, editingBean.getPhysDoc());
      editingBean.setDocSon(docSon);
      int docUpperBrother = xwconn.docRelNavigate(xwconn.connection, workFlowBean.getAlias(), it.highwaytech.broker.ServerCommand.navigarel_MAGGIOREMINORE, editingBean.getPhysDoc());
      editingBean.setDocUpperBrother(docUpperBrother);
      int docLowerBrother = xwconn.docRelNavigate(xwconn.connection, workFlowBean.getAlias(), it.highwaytech.broker.ServerCommand.navigarel_MINOREMAGGIORE, editingBean.getPhysDoc());
      editingBean.setDocLowerBrother(docLowerBrother);

      editingBean.setPos(MyRequest.getParameter("pos", parameterMap));
      editingBean.setSelid(MyRequest.getParameter("selid", parameterMap));

      if (!editingBean.getSelid().equals("") && !editingBean.getPos().equals("")) {
        QueryResult queryResult = xwconn.getQRFromSelId(editingBean.getSelid());

        try {
          editingBean.setPhysDocNext(xwconn.getNumDocFromQRElement(queryResult, Integer.parseInt(editingBean.getPos()) + 1));
        } catch (Exception e) {
          editingBean.setPhysDocNext(-1);
        }
        try {
          editingBean.setPhysDocPrev(xwconn.getNumDocFromQRElement(queryResult, Integer.parseInt(editingBean.getPos()) - 1));
        } catch (Exception e) {
          editingBean.setPhysDocPrev(-1);
        }
        if (Integer.parseInt(editingBean.getPos()) < queryResult.elements - 1) {
          editingBean.setPosNext(Integer.parseInt(editingBean.getPos()) + 1);
View Full Code Here

    this.modelMap = modelMap;
  }

  @SuppressWarnings("unchecked")
  public void execute() throws Exception {
    XWConnection xwconn = null;
    ConnectionManager connectionManager = new ConnectionManager();
    Vector<Key> result = new Vector<Key>();
    System.out.println("Vocabulary.execute() parameterMap\n " + parameterMap);
    System.out.println("Vocabulary.execute() searchAlias\n " + parameterMap.get("searchAlias")[0]);
    String searchAlias = parameterMap.get("searchAlias")[0];
    System.out.println("searchAlias: " + searchAlias);
    WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
    System.out.println(workFlowBean);
    String name = "";
    try {
      if (parameterMap.get("name") != null) {
        name = parameterMap.get("name")[0];
        System.out.println("name VALUE IS: " + name);
      }
    } catch (Exception e) {
    }

    String startParam = "";
    try {
      if (parameterMap.get("startParam") != null) {
        startParam = parameterMap.get("startParam")[0];
        System.out.println("startParam: " + startParam);
      }
    } catch (Exception e) {
    }

    String orientation = "up";
    try {
      if (parameterMap.get("orientation") != null) {
        orientation = parameterMap.get("orientation")[0];
        System.out.println("orientation: " + orientation);
      }
    } catch (Exception e) {
    }
    int totResult = 3;
    try {
      if (parameterMap.get("totResult") != null) {
        totResult = Integer.parseInt(parameterMap.get("totResult")[0]);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    System.out.println("numero risultati per pagina: " + totResult);

    try {
      xwconn = connectionManager.getConnection(workFlowBean.getArchive());
      result = xwconn.getSingleKeys(searchAlias, totResult, orientation, startParam);
    } catch (Exception e) {
      throw e;
    } finally {
      modelMap.put("resultVoc", result);
      // model.put("numeropaginacorrente", numeropagina);
View Full Code Here

    confControl.add("docEdit");
    try {
      UserBean userBean = (UserBean) modelMap.get("userBean");
      confBean = (ConfBean) modelMap.get("confBean");
      workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      XWConnection xwconnone = connectionManager.getConnection(workFlowBean.getArchive());
      MultiEditingManager editingManager = new MultiEditingManager(parameterMap, confBean, userBean, workFlowBean);
      editingManager.setTheXML(new XMLBuilder(xwconnone.getSingleXMLFromNumDoc(Integer.parseInt(physDoc)), "ISO-8859-1"));
      confBean = editingManager.rewriteMultipleConf(confControl);
      connectionManager.closeConnection(xwconnone);
      XMLBuilder theXMLconf = confBean.getTheXMLConfEditing();
      if (!codeToFind.equals("") && makeAction.equals("")) {
       
        Map<String, List<ElementToFindBean>> hashDbToFind = buildElementToFindBean.buildElementToFindBean(theXMLconf, workFlowBean.getAlias());
        System.out.println("ModifyAuther.execute() (hashDbToFind) " + (hashDbToFind));
        int contaArchProc = 0;
        String archivioCorrente = "";
        QueryResult qr = null;
        for (Entry<String, List<ElementToFindBean>> entrySet : hashDbToFind.entrySet()) {
          String dbToFind = entrySet.getKey();
          List<ElementToFindBean> arrElmToFind = hashDbToFind.get(dbToFind);
          archivioCorrente = dbToFind;
          if(userBean.getArchivesMap().get(dbToFind)==null){
            continue;
          }
          Archive archiveBean = userBean.getArchivesMap().get(dbToFind);
          String descrArchive = archiveBean.getArchiveDescr();
          List<String> listCtrlModAuther = new ArrayList<String>();
          if (!archiveBean.getAlias().equals("")) {
            for (int a = 0; a < arrElmToFind.size(); a++) {
              ModifyAutherBean autherBean = new ModifyAutherBean();
              ElementToFindBean elementToFindBean = (ElementToFindBean) arrElmToFind.get(a);
              System.out.println("ModifyAuther.execute() elementToFindBean.getStrQuery()" + elementToFindBean.getStrQuery() + "AAAA");
              if (elementToFindBean.getStrQuery() != null && !elementToFindBean.getStrQuery().equals("null")) {
                String query = "(" + elementToFindBean.getStrQuery() + "=" + codeToFind + ")";
                System.out.println("query " + query + "<br>");
                System.out.println("archivioCorrente " + archivioCorrente + "<br>");
                XWConnection xwconn = null;
                try {
                  xwconn = connectionManager.getConnection(archiveBean);
                  qr = xwconn.getQRfromPhrase(query);
                  System.out.println("ModifyAuther.execute() qr " + qr.elements);
                } catch (Exception e) {
                  // throw new Exception("ERRORE NELLA CONNESSIONE CON IL DATABASE " + archiviBean.getTheArch());
                } finally {
                  connectionManager.closeConnection(xwconn);
                }
                // System.out.println("<span style=\"background:#fff;\"><b>" + archivioCorrente + "</b>" + query + " occorrenze=" + qr.elements + "</span><br>");
                autherBean.setArchivioAlias(archivioCorrente);
                autherBean.setArchivioDescr(descrArchive);
                autherBean.setElementToFindBean(elementToFindBean);
                autherBean.setQuery(query);
                autherBean.setNumElementi(qr.elements);
                // escludere per ArchivioAlias e query
                if (!listCtrlModAuther.contains(archivioCorrente + query)) {
                  modifyAutherBean.addArrModifyAutherBean(autherBean);
                  listCtrlModAuther.add(archivioCorrente + query);
                }
              }
            }
          }
        }
        modifyAutherBean.setDispatchView(jspDispatchMenu);
      } else if (!codeToFind.equals("") && makeAction.equals("true")) {
        System.out.println("ModifyAuther.execute() - SONO IN MODIFICA AUTH 1");
        Map<String, List<ElementToFindBean>> hashDbToFind = buildElementToFindBean.buildElementToFindBean(theXMLconf, workFlowBean.getAlias());
        int modificatiTotali = 0;
        int erroriTotali = 0;
        int modificatiXPathToChange = 0;
        for (Entry<String, List<ElementToFindBean>> entrySet : hashDbToFind.entrySet()) {
          System.out.println("ModifyAuther.execute() - SONO IN MODIFICA AUTH 2");
          try {
            String dbToFind = entrySet.getKey();
            List<ElementToFindBean> arrElmToFind = hashDbToFind.get(dbToFind);
            // Enumeration elementi = myRequest.getHttpServletRequest().getParameterNames();
            boolean processArch = false;
            System.out.println("ModifyAuther.execute() - SONO IN MODIFICA AUTH 3");
            // while (elementi.hasMoreElements()) {
            for (Entry<String, String[]> entry : parameterMap.entrySet()) {
              String nome = entry.getKey();
              if (nome.indexOf("theArchiveToProcess_") != -1) {
                String tmpArch = MyRequest.getParameter(nome, parameterMap);
                if (tmpArch.indexOf(dbToFind) != -1) {
                  // out.println(theArch+"vado a processare i record <br>");
                  processArch = true;
                  break;
                }
              }
            }

            System.out.println("ModifyAuther.execute() - SONO IN MODIFICA AUTH 3 processArch " + processArch);
            if (processArch) {
              if(userBean.getArchivesMap().get(dbToFind)==null){
                continue;
              }
              Archive archiveBean = userBean.getArchivesMap().get(dbToFind);
              System.out.println("ModifyAuther.execute() - SONO IN MODIFICA AUTH 4 archiviBean " + archiveBean);
              String descrArchive = archiveBean.getArchiveDescr();
              System.out.println("ModifyAuther.execute() - SONO IN MODIFICA AUTH 5 descrArchive " + descrArchive);

              for (int z = 0; z < arrElmToFind.size(); z++) {
                ElementToFindBean elementToFindBean = (ElementToFindBean) arrElmToFind.get(z);
                String strQuery = elementToFindBean.getStrQuery();
                String strPrefix = elementToFindBean.getStrPrefix();
                String strCode = elementToFindBean.getStrCode();
                String xPathToChange = elementToFindBean.getXPathToChange();
                String isTextNode = elementToFindBean.getIsTextNode();

                String query = "(" + strQuery + "=" + codeToFind + ")";
                System.out.println("ModifyAuther.execute() - SONO IN MODIFICA AUTH 6 strQuery " + strQuery);
                System.out.println("ModifyAuther.execute() - SONO IN MODIFICA AUTH su Archivio  " + archiveBean.getAlias());
                QueryResult qr = null;
                XWConnection xwconn = null;
                try {
                  xwconn = connectionManager.getConnection(archiveBean);
                  qr = xwconn.getQRfromPhrase(query);
                  if (qr.elements > 0) {
                    ModifyAutherBean autherBean = new ModifyAutherBean();
                    for (int a = 0; a < qr.elements; a++) {
                      boolean modificato = false;
                      int numDoc = xwconn.getNumDocFromQRElement(qr, a);
                      XMLBuilder builder = new XMLBuilder(xwconn.getSingleXMLFromNumDoc(numDoc), "ISO-8859-1");
                      // out.println("strPrefix "+strPrefix+"<br>");
                      if (elementToFindBean.isAdvEditing()) {
                        MappingAdv mappingAdv = new MappingAdv();
                        List<Element> list = mappingAdv.extractMapping(elementToFindBean.getConfigurationXMLReader().getObjects(), null, new HashMap<String, String>());
                        ArrayList<Element> arrayList = new ArrayList<Element>(list);
                        for (Element element : arrayList) {
                          List<Element> arrayListA = new ArrayList<Element>();
                          arrayListA.add(element);
                          mappingAdv.buildXML(arrayListA, builder, null, null, new GenericInterface<XMLBuilder>() {
                            public void invoke(XMLBuilder builder, Element element) {
                              try {
                                if (!nameToChange.equals(element.getFieldValue())) {
                                  System.out.println(element.getFieldValue());
                                }
                              } catch (Exception e) {
                                e.printStackTrace();
                              }
                            }
                          });
                        }
                        System.out.println("###############################");
                        System.out.println("###############################");
                        System.out.println("###############(elementToFindBean.isAdvEditing()################");
                        System.out.println("###############################");
                        System.out.println("###############################");
                        System.out.println("###############################");

                      } else {
                        int countPrefix = builder.contaNodi(strPrefix);
                        for (int x = 0; x < countPrefix; x++) {
                          String newXPathToChange = strPrefix + "[" + (x + 1) + "]" + xPathToChange.substring(xPathToChange.indexOf(strPrefix) + strPrefix.length());
                          String newXpathCode = "";
                          if (isTextNode.equals("true")) {
                            newXpathCode = newXPathToChange.substring(0, newXPathToChange.lastIndexOf("/") + 1) + strCode;
                          } else {
                            System.out.println("ModifyAuther.execute() CI SONO UN PREFIX strCode.indexOf(strPrefix)!=-1 " + strPrefix.contains(strCode));
                            System.out.println("ModifyAuther.execute() CI SONO UN PREFIX strPrefix " + strPrefix);
                            System.out.println("ModifyAuther.execute() CI SONO UN PREFIX strCode " + strCode);
                            if (strCode.indexOf(strPrefix) != -1) {
                              System.out.println("ModifyAuther.execute() CI SONO UN PREFIX DIDIDIDIDI");
                              newXpathCode = strPrefix + "[" + (x + 1) + "]" + StringUtils.difference(strPrefix, strCode);
                              System.out.println("ModifyAuther.execute() CI SONO UN PREFIX DIDIDIDIDI" + newXpathCode);
                              // newXpathCode = newXPathToChange.substring(0, newXPathToChange.lastIndexOf("/") + 1) + "@" + strCode;
                            } else {
                              if (strCode.indexOf("@") != -1) {
                                newXpathCode = newXPathToChange.substring(0, newXPathToChange.lastIndexOf("/") + 1) + strCode;
                              } else {
                                newXpathCode = newXPathToChange.substring(0, newXPathToChange.lastIndexOf("/") + 1) + "@" + strCode;
                              }

                            }

                          }
                          System.out.println("ModifyAuther.execute() newXpathCode " + newXpathCode);
                          String ilValoreCode = builder.valoreNodo(newXpathCode);
                          System.out.println("ModifyAuther.execute() ilValoreCode " + ilValoreCode);
                          System.out.println("ModifyAuther.execute() newXpathCode " + newXpathCode);
                          System.out.println("ModifyAuther.execute() newXpathCode " + newXpathCode);
                          System.out.println("ModifyAuther.execute() ilValoreCode " + ilValoreCode);
                          String ilValoreText = builder.valoreNodo(newXPathToChange);
                          System.out.println("ModifyAuther.execute() ilValoreText " + ilValoreText);
                          System.out.println("ModifyAuther.execute() ilValoreText " + ilValoreText);
                          System.out.println("ModifyAuther.execute() ilValoreText " + ilValoreText);
                          System.out.println("ModifyAuther.execute() ilValoreText " + ilValoreText);
                          System.out.println("ModifyAuther.execute() ilValoreText " + ilValoreText);

                          if (ilValoreCode.indexOf(codeToFind) != -1 && !ilValoreText.equals(nameToChange)) {
                            modificato = true;
                            builder.insertValueAt(newXPathToChange, nameToChange);
                            modificatiXPathToChange++;
                          }
                        }
                        if (modificato) {
                          // String rootElement = (builder.getDomDocument().getDocumentElement()).getNodeName();
                          // // out.println("rootElement "+rootElement+"<br>");
                          // if (rootElement.equals("c")) {
                          // int numProcessInfo = builder.contaNodi("/" + rootElement + "/processinfo/list/item");
                          // numProcessInfo++;
                          // builder.insertValueAt("/" + rootElement + "/processinfo/list/item[" + numProcessInfo + "]/persname/text()", myRequest.getParameter(".persona"));
                          // builder.insertValueAt("/" + rootElement + "/processinfo/list/item[" + numProcessInfo + "]/text()", myRequest.getParameter(".action"));
                          // builder.insertValueAt("/" + rootElement + "/processinfo/list/item[" + numProcessInfo + "]/date/text()", myRequest.getParameter(".data"));
                          // } else {
                          // int numProcessInfo = builder.contaNodi("/" + rootElement + "/eacheader/mainhistory/mainevent");
                          // numProcessInfo++;
                          // builder.insertValueAt("/" + rootElement + "/eacheader/mainhistory/mainevent[" + numProcessInfo + "]/name/text()", myRequest.getParameter(".persona"));
                          // builder.insertValueAt("/" + rootElement + "/eacheader/mainhistory/mainevent[" + numProcessInfo + "]/@maintype", myRequest.getParameter(".action"));
                          // builder.insertValueAt("/" + rootElement + "/eacheader/mainhistory/mainevent[" + numProcessInfo + "]/maindate/text()", myRequest.getParameter(".data"));
                          // }

                          modificatiTotali++;
                          String docXML = builder.getXML("ISO-8859-1");
                          docXML = XMLCleaner.clearXwXML(docXML, true);
                          try {
                            xwconn.executeUpdateByDocNumber(docXML, numDoc);
                          } catch (Exception e) {
                            erroriTotali++;
                            modifyAutherBean.addErrorMsg("Errore in proietta authority per il documento numero " + numDoc + " in  " + descrArchive + " " + e.getMessage());
                            e.printStackTrace();
                          }
View Full Code Here

    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>");
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;
    TreeBean treeBean = null;
    String titleRole = "";
    List<String> confControl = new ArrayList<String>();
    confControl.add("titleManager");
    confControl.add("query");
    try {
      UserBean userBean = (UserBean) modelMap.get("userBean");
      confBean = (ConfBean) modelMap.get("confBean");
      WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      treeBean = new TreeBean();
      MultiEditingManager editingManager = new MultiEditingManager(parameterMap, confBean, userBean, workFlowBean);
      editingManager.setTheXML(new XMLBuilder("root"));
      confBean = editingManager.rewriteMultipleConf(confControl);
      xwconn = connectionManager.getConnection(workFlowBean.getArchive());
      if (MyRequest.getParameter("docStart", parameterMap) != null && !MyRequest.getParameter("docStart", parameterMap).equals("")) {
        treeBean.setDocStart(Integer.parseInt(MyRequest.getParameter("docStart", parameterMap)));
        String docXML = xwconn.getSingleXMLFromNumDoc(treeBean.getDocStart());
        editingManager.setTheXML(new XMLBuilder(docXML, "ISO-8859-1"));
        confBean = editingManager.rewriteMultipleConf(confControl);
      } else {
        confBean = editingManager.rewriteMultipleConf(confControl);
      }
      if (modelMap.get("pageName") != null && modelMap.get("pageName").equals("tree")) {
        System.out.println("HierBrowserPageCommand.execute()");
        XMLBuilder builder = confBean.getTheXMLConfTitle();
        titleRole = builder.valoreNodo("/root/titleManager/sezione[@name='hierBrowser']/titleRole/text()", false);
        System.out.println("HierBrowserPageCommand.execute()" + titleRole);
        try {
          if (!titleRole.trim().equals("")) {
            xwconn.setTitleRole(titleRole);
          }
        } catch (Exception e) {
          System.out.println(" ----- ERROR ---- HierBrowserPageCommand (xwconn.setTitleRole(titleRole)), title to parse: " + titleRole);
          xwconn.restoreTitleRole();
        }
        if (MyRequest.getParameter("docToggle", parameterMap) != null && !MyRequest.getParameter("docToggle", parameterMap).equals("")) {
          treeBean.setDocToggle(Integer.parseInt(MyRequest.getParameter("docToggle", parameterMap)));
        }
        if (!MyRequest.getParameter("docCount", parameterMap).equals("")) {
          treeBean.setDocCount(Integer.parseInt(MyRequest.getParameter("docCount", parameterMap)));
        }
          //else if(WebUtils.getCookie(workFlowBean.getRequest(), workFlowBean.getAlias()+userBean.getId())!=null){
//          treeBean.setDocCount(Integer.parseInt(WebUtils.getCookie(workFlowBean.getRequest(), workFlowBean.getAlias()+userBean.getId()).getValue()));
//        }
//       
//        System.out.println("HierBrowserPageCommand.execute() "+treeBean.getDocCount());
//        System.out.println("HierBrowserPageCommand.execute() WebUtils "+WebUtils.getCookie(workFlowBean.getRequest(), workFlowBean.getAlias()+userBean.getId()).getValue());
//        System.out.println("HierBrowserPageCommand.execute() MyRequest "+MyRequest.getParameter("docCount", parameterMap).equals(""));
//        System.out.println("HierBrowserPageCommand.execute() "+treeBean.getDocCount());
//        System.out.println("HierBrowserPageCommand.execute() "+treeBean.getDocCount());
//        System.out.println("HierBrowserPageCommand.execute() "+treeBean.getDocCount());
//       
         if (MyRequest.getParameter("hierStatus", parameterMap) != null && !MyRequest.getParameter("hierStatus", parameterMap).equals("")) {
          treeBean.setHierStatus(MyRequest.getParameter("hierStatus", parameterMap));
        }

        if (MyRequest.getParameter("backward", parameterMap) != null && !MyRequest.getParameter("backward", parameterMap).equals("") && MyRequest.getParameter("backward", parameterMap).equals("1")) {
          treeBean.setBackward(true);
        }

        it.highwaytech.broker.BrowseExtras bExtras = new it.highwaytech.broker.BrowseExtras(treeBean.getHierStatus(), treeBean.getDocToggle());
        java.util.Vector vectHierTitle = xwconn.hierList(xwconn.connection, xwconn.getTheDb(), treeBean.getDocStart(), treeBean.isBackward() ? it.highwaytech.broker.ServerCommand.browse_MOVEUP : it.highwaytech.broker.ServerCommand.browse_MOVEDOWN, treeBean.getDocCount(), bExtras);
        treeBean.setHierStatus(bExtras.readStatus());
        treeBean.setVectHierTitle(vectHierTitle);
        if (vectHierTitle != null) {
          treeBean.setUpEnabled(!(((it.highwaytech.db.HierTitle) (vectHierTitle.firstElement())).isFirst()));
          treeBean.setDownEnabled(!(((it.highwaytech.db.HierTitle) (vectHierTitle.lastElement())).isLast()));
        }
        treeBean.setFirstDocNumber(((it.highwaytech.db.HierTitle) (vectHierTitle.firstElement())).docNumber());
        treeBean.setLastDocNumber(((it.highwaytech.db.HierTitle) vectHierTitle.lastElement()).docNumber());

        for (int index = 0; index < vectHierTitle.size(); index++) {
          HierBrowserBean hierBrowserBean = new HierBrowserBean();
          it.highwaytech.db.HierTitle theTitle = ((it.highwaytech.db.HierTitle) (vectHierTitle.get(index)));
          String hier = theTitle.getHier(xwconn.getTheDb(), xwconn.getServerConnection(xwconn.connection), "&#10;");
          hierBrowserBean.setHier(hier);
          int docNumber = theTitle.docNumber();
          hierBrowserBean.setDocNumber(docNumber);
          try {
            it.highwaytech.db.HierPath thePath = xwconn.getHierPath(hierBrowserBean.getDocNumber());
            hierBrowserBean.setHierPath(thePath);
          } catch (Exception e) {
          }
          int depth = theTitle.depth();
          hierBrowserBean.setDepth(depth);
          boolean hasSons = theTitle.hasSons();
          hierBrowserBean.setHasSons(hasSons);
          int firstDocNumber = ((it.highwaytech.db.HierTitle) (vectHierTitle.firstElement())).docNumber();
          hierBrowserBean.setFirstDocNumber(firstDocNumber);
          int lastDocNumber = ((it.highwaytech.db.HierTitle) vectHierTitle.lastElement()).docNumber();
          hierBrowserBean.setLastDocNumber(lastDocNumber);
          boolean opened = theTitle.isOpened();
          hierBrowserBean.setOpened(opened);
          Title titArch = xwconn.getTitle(xwconn.connection, xwconn.getTheDb(), theTitle.docNumber());
          // System.out.println("HierBrowserPageCommand.execute() title docNumber aa "+theTitle.docNumber(xwconn.getTheDb(),
          // xwconn.getServerConnection(xwconn.connection),
          // theTitle.depth()));
          // System.out.println("HierBrowserPageCommand.execute() title docNumber bb "+theTitle.docNumber());
          // System.out.println("HierBrowserPageCommand.execute() title "+title);
          // System.out.println("HierBrowserPageCommand.execute() title "+titArch.getTitle());
          String title = titArch.getTitle();
          hierBrowserBean.setTitle(title);
          boolean lastChild = theTitle.hasBrothers(theTitle.depth());
          hierBrowserBean.setLastChild(!lastChild);
          if (theTitle.depth() > 1) {
            boolean fatherLastChild = theTitle.hasBrothers(theTitle.depth() - 1);
            hierBrowserBean.setFatherLastChild(!fatherLastChild);
          }
          if (theTitle.depth() > 1) {
            boolean[] fathers = new boolean[theTitle.depth() - 1];
            for (int i = theTitle.depth() - 2; i > 0; i--) {
              fathers[(theTitle.depth() - 2) - i] = !theTitle.hasBrothers(theTitle.depth() - i);
            }
            hierBrowserBean.setFathersLastChild(fathers);
          }
          treeBean.getVectHierBrowserBean().addElement(hierBrowserBean);

        }
      }

    } catch (Exception e) {
      e.printStackTrace();
      throw new Exception(e.toString());
    } finally {
      if (!titleRole.trim().equals("")) {
        try {
          xwconn.restoreTitleRole();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }
      modelMap.put("treeBean", treeBean);
View Full Code Here

    // System.err.println("aaaaaaaaaaaaaaaaaaaaaaa xpath " + xpath);
    // System.err.println("aaaaaaaaaaaaaaaaaaaaaaa nameFileXml " + nameFileXml);
    ConfBean confBean = null;
    WorkFlowBean workFlowBean = null;
    ConnectionManager connectionManager = new ConnectionManager();
    XWConnection xwconn = null;
    List<String> confControl = new ArrayList<String>();
    confControl.add("query");
    try {
      UserBean userBean = (UserBean) modelMap.get("userBean");
      confBean = (ConfBean) modelMap.get("confBean");
      workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");

      xwconn = connectionManager.getConnection(workFlowBean.getArchive());
      MultiEditingManager editingManager = new MultiEditingManager(req.getParameterMap(), confBean, userBean, workFlowBean);
      editingManager.setTheXML(new XMLBuilder("root"));
      confBean = editingManager.rewriteMultipleConf(confControl);
      XMLBuilder xmlBuilder = confBean.getTheXMLConfQuery();
      String qlphrase = xmlBuilder.valoreNodo("/root/access_method/query[@ajaxCheck='notinhier']/text()");
      System.out.println("AjaxCommandNotInHier.execute() qlphrase " + qlphrase);
      if (!qlphrase.trim().equals("")) {
        int intDoc = Integer.parseInt(StringUtils.substringAfter(qlphrase.toLowerCase(), "notinhier:"));
        QueryResult queryResult = xwconn.getQRFromHier(intDoc, true);
        String query = " NOT ([?SEL]=" + queryResult.id + ") AND ([UD,/xw/@UdType/]=\"" + workFlowBean.getArchive().getPne() + "\")";
        queryResult = xwconn.getQRfromPhrase(query);
        if (queryResult.elements != 0) {
          ajaxBean.setStrXmlOutput("" + queryResult.elements);
        }

      }
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.