Package org.xdams.ajax.bean

Examples of org.xdams.ajax.bean.AjaxBean


  public ResponseEntity<String> ajaxCall(@PathVariable String archive, @ModelAttribute("userBean") UserBean userBean, @ModelAttribute("workFlowBean") WorkFlowBean workFlowBean, @ModelAttribute("confBean") ConfBean confBean, ModelMap modelMap, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    common(confBean, userBean, archive, modelMap, request, response);

    AjaxFactory ajaxFactory = new AjaxFactory(request, response, modelMap);
    AjaxBean ajaxBean = new AjaxBean();
    try {
      ajaxBean = ajaxFactory.execute();
    } catch (Exception e) {
      e.printStackTrace();
    }
    HttpHeaders responseHeaders = new HttpHeaders();
    responseHeaders.add("Content-Type", ajaxBean.getContentType().equals("") ? "text/xml; charset=iso-8859-1" : ajaxBean.getContentType());
    System.out.println("ajaxBean.getStrXmlOutput() " + ajaxBean.getStrXmlOutput());
    System.out.println("ajaxBean.getContentType() " + ajaxBean.getContentType());
    return new ResponseEntity<String>(ajaxBean.getStrXmlOutput(), responseHeaders, HttpStatus.CREATED);
  }
View Full Code Here


  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++) {

          it.highwaytech.db.DbKey key = null;
          if (!reverseMode) {
            key = (it.highwaytech.db.DbKey) result.elementAt(i);
          } else { // CHIAVI INVERSE

            key = (it.highwaytech.db.DbKey) result.elementAt((result.size() - 1) - i);
          }
          // numDocs += key.getKeyFrequency();
          // System.err.println(key.getKeyFrequency()+" "+key.toString()+"<br>");
          // if(key.toString().indexOf(ilValore)==0)
          if (isQuery)
            valori += "\n{\"value\":\"\\\"" + key.toString() + "\\\"\", \"label\":\"" + key.toString().trim() + "\", \"frequency\":" + key.getKeyFrequency() + "},";
          else
            valori += "\n{\"value\":\"" + (key.toString()).trim() + "\", \"label\":\"" + (key.toString()).trim() + "\", \"frequency\":" + key.getKeyFrequency() + "},";
        }
        if (valori.endsWith(",")) {
          valori = valori.substring(0, valori.length() - 1);
        }

      } else {
        valori = "{\"value\":\"\", \"label\":\"nessun elemento\", \"frequency\":0}";
      }
    } catch (Exception e) {
      e.printStackTrace();
      valori = "{\"value\":\"\", \"label\":\"nessun elemento\", \"frequency\":0}";
    } finally {
      ajaxBean.setStrXmlOutput("{\"items\": [" + valori + "]}");
      connectionManager.closeConnection(xwconn);
    }
//      System.out.println("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz "+valori);

    return ajaxBean;
View Full Code Here

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

  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>");
    }
    ajaxBean.setStrXmlOutput("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" + "<sessionList>\n" + valori + "</sessionList>");
    // ajaxBean.setStrXmlOutput("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<?xml-stylesheet type=\"text/xsl\" href=\"http://localhost:8080//xdams-front/REGEXE/xslt/prova.xslt\"?>\n" + "<sessionList>\n" + valori + "</sessionList>");
    return ajaxBean;
  }
View Full Code Here

    this.modelMap = modelMap;
  }

  // @SuppressWarnings("unchecked")
  public AjaxBean execute() throws Exception {
    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>");
    } finally {
      httpSession.setAttribute(workFlowBean.getManagingBeanName(), managingBean);
      connectionManager.closeConnection(xwconn);
    }

View Full Code Here

    this.modelMap = modelMap;
  }

  public AjaxBean execute() throws Exception {

    AjaxBean ajaxBean = new AjaxBean();
    String nameFileXml = MyRequest.getParameter("nameFileXml", req.getParameterMap());
    // aReq.getParameter("nameFileXml");
    String xpath = MyRequest.getParameter("xpath", req.getParameterMap());// aReq.getParameter("xpath");
    // 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);
        }

      }
    } catch (Exception e) {
      e.printStackTrace();
      ajaxBean.setStrXmlOutput("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<optionList><option><text>Errore Caricamento</text><value></value></option>\n</optionList>");
    } finally {
      connectionManager.closeConnection(xwconn);
    }
    return ajaxBean;
  }
View Full Code Here

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

  public AjaxBean execute() throws Exception {
    AjaxBean ajaxBean = new AjaxBean();
    HttpSession httpSession = null;
    String actionType = MyRequest.getParameter("action", req.getParameterMap());
    String physDoc = MyRequest.getParameter("physDoc", req.getParameterMap());
    ManagingBean managingBean = null;
    String valori = "";
    ConnectionManager connectionManager = new ConnectionManager();
    XWConnection xwconn = null;
    ConfBean confBean = null;
    WorkFlowBean workFlowBean = null;
    XMLCopy xmlCopy = new XMLCopy();
    // questa lista pu� essere presa da un file di configurazione
    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);

      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);

      ModifyAuther modifyAuther = new ModifyAuther(req.getParameterMap(), modelMap);
      /*
       * qui forse ho un problema, forse � meglio non estendere ModifyAutherBean a MangingBean, ma semplicemente metterci un addModifyAutherBean e quindi un get e set all'interno di ManaginBean.
       */

      String contenitoreIni = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<div class=\"riga_sch_bre\">archivi collegati</div>\n<div class=\"box_sch_bre\">\n";
      String string0 = "";
      String contenitoreEnd = "</div>";
      ModifyAutherBean modifyAutherBean = (ModifyAutherBean) modifyAuther.execute();
      boolean atLastOne = false;
      for (int x = 0; x < modifyAutherBean.getArrModifyAutherBean().size(); x++) {
        ModifyAutherBean autherBean = (ModifyAutherBean) (modifyAutherBean.getArrModifyAutherBean()).get(x);
        if (autherBean.getNumElementi() > 0) {
          atLastOne = true;
          // string0 += "<div class=\"campo\"> archivio alias " + autherBean.getArchivioAlias() + "</div>\n";
          string0 += "<strong>" + java.net.URLEncoder.encode(autherBean.getArchivioDescr().replaceAll(" ", "\\&nbsp;"), "iso-8859-1") + "</strong> numero elementi " + autherBean.getNumElementi() + "<br />";
          // string0 += "<div class=\"campo\"> descr. archivio " + (autherBean.getArchivioDescr()) + "</div>\n";
          // string0 += "<div class=\"campo\"> descr. archivio escapeHtml " + StringEscapeUtils.escapeHtml(autherBean.getArchivioDescr()) + "</div>\n";
          // string0 += "<div class=\"campo\"> descr. archivio escapeJavaScript " + StringEscapeUtils.escapeJavaScript(autherBean.getArchivioDescr()) + "</div>\n";
          // string0 += "<div class=\"campo\"> descr. archivio escapeXml " + StringEscapeUtils.escapeXml(autherBean.getArchivioDescr()) + "</div>\n";
          // string0 += "<div class=\"campo\"> descr. archivio escapeXml and escapeJavaScript " + StringEscapeUtils.escapeXml(StringEscapeUtils.escapeJavaScript(autherBean.getArchivioDescr())) + "</div>\n";
          // string0 += "<div class=\"campo\"> descr. archivio escapeJavaScript and escapeXml " + StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeXml(autherBean.getArchivioDescr())) + "</div>\n";
          // string0 += "<div class=\"campo\"> query " + autherBean.getQuery() + "</div>\n";
          // string0 += "<div class=\"campo\"></div>\n";
        }
        // <div class="m10"><span class="testoMain12"><input type="checkbox" checked="checked" name="theArchiveToProcess_<%=x%>" value="<%=autherBean.getArchivioAlias()%>"/><em class="testoMainBold12"><%=autherBean.getArchivioDescr()%></em><br> trovate
        // <strong><%=autherBean.getNumElementi()%></strong> occorrenze per <%=autherBean.getQuery()%></span><br></div>
      }

      if (atLastOne) {
        String string = contenitoreIni + string0 + contenitoreEnd;
        ajaxBean.setStrXmlOutput(string);
      } else {
        String string = contenitoreIni + "<strong>nessun elemento collegato</strong>" + contenitoreEnd;
        ajaxBean.setStrXmlOutput(string);
      }

    } 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>");
    } finally {
      connectionManager.closeConnection(xwconn);
    }

    return ajaxBean;
View Full Code Here

  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");
          }

          if (!ilMinore.trim().equals("")) {
            valori += "<li>Elemento collegato con data minore: <strong>" + ilMinore + "</strong></li>";
          }
          if (!ilMaggiore.trim().equals("")) {
            valori += "<li>Elemento collegato con data maggiore: <strong>" + ilMaggiore + "</strong></li>";
          }

        } catch (Exception e) {
          // e.printStackTrace();
        }
      }
      ajaxBean.setStrXmlOutput("<ul>" + valori + "</ul>");
    } catch (Exception e) {
      e.printStackTrace();
      System.out.println("ECCOLO");
      ajaxBean.setStrXmlOutput("<ul><li>attenzione e avvenuto un errore (" + e.getMessage() + ")</li></ul>");
    } finally {
      connectionManager.closeConnection(xwconn);
    }

    return ajaxBean;
View Full Code Here

TOP

Related Classes of org.xdams.ajax.bean.AjaxBean

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.