Search in sources :

Example 1 with DynRealmDAO

use of org.apache.syncope.core.persistence.api.dao.DynRealmDAO in project syncope by apache.

the class AbstractAnyDAO method findDynRealms.

@Transactional(readOnly = true)
@Override
@SuppressWarnings("unchecked")
public List<String> findDynRealms(final String key) {
    Query query = entityManager().createNativeQuery("SELECT dynRealm_id FROM " + JPADynRealmDAO.DYNMEMB_TABLE + " WHERE any_id=?");
    query.setParameter(1, key);
    List<String> result = new ArrayList<>();
    query.getResultList().stream().map(resultKey -> resultKey instanceof Object[] ? (String) ((Object[]) resultKey)[0] : ((String) resultKey)).forEachOrdered((actualKey) -> {
        DynRealm dynRealm = dynRealmDAO().find(actualKey.toString());
        if (dynRealm == null) {
            LOG.error("Could not find dynRealm with id {}, even though returned by the native query", actualKey);
        } else if (!result.contains(actualKey.toString())) {
            result.add(actualKey.toString());
        }
    });
    return result;
}
Also used : Date(java.util.Date) NoResultException(javax.persistence.NoResultException) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) Schema(org.apache.syncope.core.persistence.api.entity.Schema) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) AllowedSchemas(org.apache.syncope.core.persistence.api.dao.AllowedSchemas) HashSet(java.util.HashSet) ParserConstants(org.apache.commons.jexl3.parser.ParserConstants) AttributeCond(org.apache.syncope.core.persistence.api.dao.search.AttributeCond) Propagation(org.springframework.transaction.annotation.Propagation) DerSchema(org.apache.syncope.core.persistence.api.entity.DerSchema) Map(java.util.Map) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) JPAUser(org.apache.syncope.core.persistence.jpa.entity.user.JPAUser) AbstractPlainAttrValue(org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue) AnyTypeClass(org.apache.syncope.core.persistence.api.entity.AnyTypeClass) DynRealmDAO(org.apache.syncope.core.persistence.api.dao.DynRealmDAO) SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) TemporalType(javax.persistence.TemporalType) AnyObject(org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject) Collection(java.util.Collection) PlainSchemaDAO(org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO) Set(java.util.Set) User(org.apache.syncope.core.persistence.api.entity.user.User) PlainAttrValue(org.apache.syncope.core.persistence.api.entity.PlainAttrValue) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) VirSchema(org.apache.syncope.core.persistence.api.entity.VirSchema) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource) List(java.util.List) Query(javax.persistence.Query) DerSchemaDAO(org.apache.syncope.core.persistence.api.dao.DerSchemaDAO) StringReader(java.io.StringReader) AnyDAO(org.apache.syncope.core.persistence.api.dao.AnyDAO) PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema) Group(org.apache.syncope.core.persistence.api.entity.group.Group) Pattern(java.util.regex.Pattern) AnyCond(org.apache.syncope.core.persistence.api.dao.search.AnyCond) Token(org.apache.commons.jexl3.parser.Token) AnyUtils(org.apache.syncope.core.persistence.api.entity.AnyUtils) ApplicationContextProvider(org.apache.syncope.core.spring.ApplicationContextProvider) Collections(java.util.Collections) Any(org.apache.syncope.core.persistence.api.entity.Any) DynRealm(org.apache.syncope.core.persistence.api.entity.DynRealm) Parser(org.apache.commons.jexl3.parser.Parser) Transactional(org.springframework.transaction.annotation.Transactional) Query(javax.persistence.Query) ArrayList(java.util.ArrayList) AnyObject(org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject) DynRealm(org.apache.syncope.core.persistence.api.entity.DynRealm) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Pattern (java.util.regex.Pattern)1 NoResultException (javax.persistence.NoResultException)1 Query (javax.persistence.Query)1 TemporalType (javax.persistence.TemporalType)1 Parser (org.apache.commons.jexl3.parser.Parser)1 ParserConstants (org.apache.commons.jexl3.parser.ParserConstants)1 Token (org.apache.commons.jexl3.parser.Token)1 StringUtils (org.apache.commons.lang3.StringUtils)1 AllowedSchemas (org.apache.syncope.core.persistence.api.dao.AllowedSchemas)1 AnyDAO (org.apache.syncope.core.persistence.api.dao.AnyDAO)1