private Document prepareInputXMLToSearch() { Element eleSearchCriteria = getTargetModel("DivisionSearchCriteria"); eleSearchCriteria.setAttribute("IsNode", "Y"); if (!YRCPlatformUI.isVoid( YRCXmlUtils.getAttributeValue(eleSearchCriteria, "Organization/Extn/@ExtnBrandCode"))) { YRCXmlUtils.setAttributeValue( eleSearchCriteria, "Organization/Extn/@ExtnBrandCodeQryType", "LIKE"); } String strDivision = eleSearchCriteria.getAttribute("OrganizationCodeOrName"); if (!YRCPlatformUI.isVoid(strDivision)) { Element eleCQ = YRCXmlUtils.createChild(eleSearchCriteria, "ComplexQuery"); Element eleOr = YRCXmlUtils.createChild(eleCQ, "Or"); Element eleExpCode = YRCXmlUtils.createChild(eleOr, "Exp"); eleExpCode.setAttribute("Name", "OrganizationCode"); eleExpCode.setAttribute("Value", strDivision); eleExpCode.setAttribute("QryType", "LIKE"); Element eleExpName = YRCXmlUtils.createChild(eleOr, "Exp"); eleExpName.setAttribute("Name", "OrganizationName"); eleExpName.setAttribute("Value", strDivision); eleExpName.setAttribute("QryType", "LIKE"); } else { if (eleSearchCriteria.hasAttribute("OrganizationCodeOrName")) { eleSearchCriteria.removeAttribute("OrganizationCodeOrName"); } } return eleSearchCriteria.getOwnerDocument(); }
public void getChildList() { Element childCustomerList = getModel("XPXGetImmediateChildCustomerListService"); String strMasterCustomerID = YRCXmlUtils.getAttributeValue(childCustomerList, "/CustomerList/Customer/@CustomerID"); // Called for JIRA 4157 getDivisionSet(strMasterCustomerID); Element customerElement = YRCXmlUtils.getChildElement(childCustomerList, "Customer"); ArrayList<Element> arrlst = new ArrayList<Element>(); arrlst.add(customerElement); page.setTreeValues( null, arrlst); // --function used to set the values of child nodes in Tree structure }
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); }