VariantSpecLoadOutputBean API のサンプルコード
VariantSpecLoadOutputBean API を使用してバリエーション仕様を読み込むためのサンプルコードを以下に示します。
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
List<WTPartConfigSpec> partSpecs = new ArrayList<WTPartConfigSpec>();
partSpecs.add(myPartConfigSpec);
nc.setConfigSpecs(partSpecs);
ATONavigationFilter filter = ATONavigationFilter.newATONavigationFilter();
filter.setFilterMode(1);
filter.setOptionSet(optionSet);
filter.setRuleCheckingDisabled(true);
// 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, List<String>> userSelectedOptionChoiceNameMap = new HashMap<String, List<String>>();
ArrayList<String> choices1 = new ArrayList<String>();
choices1.add("D30010");
userSelectedOptionChoiceNameMap.put("Steering Type", choices1);
ArrayList<String> choices2 = new ArrayList<String>();
choices2.add("D30021");
userSelectedOptionChoiceNameMap.put("Suspension", choices2);
Map<String, Object> ibas = new HashMap<>();
ibas.put(stringIBA, "first test value");
ibas.put(intIBA, 5);
ibas.put(booleanIBA, false);
ibas.put(realIBA, FloatingPoint.valueOf("5.7"));
ibas.put(realWithUnitsIBA, FloatingPointWithUnits.valueOf("12.0253 kg"));
ibas.put(dateIBA, new WrappedTimestamp("09 01 2020 02:30:00 GMT", 0));
ibas.put(linkIBA, new Hyperlink("http://www.ptc.com", "PTC"));

// create the VariantSpecLoadOutputBean
VariantSpecLoadOutputBean myRow1Bean = new VariantSpecLoadOutputBean();
myRow1Bean.setRowNo(0);
myRow1Bean.setFilterMode(1);
myRow1Bean.setIsApplyToTopPresent(true);
myRow1Bean.setVariantSpecName("Bicycle3-VarSpec2");
myRow1Bean.setVariantSpecFolder(folder);
myRow1Bean.setCreateVariants(false);
myRow1Bean.setVariantSpecPart(part);
myRow1Bean.setNavigationCriteria(nc);
myRow1Bean.setOptionSet(optionSet);
myRow1Bean.setUserSelectedOptionChoiceNameMap(userSelectedOptionChoiceNameMap);
myRow1Bean.setType(VariantSpecType.TRADITIONAL_STANDALONE);
myRow1Bean.setVariantSpecIBAs(ibas);
myRow1Bean.setVariantSpecLifeCycleTemplate(“Basic”);
myRow1Bean.setVariantSpecLifeCycleState(“INWORK”);
// Create a list of such beans
ArrayList<VariantSpecLoadOutputBean> variantSpecBeans = new
ArrayList<VariantSpecLoadOutputBean>();
variantSpecBeans.add(myRow1Bean);
Map<String, VariantSpec> existingVariantSpecs = new HashMap<String, VariantSpec>();
//Invoke the API
List<VariantSpecLoadOutputBean> outputBeans = VariantSpecLoaderHelper.service.loadVariantSpecs(variantSpecBeans, existingVariantSpecs);
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();
これは役に立ちましたか?