首页 > 其他分享 >Teamcenter 产品配置前操作代码

Teamcenter 产品配置前操作代码

时间:2024-06-23 11:31:23浏览次数:40  
标签:代码 配置 ModelObject Teamcenter base input put new properties

  import java.math.BigInteger; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set;
import org.apache.log4j.Logger;
import com.cfg0.services.internal.strong.configurator.ConfiguratorManagementService; import com.cfg0.services.internal.strong.configurator._2015_10.ConfiguratorManagement.ApplicationConfigExpression; import com.cfg0.services.internal.strong.configurator._2015_10.ConfiguratorManagement.BusinessObjectConfigExpression; import com.cfg0.services.internal.strong.configurator._2015_10.ConfiguratorManagement.ConfigExpression; import com.cfg0.services.internal.strong.configurator._2015_10.ConfiguratorManagement.ConfigExpressionGroup; import com.cfg0.services.internal.strong.configurator._2015_10.ConfiguratorManagement.ConfigExpressionSet; import com.cfg0.services.internal.strong.configurator._2015_10.ConfiguratorManagement.ConfigExpressionTerm; import com.cfg0.services.internal.strong.configurator._2015_10.ConfiguratorManagement.ConfigSubExpression; import com.cfg0.services.internal.strong.configurator._2015_10.ConfiguratorManagement.ConvertVariantExpressionInput; import com.cfg0.services.internal.strong.configurator._2015_10.ConfiguratorManagement.ConvertVariantExpressionsResponse; import com.cfg0.services.internal.strong.configurator._2015_10.ConfiguratorManagement.SetVariantExpressionInput; import com.real.session.cfg.BaseSession; import com.real.session.manager.RealSessionManager; import com.sotos.uif.exception.TCOperationException; import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; import com.teamcenter.services.internal.strong.core.ICTService; import com.teamcenter.services.internal.strong.core._2011_06.ICT; import com.teamcenter.services.internal.strong.core._2011_06.ICT.Arg; import com.teamcenter.services.internal.strong.core._2011_06.ICT.Entry; import com.teamcenter.services.strong.core.DataManagementService; import com.teamcenter.services.strong.core._2007_01.DataManagement.VecStruct; import com.teamcenter.services.strong.core._2008_06.DataManagement.CreateIn; import com.teamcenter.services.strong.core._2008_06.DataManagement.CreateInput; import com.teamcenter.services.strong.core._2008_06.DataManagement.CreateOut; import com.teamcenter.services.strong.core._2008_06.DataManagement.CreateResponse; import com.teamcenter.soa.client.model.ModelObject; import com.teamcenter.soa.client.model.ServiceData; import com.teamcenter.soa.client.model.Type; import com.teamcenter.soa.client.model.strong.Cfg0AbsFamily; import com.teamcenter.soa.client.model.strong.Cfg0AbsValue; import com.teamcenter.soa.client.model.strong.Cfg0ConfiguratorPerspective; import com.teamcenter.soa.client.model.strong.RevisionRule; import com.teamcenter.soa.exceptions.NotLoadedException;
public class ConfigurationOperation {
    static Logger logger = Logger.getLogger(ConfigurationOperation.class);     /*public static void main(String[] args) {         ModelObject dictionary = TcUtil.getModelObjectByUid("g6Z9sVFy4TQ6oA");         ModelObject family = TcUtil.getModelObjectByUid("w1b9spRf4TQ6oA");         try {             //createFamily(dictionary,familygroup,"Fam6","CustFam5");             //createFamilies(dictionary, familygroup, new String[]{"Famqq5","Famqq6"}, new String[]{"CustFam9","CustFam10"});             //createOptionValue(dictionary,family,"V2","V1Desc");             createOptionValues(dictionary,family,new String[]{"V3","V4"},new String[]{"V3Desc","V4Desc"});         } catch (ServiceException e) {             // TODO Auto-generated catch block             e.printStackTrace();         }     }*/         public BaseSession tcSession = null;     public TCTools tool;     public ConfigurationOperation(BaseSession tcSession){         this.tcSession = tcSession;         tool = new TCTools(tcSession);     }         public static void main(String[] args) { //      try { //          ModelObject queryFamilyGroup = queryFamilyGroup("TestBatch1W"); //          logger.info(queryFamilyGroup); //          ModelObject queryFamily = queryFamily("Famqq5W"); //          logger.info(queryFamily); //          ModelObject queryOptionValue = queryOptionValue("ER4W"); //          logger.info(queryOptionValue); //      } catch (TCOperationException e) { //          // TODO Auto-generated catch block //          e.printStackTrace(); //      }         /*try {             createConfigurationContext("VDL010","CVTest","CVDesc");         } catch (ServiceException e) {             // TODO Auto-generated catch block             e.printStackTrace();         }*/         //      ModelObject cc = TcUtil.getModelObjectByUid("Q9Z9N9pS4TQ6oA"); //      ModelObject queryFamilyGroup; //      try { //          queryFamilyGroup = queryFamilyGroup("Safety"); //          //queryFamilyGroup = queryOptionValue("V2"); //          updateObjecttoConfigurationContext(cc,queryFamilyGroup); //      } catch (TCOperationException e) { //          // TODO Auto-generated catch block //          e.printStackTrace(); //      } catch (ServiceException e) { //          // TODO Auto-generated catch block //          e.printStackTrace(); //      }         //      try { //          removeObjectfromConfigurationContext("VDL010","Safety"); //      } catch (TCOperationException e) { //          // TODO Auto-generated catch block //          e.printStackTrace(); //      } catch (ServiceException e) { //          // TODO Auto-generated catch block //          e.printStackTrace(); //      }                                 /*ModelObject cfgcontext  =  TcUtil.getModelObjectByUid("Q9Z9N9pS4TQ6oA");         if(cfgcontext != null){             try {                 ModelObject newSVR = createSVR("testsvr", "testsvrdesc", cfgcontext);                 Map<ModelObject,ModelObject> family_option_valus_map = new HashMap<ModelObject,ModelObject>();                 ModelObject family = queryFamily("BX");                 ModelObject option_value = queryOptionValue("BX01");                                 ModelObject family1 = queryFamily("Famqq6");                 ModelObject option_value1 = queryOptionValue("V1");                                 family_option_valus_map.put(family,option_value);                 family_option_valus_map.put(family1,option_value1);                                 createSVRBasedOnOptions(newSVR, family_option_valus_map);             } catch (ServiceException e) {                 // TODO Auto-generated catch block                 e.printStackTrace();             } catch (TCOperationException e) {                 // TODO Auto-generated catch block                 e.printStackTrace();             }         }*/         /*try {             ModelObject configuremodelObject = TcUtil.getModelObjectByUid("Q9Z9N9pS4TQ6oA");             ModelObject perspective = TcUtil.getModelObjectPropertyValue(configuremodelObject, "cfg0ConfigPerspective");             Map<ModelObject,ModelObject> family_option_valus_map = new HashMap<ModelObject,ModelObject>();                         ModelObject family = TcUtil.getModelObjectByUid("xkbtm2RK4TQ6oA");             ModelObject option_value = TcUtil.getModelObjectByUid("RWZtGDpB4TQ6oA");                         ModelObject family1 = TcUtil.getModelObjectByUid("w1b9spRf4TQ6oA");             ModelObject option_value1 = TcUtil.getModelObjectByUid("w9Y9spRf4TQ6oA");                         family_option_valus_map.put(family,option_value);             family_option_valus_map.put(family1,option_value1);                         String formula = getExpressionBasedOnConfig(perspective, family_option_valus_map);             System.out.println("formula is "+formula);             TCBOMUitl bomutil = new TCBOMUitl();             ModelObject ir = TcUtil.getModelObjectByUid("A7e98eDC4TQ6oA");             bomutil.createBOMWindowWithIR(ir);             try {                 TcUtil.loadObjectProperties(bomutil.getTopline(), new String[]{"bl_all_child_lines","bl_has_children"});                 if(bomutil.getTopline().get_bl_has_children()){                     ModelObject[] childrens = bomutil.getTopline().get_bl_all_child_lines();                     for (int i = 0; i < childrens.length; i++) {                         TcUtil.setPropertyStringValue(childrens[i], "bl_formula", formula);                     }                                     }             } catch (NotLoadedException e) {                 // TODO Auto-generated catch block                 e.printStackTrace();             }             bomutil.saveBOMWindow();             bomutil.closeBOMWindow();         } catch (TCOperationException e) {             // TODO Auto-generated catch block             e.printStackTrace();         }*/ //      try { //          TcSession_1 session = new TcSession_1(); //          ConfigurationOperation cfgOp = new ConfigurationOperation(session); //          cfgOp.createConfigurationContext("","CVTest22","CVDesc"); //      } catch (ServiceException e) { //      // TODO Auto-generated catch block //      e.printStackTrace(); //      }             }     public static final String QUERY_FAMILY_GROUP = "__FamilyGroup";//根据familygroup的ID只查询familygroup     public static final String QUERY_FAMILY_GROUP_WITH_DICTIONARY = "__FamilyGroup";//根据familygroup的ID以及Dictionary的ID查询familygroup         public static final String QUERY_FAMILY = "__Cfg0Families";//根据family的ID只查询family     public static final String QUERY_FAMILY_WITH_DICTIONARY = "__Cfg0OptionFamiliesFromIDs";//根据family的ID以及Dictionary的ID只查询family         public static final String QUERY_OPTION_VALUE = "__Cfg0OptionValuesFromValueIDs";     public static final String QUERY_OPTION_VALUE_WITH_DICTIONARY = "__Cfg0OptionValuesFromValueIDs";//根据optionvalue的ID以及Dictionary的ID只查询选项值         public static final String QUERY_OPTION_VALUE_WITH_FAMILY = "__Cfg0OptionValuesFromOptionFamilyIDs";//根据选项的ID以及Dictionary的ID只查询选项值         public static final String QUERY_ALLOCATION_VALUE = "__Cfg0GetAllocationForProduct_CV";//根据配置器关联的ID以及Allocation的名称只查询Allocation         public static final String QUERY_CONFIGURATION_CONTEXT_VALUE = "__Configuration_Item_Name_or_ID";//根据配置器关联的ID以及Allocation的名称只查询Allocation         /**      * 转换变量表达式      * @param perspective      * @param family_optionsvaluesmap 选项/选项值键值对,仅仅可以用于OR      */     public  String getExpressionBasedOnConfig(ModelObject perspective,Map<ModelObject,ModelObject> family_optionsvaluesmap){         ConfiguratorManagementService configservice = ConfiguratorManagementService.getService(this.tcSession.getConnection());         //configservice.getAdmissibility                 SetVariantExpressionInput[] paramArrayOfSetVariantExpressionInput = null;         RevisionRule paramRevisionRule = null;         paramArrayOfSetVariantExpressionInput[0].saveExpressions = true;         configservice.setVariantExpressions(paramArrayOfSetVariantExpressionInput, paramRevisionRule);                 ConvertVariantExpressionInput[]  inputs = new ConvertVariantExpressionInput[1];         ConvertVariantExpressionInput input = new ConvertVariantExpressionInput();         inputs[0] = input;                 ApplicationConfigExpression[] configexpressions = new ApplicationConfigExpression[1];         ApplicationConfigExpression configexpression = new ApplicationConfigExpression();         configexpressions[0] = configexpression;                         ConfigExpressionSet[] sets = new ConfigExpressionSet[1];         ConfigExpressionSet set = new ConfigExpressionSet();                         ConfigExpression[] ces = new ConfigExpression[1];         ConfigExpression ce = new ConfigExpression();         ces[0] = ce;                 ConfigSubExpression[] subexpressions = new ConfigSubExpression[1];         ConfigSubExpression subexpression = new ConfigSubExpression();         subexpressions[0] = subexpression;                 /**          * 一组内部表示其关系是OR关系          * 组与组之间表示的是AND关系,其中可以通过复杂组合进行group的封装          * OperationCode 5 表示等于          * OperationCode 6 表示不等于          */         ConfigExpressionGroup[] groups = null;         if(family_optionsvaluesmap.size() > 0){             groups = new ConfigExpressionGroup[family_optionsvaluesmap.size()];             Set keySet = family_optionsvaluesmap.keySet();             Iterator itr = keySet.iterator();             int count = 0;             while(itr.hasNext()){                                 ModelObject family = (ModelObject) itr.next();                 ModelObject option_value = family_optionsvaluesmap.get(family);                 String familyID = tool.getCommonPropertyValue(family, "cfg0ObjectId");                 String valueText = tool.getCommonPropertyValue(option_value, "cfg0ObjectId");                                 ConfigExpressionTerm[] terms = new ConfigExpressionTerm[1];                 ConfigExpressionTerm term = new ConfigExpressionTerm();                 terms[0] = term;                                 term.familyID = familyID;                 term.familyNamespace = "Teamcenter";                 term.operatorCode = 5;                 term.valueText = valueText;                                 groups[count] = new ConfigExpressionGroup();                 groups[count].groupName ="";                 groups[count].terms = terms;                                 count++;             }         }                 subexpression.expressionGroups  = groups;                 ce.clientID ="";         ce.expressionType = 23;         ce.formula = "";         ce.subExpressions = subexpressions;                         set.configExpressions = ces;                 configexpression.exprID="";         configexpression.expressionType = 23;         configexpression.formula = "";         configexpression.configExprSets = sets;                 input.clientId = "";         input.expressionFormat = 0;         input.exprsToConvert = configexpressions;         Type typeObjectperspective = perspective.getTypeObject();         Cfg0ConfiguratorPerspective persptcive_temp = new  Cfg0ConfiguratorPerspective(typeObjectperspective, perspective.getUid());         input.context = persptcive_temp;//perspective         ConvertVariantExpressionsResponse convertVariantExpressions = configservice.convertVariantExpressions(inputs);         String formula = convertVariantExpressions.outputs[0].applConfigExprsWithDisplayString[0].applConfigExpr.formula;                 return formula;     }     /**      * 构建SVR变量表达式      * @param svr      * @param family_optionsvaluesmap      */     public  void createSVRBasedOnOptions(ModelObject svr,Map<ModelObject,ModelObject> family_optionsvaluesmap){         ConfiguratorManagementService configservice = ConfiguratorManagementService.getService(this.tcSession.getConnection());         SetVariantExpressionInput[]  inputs = new SetVariantExpressionInput[1];         SetVariantExpressionInput input = new SetVariantExpressionInput();         inputs[0] = input;                         ApplicationConfigExpression[] configexpressions = new ApplicationConfigExpression[1];         ApplicationConfigExpression configexpression = new ApplicationConfigExpression();         configexpressions[0] = configexpression;                 ConfigExpressionSet[] sets = new ConfigExpressionSet[1];         ConfigExpressionSet set = new ConfigExpressionSet();         sets[0] = set;                         ConfigExpression[] ces = new ConfigExpression[1];         ConfigExpression ce = new ConfigExpression();         ces[0] = ce;                 ConfigSubExpression[] subexpressions = new ConfigSubExpression[1];         ConfigSubExpression subexpression = new ConfigSubExpression();         subexpressions[0] = subexpression;                 ConfigExpressionGroup[] groups = null;         if(family_optionsvaluesmap.size() > 0){             groups = new ConfigExpressionGroup[family_optionsvaluesmap.size()];             Set keySet = family_optionsvaluesmap.keySet();             Iterator itr = keySet.iterator();             int count = 0;             while(itr.hasNext()){                                 ModelObject family = (ModelObject) itr.next();                 ModelObject option_value = family_optionsvaluesmap.get(family);                 String familyID = tool.getCommonPropertyValue(family, "cfg0ObjectId");                 String valueText = tool.getCommonPropertyValue(option_value, "cfg0ObjectId"); //              System.out.println("set family"+familyID + "to:"+valueText);                 ConfigExpressionTerm[] terms = new ConfigExpressionTerm[1];                 ConfigExpressionTerm term = new ConfigExpressionTerm();                 terms[0] = term;                                 Type typeObjectfamily = family.getTypeObject();                 Cfg0AbsFamily absFamily = new Cfg0AbsFamily(typeObjectfamily,family.getUid());                 Type typeObjecttoption = option_value.getTypeObject();                 Cfg0AbsValue absOption = new Cfg0AbsValue(typeObjecttoption,option_value.getUid());                                 term.family = absFamily;                 term.value = absOption;                 term.familyID = familyID;                 term.familyNamespace = "Teamcenter";                 term.operatorCode = 5;                 term.valueText = valueText;                                 groups[count] = new ConfigExpressionGroup();                 groups[count].groupName ="";                 groups[count].terms = terms;                                 count++;             }         }                 subexpression.expressionGroups  = groups;                 ce.clientID ="";         ce.expressionType = 18;         ce.formula = "";         ce.subExpressions = subexpressions;                         set.configExpressions = ces;                 configexpression.exprID="";         configexpression.expressionType = 18;         configexpression.formula = "";         configexpression.configExprSets = sets;                 BusinessObjectConfigExpression[] businessobjectConfiexpressions = new BusinessObjectConfigExpression[1];         BusinessObjectConfigExpression businessobjectConfiexpression = new BusinessObjectConfigExpression();         businessobjectConfiexpressions[0] = businessobjectConfiexpression;         businessobjectConfiexpression.targetObject = svr;         businessobjectConfiexpression.clientId  = svr.getUid();         businessobjectConfiexpression.expressions = configexpressions;                         input.saveExpressions = true;         input.businessObjectExpressions = businessobjectConfiexpressions;         ServiceData setVariantExpressions = configservice.setVariantExpressions(inputs, null);         if(setVariantExpressions.sizeOfPartialErrors()>0){             logger.error("构建SVR错误,错误信息为:"+setVariantExpressions.getPartialError(0));         }else{             logger.info("构建SVR成功");         }     }     /**      * 创建SVR并将其挂在配置器关联下      * @param svrname      * @param svrdesc      * @return      * @throws ServiceException      * @throws TCOperationException      */     public  ModelObject createSVR(String svrname,String svrdesc,ModelObject configurationcontext) throws ServiceException, TCOperationException{         CreateIn[] inputs = new CreateIn[1];                 CreateIn input  = new CreateIn();         inputs[0]  = input ;                 Map<String,String> base_string_properties = new HashMap<String,String>();         base_string_properties.put("object_name", svrname);         base_string_properties.put("object_desc", svrdesc);                 input.data.boName = "VariantRule";         input.data.stringProps = base_string_properties;         //create         DataManagementService datamanagementservice = DataManagementService.getService(this.tcSession.getConnection());         CreateResponse response = datamanagementservice.createObjects(inputs);         ModelObject svr = response.output[0].objects[0];         if(svr != null){             logger.error("创建SVR成功");             if(configurationcontext != null){                 tool.createRelationships(configurationcontext, new ModelObject[]{svr}, "IMAN_reference");                 logger.error("SVR成功添加到配置器关联下");             }else{                 logger.error("SVR未添加到配置器关联下");             }         }         else{             logger.error("创建SVR失败");         }         return svr;     }     /**      * 批量创建SVR,并且将其挂在配置器关联对象下      * @param svrname      * @param svrdesc      * @return      * @throws ServiceException      * @throws TCOperationException      */     public  ModelObject[] createSVRS(String[] svrname,String svrdesc[],ModelObject configurationcontext) throws ServiceException, TCOperationException{         ModelObject[] svrs = null;         if(svrname!= null && svrname.length > 0){             CreateIn[] inputs = new CreateIn[svrname.length];             for (int i = 0; i < svrname.length; i++) {                 CreateIn input  = new CreateIn();                 inputs[i]  = input ;                 Map<String,String> base_string_properties = new HashMap<String,String>();                 base_string_properties.put("object_name", svrname[i]);                 base_string_properties.put("object_desc", svrdesc[i]);                 input.data.boName = "VariantRule";                 input.data.stringProps = base_string_properties;             }             //create             DataManagementService datamanagementservice = DataManagementService.getService(this.tcSession.getConnection());             CreateResponse response = datamanagementservice.createObjects(inputs);             svrs = response.output[0].objects;             if(svrs != null){                 logger.error("创建SVR成功");                 if(configurationcontext != null){                     tool.createRelationships(configurationcontext,svrs, "IMAN_reference");                     logger.error("SVR成功添加到配置器关联下");                 }else{                     logger.error("SVR未添加到配置器关联下");                 }             }             else{                 logger.error("创建SVR失败");             }         }         return svrs;     }     /**      * 查询组族      * @param familyGroupid      * @throws TCOperationException      */     public  ModelObject[] queryFamilyGroup(String familyGroupid) throws TCOperationException{         Map<String,String> criterias = new HashMap<String,String>();         criterias.put("Cfg0AbsFamilyGroupThread:wso_thread.fnd0ThreadId", familyGroupid);         ModelObject[] familgroups = tool.queryObjectsBySavedQuery(QUERY_FAMILY_GROUP, criterias);         return familgroups;     }     /**      * 查询组族      * @param familyGroupid      * @throws TCOperationException      */     public  ModelObject[] queryFamilyGroup(String familyGroupid,String dictionary) throws TCOperationException{         Map<String,String> criterias = new HashMap<String,String>();         criterias.put("Cfg0AbsFamilyGroupThread:wso_thread.fnd0ThreadId", familyGroupid);         ModelObject[] familgroups = tool.queryObjectsBySavedQuery(QUERY_FAMILY_GROUP, criterias);         return familgroups;     }     /**      * 查询族      * @param familyid      * @throws TCOperationException      */     public  ModelObject[] queryFamily(String familyid) throws TCOperationException{         Map<String,String> criterias = new HashMap<String,String>();         criterias.put("Cfg0AbsFamilyThread:wso_thread.fnd0ThreadId", familyid);         ModelObject[] famils = tool.queryObjectsBySavedQuery(QUERY_FAMILY, criterias);         return famils;     }     /**      * 根据ID或者名称查询配置器关联      * @param id      * @param name      * @return      * @throws TCOperationException      */     public  ModelObject queryConfigurationContext(String id,String name) throws TCOperationException{         Map<String,String> criterias = new HashMap<String,String>();         criterias.put("item_id", id);         criterias.put("object_name", name);         ModelObject[] configuration = tool.queryObjectsBySavedQuery(QUERY_CONFIGURATION_CONTEXT_VALUE, criterias);         if (configuration != null && configuration.length > 0 ) {             return configuration[0];         }         else{             return null;         }     }     /**      * 查询选项值      * @param familyid      * @throws TCOperationException      */     public  ModelObject[] queryOptionValue(String optionvalueid) throws TCOperationException{         Map<String,String> criterias = new HashMap<String,String>();         criterias.put("Cfg0AbsOptionValueThread:wso_thread.fnd0ThreadId", optionvalueid);         ModelObject[] optionvalues = tool.queryObjectsBySavedQuery(QUERY_OPTION_VALUE, criterias);         return optionvalues;     }     /**      * 查询选项值(根据配置器关联或者是字典以及选项的ID)      * @param optionvalueid      * @param families      * @return      * @throws TCOperationException      */     public ModelObject[] queryOptionValue(String configurationcontext,String[] families) throws TCOperationException{         Map<String,String> criterias = new HashMap<String,String>();         StringBuffer families_sb =  new StringBuffer();         criterias.put("Cfg0AbsOptionValueThread:wso_thread.Cfg0AbsAllocationThread<-cfg0TargetThread.cfg0ProductItem.item_id", configurationcontext);         if(families != null && families.length > 0){             for (String family : families) {                 families_sb.append(family).append(";");             }         } //      System.out.println("families_sb" + families_sb.toString());         criterias.put("cfg0OptionFamilyThread.fnd0ThreadId", families_sb.toString());         ModelObject[] optionvalues = tool.queryObjectsBySavedQuery(QUERY_OPTION_VALUE_WITH_FAMILY, criterias);         return optionvalues;     }     /**      * 查询选项值(根据配置器关联或者是字典)      * @param familyid      * @throws TCOperationException      */     public ModelObject[] queryOptionValues(String optionvalueid,String configurationcontext) throws TCOperationException{         Map<String,String> criterias = new HashMap<String,String>();         criterias.put("Cfg0AbsOptionValueThread:wso_thread.fnd0ThreadId", optionvalueid);         criterias.put("Cfg0AbsOptionValueThread:wso_thread.Cfg0AbsAllocationThread<-cfg0TargetThread.cfg0ProductItem.item_id", configurationcontext);         ModelObject[] optionvalues = tool.queryObjectsBySavedQuery(QUERY_OPTION_VALUE, criterias);         return optionvalues;     }     /**      * 根据配置器的名称以及对象名称查询Allocation      * @param configurationContextID      * @param objectName      * @return      * @throws TCOperationException      */     public ModelObject[] queryAllocationValue(String configurationContextID,String objectName) throws TCOperationException{         Map<String,String> criterias = new HashMap<String,String>();         criterias.put("Cfg0AbsAllocationThread:wso_thread.Cfg0ConfContext:cfg0ProductItem.item_id", configurationContextID);         criterias.put("object_name", objectName);         ModelObject[] alloctionsvalues = tool.queryObjectsBySavedQuery(QUERY_ALLOCATION_VALUE, criterias);         return alloctionsvalues;     }     /**      * 创建family group      * @param dictionary 字典对象      * @param id        * @param desc      * @return      * @throws ServiceException      */     public  ModelObject createFamilyGroup(ModelObject dictionary,String id,String desc) throws ServiceException{                 CreateIn[] inputs = new CreateIn[1];                 CreateIn input  = new CreateIn();         inputs[0]  = input ;                 Map<String,String> base_string_properties = new HashMap<String,String>();         base_string_properties.put("object_desc", desc);         base_string_properties.put("cfg0ObjectId", id);                 Map<String,BigInteger> base_int_properties = new HashMap<String,BigInteger>();         base_int_properties.put("cfg0Sequence", BigInteger.valueOf(0));                 //parent dictionary         Map<String, ModelObject[]> tagArrayProps = new HashMap<String,ModelObject[]>();         tagArrayProps.put("cfg0ProductItems", new ModelObject[]{dictionary});                 //compounded properties         Map<String, CreateInput[]> secondInput = new HashMap<String,CreateInput[]>();         CreateInput[] secnondsinputs = new CreateInput[1];         CreateInput secnondsinput = new CreateInput();         secnondsinputs[0] = secnondsinput;                 Map<String, ModelObject> second_tagArrayProps = new HashMap<String,ModelObject>();         second_tagArrayProps.put("cfg0ProductItem", dictionary);                 secnondsinput.boName = "Cfg0Allocation";         secnondsinput.tagProps = second_tagArrayProps;         secondInput.put("cfg0SecondaryObjects", secnondsinputs);                 input.data.boName = "Cfg0FamilyGroup";         input.data.stringProps = base_string_properties;         input.data.tagArrayProps =  tagArrayProps;         input.data.compoundCreateInput = secondInput;         input.data.intProps = base_int_properties;         //create         DataManagementService datamanagementservice = DataManagementService.getService(this.tcSession.getConnection());         CreateResponse response = datamanagementservice.createObjects(inputs);         ModelObject familygroup = response.output[0].objects[0];         return familygroup;     }     /**      * 将familygroup/family/optionvalue添加到dictionary对象下      * @param dictionary      * @param familygroup      * @throws ServiceException      */     public  boolean updateObjecttoDictionary(ModelObject dictionary,ModelObject familygroup) throws ServiceException{         DataManagementService datamanagementservice = DataManagementService.getService(this.tcSession.getConnection());         String object_name = tool.getCommonPropertyValue(familygroup, "cfg0ObjectId");         String uid = familygroup.getUid();         CreateIn[] inputs = new CreateIn[1];                 CreateIn input  = new CreateIn();         inputs[0]  = input ;                 Map<String,String> stringProps = new HashMap<String,String>();         //stringProps.put("object_name", object_name);                 Map<String,Boolean> bool_properties = new HashMap<String,Boolean>();         bool_properties.put("cfg0CascadeAssociations", false);                 Map<String,ModelObject> tag_properties = new HashMap<String,ModelObject>();         tag_properties.put("cfg0ProductItem", dictionary);         tag_properties.put("cfg0Target", familygroup);                 input.clientId = uid;         input.data.boName = "Cfg0Allocation";         input.data.stringProps = stringProps;         input.data.boolProps = stringProps;         input.data.tagProps = tag_properties;         //create                 CreateResponse response = datamanagementservice.createObjects(inputs);         if(response.serviceData.sizeOfPartialErrors() > 0 )             return false;         else             return true;     }     /**      * 将familygroup/family/optionvalue添加到configurationContext下      * @param configurationContext      * @param object      * @return      * @throws ServiceException      */     public  boolean updateObjecttoConfigurationContext(ModelObject configurationContext,ModelObject object) throws ServiceException{         DataManagementService datamanagementservice = DataManagementService.getService(this.tcSession.getConnection());         String uid = object.getUid();         CreateIn[] inputs = new CreateIn[1];                 CreateIn input  = new CreateIn();         inputs[0]  = input ;                 Map<String,String> stringProps = new HashMap<String,String>();                 Map<String,Boolean> bool_properties = new HashMap<String,Boolean>();         bool_properties.put("cfg0CascadeAssociations", false);                 Map<String,ModelObject> tag_properties = new HashMap<String,ModelObject>();         tag_properties.put("cfg0ProductItem", configurationContext);         tag_properties.put("cfg0Target", object);                 input.clientId = uid;         input.data.boName = "Cfg0Allocation";         input.data.stringProps = stringProps;         input.data.boolProps = stringProps;         input.data.tagProps = tag_properties;         //create                 CreateResponse response = datamanagementservice.createObjects(inputs);         if(response.serviceData.sizeOfPartialErrors() > 0 )             return false;         else             return true;     }     /**      * 批量将familygroup/family/optionvalue添加到configurationContext下      * @param configurationContext      * @param objects      * @return      * @throws ServiceException      */     public  boolean updateObjectstoConfigurationContext(ModelObject configurationContext,ModelObject[] objects) throws ServiceException{         DataManagementService datamanagementservice = DataManagementService.getService(this.tcSession.getConnection());         if(objects != null && objects.length > 0){             CreateIn[] inputs = new CreateIn[objects.length];             for (int i = 0; i < objects.length; i++) {                 ModelObject object = objects[i];                 String uid = object.getUid();                                 CreateIn input  = new CreateIn();                 inputs[i]  = input ;                                 Map<String,String> stringProps = new HashMap<String,String>();                                 Map<String,Boolean> bool_properties = new HashMap<String,Boolean>();                 bool_properties.put("cfg0CascadeAssociations", false);                                 Map<String,ModelObject> tag_properties = new HashMap<String,ModelObject>();                 tag_properties.put("cfg0ProductItem", configurationContext);                 tag_properties.put("cfg0Target", object);                                 input.clientId = uid;                 input.data.boName = "Cfg0Allocation";                 input.data.stringProps = stringProps;                 input.data.boolProps = stringProps;                 input.data.tagProps = tag_properties;             }             //create             CreateResponse response = datamanagementservice.createObjects(inputs);             if(response.serviceData.sizeOfPartialErrors() > 0 )                 return false;             else                 return true;         }         return true;     }     /**      * 将对象从配置管理器中移除      * @param configurationContext      * @param object_name      * @return      * @throws ServiceException      * @throws TCOperationException      */     public  void removeObjectfromConfigurationContext(String configurationContextName,String object_name) throws ServiceException, TCOperationException{         DataManagementService datamanagementservice = DataManagementService.getService(this.tcSession.getConnection());         ModelObject allocationValue = null;         if(configurationContextName != null && configurationContextName.length() >0 ){             ModelObject[] allocationValues  = queryAllocationValue(configurationContextName, object_name);             if(allocationValues != null && allocationValues.length > 0){                 allocationValue = allocationValues[0];             }         }         if(allocationValue != null)             datamanagementservice.deleteObjects(new ModelObject[]{allocationValue});     }     /**      * 批量创建family group      * @param dictionary      * @param ids      * @param desc      * @return      * @throws ServiceException      */     public  ModelObject[] createFamilyGroups(ModelObject dictionary,String[] ids,String[] desc) throws ServiceException{         ModelObject[] createdObject = null;         if (ids.length == desc.length ) {             CreateIn[] inputs = new CreateIn[ids.length];             for (int i = 0; i < ids.length; i++) {                 CreateIn input  = new CreateIn();                 inputs[i]  = input ;                                 Map<String,String> base_string_properties = new HashMap<String,String>();                 base_string_properties.put("object_desc", desc[i]);                 base_string_properties.put("cfg0ObjectId", ids[i]);                                 Map<String,BigInteger> base_int_properties = new HashMap<String,BigInteger>();                 base_int_properties.put("cfg0Sequence", BigInteger.valueOf(0));                                 //parent dictionary                 Map<String, ModelObject[]> tagArrayProps = new HashMap<String,ModelObject[]>();                 tagArrayProps.put("cfg0ProductItems", new ModelObject[]{dictionary});                                 //compounded properties                 Map<String, CreateInput[]> secondInput = new HashMap<String,CreateInput[]>();                 CreateInput[] secnondsinputs = new CreateInput[1];                 CreateInput secnondsinput = new CreateInput();                 secnondsinputs[0] = secnondsinput;                                 Map<String, ModelObject> second_tagArrayProps = new HashMap<String,ModelObject>();                 second_tagArrayProps.put("cfg0ProductItem",dictionary);                                 secnondsinput.boName = "Cfg0Allocation";                 secnondsinput.tagProps = second_tagArrayProps;                 secondInput.put("cfg0SecondaryObjects", secnondsinputs);                                 input.data.boName = "Cfg0FamilyGroup";                 input.data.stringProps = base_string_properties;                 input.data.tagArrayProps =  tagArrayProps;                 input.data.compoundCreateInput = secondInput;                 input.data.intProps = base_int_properties;             }             //create             DataManagementService datamanagementservice = DataManagementService.getService(this.tcSession.getConnection());             CreateResponse response = datamanagementservice.createObjects(inputs);             createdObject = response.output[0].objects;         }         return createdObject;     }     /**      *创建family,并将其加到familygroup中,注意,将新增的family追加到group中,若familyGroup不存在,则不添加      * @param dictionary 字典      * @param familyGroup 组族      * @param id         family ID      * @param desc       family desc      * @return      * @throws ServiceException      * @throws NotLoadedException      */     public  ModelObject createFamily(ModelObject dictionary,ModelObject familyGroup,String id ,String desc) throws ServiceException, NotLoadedException{
        CreateIn[] inputs = new CreateIn[1];                 CreateIn input  = new CreateIn();         inputs[0]  = input ;                 Map<String,String> base_string_properties = new HashMap<String,String>();         base_string_properties.put("object_desc", desc);         base_string_properties.put("cfg0ValueDataType", "String");         base_string_properties.put("cfg0MaximumValue", "");         base_string_properties.put("cfg0FamilyNamespace", "Teamcenter");         base_string_properties.put("cfg0MinimumValue", "");         base_string_properties.put("cfg0ObjectId", id);                 Map<String,Boolean> base_bool_properties = new HashMap<String,Boolean>();         base_bool_properties.put("cfg0HasFreeFormValues", false);         base_bool_properties.put("cfg0IsMultiselect", false);         base_bool_properties.put("cfg0IsDiscretionary", false);                 Map<String,BigInteger> base_int_properties = new HashMap<String,BigInteger>();         base_int_properties.put("cfg0Sequence", BigInteger.valueOf(0));                 Map<String, ModelObject> base_tag_Props = new HashMap<String,ModelObject>();         base_tag_Props.put("cfg0UOM", null);                 //compounded properties         Map<String, CreateInput[]> secondInput = new HashMap<String,CreateInput[]>();         CreateInput[] secnondsinputs = new CreateInput[1];         CreateInput secnondsinput = new CreateInput();         secnondsinputs[0] = secnondsinput;                 Map<String, ModelObject> second_tagArrayProps = new HashMap<String,ModelObject>();         second_tagArrayProps.put("cfg0ProductItem", dictionary);                 secnondsinput.boName = "Cfg0Allocation";         secnondsinput.tagProps = second_tagArrayProps;         secondInput.put("cfg0SecondaryObjects", secnondsinputs);                 input.data.boName = "Cfg0LiteralValueFamily";         input.data.stringProps = base_string_properties;         input.data.intProps = base_int_properties;         input.data.boolProps = base_bool_properties;         input.data.tagProps = base_tag_Props;         input.data.compoundCreateInput = secondInput;                 //create         DataManagementService datamanagementservice = DataManagementService.getService(this.tcSession.getConnection());         CreateResponse response = datamanagementservice.createObjects(inputs);         ModelObject family = response.output[0].objects[0];         addFamilytoFamilyGroup(familyGroup,new ModelObject[]{family});         return family;     }     /**      * 批量创建family,并将其加到family group 下,若family group不存在,则不做处理      * @param dictionary 字典      * @param familygroup 组族      * @param ids         familyID      * @param descs       familydesc      * @return      * @throws ServiceException      * @throws NotLoadedException      */     public ModelObject[] createFamilies(ModelObject dictionary,ModelObject familygroup ,String[] ids ,String[] descs) throws ServiceException, NotLoadedException{         ModelObject[] familys = null;         if (ids.length == descs.length ) {             CreateIn[] inputs = new CreateIn[ids.length];             for (int i = 0; i < ids.length; i++) {                 CreateIn input  = new CreateIn();                 inputs[i]  = input ;                                 //string properties                 Map<String,String> base_string_properties = new HashMap<String,String>();                 base_string_properties.put("object_desc", descs[i]);                 base_string_properties.put("cfg0ValueDataType", "String");                 base_string_properties.put("cfg0MaximumValue", "");                 base_string_properties.put("cfg0FamilyNamespace", "Teamcenter");                 base_string_properties.put("cfg0MinimumValue", "");                 base_string_properties.put("cfg0ObjectId", ids[i]);                                 //bool properties                 Map<String,Boolean> base_bool_properties = new HashMap<String,Boolean>();                 base_bool_properties.put("cfg0HasFreeFormValues", false);                 base_bool_properties.put("cfg0IsMultiselect", false);                 base_bool_properties.put("cfg0IsDiscretionary", false);                                 //int properties                 Map<String,BigInteger> base_int_properties = new HashMap<String,BigInteger>();                 base_int_properties.put("cfg0Sequence", BigInteger.valueOf(0));                                 //tags properties                 Map<String, ModelObject> base_tag_Props = new HashMap<String,ModelObject>();                 base_tag_Props.put("cfg0UOM", null);                                 //compounded properties                 Map<String, CreateInput[]> secondInput = new HashMap<String,CreateInput[]>();                 CreateInput[] secnondsinputs = new CreateInput[1];                 CreateInput secnondsinput = new CreateInput();                 secnondsinputs[0] = secnondsinput;                                 Map<String, ModelObject> second_tagArrayProps = new HashMap<String,ModelObject>();                 second_tagArrayProps.put("cfg0ProductItem", dictionary);                                 secnondsinput.boName = "Cfg0Allocation";                 secnondsinput.tagProps = second_tagArrayProps;                 secondInput.put("cfg0SecondaryObjects", secnondsinputs);                                 input.data.boName = "Cfg0LiteralValueFamily";                 input.data.stringProps = base_string_properties;                 input.data.intProps = base_int_properties;                 input.data.boolProps = base_bool_properties;                 input.data.tagProps = base_tag_Props;                 input.data.compoundCreateInput = secondInput;             }             //create             DataManagementService datamanagementservice = DataManagementService.getService(this.tcSession.getConnection());             CreateResponse response = datamanagementservice.createObjects(inputs);             CreateOut[] output = response.output;             if (output != null && output.length > 0 ) {                 familys = new ModelObject[output.length];                 for (int j = 0; j < output.length; j++) {                     familys[j] = output[j].objects[0];                 }                 addFamilytoFamilyGroup(familygroup,familys);             }         }         return familys;     }     /**      * 将family添加到familygroup      * @param familyGroup      * @param families_input      * @throws NotLoadedException      */     public void addFamilytoFamilyGroup(ModelObject familyGroup,ModelObject[] families_input) throws NotLoadedException{         DataManagementService datamanagementservice = DataManagementService.getService(this.tcSession.getConnection());         if(familyGroup != null && families_input != null && families_input.length > 0 ){             datamanagementservice.getProperties(new ModelObject[]{familyGroup}, new String[]{"cfg0Families"});             ModelObject[] families = familyGroup.getPropertyObject("cfg0Families").getModelObjectArrayValue();             String[] new_families = null;             if(families != null && families.length > 0 ){                 new_families = new String[families.length + families_input.length];                 for (int i = 0; i < families.length; i++) {                     new_families[i] = families[i].getUid();                 }                 for (int i = 0; i < families_input.length; i++) {                     new_families[i+families.length] = families_input[i].getUid();                 }             }             else{                 new_families = new String[families_input.length];                 for (int i = 0; i < families_input.length; i++) {                     new_families[i] = families_input[i].getUid();                 }             }             Map<String,VecStruct> map = new HashMap<String,VecStruct>();             VecStruct vecStr = new VecStruct();             vecStr.stringVec= new_families;             map.put("cfg0Families", vecStr);             datamanagementservice.setProperties(new ModelObject[]{familyGroup}, map);         }     }     /**      *创建选项值,默认会放到family下面      * @param dictionary 字典      * @param id         ID      * @param desc       描述      * @return      * @throws ServiceException      */     public ModelObject createOptionValue(ModelObject dictionary,ModelObject family ,String id ,String desc) throws ServiceException{
        CreateIn[] inputs = new CreateIn[1];                 CreateIn input  = new CreateIn();         inputs[0]  = input ;                 Map<String,String> base_string_properties = new HashMap<String,String>();         base_string_properties.put("object_desc", desc);         base_string_properties.put("cfg0ObjectId", id);                 Map<String,BigInteger> base_int_properties = new HashMap<String,BigInteger>();         base_int_properties.put("cfg0Sequence", BigInteger.valueOf(0));                 //parent family group         Map<String, ModelObject> base_tag_Props = new HashMap<String,ModelObject>();         base_tag_Props.put("cfg0OptionFamily", family);                 //compounded properties         Map<String, CreateInput[]> secondInput = new HashMap<String,CreateInput[]>();         CreateInput[] secnondsinputs = new CreateInput[1];         CreateInput secnondsinput = new CreateInput();         secnondsinputs[0] = secnondsinput;                 Map<String, ModelObject> second_tagArrayProps = new HashMap<String,ModelObject>();         second_tagArrayProps.put("cfg0ProductItem", dictionary);                 secnondsinput.boName = "Cfg0Allocation";         secnondsinput.tagProps = second_tagArrayProps;         secondInput.put("cfg0SecondaryObjects", secnondsinputs);                 input.data.boName = "Cfg0LiteralOptionValue";         input.data.stringProps = base_string_properties;         input.data.intProps = base_int_properties;         input.data.tagProps = base_tag_Props;         input.data.compoundCreateInput = secondInput;                 //create         DataManagementService datamanagementservice = DataManagementService.getService(this.tcSession.getConnection());         CreateResponse response = datamanagementservice.createObjects(inputs);         ModelObject optionvalue = response.output[0].objects[0];         logger.info("optionvalue"+optionvalue.getUid());         return optionvalue;     }     /**      *批量创建选项值,默认会放到family下面      * @param dictionary 字典      * @param id         ID      * @param desc       描述      * @return      * @throws ServiceException      */     public ModelObject[] createOptionValues(ModelObject dictionary,ModelObject family ,String[] id ,String[] desc) throws ServiceException{         ModelObject[] optionvalues = null;         CreateIn[] inputs = null;         if (id != null && id.length == desc.length) {             inputs = new CreateIn[id.length];             for (int i = 0; i < id.length; i++) {                 CreateIn input  = new CreateIn();                 inputs[i]  = input ;                                 Map<String,String> base_string_properties = new HashMap<String,String>();                 base_string_properties.put("object_desc", desc[i]);                 base_string_properties.put("cfg0ObjectId", id[i]);                                 Map<String,BigInteger> base_int_properties = new HashMap<String,BigInteger>();                 base_int_properties.put("cfg0Sequence", BigInteger.valueOf(0));                                 //parent family group                 Map<String, ModelObject> base_tag_Props = new HashMap<String,ModelObject>();                 base_tag_Props.put("cfg0OptionFamily", family);                                 //compounded properties                 Map<String, CreateInput[]> secondInput = new HashMap<String,CreateInput[]>();                 CreateInput[] secnondsinputs = new CreateInput[1];                 CreateInput secnondsinput = new CreateInput();                 secnondsinputs[0] = secnondsinput;                                 Map<String, ModelObject> second_tagArrayProps = new HashMap<String,ModelObject>();                 second_tagArrayProps.put("cfg0ProductItem", dictionary);                                 secnondsinput.boName = "Cfg0Allocation";                 secnondsinput.tagProps = second_tagArrayProps;                 secondInput.put("cfg0SecondaryObjects", secnondsinputs);                                 input.data.boName = "Cfg0LiteralOptionValue";                 input.data.stringProps = base_string_properties;                 input.data.intProps = base_int_properties;                 input.data.tagProps = base_tag_Props;                 input.data.compoundCreateInput = secondInput;             }             //create             DataManagementService datamanagementservice = DataManagementService.getService(this.tcSession.getConnection());             CreateResponse response = datamanagementservice.createObjects(inputs);             CreateOut[] output = response.output;             if (output != null && output.length > 0 ) {                 optionvalues = new ModelObject[output.length];                 for (int i = 0; i < output.length; i++) {                     optionvalues[i]= output[i].objects[0];                 }             }         }         return optionvalues;     }     /**      * 创建配置器关联      * @param dictionary      * @param id      * @param name      * @return      * @throws ServiceException      */     public ModelObject createConfigurationContext(String id,String name,String desc) throws ServiceException{         CreateIn[] inputs = new CreateIn[1];                 CreateIn input  = new CreateIn();         inputs[0]  = input ;                 Map<String,String> base_string_properties = new HashMap<String,String>();         base_string_properties.put("object_desc", desc);         base_string_properties.put("item_id", id);         base_string_properties.put("object_name", name);                 Map<String,Boolean> base_boolean_properties = new HashMap<String,Boolean>();         base_boolean_properties.put("cfg0PosBiasedVariantAvail", false);                 //all compounded properties         Map<String, CreateInput[]> secondInput = new HashMap<String,CreateInput[]>();                 //compounded properties level 1         CreateInput[] secnondsinputs = new CreateInput[1];         CreateInput secnondsinput = new CreateInput();         secnondsinputs[0] = secnondsinput;                 Map<String, String> second_stringProps = new HashMap<String,String>();         second_stringProps.put("item_revision_id", "");                 //compounded properties level 1.1         Map<String, CreateInput[]> secondInput2 = new HashMap<String,CreateInput[]>();         CreateInput[] secnondsinputs2 = new CreateInput[1];         CreateInput secnondsinput2 = new CreateInput();         secnondsinputs2[0] = secnondsinput2;                 Map<String, String> second_stringProps2 = new HashMap<String,String>();         second_stringProps2.put("previous_version_id", "");         second_stringProps2.put("item_comment", "");         second_stringProps2.put("project_id", "");         second_stringProps2.put("user_data_3", "");         second_stringProps2.put("user_data_2", "");         second_stringProps2.put("user_data_1", "");         second_stringProps2.put("serial_number", "");                 secnondsinput2.boName = "Cfg0ProductItemRevisionMaster";         secnondsinput2.stringProps = second_stringProps2;         secondInput2.put("IMAN_master_form_rev", secnondsinputs2);                 secnondsinput.boName = "Cfg0ProductItemRevision";         secnondsinput.stringProps = second_stringProps;         secnondsinput.compoundCreateInput = secondInput2;         secondInput.put("revision", secnondsinputs);                 //compounded properties level 2         CreateInput[] thirdinputothers = new CreateInput[1];         CreateInput thirdinputother= new CreateInput();         thirdinputothers[0] = thirdinputother;                 Map<String, String> second_stringPropslevel2 = new HashMap<String,String>();         second_stringPropslevel2.put("previous_item_id", "");         second_stringPropslevel2.put("item_comment", "");         second_stringPropslevel2.put("project_id", "");         second_stringPropslevel2.put("user_data_3", "");         second_stringPropslevel2.put("user_data_2", "");         second_stringPropslevel2.put("user_data_1", "");         second_stringPropslevel2.put("serial_number", "");                 thirdinputother.boName= "Cfg0ProductItemMaster";         thirdinputother.stringProps = second_stringPropslevel2;                 secondInput.put("IMAN_master_form", thirdinputothers);                 input.data.boName = "Cfg0ProductItem";         input.data.stringProps = base_string_properties;         input.data.boolProps = base_boolean_properties;         input.data.compoundCreateInput = secondInput;         //create         DataManagementService datamanagementservice = DataManagementService.getService(this.tcSession.getConnection());         CreateResponse response = datamanagementservice.createObjects(inputs);         ModelObject configurationContext = response.output[0].objects[0];         return configurationContext;     }         /**      * 创建Allocation(分配)      * @param object_name 名称,OTB默认与粘贴对象的名称保持一致      * @param dictionary      * @param patested_cfg  需要将字典/配置器关联创建创建分配的组/族/选项      * @return      * @throws ServiceException      */     public ModelObject createAllocation(String object_name,ModelObject dictionary,ModelObject patested_cfg) throws ServiceException{         CreateIn[] inputs = new CreateIn[1];                 CreateIn input  = new CreateIn();         inputs[0]  = input ;                 Map<String,String> base_string_properties = new HashMap<String,String>();         base_string_properties.put("object_name", object_name);                 Map<String,Boolean> base_bool_properties = new HashMap<String,Boolean>();         base_bool_properties.put("cfg0CascadeAssociations", false);                 Map<String, ModelObject> base_tag_Props = new HashMap<String,ModelObject>();         base_tag_Props.put("cfg0ProductItem", dictionary);         base_tag_Props.put("cfg0Target", patested_cfg);                 input.data.boName = "Cfg0Allocation";         input.data.stringProps = base_string_properties;         input.data.boolProps = base_bool_properties;         input.data.tagProps = base_tag_Props;                 //create         DataManagementService datamanagementservice = DataManagementService.getService(this.tcSession.getConnection());         CreateResponse response = datamanagementservice.createObjects(inputs);         ModelObject allocation = response.output[0].objects[0];         return allocation;     }     /**      * 清除字典/配置器关联日期      * @param fonfigurationContextModel      */     public void clearDate(ModelObject fonfigurationContextModel){         //清楚日期         DataManagementService service = DataManagementService.getService(this.tcSession.getConnection());         ModelObject perspective = tool.getModelObjectPropertyValue(fonfigurationContextModel, "cfg0ConfigPerspective");         Map<String,VecStruct> map = new HashMap<String,VecStruct>();         VecStruct vecstruct = new VecStruct();         vecstruct.stringVec = new String[]{};         map.put("cfg0RuleSetCompileDate", vecstruct);         service.setProperties(new ModelObject[]{perspective}, map);     }     /**      * 族对象更新到字典库下(此场景适用于在族在其他字典下,但是不在当前的group下的数据)      * @param fonfigurationContextModel      * @throws ServiceException      * @throws NotLoadedException      */     public  void upateConfiguration(ModelObject dictionary,ModelObject parent,ModelObject child) throws ServiceException, NotLoadedException{         //先创建allocation         String id = tool.getCommonPropertyValue(child, "cfg0ObjectId");         createAllocation(id, dictionary, child);         //将其添加到familygroup下         addFamilytoFamilyGroup(parent,new ModelObject[]{child});     }     public void removeSVR(ModelObject configuration,ModelObject svr){         ICTService ictservice = ICTService.getService(this.tcSession.getConnection());         Arg[] args = new Arg[5];         args[0]=new Arg();         args[1]=new Arg();         args[2]=new Arg();         args[3]=new Arg();         args[4]=new Arg();                 args[0].val="VariantRule";         args[1].val="TYPE::VariantRule::VariantRule::WorkspaceObject";         args[2].val =  "";                 ICT.Structure[] structures = new ICT.Structure[1];         ICT.Structure structure = new ICT.Structure();         structures[0] = structure;         Arg[] parnet_arg = new Arg[2];         parnet_arg[0] = new Arg();         parnet_arg[1] = new Arg();                 parnet_arg[0].val = "true";         parnet_arg[1].val = configuration.getUid();         structure.args = parnet_arg;         args[2].structure = structures;                 args[3].val =  "IMAN_reference";                 ICT.Array[] arrays = new ICT.Array[1];         ICT.Array array = new ICT.Array();         arrays[0] = array;         Entry[] entrys = new Entry[1];         Entry entry = new Entry();         entrys[0] = entry;                 entry.val = svr.getUid();         array.entries = entrys;         args[4].val =  "";         args[4].array = arrays;         try {             ictservice.invokeICTMethod("ICCT", "removeAndDestroyWithErrors", args);         } catch (ServiceException e1) {             e1.printStackTrace();         }     } }

标签:代码,配置,ModelObject,Teamcenter,base,input,put,new,properties
From: https://www.cnblogs.com/PLM-Teamcenter/p/18263197

相关文章

  • [技巧] NOI LINUX 中不用自己手打的Sublime配置环境
    一般我们测试代码时,需要开$O2$,而$Sublime$中的$C++SingleFile$是没有$O2$的,为此,我们需要手打环境;其实是不用的;第一步,打开“文件”中的“其它位置”中的“计算机”;第二步,在上面的搜索栏中搜索“Sublime”;打开图中高亮的,找到如下图中高亮的并打开,复制;发现会......
  • Python vs MATLAB: 易于学习和代码可理解性的对比
    PythonvsMATLABPythonvsMATLAB:易于学习和代码可理解性**Python的易用性与代码理解****MATLAB的易用性与代码理解****哪个更易上手?****结论**PythonvsMATLAB:易于学习和代码可理解性在科学计算、工程模拟和数据分析领域,Python和MATLAB是两种广泛使用的编程......
  • antdesign-vue3 List的分页器最全配置
    AntDesignVue官网:https://www.antdv.com/components/list-cn何时使用#最基础的列表展示,可承载文字、列表、图片、段落,常用于后台数据展示页面。<a-listsize="large"bordered:data-source="listData":pagination="pagination"><......
  • elasticsearch-7.17.15 集群安装部署及kibana配置
    一、物料准备(注意:必须版本一致):1、安装包 elasticsearch-7.17.15-linux-x86_64.tar.gz(这个版本的插件需要在线使用命令安装:/es/elasticsearch-7.17.15/bin/elasticsearch-plugininstallhttps://get.infini.cloud/elasticsearch/analysis-ik/7.17.15,或者用我的传送门) an......
  • MybatisPlus逆向工程插件,无需编写任何配置文件,只需配置数据库信息,一键生成Entity、Con
    文章目录1.前言2.与其它逆向工程工具相比的优势3.下载插件4.准备工作4.1创建数据库和表(可跳过)4.2配置数据库信息4.2.1打开IDEA的菜单栏4.2.2找到工具,点击ConfigDatabase4.2.3填写连接数据库所需要的信息4.3导入MybatisPlus的Maven依赖和SpringWeb的Maven依......
  • windows系统配置linux环境wsl
    前言WindowsSubsystemforLinux(WSL)是微软为Windows10和WindowsServer引入的一个特性,它允许用户在Windows操作系统上直接运行Linux环境,而不需要使用虚拟机或双启动系统。WSL的主要目的是提高开发者的生产力,特别是那些需要在Linux和Windows之间切换的开发人员。一、wsl......
  • 一、第一个C语言代码
    1.打开vs2019。2.创建新项目,点空项目——项目名称test_6_22(test_月_日)。改路径,不要用默认路径。3.创建源文件。后缀 .c源文件  .h头文件.c为后缀的为c的代码.cpp为后缀的为c++的代码.c编译器会按照C的语言来编译代码.cpp编译器会按照C++的语言来编译代码4.......
  • java环境配置
    原文:https://edu.csdn.net/skill/java/java-4ddfc05dbbe54300905f404c1ed1b4f9?category=462&typeId=19824前言为什么写这篇文章呢,因为我不想再去百度搜别人的文章了,所以自己写一篇以作记录。一、准备工作JDK8下载地址JDK11下载地址在这里插入图片描述下载好之后双击exe文......
  • springboot 加密配置文件指定信息 (Jasypt篇)
    前言-与正文无关        生活远不止眼前的苦劳与奔波,它还充满了无数值得我们去体验和珍惜的美好事物。在这个快节奏的世界中,我们往往容易陷入工作的漩涡,忘记了停下脚步,感受周围的世界。让我们一起提醒自己,要适时放慢脚步,欣赏生活中的每一道风景,享受与家人朋友的温馨时......
  • 代码随想录第13天 | 二叉树part01 基础和遍历
    二叉树基础知识二叉树种类满二叉树满二叉树:如果一棵二叉树只有度为0和度为2的结点,并且度为0的结点在同一层上,则这棵二叉树为满二叉树(子节点要么为0,要么为2)若满二叉树的深度为k(即k层,从1开始),则其节点个数为:2^k-1完全二叉树完全二叉树:从上到下,从左到右,都是连续的。满二叉树一......