Windchill-变型规范

变形规范:

//Create 1 VariantSpecLoadOutputBean per variant specification you want to create
VariantSpecLoadOutputBean myRow1Bean = new VariantSpecLoadOutputBean();
//Set the correct part to use. Make sure the part has an assigned option set
WTPart part = VariantSpecLoaderHelper.serivce.getWTPart("BICYCLE3", “A”, “1”);
//Set the option set with the assigned option set for the part.
OptionSet optionSet = VariantSpecLoaderHelper.serivce.getAssignedOptionSet(part);        
//If you are creating a variant specification based on an option set and not a 
//part, do not set the part on the bean. Instead set the option set to the one 
//you want to base the variant specification on
// OptionSet optionSet = VariantSpecLoaderHelper.serivce.getOptionSet("Bicycle3 Option Set Template", myContainerReference);
//Get the folder to save the variant specification in
Folder folder = FolderHelper.service.getFolder("/Default/",myPartContainerReference);
// You can use an existing navigation criteria from the database (for testing) 
// or create one brand new like below
NavigationCriteria nc = NavigationCriteria.newNavigationCriteria();
nc.setApplyToTopLevelObject(true);
nc.setUseDefaultForUnresolved(true);
nc.setName(DocHelper.service.autogenerateNavigationCriteriaName());
nc.setOwner((WTUser) SessionHelper.getPrincipal());
nc.setApplicableType(WTPart.class.getName());

// Add Part Configuration Specifications to this criteria. You can also use 
//default which is latest. Existing criteria will already have a config specs 
//assigned
WTPartConfigSpec myPartConfigSpec = (WTPartConfigSpec) 
ConfigHelper.service.getDefaultConfigSpecFor(WTPart.class, myPartContainerReference);
// NOTE : The configuration specifications must always be persisted before adding to a navigation criteria     
List<WTPartConfigSpec> partSpecs = new ArrayList<WTPartConfigSpec>();
partSpnc.setPartConfigSpecs(partSpecs);
nc.setPartConfigSpecs(partSpecs);
//If using new navigation criteria, create a new ATONavigationFilter (if you have choices you want to filter by)
ATONavigationFilter filter = ATONavigationFilter.newATONavigationFilter();
filter.setFilterMode(navCriteriaBean.getFilterMode());
filter.setOptionSet(optionSet);
filter.setRuleCheckingDisabled(navCriteriaBean.isRuleCheckingDisabled());
// Set the Options filter configuration specification. The one below is a latest configuration specification
List <ATORuleConfigSpec> atoRuleConfigs = new ArrayList<ATORuleConfigSpec>();
ATORuleConfigSpec atoRuleConfigSpec =ATORuleConfigSpec.newATORuleConfigSpec();
atoRuleConfigSpec.setEffActive(false); 
atoRuleConfigSpec.setLatestActive(false);            
atoRuleConfigSpec.setLifeCycleActive(true);
atoRuleConfigSpec = (ATORuleConfigSpec)PersistenceHelper.manager.store(atoRuleConfigSpec);
atoRuleconfigs.add(atoRuleConfigSpec);
filter.setConfigSpecs(atoRuleConfigs); 
// Now add the filter to the navigation criteria ArrayList<NavigationFilter2> filterList = new ArrayList<NavigationFilter2>(1);
filterList.add(filter);
nc.setFilters(filterList);
// Setup the choices to select for the Options filter
Map<String, Set<String>> optionToChoiceMap = new HashMap<String, 
// Steering Type : D30010 Set<String> choiceSet = new HashSet<String>();
Option testOptionA = MyHelper.getOption ("Steering Type", 
part.getContainerReference());
Choice testChoice = MyHelper.getChoice("D30010", "Steering Type", 
part.getContainerReference());
choiceSet.add(testChoice.getPersistInfo().getObjectIdentifier().toString());
optionToChoiceMap.put(testOption.getPersistInfo().getObjectIdentifier().toString(), choiceSet);
// Suspension : D30021
testOption = MyHelper.getOption ("Suspension", part.getContainerReference());
testChoice = MyHelper.getChoice("D30021", "Suspension", 
part.getContainerReference());
choiceSet = new HashSet<String>();
choiceSet.add(testChoice.getPersistInfo().getObjectIdentifier().toString());
argOptionToChoiceMap.put(testOption.getPersistInfo().getObjectIdentifier().toString(), choiceSet);
// Finally populate the bean with all of this information myRow1Bean.setRowNo(0);
myRow1Bean.setRowNo(0);
myRow1Bean.setVariantSpecName("Bicycle3-VarSpec2");
myRow1Bean.setVariantSpecFolder(folder);
myRow1Bean.setCreateVariants(false);
myRow1Bean.setVariantSpecPart(part);
myRow1Bean.setNavigationCriteria(navCriteria);
myRow1Bean.setOptionSet(optionSet);
myRow1Bean.setUserSelectedOptionChoiceOidMap(optionToChoiceMap);
// Create a list of such beans
ArrayList<VariantSpecLoadOutputBean> variantSpecBeans = new 
ArrayList<VariantSpecLoadOutputBean>();
variantSpecBeans.add(myRow1Bean);
//Invoke the API
ArrayList<VariantSpecLoadOutputBean> outputBeans = VariantSpecHelper.service.loadVariantSpecs(variantSpecBeans);
// Check for status on each bean
VariantSpecLoadOutputBean row1Output = outputBeans.get(0);
row1Output.getLoadStatus().getOverAllStatus();
row1Output.getLoadStatus().getVariantSpecNumber();
Boolean.toString(row1Output.getLoadStatus().isVariantSpecCreateSuccess());  
Boolean.toString(row1Output.getLoadStatus().isVariantSpecUpdateSuccess());               
row1Output.getLoadStatus().getValidationErrorMessage(); 
row1Output.getLoadStatus().getValidationWarningMessage()                          
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值