Search in sources :

Example 1 with SchemaType

use of org.apache.syncope.common.lib.types.SchemaType in project syncope by apache.

the class SchemaRestClient method getSchemas.

public <T extends SchemaTO> List<T> getSchemas(final SchemaType schemaType, final AnyTypeKind kind) {
    final AnyTypeService client = getService(AnyTypeService.class);
    final List<String> classes = new ArrayList<>();
    switch(kind) {
        case USER:
        case GROUP:
            final AnyTypeTO type = client.read(kind.name());
            if (type != null) {
                classes.addAll(type.getClasses());
            }
            break;
        default:
            new AnyTypeRestClient().listAnyTypes().stream().filter(anyTypeTO -> (anyTypeTO.getKind() != AnyTypeKind.USER && anyTypeTO.getKind() != AnyTypeKind.GROUP)).forEach((anyTypeTO) -> {
                classes.addAll(anyTypeTO.getClasses());
            });
    }
    return getSchemas(schemaType, null, classes.toArray(new String[] {}));
}
Also used : AnyTypeService(org.apache.syncope.common.rest.api.service.AnyTypeService) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) SchemaService(org.apache.syncope.common.rest.api.service.SchemaService) SchemaType(org.apache.syncope.common.lib.types.SchemaType) Collectors(java.util.stream.Collectors) StringUtils(org.apache.commons.lang3.StringUtils) VirSchemaTO(org.apache.syncope.common.lib.to.VirSchemaTO) ArrayList(java.util.ArrayList) AnyTypeKind(org.apache.syncope.common.lib.types.AnyTypeKind) DerSchemaTO(org.apache.syncope.common.lib.to.DerSchemaTO) List(java.util.List) AnyTypeTO(org.apache.syncope.common.lib.to.AnyTypeTO) PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) EntityTO(org.apache.syncope.common.lib.to.EntityTO) SchemaTO(org.apache.syncope.common.lib.to.SchemaTO) SchemaQuery(org.apache.syncope.common.rest.api.beans.SchemaQuery) Collections(java.util.Collections) AnyTypeService(org.apache.syncope.common.rest.api.service.AnyTypeService) ArrayList(java.util.ArrayList) AnyTypeTO(org.apache.syncope.common.lib.to.AnyTypeTO)

Aggregations

ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang3.StringUtils)1 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)1 AnyTypeTO (org.apache.syncope.common.lib.to.AnyTypeTO)1 DerSchemaTO (org.apache.syncope.common.lib.to.DerSchemaTO)1 EntityTO (org.apache.syncope.common.lib.to.EntityTO)1 PlainSchemaTO (org.apache.syncope.common.lib.to.PlainSchemaTO)1 SchemaTO (org.apache.syncope.common.lib.to.SchemaTO)1 VirSchemaTO (org.apache.syncope.common.lib.to.VirSchemaTO)1 AnyTypeKind (org.apache.syncope.common.lib.types.AnyTypeKind)1 SchemaType (org.apache.syncope.common.lib.types.SchemaType)1 SchemaQuery (org.apache.syncope.common.rest.api.beans.SchemaQuery)1 AnyTypeService (org.apache.syncope.common.rest.api.service.AnyTypeService)1 SchemaService (org.apache.syncope.common.rest.api.service.SchemaService)1