示例#1
0
  private int fireQuery(YFSEnvironment env, String str, Document inXML) throws Exception {
    Connection m_Conn = getDBConnection(env);
    Statement stmt = null;
    int rSet = 0;
    try {
      stmt = m_Conn.createStatement();
      rSet = stmt.executeUpdate(str);

    } catch (Exception e) {
      log.error("Exception: " + e.getStackTrace());
      prepareErrorObject(e, XPXLiterals.UOM_B_TRANS_TYPE, XPXLiterals.E_ERROR_CLASS, env, inXML);
      rSet = 0;
      return rSet;
    }

    return rSet;
  }
示例#2
0
  public Document getUomUpload(YFSEnvironment env, Document inXML) throws Exception {
    /** try-catch block added by Arun Sekhar on 01-Feb-2011 for CENT tool logging * */
    Element UOMElement1 = null;
    try {
      int rSet = 0;
      String finalQuery = null;
      NodeList UOMList = inXML.getElementsByTagName("Uom");
      for (int UOMNo = 0; UOMNo < UOMList.getLength(); UOMNo++) {
        String uniqueSequenceNo = getUniqueSequenceNo(env);

        UOMElement1 = (Element) UOMList.item(UOMNo);
        String Uom = UOMElement1.getAttribute("Uom");
        String UomDescription = UOMElement1.getAttribute("UomDescription");

        Document getUomListInputDoc = YFCDocument.createDocument("Uom").getDocument();
        getUomListInputDoc.getDocumentElement().setAttribute("Uom", Uom);
        getUomListInputDoc.getDocumentElement().setAttribute("OrganizationCode", "DEFAULT");
        env.setApiTemplate("getUomList", getUomListTemplate);
        Document getUomListOutputDoc = api.invoke(env, "getUomList", getUomListInputDoc);
        log.info("The output of getUomList is: " + SCXmlUtil.getString(getUomListInputDoc));
        env.clearApiTemplate("getUomList");
        if (getUomListOutputDoc.getDocumentElement().getElementsByTagName("Uom").getLength() > 0) {
          Element uomElement =
              (Element)
                  getUomListOutputDoc.getDocumentElement().getElementsByTagName("Uom").item(0);
          String uomKey = "";
          uomKey = uomElement.getAttribute("UomKey");
          log.info("The uomkey retrieved is: " + uomKey);
          if (uomKey != null && uomKey.trim().length() > 0) {
            finalQuery =
                "UPDATE YFS_UOM SET UOM_DESCRIPTION = '"
                    + UomDescription
                    + "' WHERE UOM_KEY='"
                    + uomKey
                    + "'";
            log.info("The query for uom is: " + finalQuery);
          }
        } else {

          finalQuery =
              "INSERT INTO YFS_UOM(UOM_KEY,ORGANIZATION_CODE,UOM_TYPE,UOM,UOM_DESCRIPTION,CREATEUSERID,MODIFYUSERID,CREATEPROGID,MODIFYPROGID) VALUES('"
                  + uniqueSequenceNo
                  + "','DEFAULT','QUANTITY','"
                  + Uom
                  + "','"
                  + UomDescription
                  + "','xpxBatchLoadAgent','xpxBatchLoadAgent','xpxBatchLoadAgent','xpxBatchLoadAgent')";
          log.info("The query for uom is: " + finalQuery);
        }
        rSet = fireQuery(env, finalQuery, inXML);
        /*if(rSet!=-1)
        {
        	log.info(UomDescription+"YFS_UOM Record not Inserted in YFS_UOM table");

        }*/

        Document getItemUomMasterListInputDoc =
            YFCDocument.createDocument("ItemUOMMaster").getDocument();
        getItemUomMasterListInputDoc.getDocumentElement().setAttribute("UnitOfMeasure", Uom);
        getItemUomMasterListInputDoc.getDocumentElement().setAttribute("OrganizationCode", "xpedx");
        env.setApiTemplate("getItemUOMMasterList", getItemUomMasterListTemplate);
        Document getItemUomMasterListOutputDoc =
            api.invoke(env, "getItemUOMMasterList", getItemUomMasterListInputDoc);
        log.info(
            "The output of getItemUOMMasterList is: "
                + SCXmlUtil.getString(getItemUomMasterListOutputDoc));
        env.clearApiTemplate("getItemUOMMasterList");
        if (getItemUomMasterListOutputDoc
                .getDocumentElement()
                .getElementsByTagName("ItemUOMMaster")
                .getLength()
            > 0) {
          Element itemUommasterElement =
              (Element)
                  getItemUomMasterListOutputDoc
                      .getDocumentElement()
                      .getElementsByTagName("ItemUOMMaster")
                      .item(0);
          String itemUommasterKey = "";
          itemUommasterKey = itemUommasterElement.getAttribute("ItemUOMMasterKey");
          log.info("The item uom master key is: " + itemUommasterKey);
          if (itemUommasterKey != null && itemUommasterKey.trim().length() > 0) {
            finalQuery =
                "UPDATE YFS_ITEM_UOM_MASTER SET DESCRIPTION = '"
                    + UomDescription
                    + "' WHERE ITEM_UOM_MASTER_KEY='"
                    + itemUommasterKey
                    + "'";
            log.info("The query for item_uom_master is: " + finalQuery);
          }
        } else {
          finalQuery =
              "INSERT INTO YFS_ITEM_UOM_MASTER(ITEM_UOM_MASTER_KEY,ORGANIZATION_CODE,UOM ,UOM_TYPE ,ITEM_GROUP_CODE,DESCRIPTION ,ALLOW_FRACTIONS_IN_CONVERSION,IS_INVENTORY_UOM ,IS_ORDERING_UOM,CREATEUSERID,MODIFYUSERID,CREATEPROGID,MODIFYPROGID)values('"
                  + uniqueSequenceNo
                  + "','xpedx','"
                  + Uom
                  + "','QUANTITY','PROD','"
                  + UomDescription
                  + "','N','Y','Y','xpxBatchLoadAgent','xpxBatchLoadAgent','xpxBatchLoadAgent','xpxBatchLoadAgent')";
          log.info("The query for item_uom_master is: " + finalQuery);
        }
        rSet = fireQuery(env, finalQuery, inXML);
        /*if(rSet!=-1)
        {
        	//log.info(UomDescription+"YFS_ITEM_UOM_MASTER Record not Inserted");
        }*/
      }
    } catch (NullPointerException ne) {
      log.error("------------Failed XML Needs to Catch for Re-Processing XML START ----------");
      log.error(SCXmlUtil.getString(UOMElement1));
      log.error("------------Failed XML Needs to Catch for Re-Processing XML END ----------");
      log.error("NullPointerException: " + ne.getStackTrace());
      prepareErrorObject(ne, XPXLiterals.UOM_B_TRANS_TYPE, XPXLiterals.NE_ERROR_CLASS, env, inXML);
      throw ne;
    } catch (YFSException yfe) {
      log.error("------------Failed XML Needs to Catch for Re-Processing XML START ----------");
      log.error(SCXmlUtil.getString(UOMElement1));
      log.error("------------Failed XML Needs to Catch for Re-Processing XML END ----------");
      log.error("YFSException: " + yfe.getStackTrace());
      prepareErrorObject(
          yfe, XPXLiterals.UOM_B_TRANS_TYPE, XPXLiterals.YFE_ERROR_CLASS, env, inXML);
      throw yfe;
    } catch (Exception e) {
      log.error("------------Failed XML Needs to Catch for Re-Processing XML START ----------");
      log.error(SCXmlUtil.getString(UOMElement1));
      log.error("------------Failed XML Needs to Catch for Re-Processing XML END ----------");
      log.error("Exception: " + e.getStackTrace());
      prepareErrorObject(e, XPXLiterals.UOM_B_TRANS_TYPE, XPXLiterals.E_ERROR_CLASS, env, inXML);
      throw e;
    }
    return inXML;
  }