Package org.xdams.xw

Examples of org.xdams.xw.XWConnection


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

  public void execute() throws Exception {
    XWConnection xwconn = null;
    ConnectionManager connectionManager = new ConnectionManager();
    ConfBean confBean = null;
    String physDoc = MyRequest.getParameter("physDoc", parameterMap);
    UploadBean uploadBean = (UploadBean) modelMap.get("uploadBean");
    List<String> confControl = new ArrayList<String>();
    confControl.add("upload");
    try {
      UserBean userBean = (UserBean) modelMap.get("userBean");
      confBean = (ConfBean) modelMap.get("confBean");
      WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      xwconn = connectionManager.getConnection(workFlowBean.getArchive());
      MultiEditingManager editingManager = new MultiEditingManager(parameterMap, confBean, userBean, workFlowBean);
      editingManager.setTheXML(new XMLBuilder(xwconn.getSingleXMLFromNumDoc(Integer.parseInt(physDoc)), "ISO-8859-1"));
      confBean = editingManager.rewriteMultipleConf(confControl);
      LoadUploadBean.loadUploadBean(uploadBean, confBean.getTheXMLConfUpload(), modelMap);
      System.out.println(uploadBean);
      // da prendere dentro workflowBean
      String archiveName = workFlowBean.getAlias();
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;
    HttpServletRequest request = null;
    try {
      UserBean userBean = (UserBean) modelMap.get("userBean");
      confBean = (ConfBean) modelMap.get("confBean");
      WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      String thePne = workFlowBean.getArchive().getPne();
      request = workFlowBean.getRequest();
      MyRequest myRequest = new MyRequest(request);
      if (!(myRequest.getParameter("thePne")).equals("")) {
        thePne = myRequest.getParameter("thePne");
      }
      String[] nomiRequest = MyRequest.ordinaRequest(request, "." + thePne + ".");
      xwconn = connectionManager.getConnection(workFlowBean.getArchive());
      XMLBuilder builder = new XMLBuilder(thePne);
      for (int i = 0; i < nomiRequest.length; i++) {
        boolean isCDATA = false;
        String ilNome = nomiRequest[i].replace('.', '/');
        String ilValore = (request.getParameter(nomiRequest[i])).trim();
        if (ilNome.endsWith("/@cdata")) {
          ilNome = StringUtils.chomp(ilNome, "/@cdata");
          isCDATA = true;
        }
        if (!ilValore.equals("")) {
          if (isCDATA) {
            builder.insertNode(ilNome, ilValore, true);
          } else {
            builder.insertNode(ilNome, ilValore);
          }
        }
      }
      String theXML = builder.getXML("ISO-8859-1", false);
//      System.out.println(theXML);
      xwconn.executeUpdateByDocNumber(XMLCleaner.clearXwXML(theXML, false), Integer.parseInt(request.getParameter("physDoc")));
    } catch (Throwable e) {
      e.printStackTrace();
      throw new Exception(e.toString());
    } finally {
      connectionManager.closeConnection(xwconn);
View Full Code Here

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

  public void execute() throws Exception {
    XWConnection xwconn = null;
    ConnectionManager connectionManager = new ConnectionManager();
    ConfBean confBean = null;
    String physDoc = MyRequest.getParameter("physDoc", parameterMap);
    String pathToView = MyRequest.getParameter("pathToView", parameterMap);
    UploadBean uploadBean = (UploadBean) modelMap.get("uploadBean");
    List<String> confControl = new ArrayList<String>();
    confControl.add("upload");
    try {
      UserBean userBean = (UserBean) modelMap.get("userBean");
      confBean = (ConfBean) modelMap.get("confBean");
      WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      xwconn = connectionManager.getConnection(workFlowBean.getArchive());
      MultiEditingManager editingManager = new MultiEditingManager(parameterMap, confBean, userBean, workFlowBean);
      editingManager.setTheXML(new XMLBuilder(xwconn.getSingleXMLFromNumDoc(Integer.parseInt(physDoc)), "ISO-8859-1"));
      confBean = editingManager.rewriteMultipleConf(confControl);
      LoadUploadBean.loadUploadBean(uploadBean, confBean.getTheXMLConfUpload(), modelMap);
       if (!pathToView.equals("")) {
        File file = new File(pathToView);
        File[] files = file.listFiles();
View Full Code Here

  }

  @RequestMapping(value = "/custom/{archive}/page")
  public String customPage(@ModelAttribute("userBean") UserBean userBean, @ModelAttribute("confBean") ConfBean confBean, @ModelAttribute CustomPageBean customPageBean, @PathVariable String archive, ModelMap modelMap, HttpServletRequest request, HttpServletResponse response) throws Exception {
    common(confBean, userBean, archive, modelMap, request, response);
    XWConnection xwconn = null;
    ConnectionManager connectionManager = new ConnectionManager();
    WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
    List<String> confControl = customPageBean.getConfControl();
    try {
      MultiEditingManager editingManager = new MultiEditingManager(request.getParameterMap(), confBean, userBean, workFlowBean);
      if (customPageBean.getPhysDoc() != null && !customPageBean.getPhysDoc().equals("")) {
        xwconn = connectionManager.getConnection(workFlowBean.getArchive());
        customPageBean.setXmlBuilder(new XMLBuilder(XMLCleaner.clearXwXML(xwconn.getSingleXMLFromNumDoc(Integer.parseInt(customPageBean.getPhysDoc())), true), "ISO-8859-1"));
        editingManager.setTheXML(customPageBean.getXmlBuilder());
      } else {
        editingManager.setTheXML(new XMLBuilder("root"));
      }
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);// myRequest.getParameter("physDoc");
    String makeAction = MyRequest.getParameter("makeAction", parameterMap); // myRequest.getParameter("makeAction");
    String applyTo = MyRequest.getParameter("applyTo", parameterMap); // myRequest.getParameter("applyTo");
    String selid = MyRequest.getParameter("selid", parameterMap); // myRequest.getParameter("selid");
    String whichTo = MyRequest.getParameter("whichTo", parameterMap); // myRequest.getParameter("whichTo");
    boolean menuFlag = true;
    HttpSession httpSession = null;
    List<String> confControl = new ArrayList<String>();
    confControl.add("titleManager");
    confControl.add("docEdit");
    try {
      managingBean = new ManagingBean();
      UserBean userBean = (UserBean) modelMap.get("userBean");
      confBean = (ConfBean) modelMap.get("confBean");
      WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      httpSession = workFlowBean.getRequest().getSession(false);

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

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

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

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

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

            } catch (Exception e) {
              managingBean.addErrorMsg("Errore in Sposta per il documento  " + physDocToCut + " " + e.getMessage());
View Full Code Here

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

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

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

  public void execute() throws Exception {
    XWConnection xwconn = null;
    ConnectionManager connectionManager = new ConnectionManager();
    ConfBean confBean = null;
    QueryResult queryResult = null;
    HttpSession httpSession = null;
    String titleRole = "";
    List<String> confControl = new ArrayList<String>();
    confControl.add("titleManager");
    confControl.add("valoriControllati");
    confControl.add("media");
    confControl.add("query");
    try {
      UserBean userBean = (UserBean) modelMap.get("userBean");
      confBean = (ConfBean) modelMap.get("confBean");
      WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      httpSession = workFlowBean.getRequest().getSession(false);

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

      // mettere queryBean
      System.out.println("QueryParserCommand.execute() workFlowBean.getAlias() " + workFlowBean.getAlias());
      System.out.println("QueryParserCommand.execute() aReq.getParameter(\"fromId\") " + workFlowBean.getRequest().getParameter("fromId") + "aaaaaaa");

      xwconn = connectionManager.getConnection(workFlowBean.getArchive());

      XMLBuilder builder = confBean.getTheXMLConfTitle();
      titleRole = builder.valoreNodo("/root/titleManager/sezione[@name='title']/titleRole/text()", false);
      System.out.println("QueryParserCommand.execute()" + titleRole);
      try {
        if (!titleRole.trim().equals("")) {
          xwconn.setTitleRole(titleRole);
        }
      } catch (Exception e) {
        System.out.println(" ---- ERROR ---- QueryParserCommand (xwconn.setTitleRole(titleRole)), title to parse: " + titleRole);
        xwconn.restoreTitleRole();
      }

      if (MyRequest.getParameter("fromId", parameterMap).equals("")) {
        FindDocumentCommand findDocumentCommand = null;
        try {
          findDocumentCommand = new FindDocumentCommand(parameterMap, modelMap);
          queryResult = findDocumentCommand.execute(workFlowBean, xwconn);
          // mi setto il selid per le operazioni di raffinamento
          workFlowBean.getRequest().setAttribute("qrId", queryResult.id);
          QueryBean queryBean = new QueryBean();
          queryBean.setDb(workFlowBean.getAlias());
          System.out.println("findDocumentCommand.getLaFrase() " + findDocumentCommand.getLaFrase());
          queryBean.setQuery(findDocumentCommand.getLaFrase());
          queryBean.setTot(String.valueOf(queryResult.elements));

          if (httpSession.getAttribute(workFlowBean.getQueryBeanName()) == null) {
            ArrayList arrQueryBean = new ArrayList();
            arrQueryBean.add(queryBean);
            httpSession.setAttribute(workFlowBean.getQueryBeanName(), arrQueryBean);
          } else {
            ArrayList arrQueryBean = (ArrayList) httpSession.getAttribute(workFlowBean.getQueryBeanName());
            boolean insert = true;
            int indexQr = 0;
            for (int i = 0; i < arrQueryBean.size(); i++) {
              QueryBean ilBean = (QueryBean) arrQueryBean.get(i);
              if (ilBean.getQuery().equals(queryBean.getQuery())) {
                insert = false;
                arrQueryBean.remove(i);
                arrQueryBean.add(queryBean);
                break;
              }
            }
            if (insert) {
              arrQueryBean.add(queryBean);
              httpSession.setAttribute(workFlowBean.getQueryBeanName(), arrQueryBean);
            }
          }
        } catch (Exception e) {
          queryResult = new QueryResult();
          workFlowBean.getRequest().setAttribute("qrId", queryResult.id);
        }
        System.out.println("QueryParserCommand.execute() " + findDocumentCommand.getLaFrase());
      } else {
        queryResult = xwconn.getQRFromSelId(MyRequest.getParameter("qrId", parameterMap));
        workFlowBean.getRequest().setAttribute("qrId", queryResult.id);
      }

      PagingTool pagingTool = new PagingTool(parameterMap, modelMap);
      pagingTool.pagingTitleBean(queryResult, xwconn);
    } 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("confBean", confBean);
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 makeAction = MyRequest.getParameter("makeAction", parameterMap);
    String applyTo = MyRequest.getParameter("applyTo", parameterMap);
    String selid = MyRequest.getParameter("selid", parameterMap);
    String formattedText = MyRequest.getParameter("formattedText", parameterMap);
    HttpSession httpSession = null;
    String PDFType = ""; // 4 SELEZIONE
    // 1 UN DOCUMENTO
    // 2 FIGLI DI PRIMO LIVELLO
    // 3 TUTTA LA GERARCHIA
    List<String> confControl = new ArrayList<String>();
    confControl.add("titleManager");
    confControl.add("upload");
    confControl.add("media");

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

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

                }

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

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

        // System.out.println("aaaaaaaaaaaaaaaaa 09");
View Full Code Here

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

  public void execute() throws Exception, SQLException {
    XWConnection xwconn = null;
    List<String> titleList = new ArrayList<String>();
    ConnectionManager connectionManager = new ConnectionManager();
     WorkFlowBean workFlowBean = null;
    Titles titlesPage = new Titles();
    LookupBean lookupBean = null;
    try {

       workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
      lookupBean = (LookupBean) modelMap.get("lookupBean");
      xwconn = connectionManager.getConnection(workFlowBean.getArchiveLookup());
      QueryResult qr = null;
      String startPage = "";
      String keyCountQuery = MyRequest.getParameter("inputPerPage", "10", parameterMap);
      System.out.println("keyCountQuery keyCountQuery " + keyCountQuery);
      System.out.println("ENTRATO QUI " + (String) modelMap.get("selId"));
      System.out.println("ENTRATO selId " + MyRequest.getParameter("selId", parameterMap));

      if (!(MyRequest.getParameter("selId", parameterMap).trim()).equals("")) {
        qr = xwconn.getQRFromSelId(MyRequest.getParameter("selId", parameterMap));
        System.out.println("Lookup.execute()1111" + qr);
      } else {
        // System.out.println("ENTRATO QUA " + getQrSelId());
        qr = find(xwconn, "singoloTermine", keyCountQuery, lookupBean);
        System.out.println("Lookup.execute()2222" + qr);
      }
      System.out.println("Lookup.execute() " + qr);
      if (!MyRequest.getParameter("flagXML", parameterMap).equals("true")) {
        if (!lookupBean.getInputTitleRule().trim().equals("")) {
          xwconn.setTitleRule(xwconn.connection, workFlowBean.getArchiveLookup().getAlias(), lookupBean.getInputTitleRule());
        }
        System.out.println("Lookup.execute()333333" + qr);
        int totElements = qr.elements;
        // setQrSelId(qr.id);
        // System.out.println("PIPPETTO " + qr.elements + " FINE");
        if (!MyRequest.getParameter("startPage", parameterMap).equals("")) {
          startPage = MyRequest.getParameter("startPage", parameterMap);
        }
        if (startPage.equals("")) {
          titlesPage.setPages(Integer.parseInt(keyCountQuery), totElements);
        } else {
          titlesPage.setPages(Integer.parseInt(keyCountQuery), totElements, Integer.parseInt(startPage));
        }
        int ilPrimo = titlesPage.getFirstElement() - 1;
        for (int x = 0; x < Integer.parseInt(keyCountQuery); x++) {
          if (x + ilPrimo < totElements) {
            Title titolo = xwconn.getTitle(xwconn.connection, workFlowBean.getArchiveLookup().getAlias(), qr, x + ilPrimo);
            System.out.println(titolo.getTitle());
            titleList.add(titolo.getTitle());
          }
        }
        System.out.println("Lookup.execute()44444" + qr);
        modelMap.put("selId", qr.id);
        System.out.println("Lookup.execute()6666666" + qr);
      } else if (MyRequest.getParameter("flagXML", parameterMap).equals("true")) {
        lookupBean.setInputTitleRule("");
        int totElements = qr.elements;
        // setQrSelId(qr.id);
        System.out.println("PIPPETTO " + qr.elements + " FINE");
        if (!MyRequest.getParameter("startPage", parameterMap).equals("")) {
          startPage = MyRequest.getParameter("startPage", parameterMap);
        }

        if (startPage.equals("")) {
          titlesPage.setPages(Integer.parseInt(keyCountQuery), totElements);
        } else {
          titlesPage.setPages(Integer.parseInt(keyCountQuery), totElements, Integer.parseInt(startPage));
        }
        int ilPrimo = titlesPage.getFirstElement() - 1;
        StringBuffer buffer = new StringBuffer();
        for (int x = 0; x < Integer.parseInt(keyCountQuery); x++) {
          if (x + ilPrimo < totElements) {
            int numDoc = xwconn.getNumDocFromQRElement(qr, x + ilPrimo);
            String strXml = xwconn.getSingleXMLFromQr(qr, x + ilPrimo, false);
            try {
              titleList.add(strXml);
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        }
        modelMap.put("selId", qr.id);
      }

    } catch (Exception e) {
      e.printStackTrace();
      throw new Exception(e.toString());
    } finally {
      modelMap.put("titleList", titleList);
      modelMap.put("titlesPage", titlesPage);
      try {
        if (!lookupBean.getInputTitleRule().trim().equals("")) {
          xwconn.restoreTitleRule(xwconn.connection, workFlowBean.getArchiveLookup().getAlias());
        }
        connectionManager.closeConnection(xwconn);
      } catch (Exception e1) {
        throw new Exception(e1.toString());
      }
View Full Code Here

  }

  private boolean isFirstKey(String theArchs, String aliasMulti, String param, String startParam, String filter, String part) throws CommandException {
    boolean result;
    result = true;
    XWConnection xwconn = null;
    ConnectionManager connectionManager = new ConnectionManager();
    WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
    UserBean userBean = (UserBean) modelMap.get("userBean");
    try {
      StringTokenizer stringTokenizer = new StringTokenizer(theArchs, ";");
      StringTokenizer stringTokenizer2 = new StringTokenizer(aliasMulti, ";");
      String[] values = new String[stringTokenizer.countTokens()];
      int countBoolean = 0;
      while (stringTokenizer.hasMoreTokens()) {
        try {
          String theArch = stringTokenizer.nextToken();
          String alias = "";
          if (aliasMulti.indexOf(";") != -1)
            alias = stringTokenizer2.nextToken();
          else
            alias = aliasMulti;
          if (theArch != null)
            xwconn = connectionManager.getConnection(ServiceUser.getArchive(userBean, theArch));

          else
            throw new CommandException("Errore theArch = null");
          Vector first = null;
          if (filter == null)
            first = xwconn.getSingleKeys(alias, 2, "down", "", part);
          else
            // first = xwconn.getFilteredKeys(filter,alias, 2, "down", "",part);
            first = xwconn.getFilteredKeys(filter, alias, 2, "down", "", 1, xwconn.getTotNumDoc(), "", "frequenze|spettrale");
          if (first != null && first.size() > 0) {
            Key key = (Key) first.elementAt(0);
            values[countBoolean] = key.key.toString().trim();
          } else {
            values[countBoolean] = "zzzzzzzzzzzzzzzzzz";
          }
          xwconn.close();
          countBoolean++;
        } catch (SQLException e) {
          try {
            if (xwconn != null && !xwconn.isClosed())
              xwconn.close();
          } catch (XWException e1) {
            e1.printStackTrace();
          }
          e.printStackTrace();
        } catch (XWException e) {
          try {
            if (xwconn != null && !xwconn.isClosed())
              xwconn.close();
          } catch (XWException e1) {
            e1.printStackTrace();
          }
          e.printStackTrace();
        }
      }
      // Arrays.sort(values);
      Arrays.sort(values, new XWComparator());
      // Arrays.sort(values,Collator.getInstance(Locale.ITALIAN));
      // System.out.println(param.trim()+" = "+values[0]+" = "+startParam);
      if (param.trim().equalsIgnoreCase(values[0])) {
        result = true;
      } else {
        result = false;
      }
    } catch (Exception exc) {
      exc.printStackTrace();
    } finally {
      try {
        if (xwconn != null && !xwconn.isClosed())
          xwconn.close();
      } catch (XWException e1) {
        e1.printStackTrace();
      }
    }
    return result;
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.