cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

How to apply option filter for a WTPart structure programmatically?

tm-4
12-Amethyst

How to apply option filter for a WTPart structure programmatically?

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

ACCEPTED SOLUTION

Accepted Solutions
tm-4
12-Amethyst
(To: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

View solution in original post

2 REPLIES 2
tm-4
12-Amethyst
(To: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

sidsinha16
10-Marble
(To:tm-4)

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

Announcements

Top Tags