Search in sources :

Example 6 with S_AtomicFilterEntry

use of com.evolveum.midpoint.prism.query.builder.S_AtomicFilterEntry in project midpoint by Evolveum.

the class PageCreatedReports method appendTypeFilter.

private ObjectQuery appendTypeFilter() {
    DropDownChoicePanel<String> typeSelect = (DropDownChoicePanel<String>) getMainForm().get(ID_REPORT_TYPE_SELECT);
    String typeRef = typeSelect == null ? reportTypeMal.get(getReportType()) : typeSelect.getBaseFormComponent().getModelObject();
    S_AtomicFilterEntry q = getPrismContext().queryFor(ReportDataType.class);
    S_AtomicFilterExit refF;
    if (StringUtils.isNotBlank(typeRef)) {
        Entry<String, String> typeRefFilter = reportTypeMal.entrySet().stream().filter(e -> e.getValue().equals(typeRef)).findFirst().get();
        if (typeRefFilter != null) {
            refF = q.item(ReportDataType.F_REPORT_REF).ref(typeRefFilter.getKey());
            return refF.build();
        }
    }
    return null;
}
Also used : DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) S_AtomicFilterEntry(com.evolveum.midpoint.prism.query.builder.S_AtomicFilterEntry) S_AtomicFilterExit(com.evolveum.midpoint.prism.query.builder.S_AtomicFilterExit)

Example 7 with S_AtomicFilterEntry

use of com.evolveum.midpoint.prism.query.builder.S_AtomicFilterEntry in project midpoint by Evolveum.

the class PageReports method createQuery.

private ObjectQuery createQuery() {
    ReportSearchDto dto = searchModel.getObject();
    String text = dto.getText();
    Boolean parent = !dto.isParent();
    S_AtomicFilterEntry q = QueryBuilder.queryFor(ReportType.class, getPrismContext());
    if (StringUtils.isNotEmpty(text)) {
        PolyStringNormalizer normalizer = getPrismContext().getDefaultPolyStringNormalizer();
        String normalizedText = normalizer.normalize(text);
        q = q.item(ReportType.F_NAME).eqPoly(normalizedText).matchingNorm().and();
    }
    if (parent) {
        q = q.item(ReportType.F_PARENT).eq(true).and();
    }
    return q.all().build();
}
Also used : ReportSearchDto(com.evolveum.midpoint.web.page.admin.reports.dto.ReportSearchDto) S_AtomicFilterEntry(com.evolveum.midpoint.prism.query.builder.S_AtomicFilterEntry) PolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PolyStringNormalizer)

Example 8 with S_AtomicFilterEntry

use of com.evolveum.midpoint.prism.query.builder.S_AtomicFilterEntry in project midpoint by Evolveum.

the class TaskManagerQuartzImpl method listWaitingTasks.

private List<Task> listWaitingTasks(TaskWaitingReason reason, OperationResult result) throws SchemaException {
    S_AtomicFilterEntry q = QueryBuilder.queryFor(TaskType.class, prismContext);
    q = q.item(TaskType.F_EXECUTION_STATUS).eq(TaskExecutionStatusType.WAITING).and();
    if (reason != null) {
        q = q.item(TaskType.F_WAITING_REASON).eq(reason.toTaskType()).and();
    }
    ObjectQuery query = q.all().build();
    List<PrismObject<TaskType>> prisms = repositoryService.searchObjects(TaskType.class, query, null, result);
    List<Task> tasks = resolveTasksFromTaskTypes(prisms, result);
    result.recordSuccessIfUnknown();
    return tasks;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) S_AtomicFilterEntry(com.evolveum.midpoint.prism.query.builder.S_AtomicFilterEntry) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 9 with S_AtomicFilterEntry

use of com.evolveum.midpoint.prism.query.builder.S_AtomicFilterEntry in project midpoint by Evolveum.

the class ShadowManager method createSearchShadowQuery.

private ObjectQuery createSearchShadowQuery(ProvisioningContext ctx, Collection<ResourceAttribute<?>> identifiers, boolean primaryIdentifiersOnly, PrismContext prismContext, OperationResult parentResult) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException {
    S_AtomicFilterEntry q = QueryBuilder.queryFor(ShadowType.class, prismContext);
    RefinedObjectClassDefinition objectClassDefinition = ctx.getObjectClassDefinition();
    for (PrismProperty<?> identifier : identifiers) {
        RefinedAttributeDefinition rAttrDef;
        PrismPropertyValue<?> identifierValue = identifier.getValue();
        if (objectClassDefinition == null) {
            // If there is no specific object class definition then the identifier definition 
            // must be the same in all object classes and that means that we can use
            // definition from any of them.
            RefinedObjectClassDefinition anyDefinition = ctx.getRefinedSchema().getRefinedDefinitions().iterator().next();
            rAttrDef = anyDefinition.findAttributeDefinition(identifier.getElementName());
            if (primaryIdentifiersOnly && !anyDefinition.isPrimaryIdentifier(identifier.getElementName())) {
                continue;
            }
        } else {
            if (primaryIdentifiersOnly && !objectClassDefinition.isPrimaryIdentifier(identifier.getElementName())) {
                continue;
            }
            rAttrDef = objectClassDefinition.findAttributeDefinition(identifier.getElementName());
        }
        String normalizedIdentifierValue = (String) getNormalizedAttributeValue(identifierValue, rAttrDef);
        PrismPropertyDefinition<String> def = (PrismPropertyDefinition<String>) identifier.getDefinition();
        q = q.itemWithDef(def, ShadowType.F_ATTRIBUTES, def.getName()).eq(normalizedIdentifierValue).and();
    }
    if (identifiers.size() < 1) {
        throw new SchemaException("Identifier not specified. Cannot create search query by identifier.");
    }
    if (objectClassDefinition != null) {
        q = q.item(ShadowType.F_OBJECT_CLASS).eq(objectClassDefinition.getTypeName()).and();
    }
    return q.item(ShadowType.F_RESOURCE_REF).ref(ctx.getResourceOid()).build();
}
Also used : RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) RefinedAttributeDefinition(com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition) S_AtomicFilterEntry(com.evolveum.midpoint.prism.query.builder.S_AtomicFilterEntry) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 10 with S_AtomicFilterEntry

use of com.evolveum.midpoint.prism.query.builder.S_AtomicFilterEntry in project midpoint by Evolveum.

the class PageAccounts method createObjectQuery.

private ObjectQuery createObjectQuery() {
    AccountDetailsSearchDto dto = searchModel.getObject();
    String searchText = dto.getText();
    ShadowKindType kind = dto.getKind();
    String intent = dto.getIntent();
    String objectClass = dto.getObjectClass();
    FailedOperationTypeType failedOperatonType = dto.getFailedOperationType();
    S_AtomicFilterEntry q = QueryBuilder.queryFor(ShadowType.class, getPrismContext());
    if (StringUtils.isNotEmpty(searchText)) {
        PolyStringNormalizer normalizer = getPrismContext().getDefaultPolyStringNormalizer();
        String normalized = normalizer.normalize(searchText);
        q = q.item(ShadowType.F_NAME).contains(normalized).matchingNorm().and();
    }
    if (kind != null) {
        q = q.item(ShadowType.F_KIND).eq(kind).and();
    }
    if (StringUtils.isNotEmpty(intent)) {
        q = q.item(ShadowType.F_INTENT).eq(intent).and();
    }
    if (failedOperatonType != null) {
        q = q.item(ShadowType.F_FAILED_OPERATION_TYPE).eq(failedOperatonType).and();
    }
    if (StringUtils.isNotEmpty(objectClass)) {
        QName objClass = new QName(objectClass);
        for (QName qn : dto.getObjectClassList()) {
            if (objectClass.equals(qn.getLocalPart())) {
                objClass = qn;
            }
        }
        q = q.item(ShadowType.F_OBJECT_CLASS).eq(objClass).and();
    }
    return appendResourceQueryFilter(q);
}
Also used : AccountDetailsSearchDto(com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto) QName(javax.xml.namespace.QName) S_AtomicFilterEntry(com.evolveum.midpoint.prism.query.builder.S_AtomicFilterEntry) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType) FailedOperationTypeType(com.evolveum.midpoint.xml.ns._public.common.common_3.FailedOperationTypeType) PolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PolyStringNormalizer)

Aggregations

S_AtomicFilterEntry (com.evolveum.midpoint.prism.query.builder.S_AtomicFilterEntry)12 PolyStringNormalizer (com.evolveum.midpoint.prism.polystring.PolyStringNormalizer)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)2 ResourceAttribute (com.evolveum.midpoint.schema.processor.ResourceAttribute)2 RefinedAttributeDefinition (com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition)1 RefinedObjectClassDefinition (com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)1 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 S_AtomicFilterExit (com.evolveum.midpoint.prism.query.builder.S_AtomicFilterExit)1 ResourceObjectDefinition (com.evolveum.midpoint.schema.processor.ResourceObjectDefinition)1 ResourceObjectTypeDefinition (com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 DropDownChoicePanel (com.evolveum.midpoint.web.component.input.DropDownChoicePanel)1 CertCampaignsSearchDto (com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignsSearchDto)1 AccountDetailsSearchDto (com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto)1 ReportOutputSearchDto (com.evolveum.midpoint.web.page.admin.reports.dto.ReportOutputSearchDto)1 ReportSearchDto (com.evolveum.midpoint.web.page.admin.reports.dto.ReportSearchDto)1 FailedOperationTypeType (com.evolveum.midpoint.xml.ns._public.common.common_3.FailedOperationTypeType)1 ShadowKindType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)1