use of eu.bcvsolutions.idm.core.model.jaxb.IdmScriptAllowClassesType 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;
}
Aggregations