Search in sources :

Example 1 with PermissionsDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.PermissionsDTO in project ArachneCentralAPI by OHDSI.

the class HasArachnePermissionsToPermissionDTOConverter method convert.

@Override
public PermissionsDTO convert(HasArachnePermissions hasArachnePermissions) {
    PermissionsDTO permissionsDTO = new PermissionsDTO();
    Set<ArachnePermission> permissions = hasArachnePermissions.getPermissions();
    if (permissions != null) {
        Arrays.stream(ArachnePermission.values()).filter(arachnePermission -> Stream.of(arachnePermission.getApplicableClass()).anyMatch(clazz -> clazz.isAssignableFrom(hasArachnePermissions.getClass()))).forEach(ap -> permissionsDTO.put(ap, permissions.contains(ap)));
    }
    return permissionsDTO;
}
Also used : Arrays(java.util.Arrays) Component(org.springframework.stereotype.Component) Stream(java.util.stream.Stream) Set(java.util.Set) BaseConversionServiceAwareConverter(com.odysseusinc.arachne.portal.api.v1.dto.converters.BaseConversionServiceAwareConverter) PermissionsDTO(com.odysseusinc.arachne.portal.api.v1.dto.PermissionsDTO) ArachnePermission(com.odysseusinc.arachne.portal.security.ArachnePermission) HasArachnePermissions(com.odysseusinc.arachne.portal.security.HasArachnePermissions) PermissionsDTO(com.odysseusinc.arachne.portal.api.v1.dto.PermissionsDTO) ArachnePermission(com.odysseusinc.arachne.portal.security.ArachnePermission)

Aggregations

PermissionsDTO (com.odysseusinc.arachne.portal.api.v1.dto.PermissionsDTO)1 BaseConversionServiceAwareConverter (com.odysseusinc.arachne.portal.api.v1.dto.converters.BaseConversionServiceAwareConverter)1 ArachnePermission (com.odysseusinc.arachne.portal.security.ArachnePermission)1 HasArachnePermissions (com.odysseusinc.arachne.portal.security.HasArachnePermissions)1 Arrays (java.util.Arrays)1 Set (java.util.Set)1 Stream (java.util.stream.Stream)1 Component (org.springframework.stereotype.Component)1