Search in sources :

Example 1 with IdmScriptServicesType

use of eu.bcvsolutions.idm.core.model.jaxb.IdmScriptServicesType in project CzechIdMng by bcvsolutions.

the class DefaultIdmScriptService method dtoToType.

/**
 * Transform dto to type.
 *
 * @param dto
 * @return
 */
private IdmScriptType dtoToType(IdmScriptDto dto, List<IdmScriptAuthorityDto> authorities) {
    IdmScriptType type = new IdmScriptType();
    if (dto == null) {
        return type;
    }
    // transform DTO to type
    type.setCode(dto.getCode());
    type.setName(dto.getName());
    // parameter isn't implemented yet
    // type.setParameters(dto.getParameter());
    type.setBody(dto.getScript());
    type.setCategory(dto.getCategory());
    type.setDescription(dto.getDescription());
    type.setType(SCRIPT_DEFAULT_TYPE);
    // 
    if (authorities != null && !authorities.isEmpty()) {
        List<IdmScriptAllowClassType> classes = new ArrayList<>();
        List<IdmScriptServiceType> services = new ArrayList<>();
        for (IdmScriptAuthorityDto auth : authorities) {
            if (auth.getType() == ScriptAuthorityType.CLASS_NAME) {
                IdmScriptAllowClassType classType = new IdmScriptAllowClassType();
                classType.setClassName(auth.getClassName());
                classes.add(classType);
            } else {
                IdmScriptServiceType service = new IdmScriptServiceType();
                service.setClassName(auth.getClassName());
                service.setName(auth.getService());
                services.add(service);
            }
        }
        if (!classes.isEmpty()) {
            type.setAllowClasses(new IdmScriptAllowClassesType());
            type.getAllowClasses().setAllowClasses(classes);
        }
        if (!services.isEmpty()) {
            type.setServices(new IdmScriptServicesType());
            type.getServices().setServices(services);
        }
    }
    return type;
}
Also used : IdmScriptType(eu.bcvsolutions.idm.core.model.jaxb.IdmScriptType) IdmScriptServicesType(eu.bcvsolutions.idm.core.model.jaxb.IdmScriptServicesType) IdmScriptAllowClassType(eu.bcvsolutions.idm.core.model.jaxb.IdmScriptAllowClassType) IdmScriptServiceType(eu.bcvsolutions.idm.core.model.jaxb.IdmScriptServiceType) IdmScriptAuthorityDto(eu.bcvsolutions.idm.core.api.dto.IdmScriptAuthorityDto) ArrayList(java.util.ArrayList) IdmScriptAllowClassesType(eu.bcvsolutions.idm.core.model.jaxb.IdmScriptAllowClassesType)

Aggregations

IdmScriptAuthorityDto (eu.bcvsolutions.idm.core.api.dto.IdmScriptAuthorityDto)1 IdmScriptAllowClassType (eu.bcvsolutions.idm.core.model.jaxb.IdmScriptAllowClassType)1 IdmScriptAllowClassesType (eu.bcvsolutions.idm.core.model.jaxb.IdmScriptAllowClassesType)1 IdmScriptServiceType (eu.bcvsolutions.idm.core.model.jaxb.IdmScriptServiceType)1 IdmScriptServicesType (eu.bcvsolutions.idm.core.model.jaxb.IdmScriptServicesType)1 IdmScriptType (eu.bcvsolutions.idm.core.model.jaxb.IdmScriptType)1 ArrayList (java.util.ArrayList)1