final String selectorName = "selector"; //$NON-NLS-1$
// selector
final Selector selector = fac.selector( "nt:base", selectorName ); //$NON-NLS-1$
// constraint1
Constraint origParentFolderPathConstraint =
fac.comparison( fac.propertyValue( selectorName, pentahoJcrConstants.getPHO_ORIGPARENTFOLDERPATH() ),
QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, fac.literal( session.getValueFactory().createValue(
origParentFolderPath ) ) );
// constraint2
Constraint origNameConstraint = null;
if ( StringUtils.hasLength( filter ) ) {
String convertedFilter = filter.replace( '*', '%' );
origNameConstraint =
fac.comparison( fac.propertyValue( selectorName, pentahoJcrConstants.getPHO_ORIGNAME() ),
QueryObjectModelConstants.JCR_OPERATOR_LIKE, fac.literal( session.getValueFactory().createValue(
convertedFilter ) ) );
}
// constraint3
Constraint descendantNodeConstraint = fac.descendantNode( selectorName, trashNode.getPath() );
// AND together constraints
Constraint allConstraints = fac.and( descendantNodeConstraint, origParentFolderPathConstraint );
if ( StringUtils.hasLength( filter ) ) {
allConstraints = fac.and( allConstraints, origNameConstraint );
}
Query query = fac.createQuery( selector, allConstraints, null, null );
QueryResult result =