예제 #1
0
  @Override
  public ResultDTO executeCommand(
      String screenName,
      String querynodeXpath,
      JSONObject jsonRecord,
      InputDTO inputDTO,
      ResultDTO resultDTO) {
    ResultDTO resDTO = new ResultDTO();
    try {
      Element rootXml = ScreenMapRepo.findMapXMLRoot(screenName);
      Element processorElm =
          (Element) rootXml.selectSingleNode("/root/screen/bl/" + querynodeXpath + " ");
      String methodName = processorElm.attributeValue("method");

      if ("testMethod1".equals(methodName)) {
        testMethod1();
        System.out.println(ServletActionContext.getContext().getSession());
        System.out.println(
            "Session var retreived:"
                + ServletActionContext.getContext().getSession().get("mysessionkey"));
      } else {
        System.out.println("ProgramSetup BL methodname is not defined");
      }

      List<String> errors = new ArrayList<String>();
      errors.add("business.logic.unimplemented");
      resDTO.setMessages(errors);
    } catch (FrontendException e) {
      resDTO.addError("error.accessxml");
    }
    return resDTO;
  }
예제 #2
0
  public String selectList(
      String screenName,
      String panelname,
      String querynode,
      JSONObject jsonObject,
      InputDTO jsonInput,
      ResultDTO prevResultDTO) {
    String parsedquery = "";
    try {
      String xmlconfigfile = ScreenMapRepo.findMapXMLPath(screenName);
      org.dom4j.Document document1 = new SAXReader().read(xmlconfigfile);
      org.dom4j.Element root = document1.getRootElement();
      Node crudnode = root.selectSingleNode("//crud");
      Node node = crudnode.selectSingleNode(querynode);
      if (node == null) throw new Exception("<" + querynode + "> node not defined");

      String outstack = ((Element) node).attributeValue("outstack");
      panelname = outstack;

      String updatequery = "";
      updatequery += node.getText();

      List<Element> nodeList = crudnode.selectNodes("../fields/field/*");
      logger.debug("fields size:" + nodeList.size());
      HashMap<String, DataType> hmfielddbtype = new HashMap<String, PrepstmtDTO.DataType>();
      QueryParser.populateFieldDBType(nodeList, hmfielddbtype);

      /*Pattern pattern  = Pattern.compile(":(\\w*)",Pattern.DOTALL|Pattern.MULTILINE);
      Matcher m = pattern.matcher(updatequery);
      while(m.find()){
      	String val = "";
      	logger.debug(m.group(0)+ " "+ m.group(1));
      	if(jsonObject.has(m.group(1))){
      		val = jsonObject.getString(m.group(1));
      		updatequery = updatequery.replaceAll(":"+m.group(1), val);
      	}
      }*/
      // SET
      List<Element> primarykeys = crudnode.selectNodes("../fields/field/*[@primarykey]");

      PrepstmtDTOArray arparam = new PrepstmtDTOArray();
      parsedquery =
          QueryParser.parseQuery(
              updatequery, panelname, jsonObject, arparam, hmfielddbtype, jsonInput, prevResultDTO);

      logger.debug(
          "UPDATE query:" + parsedquery + "\n Expanded prep:" + arparam.toString(parsedquery));
    } catch (Exception e) {
      logger.debug("Exception caught in InsertData", e);
    }
    return parsedquery;
  }