use of eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto in project CzechIdMng by bcvsolutions.
the class DefaultWorkflowTaskInstanceService method getPermissions.
@Override
public Set<String> getPermissions(WorkflowTaskInstanceDto dto) {
Assert.notNull(dto);
//
final Set<String> permissions = new HashSet<>();
String loggedUserId = securityService.getCurrentId().toString();
//
for (IdentityLinkDto identity : dto.getIdentityLinks()) {
if ((identity.getType().equals(IdentityLinkType.ASSIGNEE) || identity.getType().equals(IdentityLinkType.CANDIDATE)) && identity.getUserId().equals(loggedUserId)) {
permissions.add(IdmBasePermission.EXECUTE.getName());
}
}
return permissions;
}
use of eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto in project CzechIdMng by bcvsolutions.
the class DefaultWorkflowTaskInstanceService method toResource.
private IdentityLinkDto toResource(IdentityLink link) {
if (link == null) {
return null;
}
IdentityLinkDto dto = new IdentityLinkDto();
dto.setGroupId(link.getGroupId());
dto.setType(link.getType());
dto.setUserId(link.getUserId());
return dto;
}
use of eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto in project CzechIdMng by bcvsolutions.
the class DefaultWorkflowTaskInstanceService method toResource.
private WorkflowTaskInstanceDto toResource(Task task) {
if (task == null) {
return null;
}
WorkflowTaskInstanceDto dto = new WorkflowTaskInstanceDto();
dto.setId(task.getId());
dto.setCreated(task.getCreateTime());
dto.setFormKey(task.getFormKey());
dto.setAssignee(task.getAssignee());
dto.setName(task.getName());
dto.setDescription(task.getDescription());
dto.setProcessInstanceId(task.getProcessInstanceId());
Map<String, Object> taksVariables = task.getTaskLocalVariables();
Map<String, Object> processVariables = task.getProcessVariables();
// Add applicant username to task dto (for easier work)
if (processVariables != null && processVariables.containsKey(WorkflowProcessInstanceService.APPLICANT_IDENTIFIER)) {
dto.setApplicant((String) processVariables.get(WorkflowProcessInstanceService.APPLICANT_IDENTIFIER).toString());
}
dto.setVariables(processVariables);
convertToDtoVariables(dto, taksVariables);
dto.setDefinition(workflowTaskDefinitionService.searchTaskDefinitionById(task.getProcessDefinitionId(), task.getTaskDefinitionKey()));
if (!Strings.isNullOrEmpty(task.getProcessDefinitionId())) {
WorkflowProcessDefinitionDto processDefinition = workflowProcessDefinitionService.get(task.getProcessDefinitionId());
if (processDefinition != null) {
dto.setProcessDefinitionKey(processDefinition.getKey());
}
}
TaskFormData taskFormData = formService.getTaskFormData(task.getId());
// Add form data (it means form properties and value from WF)
List<FormProperty> formProperties = taskFormData.getFormProperties();
// Search and add identity links to dto (It means all user
// (assigned/candidates/group) for this task)
List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(task.getId());
if (identityLinks != null) {
List<IdentityLinkDto> identityLinksDtos = new ArrayList<>();
for (IdentityLink il : identityLinks) {
identityLinksDtos.add(toResource(il));
}
dto.getIdentityLinks().addAll(identityLinksDtos);
}
// Check if the logged user can complete this task
boolean canExecute = this.canExecute(dto);
if (formProperties != null && !formProperties.isEmpty()) {
for (FormProperty property : formProperties) {
resovleFormProperty(property, dto, canExecute);
}
}
return dto;
}
Aggregations