Search in sources :

Example 16 with ParsedKey

use of io.jans.orm.impl.model.ParsedKey in project jans by JanssenProject.

the class SqlEntryManager method removeImpl.

protected <T> int removeImpl(String dn, Class<T> entryClass, Filter filter, int count) {
    // Check entry class
    checkEntryClass(entryClass, false);
    String[] objectClasses = getTypeObjectClasses(entryClass);
    Filter searchFilter;
    if (objectClasses.length > 0) {
        LOG.trace("Filter: {}", filter);
        searchFilter = addObjectClassFilter(filter, objectClasses);
    } else {
        throw new EntryDeleteException(String.format("Failed to delete entries with DN: '%s', filter: '%s' because objectClass is not specified", dn, filter));
    }
    // Find entries
    LOG.trace("-------------------------------------------------------");
    LOG.trace("Filter: {}", filter);
    LOG.trace("objectClasses count: {} ", objectClasses.length);
    LOG.trace("objectClasses: {}", objectClasses.toString());
    LOG.trace("Search filter: {}", searchFilter);
    // Prepare properties types to allow build filter properly
    List<PropertyAnnotation> propertiesAnnotations = getEntryPropertyAnnotations(entryClass);
    Map<String, PropertyAnnotation> propertiesAnnotationsMap = prepareEntryPropertiesTypes(entryClass, propertiesAnnotations);
    ParsedKey keyWithInum = toSQLKey(dn);
    ConvertedExpression convertedExpression;
    try {
        convertedExpression = toSqlFilterWithEmptyAlias(searchFilter, propertiesAnnotationsMap);
    } catch (SearchException ex) {
        throw new EntryDeleteException(String.format("Failed to convert filter '%s' to expression", searchFilter), ex);
    }
    try {
        int processed = (int) getOperationService().delete(keyWithInum.getKey(), objectClasses[0], convertedExpression, count);
        return processed;
    } catch (Exception ex) {
        throw new EntryDeleteException(String.format("Failed to delete entries with key: '%s', expression: '%s'", keyWithInum.getKey(), convertedExpression), ex);
    }
}
Also used : Filter(io.jans.orm.search.filter.Filter) ConvertedExpression(io.jans.orm.sql.model.ConvertedExpression) ParsedKey(io.jans.orm.impl.model.ParsedKey) SearchException(io.jans.orm.exception.operation.SearchException) EntryDeleteException(io.jans.orm.exception.EntryDeleteException) MappingException(io.jans.orm.exception.MappingException) EntryPersistenceException(io.jans.orm.exception.EntryPersistenceException) EntryDeleteException(io.jans.orm.exception.EntryDeleteException) SearchException(io.jans.orm.exception.operation.SearchException) DateTimeParseException(java.time.format.DateTimeParseException) AuthenticationException(io.jans.orm.exception.AuthenticationException) PropertyAnnotation(io.jans.orm.reflect.property.PropertyAnnotation)

Example 17 with ParsedKey

use of io.jans.orm.impl.model.ParsedKey in project jans by JanssenProject.

the class SqlEntryManager method createEntities.

protected <T> List<T> createEntities(String baseDN, Class<T> entryClass, PagedResult<EntryData> searchResult) {
    ParsedKey keyWithInum = toSQLKey(baseDN);
    List<PropertyAnnotation> propertiesAnnotations = getEntryPropertyAnnotations(entryClass);
    List<T> entries = createEntities(entryClass, propertiesAnnotations, keyWithInum, searchResult.getEntries().toArray(new EntryData[searchResult.getEntriesCount()]));
    return entries;
}
Also used : EntryData(io.jans.orm.model.EntryData) ParsedKey(io.jans.orm.impl.model.ParsedKey) PropertyAnnotation(io.jans.orm.reflect.property.PropertyAnnotation)

Aggregations

ParsedKey (io.jans.orm.impl.model.ParsedKey)17 AuthenticationException (io.jans.orm.exception.AuthenticationException)14 EntryDeleteException (io.jans.orm.exception.EntryDeleteException)14 EntryPersistenceException (io.jans.orm.exception.EntryPersistenceException)14 MappingException (io.jans.orm.exception.MappingException)14 SearchException (io.jans.orm.exception.operation.SearchException)14 DateTimeParseException (java.time.format.DateTimeParseException)11 PropertyAnnotation (io.jans.orm.reflect.property.PropertyAnnotation)9 AttributeData (io.jans.orm.model.AttributeData)8 Filter (io.jans.orm.search.filter.Filter)6 JsonObject (com.couchbase.client.java.document.json.JsonObject)5 DateTimeException (java.time.DateTimeException)5 EntryData (io.jans.orm.model.EntryData)4 ConvertedExpression (io.jans.orm.couchbase.model.ConvertedExpression)3 ConvertedExpression (io.jans.orm.sql.model.ConvertedExpression)3 ISO_INSTANT (java.time.format.DateTimeFormatter.ISO_INSTANT)2 ArrayList (java.util.ArrayList)2 ScanConsistency (com.couchbase.client.java.query.consistency.ScanConsistency)1 Sort (com.couchbase.client.java.query.dsl.Sort)1 OrderSpecifier (com.querydsl.core.types.OrderSpecifier)1