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

How to apply option filter for a WTPart structure programmatically?

Regular Member

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 ?

Tags (1)
1 REPLY 1
Highlighted

Re: How to apply option filter for a WTPart structure programmatically?

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

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum! ______________________________ Check out the Windchill Tips Board! We're talking about Whirlpool's use of digital twin, augmented reality, and data-driven design!

The NAVIGATE WORKING GROUP is here! Come innovate with PTC!

Sign up for a Working Group