Filters a set of occurrences by removing occurrences that do not match a WhereClause
criteria applied to their references, with a configuration filter if necessary.
Output
- A Navigation Set that contains the filtered occurrences
Note:
This output may contain:
- Occurrences included in other occurrences. To remove them, see the compact primitive.
- More occurrences than the input Navigation Set
Example
/*
* Cut occurrences from a Navigation Set according to criteria applied on references (WhereClause)
*
* @param ctx: completion context
* @param inputNavSet: input navigation to filter. Not modified by this method
* @param whereClause where clause to apply on references
*
* @return navigation set that contains the filtered occurrences
* @throws Exception
*/
public static NavigationSet cutOccurrences (CompletionContext ctx, NavigationSet inputNavSet, java.lang.String whereClause) throws java.lang.Exception
WhereClause Examples
The WhereClause examples concern only the filterOnLeaves and cutOccurrences primitives.
- Removing Fasten Items
-
// To remove Fasten Mfg Items from PRCS navigation set
var whereClause = "attribute[" + CompletionServicesConstants.BO_ATTRIBUTE_V_DISCIPLINE + "] != 'Fasten'";
PRCS = FilterServices.cutOccurrences(context, PRCS, whereClause);
- Retrieving and Expanding an Entity Named "LINE (MainBodyRespot)"
-
// To retrieve an entity named 'LINE (MainBodyRespot)' and expand it one level
var SystExpand1lUpScope = ExpandPrimitives.expandSystem (context, SystScopeNS, 1);
var whereClause0 = "attribute[PLMEntity.V_Name] == 'LINE (MainBodyRespot)'";
var TMP0 = FilterServices.cutOccurrences (context, SEL_PROD_SYS, whereClause0);
var SystExpand1lUpScope = ExpandPrimitives.expandSystem (context, TMP0, 1);
- Keeping Only General Operations
-
// Keep only GeneralOperations from SystExpand1lUpScope Navigation Set and add them to PROD_SYS Navigation Set
var whereClause1 = "type.kindof[DELLmiGeneralOperationReference] == TRUE";
var TMP1 = FilterServices.cutOccurrences (context, SystExpand1lUpScope, whereClause1);
PROD_SYS = PROD_SYS.merge (TMP1);
- Removing All Predecessor Fastening Operations
-
// Remove all predecessor Fastening Operations from SelPrdcsorSysExpandAll Navigation Set and add the remaining operations to PROD_SYS Navigation Set
var whereClause2 = "type.kindof[DELLmiPunctualOperationReference] == FALSE";
var TMP2 = FilterServices.cutOccurrences (context, SelPrdcsorSysExpandAll, whereClause2);
PROD_SYS = PROD_SYS.merge (TMP2);
- Keeping Only EBOM Entities Modified in the Last Two Days
-
// Keep only product modified in the last 2 days
var dateNow = new Date();
var X=2
var day = dateNow.getDate()-X;
dateNow.setDate(day)
day = dateNow.getDate()
var month = dateNow.getMonth()+1;
var year = dateNow.getFullYear();
var date = "'" + month + "/" + day + "/" + year + "'";
var whereClause = "modified >=" + date;
var TMP = FilterServices.cutOccurrences (context, resExpandProduct, whereClause);
- Keeping Only EBOM Entities Created After a Given Date
-
// Keep only Products created after a given date
var date = '11/19/2020';
var whereClause = "originated >=" + date;
var TMP = FilterServices.cutOccurrences (context, resExpandProduct, whereClause);
- Keeping Only EBOM Entities Modified Between Two Dates
-
// Keep only Products modified between 2 dates
var whereClause = (modified >= '11/20/2020') AND (modified <= '11/30/2020');
var TMP = FilterServices.cutOccurrences (context, resExpandProduct, whereClause);