Example #1
0
 private ObjectQuery getAssociationsSearchQuery(
     PrismContext prismContext,
     PrismObject resource,
     QName objectClass,
     ShadowKindType kind,
     String intent) {
   try {
     ObjectFilter andFilter =
         AndFilter.createAnd(
             EqualFilter.createEqual(
                 ShadowType.F_OBJECT_CLASS, ShadowType.class, prismContext, objectClass),
             EqualFilter.createEqual(ShadowType.F_KIND, ShadowType.class, prismContext, kind),
             //                    EqualFilter.createEqual(ShadowType.F_INTENT, ShadowType.class,
             // prismContext, intent),
             RefFilter.createReferenceEqual(
                 new ItemPath(ShadowType.F_RESOURCE_REF),
                 ShadowType.class,
                 prismContext,
                 resource.getOid()));
     ObjectQuery query = ObjectQuery.createObjectQuery(andFilter);
     return query;
   } catch (SchemaException ex) {
     LoggingUtils.logUnexpectedException(LOGGER, "Unable to create associations search query", ex);
     return null;
   }
 }
Example #2
0
  private ObjectQuery createQuery() {
    ReportOutputSearchDto dto = searchModel.getObject();

    try {
      List<ObjectFilter> ands = new ArrayList<>();

      if (StringUtils.isNotEmpty(dto.getText())) {
        PolyStringNormalizer normalizer = getPrismContext().getDefaultPolyStringNormalizer();
        String normalizedString = normalizer.normalize(dto.getText());

        SubstringFilter substring =
            SubstringFilter.createSubstring(
                ReportOutputType.F_NAME,
                ReportOutputType.class,
                getPrismContext(),
                PolyStringNormMatchingRule.NAME,
                normalizedString);
        ands.add(substring);
      }

      String oid = dto.getReportTypeMap().get(dto.getReportType());
      if (StringUtils.isNotEmpty(oid)) {
        RefFilter ref =
            RefFilter.createReferenceEqual(
                ReportOutputType.F_REPORT_REF, ReportOutputType.class, getPrismContext(), oid);
        ands.add(ref);
      }

      switch (ands.size()) {
        case 0:
          return null;
        case 1:
          return ObjectQuery.createObjectQuery(ands.get(0));
        default:
          AndFilter and = AndFilter.createAnd(ands);
          return ObjectQuery.createObjectQuery(and);
      }
    } catch (Exception e) {
      error(getString("pageCreatedReports.message.queryError") + " " + e.getMessage());
      LoggingUtils.logException(LOGGER, "Couldn't create query filter.", e);
      return null;
    }
  }
Example #3
0
 <O extends Containerable> RefFilter createReferenceEqualFilter(
     ItemPath propertyPath, Class<O> type, String... oids) throws SchemaException {
   return RefFilter.createReferenceEqual(propertyPath, type, prismContext, oids);
 }
Example #4
0
 <O extends Containerable> RefFilter createReferenceEqualFilter(
     QName propertyName, Class<O> type, String... oids) {
   return RefFilter.createReferenceEqual(propertyName, type, prismContext, oids);
 }
 public static ObjectFilter createResourceFilter(String resourceOid, PrismContext prismContext)
     throws SchemaException {
   return RefFilter.createReferenceEqual(
       ShadowType.F_RESOURCE_REF, ShadowType.class, prismContext, resourceOid);
 }