Skip to main content
13-Aquamarine
March 16, 2017
Solved

How to apply option filter for a WTPart structure programmatically?

  • March 16, 2017
  • 1 reply
  • 2553 views

Need to apply option filter on the WTPart structure programmatically. What API's to be used ?

Best answer by tm-4

Finally got a way to achieve this, Below is the approach and not the exact code.

// Create a New filter or get a existing Filter as below

NavigationCriteria nc = NavigationCriteriaHelper.service.getNavigationCriteria("FilterName");

//Get the Option and Choice linked to the part container

Map<String, Set<String>> optionToChoiceMap = new HashMap<String, Set<String>>(); 

// Op1 : Ch1

Set<String> choiceSet = new HashSet<String>();

Option option1 = OptionHelper.service.getOptionByName (op1, part.getContainerReference());

Choice choiceOp1 = OptionHelper.service.getChoice(ch1, op1, part.getContainerReference());

choiceSet.add(choiceOp1.getPersistInfo().getObjectIdentifier().toString());

optionToChoiceMap.put(option1.getPersistInfo().getObjectIdentifier().toString(), choiceSet);

 

//Create a New ATOFilter to apply the option and choices to the Navigation Criteria. Set the Option & Choice to the ATOFilter

ATONavigationFilter filter = ATONavigationFilter.newATONavigationFilter();

filter.setFilterMode(1);

filter.setOptionSet(optionSet);

filter.setChoiceMap(optionToChoiceMap);

filter.setRuleCheckingDisabled(true);

 

// Applying the latest ConfigSpec

List <ATORuleConfigSpec> atoRuleConfigs = new ArrayList<ATORuleConfigSpec>();

ATORuleConfigSpec atoRuleConfigSpec =ATORuleConfigSpec.newATORuleConfigSpec();

atoRuleConfigSpec.setEffActive(false); 

atoRuleConfigSpec.setLatestActive(true); 

atoRuleConfigSpec.setLifeCycleActive(false);

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);

// Persist the navigation criteria

NavigationCriteriaHelper.service.saveNavigationCriteria(nc);

Regards,

Thiagarajan

1 reply

tm-413-AquamarineAuthorAnswer
13-Aquamarine
April 6, 2017

Finally got a way to achieve this, Below is the approach and not the exact code.

// Create a New filter or get a existing Filter as below

NavigationCriteria nc = NavigationCriteriaHelper.service.getNavigationCriteria("FilterName");

//Get the Option and Choice linked to the part container

Map<String, Set<String>> optionToChoiceMap = new HashMap<String, Set<String>>(); 

// Op1 : Ch1

Set<String> choiceSet = new HashSet<String>();

Option option1 = OptionHelper.service.getOptionByName (op1, part.getContainerReference());

Choice choiceOp1 = OptionHelper.service.getChoice(ch1, op1, part.getContainerReference());

choiceSet.add(choiceOp1.getPersistInfo().getObjectIdentifier().toString());

optionToChoiceMap.put(option1.getPersistInfo().getObjectIdentifier().toString(), choiceSet);

 

//Create a New ATOFilter to apply the option and choices to the Navigation Criteria. Set the Option & Choice to the ATOFilter

ATONavigationFilter filter = ATONavigationFilter.newATONavigationFilter();

filter.setFilterMode(1);

filter.setOptionSet(optionSet);

filter.setChoiceMap(optionToChoiceMap);

filter.setRuleCheckingDisabled(true);

 

// Applying the latest ConfigSpec

List <ATORuleConfigSpec> atoRuleConfigs = new ArrayList<ATORuleConfigSpec>();

ATORuleConfigSpec atoRuleConfigSpec =ATORuleConfigSpec.newATORuleConfigSpec();

atoRuleConfigSpec.setEffActive(false); 

atoRuleConfigSpec.setLatestActive(true); 

atoRuleConfigSpec.setLifeCycleActive(false);

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);

// Persist the navigation criteria

NavigationCriteriaHelper.service.saveNavigationCriteria(nc);

Regards,

Thiagarajan

10-Marble
October 31, 2019

Hi, Can you please provide me exact code like how have you fetch the WTPart with given option and Choice? it will be so healpful. Thanks. My Mail ID is Siddharth.sinha@ltts.com