// --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);
  }
  // Called for JIRA 4157
  private void getDivisionSet(String strMasterCustomerID) {

    if (strMasterCustomerID != null) {
      Element XPXCustHierarchyViewelem =
          YRCXmlUtils.createDocument("XPXCustHierarchyView").getDocumentElement();
      XPXCustHierarchyViewelem.setAttribute("MSAPCustomerID", strMasterCustomerID);
      callApi("XPXCustomerHierarchyViewService", XPXCustHierarchyViewelem.getOwnerDocument());
    }
  }
  public void loadIntialDataAndSetModel() {
    Element eDummy = YRCXmlUtils.createDocument("Organization").getDocumentElement();
    setModel("DivisionSearchCriteria", eDummy);

    // Get List Of Brands
    Document docGetBrandsIn = YRCXmlUtils.createDocument("CommonCode");
    docGetBrandsIn
        .getDocumentElement()
        .setAttribute("CodeType", XPXConstants.COMMON_CODE_XPX_BRAND);
    /* commented because Brands are configured at DEFAULT Level
     * docGetBrandsIn.getDocumentElement().setAttribute("CallingOrganizationCode", YRCPlatformUI.getUserElement().getAttribute("EnterpriseCode"));
     */
    docGetBrandsIn
        .getDocumentElement()
        .setAttribute("CallingOrganizationCode", XPXConstants.COMMON_CODE_XPX_BRAND_DEFAULT_ORG);

    YRCApiContext context = new YRCApiContext();
    context.setApiName("XPXBrandCodesList");
    context.setFormId(page.getFormId());
    context.setInputXml(docGetBrandsIn);
    callApi(context);
  }
  @Override
  public void execute(IAction arg0) {

    WorkbenchPart workbench = YRCDesktopUI.getCurrentPart();
    workbench.setFocus();

    Element eInput = YRCXmlUtils.createDocument("SearchCriteria").getDocumentElement();
    YRCXmlUtils.setAttribute(eInput, "ReferenceOrderSearchEditorKey", System.currentTimeMillis());
    YRCEditorInput editorInput = null;
    editorInput = new YRCEditorInput(eInput, new String[] {""}, "");

    boolean b = YRCPlatformUI.openEditor(XPXRefOrderSearchEditor.ID_EDITOR, editorInput);
  }
  private Document createUpdateXPEDXMyItemsListInput(Element eleUpdateMyItemsListData) {

    Element updateXPEDXMyItemsListInput =
        YRCXmlUtils.createDocument("XPEDXMyItemsItemsList").getDocumentElement();
    String strCreatedByUsername = YRCPlatformUI.getUserElement().getAttribute("Username");
    String strModifyuserid = YRCPlatformUI.getUserElement().getAttribute("Loginid");
    updateXPEDXMyItemsListInput.setAttribute("MyItemsListKey", strMILKey);
    updateXPEDXMyItemsListInput.setAttribute("Name", eleUpdateMyItemsListData.getAttribute("Name"));
    updateXPEDXMyItemsListInput.setAttribute("Desc", eleUpdateMyItemsListData.getAttribute("Desc"));
    if (!YRCPlatformUI.isVoid(strCreatedByUsername)) {
      updateXPEDXMyItemsListInput.setAttribute("ModifyUserName", strCreatedByUsername);
      updateXPEDXMyItemsListInput.setAttribute("Modifyuserid", strModifyuserid);
    }
    Element xPEDXMyItemsItemsList =
        YRCXmlUtils.createChild(updateXPEDXMyItemsListInput, "XPEDXMyItemsItemsList");
    NodeList nlItems = eleUpdateMyItemsListData.getElementsByTagName("XPEDXMyItemsItems");

    // System.out.println("The file is not updated");
    Calendar currentDate = Calendar.getInstance();
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    String dateNow = formatter.format(currentDate.getTime());
    updateXPEDXMyItemsListInput.setAttribute("Modifyts", dateNow);

    for (int i = 0; i < nlItems.getLength(); i++) {

      Element tempElement = (Element) nlItems.item(i);
      Element xPEDXMyItemsItems =
          YRCXmlUtils.createChild(xPEDXMyItemsItemsList, "XPEDXMyItemsItems");
      xPEDXMyItemsItems.setAttribute("MyItemsKey", tempElement.getAttribute("MyItemsKey"));
      xPEDXMyItemsItems.setAttribute("MyItemsListKey", strMILKey);
      xPEDXMyItemsItems.setAttribute("Qty", tempElement.getAttribute("Qty"));
      xPEDXMyItemsItems.setAttribute("ItemPoNumber", tempElement.getAttribute("ItemPoNumber"));
      xPEDXMyItemsItems.setAttribute("JobId", tempElement.getAttribute("JobId"));
      xPEDXMyItemsItems.setAttribute("UomId", tempElement.getAttribute("UomId"));
      xPEDXMyItemsItems.setAttribute("ItemOrder", tempElement.getAttribute("ItemOrder"));
    }
    return updateXPEDXMyItemsListInput.getOwnerDocument();
  }