ArrayList API のサンプルコード
ArrayList 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);
// 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);
// 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();