コード例 #1
0
 public static int getPartyActivationLevelForPartyRole(String partyRoleCode) throws Exception {
   int activationLevel = 0;
   if (partyRoleCode != null && !"".equals(partyRoleCode)) {
     if (roleActivationLevelMap.containsKey(partyRoleCode)) {
       activationLevel = ((Integer) roleActivationLevelMap.get(partyRoleCode)).intValue();
     } else if (roleActivationLevelMap.size() == 0) {
       try {
         LogicModuleService lms = LogicModuleServiceUtil.getHome().create();
         ObjectQueryCommand additionalCommand =
             new ObjectQueryCommand("com.foursoft.etrans.entities.PartyRoleType", Locale.US);
         additionalCommand.setAttributeNames(new String[] {"code", "roleDependencyIndicator"});
         additionalCommand.sethasLocaleData(false);
         Object[][] data = lms.getTableModel(additionalCommand).getData();
         if (data != null && data.length > 0) {
           for (int i = 0; i < data.length; i++) {
             String code = (String) data[i][0];
             Integer roleActivationLevel =
                 (Integer) ((RoleDependencyIndicatorEnumeration) data[i][1]).getEnumCode();
             if (code != null && !"".equals(code) && roleActivationLevel != null) {
               if (partyRoleCode.equals(code)) activationLevel = roleActivationLevel.intValue();
               roleActivationLevelMap.put(code, roleActivationLevel);
             }
           }
         }
       } finally {
       }
     }
   }
   return activationLevel;
 }
コード例 #2
0
 public String[] getRelatedPartiesForParty(String partyId, String relationshipType)
     throws Exception {
   String[] ret = null;
   try {
     LogicModuleService lms = LogicModuleServiceUtil.getHome().create();
     Serializable mainPartyId = null;
     ObjectQueryCommand additionalCommand =
         new ObjectQueryCommand("com.foursoft.etrans.entities.BusinessParty", Locale.US);
     additionalCommand.setAttributeNames(new String[] {"code"});
     additionalCommand.sethasLocaleData(false);
     additionalCommand.setPaginationEnabled(false);
     additionalCommand.addFilterCriterion("code", ObjectQueryCommand.OPERATOR_EQUALS, partyId);
     IdTableModel additionalTableModel = lms.getTableModel(additionalCommand);
     Object[][] data = additionalTableModel.getData();
     if (data != null && data.length > 0) {
       mainPartyId = additionalTableModel.getIdForRow(0); // Id retrieval
     }
     if (mainPartyId != null) {
       additionalCommand =
           new ObjectQueryCommand("com.foursoft.etrans.entities.PartyRelationShip", Locale.US);
       additionalCommand.setAttributeNames(new String[] {"relatedParty.code"});
       additionalCommand.setPaginationEnabled(false);
       additionalCommand.sethasLocaleData(false);
       ParentInfo parentInfo = null;
       parentInfo = new ParentInfo();
       parentInfo.setClassname("com.foursoft.etrans.entities.BusinessParty");
       parentInfo.setId(mainPartyId);
       parentInfo.setChildRelationName("partyRelationShips");
       additionalCommand.setParentInfo(parentInfo);
       additionalCommand.addFilterCriterion(
           "partyRelshipType.code", ObjectQueryCommand.OPERATOR_EQUALS, relationshipType);
       data = lms.getTableModel(additionalCommand).getData();
       if (data != null && data.length > 0) {
         ArrayList relatedParties = new ArrayList();
         for (int i = 0; i < data.length; i++) relatedParties.add((String) data[i][0]);
         if (relatedParties.size() > 0)
           ret = (String[]) relatedParties.toArray(new String[relatedParties.size()]);
       }
     }
   } finally {
   }
   return ret;
 }
コード例 #3
0
 public String[] getDefaultSalespersonForCustomer(String customerId, String branchId)
     throws Exception {
   String[] ret = null;
   try {
     String[] salesPersonArray = getRelatedPartiesForParty(customerId, "*SALESPERSON");
     LogicModuleService lms = LogicModuleServiceUtil.getHome().create();
     ObjectQueryCommand additionalCommand =
         new ObjectQueryCommand("com.foursoft.etrans.entities.BusinessParty", Locale.US);
     additionalCommand.setAttributeNames(new String[] {"code", "nickName"});
     additionalCommand.sethasLocaleData(false);
     additionalCommand.addFilterCriterion(
         "partyRoleCrossRefs.partyRoleType.code",
         ObjectQueryCommand.OPERATOR_EQUALS,
         "*SALESPERSON");
     int salesPersonActivationLevel = getPartyActivationLevelForPartyRole("*SALESPERSON");
     if (salesPersonActivationLevel == 2
         && branchId != null
         && !"".equals(branchId)
         && branchId.length() >= 3)
       additionalCommand.addFilterCriterion(
           "partyRoleCrossRefs.activatedCompanyPartyId",
           ObjectQueryCommand.OPERATOR_EQUALS,
           branchId.substring(0, 3));
     if (salesPersonActivationLevel == 3
         && branchId != null
         && !"".equals(branchId)
         && branchId.length() == 6)
       additionalCommand.addFilterCriterion(
           "partyRoleCrossRefs.activatedBranchPartyId",
           ObjectQueryCommand.OPERATOR_EQUALS,
           branchId);
     additionalCommand.addFilterCriterion(
         "code", ObjectQueryCommand.OPERATOR_IN, salesPersonArray);
     Object[][] data = lms.getTableModel(additionalCommand).getData();
     if (data != null && data.length == 1) {
       ret = new String[2];
       ret[0] = (String) data[0][0];
       ret[1] = (String) data[0][1];
     }
   } finally {
   }
   return ret;
 }