コード例 #1
0
  // --createManageAssignmentInput function used to decide addition or deletion action of nodes
  public void createManageAssignmentInput(
      String strMILShareKey,
      String strCustID,
      String strCustPath,
      String strDivisionID,
      boolean action) {
    if (null == multiAPIDocElement) {
      multiAPIDocElement = YRCXmlUtils.createDocument("MultiApi").getDocumentElement();
    }
    Element APIele = YRCXmlUtils.createChild(multiAPIDocElement, "API");
    if (!action) APIele.setAttribute("FlowName", "deleteXPEDX_MyItemsDetailsShareList");
    else APIele.setAttribute("FlowName", "createXPEDX_MyItemsDetailsShareList");

    Element inputEle = YRCXmlUtils.createChild(APIele, "Input");
    Element lineEle =
        YRCXmlUtils.createFromString("<XPEDXMyItemsListShare CustomerID='" + strCustID + "'/>")
            .getDocumentElement();
    lineEle.setAttribute("CustomerPath", strCustPath);
    lineEle.setAttribute("MyItemsListKey", strMILKey);

    if (!YRCPlatformUI.isVoid(strMILShareKey))
      lineEle.setAttribute("MyItemsListShareKey", strMILShareKey);
    // Called for JIRA 4157
    if (!YRCPlatformUI.isVoid(strDivisionID)) {
      strDivisionID = strDivisionID.concat("_M");
      lineEle.setAttribute("DivisionID", strDivisionID);
    } else {
      int divisionHashSetsize = divisionHashSet.size();
      if (divisionHashSetsize == 1) {
        ArrayList<String> customerIDs = new ArrayList<String>();
        customerIDs.addAll(divisionHashSet);
        String strMasterDivisionID = customerIDs.get(0);
        if (!YRCPlatformUI.isVoid(strMasterDivisionID))
          strMasterDivisionID = strMasterDivisionID.concat("_M");
        lineEle.setAttribute("DivisionID", strMasterDivisionID);
        divisionHashSet = new HashSet();
      }
    }

    YRCXmlUtils.importElement(inputEle, lineEle);

    // InPut XML prepared for changeXPEDX_MyItemsList API
    Element eleXPEDXMyItemsList =
        YRCXmlUtils.createDocument("XPEDXMyItemsList").getDocumentElement();
    eleXPEDXMyItemsList.setAttribute("MyItemsListKey", strMILKey);
    eleXPEDXMyItemsList.setAttribute("SharePrivate", "");
    eleXPEDXMyItemsList.setAttribute("ShareAdminOnly", "");
    Element XPEDXMyItemsListShareListelem =
        YRCXmlUtils.createChild(eleXPEDXMyItemsList, "XPEDXMyItemsListShareList");
    XPEDXMyItemsListShareListelem.setAttribute("Reset", "true");

    // changeXPEDX_MyItemsList API Called for removing the my items list from personal list when it
    // got shared....
    YRCApiContext apiCtx = new YRCApiContext();
    String[] apinames = {"changeXPEDX_MyItemsList"};
    apiCtx.setApiNames(apinames);
    apiCtx.setInputXml(eleXPEDXMyItemsList.getOwnerDocument());
    apiCtx.setFormId(getFormId());
    callApi(apiCtx);
  }
コード例 #2
0
 private void getCustomerAssignmentsAfterUpdate() {
   YRCApiContext apiCtx = new YRCApiContext();
   String[] apinames = {"getXPEDXMyItemsListDetail"};
   Document[] docInput = {
     YRCXmlUtils.createFromString("<XPEDXMyItemsList MyItemsListKey='" + strMILKey + "'/>")
   };
   apiCtx.setApiNames(apinames);
   apiCtx.setInputXmls(docInput);
   apiCtx.setUserData("isCustomerListQueried", true);
   apiCtx.setFormId(getFormId());
   callApi(apiCtx);
 }
コード例 #3
0
 public void initPage() {
   YRCApiContext apiCtx = new YRCApiContext();
   if (!YRCPlatformUI.isVoid(strMILCustomerID)) {
     String[] apinames = {"getListOfXPEDXMyItemsLists", "getCustomerList"};
     Document[] docInput = {
       YRCXmlUtils.createFromString("<XPEDXMyItemsList MyItemsListKey='" + strMILKey + "'/>"),
       YRCXmlUtils.createFromString("<Customer CustomerID='" + strMILCustomerID + "' />")
     };
     apiCtx.setApiNames(apinames);
     apiCtx.setInputXmls(docInput);
     apiCtx.setUserData("isCustomerListQueried", true);
   } else {
     String[] apinames = {"getXPEDXMyItemsListDetail"};
     Document[] docInput = {
       YRCXmlUtils.createFromString("<XPEDXMyItemsList MyItemsListKey='" + strMILKey + "'/>")
     };
     apiCtx.setApiNames(apinames);
     apiCtx.setInputXmls(docInput);
     apiCtx.setUserData("isCustomerListQueried", false);
   }
   apiCtx.setFormId(getFormId());
   callApi(apiCtx);
 }
コード例 #4
0
  public void handleApiCompletion(YRCApiContext ctx) {
    if (ctx.getInvokeAPIStatus() > 0) {
      if (page.isDisposed()) {
        YRCPlatformUI.trace("Page is Disposed");
      } else {
        String[] apinames = ctx.getApiNames();
        for (int i = 0; i < apinames.length; i++) {

          String apiname = apinames[i];
          if ("getListOfXPEDXMyItemsLists".equals(apiname)) {
            Element outXml = ctx.getOutputXmls()[i].getDocumentElement();
            Element eleMILDtls = YRCXmlUtils.getChildElement(outXml, "XPEDXMyItemsList");
            if (null != eleMILDtls) {
              Element eleShareList =
                  YRCXmlUtils.getChildElement(eleMILDtls, "XPEDXMyItemsListShareList");
              if (null != eleShareList) {
                ArrayList<Element> list =
                    YRCXmlUtils.getChildren(eleShareList, "XPEDXMyItemsListShare");
                assignedMap = null;
                if (null == assignedMap) {
                  assignedMap = new HashMap<String, Element>();
                }
                for (Element eleCustAssignment : list) {
                  String strCustID = eleCustAssignment.getAttribute("CustomerID");
                  if (!YRCPlatformUI.isVoid(strCustID)) {
                    assignedMap.put(strCustID, eleCustAssignment);
                  }
                }
                page.resetTreeAssignedValues(assignedMap);
              } // Share List
              setModel("XPEDXMyItemsList", eleMILDtls);
              strMILCustomerID = eleMILDtls.getAttribute("CustomerID");

              if (!YRCPlatformUI.isVoid(strMILCustomerID)
                  && !(Boolean) ctx.getUserData("isCustomerListQueried")) {
                YRCApiContext apiCtx = new YRCApiContext();
                String cmdName = "getCustomerList";
                Document docInput =
                    YRCXmlUtils.createFromString(
                        "<Customer CustomerID='" + strMILCustomerID + "' />");
                apiCtx.setApiName(cmdName);
                apiCtx.setInputXml(docInput);
                apiCtx.setFormId(getFormId());
                callApi(apiCtx);
              } else if (YRCPlatformUI.isVoid(strMILCustomerID)) {
                YRCPlatformUI.showError("Error", "Unable to retrive the ");
              }
            }
          } else if ("getCustomerList".equals(apiname)) {
            System.out.println("its inside the api call-->>");

            Element outXml = ctx.getOutputXmls()[i].getDocumentElement();
            setModel("XPXGetImmediateChildCustomerListService", outXml);

            String strCustomerKey =
                YRCXmlUtils.getAttributeValue(outXml, "/CustomerList/Customer/@CustomerKey");
            String strCustomerID =
                YRCXmlUtils.getAttributeValue(outXml, "/CustomerList/Customer/@CustomerID");
            String strOrgCode =
                YRCXmlUtils.getAttributeValue(outXml, "/CustomerList/Customer/@OrganizationCode");
            String strSuffixType =
                YRCXmlUtils.getAttributeValue(
                    outXml, "/CustomerList/Customer/Extn/@ExtnSuffixType");
            if (YRCPlatformUI.isVoid(strSuffixType) || !"MC".equals(strSuffixType)) {
              YRCApiContext apiCtx = new YRCApiContext();
              String cmdName = "XPXGetParentCustomerListService";
              Document docInput =
                  YRCXmlUtils.createFromString(
                      "<Customer CustomerID='"
                          + strCustomerID
                          + "' OrganizationCode='"
                          + strOrgCode
                          + "'/>");
              apiCtx.setApiName(cmdName);
              apiCtx.setInputXml(docInput);
              apiCtx.setFormId(getFormId());
              callApi(apiCtx);
            } else {
              this.getChildList(); // --function used to set the values of child nodes in Tree
              // structure
            }
          } else if ("XPXGetParentCustomerListService".equals(apiname)) {
            // Set the Global Variable CustomerPath Prefix
            // XPXGetParentCustomerListService List output will be from Queried_Customer(lower) to
            // Master_Customer(top)
            Element outXml = ctx.getOutputXmls()[i].getDocumentElement();
            setModel("XPXGetParentCustomerListService", outXml);
            boolean isFirstCustElement = true;
            if (outXml != null && outXml.hasChildNodes()) {
              NodeList childList = outXml.getChildNodes();
              for (int j = 0; j < childList.getLength(); j++) {
                if ((childList.item(j) instanceof Element)
                    && "Customer".equals(childList.item(j).getNodeName())) {
                  Element eleCustomer = (Element) childList.item(j);
                  if (!isFirstCustElement) {
                    if (!YRCPlatformUI.isVoid(strCustomerPathPrefix)) {
                      strCustomerPathPrefix = "|" + strCustomerPathPrefix;
                    }
                    strCustomerPathPrefix =
                        eleCustomer.getAttribute("CustomerID") + strCustomerPathPrefix;
                  } else {
                    // This eats up the first Customer Element in the loop
                    isFirstCustElement = false;
                  }
                }
              }
            }
            ArrayList listParentCustomers = YRCXmlUtils.getChildren(outXml, "Customer");
            int numberOfCustomer = 0;
            if (!YRCPlatformUI.isVoid(listParentCustomers)) {
              for (int k = 0; k < listParentCustomers.size(); k++) {
                Element customerEle = (Element) listParentCustomers.get(k);
                String CustomerIDValue = YRCXmlUtils.getAttribute(customerEle, "CustomerID");
                parentcustomer.add(CustomerIDValue);
                numberOfCustomer = parentcustomer.size();
              }
            }
            if (numberOfCustomer == 3) {
              String strMasterCustomerID = (String) parentcustomer.get(2);
              YRCApiContext apiCtx = new YRCApiContext();
              String cmdName = "getCustomerList";
              Document docInput =
                  YRCXmlUtils.createFromString(
                      "<Customer CustomerID='" + strMasterCustomerID + "' />");
              apiCtx.setApiName(cmdName);
              apiCtx.setInputXml(docInput);
              apiCtx.setFormId(getFormId());
              callApi(apiCtx);
            } else if (numberOfCustomer == 4) {
              String strMasterCustomerID = (String) parentcustomer.get(3);
              YRCApiContext apiCtx = new YRCApiContext();
              String cmdName = "getCustomerList";
              Document docInput =
                  YRCXmlUtils.createFromString(
                      "<Customer CustomerID='" + strMasterCustomerID + "' />");
              apiCtx.setApiName(cmdName);
              apiCtx.setInputXml(docInput);
              apiCtx.setFormId(getFormId());
              callApi(apiCtx);
            } else if (numberOfCustomer == 2) {
              String strMasterCustomerID = (String) parentcustomer.get(1);
              YRCApiContext apiCtx = new YRCApiContext();
              String cmdName = "getCustomerList";
              Document docInput =
                  YRCXmlUtils.createFromString(
                      "<Customer CustomerID='" + strMasterCustomerID + "' />");
              apiCtx.setApiName(cmdName);
              apiCtx.setInputXml(docInput);
              apiCtx.setFormId(getFormId());
              callApi(apiCtx);
            }
            // this.getChildList();    //--function used to set the values of child nodes in Tree
            // structure
          } else if ("multiApi".equals(apiname)) {
            updateAssignFlag = true;
            updateMyitemsList();
            ((XPXUserProfileEditor) YRCDesktopUI.getCurrentPart()).showBusy(false);
          }
          // Called for JIRA 4157
          else if ("XPXCustomerHierarchyViewService".equals(apiname)) {
            Element outXml = ctx.getOutputXmls()[i].getDocumentElement();
            NodeList XPXCustHierarchyViewNodeList =
                outXml.getElementsByTagName("XPXCustHierarchyView");
            if (XPXCustHierarchyViewNodeList != null
                && XPXCustHierarchyViewNodeList.getLength() > 0) {
              for (int k = 0; k < XPXCustHierarchyViewNodeList.getLength(); k++) {
                Element eleMyItemsList = (Element) XPXCustHierarchyViewNodeList.item(k);
                String strDivisionID = eleMyItemsList.getAttribute("ExtnCustomerDivision");
                if (strDivisionID != "") {
                  divisionHashSet.add(strDivisionID);
                }
              }
            }
          } else if ("updateXPEDXMyItemsList".equals(apiname)) {
            Element outXml = ctx.getOutputXmls()[i].getDocumentElement();
            Element eleMyItemsList = YRCXmlUtils.getXPathElement(outXml, "/XPEDXMyItemsList");
            setModel("getXPEDXMyItemsListDetail", eleMyItemsList);
            this.getCustomerAssignmentsAfterUpdate();
          }
        }
      }
    }
    // In case of Invoke API failure
    else if (ctx.getInvokeAPIStatus() == -1) {
      Element outXml = ctx.getOutputXml().getDocumentElement();
      if ("Errors".equals(outXml.getNodeName())) {
        Element errorEle = (Element) outXml.getElementsByTagName("Error").item(0);
        if (!YRCPlatformUI.isVoid(errorEle)) {
          YRCPlatformUI.trace(errorEle.getAttribute("ErrorDescription"), outXml);
          YRCPlatformUI.showError("Failed!", errorEle.getAttribute("ErrorDescription"));
        }
      }
    }

    super.handleApiCompletion(ctx);
  }