Search in sources :

Example 1 with SqaleRepoContext

use of com.evolveum.midpoint.repo.sqale.SqaleRepoContext in project midpoint by Evolveum.

the class SqaleAuditServiceFactory method createSqaleRepoContext.

private SqaleRepoContext createSqaleRepoContext(JdbcRepositoryConfiguration config, DataSource dataSource, SchemaService schemaService) {
    QueryModelMappingRegistry mappingRegistry = new QueryModelMappingRegistry();
    SqaleRepoContext repositoryContext = new SqaleRepoContext(config, dataSource, schemaService, mappingRegistry);
    repositoryContext.setQuerydslSqlListener(new SqlLogger());
    // Registered mapping needs repository context which needs registry - now we have both:
    mappingRegistry.register(AuditEventRecordType.COMPLEX_TYPE, QAuditEventRecordMapping.init(repositoryContext)).register(QAuditRefValueMapping.init(repositoryContext)).register(QAuditDeltaMapping.init(repositoryContext)).seal();
    return repositoryContext;
}
Also used : SqaleRepoContext(com.evolveum.midpoint.repo.sqale.SqaleRepoContext) QueryModelMappingRegistry(com.evolveum.midpoint.repo.sqlbase.mapping.QueryModelMappingRegistry) SqlLogger(com.evolveum.midpoint.repo.sqlbase.querydsl.SqlLogger)

Example 2 with SqaleRepoContext

use of com.evolveum.midpoint.repo.sqale.SqaleRepoContext in project midpoint by Evolveum.

the class SqaleAuditServiceFactory method init.

@Override
public synchronized void init(@NotNull Configuration configuration) throws AuditServiceFactoryException {
    LOGGER.info("Initializing SQL audit service factory.");
    try {
        SqaleRepoContext sqlRepoContext = createSqaleRepoContext(configuration);
        auditService = new SqaleAuditService(sqlRepoContext, sqlPerformanceMonitorsCollection);
        initCustomColumns(configuration, sqlRepoContext);
    } catch (RepositoryServiceFactoryException ex) {
        throw new AuditServiceFactoryException(ex.getMessage(), ex);
    }
    LOGGER.info("SQL audit service factory initialization complete.");
}
Also used : AuditServiceFactoryException(com.evolveum.midpoint.audit.api.AuditServiceFactoryException) SqaleRepoContext(com.evolveum.midpoint.repo.sqale.SqaleRepoContext) RepositoryServiceFactoryException(com.evolveum.midpoint.repo.api.RepositoryServiceFactoryException)

Example 3 with SqaleRepoContext

use of com.evolveum.midpoint.repo.sqale.SqaleRepoContext in project midpoint by Evolveum.

the class ExtensionItemFilterProcessor method process.

@Override
public Predicate process(ValueFilter<?, ?> filter) throws RepositoryException {
    ItemDefinition<?> definition = filter.getDefinition();
    Objects.requireNonNull(definition, "Item '" + filter.getPath() + "' without definition used in query.");
    MExtItem extItem = new ExtensionProcessor((SqaleRepoContext) context.repositoryContext()).resolveExtensionItem(definition, holderType);
    assert definition != null;
    if (extItem == null) {
        throw new QueryException("Extension item " + definition.getItemName() + " is not indexed, filter: " + filter);
    }
    if (definition instanceof PrismReferenceDefinition) {
        return processReference(extItem, (RefFilter) filter);
    }
    PropertyValueFilter<?> propertyValueFilter = (PropertyValueFilter<?>) filter;
    ValueFilterValues<?, ?> values = ValueFilterValues.from(propertyValueFilter);
    FilterOperation operation = operation(filter);
    List<?> filterValues = filter.getValues();
    if (filterValues == null || filterValues.isEmpty()) {
        if (operation.isAnyEqualOperation()) {
            return extItemIsNull(extItem);
        } else {
            throw new QueryException("Null value for other than EQUAL filter: " + filter);
        }
    }
    if (extItem.valueType.equals(STRING_TYPE)) {
        return processString(extItem, values, operation, filter);
    }
    // TODO for anything lower we don't support multi-value filter yet, but the solution from string can be adapted.
    if (filterValues.size() > 1) {
        throw new QueryException("Multiple values in filter are not supported for extension items: " + filter);
    }
    if (ExtUtils.isEnumDefinition((PrismPropertyDefinition<?>) definition)) {
        return processEnum(extItem, values, operation, filter);
    } else if (extItem.valueType.equals(INT_TYPE) || extItem.valueType.equals(INTEGER_TYPE) || extItem.valueType.equals(LONG_TYPE) || extItem.valueType.equals(SHORT_TYPE) || extItem.valueType.equals(DOUBLE_TYPE) || extItem.valueType.equals(FLOAT_TYPE) || extItem.valueType.equals(DECIMAL_TYPE)) {
        return processNumeric(extItem, values, operation, filter);
    } else if (extItem.valueType.equals(BOOLEAN_TYPE)) {
        return processBoolean(extItem, values, operation, filter);
    } else if (extItem.valueType.equals(DATETIME_TYPE)) {
        // noinspection unchecked
        PropertyValueFilter<XMLGregorianCalendar> dateTimeFilter = (PropertyValueFilter<XMLGregorianCalendar>) filter;
        return processString(extItem, ValueFilterValues.from(dateTimeFilter, ExtUtils::extensionDateTime), operation, filter);
    } else if (extItem.valueType.equals(POLY_STRING_TYPE)) {
        return processPolyString(extItem, values, operation, propertyValueFilter);
    }
    throw new QueryException("Unsupported filter for extension item: " + filter);
}
Also used : ExtUtils(com.evolveum.midpoint.repo.sqale.ExtUtils) SqaleRepoContext(com.evolveum.midpoint.repo.sqale.SqaleRepoContext) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) QueryException(com.evolveum.midpoint.repo.sqlbase.QueryException) MExtItem(com.evolveum.midpoint.repo.sqale.qmodel.ext.MExtItem) FilterOperation(com.evolveum.midpoint.repo.sqlbase.filtering.item.FilterOperation) ExtensionProcessor(com.evolveum.midpoint.repo.sqale.ExtensionProcessor) PropertyValueFilter(com.evolveum.midpoint.prism.query.PropertyValueFilter)

Aggregations

SqaleRepoContext (com.evolveum.midpoint.repo.sqale.SqaleRepoContext)3 AuditServiceFactoryException (com.evolveum.midpoint.audit.api.AuditServiceFactoryException)1 PropertyValueFilter (com.evolveum.midpoint.prism.query.PropertyValueFilter)1 RepositoryServiceFactoryException (com.evolveum.midpoint.repo.api.RepositoryServiceFactoryException)1 ExtUtils (com.evolveum.midpoint.repo.sqale.ExtUtils)1 ExtensionProcessor (com.evolveum.midpoint.repo.sqale.ExtensionProcessor)1 MExtItem (com.evolveum.midpoint.repo.sqale.qmodel.ext.MExtItem)1 QueryException (com.evolveum.midpoint.repo.sqlbase.QueryException)1 FilterOperation (com.evolveum.midpoint.repo.sqlbase.filtering.item.FilterOperation)1 QueryModelMappingRegistry (com.evolveum.midpoint.repo.sqlbase.mapping.QueryModelMappingRegistry)1 SqlLogger (com.evolveum.midpoint.repo.sqlbase.querydsl.SqlLogger)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1