diff --git a/application-engine/src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/logic/action/ActionDelegate.groovy b/application-engine/src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/logic/action/ActionDelegate.groovy index df4371b62e6..be4a9eda0a3 100644 --- a/application-engine/src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/logic/action/ActionDelegate.groovy +++ b/application-engine/src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/logic/action/ActionDelegate.groovy @@ -33,6 +33,7 @@ import com.netgrif.application.engine.objects.auth.domain.ActorTransformer import com.netgrif.application.engine.menu.services.interfaces.DashboardItemService import com.netgrif.application.engine.menu.services.interfaces.DashboardManagementService import com.netgrif.application.engine.menu.services.interfaces.IMenuItemService +import com.netgrif.application.engine.objects.auth.domain.Group import com.netgrif.application.engine.objects.auth.domain.LoggedUser import com.netgrif.application.engine.objects.petrinet.domain.I18nString import com.netgrif.application.engine.objects.petrinet.domain.PetriNet @@ -781,10 +782,27 @@ class ActionDelegate { if (field instanceof NumberField) { value = value as Double } - if (field instanceof UserListField && (value instanceof String[] || value instanceof List)) { - LinkedHashSet users = new LinkedHashSet<>() - value.each { id -> users.add(new UserFieldValue(userService.findById(id as String, null))) } - value = new UserListFieldValue(users) + if (field instanceof ActorListField && (value instanceof String[] || value instanceof List)) { + LinkedHashSet actorFieldValues = new LinkedHashSet<>() + value.each { id -> + AbstractUser user = userService.findById(id as String, null) + if (user != null) { + actorFieldValues.add(new UserFieldValue(user)) + } else { + Group group = groupService.findById((String) id) + actorFieldValues.add(new GroupFieldValue(group)) + } + } + value = new ActorListFieldValue(actorFieldValues) + } + if (field instanceof ActorField && value instanceof String) { + AbstractUser user = userService.findById(value, null) + if (user != null) { + value = new UserFieldValue(user) + } else { + Group group = groupService.findById(value) + value = new GroupFieldValue(group) + } } // if (field instanceof TaskField && targetTask.isPresent()) { // dataService.validateTaskRefValue(value, targetTask.get().getStringId()); diff --git a/application-engine/src/main/java/com/netgrif/application/engine/auth/web/UserController.java b/application-engine/src/main/java/com/netgrif/application/engine/auth/web/UserController.java index e03c3f168ef..2818d2d98ae 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/auth/web/UserController.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/auth/web/UserController.java @@ -181,17 +181,17 @@ public ResponseEntity getUser(@PathVariable("realmId") String realmId, @Pa // return null; // } // LoggedUser loggedUser = (LoggedUser) auth.getPrincipal(); -// String userId = updates.getStringId(); +// String actorId = updates.getStringId(); // IUser user; // try { -// user = userService.findById(userId, updatedUser.getRealmId()); +// user = userService.findById(actorId, updatedUser.getRealmId()); // } catch (IllegalArgumentException e) { -// log.error("Could not find user with id [{}]", userId, e); +// log.error("Could not find user with id [{}]", actorId, e); // return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); // } // user = userService.update(user, updates.getUpdatedUser()); -// securityContextService.saveToken(userId); -// if (Objects.equals(loggedUser.getId(), userId)) { +// securityContextService.saveToken(actorId); +// if (Objects.equals(loggedUser.getId(), actorId)) { // loggedUser.setFirstName(user.getFirstName()); // loggedUser.setLastName(user.getLastName()); // securityContextService.reloadSecurityContext(loggedUser); @@ -239,15 +239,15 @@ public ResponseEntity assignRolesToUser(@PathVariable("realmId" // @ApiResponse(responseCode = "403", description = "Caller doesn't fulfill the authorisation requirements"), // @ApiResponse(responseCode = "500", description = "Internal server error") // }) -// public ResponseEntity assignNegativeRolesToUser(@PathVariable("realmId") String realmId, @PathVariable("id") String userId, @RequestBody Set roleIds, Authentication auth) { +// public ResponseEntity assignNegativeRolesToUser(@PathVariable("realmId") String realmId, @PathVariable("id") String actorId, @RequestBody Set roleIds, Authentication auth) { // try { -// AbstractUser user = userService.findById(userId, realmId); +// AbstractUser user = userService.findById(actorId, realmId); // processRoleService.assignNegativeRolesToUser(user, roleIds.stream().map(ProcessResourceId::new).collect(Collectors.toSet()), (LoggedUser) auth.getPrincipal()); -// log.info("Negative process roles {} assigned to user [{}]", roleIds, userId); -// return ResponseEntity.ok(ResponseMessage.createSuccessMessage("Selected negative roles assigned to user " + userId)); +// log.info("Negative process roles {} assigned to user [{}]", roleIds, actorId); +// return ResponseEntity.ok(ResponseMessage.createSuccessMessage("Selected negative roles assigned to user " + actorId)); // } catch (IllegalArgumentException e) { -// log.error("Assigning negative roles to user with id [{}] has failed!", userId, e); -// return ResponseEntity.badRequest().body(ResponseMessage.createErrorMessage("Assigning negative roles to user " + userId + " has failed!")); +// log.error("Assigning negative roles to user with id [{}] has failed!", actorId, e); +// return ResponseEntity.badRequest().body(ResponseMessage.createErrorMessage("Assigning negative roles to user " + actorId + " has failed!")); // } // } // diff --git a/application-engine/src/main/java/com/netgrif/application/engine/elastic/service/ElasticCaseMappingService.java b/application-engine/src/main/java/com/netgrif/application/engine/elastic/service/ElasticCaseMappingService.java index 23ec0930def..8bc66877104 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/elastic/service/ElasticCaseMappingService.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/elastic/service/ElasticCaseMappingService.java @@ -1,7 +1,5 @@ package com.netgrif.application.engine.elastic.service; -import com.netgrif.application.engine.objects.elastic.domain.UserField; -import com.netgrif.application.engine.objects.elastic.domain.UserListField; import com.netgrif.application.engine.objects.elastic.domain.*; import com.netgrif.application.engine.elastic.service.interfaces.IElasticCaseMappingService; import com.netgrif.application.engine.objects.petrinet.domain.I18nString; @@ -36,7 +34,7 @@ protected void populateDataSet(ElasticCase transformedCase, Case useCase) { } protected Optional transformDataField(String fieldId, Case useCase) { - Field netField = useCase.getField(fieldId); + Field netField = useCase.getField(fieldId); com.netgrif.application.engine.objects.workflow.domain.DataField caseField = useCase.getDataField(fieldId); if (caseField.getValue() == null) { @@ -51,8 +49,8 @@ protected Optional transformDataField(String fieldId, Case useCase) { return this.transformNumberField(caseField); } else if (netField instanceof com.netgrif.application.engine.objects.petrinet.domain.dataset.ButtonField) { return this.transformButtonField(caseField); - } else if (netField instanceof com.netgrif.application.engine.objects.petrinet.domain.dataset.UserField) { - return this.transformUserField(caseField); + } else if (netField instanceof com.netgrif.application.engine.objects.petrinet.domain.dataset.ActorField) { + return this.transformActorField(caseField); } else if (netField instanceof com.netgrif.application.engine.objects.petrinet.domain.dataset.DateField) { return this.transformDateField(caseField, (com.netgrif.application.engine.objects.petrinet.domain.dataset.DateField) netField); } else if (netField instanceof DateTimeField) { @@ -67,8 +65,8 @@ protected Optional transformDataField(String fieldId, Case useCase) { return this.transformFileField(caseField); } else if (netField instanceof FileListField) { return this.transformFileListField(caseField); - } else if (netField instanceof com.netgrif.application.engine.objects.petrinet.domain.dataset.UserListField) { - return this.transformUserListField(caseField); + } else if (netField instanceof com.netgrif.application.engine.objects.petrinet.domain.dataset.ActorListField) { + return this.transformActorListField(caseField); } else if (netField instanceof com.netgrif.application.engine.objects.petrinet.domain.dataset.I18nField) { return this.transformI18nField(caseField, (com.netgrif.application.engine.objects.petrinet.domain.dataset.I18nField) netField); } else if (netField instanceof com.netgrif.application.engine.objects.petrinet.domain.dataset.CaseField) { @@ -88,7 +86,7 @@ protected Optional transformDataField(String fieldId, Case useCase) { protected Optional transformMultichoiceMapField (com.netgrif.application.engine.objects.workflow.domain.DataField multichoiceMap, MultichoiceMapField netField) { Optional optValues = this.getMultichoiceValue(multichoiceMap, netField); - if (!optValues.isPresent()) { + if (optValues.isEmpty()) { return Optional.empty(); } Set mapValues = optValues.get(); @@ -110,22 +108,23 @@ protected Optional transformDataField(String fieldId, Case useCase) { return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.I18nField(keys, values, ((I18nString) dataField.getValue()).getTranslations())); } - protected Optional transformCaseFieldField(com.netgrif.application.engine.objects.workflow.domain.DataField dataField, com.netgrif.application.engine.objects.petrinet.domain.dataset.CaseField netField) { - String[] allowedNets = dataField.getAllowedNets().toArray(new String[0]); - String[] referencedCases = ((List) dataField.getValue()).toArray(new String[0]); - return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.CaseField(referencedCases,allowedNets)); + protected Optional transformCaseFieldField(com.netgrif.application.engine.objects.workflow.domain.DataField dataField, + com.netgrif.application.engine.objects.petrinet.domain.dataset.CaseField netField) { + return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.CaseField( + (List) dataField.getValue(), dataField.getAllowedNets())); } - protected Optional transformFilterFieldField(com.netgrif.application.engine.objects.workflow.domain.DataField dataField, com.netgrif.application.engine.objects.petrinet.domain.dataset.FilterField netField) { - String[] allowedNets = dataField.getAllowedNets().toArray(new String[0]); - Map filterMetadata = dataField.getFilterMetadata(); - return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.FilterField(dataField.getValue().toString(),allowedNets, filterMetadata)); + protected Optional transformFilterFieldField(com.netgrif.application.engine.objects.workflow.domain.DataField dataField, + com.netgrif.application.engine.objects.petrinet.domain.dataset.FilterField netField) { + return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.FilterField( + dataField.getValue().toString(), dataField.getAllowedNets(), dataField.getFilterMetadata())); } - protected Optional transformStringCollectionField(com.netgrif.application.engine.objects.workflow.domain.DataField dataField, com.netgrif.application.engine.objects.petrinet.domain.dataset.StringCollectionField netField) { - if (dataField.getValue() != null && dataField.getValue() instanceof Collection && !((Collection) dataField.getValue()).isEmpty()) { - String[] values = ((Collection) dataField.getValue()).toArray(new String[0]); - return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.StringCollectionField(values)); + protected Optional transformStringCollectionField(com.netgrif.application.engine.objects.workflow.domain.DataField dataField, + com.netgrif.application.engine.objects.petrinet.domain.dataset.StringCollectionField netField) { + if (dataField.getValue() != null && dataField.getValue() instanceof Collection dataFieldValue && !dataFieldValue.isEmpty()) { + List dataFieldValueAsList = dataFieldValue.stream().map(String::valueOf).toList(); + return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.StringCollectionField(dataFieldValueAsList)); } return Optional.empty(); } @@ -135,7 +134,8 @@ protected Optional transformStringCollectionField(com.netgrif.applica Map options = this.getFieldOptions(enumMap, netField); String selectedKey = (String) enumMap.getValue(); I18nString selectedValue = options.get(selectedKey); - return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.MapField(new AbstractMap.SimpleEntry<>(selectedKey, selectedValue != null ? selectedValue : new I18nString("")))); + return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.MapField( + new AbstractMap.SimpleEntry<>(selectedKey, selectedValue != null ? selectedValue : new I18nString("")))); } private Map getFieldOptions @@ -149,7 +149,7 @@ protected Optional transformStringCollectionField(com.netgrif.applica protected Optional transformMultichoiceField (com.netgrif.application.engine.objects.workflow.domain.DataField multichoiceField, MultichoiceField netField) { Optional optValues = this.getMultichoiceValue(multichoiceField, netField); - if (!optValues.isPresent()) { + if (optValues.isEmpty()) { return Optional.empty(); } Set values = optValues.get(); @@ -165,7 +165,7 @@ protected Optional transformStringCollectionField(com.netgrif.applica log.error("MultichoiceField has element value of illegal type! Expected: I18nString, Found: " + value.getClass().getCanonicalName()); } }); - return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.TextField(translations.toArray(new String[0]))); + return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.TextField(translations)); } private Optional getMultichoiceValue(com.netgrif.application.engine.objects.workflow.domain.DataField @@ -188,7 +188,7 @@ private Optional getMultichoiceValue(com.netgrif.application.engine.objects (com.netgrif.application.engine.objects.workflow.domain.DataField enumField) { Object value = enumField.getValue(); if (value instanceof I18nString) { - return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.TextField(I18nStringUtils.collectTranslations((I18nString) value).toArray(new String[0]))); + return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.TextField(I18nStringUtils.collectTranslations((I18nString) value))); } else if (value instanceof String) { return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.TextField((String) value)); } else { @@ -211,46 +211,27 @@ private Optional getMultichoiceValue(com.netgrif.application.engine.objects return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.ButtonField((Integer) buttonField.getValue())); } - protected Optional transformUserField - (com.netgrif.application.engine.objects.workflow.domain.DataField userField) { - UserFieldValue user = (UserFieldValue) userField.getValue(); - if (user == null) + protected Optional transformActorField + (com.netgrif.application.engine.objects.workflow.domain.DataField actorField) { + ActorFieldValue actorFieldValue = (ActorFieldValue) actorField.getValue(); + if (actorFieldValue == null) return Optional.empty(); - return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.UserField(this.transformUserValue(user))); + return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.ActorField(actorFieldValue.buildMappingData())); } - protected Optional transformUserListField - (com.netgrif.application.engine.objects.workflow.domain.DataField userListField) { - UserListFieldValue userListValue = (UserListFieldValue) userListField.getValue(); - UserField.UserMappingData[] userMappingData = userListValue.getUserValues().stream().map(this::transformUserListValue).toArray(UserField.UserMappingData[]::new); - return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.UserListField(userMappingData)); - } - - private UserField.UserMappingData transformUserValue(UserFieldValue user) { - return new UserField.UserMappingData(user.getId(), user.getRealmId(), user.getUsername(), buildFullName(user.getFirstName(), user.getLastName()).toString()); - } - - private UserListField.UserMappingData transformUserListValue(UserFieldValue user) { - return new UserListField.UserMappingData(user.getId(), user.getRealmId(), user.getUsername(), buildFullName(user.getFirstName(), user.getLastName()).toString()); - } - - private StringBuilder buildFullName(String name, String surname) { - StringBuilder fullName = new StringBuilder(); - if (name != null) { - fullName.append(name); - fullName.append(" "); - } - if (surname != null) { - fullName.append(surname); - } - return fullName; + protected Optional transformActorListField + (com.netgrif.application.engine.objects.workflow.domain.DataField actorListField) { + ActorListFieldValue actorListFieldValue = (ActorListFieldValue) actorListField.getValue(); + List actorMappingDataList = actorListFieldValue.getActorValues().stream() + .map(ActorFieldValue::buildMappingData) + .toList(); + return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.ActorListField(actorMappingDataList)); } protected Optional transformDateField (com.netgrif.application.engine.objects.workflow.domain.DataField dateField, com.netgrif.application.engine.objects.petrinet.domain.dataset.DateField netField) { - if (dateField.getValue() instanceof LocalDate) { - LocalDate date = (LocalDate) dateField.getValue(); + if (dateField.getValue() instanceof LocalDate date) { return formatDateField(LocalDateTime.of(date, LocalTime.MIDNIGHT)); } else if (dateField.getValue() instanceof Date) { // log.warn(String.format("DateFields should have LocalDate values! DateField (%s) with Date value found! Value will be converted for indexation.", netField.getImportId())); @@ -310,7 +291,7 @@ private Optional formatDateField(LocalDateTime date) { protected Optional transformFileListField (com.netgrif.application.engine.objects.workflow.domain.DataField fileListField) { - return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.FileField(((FileListFieldValue) fileListField.getValue()).getNamesPaths().toArray(new FileFieldValue[0]))); + return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.FileField(((FileListFieldValue) fileListField.getValue()).getNamesPaths())); } protected Optional transformOtherFields diff --git a/application-engine/src/main/java/com/netgrif/application/engine/elastic/service/ElasticViewPermissionService.java b/application-engine/src/main/java/com/netgrif/application/engine/elastic/service/ElasticViewPermissionService.java index 33404f4c7ba..e8362e13fc3 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/elastic/service/ElasticViewPermissionService.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/elastic/service/ElasticViewPermissionService.java @@ -8,17 +8,16 @@ import com.netgrif.application.engine.objects.auth.domain.LoggedUser; import com.netgrif.application.engine.objects.petrinet.domain.roles.ProcessRole; +import java.util.HashSet; +import java.util.Set; import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static org.springframework.data.elasticsearch.client.elc.Queries.termQuery; public abstract class ElasticViewPermissionService { protected void buildViewPermissionQuery(BoolQuery.Builder query, LoggedUser user) { BoolQuery.Builder viewPermsExists = new BoolQuery.Builder() .should(should -> should.exists(ExistsQuery.of(builder -> builder.field("viewRoles")))) - .should(should -> should.exists(ExistsQuery.of(builder -> builder.field("viewUserRefs")))); + .should(should -> should.exists(ExistsQuery.of(builder -> builder.field("viewActorRefs")))); BoolQuery.Builder viewPermNotExistsBuilder = new BoolQuery.Builder() .mustNot(mustNot -> mustNot.bool(viewPermsExists.build())); @@ -33,17 +32,17 @@ protected void buildViewPermissionQuery(BoolQuery.Builder query, LoggedUser user /* Positive view role set-minus negative view role */ BoolQuery positiveRoleSetMinusNegativeRole = setMinus(positiveViewRole, negativeViewRole); - /* Build positive view userList query */ - BoolQuery positiveViewUser = buildPositiveViewUser(viewPermNotExists, user); + /* Build positive view actorList query */ + BoolQuery positiveViewActor = buildPositiveViewActor(viewPermNotExists, user); - /* Role query union positive view userList */ - BoolQuery roleSetMinusPositiveUserList = union(positiveRoleSetMinusNegativeRole, positiveViewUser); + /* Role query union positive view actorList */ + BoolQuery roleSetMinusPositiveActorList = union(positiveRoleSetMinusNegativeRole, positiveViewActor); - /* Build negative view userList query */ - BoolQuery negativeViewUser = buildNegativeViewUser(user); + /* Build negative view actorList query */ + BoolQuery negativeViewActor = buildNegativeViewActor(user); - /* Role-UserListPositive set-minus negative view userList */ - BoolQuery permissionQuery = setMinus(roleSetMinusPositiveUserList, negativeViewUser); + /* Role-UserListPositive set-minus negative view actorList */ + BoolQuery permissionQuery = setMinus(roleSetMinusPositiveActorList, negativeViewActor); query.filter(permissionQuery._toQuery()); } @@ -76,16 +75,26 @@ private BoolQuery buildNegativeViewRoleQuery(LoggedUser user) { return negativeViewRole.build(); } - private BoolQuery buildPositiveViewUser(BoolQuery viewPermNotExists, LoggedUser user) { + private BoolQuery buildPositiveViewActor(BoolQuery viewPermNotExists, LoggedUser user) { + TermsQueryField actorIdsQueryField = buildTermsQueryFieldOfUser(user); return new BoolQuery.Builder() .should(viewPermNotExists._toQuery()) - .filter(termQuery("viewUsers", user.getStringId())._toQuery()) + .filter(QueryBuilders.terms(term -> term.field("viewActors").terms(actorIdsQueryField))) .build(); } - private BoolQuery buildNegativeViewUser(LoggedUser user) { + private BoolQuery buildNegativeViewActor(LoggedUser user) { + TermsQueryField actorIdsQueryField = buildTermsQueryFieldOfUser(user); return new BoolQuery.Builder() - .mustNot(termQuery("negativeViewUsers", user.getStringId())._toQuery()) + .mustNot(QueryBuilders.terms(term -> term.field("negativeViewActors").terms(actorIdsQueryField))) + .build(); + } + + private TermsQueryField buildTermsQueryFieldOfUser(LoggedUser loggedUser) { + Set actorIds = loggedUser.getGroupIds() == null ? new HashSet<>() : new HashSet<>(loggedUser.getGroupIds()); + actorIds.add(loggedUser.getStringId()); + return new TermsQueryField.Builder() + .value(actorIds.stream().map(FieldValue::of).toList()) .build(); } diff --git a/application-engine/src/main/java/com/netgrif/application/engine/export/service/ExportService.java b/application-engine/src/main/java/com/netgrif/application/engine/export/service/ExportService.java index fb56f44eb97..2e806ae1ebe 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/export/service/ExportService.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/export/service/ExportService.java @@ -273,17 +273,25 @@ public String resolveFieldValue(Case exportCase, String exportFieldId) { case TASK_REF: fieldValue = String.join(";", ((TaskField) fieldData).getValue()); break; - case USER: - fieldValue = ((UserFieldValue) fieldData).getUsername(); + case ACTOR: + if (fieldData instanceof UserFieldValue) { + fieldValue = ((UserFieldValue) fieldData).getUsername(); + } else if (fieldData instanceof GroupFieldValue) { + fieldValue = ((GroupFieldValue) fieldData).getName(); + } else { + fieldValue = ""; + } break; case DATE: fieldValue = ((LocalDate) fieldData).toString(); break; case DATETIME: - fieldValue = ((Date) fieldData).toString(); + fieldValue = fieldData.toString(); break; - case USERLIST: - fieldValue = ((UserListField) fieldData).getValue().getUserValues().stream().map(UserFieldValue::getId).collect(Collectors.joining(";")); + case ACTORLIST: + fieldValue = ((ActorListField) fieldData).getValue().getActorValues().stream() + .map(ActorFieldValue::getId) + .collect(Collectors.joining(";")); break; case NUMBER: fieldValue = fieldData.toString(); diff --git a/application-engine/src/main/java/com/netgrif/application/engine/impersonation/service/ImpersonationAuthorizationService.java b/application-engine/src/main/java/com/netgrif/application/engine/impersonation/service/ImpersonationAuthorizationService.java index 94b492f20b4..6898d62f6b3 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/impersonation/service/ImpersonationAuthorizationService.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/impersonation/service/ImpersonationAuthorizationService.java @@ -139,7 +139,7 @@ protected CaseSearchRequest makeRequest(String impersonatorId, String impersonat queries.add("(dataSet.is_active.booleanValue:true)"); queries.addAll(validityQueries()); if (impersonatedId != null) { - queries.add("(dataSet.impersonated.userIdValue.keyword:" + impersonatedId + ")"); + queries.add("(dataSet.impersonated.actorIdValue.keyword:" + impersonatedId + ")"); } request.query = combineQueries(queries); return request; diff --git a/application-engine/src/main/java/com/netgrif/application/engine/importer/service/DataValidator.java b/application-engine/src/main/java/com/netgrif/application/engine/importer/service/DataValidator.java index b0bf2752e11..cb9bb77f366 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/importer/service/DataValidator.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/importer/service/DataValidator.java @@ -1,6 +1,7 @@ package com.netgrif.application.engine.importer.service; import com.netgrif.application.engine.objects.importer.model.Data; +import com.netgrif.application.engine.objects.importer.model.DataType; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -14,11 +15,13 @@ public void checkDeprecatedAttributes(Data data) { validateAttribute(data.getValid() != null && !data.getValid().isEmpty() ? data.getValid() : null, "valid", data.getId()); validateAttribute(data.getFormat(), "format", data.getId()); validateAttribute(data.getValues() != null && !data.getValues().isEmpty() ? data.getValues() : null, "values", data.getId()); + validateAttribute(data.getType() == DataType.USER ? Boolean.TRUE : null, "type: " + DataType.USER.name(), data.getId()); + validateAttribute(data.getType() == DataType.USER_LIST ? Boolean.TRUE : null, "type: " + DataType.USER_LIST.name(), data.getId()); } protected void validateAttribute(Object attr, String attrName, String fieldName) { if (attr != null) { - log.warn("Data attribute [" + attrName + "] on field [" + fieldName + "] is deprecated."); + log.warn("Data attribute [{}] on field [{}] is deprecated.", attrName, fieldName); } } } diff --git a/application-engine/src/main/java/com/netgrif/application/engine/importer/service/DocumentValidator.java b/application-engine/src/main/java/com/netgrif/application/engine/importer/service/DocumentValidator.java index d2e948ba66f..2745e32df0d 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/importer/service/DocumentValidator.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/importer/service/DocumentValidator.java @@ -11,6 +11,7 @@ public class DocumentValidator implements IDocumentValidator { @Override public void checkDeprecatedAttributes(Document document) { validateAttribute(document.getUsersRef(), "usersRef"); + validateAttribute(document.getUsersRef(), "userRef"); } @Override diff --git a/application-engine/src/main/java/com/netgrif/application/engine/importer/service/FieldFactory.java b/application-engine/src/main/java/com/netgrif/application/engine/importer/service/FieldFactory.java index e0a0e55bbd5..b7ab15b8f1e 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/importer/service/FieldFactory.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/importer/service/FieldFactory.java @@ -223,11 +223,13 @@ Field getField(Data data, Importer importer) throws IllegalArgumentException, Mi case NUMBER: field = buildNumberField(data); break; + case ACTOR: case USER: - field = buildUserField(data, importer); + field = buildActorField(data, importer); break; + case ACTOR_LIST: case USER_LIST: - field = buildUserListField(data, importer); + field = buildActorListField(data, importer); break; case CASE_REF: field = buildCaseField(data); @@ -505,22 +507,22 @@ private CaseField buildCaseField(Data data) { return field; } - private UserField buildUserField(Data data, Importer importer) { + private ActorField buildActorField(Data data, Importer importer) { String[] roles = data.getValues().stream() .map(value -> importer.getRoles().get(value.getValue()).getStringId()) .toArray(String[]::new); - UserField field = new UserField(roles); + ActorField field = new ActorField(roles); setDefaultValues(field, data, inits -> { field.setDefaultValue(null); }); return field; } - private UserListField buildUserListField(Data data, Importer importer) { + private ActorListField buildActorListField(Data data, Importer importer) { String[] roles = data.getValues().stream() .map(value -> importer.getRoles().get(value.getValue()).getStringId()) .toArray(String[]::new); - UserListField field = new UserListField(roles); + ActorListField field = new ActorListField(roles); setDefaultValues(field, data, inits -> { }); return field; @@ -709,33 +711,33 @@ private void resolveDataValues(Field field, Case useCase, String fieldId) { case FILELIST: parseFileListValue((FileListField) field, useCase, fieldId); break; - case USER: - parseUserValues((UserField) field, useCase, fieldId); + case ACTOR: + parseActorValues((ActorField) field, useCase, fieldId); break; - case USERLIST: - parseUserListValues((UserListField) field, useCase, fieldId); + case ACTORLIST: + parseActorListValues((ActorListField) field, useCase, fieldId); break; default: field.setValue(useCase.getFieldValue(fieldId)); } } - private void parseUserValues(UserField field, Case useCase, String fieldId) { - DataField userField = useCase.getDataField(fieldId); - if (userField.getChoices() != null) { - Set roles = userField.getChoices().stream().map(I18nString::getDefaultValue).collect(Collectors.toSet()); + private void parseActorValues(ActorField field, Case useCase, String fieldId) { + DataField actorField = useCase.getDataField(fieldId); + if (actorField.getChoices() != null) { + Set roles = actorField.getChoices().stream().map(I18nString::getDefaultValue).collect(Collectors.toSet()); field.setRoles(roles); } - field.setValue((UserFieldValue) useCase.getFieldValue(fieldId)); + field.setValue((ActorFieldValue) useCase.getFieldValue(fieldId)); } - private void parseUserListValues(UserListField field, Case useCase, String fieldId) { - DataField userListField = useCase.getDataField(fieldId); - if (userListField.getChoices() != null) { - Set roles = userListField.getChoices().stream().map(I18nString::getDefaultValue).collect(Collectors.toSet()); + private void parseActorListValues(ActorListField field, Case useCase, String fieldId) { + DataField actorListField = useCase.getDataField(fieldId); + if (actorListField.getChoices() != null) { + Set roles = actorListField.getChoices().stream().map(I18nString::getDefaultValue).collect(Collectors.toSet()); field.setRoles(roles); } - field.setValue((UserListFieldValue) useCase.getFieldValue(fieldId)); + field.setValue((ActorListFieldValue) useCase.getFieldValue(fieldId)); } private Double parseNumberValue(Case useCase, String fieldId) { diff --git a/application-engine/src/main/java/com/netgrif/application/engine/importer/service/IModelValidator.java b/application-engine/src/main/java/com/netgrif/application/engine/importer/service/IModelValidator.java index 334b9f7bf70..e6d8b0852b4 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/importer/service/IModelValidator.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/importer/service/IModelValidator.java @@ -11,11 +11,11 @@ default void validateAttribute(Object attr, String attrName) { Logger log = LoggerFactory.getLogger(IModelValidator.class); if (attr instanceof Collection && !((Collection) attr).isEmpty()) { - log.warn("Data attribute [" + attrName + "] is deprecated."); + log.warn("Data attribute [{}] is deprecated.", attrName); } if (!(attr instanceof Collection) && attr != null) { - log.warn("Data attribute [" + attrName + "] is deprecated."); + log.warn("Data attribute [{}] is deprecated.", attrName); } } } diff --git a/application-engine/src/main/java/com/netgrif/application/engine/importer/service/Importer.java b/application-engine/src/main/java/com/netgrif/application/engine/importer/service/Importer.java index b52ee3581b4..dd83498036b 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/importer/service/Importer.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/importer/service/Importer.java @@ -44,7 +44,6 @@ import org.bson.types.ObjectId; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Pageable; -import org.springframework.transaction.annotation.Transactional; import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBException; @@ -75,7 +74,7 @@ public class Importer { protected ProcessRole anonymousRole; @Getter protected Map roles; - protected Map fields; + protected Map> fields; protected Map transitions; protected Map places; protected Map transactions; @@ -129,7 +128,6 @@ public class Importer { @Autowired private ILogicValidator logicValidator; - @Transactional public Optional importPetriNet(InputStream xml) throws MissingPetriNetMetaDataException, MissingIconKeyException { try { initialize(); @@ -141,7 +139,6 @@ public Optional importPetriNet(InputStream xml) throws MissingPetriNet return Optional.empty(); } - @Transactional public Optional importPetriNet(File xml) throws MissingPetriNetMetaDataException, MissingIconKeyException { try { return importPetriNet(new FileInputStream(xml)); @@ -165,7 +162,6 @@ protected void initialize() { this.functions = new LinkedList<>(); } - @Transactional protected void unmarshallXml(InputStream xml) throws JAXBException { JAXBContext jaxbContext = JAXBContext.newInstance(Document.class); @@ -173,7 +169,6 @@ protected void unmarshallXml(InputStream xml) throws JAXBException { document = (Document) jaxbUnmarshaller.unmarshal(xml); } - @Transactional public Path saveNetFile(PetriNet net, InputStream xmlFile) throws IOException { File savedFile = new File(fileStorageConfiguration.getArchivedPath() + net.getStringId() + "-" + net.getTitle() + FILE_EXTENSION); savedFile.getParentFile().mkdirs(); @@ -182,12 +177,11 @@ public Path saveNetFile(PetriNet net, InputStream xmlFile) throws IOException { return savedFile.toPath(); } - @Transactional protected Optional createPetriNet() throws MissingPetriNetMetaDataException, MissingIconKeyException { net = new com.netgrif.application.engine.adapter.spring.petrinet.domain.PetriNet(); net.setVersion(null); - documentValidator.checkConflictingAttributes(document, document.getUsersRef(), document.getUserRef(), "usersRef", "userRef"); + documentValidator.checkConflictingAttributes(document, document.getUsersRef(), document.getActorRef(), "usersRef", "userRef"); documentValidator.checkDeprecatedAttributes(document); document.getI18N().forEach(this::addI18N); @@ -213,8 +207,9 @@ protected Optional createPetriNet() throws MissingPetriNetMetaDataExce actionRefs.forEach(this::resolveActionRefs); document.getFunction().forEach(this::createFunction); document.getRoleRef().forEach(this::resolveRoleRef); - document.getUsersRef().forEach(this::resolveUserRef); - document.getUserRef().forEach(this::resolveUserRef); + document.getUsersRef().forEach(this::resolveActorRef); // deprecated + document.getUserRef().forEach(this::resolveActorRef); // deprecated + document.getActorRef().forEach(this::resolveActorRef); addPredefinedRolesWithDefaultPermissions(); @@ -235,7 +230,6 @@ protected Optional createPetriNet() throws MissingPetriNetMetaDataExce return Optional.of(net); } - @Transactional protected void resolveRoleRef(CaseRoleRef roleRef) { CaseLogic logic = roleRef.getCaseLogic(); String roleId = getRole(roleRef.getId()).getStringId(); @@ -250,7 +244,6 @@ protected void resolveRoleRef(CaseRoleRef roleRef) { net.addPermission(roleId, roleFactory.getProcessPermissions(logic)); } - @Transactional protected void createFunction(com.netgrif.application.engine.objects.importer.model.Function function) { com.netgrif.application.engine.objects.petrinet.domain.Function fun = functionFactory.getFunction(function); @@ -258,33 +251,29 @@ protected void createFunction(com.netgrif.application.engine.objects.importer.mo functions.add(fun); } - @Transactional - protected void resolveUserRef(CaseUserRef userRef) { - CaseLogic logic = userRef.getCaseLogic(); - String usersId = userRef.getId(); + protected void resolveActorRef(CaseActorRef actorRef) { + CaseLogic logic = actorRef.getCaseLogic(); + String actorFieldId = actorRef.getId(); - if (logic == null || usersId == null) { + if (logic == null || actorFieldId == null) { return; } - net.addUserPermission(usersId, roleFactory.getProcessPermissions(logic)); + net.addActorPermission(actorFieldId, roleFactory.getProcessPermissions(logic)); } - @Transactional protected void resolveProcessEvents(ProcessEvents processEvents) { if (processEvents != null && processEvents.getEvent() != null) { net.setProcessEvents(createProcessEventsMap(processEvents.getEvent())); } } - @Transactional protected void resolveCaseEvents(CaseEvents caseEvents) { if (caseEvents != null && caseEvents.getEvent() != null) { net.setCaseEvents(createCaseEventsMap(caseEvents.getEvent())); } } - @Transactional protected void evaluateFunctions() { try { actionsCacheService.evaluateFunctions(functions); @@ -293,7 +282,6 @@ protected void evaluateFunctions() { } } - @Transactional protected void evaluateActions(String s, Action action) { try { actionsRunner.getActionCode(action, functions, true); @@ -302,7 +290,6 @@ protected void evaluateActions(String s, Action action) { } } - @Transactional protected void resolveActionRefs(String actionId, Action action) { Action referenced = actions.get(actionId); if (referenced == null) { @@ -312,13 +299,11 @@ protected void resolveActionRefs(String actionId, Action action) { action.setTrigger(referenced.getTrigger()); } - @Transactional protected void addI18N(I18N importI18N) { String locale = importI18N.getLocale(); importI18N.getI18NString().forEach(translation -> addTranslation(translation, locale)); } - @Transactional protected void addTranslation(I18NStringType i18NStringType, String locale) { String name = i18NStringType.getName(); I18nString translation = getI18n(name); @@ -329,7 +314,6 @@ protected void addTranslation(I18NStringType i18NStringType, String locale) { translation.addTranslation(locale, i18NStringType.getValue()); } - @Transactional protected void applyMapping(Mapping mapping) throws MissingIconKeyException { Transition transition = getTransition(mapping.getTransitionRef()); mapping.getRoleRef().forEach(roleRef -> addRoleLogic(transition, roleRef)); @@ -340,7 +324,7 @@ protected void applyMapping(Mapping mapping) throws MissingIconKeyException { mapping.getTrigger().forEach(trigger -> addTrigger(transition, trigger)); } - @Transactional + protected void resolveDataActions(Data data) { String fieldId = data.getId(); if (data.getEvent() != null && !data.getEvent().isEmpty()) { @@ -378,7 +362,6 @@ private void addActionsToEvent(List actions, DataEventType type, Map actions = buildActionRefs(data.getActionRef()); @@ -398,7 +381,6 @@ protected Action fromActionRef(ActionRef actionRef) { return placeholder; } - @Transactional protected void resolveTransitionActions(com.netgrif.application.engine.objects.importer.model.Transition trans) { if (trans.getDataRef() != null) { resolveDataRefActions(trans.getDataRef(), trans); @@ -412,7 +394,6 @@ protected void resolveTransitionActions(com.netgrif.application.engine.objects.i } } - @Transactional protected void resolveDataRefActions(List dataRef, com.netgrif.application.engine.objects.importer.model.Transition trans) { dataRef.forEach(ref -> { String fieldId = getField(ref.getId()).getStringId(); @@ -459,7 +440,6 @@ protected DataEvent createDefaultEvent(List actions, DataEventType type) return event; } - @Transactional protected void createArc(com.netgrif.application.engine.objects.importer.model.Arc importArc) { Arc arc = arcFactory.getArc(importArc); arc.setImportId(importArc.getId()); @@ -487,15 +467,13 @@ protected void createArc(com.netgrif.application.engine.objects.importer.model.A net.addArc(arc); } - @Transactional protected void createDataSet(Data importData) throws MissingIconKeyException { - Field field = fieldFactory.getField(importData, this); + Field field = fieldFactory.getField(importData, this); net.addDataSetField(field); fields.put(importData.getId(), field); } - @Transactional protected void createTransition(com.netgrif.application.engine.objects.importer.model.Transition importTransition) throws MissingIconKeyException { transitionValidator.checkConflictingAttributes(importTransition, importTransition.getUsersRef(), importTransition.getUserRef(), "usersRef", "userRef"); transitionValidator.checkDeprecatedAttributes(importTransition); @@ -523,15 +501,18 @@ protected void createTransition(com.netgrif.application.engine.objects.importer. addRoleLogic(transition, roleRef) ); } - /* @Deprecated - This 'importTransition.getUsersRef()' is deprecated, will be removed in future releases*/ + /* @Deprecated - This 'importTransition.getUsersRef()' is deprecated, will be removed in future releases */ if (importTransition.getUsersRef() != null) { - importTransition.getUsersRef().forEach(usersRef -> - addUserLogic(transition, usersRef)); + importTransition.getUsersRef().forEach(usersRef -> addActorLogic(transition, usersRef)); } + /* @Deprecated - This 'importTransition.getUserRef()' is deprecated, will be removed in future releases */ if (importTransition.getUserRef() != null) { - importTransition.getUserRef().forEach(userRef -> - addUserLogic(transition, userRef)); + importTransition.getUserRef().forEach(userRef -> addActorLogic(transition, userRef)); + } + + if (importTransition.getActorRef() != null) { + importTransition.getActorRef().forEach(actorRef -> addActorLogic(transition, actorRef)); } if (importTransition.getDataRef() != null) { @@ -568,7 +549,6 @@ protected void createTransition(com.netgrif.application.engine.objects.importer. transitions.put(importTransition.getId(), transition); } - @Transactional protected void addAssignedUserPolicy(com.netgrif.application.engine.objects.importer.model.Transition importTransition, Transition transition) { if (importTransition.getAssignedUser().isCancel() != null) { transition.getAssignedUserPolicy().put("cancel", importTransition.getAssignedUser().isCancel()); @@ -578,7 +558,6 @@ protected void addAssignedUserPolicy(com.netgrif.application.engine.objects.impo } } - @Transactional protected com.netgrif.application.engine.objects.petrinet.domain.events.Event addEvent(String transitionId, com.netgrif.application.engine.objects.importer.model.Event imported) { com.netgrif.application.engine.objects.petrinet.domain.events.Event event = new com.netgrif.application.engine.objects.petrinet.domain.events.Event(); event.setImportId(imported.getId()); @@ -591,7 +570,6 @@ protected com.netgrif.application.engine.objects.petrinet.domain.events.Event ad return event; } - @Transactional protected com.netgrif.application.engine.objects.petrinet.domain.events.ProcessEvent addProcessEvent(com.netgrif.application.engine.objects.importer.model.ProcessEvent imported) { com.netgrif.application.engine.objects.petrinet.domain.events.ProcessEvent event = new com.netgrif.application.engine.objects.petrinet.domain.events.ProcessEvent(); event.setMessage(toI18NString(imported.getMessage())); @@ -603,7 +581,6 @@ protected com.netgrif.application.engine.objects.petrinet.domain.events.ProcessE return event; } - @Transactional protected com.netgrif.application.engine.objects.petrinet.domain.events.CaseEvent addCaseEvent(com.netgrif.application.engine.objects.importer.model.CaseEvent imported) { com.netgrif.application.engine.objects.petrinet.domain.events.CaseEvent event = new com.netgrif.application.engine.objects.petrinet.domain.events.CaseEvent(); event.setMessage(toI18NString(imported.getMessage())); @@ -654,7 +631,6 @@ protected List parsePhaseActions(String fieldId, EventPhaseType phase, D return actionList; } - @Transactional protected void addDefaultRole(Transition transition) { if (!net.isDefaultRoleEnabled() || isDefaultRoleReferenced(transition)) { return; @@ -666,7 +642,6 @@ protected void addDefaultRole(Transition transition) { transition.addRole(defaultRole.getStringId(), roleFactory.getPermissions(logic)); } - @Transactional protected void addAnonymousRole(Transition transition) { if (!net.isAnonymousRoleEnabled() || isAnonymousRoleReferenced(transition)) { return; @@ -677,7 +652,6 @@ protected void addAnonymousRole(Transition transition) { transition.addRole(anonymousRole.getStringId(), roleFactory.getPermissions(logic)); } - @Transactional protected void addDefaultPermissions() { if (!net.isDefaultRoleEnabled() || isDefaultRoleReferencedOnNet()) { return; @@ -690,7 +664,6 @@ protected void addDefaultPermissions() { net.addPermission(defaultRole.getStringId(), roleFactory.getProcessPermissions(logic)); } - @Transactional protected void addAnonymousPermissions() { if (!net.isAnonymousRoleEnabled() || isAnonymousRoleReferencedOnNet()) { return; @@ -702,7 +675,6 @@ protected void addAnonymousPermissions() { net.addPermission(anonymousRole.getStringId(), roleFactory.getProcessPermissions(logic)); } - @Transactional protected void addDataWithDefaultGroup(Transition transition, DataRef dataRef) throws MissingIconKeyException { DataGroup dataGroup = new com.netgrif.application.engine.adapter.spring.workflow.domain.DataGroup(); dataGroup.setImportId(transition.getImportId() + "_" + dataRef.getId() + "_" + System.currentTimeMillis()); @@ -719,7 +691,6 @@ protected void addDataWithDefaultGroup(Transition transition, DataRef dataRef) t addDataComponent(transition, dataRef); } - @Transactional protected void addDataGroup(Transition transition, com.netgrif.application.engine.objects.importer.model.DataGroup importDataGroup, int index) throws MissingIconKeyException { String alignment = importDataGroup.getAlignment() != null ? importDataGroup.getAlignment().value() : ""; DataGroup dataGroup = new com.netgrif.application.engine.adapter.spring.workflow.domain.DataGroup(); @@ -748,7 +719,6 @@ protected void addDataGroup(Transition transition, com.netgrif.application.engin } } - @Transactional protected void addToTransaction(Transition transition, TransactionRef transactionRef) { Transaction transaction = getTransaction(transactionRef.getId()); if (transaction == null) { @@ -757,7 +727,6 @@ protected void addToTransaction(Transition transition, TransactionRef transactio transaction.addTransition(transition); } - @Transactional protected void addRoleLogic(Transition transition, RoleRef roleRef) { Logic logic = roleRef.getLogic(); String roleId = getRole(roleRef.getId()).getStringId(); @@ -775,22 +744,20 @@ protected void addRoleLogic(Transition transition, RoleRef roleRef) { transition.addRole(roleId, roleFactory.getPermissions(logic)); } - @Transactional - protected void addUserLogic(Transition transition, UserRef userRef) { - Logic logic = userRef.getLogic(); - String userRefId = userRef.getId(); + protected void addActorLogic(Transition transition, ActorRef actorRef) { + Logic logic = actorRef.getLogic(); + String actorFieldId = actorRef.getId(); - if (logic == null || userRefId == null) { + if (logic == null || actorFieldId == null) { return; } logicValidator.checkConflictingAttributes(logic, logic.isAssigned(), logic.isAssign(), "assigned", "assign"); logicValidator.checkDeprecatedAttributes(logic); - transition.addUserRef(userRefId, roleFactory.getPermissions(logic)); + transition.addActorRef(actorFieldId, roleFactory.getPermissions(logic)); } - @Transactional protected void addDataLogic(Transition transition, DataRef dataRef) { Logic logic = dataRef.getLogic(); try { @@ -810,7 +777,6 @@ protected void addDataLogic(Transition transition, DataRef dataRef) { } } - @Transactional protected void addDataLayout(Transition transition, DataRef dataRef) { Layout layout = dataRef.getLayout(); try { @@ -841,7 +807,6 @@ protected void addDataLayout(Transition transition, DataRef dataRef) { } } - @Transactional protected void addDataComponent(Transition transition, DataRef dataRef) throws MissingIconKeyException { String fieldId = getField(dataRef.getId()).getStringId(); Component component = null; @@ -851,7 +816,6 @@ protected void addDataComponent(Transition transition, DataRef dataRef) throws M transition.addDataSet(fieldId, null, null, null, component); } - @Transactional protected Map buildEvents(String fieldId, List events, String transitionId) { Map parsedEvents = new HashMap<>(); @@ -907,7 +871,6 @@ protected com.netgrif.application.engine.objects.petrinet.domain.events.DataEven return dataEvent; } - @Transactional protected List buildActions(List imported, String fieldId, String transitionId) { return imported.stream() .map(action -> parseAction(fieldId, transitionId, action)) @@ -974,7 +937,6 @@ protected boolean containsParams(String definition) { return definition.matches("[\\W\\w\\s]*[\\w]*:[\\s]*[ft].[\\w]+;[\\w\\W\\s]*"); } - @Transactional protected void parseObjectIds(Action action, String fieldId, String transitionId, String definition) { try { Map ids = parseParams(definition); @@ -1030,14 +992,12 @@ protected String getFieldId(String importId) { } } - @Transactional protected void addTrigger(Transition transition, com.netgrif.application.engine.objects.importer.model.Trigger importTrigger) { Trigger trigger = triggerFactory.buildTrigger(importTrigger); transition.addTrigger(trigger); } - @Transactional protected void createPlace(com.netgrif.application.engine.objects.importer.model.Place importPlace) { Place place = new Place(); place.setImportId(importPlace.getId()); @@ -1054,7 +1014,6 @@ protected void createPlace(com.netgrif.application.engine.objects.importer.model places.put(importPlace.getId(), place); } - @Transactional protected void createRole(Role importRole) { if (importRole.getId().equals(ProcessRole.DEFAULT_ROLE)) { throw new IllegalArgumentException("Role ID '" + ProcessRole.DEFAULT_ROLE + "' is a reserved identifier, roles with this ID cannot be defined!"); @@ -1128,7 +1087,6 @@ protected Map perms.containsValue(true)) - || net.getUserRefs().values().stream().anyMatch(perms -> perms.containsValue(true))) { + || net.getActorRefs().values().stream().anyMatch(perms -> perms.containsValue(true))) { return; } @@ -1204,7 +1162,7 @@ protected void addPredefinedRolesWithDefaultPermissions() { protected PetriNet getNetByImportId(String id) { Optional net = service.findByImportId(id); - if (!net.isPresent()) { + if (net.isEmpty()) { throw new IllegalArgumentException(); } return net.get(); diff --git a/application-engine/src/main/java/com/netgrif/application/engine/importer/service/TransitionValidator.java b/application-engine/src/main/java/com/netgrif/application/engine/importer/service/TransitionValidator.java index 3389939d19c..d83ec602889 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/importer/service/TransitionValidator.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/importer/service/TransitionValidator.java @@ -12,6 +12,7 @@ public class TransitionValidator implements ITransitionValidator { @Override public void checkDeprecatedAttributes(Transition transition) { validateAttribute(transition.getUsersRef(), "usersRef"); + validateAttribute(transition.getUsersRef(), "userRef"); } @Override diff --git a/application-engine/src/main/java/com/netgrif/application/engine/pdf/generator/service/fieldbuilder/TextFieldBuilder.java b/application-engine/src/main/java/com/netgrif/application/engine/pdf/generator/service/fieldbuilder/TextFieldBuilder.java index 65376084e27..3ad0644db09 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/pdf/generator/service/fieldbuilder/TextFieldBuilder.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/pdf/generator/service/fieldbuilder/TextFieldBuilder.java @@ -1,13 +1,10 @@ package com.netgrif.application.engine.pdf.generator.service.fieldbuilder; +import com.netgrif.application.engine.objects.petrinet.domain.dataset.*; import com.netgrif.application.engine.pdf.generator.config.PdfResourceConfigurationProperties; import com.netgrif.application.engine.pdf.generator.domain.PdfField; import com.netgrif.application.engine.pdf.generator.domain.PdfTextField; import com.netgrif.application.engine.objects.petrinet.domain.DataGroup; -import com.netgrif.application.engine.objects.petrinet.domain.dataset.FileFieldValue; -import com.netgrif.application.engine.objects.petrinet.domain.dataset.FileListFieldValue; -import com.netgrif.application.engine.objects.petrinet.domain.dataset.UserFieldValue; -import com.netgrif.application.engine.objects.petrinet.domain.dataset.UserListFieldValue; import com.netgrif.application.engine.utils.DateUtils; import com.netgrif.application.engine.objects.petrinet.domain.dataset.localised.LocalisedField; import org.jsoup.Jsoup; @@ -59,11 +56,13 @@ public PdfField buildField(DataGroup dataGroup, LocalisedField field, int lastX, case FILELIST: value = field.getValue() != null ? resolveFileListNames((FileListFieldValue) field.getValue()) : ""; break; - case USER: - value = field.getValue() != null ? ((UserFieldValue) field.getValue()).getFullName() : ""; + case ACTOR: + value = field.getValue() != null ? ((ActorFieldValue) field.getValue()).getFullName() : ""; break; - case USERLIST: - value = field.getValue() != null ? ((UserListFieldValue) field.getValue()).getUserValues().stream().map(UserFieldValue::getFullName).collect(Collectors.joining(", ")) : ""; + case ACTORLIST: + value = field.getValue() != null ? ((ActorListFieldValue) field.getValue()).getActorValues().stream() + .map(ActorFieldValue::getFullName) + .collect(Collectors.joining(", ")) : ""; break; default: value = field.getValue() != null ? Jsoup.parse(field.getValue().toString()).text() : ""; diff --git a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/AbstractAuthorizationService.java b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/AbstractAuthorizationService.java index a24222a4929..4a31058c948 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/AbstractAuthorizationService.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/AbstractAuthorizationService.java @@ -3,6 +3,7 @@ import com.netgrif.application.engine.objects.auth.domain.AbstractUser; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; @@ -42,4 +43,55 @@ private void aggregatePermission(Set userProcessRoleIDs, Map.Entry findUserPermissions(Map> docPermissions, AbstractUser user) { + // TODO: impersonation + if (docPermissions == null) { + return null; + } + Map permissions = docPermissions.get(user.getStringId()); + if (user.getGroupIds().isEmpty()) { + return permissions; + } else { + // Defensive copy: do not mutate docPermissions' backing maps + permissions = (permissions == null) ? null : new HashMap<>(permissions); + Set intersectionOfActorIds = new HashSet<>(docPermissions.keySet()); + intersectionOfActorIds.retainAll(user.getGroupIds()); + + if (intersectionOfActorIds.isEmpty()) { + return permissions; + } + + if (permissions == null) { + permissions = new HashMap<>(); + } + + for (String actorId : intersectionOfActorIds) { + putPermissionIfNotAlreadyNegative(permissions, docPermissions.get(actorId)); + } + + return permissions; + } + } + + protected static void putPermissionIfNotAlreadyNegative(Map permissions, Map newPermissions) { + if (newPermissions == null) { + return; + } + for (Map.Entry entry : newPermissions.entrySet()) { + putPermissionIfNotAlreadyNegative(permissions, entry.getKey(), entry.getValue()); + } + } + + protected static void putPermissionIfNotAlreadyNegative(Map permissions, String permType, Boolean permValue) { + if (permValue == null) { + return; + } + Boolean existingPermValue = permissions.get(permType); + // Overwrite if no existing value OR existing is positive (true). + // Existing negative (false) permissions are never overwritten to preserve explicit denials. + if (existingPermValue == null || existingPermValue) { + permissions.put(permType, permValue); + } + } } diff --git a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/CaseSearchService.java b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/CaseSearchService.java index 923d17bfa54..02fd2d6a9d2 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/CaseSearchService.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/CaseSearchService.java @@ -5,8 +5,8 @@ import com.netgrif.application.engine.objects.petrinet.domain.I18nString; import com.netgrif.application.engine.objects.petrinet.domain.PetriNet; import com.netgrif.application.engine.objects.petrinet.domain.PetriNetSearch; +import com.netgrif.application.engine.objects.petrinet.domain.dataset.ActorFieldValue; import com.netgrif.application.engine.objects.petrinet.domain.dataset.FieldType; -import com.netgrif.application.engine.objects.petrinet.domain.dataset.UserFieldValue; import com.netgrif.application.engine.petrinet.service.interfaces.IPetriNetService; import com.netgrif.application.engine.petrinet.web.responsebodies.PetriNetReference; import com.netgrif.application.engine.utils.FullPageRequest; @@ -97,8 +97,8 @@ public Predicate buildQuery(Map requestQuery, LoggedUser user, L } BooleanBuilder permissionConstraints = new BooleanBuilder(buildViewRoleQueryConstraint(user)); permissionConstraints.andNot(buildNegativeViewRoleQueryConstraint(user)); - permissionConstraints.or(buildViewUserQueryConstraint(user)); - permissionConstraints.andNot(buildNegativeViewUsersQueryConstraint(user)); + permissionConstraints.or(buildViewActorQueryConstraint(user)); + permissionConstraints.andNot(buildNegativeViewActorsQueryConstraint(user)); builder.and(permissionConstraints); return builder; } @@ -109,16 +109,16 @@ protected Predicate buildViewRoleQueryConstraint(LoggedUser user) { } public Predicate viewRoleQuery(String role) { - return QCase.case$.viewUserRefs.isEmpty().and(QCase.case$.viewRoles.isEmpty()).or(QCase.case$.viewRoles.contains(role)); + return QCase.case$.viewActorRefs.isEmpty().and(QCase.case$.viewRoles.isEmpty()).or(QCase.case$.viewRoles.contains(role)); } - protected Predicate buildViewUserQueryConstraint(LoggedUser user) { - Predicate roleConstraints = viewUserQuery(user.getStringId()); - return constructPredicateTree(Collections.singletonList(roleConstraints), BooleanBuilder::or); + protected Predicate buildViewActorQueryConstraint(LoggedUser user) { + List userConstraints = getActorIdsOfUser(user).stream().map(this::viewActorQuery).toList(); + return constructPredicateTree(userConstraints, BooleanBuilder::or); } - public Predicate viewUserQuery(String userId) { - return QCase.case$.viewUserRefs.isEmpty().and(QCase.case$.viewRoles.isEmpty()).or(QCase.case$.viewUsers.contains(userId)); + public Predicate viewActorQuery(String actorId) { + return QCase.case$.viewActorRefs.isEmpty().and(QCase.case$.viewRoles.isEmpty()).or(QCase.case$.viewActors.contains(actorId)); } protected Predicate buildNegativeViewRoleQueryConstraint(LoggedUser user) { @@ -130,13 +130,13 @@ public Predicate negativeViewRoleQuery(String role) { return QCase.case$.negativeViewRoles.contains(role); } - protected Predicate buildNegativeViewUsersQueryConstraint(LoggedUser user) { - Predicate roleConstraints = negativeViewUserQuery(user.getStringId()); - return constructPredicateTree(Collections.singletonList(roleConstraints), BooleanBuilder::or); + protected Predicate buildNegativeViewActorsQueryConstraint(LoggedUser user) { + List userConstraints = getActorIdsOfUser(user).stream().map(this::negativeViewActorQuery).toList(); + return constructPredicateTree(userConstraints, BooleanBuilder::or); } - public Predicate negativeViewUserQuery(String userId) { - return QCase.case$.negativeViewUsers.contains(userId); + public Predicate negativeViewActorQuery(String actorId) { + return QCase.case$.negativeViewActors.contains(actorId); } public Predicate petriNet(Object query, LoggedUser user, Locale locale) { @@ -226,8 +226,8 @@ public Predicate data(Object data) { FieldType type = FieldType.fromString(entry.getKey()); switch (type) { - case USER: - Path valuePath = Expressions.simplePath(UserFieldValue.class, QCase.case$.dataSet.get((String) k), "value"); + case ACTOR: + Path valuePath = Expressions.simplePath(ActorFieldValue.class, QCase.case$.dataSet.get((String) k), "value"); Path idPath = Expressions.stringPath(valuePath, "id"); Expression constant = Expressions.constant(Long.valueOf("" + fieldValue)); predicates.add(Expressions.predicate(Ops.EQ, idPath, constant)); diff --git a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/DataService.java b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/DataService.java index b7eb4d4855f..b3935747879 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/DataService.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/DataService.java @@ -7,8 +7,10 @@ import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; +import com.netgrif.application.engine.auth.service.GroupService; import com.netgrif.application.engine.configuration.properties.DataConfigurationProperties; import com.netgrif.application.engine.objects.auth.domain.AbstractUser; +import com.netgrif.application.engine.objects.auth.domain.Group; import com.netgrif.application.engine.workflow.domain.EventNotExecutableException; import com.netgrif.application.engine.auth.service.UserService; import com.netgrif.application.engine.objects.petrinet.domain.I18nString; @@ -48,7 +50,6 @@ import org.apache.pdfbox.rendering.PDFRenderer; import org.apache.poi.util.IOUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.data.domain.Page; @@ -83,6 +84,9 @@ public class DataService implements IDataService { @Autowired protected UserService userService; + @Autowired + protected GroupService groupService; + @Autowired protected FieldFactory fieldFactory; @@ -748,9 +752,14 @@ public List> getImmediateFields(Task task) { } @Override - public UserFieldValue makeUserFieldValue(String id) { + public ActorFieldValue makeActorFieldValue(String id) { AbstractUser user = userService.findById(id, null); - return new UserFieldValue(user); + if (user != null) { + return new UserFieldValue(user); + } else { + Group group = groupService.findById(id); + return new GroupFieldValue(group); + } } private void updateDataset(Case useCase) { @@ -775,8 +784,8 @@ public Case applyFieldConnectedChanges(Case useCase, String fieldId) { @Override public Case applyFieldConnectedChanges(Case useCase, Field field) { switch (field.getType()) { - case USERLIST: - return workflowService.resolveUserRef(useCase); + case ACTORLIST: + return workflowService.resolveActorRef(useCase); default: return useCase; } @@ -866,16 +875,12 @@ private Object parseFieldsValues(JsonNode jsonNode, DataField dataField, String value = parseI18nString(node.get("value")); break; case "user": + case "actor": if (node.get("value") == null || node.get("value").isNull()) { value = null; break; } -// User user = new User(userService.findById(node.get("value").asLong(), true)); -// user.setPassword(null); -// user.setGroups(null); -// user.setAuthorities(null); -// user.setUserProcessRoles(null); - value = makeUserFieldValue(node.get("value").asText()); + value = makeActorFieldValue(node.get("value").asText()); break; case "number": if (node.get("value") == null || node.get("value").isNull()) { @@ -916,11 +921,12 @@ private Object parseFieldsValues(JsonNode jsonNode, DataField dataField, String value = parseListStringValues(node); break; case "userList": + case "actorList": if (node.get("value") == null) { value = null; break; } - value = makeUserListFieldValue(node); + value = makeActorListFieldValue(node); break; case "button": if (node.get("value") == null) { @@ -959,9 +965,9 @@ private Set parseMultichoiceFieldValues(ObjectNode node) { return set; } - private UserListFieldValue makeUserListFieldValue(ObjectNode nodes) { - Set userIds = new LinkedHashSet<>(parseListStringValues(nodes)); - return new UserListFieldValue(userIds.stream().map(this::makeUserFieldValue).collect(Collectors.toSet())); + private ActorListFieldValue makeActorListFieldValue(ObjectNode nodes) { + Set actorIds = new LinkedHashSet<>(parseListStringValues(nodes)); + return new ActorListFieldValue(actorIds.stream().map(this::makeActorFieldValue).collect(Collectors.toSet())); } private FileListFieldValue parseFileListFieldValue(ObjectNode node) { diff --git a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/MongoSearchService.java b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/MongoSearchService.java index 8e3259e2390..a193fc651ce 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/MongoSearchService.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/MongoSearchService.java @@ -2,6 +2,7 @@ import com.netgrif.application.engine.auth.service.UserService; import com.netgrif.application.engine.objects.auth.domain.AbstractUser; +import com.netgrif.application.engine.objects.auth.domain.LoggedUser; import com.querydsl.core.BooleanBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -249,7 +250,7 @@ protected String resolveAuthorByEmail(String email) { } protected BooleanBuilder constructPredicateTree(List elementaryPredicates, BiFunction nodeOperation) { - if (elementaryPredicates.size() == 0) + if (elementaryPredicates.isEmpty()) return new BooleanBuilder(); ArrayDeque subtrees = new ArrayDeque<>(elementaryPredicates.size() / 2 + elementaryPredicates.size() % 2); @@ -266,4 +267,10 @@ protected BooleanBuilder constructPredicateTree(List getActorIdsOfUser(LoggedUser loggedUser) { + Set actorIds = loggedUser.getGroupIds() == null ? new HashSet<>() : new HashSet<>(loggedUser.getGroupIds()); + actorIds.add(loggedUser.getStringId()); + return actorIds; + } } diff --git a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskAuthorizationService.java b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskAuthorizationService.java index 3ed448f14d1..afd92163021 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskAuthorizationService.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskAuthorizationService.java @@ -12,8 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.Arrays; -import java.util.Map; +import java.util.*; @Service public class TaskAuthorizationService extends AbstractAuthorizationService implements ITaskAuthorizationService { @@ -52,19 +51,15 @@ public Boolean userHasUserListPermission(LoggedUser loggedUser, String taskId, R @Override public Boolean userHasUserListPermission(AbstractUser user, Task task, RolePermission... permissions) { - if (task.getUserRefs() == null || task.getUserRefs().isEmpty()) + if (task.getActorRefs() == null || task.getActorRefs().isEmpty()) { return null; + } - // TODO: impersonation -// if (!task.getUsers().containsKey(user.getSelfOrImpersonated().getStringId())) { - if (!task.getUsers().containsKey(user.getStringId())) { + Map userPermissions = findUserPermissions(task, user); + if (userPermissions == null) { return null; } - // TODO: impersonation -// Map userPermissions = task.getUsers().get(user.getSelfOrImpersonated().getStringId()); - Map userPermissions = task.getUsers().get(user.getStringId()); - for (RolePermission permission : permissions) { Boolean perm = userPermissions.get(permission.toString()); if (hasRestrictedPermission(perm)) { @@ -167,4 +162,8 @@ public boolean canCallSaveFile(LoggedUser loggedUser, String taskId) { // return loggedUser.getSelfOrImpersonated().isAdmin() || isAssignee(loggedUser, taskId); return loggedUser.isAdmin() || isAssignee(loggedUser, taskId); } + + private Map findUserPermissions(Task task, AbstractUser user) { + return findUserPermissions(task.getActors(), user); + } } diff --git a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskSearchService.java b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskSearchService.java index 486dbe6f5b6..ec414b5264c 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskSearchService.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskSearchService.java @@ -12,7 +12,6 @@ import com.netgrif.application.engine.workflow.web.requestbodies.taskSearch.TaskSearchCaseRequest; import com.querydsl.core.BooleanBuilder; import com.querydsl.core.types.Predicate; -import org.bson.types.ObjectId; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -36,7 +35,7 @@ public Predicate buildQuery(List requests, LoggedUser user, L return null; } else if (!isIntersection) { singleQueries = singleQueries.stream().filter(Objects::nonNull).collect(Collectors.toList()); - if (singleQueries.size() == 0) { + if (singleQueries.isEmpty()) { // all queries result in an empty set => the entire result is an empty set return null; } @@ -45,13 +44,13 @@ public Predicate buildQuery(List requests, LoggedUser user, L BooleanBuilder builder = constructPredicateTree(singleQueries, isIntersection ? BooleanBuilder::and : BooleanBuilder::or); BooleanBuilder constraints = new BooleanBuilder(buildRolesQueryConstraint(loggedOrImpersonated)); - constraints.or(buildUserRefQueryConstraint(loggedOrImpersonated)); + constraints.or(buildActorRefQueryConstraint(loggedOrImpersonated)); builder.and(constraints); BooleanBuilder permissionConstraints = new BooleanBuilder(buildViewRoleQueryConstraint(loggedOrImpersonated)); permissionConstraints.andNot(buildNegativeViewRoleQueryConstraint(loggedOrImpersonated)); - permissionConstraints.or(buildViewUserQueryConstraint(loggedOrImpersonated)); - permissionConstraints.andNot(buildNegativeViewUsersQueryConstraint(loggedOrImpersonated)); + permissionConstraints.or(buildViewActorQueryConstraint(loggedOrImpersonated)); + permissionConstraints.andNot(buildNegativeViewActorsQueryConstraint(loggedOrImpersonated)); builder.and(permissionConstraints); return builder; } @@ -61,9 +60,9 @@ protected Predicate buildRolesQueryConstraint(LoggedUser user) { return constructPredicateTree(roleConstraints, BooleanBuilder::or); } - protected Predicate buildUserRefQueryConstraint(LoggedUser user) { - Predicate userRefConstraints = userRefQuery(user.getStringId()); - return constructPredicateTree(Collections.singletonList(userRefConstraints), BooleanBuilder::or); + protected Predicate buildActorRefQueryConstraint(LoggedUser user) { + List userConstraints = getActorIdsOfUser(user).stream().map(this::actorRefQuery).toList(); + return constructPredicateTree(userConstraints, BooleanBuilder::or); } protected Predicate buildViewRoleQueryConstraint(LoggedUser user) { @@ -72,16 +71,16 @@ protected Predicate buildViewRoleQueryConstraint(LoggedUser user) { } public Predicate viewRoleQuery(String role) { - return QTask.task.viewUserRefs.isEmpty().and(QTask.task.viewRoles.isEmpty()).or(QTask.task.viewRoles.contains(role)); + return QTask.task.viewActorRefs.isEmpty().and(QTask.task.viewRoles.isEmpty()).or(QTask.task.viewRoles.contains(role)); } - protected Predicate buildViewUserQueryConstraint(LoggedUser user) { - Predicate userConstraints = viewUsersQuery(user.getStringId()); - return constructPredicateTree(Collections.singletonList(userConstraints), BooleanBuilder::or); + protected Predicate buildViewActorQueryConstraint(LoggedUser user) { + List userConstraints = getActorIdsOfUser(user).stream().map(this::viewActorsQuery).toList(); + return constructPredicateTree(userConstraints, BooleanBuilder::or); } - public Predicate viewUsersQuery(String userId) { - return QTask.task.negativeViewRoles.isEmpty().and(QTask.task.viewUserRefs.isEmpty()).and(QTask.task.viewRoles.isEmpty()).or(QTask.task.viewUsers.contains(userId)); + public Predicate viewActorsQuery(String actorId) { + return QTask.task.negativeViewRoles.isEmpty().and(QTask.task.viewActorRefs.isEmpty()).and(QTask.task.viewRoles.isEmpty()).or(QTask.task.viewActors.contains(actorId)); } protected Predicate buildNegativeViewRoleQueryConstraint(LoggedUser user) { @@ -93,13 +92,13 @@ public Predicate negativeViewRoleQuery(String role) { return QTask.task.negativeViewRoles.contains(role); } - protected Predicate buildNegativeViewUsersQueryConstraint(LoggedUser user) { - Predicate userConstraints = negativeViewUsersQuery(user.getStringId()); - return constructPredicateTree(Collections.singletonList(userConstraints), BooleanBuilder::or); + protected Predicate buildNegativeViewActorsQueryConstraint(LoggedUser user) { + List userConstraints = getActorIdsOfUser(user).stream().map(this::negativeViewActorsQuery).toList(); + return constructPredicateTree(userConstraints, BooleanBuilder::or); } - public Predicate negativeViewUsersQuery(String userId) { - return QTask.task.negativeViewUsers.contains(userId); + public Predicate negativeViewActorsQuery(String actorId) { + return QTask.task.negativeViewActors.contains(actorId); } @@ -155,8 +154,8 @@ public Predicate stringIdQuery(String id) { return QTask.task._id.eq(new ProcessResourceId(id)); } - public Predicate userRefQuery(String userId) { - return QTask.task.users.containsKey(userId); + public Predicate actorRefQuery(String actorId) { + return QTask.task.actors.containsKey(actorId); } private void buildCaseQuery(TaskSearchRequest request, BooleanBuilder query) { @@ -278,7 +277,7 @@ public boolean buildGroupQuery(TaskSearchRequest request, LoggedUser user, Local PetriNetSearch processQuery = new PetriNetSearch(); processQuery.setGroup(request.group); List groupProcesses = this.petriNetService.search(processQuery, user, new FullPageRequest(), locale).getContent(); - if (groupProcesses.size() == 0) + if (groupProcesses.isEmpty()) return true; query.and( diff --git a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java index ac21c61ae5f..c55ac69f52f 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java @@ -1,8 +1,12 @@ package com.netgrif.application.engine.workflow.service; import com.google.common.collect.Ordering; +import com.netgrif.application.engine.auth.service.GroupService; import com.netgrif.application.engine.objects.auth.domain.AbstractUser; import com.netgrif.application.engine.objects.auth.domain.ActorTransformer; +import com.netgrif.application.engine.objects.petrinet.domain.dataset.ActorFieldValue; +import com.netgrif.application.engine.objects.petrinet.domain.dataset.ActorListFieldValue; +import com.netgrif.application.engine.objects.petrinet.domain.roles.RolePermission; import com.netgrif.application.engine.workflow.domain.TaskNotFoundException; import com.netgrif.application.engine.objects.auth.domain.LoggedUser; import com.netgrif.application.engine.auth.service.UserService; @@ -14,8 +18,6 @@ import com.netgrif.application.engine.objects.petrinet.domain.arcs.ArcOrderComparator; import com.netgrif.application.engine.objects.petrinet.domain.arcs.ResetArc; import com.netgrif.application.engine.objects.petrinet.domain.dataset.Field; -import com.netgrif.application.engine.objects.petrinet.domain.dataset.UserFieldValue; -import com.netgrif.application.engine.objects.petrinet.domain.dataset.UserListFieldValue; import com.netgrif.application.engine.objects.petrinet.domain.events.EventPhase; import com.netgrif.application.engine.objects.petrinet.domain.events.EventType; import com.netgrif.application.engine.objects.petrinet.domain.roles.ProcessRole; @@ -72,6 +74,9 @@ public class TaskService implements ITaskService { @Autowired protected UserService userService; + @Autowired + protected GroupService groupService; + @Autowired protected MongoTemplate mongoTemplate; @@ -524,7 +529,7 @@ public void reloadTasks(Case useCase) { } save(newTasks); delete(disabledTasks, useCase); - useCase = workflowService.resolveUserRef(useCase); + useCase = workflowService.resolveActorRef(useCase); for (Task task : newTasks) { executeIfAutoTrigger(useCase, net, task); @@ -798,35 +803,49 @@ public List save(List tasks) { } @Override - public void resolveUserRef(Case useCase) { + public void resolveActorRef(Case useCase) { useCase.getTasks().forEach(taskPair -> { Optional taskOptional = findOptionalById(taskPair.getTask()); - taskOptional.ifPresent(task -> resolveUserRef(task, useCase)); + taskOptional.ifPresent(task -> resolveActorRef(task, useCase)); }); } @Override - public Task resolveUserRef(Task task, Case useCase) { - task.getUsers().clear(); - task.getNegativeViewUsers().clear(); - task.getUserRefs().forEach((id, permission) -> { - List userIds = getExistingUsers((UserListFieldValue) useCase.getDataSet().get(id).getValue()); - if (userIds != null && userIds.size() != 0 && permission.containsKey("view") && !permission.get("view")) { - task.getNegativeViewUsers().addAll(userIds); - } else if (userIds != null && userIds.size() != 0) { - task.addUsers(new HashSet<>(userIds), permission); + public Task resolveActorRef(Task task, Case useCase) { + task.getActors().clear(); + task.getNegativeViewActors().clear(); + task.getActorRefs().forEach((actorFieldId, permission) -> { + List actorIds = getExistingActors((ActorListFieldValue) useCase.getDataSet().get(actorFieldId).getValue()); + if (actorIds != null && !actorIds.isEmpty()) { + task.addActors(new HashSet<>(actorIds), permission); + if (permission.containsKey(RolePermission.VIEW.getValue()) && !permission.get(RolePermission.VIEW.getValue())) { + task.getNegativeViewActors().addAll(actorIds); + } } }); - task.resolveViewUsers(); + task.resolveViewActors(); return taskRepository.save(task); } - private List getExistingUsers(UserListFieldValue userListValue) { - if (userListValue == null) + private List getExistingActors(ActorListFieldValue actorListFieldValue) { + if (actorListFieldValue == null) { return null; - return userListValue.getUserValues().stream().map(UserFieldValue::getId) - .filter(id -> userService.findById(id, null) != null) + } + return actorListFieldValue.getActorValues().stream() + .map(ActorFieldValue::getId) + .filter(actorId -> { + AbstractUser user = userService.findById(actorId, null); + if (user != null) { + return true; + } + try { + groupService.findById(actorId); + return true; + } catch (IllegalArgumentException ignored) { + return false; + } + }) .collect(Collectors.toList()); } @@ -848,13 +867,13 @@ private Task createFromTransition(Transition transition, Case useCase) { .finishPolicy(transition.getFinishPolicy()) .assignedUserPolicy(new HashMap<>(transition.getAssignedUserPolicy())) .roles(new HashMap<>()) - .userRefs(new HashMap<>()) - .users(new HashMap<>()) + .actorRefs(new HashMap<>()) + .actors(new HashMap<>()) .viewRoles(new LinkedList<>()) - .viewUserRefs(new LinkedList<>()) - .viewUsers(new LinkedList<>()) + .viewActorRefs(new LinkedList<>()) + .viewActors(new LinkedList<>()) .negativeViewRoles(new LinkedList<>()) - .negativeViewUsers(new LinkedList<>()) + .negativeViewActors(new LinkedList<>()) .triggers(new LinkedList<>()) .eventTitles(new HashMap<>()) .build(); @@ -878,11 +897,11 @@ private Task createFromTransition(Transition transition, Case useCase) { } transition.getNegativeViewRoles().forEach(task::addNegativeViewRole); - for (Map.Entry> entry : transition.getUserRefs().entrySet()) { - task.addUserRef(entry.getKey(), entry.getValue()); + for (Map.Entry> entry : transition.getActorRefs().entrySet()) { + task.addActorRef(entry.getKey(), entry.getValue()); } task.resolveViewRoles(); - task.resolveViewUserRefs(); + task.resolveViewActorRefs(); Transaction transaction = useCase.getPetriNet().getTransactionByTransition(transition); if (transaction != null) { diff --git a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/WorkflowAuthorizationService.java b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/WorkflowAuthorizationService.java index 707e33353dc..8b714228ec2 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/WorkflowAuthorizationService.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/WorkflowAuthorizationService.java @@ -12,8 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.Arrays; -import java.util.Map; +import java.util.*; @Service public class WorkflowAuthorizationService extends AbstractAuthorizationService implements IWorkflowAuthorizationService { @@ -61,18 +60,15 @@ public Boolean userHasAtLeastOneRolePermission(AbstractUser user, PetriNet net, @Override public Boolean userHasUserListPermission(AbstractUser user, Case useCase, ProcessRolePermission... permissions) { - if (useCase.getUserRefs() == null || useCase.getUserRefs().isEmpty()) + if (useCase.getActorRefs() == null || useCase.getActorRefs().isEmpty()) { return null; + } - // TODO: impersonation -// if (!useCase.getUsers().containsKey(user.getSelfOrImpersonated().getStringId())) { - if (!useCase.getUsers().containsKey(user.getStringId())) { + Map userPermissions = findUserPermissions(useCase, user); + if (userPermissions == null) { return null; } - // TODO: impersonation - Map userPermissions = useCase.getUsers().get(user.getStringId()); - for (ProcessRolePermission permission : permissions) { Boolean perm = userPermissions.get(permission.toString()); if (hasRestrictedPermission(perm)) { @@ -81,4 +77,8 @@ public Boolean userHasUserListPermission(AbstractUser user, Case useCase, Proces } return Arrays.stream(permissions).anyMatch(permission -> hasPermission(userPermissions.get(permission.toString()))); } + + private Map findUserPermissions(Case useCase, AbstractUser user) { + return findUserPermissions(useCase.getActors(), user); + } } diff --git a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/WorkflowService.java b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/WorkflowService.java index 9fdb0e83f11..f4d2c4bc275 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/WorkflowService.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/WorkflowService.java @@ -1,7 +1,11 @@ package com.netgrif.application.engine.workflow.service; import com.google.common.collect.Ordering; +import com.netgrif.application.engine.auth.service.GroupService; +import com.netgrif.application.engine.objects.auth.domain.AbstractUser; import com.netgrif.application.engine.objects.auth.domain.ActorTransformer; +import com.netgrif.application.engine.objects.petrinet.domain.dataset.*; +import com.netgrif.application.engine.objects.petrinet.domain.roles.ProcessRolePermission; import com.netgrif.application.engine.objects.workflow.domain.Case; import com.netgrif.application.engine.objects.auth.domain.LoggedUser; import com.netgrif.application.engine.auth.service.UserService; @@ -15,10 +19,6 @@ import com.netgrif.application.engine.importer.service.FieldFactory; import com.netgrif.application.engine.objects.petrinet.domain.I18nString; import com.netgrif.application.engine.objects.petrinet.domain.PetriNet; -import com.netgrif.application.engine.objects.petrinet.domain.dataset.Field; -import com.netgrif.application.engine.objects.petrinet.domain.dataset.TaskField; -import com.netgrif.application.engine.objects.petrinet.domain.dataset.UserFieldValue; -import com.netgrif.application.engine.objects.petrinet.domain.dataset.UserListFieldValue; import com.netgrif.application.engine.petrinet.domain.dataset.logic.action.FieldActionsRunner; import com.netgrif.application.engine.objects.petrinet.domain.events.CaseEventType; import com.netgrif.application.engine.objects.petrinet.domain.events.EventPhase; @@ -96,6 +96,9 @@ public class WorkflowService implements IWorkflowService { @Autowired protected UserService userService; + @Autowired + protected GroupService groupService; + @Autowired protected InitValueExpressionEvaluator initValueExpressionEvaluator; @@ -227,33 +230,45 @@ public long count(Map request, LoggedUser user, Locale locale) { } @Override - public Case resolveUserRef(Case useCase) { - useCase.getUsers().clear(); - useCase.getNegativeViewUsers().clear(); - useCase.getUserRefs().forEach((id, permission) -> { - resolveUserRefPermissions(useCase, id, permission); + public Case resolveActorRef(Case useCase) { + useCase.getActors().clear(); + useCase.getNegativeViewActors().clear(); + useCase.getActorRefs().forEach((actorFieldId, permission) -> { + resolveActorRefPermissions(useCase, actorFieldId, permission); }); - useCase.resolveViewUsers(); - taskService.resolveUserRef(useCase); + useCase.resolveViewActors(); + taskService.resolveActorRef(useCase); return save(useCase); } - private void resolveUserRefPermissions(Case useCase, String userListId, Map permission) { - List userIds = getExistingUsers((UserListFieldValue) useCase.getDataSet().get(userListId).getValue()); - if (userIds != null && userIds.size() != 0) { - if (permission.containsKey("view") && !permission.get("view")) { - useCase.getNegativeViewUsers().addAll(userIds); - } else { - useCase.addUsers(new HashSet<>(userIds), permission); + private void resolveActorRefPermissions(Case useCase, String actorFieldId, Map permission) { + List actorIds = getExistingActors((ActorListFieldValue) useCase.getDataSet().get(actorFieldId).getValue()); + if (actorIds != null && !actorIds.isEmpty()) { + useCase.addActors(new HashSet<>(actorIds), permission); + if (permission.containsKey(ProcessRolePermission.VIEW.getValue()) && !permission.get(ProcessRolePermission.VIEW.getValue())) { + useCase.getNegativeViewActors().addAll(actorIds); } } } - private List getExistingUsers(UserListFieldValue userListValue) { - if (userListValue == null) + private List getExistingActors(ActorListFieldValue actorListFieldValue) { + if (actorListFieldValue == null) { return null; - return userListValue.getUserValues().stream().map(UserFieldValue::getId) - .filter(id -> userService.findById(id, null) != null) + } + return actorListFieldValue.getActorValues().stream() + .map(ActorFieldValue::getId) + .filter(actorId -> { + AbstractUser user = userService.findById(actorId, null); + if (user != null) { + return true; + } + try { + groupService.findById(actorId); + return true; + } catch (IllegalArgumentException ignored) { + return false; + } + }) .collect(Collectors.toList()); } diff --git a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/interfaces/IDataService.java b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/interfaces/IDataService.java index 4426b3500ad..0965e4905f5 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/interfaces/IDataService.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/interfaces/IDataService.java @@ -87,7 +87,7 @@ public interface IDataService { List> getImmediateFields(Task task); - UserFieldValue makeUserFieldValue(String id); + ActorFieldValue makeActorFieldValue(String id); Case applyFieldConnectedChanges(Case useCase, String fieldId); diff --git a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/interfaces/ITaskService.java b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/interfaces/ITaskService.java index e8bf1f73edd..61d9abe703b 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/interfaces/ITaskService.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/interfaces/ITaskService.java @@ -104,9 +104,9 @@ public interface ITaskService { DelegateTaskEventOutcome delegateTask(LoggedUser loggedUser, String delegatedId, String taskId, Map params) throws TransitionNotExecutableException; - void resolveUserRef(Case useCase); + void resolveActorRef(Case useCase); - Task resolveUserRef(Task task, Case useCase); + Task resolveActorRef(Task task, Case useCase); void delete(List tasks, Case useCase); diff --git a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/interfaces/IWorkflowService.java b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/interfaces/IWorkflowService.java index 74d8eab44a2..131b988dcab 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/interfaces/IWorkflowService.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/workflow/service/interfaces/IWorkflowService.java @@ -27,7 +27,7 @@ public interface IWorkflowService { Page getAll(Pageable pageable); - Case resolveUserRef(Case useCase); + Case resolveActorRef(Case useCase); CreateCaseEventOutcome createCase(String netId, String title, String color, LoggedUser user, Locale locale, Map params); diff --git a/application-engine/src/main/java/com/netgrif/application/engine/workflow/web/responsebodies/Task.java b/application-engine/src/main/java/com/netgrif/application/engine/workflow/web/responsebodies/Task.java index b226b7e8895..f01584c4965 100644 --- a/application-engine/src/main/java/com/netgrif/application/engine/workflow/web/responsebodies/Task.java +++ b/application-engine/src/main/java/com/netgrif/application/engine/workflow/web/responsebodies/Task.java @@ -88,7 +88,7 @@ public Task(com.netgrif.application.engine.objects.workflow.domain.Task task, Lo this.userId = task.getUser() != null ? task.getUser().getStringId() : null; this.userRealmId = task.getUser() != null ? task.getUser().getRealmId() : null; this.roles = task.getRoles(); - this.users = task.getUsers(); + this.users = task.getActors(); this.startDate = task.getStartDate(); this.finishDate = task.getFinishDate(); this.finishedBy = task.getFinishedBy(); diff --git a/application-engine/src/main/resources/petriNets/engine-processes/impersonation_config.xml b/application-engine/src/main/resources/petriNets/engine-processes/impersonation_config.xml index 65128115668..56730468963 100644 --- a/application-engine/src/main/resources/petriNets/engine-processes/impersonation_config.xml +++ b/application-engine/src/main/resources/petriNets/engine-processes/impersonation_config.xml @@ -77,13 +77,13 @@ true - + config_owner true true - + create @@ -93,11 +93,11 @@ impersonated: f.impersonated, config_owner: f.config_owner; - def user = userService.loggedOrSystem - change impersonated value { new com.netgrif.application.engine.objects.petrinet.domain.dataset.UserFieldValue(user.stringId, user.firstName, user.lastName, user.username) } - change impersonated_email value { user.username } + def user = userService.loggedOrSystem + change impersonated value { new com.netgrif.application.engine.objects.petrinet.domain.dataset.UserFieldValue(user.stringId, user.firstName, user.lastName, user.username) } + change impersonated_email value { user.username } - change config_owner value { new com.netgrif.application.engine.objects.petrinet.domain.dataset.UserListFieldValue([impersonated.value]) } + change config_owner value { new com.netgrif.application.engine.objects.petrinet.domain.dataset.ActorListFieldValue([impersonated.value]) } @@ -147,7 +147,7 @@ - + config_owner </data> @@ -193,7 +193,7 @@ </actions> </event> </data> - <data type="user" immediate="true"> + <data type="actor" immediate="true"> <id>impersonated</id> <title name="impersonated">User to impersonate @@ -363,7 +363,7 @@ true - + config_owner true @@ -372,7 +372,7 @@ true true - + t2_0 4 @@ -546,7 +546,7 @@ true - + config_owner true @@ -555,7 +555,7 @@ true true - + assign @@ -602,7 +602,7 @@ true - + config_owner true @@ -611,7 +611,7 @@ true true - + t4_0 diff --git a/application-engine/src/main/resources/petriNets/engine-processes/org_group.xml b/application-engine/src/main/resources/petriNets/engine-processes/org_group.xml index e9accb1fbc9..1168322a352 100644 --- a/application-engine/src/main/resources/petriNets/engine-processes/org_group.xml +++ b/application-engine/src/main/resources/petriNets/engine-processes/org_group.xml @@ -33,7 +33,7 @@ Enter group ID ID of organization group - + author Group Author @@ -54,7 +54,7 @@ workflowService.save(useCase) - + user_selection Select user No user selected diff --git a/application-engine/src/test/groovy/com/netgrif/application/engine/auth/TaskAuthorizationServiceTest.groovy b/application-engine/src/test/groovy/com/netgrif/application/engine/auth/TaskAuthorizationServiceTest.groovy index 93934b83367..583d5ceb798 100644 --- a/application-engine/src/test/groovy/com/netgrif/application/engine/auth/TaskAuthorizationServiceTest.groovy +++ b/application-engine/src/test/groovy/com/netgrif/application/engine/auth/TaskAuthorizationServiceTest.groovy @@ -1,5 +1,6 @@ package com.netgrif.application.engine.auth +import com.netgrif.application.engine.auth.service.GroupService import com.netgrif.application.engine.auth.service.UserService import com.netgrif.application.engine.objects.auth.domain.AbstractUser import com.netgrif.application.engine.objects.auth.domain.ActorTransformer @@ -91,6 +92,9 @@ class TaskAuthorizationServiceTest { @Autowired private IWorkflowService workflowService + @Autowired + private GroupService groupService + @Autowired TestHelper testHelper @@ -125,7 +129,7 @@ class TaskAuthorizationServiceTest { // [auths.get("user")] as Authority[], // [processRoles.find({ it.name.equals("role") })] as ProcessRole[]) // -// userId = user.getStringId() +// actorId = user.getStringId() // this.userWithRoleAuth = new UsernamePasswordAuthenticationToken(USER_WITH_ROLE_EMAIL, "password") // // importHelper.createUser(new User(firstName: "NoRole", lastName: "User", email: USER_WITHOUT_ROLE_EMAIL, password: "password", state: UserState.ACTIVE), @@ -343,41 +347,57 @@ class TaskAuthorizationServiceTest { } @Test - void testCanAssignWithUsersRef() { + void testCanAssignWithActorsRef() { Case case_ = workflowService.createCase(netWithUserRefs.getStringId(), "Test assign", "", ActorTransformer.toLoggedUser(testUser)).getCase() String taskId = (new ArrayList<>(case_.getTasks())).get(0).task case_ = dataService.setData(taskId, ImportHelper.populateDataset([ "assign_pos_ul": [ "value": [testUser.stringId], - "type": "userList" + "type": "actorList" + ] + ] as Map)).getCase() + + assert taskAuthorizationService.canCallAssign(ActorTransformer.toLoggedUser(testUser), taskId) + + case_ = dataService.setData(taskId, ImportHelper.populateDataset([ + "assign_pos_ul": [ + "value": [groupService.getDefaultSystemGroup().stringId], + "type": "actorList" ] ] as Map)).getCase() - workflowService.save(case_) - sleep(4000) assert taskAuthorizationService.canCallAssign(ActorTransformer.toLoggedUser(testUser), taskId) + workflowService.deleteCase(case_.stringId) } @Test - void testCannotAssignWithUsersRef() { + void testCannotAssignWithActorsRef() { Case case_ = workflowService.createCase(netWithUserRefs.getStringId(), "Test assign", "", ActorTransformer.toLoggedUser(testUser)).getCase() String taskId = (new ArrayList<>(case_.getTasks())).get(0).task case_ = dataService.setData(taskId, ImportHelper.populateDataset([ "assign_neg_ul": [ "value": [testUser.stringId], - "type": "userList" + "type": "actorList" + ] + ] as Map)).getCase() + + assert !taskAuthorizationService.canCallAssign(ActorTransformer.toLoggedUser(testUser), taskId) + + case_ = dataService.setData(taskId, ImportHelper.populateDataset([ + "assign_neg_ul": [ + "value": [groupService.getDefaultSystemGroup().stringId], + "type": "actorList" ] ] as Map)).getCase() - workflowService.save(case_) - sleep(4000) assert !taskAuthorizationService.canCallAssign(ActorTransformer.toLoggedUser(testUser), taskId) + workflowService.deleteCase(case_.stringId) } @Test - void testCanAssignWithNegRoleAndPosUsersRef() { + void testCanAssignWithNegRoleAndPosActorsRef() { ProcessRole positiveRole = this.netWithUserRefs.getRoles().values().find(v -> v.getImportId() == "assign_pos_role") userService.addRole(testUser, positiveRole.get_id()) Case case_ = workflowService.createCase(netWithUserRefs.getStringId(), "Test assign", "", ActorTransformer.toLoggedUser(testUser)).getCase() @@ -385,13 +405,21 @@ class TaskAuthorizationServiceTest { case_ = dataService.setData(taskId, ImportHelper.populateDataset([ "assign_pos_ul": [ "value": [testUser.stringId], - "type": "userList" + "type": "actorList" ] ] as Map)).getCase() - workflowService.save(case_) - sleep(4000) assert taskAuthorizationService.canCallAssign(ActorTransformer.toLoggedUser(testUser), taskId) + + case_ = dataService.setData(taskId, ImportHelper.populateDataset([ + "assign_pos_ul": [ + "value": [groupService.getDefaultSystemGroup().stringId], + "type": "actorList" + ] + ] as Map)).getCase() + + assert taskAuthorizationService.canCallAssign(ActorTransformer.toLoggedUser(testUser), taskId) + userService.removeRole(testUser, positiveRole.get_id()) workflowService.deleteCase(case_.stringId) } @@ -423,43 +451,57 @@ class TaskAuthorizationServiceTest { } @Test - void testCanFinishWithUsersRef() { + void testCanFinishWithActorsRef() { Case case_ = workflowService.createCase(netWithUserRefs.getStringId(), "Test Finish", "", ActorTransformer.toLoggedUser(testUser)).getCase() String taskId = (new ArrayList<>(case_.getTasks())).get(0).task case_ = dataService.setData(taskId, ImportHelper.populateDataset([ "finish_pos_ul": [ "value": [testUser.stringId], - "type": "userList" + "type": "actorList" ] ] as Map)).getCase() - workflowService.save(case_) - sleep(4000) taskService.assignTask(ActorTransformer.toLoggedUser(testUser), taskId) assert taskAuthorizationService.canCallFinish(ActorTransformer.toLoggedUser(testUser), taskId) + + case_ = dataService.setData(taskId, ImportHelper.populateDataset([ + "finish_pos_ul": [ + "value": [groupService.getDefaultSystemGroup().stringId], + "type": "actorList" + ] + ] as Map)).getCase() + assert taskAuthorizationService.canCallFinish(ActorTransformer.toLoggedUser(testUser), taskId) + workflowService.deleteCase(case_.stringId) } @Test - void testCannotFinishWithUsersRef() { + void testCannotFinishWithActorsRef() { Case case_ = workflowService.createCase(netWithUserRefs.getStringId(), "Test Finish", "", ActorTransformer.toLoggedUser(testUser)).getCase() String taskId = (new ArrayList<>(case_.getTasks())).get(0).task case_ = dataService.setData(taskId, ImportHelper.populateDataset([ "finish_neg_ul": [ "value": [testUser.stringId], - "type": "userList" + "type": "actorList" ] ] as Map)).getCase() - workflowService.save(case_) - sleep(4000) taskService.assignTask(ActorTransformer.toLoggedUser(testUser), taskId) assert !taskAuthorizationService.canCallFinish(ActorTransformer.toLoggedUser(testUser), taskId) + + case_ = dataService.setData(taskId, ImportHelper.populateDataset([ + "finish_neg_ul": [ + "value": [groupService.getDefaultSystemGroup().stringId], + "type": "actorList" + ] + ] as Map)).getCase() + assert !taskAuthorizationService.canCallFinish(ActorTransformer.toLoggedUser(testUser), taskId) + workflowService.deleteCase(case_.stringId) } @Test - void testCanFinishWithNegRoleAndPosUsersRef() { + void testCanFinishWithNegRoleAndPosActorsRef() { ProcessRole positiveRole = this.netWithUserRefs.getRoles().values().find(v -> v.getImportId() == "finish_pos_role") userService.addRole(testUser, positiveRole.get_id()) Case case_ = workflowService.createCase(netWithUserRefs.getStringId(), "Test Finish", "", ActorTransformer.toLoggedUser(testUser)).getCase() @@ -467,14 +509,21 @@ class TaskAuthorizationServiceTest { case_ = dataService.setData(taskId, ImportHelper.populateDataset([ "finish_pos_ul": [ "value": [testUser.stringId], - "type": "userList" + "type": "actorList" ] ] as Map)).getCase() - workflowService.save(case_) - sleep(4000) taskService.assignTask(ActorTransformer.toLoggedUser(testUser), taskId) assert taskAuthorizationService.canCallFinish(ActorTransformer.toLoggedUser(testUser), taskId) + + case_ = dataService.setData(taskId, ImportHelper.populateDataset([ + "finish_pos_ul": [ + "value": [groupService.getDefaultSystemGroup().stringId], + "type": "actorList" + ] + ] as Map)).getCase() + assert taskAuthorizationService.canCallFinish(ActorTransformer.toLoggedUser(testUser), taskId) + userService.removeRole(testUser, positiveRole.get_id()) workflowService.deleteCase(case_.stringId) } diff --git a/application-engine/src/test/groovy/com/netgrif/application/engine/auth/WorkflowAuthorizationServiceTest.groovy b/application-engine/src/test/groovy/com/netgrif/application/engine/auth/WorkflowAuthorizationServiceTest.groovy index 6191dd7946e..3df4f1df38c 100644 --- a/application-engine/src/test/groovy/com/netgrif/application/engine/auth/WorkflowAuthorizationServiceTest.groovy +++ b/application-engine/src/test/groovy/com/netgrif/application/engine/auth/WorkflowAuthorizationServiceTest.groovy @@ -1,6 +1,7 @@ package com.netgrif.application.engine.auth import com.netgrif.application.engine.TestHelper +import com.netgrif.application.engine.auth.service.GroupService import com.netgrif.application.engine.objects.auth.domain.AbstractUser import com.netgrif.application.engine.objects.auth.domain.ActorTransformer import com.netgrif.application.engine.objects.auth.domain.Authority @@ -73,6 +74,9 @@ class WorkflowAuthorizationServiceTest { @Autowired private IDataService dataService + @Autowired + private GroupService groupService + @Autowired TestHelper testHelper @@ -219,7 +223,7 @@ class WorkflowAuthorizationServiceTest { @Test - void testCanCallDeleteRoleFalseUserRefTrue() { + void testCanCallDeleteRoleFalseActorRefTrue() { ProcessRole posDeleteRole = this.netWithUserRefs.getRoles().values().find(v -> v.getImportId() == "delete_pos_role") ProcessRole negDeleteRole = this.netWithUserRefs.getRoles().values().find(v -> v.getImportId() == "delete_neg_role") @@ -231,10 +235,18 @@ class WorkflowAuthorizationServiceTest { case_ = dataService.setData(taskId, ImportHelper.populateDataset([ "pos_user_list": [ "value": [testUser.stringId], - "type": "userList" + "type": "actorList" + ] + ] as Map)).getCase() + + assert workflowAuthorizationService.canCallDelete(ActorTransformer.toLoggedUser(testUser), case_.getStringId()) + + case_ = dataService.setData(taskId, ImportHelper.populateDataset([ + "pos_user_list": [ + "value": [groupService.getDefaultSystemGroup().stringId], + "type": "actorList" ] ] as Map)).getCase() - workflowService.save(case_) assert workflowAuthorizationService.canCallDelete(ActorTransformer.toLoggedUser(testUser), case_.getStringId()) @@ -243,7 +255,7 @@ class WorkflowAuthorizationServiceTest { } @Test - void testCanCallDeleteRoleFalseUserRefTrueUserRefFalse() { + void testCanCallDeleteRoleFalseActorRefTrueActorRefFalse() { ProcessRole posDeleteRole = this.netWithUserRefs.getRoles().values().find(v -> v.getImportId() == "delete_pos_role") ProcessRole negDeleteRole = this.netWithUserRefs.getRoles().values().find(v -> v.getImportId() == "delete_neg_role") @@ -255,14 +267,13 @@ class WorkflowAuthorizationServiceTest { case_ = dataService.setData(taskId, ImportHelper.populateDataset([ "pos_user_list": [ "value": [testUser.stringId], - "type": "userList" + "type": "actorList" ], "neg_user_list": [ - "value": [testUser.stringId], - "type": "userList" + "value": [groupService.getDefaultSystemGroup().stringId], + "type": "actorList" ] ] as Map)).getCase() - workflowService.save(case_) assert !workflowAuthorizationService.canCallDelete(ActorTransformer.toLoggedUser(testUser), case_.getStringId()) diff --git a/application-engine/src/test/groovy/com/netgrif/application/engine/elastic/DataSearchRequestTest.groovy b/application-engine/src/test/groovy/com/netgrif/application/engine/elastic/DataSearchRequestTest.groovy index 0f88aadaf8a..c5b27baafb3 100644 --- a/application-engine/src/test/groovy/com/netgrif/application/engine/elastic/DataSearchRequestTest.groovy +++ b/application-engine/src/test/groovy/com/netgrif/application/engine/elastic/DataSearchRequestTest.groovy @@ -2,6 +2,7 @@ package com.netgrif.application.engine.elastic import com.netgrif.application.engine.MockService import com.netgrif.application.engine.TestHelper +import com.netgrif.application.engine.auth.service.GroupService import com.netgrif.application.engine.auth.service.UserService import com.netgrif.application.engine.elastic.domain.ElasticCaseRepository import com.netgrif.application.engine.elastic.service.interfaces.IElasticCaseService @@ -12,7 +13,7 @@ import com.netgrif.application.engine.objects.petrinet.domain.dataset.ChoiceFiel import com.netgrif.application.engine.objects.petrinet.domain.dataset.FileFieldValue import com.netgrif.application.engine.objects.petrinet.domain.dataset.FileListFieldValue import com.netgrif.application.engine.objects.petrinet.domain.dataset.UserFieldValue -import com.netgrif.application.engine.objects.petrinet.domain.dataset.UserListFieldValue +import com.netgrif.application.engine.objects.petrinet.domain.dataset.ActorListFieldValue import com.netgrif.application.engine.petrinet.service.interfaces.IPetriNetService import com.netgrif.application.engine.startup.ImportHelper import com.netgrif.application.engine.startup.runner.SuperCreatorRunner @@ -87,6 +88,9 @@ class DataSearchRequestTest { @Autowired private IDataService dataService + @Autowired + private GroupService groupService + @Autowired private TestHelper testHelper @@ -123,7 +127,9 @@ class DataSearchRequestTest { _case.dataSet["multichoice_map"].value = ["alice", "bob"].toSet() _case.dataSet["file"].value = FileFieldValue.fromString("singlefile.txt") _case.dataSet["fileList"].value = FileListFieldValue.fromString("multifile1.txt,multifile2.pdf") - _case.dataSet["userList"].value = new UserListFieldValue([dataService.makeUserFieldValue(testUser1.stringId), dataService.makeUserFieldValue(testUser2.stringId)]) + _case.dataSet["userList"].value = new ActorListFieldValue([dataService.makeActorFieldValue(testUser1.stringId), + dataService.makeActorFieldValue(testUser2.stringId), + dataService.makeActorFieldValue(groupService.getDefaultSystemGroup().stringId)]) _case.dataSet["i18n_text"].value.defaultValue = "Modified i18n text value" _case.dataSet["i18n_divider"].value.defaultValue = "Modified i18n divider value" workflowService.save(_case) @@ -147,7 +153,7 @@ class DataSearchRequestTest { new AbstractMap.SimpleEntry("user" as String, "${testUser1.name} ${testUser1.username}" as String), new AbstractMap.SimpleEntry("user.usernameValue.keyword" as String, "${testUser1.username}" as String), new AbstractMap.SimpleEntry("user.fullNameValue.keyword" as String, "${testUser1.name}" as String), - new AbstractMap.SimpleEntry("user.userIdValue" as String, "${testUser1.getStringId()}" as String), + new AbstractMap.SimpleEntry("user.actorIdValue" as String, "${testUser1.getStringId()}" as String), new AbstractMap.SimpleEntry("date.timestampValue" as String, "${Timestamp.valueOf(LocalDateTime.of(date, LocalTime.MIDNIGHT)).getTime()}" as String), new AbstractMap.SimpleEntry("datetime.timestampValue" as String, "${Timestamp.valueOf(date.atTime(13, 37)).getTime()}" as String), new AbstractMap.SimpleEntry("enumeration" as String, "Alice" as String), @@ -188,12 +194,15 @@ class DataSearchRequestTest { new AbstractMap.SimpleEntry("fileList.fileExtensionValue.keyword" as String, "pdf" as String), new AbstractMap.SimpleEntry("userList" as String, "${testUser1.name} ${testUser1.email}" as String), new AbstractMap.SimpleEntry("userList" as String, "${testUser2.name} ${testUser2.email}" as String), + new AbstractMap.SimpleEntry("userList" as String, "${groupService.getDefaultSystemGroup().getFullName()}" as String), new AbstractMap.SimpleEntry("userList.usernameValue.keyword" as String, "${testUser1.username}" as String), new AbstractMap.SimpleEntry("userList.usernameValue.keyword" as String, "${testUser2.username}" as String), new AbstractMap.SimpleEntry("userList.fullNameValue.keyword" as String, "${testUser1.name}" as String), new AbstractMap.SimpleEntry("userList.fullNameValue.keyword" as String, "${testUser2.name}" as String), - new AbstractMap.SimpleEntry("userList.userIdValue" as String, "${testUser1.getStringId()}" as String), - new AbstractMap.SimpleEntry("userList.userIdValue" as String, "${testUser2.getStringId()}" as String), + new AbstractMap.SimpleEntry("userList.fullNameValue.keyword" as String, "${groupService.getDefaultSystemGroup().getFullName()}" as String), + new AbstractMap.SimpleEntry("userList.actorIdValue" as String, "${testUser1.getStringId()}" as String), + new AbstractMap.SimpleEntry("userList.actorIdValue" as String, "${testUser2.getStringId()}" as String), + new AbstractMap.SimpleEntry("userList.actorIdValue" as String, "${groupService.getDefaultSystemGroup().stringId}" as String), new AbstractMap.SimpleEntry("enumeration_map_changed" as String, "Eve" as String), new AbstractMap.SimpleEntry("enumeration_map_changed" as String, "Eva" as String), new AbstractMap.SimpleEntry("enumeration_map_changed.textValue.keyword" as String, "Eve" as String), diff --git a/application-engine/src/test/groovy/com/netgrif/application/engine/filters/FilterImportExportTest.groovy b/application-engine/src/test/groovy/com/netgrif/application/engine/filters/FilterImportExportTest.groovy index 81383bc8c45..7be72b70ed2 100644 --- a/application-engine/src/test/groovy/com/netgrif/application/engine/filters/FilterImportExportTest.groovy +++ b/application-engine/src/test/groovy/com/netgrif/application/engine/filters/FilterImportExportTest.groovy @@ -331,8 +331,8 @@ class FilterImportExportTest { "(processIdentifier:6139e51308215f25b0a498c2_all_data)) OR ((dataSet.date.timestampValue:[1631138400000 TO 1631224800000}) AND " + "(processIdentifier:6139e51308215f25b0a498c2_all_data)) OR ((dataSet.date.timestampValue:[1631138400000 TO 1631311200000}) AND " + "(processIdentifier:6139e51308215f25b0a498c2_all_data)) OR ((dataSet.file.fileNameValue:*asdasd*) AND (processIdentifier:6139e51308215f25b0a498c2_all_data)) OR " + - "((dataSet.fileList.fileNameValue:*asdasd*) AND (processIdentifier:6139e51308215f25b0a498c2_all_data)) OR ((dataSet.user.userIdValue:<>) AND " + - "(processIdentifier:6139e51308215f25b0a498c2_all_data)) OR ((dataSet.user.userIdValue:7) AND (processIdentifier:6139e51308215f25b0a498c2_all_data)) " + + "((dataSet.fileList.fileNameValue:*asdasd*) AND (processIdentifier:6139e51308215f25b0a498c2_all_data)) OR ((dataSet.user.actorIdValue:<>) AND " + + "(processIdentifier:6139e51308215f25b0a498c2_all_data)) OR ((dataSet.user.actorIdValue:7) AND (processIdentifier:6139e51308215f25b0a498c2_all_data)) " + "OR ((dataSet.datetime.timestampValue:[1631184300000 TO 1631184360000}) AND (processIdentifier:6139e51308215f25b0a498c2_all_data)) OR " + "((dataSet.datetime.timestampValue:[1631184360000 TO 1631270820000}) AND (processIdentifier:6139e51308215f25b0a498c2_all_data))) AND (title:*asdasd*) AND " + "((creationDateSortable:[1631138400000 TO 1631224800000}) OR (creationDateSortable:[1631138400000 TO 1631311200000})) AND " + diff --git a/application-engine/src/test/groovy/com/netgrif/application/engine/impersonation/ImpersonationServiceTest.groovy b/application-engine/src/test/groovy/com/netgrif/application/engine/impersonation/ImpersonationServiceTest.groovy index b6b97f53520..a21093a329c 100644 --- a/application-engine/src/test/groovy/com/netgrif/application/engine/impersonation/ImpersonationServiceTest.groovy +++ b/application-engine/src/test/groovy/com/netgrif/application/engine/impersonation/ImpersonationServiceTest.groovy @@ -16,7 +16,7 @@ import com.netgrif.application.engine.objects.auth.domain.enums.UserState import com.netgrif.application.engine.objects.petrinet.domain.I18nString import com.netgrif.application.engine.objects.petrinet.domain.PetriNet import com.netgrif.application.engine.objects.petrinet.domain.dataset.UserFieldValue -import com.netgrif.application.engine.objects.petrinet.domain.dataset.UserListFieldValue +import com.netgrif.application.engine.objects.petrinet.domain.dataset.ActorListFieldValue import com.netgrif.application.engine.objects.petrinet.domain.roles.ProcessRole import com.netgrif.application.engine.objects.workflow.domain.Case import com.netgrif.application.engine.objects.workflow.domain.Task @@ -315,7 +315,7 @@ class ImpersonationServiceTest { def owner = new UserFieldValue(user) caze.dataSet["impersonated"].value = owner caze.dataSet["impersonated_email"].value = owner.username - caze.dataSet["config_owner"].value = new UserListFieldValue([owner]) + caze.dataSet["config_owner"].value = new ActorListFieldValue([owner]) caze.dataSet["impersonators"].value = [impersonator] caze.dataSet["impersonated_roles"].value = roles ?: user.processRoles.stringId as List caze.dataSet["impersonated_authorities"].value = auths ?: user.authoritySet.stringId as List diff --git a/application-engine/src/test/groovy/com/netgrif/application/engine/importer/UserListTest.groovy b/application-engine/src/test/groovy/com/netgrif/application/engine/importer/ActorListTest.groovy similarity index 63% rename from application-engine/src/test/groovy/com/netgrif/application/engine/importer/UserListTest.groovy rename to application-engine/src/test/groovy/com/netgrif/application/engine/importer/ActorListTest.groovy index c9c4fe1e3b8..27f2ae9e7ab 100644 --- a/application-engine/src/test/groovy/com/netgrif/application/engine/importer/UserListTest.groovy +++ b/application-engine/src/test/groovy/com/netgrif/application/engine/importer/ActorListTest.groovy @@ -1,6 +1,7 @@ package com.netgrif.application.engine.importer import com.netgrif.application.engine.TestHelper +import com.netgrif.application.engine.auth.service.GroupService import com.netgrif.application.engine.objects.petrinet.domain.VersionType import com.netgrif.application.engine.objects.petrinet.domain.throwable.MissingPetriNetMetaDataException import com.netgrif.application.engine.petrinet.service.interfaces.IPetriNetService @@ -27,25 +28,28 @@ import java.util.stream.Collectors @SpringBootTest @ActiveProfiles(["test"]) @ExtendWith(SpringExtension.class) -class UserListTest { +class ActorListTest { @Autowired - private TestHelper testHelper; + private TestHelper testHelper @Autowired - private IPetriNetService petriNetService; + private IPetriNetService petriNetService @Autowired - private SuperCreatorRunner superCreator; + private SuperCreatorRunner superCreator @Autowired - private CaseRepository caseRepository; + private CaseRepository caseRepository @Autowired - private IDataService dataService; + private IDataService dataService @Autowired - private ITaskService taskService; + private GroupService groupService + + @Autowired + private ITaskService taskService @BeforeEach void before() { @@ -53,25 +57,35 @@ class UserListTest { } @Test - void testUserList() throws MissingPetriNetMetaDataException, IOException { - ImportPetriNetEventOutcome net = petriNetService.importPetriNet(new FileInputStream("src/test/resources/user_list.xml"), VersionType.MAJOR, superCreator.getLoggedSuper()); + void testActorList() throws MissingPetriNetMetaDataException, IOException { + ImportPetriNetEventOutcome net = petriNetService.importPetriNet(new FileInputStream("src/test/resources/actor_list.xml"), VersionType.MAJOR, superCreator.getLoggedSuper()) - assert net.getNet() != null; - Optional caseOpt = caseRepository.findOne(QCase.case$.title.eq("User List")); + assert net.getNet() != null + Optional caseOpt = caseRepository.findOne(QCase.case$.title.eq("Actor List")) - assert caseOpt.isPresent(); - assert caseOpt.get().getDataSet().get("text").getValue() == "Its working..."; + assert caseOpt.isPresent() + assert caseOpt.get().getDataSet().get("text").getValue() == "Its working..." Task task = taskService.findByCases(new FullPageRequest(), Collections.singletonList(caseOpt.get().getStringId())).stream().collect(Collectors.toList()).get(0) dataService.setData(task.stringId, ImportHelper.populateDataset([ "users_1": [ "value": [superCreator.getSuperUser().getStringId()], - "type" : "userList" + "type" : "actorList" + ] + ])) + + assert taskService.findById(task.stringId).actors.get(superCreator.getSuperUser().getStringId()) + assert caseRepository.findById(caseOpt.get().stringId).get().actors.get(superCreator.getSuperUser().getStringId()) + + dataService.setData(task.stringId, ImportHelper.populateDataset([ + "users_1": [ + "value": [groupService.getDefaultSystemGroup().getStringId()], + "type" : "actorList" ] ])) - assert taskService.findById(task.stringId).users.get(superCreator.getSuperUser().getStringId()) - assert caseRepository.findById(caseOpt.get().stringId).get().users.get(superCreator.getSuperUser().getStringId()) + assert taskService.findById(task.stringId).actors.get(groupService.getDefaultSystemGroup().getStringId()) + assert caseRepository.findById(caseOpt.get().stringId).get().actors.get(groupService.getDefaultSystemGroup().getStringId()) } } diff --git a/application-engine/src/test/groovy/com/netgrif/application/engine/permissions/ElasticSearchViewPermissionTest.groovy b/application-engine/src/test/groovy/com/netgrif/application/engine/permissions/ElasticSearchViewPermissionTest.groovy index f2e3b280436..5d75d6faf48 100644 --- a/application-engine/src/test/groovy/com/netgrif/application/engine/permissions/ElasticSearchViewPermissionTest.groovy +++ b/application-engine/src/test/groovy/com/netgrif/application/engine/permissions/ElasticSearchViewPermissionTest.groovy @@ -1,6 +1,7 @@ package com.netgrif.application.engine.permissions import com.netgrif.application.engine.TestHelper +import com.netgrif.application.engine.auth.service.GroupService import com.netgrif.application.engine.objects.auth.domain.AbstractUser import com.netgrif.application.engine.objects.auth.domain.ActorTransformer import com.netgrif.application.engine.objects.auth.domain.Authority @@ -68,6 +69,9 @@ class ElasticSearchViewPermissionTest { @Autowired private IDataService dataService + @Autowired + private GroupService groupService + @Autowired private TestHelper testHelper @@ -141,7 +145,7 @@ class ElasticSearchViewPermissionTest { } @Test - void testSearchElasticViewWithUserWithoutUserRef() { + void testSearchElasticViewWithUserWithoutActorRef() { Case case_ = workflowService.createCase(netWithUserRefs.getStringId(), "Permission test", "", ActorTransformer.toLoggedUser(testUser)).getCase() CaseSearchRequest caseSearchRequest = new CaseSearchRequest() @@ -153,13 +157,37 @@ class ElasticSearchViewPermissionTest { } @Test - void testSearchElasticViewWithUserWithPosUserRef() { + void testSearchElasticViewWithUserWithPosActorRef() { Case case_ = workflowService.createCase(netWithUserRefs.getStringId(), "Permission test", "", ActorTransformer.toLoggedUser(testUser)).getCase() String taskId = (new ArrayList<>(case_.getTasks())).get(0).task case_ = dataService.setData(taskId, ImportHelper.populateDataset([ "view_ul_pos": [ "value": [testUser.stringId], - "type": "userList" + "type": "actorList" + ] + ] as Map)).getCase() + case_ = workflowService.save(case_) + sleep(4000) + + CaseSearchRequest caseSearchRequest = new CaseSearchRequest() + caseSearchRequest.process = [new CaseSearchRequest.PetriNet(netWithUserRefs.getIdentifier())] as List + Page casePage = elasticCaseService.search([caseSearchRequest] as List, ActorTransformer.toLoggedUser(testUser), PageRequest.of(0, 20), LocaleContextHolder.getLocale(), false) + + assert casePage.getContent().size() == 1 && casePage.getContent()[0].stringId == case_.stringId && case_.viewActors.contains(testUser.getStringId()) + workflowService.deleteCase(case_.getStringId()) + } + + @Test + void testSearchElasticViewWithGroupWithPosActorRef() { + String defaultGroupId = groupService.getDefaultSystemGroup().stringId + assert testUser.getGroupIds().contains(defaultGroupId) + + Case case_ = workflowService.createCase(netWithUserRefs.getStringId(), "Permission test", "", ActorTransformer.toLoggedUser(testUser)).getCase() + String taskId = (new ArrayList<>(case_.getTasks())).get(0).task + case_ = dataService.setData(taskId, ImportHelper.populateDataset([ + "view_ul_pos": [ + "value": [defaultGroupId], + "type": "actorList" ] ] as Map)).getCase() case_ = workflowService.save(case_) @@ -169,18 +197,42 @@ class ElasticSearchViewPermissionTest { caseSearchRequest.process = [new CaseSearchRequest.PetriNet(netWithUserRefs.getIdentifier())] as List Page casePage = elasticCaseService.search([caseSearchRequest] as List, ActorTransformer.toLoggedUser(testUser), PageRequest.of(0, 20), LocaleContextHolder.getLocale(), false) - assert casePage.getContent().size() == 1 && casePage.getContent()[0].stringId == case_.stringId && case_.viewUsers.contains(testUser.getStringId()) + assert casePage.getContent().size() == 1 && casePage.getContent()[0].stringId == case_.stringId && case_.viewActors.contains(defaultGroupId) workflowService.deleteCase(case_.getStringId()) } @Test - void testSearchElasticViewWithUserWithNegUserRef() { + void testSearchElasticViewWithUserWithNegActorRef() { Case case_ = workflowService.createCase(netWithUserRefs.getStringId(), "Permission test", "", ActorTransformer.toLoggedUser(testUser)).getCase() String taskId = (new ArrayList<>(case_.getTasks())).get(0).task case_ = dataService.setData(taskId, ImportHelper.populateDataset([ "view_ul_neg": [ "value": [testUser.stringId], - "type": "userList" + "type": "actorList" + ] + ] as Map)).getCase() + case_ = workflowService.save(case_) + sleep(4000) + + CaseSearchRequest caseSearchRequest = new CaseSearchRequest() + caseSearchRequest.process = [new CaseSearchRequest.PetriNet(netWithUserRefs.getIdentifier())] as List + Page casePage = elasticCaseService.search([caseSearchRequest] as List, ActorTransformer.toLoggedUser(testUser), PageRequest.of(0, 20), LocaleContextHolder.getLocale(), false) + + assert casePage.getContent().size() == 0 && case_.negativeViewActors.contains(testUser.getStringId()) + workflowService.deleteCase(case_.getStringId()) + } + + @Test + void testSearchElasticViewWithGroupWithNegActorRef() { + String defaultGroupId = groupService.getDefaultSystemGroup().stringId + assert testUser.getGroupIds().contains(defaultGroupId) + + Case case_ = workflowService.createCase(netWithUserRefs.getStringId(), "Permission test", "", ActorTransformer.toLoggedUser(testUser)).getCase() + String taskId = (new ArrayList<>(case_.getTasks())).get(0).task + case_ = dataService.setData(taskId, ImportHelper.populateDataset([ + "view_ul_neg": [ + "value": [defaultGroupId], + "type": "actorList" ] ] as Map)).getCase() case_ = workflowService.save(case_) @@ -190,12 +242,12 @@ class ElasticSearchViewPermissionTest { caseSearchRequest.process = [new CaseSearchRequest.PetriNet(netWithUserRefs.getIdentifier())] as List Page casePage = elasticCaseService.search([caseSearchRequest] as List, ActorTransformer.toLoggedUser(testUser), PageRequest.of(0, 20), LocaleContextHolder.getLocale(), false) - assert casePage.getContent().size() == 0 && case_.negativeViewUsers.contains(testUser.getStringId()) + assert casePage.getContent().size() == 0 && case_.negativeViewActors.contains(defaultGroupId) workflowService.deleteCase(case_.getStringId()) } @Test - void testSearchElasticViewWithUserWithNegativeRoleAndPosUserRef() { + void testSearchElasticViewWithUserWithNegativeRoleAndPosActorRef() { Case case_ = workflowService.createCase(netWithUserRefs.getStringId(), "Permission test", "", ActorTransformer.toLoggedUser(testUser)).getCase() ProcessRole negViewRole = this.net.getRoles().values().find(v -> v.getImportId() == "view_neg_role") userService.addRole(testUser, negViewRole.getStringId()) @@ -203,7 +255,7 @@ class ElasticSearchViewPermissionTest { case_ = dataService.setData(taskId, ImportHelper.populateDataset([ "view_ul_pos": [ "value": [testUser.stringId], - "type": "userList" + "type": "actorList" ] ] as Map)).getCase() case_ = workflowService.save(case_) @@ -213,7 +265,7 @@ class ElasticSearchViewPermissionTest { caseSearchRequest.process = [new CaseSearchRequest.PetriNet(netWithUserRefs.getIdentifier())] as List Page casePage = elasticCaseService.search([caseSearchRequest] as List, ActorTransformer.toLoggedUser(testUser), PageRequest.of(0, 20), LocaleContextHolder.getLocale(), false) - assert casePage.getContent().size() == 1 && case_.viewUsers.contains(testUser.stringId) + assert casePage.getContent().size() == 1 && case_.viewActors.contains(testUser.stringId) userService.removeRole(testUser, negViewRole.getStringId()) workflowService.deleteCase(case_.getStringId()) } diff --git a/application-engine/src/test/groovy/com/netgrif/application/engine/permissions/QueryDSLViewPermissionTest.groovy b/application-engine/src/test/groovy/com/netgrif/application/engine/permissions/QueryDSLViewPermissionTest.groovy index 5cf53bb05c7..b35fa48586d 100644 --- a/application-engine/src/test/groovy/com/netgrif/application/engine/permissions/QueryDSLViewPermissionTest.groovy +++ b/application-engine/src/test/groovy/com/netgrif/application/engine/permissions/QueryDSLViewPermissionTest.groovy @@ -1,6 +1,7 @@ package com.netgrif.application.engine.permissions import com.netgrif.application.engine.auth.service.AuthorityService +import com.netgrif.application.engine.auth.service.GroupService import com.netgrif.application.engine.auth.service.UserService import com.netgrif.application.engine.objects.auth.domain.AbstractUser import com.netgrif.application.engine.objects.auth.domain.ActorTransformer @@ -58,6 +59,9 @@ class QueryDSLViewPermissionTest { @Autowired private AuthorityService authorityService + @Autowired + private GroupService groupService + @Autowired private IDataService dataService @@ -72,7 +76,7 @@ class QueryDSLViewPermissionTest { private Authority userAuthority @BeforeEach - void inti() { + void init() { testHelper.truncateDbs() ImportPetriNetEventOutcome net = petriNetService.importPetriNet(new FileInputStream("src/test/resources/view_permission_test.xml"), VersionType.MAJOR, superCreator.getLoggedSuper()) assert net.getNet() != null @@ -127,7 +131,7 @@ class QueryDSLViewPermissionTest { } @Test - void testSearchQueryDSLViewWithoutUserRef() { + void testSearchQueryDSLViewWithoutActorRef() { Case case_ = workflowService.createCase(netWithUserRefs.getStringId(), "Permission test", "", ActorTransformer.toLoggedUser(testUser)).getCase() Page casePage = workflowService.search(["petriNet": ["identifier": netWithUserRefs.getIdentifier()], "fullText": "VPT"] as Map, PageRequest.of(0, 20), ActorTransformer.toLoggedUser(testUser), LocaleContextHolder.getLocale()) @@ -137,44 +141,86 @@ class QueryDSLViewPermissionTest { } @Test - void testSearchQueryDSLViewWithPosUserRef() { + void testSearchQueryDSLViewWithPosActorRef() { Case case_ = workflowService.createCase(netWithUserRefs.getStringId(), "Permission test", "", ActorTransformer.toLoggedUser(testUser)).getCase() String taskId = (new ArrayList<>(case_.getTasks())).get(0).task + case_ = dataService.setData(taskId, ImportHelper.populateDataset([ "view_ul_pos": [ "value": [testUser.stringId], - "type": "userList" + "type": "actorList" ] ] as Map)).getCase() - case_ = workflowService.save(case_) - sleep(4000) - Page casePage = workflowService.search(["petriNet": ["identifier": netWithUserRefs.getIdentifier()], "fullText": "VPT"] as Map, PageRequest.of(0, 20), ActorTransformer.toLoggedUser(testUser), LocaleContextHolder.getLocale()) + assert casePage.getContent().size() == 1 && casePage.getContent()[0].stringId == case_.stringId && case_.viewActors.contains(testUser.getStringId()) + + case_ = dataService.setData(taskId, ImportHelper.populateDataset([ + "view_ul_pos": [ + "value": [], + "type": "actorList" + ] + ] as Map)).getCase() + casePage = workflowService.search(["petriNet": ["identifier": netWithUserRefs.getIdentifier()], "fullText": "VPT"] as Map, + PageRequest.of(0, 20), ActorTransformer.toLoggedUser(testUser), LocaleContextHolder.getLocale()) + assert casePage.getContent().size() == 0 + + case_ = dataService.setData(taskId, ImportHelper.populateDataset([ + "view_ul_pos": [ + "value": [groupService.getDefaultSystemGroup().stringId], + "type": "actorList" + ] + ] as Map)).getCase() + casePage = workflowService.search(["petriNet": ["identifier": netWithUserRefs.getIdentifier()], "fullText": "VPT"] as Map, + PageRequest.of(0, 20), ActorTransformer.toLoggedUser(testUser), LocaleContextHolder.getLocale()) + assert casePage.getContent().size() == 1 && casePage.getContent()[0].stringId == case_.stringId + && case_.viewActors.contains(groupService.getDefaultSystemGroup().getStringId()) - assert casePage.getContent().size() == 1 && casePage.getContent()[0].stringId == case_.stringId && case_.viewUsers.contains(testUser.getStringId()) workflowService.deleteCase(case_.getStringId()) } @Test - void testSearchTaskQueryDSLViewWithPosUserRef() { + void testSearchTaskQueryDSLViewWithPosActorRef() { Case case_ = workflowService.createCase(netWithUserRefs.getStringId(), "Permission test", "", ActorTransformer.toLoggedUser(testUser)).getCase() String taskId = (new ArrayList<>(case_.getTasks())).get(0).task + case_ = dataService.setData(taskId, ImportHelper.populateDataset([ "view_ul_pos": [ "value": [testUser.stringId], - "type": "userList" + "type": "actorList" ] ] as Map)).getCase() - case_ = workflowService.save(case_) - sleep(4000) - TaskSearchRequest request = new TaskSearchRequest() request.process = [new com.netgrif.application.engine.workflow.web.requestbodies.taskSearch.PetriNet(netWithUserRefs.getStringId())] Page taskPage = taskService.search([request], PageRequest.of(0, 20), ActorTransformer.toLoggedUser(testUser), LocaleContextHolder.getLocale(), false) + assert taskPage.getContent().size() == 1 && taskPage.content[0].caseId == case_.stringId && taskPage.content[0].viewActors.contains(testUser.getStringId()) + + case_ = dataService.setData(taskId, ImportHelper.populateDataset([ + "view_ul_pos": [ + "value": [], + "type": "actorList" + ] + ] as Map)).getCase() + request = new TaskSearchRequest() + request.process = [new com.netgrif.application.engine.workflow.web.requestbodies.taskSearch.PetriNet(netWithUserRefs.getStringId())] + taskPage = taskService.search([request], PageRequest.of(0, 20), + ActorTransformer.toLoggedUser(testUser), LocaleContextHolder.getLocale(), false) + assert taskPage.getContent().size() == 0 + + case_ = dataService.setData(taskId, ImportHelper.populateDataset([ + "view_ul_pos": [ + "value": [groupService.getDefaultSystemGroup().stringId], + "type": "actorList" + ] + ] as Map)).getCase() + request = new TaskSearchRequest() + request.process = [new com.netgrif.application.engine.workflow.web.requestbodies.taskSearch.PetriNet(netWithUserRefs.getStringId())] + taskPage = taskService.search([request], PageRequest.of(0, 20), + ActorTransformer.toLoggedUser(testUser), LocaleContextHolder.getLocale(), false) + assert taskPage.getContent().size() == 1 && taskPage.content[0].caseId == case_.stringId + && taskPage.content[0].viewActors.contains(groupService.getDefaultSystemGroup().stringId) - assert taskPage.getContent().size() == 1 && taskPage.content[0].caseId == case_.stringId && taskPage.content[0].viewUsers.contains(testUser.getStringId()) workflowService.deleteCase(case_.getStringId()) } @@ -195,45 +241,85 @@ class QueryDSLViewPermissionTest { } @Test - void testSearchQueryDSLViewWithNegUserRef() { + void testSearchQueryDSLViewWithNegActorRef() { Case case_ = workflowService.createCase(netWithUserRefs.getStringId(), "Permission test", "", ActorTransformer.toLoggedUser(testUser)).getCase() String taskId = (new ArrayList<>(case_.getTasks())).get(0).task + case_ = dataService.setData(taskId, ImportHelper.populateDataset([ "view_ul_neg": [ "value": [testUser.stringId], - "type": "userList" + "type": "actorList" + ], + "view_ul_pos": [ + "value": [testUser.stringId], + "type": "actorList" ] ] as Map)).getCase() - case_ = workflowService.save(case_) - sleep(4000) - Page casePage = workflowService.search(["petriNet": ["identifier": netWithUserRefs.getIdentifier()], "fullText": "VPT"] as Map, PageRequest.of(0, 20), ActorTransformer.toLoggedUser(testUser), LocaleContextHolder.getLocale()) + assert casePage.getContent().size() == 0 && case_.negativeViewActors.contains(testUser.getStringId()) + + case_ = dataService.setData(taskId, ImportHelper.populateDataset([ + "view_ul_neg": [ + "value": [], + "type": "actorList" + ] + ] as Map)).getCase() + casePage = workflowService.search(["petriNet": ["identifier": netWithUserRefs.getIdentifier()], "fullText": "VPT"] as Map, + PageRequest.of(0, 20), ActorTransformer.toLoggedUser(testUser), LocaleContextHolder.getLocale()) + assert casePage.getContent().size() == 1 && case_.negativeViewActors.isEmpty() + + case_ = dataService.setData(taskId, ImportHelper.populateDataset([ + "view_ul_neg": [ + "value": [groupService.getDefaultSystemGroup().stringId], + "type": "actorList" + ] + ] as Map)).getCase() + casePage = workflowService.search(["petriNet": ["identifier": netWithUserRefs.getIdentifier()], "fullText": "VPT"] as Map, + PageRequest.of(0, 20), ActorTransformer.toLoggedUser(testUser), LocaleContextHolder.getLocale()) + assert casePage.getContent().size() == 0 && case_.negativeViewActors.contains(groupService.getDefaultSystemGroup().stringId) - assert casePage.getContent().size() == 0 && case_.negativeViewUsers.contains(testUser.getStringId()) workflowService.deleteCase(case_.getStringId()) } @Test - void testSearchQueryDSLViewWithNegRoleAndPosUserRef() { + void testSearchQueryDSLViewWithNegRoleAndPosActorRef() { Case case_ = workflowService.createCase(netWithUserRefs.getStringId(), "Permission test", "", ActorTransformer.toLoggedUser(testUser)).getCase() String taskId = (new ArrayList<>(case_.getTasks())).get(0).task + + ProcessRole negViewRole = this.net.getRoles().values().find(v -> v.getImportId() == "view_neg_role") + userService.addRole(testUser, negViewRole.getStringId()) + case_ = dataService.setData(taskId, ImportHelper.populateDataset([ "view_ul_pos": [ "value": [testUser.stringId], - "type": "userList" + "type": "actorList" ] ] as Map)).getCase() + Page casePage = workflowService.search(["petriNet": ["identifier": netWithUserRefs.getIdentifier()], "fullText": "VPT"] as Map, + PageRequest.of(0, 20), ActorTransformer.toLoggedUser(testUser), LocaleContextHolder.getLocale()) + assert casePage.getContent().size() == 1 && case_.viewActors.contains(testUser.stringId) - ProcessRole negViewRole = this.net.getRoles().values().find(v -> v.getImportId() == "view_neg_role") - userService.addRole(testUser, negViewRole.getStringId()) - case_ = workflowService.save(case_) - sleep(4000) + case_ = dataService.setData(taskId, ImportHelper.populateDataset([ + "view_ul_pos": [ + "value": [], + "type": "actorList" + ] + ] as Map)).getCase() + casePage = workflowService.search(["petriNet": ["identifier": netWithUserRefs.getIdentifier()], "fullText": "VPT"] as Map, + PageRequest.of(0, 20), ActorTransformer.toLoggedUser(testUser), LocaleContextHolder.getLocale()) + assert casePage.getContent().size() == 0 && case_.viewActors.isEmpty() - Page casePage = workflowService.search(["petriNet": ["identifier": netWithUserRefs.getIdentifier()], "fullText": "VPT"] as Map, + case_ = dataService.setData(taskId, ImportHelper.populateDataset([ + "view_ul_pos": [ + "value": [groupService.getDefaultSystemGroup().stringId], + "type": "actorList" + ] + ] as Map)).getCase() + casePage = workflowService.search(["petriNet": ["identifier": netWithUserRefs.getIdentifier()], "fullText": "VPT"] as Map, PageRequest.of(0, 20), ActorTransformer.toLoggedUser(testUser), LocaleContextHolder.getLocale()) + assert casePage.getContent().size() == 1 && case_.viewActors.contains(groupService.getDefaultSystemGroup().stringId) - assert casePage.getContent().size() == 1 && case_.viewUsers.contains(testUser.stringId) userService.removeRole(testUser, negViewRole.getStringId()) workflowService.deleteCase(case_.getStringId()) } diff --git a/application-engine/src/test/groovy/com/netgrif/application/engine/petrinet/domain/dataset/FieldTest.groovy b/application-engine/src/test/groovy/com/netgrif/application/engine/petrinet/domain/dataset/FieldTest.groovy index 280b33c817d..4399657f637 100644 --- a/application-engine/src/test/groovy/com/netgrif/application/engine/petrinet/domain/dataset/FieldTest.groovy +++ b/application-engine/src/test/groovy/com/netgrif/application/engine/petrinet/domain/dataset/FieldTest.groovy @@ -20,8 +20,8 @@ import com.netgrif.application.engine.objects.petrinet.domain.dataset.Multichoic import com.netgrif.application.engine.objects.petrinet.domain.dataset.NumberField import com.netgrif.application.engine.objects.petrinet.domain.dataset.TaskField import com.netgrif.application.engine.objects.petrinet.domain.dataset.TextField -import com.netgrif.application.engine.objects.petrinet.domain.dataset.UserField -import com.netgrif.application.engine.objects.petrinet.domain.dataset.UserListField +import com.netgrif.application.engine.objects.petrinet.domain.dataset.ActorField +import com.netgrif.application.engine.objects.petrinet.domain.dataset.ActorListField import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -180,7 +180,7 @@ class FieldTest { } private void assertUserField() { - UserField field = net.dataSet["user"] as UserField + ActorField field = net.dataSet["user"] as ActorField assert field.description.defaultValue == "User field description" assert field.name.defaultValue == "User" assert field.placeholder.defaultValue == "User field placeholder" @@ -203,7 +203,7 @@ class FieldTest { } private void assertUserList() { - UserListField field = net.dataSet["emptyUserList"] as UserListField + ActorListField field = net.dataSet["emptyUserList"] as ActorListField assert field.name.defaultValue == "Empty user list" assert field.description.defaultValue == "User list description" assert field.defaultValue == null diff --git a/application-engine/src/test/groovy/com/netgrif/application/engine/workflow/TaskControllerTest.groovy b/application-engine/src/test/groovy/com/netgrif/application/engine/workflow/TaskControllerTest.groovy index 569de8e8944..10f5b88847f 100644 --- a/application-engine/src/test/groovy/com/netgrif/application/engine/workflow/TaskControllerTest.groovy +++ b/application-engine/src/test/groovy/com/netgrif/application/engine/workflow/TaskControllerTest.groovy @@ -197,7 +197,7 @@ class TaskControllerTest { dataService.setData(task.stringId, ImportHelper.populateDataset([ "performable_users": [ "value": userIds, - "type" : "userList" + "type" : "actorList" ] ])) } diff --git a/application-engine/src/test/groovy/com/netgrif/application/engine/workflow/UserRefsTest.groovy b/application-engine/src/test/groovy/com/netgrif/application/engine/workflow/UserRefsTest.groovy index 6f6b6aa44c1..b4cc3eeb00f 100644 --- a/application-engine/src/test/groovy/com/netgrif/application/engine/workflow/UserRefsTest.groovy +++ b/application-engine/src/test/groovy/com/netgrif/application/engine/workflow/UserRefsTest.groovy @@ -68,7 +68,7 @@ class UserRefsTest { _case = dataService.setData(taskId, ImportHelper.populateDataset([ "user_list_1": [ "value": [id], - "type": "userList" + "type": "actorList" ] ] as Map)).getCase() newCases.add(workflowService.save(_case)) @@ -78,7 +78,7 @@ class UserRefsTest { @Test void testCases() { - newCases.eachWithIndex { Case entry, int i -> assert entry.users.get(userIds.get(i)) != null } + newCases.eachWithIndex { Case entry, int i -> assert entry.actors.get(userIds.get(i)) != null } } diff --git a/application-engine/src/test/resources/user_list.xml b/application-engine/src/test/resources/actor_list.xml similarity index 84% rename from application-engine/src/test/resources/user_list.xml rename to application-engine/src/test/resources/actor_list.xml index 7f5c2234003..ab8e804402e 100644 --- a/application-engine/src/test/resources/user_list.xml +++ b/application-engine/src/test/resources/actor_list.xml @@ -1,25 +1,25 @@ - user_list - User list + actor_list + Actor list ULT - + users_1 - + users_1 false true - + upload - createCase("user_list", "User List") + createCase("actor_list", "Actor List") @@ -39,7 +39,7 @@ pdf - createCase("user_list", "Destruct") + createCase("actor_list", "Destruct") @@ -53,12 +53,12 @@ 1 - + users_1 true - + diff --git a/application-engine/src/test/resources/all_data.xml b/application-engine/src/test/resources/all_data.xml index f6f084ac274..ab931545505 100644 --- a/application-engine/src/test/resources/all_data.xml +++ b/application-engine/src/test/resources/all_data.xml @@ -112,7 +112,7 @@ pom.xml - + user User @@ -151,7 +151,7 @@ - + userList User list diff --git a/application-engine/src/test/resources/all_data_pdf.xml b/application-engine/src/test/resources/all_data_pdf.xml index e2d8a3f82df..57de226e017 100644 --- a/application-engine/src/test/resources/all_data_pdf.xml +++ b/application-engine/src/test/resources/all_data_pdf.xml @@ -163,7 +163,7 @@ File List - + user User diff --git a/application-engine/src/test/resources/data_test.xml b/application-engine/src/test/resources/data_test.xml index a9e4feb8786..4430ecffdad 100644 --- a/application-engine/src/test/resources/data_test.xml +++ b/application-engine/src/test/resources/data_test.xml @@ -102,7 +102,7 @@ File field description - + user User User field placeholder @@ -135,8 +135,8 @@ processId2 - - + + emptyUserList Empty user list User list description diff --git a/application-engine/src/test/resources/initial_behavior.xml b/application-engine/src/test/resources/initial_behavior.xml index e169b58a7b6..f71727c592b 100644 --- a/application-engine/src/test/resources/initial_behavior.xml +++ b/application-engine/src/test/resources/initial_behavior.xml @@ -85,7 +85,7 @@ File List - + user User diff --git a/application-engine/src/test/resources/mapping_test.xml b/application-engine/src/test/resources/mapping_test.xml index d7ab7541dd6..6b698b2430d 100755 --- a/application-engine/src/test/resources/mapping_test.xml +++ b/application-engine/src/test/resources/mapping_test.xml @@ -75,7 +75,7 @@ 25 Is a burglar alarm fitted and used? - + 27 Property owner 1 diff --git a/application-engine/src/test/resources/org_group.xml b/application-engine/src/test/resources/org_group.xml index 0bbc98fe2af..0bf9c9158d5 100644 --- a/application-engine/src/test/resources/org_group.xml +++ b/application-engine/src/test/resources/org_group.xml @@ -20,7 +20,7 @@ change id value { useCase.stringId } - + author Group Author @@ -35,7 +35,7 @@ workflowService.save(useCase) - + user_selection Select user No user selected diff --git a/application-engine/src/test/resources/pdf_run_action.xml b/application-engine/src/test/resources/pdf_run_action.xml index 3256bae1686..073258bc193 100644 --- a/application-engine/src/test/resources/pdf_run_action.xml +++ b/application-engine/src/test/resources/pdf_run_action.xml @@ -110,7 +110,7 @@ File field placeholder File field description - + user User User field placeholder diff --git a/application-engine/src/test/resources/pdf_test_1.xml b/application-engine/src/test/resources/pdf_test_1.xml index 7ffd56d668f..3fd5f9e2d45 100644 --- a/application-engine/src/test/resources/pdf_test_1.xml +++ b/application-engine/src/test/resources/pdf_test_1.xml @@ -107,7 +107,7 @@ File field placeholder - + user User diff --git a/application-engine/src/test/resources/pdf_test_3.xml b/application-engine/src/test/resources/pdf_test_3.xml index a7ad5d02232..bf78d50c691 100644 --- a/application-engine/src/test/resources/pdf_test_3.xml +++ b/application-engine/src/test/resources/pdf_test_3.xml @@ -154,7 +154,7 @@ boolean_1 set label? - + [object Object]_0 set label placeholder diff --git a/application-engine/src/test/resources/petriNets/FM_v0_2.xml b/application-engine/src/test/resources/petriNets/FM_v0_2.xml index e6620e07125..e68f7dfb5de 100644 --- a/application-engine/src/test/resources/petriNets/FM_v0_2.xml +++ b/application-engine/src/test/resources/petriNets/FM_v0_2.xml @@ -67,7 +67,7 @@ 8 Oddelenie - + 9 Odovzdávajúci 1 @@ -117,13 +117,13 @@ 20 Dátum vrátenia - + 21 Vypožičal 1 2 - + 22 Vrátil 1 @@ -161,7 +161,7 @@ 30 Klientské číslo - + 31 Odovzdal 1 @@ -171,13 +171,13 @@ 32 Počet škatúľ - + 33 Kuriér 1 2 - + 34 Spracoval 1 @@ -192,13 +192,13 @@ 36 Počet uvedený v systéme - + 37 Založil 1 2 - + 38 Zapísal do systému 1 diff --git a/application-engine/src/test/resources/petriNets/all_data.xml b/application-engine/src/test/resources/petriNets/all_data.xml index f65ed4ae659..66d60298dc5 100644 --- a/application-engine/src/test/resources/petriNets/all_data.xml +++ b/application-engine/src/test/resources/petriNets/all_data.xml @@ -176,17 +176,17 @@ File List - + user User - + userList1 UserList - + userList2 UserList diff --git a/application-engine/src/test/resources/petriNets/all_data_refs.xml b/application-engine/src/test/resources/petriNets/all_data_refs.xml index 69eb782f3b3..676af85e721 100644 --- a/application-engine/src/test/resources/petriNets/all_data_refs.xml +++ b/application-engine/src/test/resources/petriNets/all_data_refs.xml @@ -119,7 +119,7 @@ File list - + user User diff --git a/application-engine/src/test/resources/petriNets/dynamic_init.xml b/application-engine/src/test/resources/petriNets/dynamic_init.xml index ed2792d53af..310c04fe2d0 100644 --- a/application-engine/src/test/resources/petriNets/dynamic_init.xml +++ b/application-engine/src/test/resources/petriNets/dynamic_init.xml @@ -29,7 +29,7 @@ java.time.LocalDateTime.now() - + user user diff --git a/application-engine/src/test/resources/petriNets/impersonation_test.xml b/application-engine/src/test/resources/petriNets/impersonation_test.xml index 7a0d1993284..c549edf14f0 100644 --- a/application-engine/src/test/resources/petriNets/impersonation_test.xml +++ b/application-engine/src/test/resources/petriNets/impersonation_test.xml @@ -30,7 +30,7 @@ file_0 </data> - <data type="userList" immediate="true"> + <data type="actorList" immediate="true"> <id>user_list</id> <title/> </data> @@ -108,11 +108,11 @@ <x>580</x> <y>300</y> <label/> - <userRef> + <actorRef> <id>user_list</id> <logic> <perform>true</perform> </logic> - </userRef> + </actorRef> </transition> </document> \ No newline at end of file diff --git a/application-engine/src/test/resources/petriNets/test_model_immediate_data.xml b/application-engine/src/test/resources/petriNets/test_model_immediate_data.xml index 7ef55217802..ad84a9966b0 100644 --- a/application-engine/src/test/resources/petriNets/test_model_immediate_data.xml +++ b/application-engine/src/test/resources/petriNets/test_model_immediate_data.xml @@ -96,7 +96,7 @@ <values>Value 3</values> <init>Value 3</init> </data> - <data type="user" immediate="true"> + <data type="actor" immediate="true"> <id>user_field</id> <title>User tester diff --git a/application-engine/src/test/resources/poistenie.xml b/application-engine/src/test/resources/poistenie.xml index bdcacd7c715..24f7db81100 100644 --- a/application-engine/src/test/resources/poistenie.xml +++ b/application-engine/src/test/resources/poistenie.xml @@ -127,7 +127,7 @@ 26 Koľko rokov ste nemali poisťovací prípad? - + 27 Vlastník poistenia 1 diff --git a/application-engine/src/test/resources/poistenie_rozsirene.xml b/application-engine/src/test/resources/poistenie_rozsirene.xml index 518ed2b9c2d..0235b55ad3d 100644 --- a/application-engine/src/test/resources/poistenie_rozsirene.xml +++ b/application-engine/src/test/resources/poistenie_rozsirene.xml @@ -127,7 +127,7 @@ 26 Koľko rokov ste nemali poisťovací prípad? - + 27 Vlastník poistenia 1 diff --git a/application-engine/src/test/resources/poistenie_transaction.xml b/application-engine/src/test/resources/poistenie_transaction.xml index 139d519e726..e1a83664703 100644 --- a/application-engine/src/test/resources/poistenie_transaction.xml +++ b/application-engine/src/test/resources/poistenie_transaction.xml @@ -140,7 +140,7 @@ 26 Koľko rokov ste nemali poisťovací prípad? - + 27 Vlastník poistenia 1 diff --git a/application-engine/src/test/resources/poistenie_triggers.xml b/application-engine/src/test/resources/poistenie_triggers.xml index 4919206b18e..b6d47b06a60 100644 --- a/application-engine/src/test/resources/poistenie_triggers.xml +++ b/application-engine/src/test/resources/poistenie_triggers.xml @@ -128,7 +128,7 @@ 26 Koľko rokov ste nemali poisťovací prípad? - + 27 Vlastník poistenia 1 diff --git a/application-engine/src/test/resources/predefinedPermissions/role_permissions_anonymous_role_shadowed_userref.xml b/application-engine/src/test/resources/predefinedPermissions/role_permissions_anonymous_role_shadowed_userref.xml index 1e69657be3f..854de0968cd 100644 --- a/application-engine/src/test/resources/predefinedPermissions/role_permissions_anonymous_role_shadowed_userref.xml +++ b/application-engine/src/test/resources/predefinedPermissions/role_permissions_anonymous_role_shadowed_userref.xml @@ -8,15 +8,15 @@ - + userList true true - + - + userList @@ -30,13 +30,13 @@ 0 - + userList true true - + diff --git a/application-engine/src/test/resources/predefinedPermissions/role_permissions_anonymous_role_shadowed_usersref.xml b/application-engine/src/test/resources/predefinedPermissions/role_permissions_anonymous_role_shadowed_usersref.xml index cdc455d6da7..8cc7bf1b09a 100644 --- a/application-engine/src/test/resources/predefinedPermissions/role_permissions_anonymous_role_shadowed_usersref.xml +++ b/application-engine/src/test/resources/predefinedPermissions/role_permissions_anonymous_role_shadowed_usersref.xml @@ -8,15 +8,15 @@ - + userList true true - + - + userList @@ -30,13 +30,13 @@ 0 - + userList true true - + diff --git a/application-engine/src/test/resources/predefinedPermissions/role_permissions_default_role_shadowed_userref.xml b/application-engine/src/test/resources/predefinedPermissions/role_permissions_default_role_shadowed_userref.xml index 131a28f2806..530f097fc94 100644 --- a/application-engine/src/test/resources/predefinedPermissions/role_permissions_default_role_shadowed_userref.xml +++ b/application-engine/src/test/resources/predefinedPermissions/role_permissions_default_role_shadowed_userref.xml @@ -8,15 +8,15 @@ - + userList true true - + - + userList @@ -30,13 +30,13 @@ 0 - + userList true true - + diff --git a/application-engine/src/test/resources/predefinedPermissions/role_permissions_default_role_shadowed_usersref.xml b/application-engine/src/test/resources/predefinedPermissions/role_permissions_default_role_shadowed_usersref.xml index 3b2a7359c9c..b92211ff411 100644 --- a/application-engine/src/test/resources/predefinedPermissions/role_permissions_default_role_shadowed_usersref.xml +++ b/application-engine/src/test/resources/predefinedPermissions/role_permissions_default_role_shadowed_usersref.xml @@ -8,15 +8,15 @@ - + userList true true - + - + userList @@ -30,13 +30,13 @@ 0 - + userList true true - + diff --git a/application-engine/src/test/resources/prikladFM.xml b/application-engine/src/test/resources/prikladFM.xml index d26601a9d87..8b6ee661381 100644 --- a/application-engine/src/test/resources/prikladFM.xml +++ b/application-engine/src/test/resources/prikladFM.xml @@ -36,7 +36,7 @@ 8 Oddelenie - + 9 Odovzdávajúci 1 @@ -86,13 +86,13 @@ 20 Dátum vrátenia - + 21 Vypožičal 1 2 - + 22 Vrátil 1 @@ -130,7 +130,7 @@ 30 Klientské číslo - + 31 Odovzdal 1 @@ -140,13 +140,13 @@ 32 Počet škatúľ - + 33 Kuriér 1 2 - + 34 Spracoval 1 @@ -161,13 +161,13 @@ 36 Počet uvedený v systéme - + 37 Založil 1 2 - + 38 Zapísal do systému 1 diff --git a/application-engine/src/test/resources/prikladFM_import.xml b/application-engine/src/test/resources/prikladFM_import.xml index 4628ff9889d..581c3b7c3bc 100644 --- a/application-engine/src/test/resources/prikladFM_import.xml +++ b/application-engine/src/test/resources/prikladFM_import.xml @@ -37,7 +37,7 @@ 8 Oddelenie - + 9 Odovzdávajúci 1 diff --git a/application-engine/src/test/resources/prikladFM_test.xml b/application-engine/src/test/resources/prikladFM_test.xml index 369a2e491b8..e6ae4568648 100644 --- a/application-engine/src/test/resources/prikladFM_test.xml +++ b/application-engine/src/test/resources/prikladFM_test.xml @@ -40,7 +40,7 @@ 8 Miestnosť - + 9 Odovzdávajúci 1 diff --git a/application-engine/src/test/resources/role_all_data.xml b/application-engine/src/test/resources/role_all_data.xml index 96c9048d849..5b49f72d527 100644 --- a/application-engine/src/test/resources/role_all_data.xml +++ b/application-engine/src/test/resources/role_all_data.xml @@ -186,17 +186,17 @@ File List - + user User - + userList1 UserList - + userList2 UserList diff --git a/application-engine/src/test/resources/set_data_test.xml b/application-engine/src/test/resources/set_data_test.xml index 209ed3ac8f0..0e4fd1b8fb4 100644 --- a/application-engine/src/test/resources/set_data_test.xml +++ b/application-engine/src/test/resources/set_data_test.xml @@ -311,7 +311,7 @@ - + user User diff --git a/application-engine/src/test/resources/task_authorization_service_test_with_userRefs.xml b/application-engine/src/test/resources/task_authorization_service_test_with_userRefs.xml index 67ca0859531..1171a5c9f70 100644 --- a/application-engine/src/test/resources/task_authorization_service_test_with_userRefs.xml +++ b/application-engine/src/test/resources/task_authorization_service_test_with_userRefs.xml @@ -20,35 +20,35 @@ finish_neg_role finish neg role - + assign_pos_ul </data> - <data type="userList"> + <data type="actorList"> <id>assign_neg_ul</id> <title/> </data> - <data type="userList"> + <data type="actorList"> <id>delegate_pos_ul</id> <title/> </data> - <data type="userList"> + <data type="actorList"> <id>delegate_neg_ul</id> <title/> </data> - <data type="userList"> + <data type="actorList"> <id>cancel_pos_ul</id> <title/> </data> - <data type="userList"> + <data type="actorList"> <id>cancel_neg_ul</id> <title/> </data> - <data type="userList"> + <data type="actorList"> <id>finish_pos_ul</id> <title/> </data> - <data type="userList"> + <data type="actorList"> <id>finish_neg_ul</id> <title/> </data> @@ -90,54 +90,54 @@ <finish>false</finish> </logic> </roleRef> - <userRef> + <actorRef> <id>assign_pos_ul</id> <logic> <assign>true</assign> </logic> - </userRef> - <userRef> + </actorRef> + <actorRef> <id>assign_neg_ul</id> <logic> <assign>false</assign> </logic> - </userRef> - <userRef> + </actorRef> + <actorRef> <id>delegate_pos_ul</id> <logic> <delegate>true</delegate> </logic> - </userRef> - <userRef> + </actorRef> + <actorRef> <id>delegate_neg_ul</id> <logic> <delegate>false</delegate> </logic> - </userRef> - <userRef> + </actorRef> + <actorRef> <id>cancel_pos_ul</id> <logic> <cancel>true</cancel> </logic> - </userRef> - <userRef> + </actorRef> + <actorRef> <id>cancel_neg_ul</id> <logic> <cancel>false</cancel> </logic> - </userRef> - <userRef> + </actorRef> + <actorRef> <id>finish_pos_ul</id> <logic> <finish>true</finish> </logic> - </userRef> - <userRef> + </actorRef> + <actorRef> <id>finish_neg_ul</id> <logic> <finish>false</finish> </logic> - </userRef> + </actorRef> <dataRef> <id>text</id> <logic> diff --git a/application-engine/src/test/resources/userrefs_test.xml b/application-engine/src/test/resources/userrefs_test.xml index e2b0c67e704..c103f712358 100644 --- a/application-engine/src/test/resources/userrefs_test.xml +++ b/application-engine/src/test/resources/userrefs_test.xml @@ -20,12 +20,12 @@ <title>Admin Role - + user_list_1 true - + @@ -37,11 +37,11 @@ remove Remove from user ref - + user_list_1 User list 1 - + user_list_2 User list 2 @@ -66,12 +66,12 @@ true - + user_list_1 true - + email diff --git a/application-engine/src/test/resources/view_permission_with_userRefs_test.xml b/application-engine/src/test/resources/view_permission_with_userRefs_test.xml index adeea8ba535..26ee995c240 100644 --- a/application-engine/src/test/resources/view_permission_with_userRefs_test.xml +++ b/application-engine/src/test/resources/view_permission_with_userRefs_test.xml @@ -17,18 +17,18 @@ false - + view_ul_pos true - - + + view_ul_neg false - + view_pos_role view role @@ -37,11 +37,11 @@ view_neg_role view role - + view_ul_pos </data> - <data type="userList"> + <data type="actorList"> <id>view_ul_neg</id> <title/> </data> @@ -71,18 +71,18 @@ <view>false</view> </logic> </roleRef> - <userRef> + <actorRef> <id>view_ul_pos</id> <logic> <view>true</view> </logic> - </userRef> - <userRef> + </actorRef> + <actorRef> <id>view_ul_neg</id> <logic> <view>false</view> </logic> - </userRef> + </actorRef> <dataRef> <id>text</id> <logic> diff --git a/application-engine/src/test/resources/workflow_authorization_service_test_with_userRefs.xml b/application-engine/src/test/resources/workflow_authorization_service_test_with_userRefs.xml index f88c05d6381..634e1e300f2 100644 --- a/application-engine/src/test/resources/workflow_authorization_service_test_with_userRefs.xml +++ b/application-engine/src/test/resources/workflow_authorization_service_test_with_userRefs.xml @@ -28,18 +28,18 @@ <create>false</create> </caseLogic> </roleRef> - <userRef> + <actorRef> <id>neg_user_list</id> <caseLogic> <delete>false</delete> </caseLogic> - </userRef> - <userRef> + </actorRef> + <actorRef> <id>pos_user_list</id> <caseLogic> <delete>true</delete> </caseLogic> - </userRef> + </actorRef> <role> <id>delete_pos_role</id> <name>delete role</name> @@ -56,11 +56,11 @@ <id>create_neg_role</id> <name>create role</name> </role> - <data type="userList"> + <data type="actorList"> <id>pos_user_list</id> <title/> </data> - <data type="userList"> + <data type="actorList"> <id>neg_user_list</id> <title/> </data> diff --git a/application-engine/src/test/resources/zaverecna_praca.xml b/application-engine/src/test/resources/zaverecna_praca.xml index f8e40e4354c..ec8404c8a26 100644 --- a/application-engine/src/test/resources/zaverecna_praca.xml +++ b/application-engine/src/test/resources/zaverecna_praca.xml @@ -16,7 +16,7 @@ <id>3</id> <title>Dátum odovzdania - + 4 Vedúci práce 1 @@ -40,12 +40,12 @@ 8 Posudok vedúceho práce - + 9 Oponent práce 3 - + 10 Autor 5 diff --git a/docs/_media/roles/usersRef_functions.groovy b/docs/_media/roles/actorRef_functions.groovy similarity index 100% rename from docs/_media/roles/usersRef_functions.groovy rename to docs/_media/roles/actorRef_functions.groovy diff --git a/docs/_media/roles/usersRef_net.xml b/docs/_media/roles/actorRef_net.xml similarity index 87% rename from docs/_media/roles/usersRef_net.xml rename to docs/_media/roles/actorRef_net.xml index 39db84655a5..229a4c5582d 100644 --- a/docs/_media/roles/usersRef_net.xml +++ b/docs/_media/roles/actorRef_net.xml @@ -31,14 +31,14 @@ true - - user_list_1 + + actor_list_1 true - + - + assign @@ -48,12 +48,12 @@ remove Remove from user ref - - user_list_1 + + actor_list_1 User list 1 - - user_list_2 + + actor_list_2 User list 2 @@ -63,8 +63,8 @@ userAddition - userList: f.user_list_1; - change userList value { [getDummyUser()] } + actorList: f.actor_list_1; + change actorList value { [getDummyUser()] } @@ -84,12 +84,12 @@ true - - user_list_1 + + actor_list_1 false - + assign @@ -99,8 +99,8 @@ assign - userList: f.user_list_1; - change userList value { [getDummyUser()] } + actorList: f.actor_list_1; + change actorList value { [getDummyUser()] } @@ -114,8 +114,8 @@ remove - userList: f.user_list_1; - change userList value { [] } + actorList: f.actor_list_1; + change actorList value { [] } diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 0bd5aacf956..d993a028b55 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -10,7 +10,7 @@ * [Filter](search/filter.md) * [Import / Export](search/filter_import_export.md) * [Permissions]() - * [User list](roles/userlist.md) + * [Actor list](roles/actorlist.md) * [Permissions](roles/permissions.md) * [Assigned user policy](roles/assigned_user_policy.md) * [Views]() diff --git a/docs/roles/actorlist.md b/docs/roles/actorlist.md new file mode 100644 index 00000000000..70129c9bb8a --- /dev/null +++ b/docs/roles/actorlist.md @@ -0,0 +1,110 @@ +# ActorList and ActorRef + +## ActorList + +ActorList is a type of data field. Values of this field represent actors (users, groups, ...) in system. Some basic information about +this field: + +- this field does not have any init value, because when the process is created or imported, the given actor may not exist +- we can add values to this field via actions and using frontend component +- it can serve as definition of permissions for volume of actors +- value type of this field is ``ActorListFieldValue`` + +```xml + + actorList1 + +</data> +``` + +Example action to change value of this field: +```xml +<action trigger="set"> + actorList: f.actorList1; + + <!-- Setting with list of actor IDs --> + change actorList value { ["userId1", "groupId1"] } + + <!-- Setting with ActorListFieldValue --> + change actorList value { + new com.netgrif.core.petrinet.domain.dataset.ActorListFieldValue( + [ + new com.netgrif.core.petrinet.domain.dataset.UserFieldValue( + "userId1", + "realm1", + "John", + "Doe", + "john@doe.com" + ), + new com.netgrif.core.petrinet.domain.dataset.GroupFieldValue( + "groupId1", + "realm1", + "A group name" + ) + ] + ) + } +</action> +``` + +## ActorRef + +It is a new property of process and transition in PetriNet. It serves as a roleRef with a difference from it: the +content of the actorList can be changed at runtime. + +- actorRef references actorList defined with its ID +- we define permissions for actorRef in the same way as for roleRef + +```xml +<document> + ... + <data type="actorList"> + <id>actorList1</id> + <title/> + </data> + ... + <actorRef> + <id>actorList1</id> + <caseLogic> + <view>true</view> + <delete>true</delete> + </caseLogic> + </actorRef> + ... + <transition> + <id>1</id> + <actorRef> + <id>actorList1</id> + <logic> + <perform>true</perform> + </logic> + </actorRef> + </transition> +</document> +``` + +## Setting permissions + +If we want to define permission only for a set of actors, and we want to change the content of this set runtime, the +actorList-actorRef combo is the best way to do so. You have to follow these steps: + +1. Define new data field of type **actorList** - required attribute is only the *id* of field. +2. For case permissions, define **actorRef** in *document* tag, for task permission define it in the corresponding * + transition* tag +3. Into *logic* property of actorRef we define the permissions with boolean values - true means enable, false mean + disable the given permission for user. The permissions can be the following: + 1. for cases: + 1. *view* - enable or disable the displaying of cases + 2. *delete* - enable or disable the deletion of cases + 2. for tasks: + 1. *perform* - enable or disable all the permissions + 2. *delegate* - enable or disable delegating tasks + 3. *assign* - enable or disable assign of tasks + 4. *cancel* - enable or disable canceling of tasks + 5. *finish* - enable or disable finish of tasks + +[Permission resolution](permissions.md?id=permissions) + +[ActorRef Petri Net](../_media/roles/actorRef_functions.groovy) + +[ActorRef Functions](../_media/roles/actorRef_net.xml) diff --git a/docs/roles/permissions.md b/docs/roles/permissions.md index 27c408013be..9dd3f21640b 100644 --- a/docs/roles/permissions.md +++ b/docs/roles/permissions.md @@ -94,24 +94,24 @@ For these examples only the `default` role is used to demonstrate the principles ```xml <document> - <userRef> + <actorRef> <id>other</id> <caseLogic> <view>false</view> </caseLogic> - </userRef> + </actorRef> </document> ``` ```xml <document> <transition> - <userRef> + <actorRef> <id>other</id> <logic> <view>false</view> </logic> - </userRef> + </actorRef> </transition> </document> ``` @@ -192,24 +192,24 @@ For these examples only the `default` role is used to demonstrate the principles ```xml <document> - <userRef> + <actorRef> <id>other</id> <caseLogic> <view>true</view> </caseLogic> - </userRef> + </actorRef> </document> ``` ```xml <document> <transition> - <userRef> + <actorRef> <id>other</id> <logic> <view>true</view> </logic> - </userRef> + </actorRef> </transition> </document> ``` @@ -261,7 +261,7 @@ Permission documentation can be found [here](#Permissions). Roles can be referen <roleRef> <id>process_role</id> <caseLogic> - <create>false</view> + <create>false</create> <view>true</view> </caseLogic> </roleRef> @@ -279,7 +279,7 @@ Permission documentation can be found [here](#Permissions). Roles can be referen <roleRef> <id>process_role</id> <logic> - <finish>false</view> + <finish>false</finish> <view>true</view> </logic> </roleRef> @@ -289,18 +289,18 @@ Permission documentation can be found [here](#Permissions). Roles can be referen </document> ``` -## User list +## Actor list -In NAE, user list is a type of data field, that is used for managing access of a set of users (who's ID is in the -given user list) to Petriflow objects and their actions. User list can be defined where other data fields used to be +In NAE, actor list is a type of data field, that is used for managing access of a set of actors (who's ID is in the +given actor list) to Petriflow objects and their actions. Actor list can be defined where other data fields used to be defined, as child element of the root **document** element: ``` <document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://petriflow.com/petriflow.schema.xsd"> ... - <data type="userList"> - <id>user_list_1</id> - <title>User list 1 + + actor_list_1 + Actor list 1 ... @@ -308,41 +308,41 @@ defined, as child element of the root **document** element: The value of this data field can be modified and managed using Actions API, as in case other types of data field. -### User reference +### Actor reference -Defined user lists can be referenced with **userRef** element, this element will contain the definition of permissions. -Permission documentation can be found [here](#Permissions). User list can be referenced as follows: +Defined actor lists can be referenced with **actorRef** element, this element will contain the definition of permissions. +Permission documentation can be found [here](#Permissions). Actor list can be referenced as follows: -- as a child element of the `document` tag for referencing user list on cases: +- as a child element of the `document` tag for referencing actor list on cases: ``` ... - - user_list_1 + + actor_list_1 - false + false true - + ... ``` -- as a child element of the `transition` tag for referencing user list on tasks: +- as a child element of the `transition` tag for referencing actor list on tasks: ``` ... ... - - user_list_1 + + actor_list_1 - false + false true - + ... ... @@ -352,31 +352,31 @@ Permission documentation can be found [here](#Permissions). User list can be ref ## Permissions Permissions can manage access and execution rights to Case and Task objects. These permissions are assigned to user -through **roleRef** and **userRef**. There may be the case, when a user can have multiple role assigned and be present -in multiple user list, and the references of the roles and user lists define the same permission but with other flags ( -e.g. one role reference grants the permission, the other forbids it, one user list reference grants the permission, the other +through **roleRef** and **actorRef**. There may be the case, when a user can have multiple role assigned and be present +in multiple actor lists, and the references of the roles and user lists define the same permission but with other flags ( +e.g. one role reference grants the permission, the other forbids it, one actor list reference grants the permission, the other forbids it). These complex situations are always resolved according to the following rule: -$$((R_{p} \setminus R_{n}) \cup U_{p}) \setminus U_{n}$$ +$$((R_{p} \setminus R_{n}) \cup A_{p}) \setminus A_{n}$$ - $\setminus$ - seminus, e.g. $A \setminus B$ = every element from A that is not in B - $\cup$ - union of sets - $R_{p}$ - set of roles that are assigned to user and define given permission with `true` (grant the permission) - $R_{n}$ - set of roles that are assigned to user and define given permission with `false` (forbid the permission) -- $U_{p}$ - set of user lists that user is part of and define given permission with `true` (grant the permission) -- $U_{n}$ - set of user lists that user is part of and define given permission with `false` (forbid the permission) +- $A_{p}$ - set of actor lists that user is part of and define given permission with `true` (grant the permission) +- $A_{n}$ - set of actor lists that user is part of and define given permission with `false` (forbid the permission) Explained in words: -A user list is stronger than a role and a forbidding/revoking (negative - `false`) association is stronger than a granting (positive - `true`) association. -A user must be granted a permission from at least one source in order to be allowed to perform an operation. -A granting (positive) user list association overrides a forbidding (negative) role association. -A forbidding (negative) user list association overrides any granting (positive) association. +An actor list is stronger than a role and a forbidding/revoking (negative - `false`) association is stronger than a granting (positive - `true`) association. +An actor must be granted a permission from at least one source in order to be allowed to perform an operation. +A granting (positive) actor list association overrides a forbidding (negative) role association. +A forbidding (negative) actor list association overrides any granting (positive) association. There are two types of permissions - case permissions and task permissions. ### Case permissions -In the XML model of process, you can define permissions for Case using **roleRef** and **userRef** inside the root **document** element. +In the XML model of process, you can define permissions for Case using **roleRef** and **actorRef** inside the root **document** element. Each reference element has a child element called **caseLogic**, which can be used to define the permissions for case created from process as follows: @@ -386,20 +386,20 @@ permissions for case created from process as follows: process_role - false + false false false ... - - user_list_1 + + actor_list_1 - true + true true true - + ... ``` @@ -408,23 +408,23 @@ permissions for case created from process as follows: If this permission is set to **true** in **roleRef**, user with this permission is allowed to create cases from the process. If it is **false**, user with this permission cannot create cases from the given process. This permission **cannot -be defined** in a **userRef**. +be defined** in an **actorRef**. #### Delete If this permission is set to **true**, user with this permission is allowed to delete cases created from the process. If it is **false**, user with this permission cannot delete cases created from given process. This permission can be -defined in both **roleRef** and **userRef**. +defined in both **roleRef** and **actorRef**. #### View If this permission is set to **true**, user with this permission can see cases created from the process. If it is **false**, user with this permission cannot see cases created from given process. This permission can be defined in -both **roleRef** and **userRef**. +both **roleRef** and **actorRef**. ### Task permissions -In the XML model of process, you can define permissions for Task using **roleRef** and **userRef** inside the ** +In the XML model of process, you can define permissions for Task using **roleRef** and **actorRef** inside the ** transition** element. Each reference element has a child element called **logic**, which can be used to define the permissions for task created from transition as follows: @@ -437,18 +437,18 @@ permissions for task created from transition as follows: process_role true - false + false true ... - - user_list_1 + + actor_list_1 - false + false true - + ... ... @@ -459,40 +459,40 @@ permissions for task created from transition as follows: If this permission is set to **true**, user with this permission can assign task to themselves created from the transition. If it is **false**, user with this permission cannot assign task to themselves created from the -transition. This permission can be defined in both **roleRef** and **userRef**. +transition. This permission can be defined in both **roleRef** and **actorRef**. #### Cancel If this permission is set to **true**, user with this permission can cancel task created from the transition. If it is **false**, user with this permission cannot cancel task created from the transition. This permission can be defined -in both **roleRef** and **userRef**. +in both **roleRef** and **actorRef**. #### Delegate If this permission is set to **true**, user with this permission can assign task to others created from the transition. If it is **false**, user with this permission cannot assign task to others created from the transition. This -permission can be defined in both **roleRef** and **userRef**. +permission can be defined in both **roleRef** and **actorRef**. #### Finish If this permission is set to **true**, user with this permission can finish task created from the transition. If it is **false**, user with this permission cannot finish task created from the transition. This permission can be defined -in both **roleRef** and **userRef**. +in both **roleRef** and **actorRef**. #### View If this permission is set to **true**, user with this permission can see task created from the transition. If it is **false**, user with this permission cannot see task created from the transition. This permission can be defined in -both **roleRef** and **userRef**. +both **roleRef** and **actorRef**. #### Set If this permission is set to **true**, user with this permission can set data on task created from the transition. If it is **false**, user with this permission cannot set data on task created from the transition. This permission can be -defined in both **roleRef** and **userRef**. +defined in both **roleRef** and **actorRef**. #### Perform It is a shortcut to define **assign, cancel, finish, view** and **set** permissions with single line of code. This -shortcut can be defined in both **roleRef** and **userRef**. A perform permission does not exist by itself, instead it is +shortcut can be defined in both **roleRef** and **actorRef**. A perform permission does not exist by itself, instead it is translated into its components when the process is imported. diff --git a/docs/roles/userlist.md b/docs/roles/userlist.md deleted file mode 100644 index 30fa237c4e7..00000000000 --- a/docs/roles/userlist.md +++ /dev/null @@ -1,110 +0,0 @@ -# UserList and UsersRef - -## UserList - -UserList is a type of data field. Values of this field represent users in system. Some basic information about -this field: - -- this field does not have any init value, because when the process is created or imported, the given user may not exist -- we can add values to this field via actions and using frontend component -- it can serve as definition of permissions for volume of users -- value type of this field is ``UserListFieldValue`` - -```xml - - userList1 - -</data> -``` - -Example action to change value of this field: -```xml -<action trigger="set"> - userList: f.userList1; - - <!-- Setting with list of user IDs --> - change userList value { ["userId1", "userId2"] } - - <!-- Setting with UserListFieldValue --> - change userList value { - new com.netgrif.core.petrinet.domain.dataset.UserListFieldValue( - [ - new com.netgrif.core.petrinet.domain.dataset.UserFieldValue( - "userId1", - "John", - "Doe", - "john@doe.com" - ), - new com.netgrif.core.petrinet.domain.dataset.UserFieldValue( - "userId2", - "Alice", - "Doe", - "alice@doe.com" - ) - ] - ) - } -</action> -``` - -## UserRef - -It is a new property of process and transition in PetriNet. It serves as a roleRef with a difference from it: the -content of the userList can be changed at runtime. - -- userRef references userList defined with its ID -- we define permissions for usersRef in a same way as for roleRef - -```xml -<document> - ... - <data type="userList"> - <id>userList1</id> - <title/> - </data> - ... - <userRef> - <id>userList1</id> - <caseLogic> - <view>true</view> - <delete>true</delete> - </caseLogic> - </userRef> - ... - <transition> - <id>1</id> - <usersRef> - <id>userList1</id> - <logic> - <perform>true</perform> - </logic> - </usersRef> - </transition> -</document> -``` - -## Setting permissions - -If we want to define permission only for a set of users, and we want to change the content of this set runtime, the -userList-usersRef combo is the best way to do so. You have to follow these steps: - -1. Define new data field of type **userList** - required attribute is only the *id* of field. -2. For case permissions, define **usersRef** in *document* tag, for task permission define it in the corresponding * - transition* tag -3. Into *logic* property of usersRef we define the permissions with boolean values - true means enable, false mean - disable the given permission for user. The permissions can be the following: - 1. for cases: - 1. *view* - enable or disable the displaying of cases - 2. *delete* - enable or disable the deletion of cases - 2. for tasks: - 1. *perform* - enable or disable all the permissions - 2. *delegate* - enable or disable delegating tasks - 3. *assign* - enable or disable assign of tasks - 4. *cancel* - enable or disable canceling of tasks - 5. *finish* - enable or disable finish of tasks - -[Permission resolution](roles/permissions.md?id=permissions) - -[UsersRef Petri Net](../_media/roles/usersRef_functions.groovy) - -[UsersRef Functions](../_media/roles/usersRef_net.xml) diff --git a/docs/search/elastic_mapping.md b/docs/search/elastic_mapping.md index d77dd922216..5b65f410ade 100644 --- a/docs/search/elastic_mapping.md +++ b/docs/search/elastic_mapping.md @@ -112,9 +112,9 @@ as _\[Dog, Hund, Pes\]_ in the index. This way, the fields value can be searched Base class for data field mapping. All indexed data variables have these attributes available. -|index|type|value| -|-----|----|-----| -|`dataSet.<fieldID>.fulltextValue`|Text array|value depends on the field type:<br>**boolean**: textual representation of the value<br>**date** & **dateTime**: date formated as ISO-8601 basic local date format<br>**file** & **fileList**: names of the contained files<br>**number**: the value stored as decimal string<br>**text**: the value itself<br>**multichoice** & **enumeration**: all translations of the selected options<br>**multichoiceMap** & **enumerationMap**: all translated values of the selected key-value pairs<br>**user** & **userList**: full name followed by email as a single string for each selected user| +|index|type| value | +|-----|----|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +|`dataSet.<fieldID>.fulltextValue`|Text array| value depends on the field type:<br>**boolean**: textual representation of the value<br>**date** & **dateTime**: date formatted as ISO-8601 basic local date format<br>**file** & **fileList**: names of the contained files<br>**number**: the value stored as decimal string<br>**text**: the value itself<br>**multichoice** & **enumeration**: all translations of the selected options<br>**multichoiceMap** & **enumerationMap**: all translated values of the selected key-value pairs<br>**actor** & **actorList**: full name for each selected actor | ### BooleanField - boolean @@ -157,10 +157,11 @@ its `toString()` value is stored. |-----|----|-----| |`dataSet.<fieldID>.keyValue`|Keyword array|the _key_ part of the selected key-value pairs (i.e. the part stored as the map field value)| -### UserField - user, userList +### ActorField - actor, actorList -|index|type|value| -|-----|----|-----| -|`dataSet.<fieldID>.emailValue`|Text array|emails of the selected users| -|`dataSet.<fieldID>.fullNameValue`|Text array|full names of the selected users| -|`dataSet.<fieldID>.userIdValue`|Long array|IDs of the selected users| \ No newline at end of file +| index |type| value | +|---------------------------------------|----|--------------------------------------| +| `dataSet.<fieldID>.usernameValue` |Text array| usernames of the selected users | +| `dataSet.<fieldID>.fullNameValue` |Text array| full names of the selected actors | +| `dataSet.<fieldID>.actorIdValue` |Text array| IDs of the selected actors | +| `dataSet.<fieldID>.actorRealmIdValue` |Text array| IDs of realms of the selected actors | \ No newline at end of file diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ActorField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ActorField.java new file mode 100644 index 00000000000..debc70d0def --- /dev/null +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ActorField.java @@ -0,0 +1,77 @@ +package com.netgrif.application.engine.objects.elastic.domain; + +import com.netgrif.application.engine.objects.petrinet.domain.dataset.ActorFieldValue; +import com.netgrif.application.engine.objects.petrinet.domain.dataset.GroupFieldValue; +import com.netgrif.application.engine.objects.petrinet.domain.dataset.UserFieldValue; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.IntStream; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +public abstract class ActorField extends DataField { + + protected List<String> usernameValue; + protected List<String> fullNameValue; + protected List<String> actorIdValue; + protected List<String> actorRealmIdValue; + + public ActorField(ActorMappingData mappingData) { + this(List.of(mappingData)); + } + + public ActorField(List<ActorMappingData> mappingDataList) { + super(); + if (mappingDataList == null || mappingDataList.isEmpty()) { + return; + } + + this.usernameValue = new ArrayList<>(); + this.fullNameValue = new ArrayList<>(); + this.actorIdValue = new ArrayList<>(); + this.actorRealmIdValue = new ArrayList<>(); + for (ActorMappingData mappingData : mappingDataList) { + this.fullNameValue.add(mappingData.fullName()); + this.actorIdValue.add(mappingData.actorId()); + this.actorRealmIdValue.add(mappingData.actorRealmId()); + if (mappingData.username() == null) { + this.fulltextValue.add(mappingData.fullName()); + } else { + this.usernameValue.add(mappingData.username()); + super.fulltextValue.add(String.format("%s %s", mappingData.fullName(), mappingData.username())); + } + } + } + + @Override + public Object getValue() { + if (this.actorIdValue != null && this.actorIdValue.size() == 1) { + return buildFieldValue(0); + } else if (this.actorIdValue != null && this.actorIdValue.size() > 1) { + return IntStream.range(0, this.actorIdValue.size()).mapToObj(this::buildFieldValue).toList(); + } + return null; + } + + protected ActorFieldValue buildFieldValue(int idx) { + String username = this.usernameValue.get(idx); + if (username == null) { + return new GroupFieldValue(this.actorIdValue.get(idx), this.actorRealmIdValue.get(idx), this.fullNameValue.get(idx)); + } else { + String fullName = this.fullNameValue.get(idx) != null ? this.fullNameValue.get(idx) : ""; + String[] fullNameSplit = fullName.split(" ", 2); + String firstName = fullNameSplit.length > 0 ? fullNameSplit[0] : ""; + String lastName = fullNameSplit.length > 1 ? fullNameSplit[1] : ""; + return new UserFieldValue(this.actorIdValue.get(idx), this.actorRealmIdValue.get(idx), firstName, lastName, username); + } + } +} + + diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ActorListField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ActorListField.java new file mode 100644 index 00000000000..afb66b2713b --- /dev/null +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ActorListField.java @@ -0,0 +1,17 @@ +package com.netgrif.application.engine.objects.elastic.domain; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public abstract class ActorListField extends ActorField { + + public ActorListField(List<ActorMappingData> actorMappingDataList) { + super(actorMappingDataList); + } +} diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ActorMappingData.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ActorMappingData.java new file mode 100644 index 00000000000..35e9fbc7534 --- /dev/null +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ActorMappingData.java @@ -0,0 +1,3 @@ +package com.netgrif.application.engine.objects.elastic.domain; + +public record ActorMappingData(String actorId, String actorRealmId, String username, String fullName) {} diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/BooleanField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/BooleanField.java index 9e23aa144f7..c45c1fc8083 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/BooleanField.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/BooleanField.java @@ -10,7 +10,7 @@ @EqualsAndHashCode(callSuper = true) public abstract class BooleanField extends DataField { - public Boolean booleanValue; + protected Boolean booleanValue; public BooleanField(Boolean value) { super(value.toString()); @@ -19,6 +19,6 @@ public BooleanField(Boolean value) { @Override public Object getValue() { - return booleanValue; + return this.booleanValue; } } diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ButtonField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ButtonField.java index 3564ddca342..233691679b5 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ButtonField.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ButtonField.java @@ -10,15 +10,21 @@ @EqualsAndHashCode(callSuper = true) public abstract class ButtonField extends DataField { - public Integer buttonValue; + protected Integer buttonValue; public ButtonField(Integer value) { - super(value.toString()); + super(value == null ? null : value.toString()); + this.buttonValue = value; + } + + public void setButtonValue(Integer value) { + this.fulltextValue.clear(); + this.fulltextValue.add(value == null ? null : value.toString()); this.buttonValue = value; } @Override public Object getValue() { - return buttonValue; + return this.buttonValue; } } diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/CaseField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/CaseField.java index 48292624f38..f5007ee46a4 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/CaseField.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/CaseField.java @@ -13,15 +13,15 @@ @EqualsAndHashCode(callSuper = true) public abstract class CaseField extends FieldWithAllowedNetsField { - private List<String> caseValue; + protected List<String> caseValue; - public CaseField(String[] fullTextValue, String[] allowedNets) { - super(fullTextValue, allowedNets); - this.caseValue = Arrays.asList(fullTextValue); + public CaseField(List<String> caseValue, List<String> allowedNets) { + super(caseValue, allowedNets); + this.caseValue = caseValue; } @Override public Object getValue() { - return new ArrayList<>(List.of(fulltextValue)); + return this.caseValue; } } \ No newline at end of file diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/DataField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/DataField.java index 7c054eee54b..816c7cdd416 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/DataField.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/DataField.java @@ -1,29 +1,34 @@ package com.netgrif.application.engine.objects.elastic.domain; -import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import java.io.Serial; import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; @Data @NoArgsConstructor @EqualsAndHashCode -@AllArgsConstructor public abstract class DataField implements Serializable { @Serial private static final long serialVersionUID = 2035013102812591274L; - public String[] fulltextValue; + protected List<String> fulltextValue = new ArrayList<>(); DataField(String fulltextValue) { - this.fulltextValue = new String[1]; - this.fulltextValue[0] = fulltextValue; + this(List.of(fulltextValue)); + } + + DataField(List<String> fulltextValue) { + if (fulltextValue != null) { + this.fulltextValue.addAll(fulltextValue); + } } public Object getValue() { - return (fulltextValue != null && fulltextValue.length > 0) ? fulltextValue[0] : null; + return (!fulltextValue.isEmpty()) ? fulltextValue.getFirst() : null; } } diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/DateField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/DateField.java index 7d30aedcb0e..008cfda5560 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/DateField.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/DateField.java @@ -14,9 +14,8 @@ @EqualsAndHashCode(callSuper = true) public abstract class DateField extends DataField { - public LocalDateTime dateValue; - - public Long timestampValue; + protected LocalDateTime dateValue; + protected Long timestampValue; public DateField(String value, LocalDateTime dateTime) { super(value); @@ -26,6 +25,6 @@ public DateField(String value, LocalDateTime dateTime) { @Override public Object getValue() { - return dateValue; + return this.dateValue; } } diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ElasticCase.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ElasticCase.java index c16316c9671..5147c2880fb 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ElasticCase.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ElasticCase.java @@ -61,21 +61,21 @@ public abstract class ElasticCase implements Serializable { private Map<String, Map<String, Boolean>> permissions; - private Map<String, Map<String, Boolean>> userRefs; + private Map<String, Map<String, Boolean>> actorRefs; - private Map<String, Map<String, Boolean>> users; + private Map<String, Map<String, Boolean>> actors; private Set<String> enabledRoles; private Set<String> viewRoles; - private Set<String> viewUserRefs; + private Set<String> viewActorRefs; private Set<String> negativeViewRoles; - private Set<String> viewUsers; + private Set<String> viewActors; - private Set<String> negativeViewUsers; + private Set<String> negativeViewActors; private Map<String, String> tags; @@ -97,10 +97,10 @@ public ElasticCase(Case useCase) { tasks = useCase.getTasks() == null ? Collections.emptySet() : useCase.getTasks().stream().map(tp -> new ElasticTaskPair(tp.getTask(), tp.getTransition())).collect(Collectors.toSet()); enabledRoles = new HashSet<>(useCase.getEnabledRoles()); viewRoles = new HashSet<>(useCase.getViewRoles()); - viewUserRefs = new HashSet<>(useCase.getViewUserRefs()); + viewActorRefs = new HashSet<>(useCase.getViewActorRefs()); negativeViewRoles = new HashSet<>(useCase.getNegativeViewRoles()); - viewUsers = new HashSet<>(useCase.getViewUsers()); - negativeViewUsers = new HashSet<>(useCase.getNegativeViewUsers()); + viewActors = new HashSet<>(useCase.getViewActors()); + negativeViewActors = new HashSet<>(useCase.getNegativeViewActors()); tags = new HashMap<>(useCase.getTags()); dataSet = new HashMap<>(); @@ -116,10 +116,10 @@ public void update(ElasticCase useCase) { tasks = useCase.getTasks(); enabledRoles = useCase.getEnabledRoles(); viewRoles = useCase.getViewRoles(); - viewUserRefs = useCase.getViewUserRefs(); + viewActorRefs = useCase.getViewActorRefs(); negativeViewRoles = useCase.getNegativeViewRoles(); - viewUsers = useCase.getViewUsers(); - negativeViewUsers = useCase.getNegativeViewUsers(); + viewActors = useCase.getViewActors(); + negativeViewActors = useCase.getNegativeViewActors(); tags = useCase.getTags(); dataSet = useCase.getDataSet(); diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ElasticTask.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ElasticTask.java index db7babc19e7..1d1ae3fb7bc 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ElasticTask.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ElasticTask.java @@ -1,9 +1,5 @@ package com.netgrif.application.engine.objects.elastic.domain; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; import com.netgrif.application.engine.objects.petrinet.domain.I18nString; import com.netgrif.application.engine.objects.workflow.domain.Task; import lombok.*; @@ -57,19 +53,19 @@ public abstract class ElasticTask implements Serializable { private Map<String, Map<String, Boolean>> roles; - private Map<String, Map<String, Boolean>> userRefs; + private Map<String, Map<String, Boolean>> actorRefs; - private Map<String, Map<String, Boolean>> users; + private Map<String, Map<String, Boolean>> actors; - private Set<String> viewUserRefs; + private Set<String> viewActorRefs; private Set<String> viewRoles; private Set<String> negativeViewRoles; - private Set<String> viewUsers; + private Set<String> viewActors; - private Set<String> negativeViewUsers; + private Set<String> negativeViewActors; private String icon; @@ -97,13 +93,13 @@ public ElasticTask(Task task) { this.userRealmId = task.getUserRealmId(); this.startDate = task.getStartDate(); this.roles = task.getRoles(); - this.userRefs = task.getUserRefs(); - this.users = task.getUsers(); + this.actorRefs = task.getActorRefs(); + this.actors = task.getActors(); this.viewRoles = new HashSet<>(task.getViewRoles()); - this.viewUserRefs = new HashSet<>(task.getViewUserRefs()); + this.viewActorRefs = new HashSet<>(task.getViewActorRefs()); this.negativeViewRoles = new HashSet<>(task.getNegativeViewRoles()); - this.viewUsers = new HashSet<>(task.getViewUsers()); - this.negativeViewUsers = new HashSet<>(task.getNegativeViewUsers()); + this.viewActors = new HashSet<>(task.getViewActors()); + this.negativeViewActors = new HashSet<>(task.getNegativeViewActors()); this.assignPolicy = task.getAssignPolicy().toString(); this.dataFocusPolicy = task.getDataFocusPolicy().toString(); this.finishPolicy = task.getFinishPolicy().toString(); @@ -121,10 +117,10 @@ public void update(ElasticTask task) { this.startDate = task.getStartDate(); this.roles = task.getRoles(); this.viewRoles = task.getViewRoles(); - this.viewUserRefs = task.getViewUserRefs(); + this.viewActorRefs = task.getViewActorRefs(); this.negativeViewRoles = task.getNegativeViewRoles(); - this.viewUsers = task.getViewUsers(); - this.negativeViewUsers = task.getNegativeViewUsers(); + this.viewActors = task.getViewActors(); + this.negativeViewActors = task.getNegativeViewActors(); this.tags = task.getTags(); } } diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/FieldWithAllowedNetsField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/FieldWithAllowedNetsField.java index 4194ba0f812..6cfa59c48d8 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/FieldWithAllowedNetsField.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/FieldWithAllowedNetsField.java @@ -12,14 +12,14 @@ @EqualsAndHashCode(callSuper = true) public abstract class FieldWithAllowedNetsField extends DataField { - public String[] allowedNets; + protected List<String> allowedNets; - public FieldWithAllowedNetsField(String fullTextValue, String[] allowedNets) { + public FieldWithAllowedNetsField(String fullTextValue, List<String> allowedNets) { super(fullTextValue); this.allowedNets = allowedNets; } - public FieldWithAllowedNetsField(String[] fullTextValue, String[] allowedNets) { + public FieldWithAllowedNetsField(List<String> fullTextValue, List<String> allowedNets) { super(fullTextValue); this.allowedNets = allowedNets; } diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/FileField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/FileField.java index 875c5740800..78abe5501ab 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/FileField.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/FileField.java @@ -6,50 +6,51 @@ import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; -import java.util.Arrays; +import java.util.ArrayList; +import java.util.List; import java.util.stream.IntStream; -import java.util.stream.Stream; @Data @NoArgsConstructor @EqualsAndHashCode(callSuper = true) public abstract class FileField extends DataField { - public String[] filePath; + protected List<String> filePath; + protected List<String> fileNameValue; + protected List<String> fileExtensionValue; - public String[] fileNameValue; - - public String[] fileExtensionValue; - - public FileField(FileFieldValue value) { - super(value.getName()); - this.filePath = new String[1]; - this.fileNameValue = new String[1]; - this.fileExtensionValue = new String[1]; - FileNameAndExtension extracted = this.extractFileExtensionFromName(value.getName()); - this.filePath[0] = value.getPath(); - this.fileNameValue[0] = extracted.name; - this.fileExtensionValue[0] = extracted.extension; + public FileField(FileFieldValue fileFieldValue) { + this(fileFieldValue == null ? null : List.of(fileFieldValue)); } - public FileField(FileFieldValue[] values) { - super(new String[values.length]); - this.fileNameValue = new String[values.length]; - this.fileExtensionValue = new String[values.length]; - for (int i = 0; i < values.length; i++) { - FileNameAndExtension extracted = this.extractFileExtensionFromName(values[i].getName()); - this.fileNameValue[i] = extracted.name; - this.fileExtensionValue[i] = extracted.extension; - super.fulltextValue[i] = values[i].getName(); + public FileField(List<FileFieldValue> fileFieldValues) { + if (fileFieldValues == null || fileFieldValues.isEmpty()) { + return; + } + this.fileNameValue = new ArrayList<>(); + this.fileExtensionValue = new ArrayList<>(); + this.filePath = new ArrayList<>(); + for (FileFieldValue fileFieldValue : fileFieldValues) { + if (fileFieldValue == null) { + continue; + } + FileNameAndExtension extracted = this.extractFileExtensionFromName(fileFieldValue.getName()); + this.fileNameValue.add(extracted.name); + this.fileExtensionValue.add(extracted.extension); + this.fulltextValue.add(fileFieldValue.getName()); + this.filePath.add(fileFieldValue.getPath()); } } @Override public Object getValue() { - if (fileNameValue != null && fileNameValue.length == 1) { - return new FileFieldValue(fileNameValue[0] + "." + fileExtensionValue[0], filePath[0]); - } else if (fileNameValue != null && fileNameValue.length > 1) { - return IntStream.range(0, fileNameValue.length).mapToObj(i -> new FileFieldValue(fileNameValue[i] + "." + fileExtensionValue[i], filePath[i])).toList(); + if (this.fileNameValue != null && this.fileNameValue.size() == 1) { + return new FileFieldValue(nameWithExtension(this.fileNameValue.getFirst(), this.fileExtensionValue.getFirst()), + this.filePath.getFirst()); + } else if (this.fileNameValue != null && this.fileNameValue.size() > 1) { + return IntStream.range(0, this.fileNameValue.size()) + .mapToObj(i -> new FileFieldValue(nameWithExtension(this.fileNameValue.get(i), this.fileExtensionValue.get(i)), + this.filePath.get(i))).toList(); } return null; } @@ -62,6 +63,13 @@ private FileNameAndExtension extractFileExtensionFromName(String filename) { return new FileNameAndExtension(filename, null); } + private static String nameWithExtension(String fileName, String extension) { + if (extension == null || extension.isEmpty()) { + return fileName; + } + return fileName + "." + extension; + } + @AllArgsConstructor private static class FileNameAndExtension { public String name; diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/FilterField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/FilterField.java index 1a4a02bd587..5eb8622a89a 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/FilterField.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/FilterField.java @@ -5,6 +5,7 @@ import lombok.NoArgsConstructor; import java.util.HashMap; +import java.util.List; import java.util.Map; @Data @@ -12,9 +13,9 @@ @EqualsAndHashCode(callSuper = true) public abstract class FilterField extends FieldWithAllowedNetsField { - public Map<String, Object> filterMetadata; + protected Map<String, Object> filterMetadata; - public FilterField(String fullTextValue, String[] allowedNets, Map<String, Object> filterMetadata) { + public FilterField(String fullTextValue, List<String> allowedNets, Map<String, Object> filterMetadata) { super(fullTextValue, allowedNets); this.filterMetadata = filterMetadata != null ? filterMetadata : new HashMap<>(); } diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/I18nField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/I18nField.java index fa6b590f4cf..5f526e4c022 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/I18nField.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/I18nField.java @@ -5,29 +5,26 @@ import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; -import java.util.Map; -import java.util.Set; +import java.util.*; @Data @NoArgsConstructor @EqualsAndHashCode(callSuper = true) public abstract class I18nField extends TextField { - public String[] keyValue; - - public Map<String, String> translations; + protected Set<String> keyValue; + protected Map<String, String> translations; public I18nField(Set<String> keys, Set<String> values, Map<String, String> translations) { - super(new String[0]); - this.keyValue = keys.toArray(new String[0]); - this.textValue = values.toArray(new String[0]); + super(new ArrayList<>(values)); + this.keyValue = keys; this.translations = translations; } @Override public Object getValue() { - if (textValue != null && textValue.length > 0) { - return new I18nString(textValue[0], translations); + if (this.textValue != null && !this.textValue.isEmpty()) { + return new I18nString(this.textValue.getFirst(), this.translations); } return null; } diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/MapField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/MapField.java index d57d980ad40..5e684ab1c90 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/MapField.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/MapField.java @@ -12,32 +12,34 @@ @EqualsAndHashCode(callSuper = true) public abstract class MapField extends TextField { - public String[] keyValue; - public Map<String, I18nString> keyValueTranslations; + protected List<String> keyValue; + protected Map<String, I18nString> keyValueTranslations; public MapField(Map.Entry<String, I18nString> valueTranslationPair) { this(List.of(valueTranslationPair)); } public MapField(List<Map.Entry<String, I18nString>> valueTranslationPairs) { - super(new String[0]); - this.keyValue = new String[valueTranslationPairs.size()]; + if (valueTranslationPairs == null || valueTranslationPairs.isEmpty()) { + return; + } List<String> values = new ArrayList<>(); + this.keyValue = new ArrayList<>(); this.keyValueTranslations = new HashMap<>(); - for (int i = 0; i < valueTranslationPairs.size(); i++) { - this.keyValue[i] = valueTranslationPairs.get(i).getKey(); - values.addAll(I18nStringUtils.collectTranslations(valueTranslationPairs.get(i).getValue())); - this.keyValueTranslations.put(valueTranslationPairs.get(i).getKey(), valueTranslationPairs.get(i).getValue()); + for (Map.Entry<String, I18nString> valueTranslationPair : valueTranslationPairs) { + this.keyValue.add(valueTranslationPair.getKey()); + values.addAll(I18nStringUtils.collectTranslations(valueTranslationPair.getValue())); + this.keyValueTranslations.put(valueTranslationPair.getKey(), valueTranslationPair.getValue()); } - this.textValue = values.toArray(new String[0]); - this.fulltextValue = values.toArray(new String[0]); + this.textValue = values; + this.fulltextValue = values; } public Object getValue() { - if (keyValue != null && keyValue.length == 1) { - return keyValue[0]; - } else if (keyValue != null && keyValue.length > 1) { - return new LinkedHashSet<>(Arrays.asList(keyValue)); + if (this.keyValue != null && this.keyValue.size() == 1) { + return this.keyValue.getFirst(); + } else if (this.keyValue != null && this.keyValue.size() > 1) { + return new LinkedHashSet<>(this.keyValue); } return null; } diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/NumberField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/NumberField.java index 21cf9441285..c918841a519 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/NumberField.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/NumberField.java @@ -10,7 +10,7 @@ @EqualsAndHashCode(callSuper = true) public abstract class NumberField extends DataField { - public Double numberValue; + protected Double numberValue; public NumberField(Double value) { super(value.toString()); @@ -18,6 +18,6 @@ public NumberField(Double value) { } public Object getValue() { - return numberValue; + return this.numberValue; } } diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/StringCollectionField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/StringCollectionField.java index c4b4cb972c2..f289a8f654b 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/StringCollectionField.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/StringCollectionField.java @@ -5,14 +5,16 @@ import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; +import java.util.List; + @Data @NoArgsConstructor @EqualsAndHashCode(callSuper = true) -public abstract class StringCollectionField extends TextField { +public abstract class StringCollectionField extends DataField { - public String[] collectionValue; + protected List<String> collectionValue; - public StringCollectionField(String[] values) { + public StringCollectionField(List<String> values) { super(values); this.collectionValue = values; } diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/TextField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/TextField.java index 83a85604982..7879435de0a 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/TextField.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/TextField.java @@ -4,20 +4,20 @@ import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; +import java.util.List; + @Data @NoArgsConstructor @EqualsAndHashCode(callSuper = true) public abstract class TextField extends DataField { - public String[] textValue; + protected List<String> textValue; public TextField(String value) { - super(value); - this.textValue = new String[1]; - this.textValue[0] = value; + this(value != null ? List.of(value) : List.of()); } - public TextField(String[] values) { + public TextField(List<String> values) { super(values); this.textValue = values; } diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/UserField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/UserField.java deleted file mode 100644 index e08b3852f2a..00000000000 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/UserField.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.netgrif.application.engine.objects.elastic.domain; - -import com.netgrif.application.engine.objects.petrinet.domain.dataset.UserFieldValue; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -import java.util.stream.IntStream; - -@Data -@NoArgsConstructor -@AllArgsConstructor -@EqualsAndHashCode(callSuper = true) -public abstract class UserField extends DataField { - - // TODO JOFO: put group into userField - private String[] usernameValue; - - private String[] fullNameValue; - - private String[] userIdValue; - - private String[] userRealmIdValue; - - public UserField(UserMappingData value) { - super(String.format("%s %s", value.fullName, value.username)); - this.usernameValue = new String[1]; - this.fullNameValue = new String[1]; - this.userIdValue = new String[1]; - this.userRealmIdValue = new String[1]; - this.usernameValue[0] = value.username; - this.fullNameValue[0] = value.fullName; - this.userIdValue[0] = value.userId; - this.userRealmIdValue[0] = value.userRealmId; - } - - public UserField(UserMappingData[] values) { - super(new String[values.length]); - this.usernameValue = new String[values.length]; - this.fullNameValue = new String[values.length]; - this.userIdValue = new String[values.length]; - this.userRealmIdValue = new String[values.length]; - for (int i = 0; i < values.length; i++) { - this.usernameValue[i] = values[i].username; - this.fullNameValue[i] = values[i].fullName; - this.userIdValue[i] = values[i].userId; - this.userRealmIdValue[i] = values[i].userRealmId; - super.fulltextValue[i] = String.format("%s %s", values[i].fullName, values[i].username); - } - } - - @Override - public Object getValue() { - if (userIdValue != null && userIdValue.length == 1) { - String fullName = fullNameValue[0] != null ? fullNameValue[0] : ""; - String[] fullNameSplit = fullName.split(" ", 2); - String firstName = fullNameSplit.length > 0 ? fullNameSplit[0] : ""; - String lastName = fullNameSplit.length > 1 ? fullNameSplit[1] : ""; - return new UserFieldValue(userIdValue[0], userRealmIdValue[0], firstName, lastName, usernameValue[0]); - } else if (userIdValue != null && userIdValue.length > 1) { - return IntStream.range(0, userIdValue.length).mapToObj(i -> { - String fullName = fullNameValue[i] != null ? fullNameValue[i] : ""; - String[] fullNameSplit = fullName.split(" ", 2); - String firstName = fullNameSplit.length > 0 ? fullNameSplit[0] : ""; - String lastName = fullNameSplit.length > 1 ? fullNameSplit[1] : ""; - return new UserFieldValue(userIdValue[i], userRealmIdValue[i], firstName, lastName, usernameValue[i]); - }).toList(); - } - return null; - } - - @AllArgsConstructor - public static class UserMappingData { - public String userId; - public String userRealmId; - public String username; - public String fullName; - } -} - - diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/UserListField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/UserListField.java deleted file mode 100644 index 1693fa5c2b8..00000000000 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/UserListField.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.netgrif.application.engine.objects.elastic.domain; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -@AllArgsConstructor -@EqualsAndHashCode(callSuper = true) -public abstract class UserListField extends UserField { - - private String[] usernameValue; - - private String[] fullNameValue; - - private String[] userIdValue; - - private String[] userRealmIdValue; - - public UserListField(UserMappingData[] values) { - super(values); - this.usernameValue = new String[values.length]; - this.fullNameValue = new String[values.length]; - this.userIdValue = new String[values.length]; - this.userRealmIdValue = new String[values.length]; - for (int i = 0; i < values.length; i++) { - this.usernameValue[i] = values[i].username; - this.fullNameValue[i] = values[i].fullName; - this.userIdValue[i] = values[i].userId; - this.userRealmIdValue[i] = values[i].userRealmId; - super.fulltextValue[i] = String.format("%s %s", values[i].fullName, values[i].username); - } - } - -} diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/PetriNet.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/PetriNet.java index a8b2fa447cd..3dc49d4dee9 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/PetriNet.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/PetriNet.java @@ -118,7 +118,7 @@ public abstract class PetriNet extends PetriNetObject { @Getter @Setter - private Map<String, Map<String, Boolean>> userRefs; + private Map<String, Map<String, Boolean>> actorRefs; @Getter @Setter @@ -154,7 +154,7 @@ public PetriNet() { processEvents = new LinkedHashMap<>(); caseEvents = new LinkedHashMap<>(); permissions = new HashMap<>(); - userRefs = new HashMap<>(); + actorRefs = new HashMap<>(); functions = new LinkedList<>(); tags = new HashMap<>(); } @@ -184,7 +184,7 @@ public PetriNet(PetriNet petriNet) { this.processEvents = petriNet.getProcessEvents(); this.caseEvents = petriNet.getCaseEvents(); this.permissions = petriNet.getPermissions(); - this.userRefs = petriNet.getUserRefs(); + this.actorRefs = petriNet.getActorRefs(); this.functions.addAll(petriNet.getFunctions()); this.tags = petriNet.getTags(); this.initialized = true; @@ -223,11 +223,14 @@ public void addFunction(Function function) { functions.add(function); } - public void addUserPermission(String usersRefId, Map<String, Boolean> permissions) { - if (this.userRefs.containsKey(usersRefId) && this.userRefs.get(usersRefId) != null) { - this.userRefs.get(usersRefId).putAll(permissions); + public void addActorPermission(String actorFieldId, Map<String, Boolean> permissions) { + if (permissions == null || permissions.isEmpty()) { + return; + } + if (this.actorRefs.containsKey(actorFieldId) && this.actorRefs.get(actorFieldId) != null) { + this.actorRefs.get(actorFieldId).putAll(permissions); } else { - this.userRefs.put(usersRefId, permissions); + this.actorRefs.put(actorFieldId, permissions); } } diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/Transition.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/Transition.java index 5522ed50535..9af5b43166b 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/Transition.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/Transition.java @@ -40,7 +40,7 @@ public class Transition extends Node { @Getter @Setter - private Map<String, Map<String, Boolean>> userRefs; + private Map<String, Map<String, Boolean>> actorRefs; @Getter @Setter @@ -93,7 +93,7 @@ public Transition() { super(); dataSet = new LinkedHashMap<>(); roles = new HashMap<>(); - userRefs = new HashMap<>(); + actorRefs = new HashMap<>(); triggers = new LinkedList<>(); negativeViewRoles = new LinkedList<>(); dataGroups = new LinkedHashMap<>(); @@ -134,11 +134,15 @@ public void addNegativeViewRole(String roleId) { negativeViewRoles.add(roleId); } - public void addUserRef(String userRefId, Map<String, Boolean> permissions) { - if (userRefs.containsKey(userRefId) && userRefs.get(userRefId) != null) { - userRefs.get(userRefId).putAll(permissions); + public void addActorRef(String actorFieldId, Map<String, Boolean> permissions) { + if (actorFieldId == null) { + throw new IllegalArgumentException("actorFieldId must not be null"); + } + Map<String, Boolean> safePermissions = (permissions == null) ? new HashMap<>() : permissions; + if (actorRefs.containsKey(actorFieldId) && actorRefs.get(actorFieldId) != null) { + actorRefs.get(actorFieldId).putAll(safePermissions); } else { - userRefs.put(userRefId, permissions); + actorRefs.put(actorFieldId, safePermissions); } } @@ -258,7 +262,7 @@ public Transition(Transition transition) { this.setDataSet(transition.dataSet == null ? null : transition.dataSet.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (x, y) -> y.clone(), LinkedHashMap::new))); this.setRoles(transition.roles == null ? null : transition.roles.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> new HashMap<>(e.getValue())))); this.setNegativeViewRoles(new ArrayList<>(transition.negativeViewRoles)); - this.setUserRefs(transition.userRefs == null ? null : transition.userRefs.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> new HashMap<>(e.getValue())))); + this.setActorRefs(transition.actorRefs == null ? null : transition.actorRefs.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> new HashMap<>(e.getValue())))); this.setTriggers(transition.triggers == null ? null : transition.triggers.stream().map(Trigger::clone).collect(Collectors.toList())); this.setLayout(transition.layout == null ? null : transition.layout.clone()); this.setPriority(transition.priority); diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/UserListField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/ActorField.java similarity index 54% rename from nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/UserListField.java rename to nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/ActorField.java index 727d0a411c1..9837e5ec86c 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/UserListField.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/ActorField.java @@ -9,30 +9,31 @@ @Setter @Getter -public class UserListField extends Field<UserListFieldValue> { +public class ActorField extends Field<ActorFieldValue> { private Set<String> roles; - public UserListField() { - super(); - this.roles = new HashSet<>(); + public ActorField() { + this(new HashSet<>()); + } + + public ActorField(String[] roles) { + this(new HashSet<>(Arrays.asList(roles))); } - public UserListField(String[] values) { - this(); - if (values != null) { - this.roles.addAll(Arrays.asList(values)); - } + public ActorField(Set<String> roles) { + super(); + this.roles = roles == null ? new HashSet<>() : roles; } @Override public FieldType getType() { - return FieldType.USERLIST; + return FieldType.ACTOR; } @Override public Field<?> clone() { - UserListField clone = new UserListField(); + ActorField clone = new ActorField(); super.clone(clone); clone.setRoles(this.roles); return clone; diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/ActorFieldValue.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/ActorFieldValue.java new file mode 100644 index 00000000000..1c13aa25659 --- /dev/null +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/ActorFieldValue.java @@ -0,0 +1,31 @@ +package com.netgrif.application.engine.objects.petrinet.domain.dataset; + +import com.netgrif.application.engine.objects.elastic.domain.ActorMappingData; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Objects; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +public abstract class ActorFieldValue implements Serializable { + + @Serial + private static final long serialVersionUID = -6421919316454802530L; + + protected String id; + protected String realmId; + + public abstract String getFullName(); + public abstract String toString(); + public abstract boolean equals(Object obj); + public abstract ActorMappingData buildMappingData(); + + public int hashCode() { + return Objects.hashCode(this.id); + } +} diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/ActorListField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/ActorListField.java new file mode 100644 index 00000000000..75ce25fb160 --- /dev/null +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/ActorListField.java @@ -0,0 +1,41 @@ +package com.netgrif.application.engine.objects.petrinet.domain.dataset; + +import lombok.Getter; +import lombok.Setter; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +@Setter +@Getter +public class ActorListField extends Field<ActorListFieldValue> { + + private Set<String> roles; + + public ActorListField() { + this(new HashSet<>()); + } + + public ActorListField(String[] roles) { + this(roles == null ? new HashSet<>() : new HashSet<>(Arrays.asList(roles))); + } + + public ActorListField(Set<String> roles) { + super(); + this.roles = roles == null ? new HashSet<>() : roles; + } + + @Override + public FieldType getType() { + return FieldType.ACTORLIST; + } + + @Override + public Field<?> clone() { + ActorListField clone = new ActorListField(); + super.clone(clone); + clone.setRoles(this.roles == null ? null : new HashSet<>(this.roles)); + return clone; + } +} diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/ActorListFieldValue.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/ActorListFieldValue.java new file mode 100644 index 00000000000..3b736de7a36 --- /dev/null +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/ActorListFieldValue.java @@ -0,0 +1,39 @@ +package com.netgrif.application.engine.objects.petrinet.domain.dataset; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.Set; + +public class ActorListFieldValue implements Serializable { + + @Serial + private static final long serialVersionUID = 5228212326431238485L; + private Set<ActorFieldValue> actorValues; + + public ActorListFieldValue() { + this(new LinkedHashSet<>()); + } + + public ActorListFieldValue(Collection<ActorFieldValue> actorValues) { + this(new LinkedHashSet<>(actorValues)); + } + + public ActorListFieldValue(LinkedHashSet<ActorFieldValue> actorValues) { + this.actorValues = actorValues; + } + + public LinkedHashSet<ActorFieldValue> getActorValues() { + return (LinkedHashSet<ActorFieldValue>) actorValues; + } + + public void setActorValues(Collection<ActorFieldValue> actorValues) { + this.actorValues = new LinkedHashSet<>(actorValues); + } + + @Override + public String toString() { + return actorValues.toString(); + } +} diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/FieldType.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/FieldType.java index 3b9280d09ac..df99a1017e6 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/FieldType.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/FieldType.java @@ -15,8 +15,8 @@ public enum FieldType { MULTICHOICE("multichoice"), MULTICHOICE_MAP("multichoice_map"), NUMBER("number"), - USER("user"), - USERLIST("userList"), + ACTOR("actor"), + ACTORLIST("actorList"), TABULAR("tabular"), CASE_REF("caseRef"), DATETIME("dateTime"), diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/GroupFieldValue.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/GroupFieldValue.java new file mode 100644 index 00000000000..070076b844a --- /dev/null +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/GroupFieldValue.java @@ -0,0 +1,45 @@ +package com.netgrif.application.engine.objects.petrinet.domain.dataset; + +import com.netgrif.application.engine.objects.auth.domain.Group; +import com.netgrif.application.engine.objects.elastic.domain.ActorMappingData; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +public class GroupFieldValue extends ActorFieldValue { + + protected String name; + + public GroupFieldValue(String id, String realmId, String name) { + super(id, realmId); + this.name = name; + } + + public GroupFieldValue(Group group) { + this(group.getStringId(), group.getRealmId(), group.getDisplayName()); + } + + @Override + public String getFullName() { + return name; + } + + @Override + public String toString() { + return "GroupFieldValue{" + ", name='" + name + "'}"; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof GroupFieldValue)) { + return false; + } + return this.id != null && ((GroupFieldValue) obj).getId() != null && this.id.equals(((GroupFieldValue) obj).getId()); + } + + @Override + public ActorMappingData buildMappingData() { + return new ActorMappingData(this.id, this.realmId, null, this.getFullName()); + } +} diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/UserField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/UserField.java deleted file mode 100644 index e37975f5688..00000000000 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/UserField.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.netgrif.application.engine.objects.petrinet.domain.dataset; - -import lombok.Getter; -import lombok.Setter; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -@Setter -@Getter -public class UserField extends Field<UserFieldValue> { - private Set<String> roles; - - public UserField() { - super(); - this.roles = new HashSet<>(); - } - - public UserField(String[] values) { - this(); - if (values != null) { - this.roles.addAll(Arrays.asList(values)); - } - } - - @Override - public FieldType getType() { - return FieldType.USER; - } - - @Override - public Field clone() { - UserField clone = new UserField(); - super.clone(clone); - clone.setRoles(this.roles); - return clone; - } -} diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/UserFieldValue.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/UserFieldValue.java index 705db48500c..7e262b687a3 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/UserFieldValue.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/UserFieldValue.java @@ -1,27 +1,20 @@ package com.netgrif.application.engine.objects.petrinet.domain.dataset; import com.netgrif.application.engine.objects.auth.domain.AbstractUser; +import com.netgrif.application.engine.objects.elastic.domain.ActorMappingData; import lombok.Getter; import lombok.NoArgsConstructor; -import java.io.Serial; -import java.io.Serializable; - @Getter @NoArgsConstructor -public class UserFieldValue implements Serializable { +public class UserFieldValue extends ActorFieldValue { - @Serial - private static final long serialVersionUID = 5228212326436828485L; - protected String id; - protected String realmId; protected String firstName; protected String lastName; protected String username; public UserFieldValue(String id, String realmId, String firstName, String lastName, String username) { - this.id = id; - this.realmId = realmId; + super(id, realmId); this.firstName = firstName; this.lastName = lastName; this.username = username; @@ -31,6 +24,7 @@ public UserFieldValue(AbstractUser user) { this(user.getStringId(), user.getRealmId(), user.getFirstName(), user.getLastName(), user.getUsername()); } + @Override public String getFullName() { return firstName + " " + lastName; } @@ -40,10 +34,6 @@ public String toString() { return "UserFieldValue{" + ", name='" + firstName + "'" + ", surname='" + lastName + "'" + ", username='" + username + "'" + "}"; } - public int hashCode() { - return this.id.hashCode(); - } - @Override public boolean equals(Object obj) { if (!(obj instanceof UserFieldValue)) { @@ -51,4 +41,9 @@ public boolean equals(Object obj) { } return this.id != null && ((UserFieldValue) obj).getId() != null && this.id.equals(((UserFieldValue) obj).getId()); } + + @Override + public ActorMappingData buildMappingData() { + return new ActorMappingData(this.id, this.realmId, this.username, this.getFullName()); + } } diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/UserListFieldValue.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/UserListFieldValue.java deleted file mode 100644 index 2f56e0e9f7e..00000000000 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/UserListFieldValue.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.netgrif.application.engine.objects.petrinet.domain.dataset; - -import java.io.Serial; -import java.io.Serializable; -import java.util.Collection; -import java.util.LinkedHashSet; -import java.util.Set; - -public class UserListFieldValue implements Serializable { - - @Serial - private static final long serialVersionUID = 5228212326431238485L; - private Set<UserFieldValue> userValues; - - public UserListFieldValue() { - this.userValues = new LinkedHashSet<UserFieldValue>(); - } - - public UserListFieldValue(Collection<UserFieldValue> userValues) { - this(); - this.userValues = new LinkedHashSet<UserFieldValue>(userValues); - } - - public LinkedHashSet<UserFieldValue> getUserValues() { - return (LinkedHashSet<UserFieldValue>) userValues; - } - - public void setUserValues(Collection<UserFieldValue> userValues) { - this.userValues = new LinkedHashSet<UserFieldValue>(userValues); - } - - @Override - public String toString() { - return userValues.toString(); - } -} diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/localised/LocalisedFieldFactory.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/localised/LocalisedFieldFactory.java index 6de69d25858..310fa8fddf0 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/localised/LocalisedFieldFactory.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/localised/LocalisedFieldFactory.java @@ -23,10 +23,10 @@ public static LocalisedField from(Field field, Locale locale) { return fromDateTime((DateTimeField) field, locale); } else if (field instanceof BooleanField) { return fromBoolean((BooleanField) field, locale); - } else if (field instanceof UserField) { - return fromUser((UserField) field, locale); - } else if (field instanceof UserListField) { - return fromUserList((UserListField) field, locale); + } else if (field instanceof ActorField) { + return fromUser((ActorField) field, locale); + } else if (field instanceof ActorListField) { + return fromUserList((ActorListField) field, locale); } else if (field instanceof EnumerationMapField) { return fromEnumerationMap((EnumerationMapField) field, locale); } else if (field instanceof MultichoiceMapField) { @@ -68,11 +68,11 @@ private static LocalisedField fromBoolean(BooleanField field, Locale locale) { return new LocalisedBooleanField(field, locale); } - private static LocalisedField fromUser(UserField field, Locale locale) { + private static LocalisedField fromUser(ActorField field, Locale locale) { return new LocalisedUserField(field, locale); } - private static LocalisedField fromUserList(UserListField field, Locale locale) { + private static LocalisedField fromUserList(ActorListField field, Locale locale) { return new LocalisedUserListField(field, locale); } diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/localised/LocalisedUserField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/localised/LocalisedUserField.java index 40b92570ecb..9c677087eff 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/localised/LocalisedUserField.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/localised/LocalisedUserField.java @@ -1,6 +1,6 @@ package com.netgrif.application.engine.objects.petrinet.domain.dataset.localised; -import com.netgrif.application.engine.objects.petrinet.domain.dataset.UserField; +import com.netgrif.application.engine.objects.petrinet.domain.dataset.ActorField; import lombok.Data; import lombok.EqualsAndHashCode; @@ -13,7 +13,7 @@ public class LocalisedUserField extends LocalisedField { private Set<String> roles; - public LocalisedUserField(UserField field, Locale locale) { + public LocalisedUserField(ActorField field, Locale locale) { super(field, locale); this.roles = field.getRoles(); } diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/localised/LocalisedUserListField.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/localised/LocalisedUserListField.java index b6a13bacb2e..76aaed5a3cf 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/localised/LocalisedUserListField.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/petrinet/domain/dataset/localised/LocalisedUserListField.java @@ -1,6 +1,6 @@ package com.netgrif.application.engine.objects.petrinet.domain.dataset.localised; -import com.netgrif.application.engine.objects.petrinet.domain.dataset.UserListField; +import com.netgrif.application.engine.objects.petrinet.domain.dataset.ActorListField; import lombok.Data; import lombok.EqualsAndHashCode; @@ -13,7 +13,7 @@ public class LocalisedUserListField extends LocalisedField { private Set<String> roles; - public LocalisedUserListField(UserListField field, Locale locale) { + public LocalisedUserListField(ActorListField field, Locale locale) { super(field, locale); this.roles = field.getRoles(); } diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/workflow/domain/Case.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/workflow/domain/Case.java index 34c21683987..85636c38a9b 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/workflow/domain/Case.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/workflow/domain/Case.java @@ -97,27 +97,27 @@ public abstract class Case implements Serializable { private Map<String, Map<String, Boolean>> permissions; @Setter - private Map<String, Map<String, Boolean>> userRefs; + private Map<String, Map<String, Boolean>> actorRefs; @Setter - private Map<String, Map<String, Boolean>> users; + private Map<String, Map<String, Boolean>> actors; @Setter private List<String> viewRoles; @Setter @JsonIgnore - private List<String> viewUserRefs; + private List<String> viewActorRefs; @Setter @JsonIgnore - private List<String> viewUsers; + private List<String> viewActors; @Setter private List<String> negativeViewRoles; @Setter - private List<String> negativeViewUsers; + private List<String> negativeViewActors; @Setter private Map<String, String> tags; @@ -130,13 +130,13 @@ protected Case() { tasks = new HashSet<>(); enabledRoles = new HashSet<>(); permissions = new HashMap<>(); - userRefs = new HashMap<>(); - users = new HashMap<>(); + actorRefs = new HashMap<>(); + actors = new HashMap<>(); viewRoles = new LinkedList<>(); - viewUserRefs = new LinkedList<>(); - viewUsers = new LinkedList<>(); + viewActorRefs = new LinkedList<>(); + viewActors = new LinkedList<>(); negativeViewRoles = new LinkedList<>(); - negativeViewUsers = new ArrayList<>(); + negativeViewActors = new ArrayList<>(); tags = new HashMap<>(); } @@ -152,7 +152,7 @@ public Case(PetriNet petriNet) { enabledRoles = new HashSet<>(petriNet.getRoles().keySet()); negativeViewRoles.addAll(petriNet.getNegativeViewRoles()); icon = petriNet.getIcon(); - userRefs = petriNet.getUserRefs(); + actorRefs = petriNet.getActorRefs(); tags = new HashMap<>(petriNet.getTags()); permissions = petriNet.getPermissions().entrySet().stream() @@ -169,7 +169,7 @@ public Case(PetriNet petriNet) { .collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue)); resolveViewRoles(); - resolveViewUserRefs(); + resolveViewActorRefs(); } public String getStringId() { @@ -198,11 +198,11 @@ public void populateDataSet(InitValueExpressionEvaluator initValueExpressionEval if (field.getComponent() != null) { this.dataSet.get(key).setComponent(field.getComponent()); } - if (field instanceof UserField) { - this.dataSet.get(key).setChoices(((UserField) field).getRoles().stream().map(I18nString::new).collect(Collectors.toSet())); + if (field instanceof ActorField) { + this.dataSet.get(key).setChoices(((ActorField) field).getRoles().stream().map(I18nString::new).collect(Collectors.toSet())); } - if (field instanceof UserListField) { - this.dataSet.get(key).setChoices(((UserListField) field).getRoles().stream().map(I18nString::new).collect(Collectors.toSet())); + if (field instanceof ActorListField) { + this.dataSet.get(key).setChoices(((ActorListField) field).getRoles().stream().map(I18nString::new).collect(Collectors.toSet())); } if (field instanceof FieldWithAllowedNets) { this.dataSet.get(key).setAllowedNets(((FieldWithAllowedNets) field).getAllowedNets()); @@ -277,12 +277,12 @@ public String getPetriNetId() { return petriNetObjectId.toString(); } - public void addUsers(Set<String> userIds, Map<String, Boolean> permissions) { - userIds.forEach(userId -> { - if (users.containsKey(userId) && users.get(userId) != null) { - compareExistingUserPermissions(userId, new HashMap<>(permissions)); + public void addActors(Set<String> actorIds, Map<String, Boolean> permissions) { + actorIds.forEach(actorId -> { + if (actors.containsKey(actorId) && actors.get(actorId) != null) { + compareExistingActorPermissions(actorId, new HashMap<>(permissions)); } else { - users.put(userId, new HashMap<>(permissions)); + actors.put(actorId, new HashMap<>(permissions)); } }); } @@ -296,28 +296,29 @@ public void resolveViewRoles() { }); } - public void resolveViewUserRefs() { - this.viewUserRefs.clear(); - this.userRefs.forEach((userRef, perms) -> { + public void resolveViewActorRefs() { + this.viewActorRefs.clear(); + this.actorRefs.forEach((actorRef, perms) -> { if (perms.containsKey(RolePermission.VIEW.getValue()) && perms.get(RolePermission.VIEW.getValue())) { - viewUserRefs.add(userRef); + viewActorRefs.add(actorRef); } }); } - public void resolveViewUsers() { - this.viewUsers.clear(); - this.users.forEach((user, perms) -> { + public void resolveViewActors() { + this.viewActors.clear(); + this.actors.forEach((actor, perms) -> { if (perms.containsKey(RolePermission.VIEW.getValue()) && perms.get(RolePermission.VIEW.getValue())) { - viewUsers.add(user); + viewActors.add(actor); } }); } - private void compareExistingUserPermissions(String userId, Map<String, Boolean> permissions) { - permissions.forEach((id, perm) -> { - if ((users.containsKey(userId) && !users.get(userId).containsKey(id)) || (users.containsKey(userId) && users.get(userId).containsKey(id) && users.get(userId).get(id))) { - users.get(userId).put(id, perm); + private void compareExistingActorPermissions(String actorId, Map<String, Boolean> permissions) { + permissions.forEach((permType, permValue) -> { + if ((actors.containsKey(actorId) && !actors.get(actorId).containsKey(permType)) + || (actors.containsKey(actorId) && actors.get(actorId).containsKey(permType) && actors.get(actorId).get(permType))) { + actors.get(actorId).put(permType, permValue); } }); } diff --git a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/workflow/domain/Task.java b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/workflow/domain/Task.java index eb52c24a819..c62930a5e8f 100644 --- a/nae-object-library/src/main/java/com/netgrif/application/engine/objects/workflow/domain/Task.java +++ b/nae-object-library/src/main/java/com/netgrif/application/engine/objects/workflow/domain/Task.java @@ -86,26 +86,26 @@ public abstract class Task implements Serializable { @Getter @Setter - private Map<String, Map<String, Boolean>> userRefs = new HashMap<>(); + private Map<String, Map<String, Boolean>> actorRefs = new HashMap<>(); @Getter @Setter - private Map<String, Map<String, Boolean>> users = new HashMap<>(); + private Map<String, Map<String, Boolean>> actors = new HashMap<>(); @Setter private List<String> viewRoles = new LinkedList<>(); @Setter - private List<String> viewUserRefs = new LinkedList<>(); + private List<String> viewActorRefs = new LinkedList<>(); @Setter - private List<String> viewUsers = new LinkedList<>(); + private List<String> viewActors = new LinkedList<>(); @Setter private List<String> negativeViewRoles = new LinkedList<>(); @Setter - private List<String> negativeViewUsers = new LinkedList<>(); + private List<String> negativeViewActors = new LinkedList<>(); @Getter @Setter @@ -204,18 +204,18 @@ public List<String> getViewRoles() { return viewRoles; } - public List<String> getViewUserRefs() { - if (viewUserRefs == null) { - viewUserRefs = new LinkedList<>(); + public List<String> getViewActorRefs() { + if (viewActorRefs == null) { + viewActorRefs = new LinkedList<>(); } - return viewUserRefs; + return viewActorRefs; } - public List<String> getViewUsers() { - if (viewUsers == null) { - viewUsers = new LinkedList<>(); + public List<String> getViewActors() { + if (viewActors == null) { + viewActors = new LinkedList<>(); } - return viewUsers; + return viewActors; } public List<String> getNegativeViewRoles() { @@ -225,11 +225,11 @@ public List<String> getNegativeViewRoles() { return negativeViewRoles; } - public List<String> getNegativeViewUsers() { - if (negativeViewUsers == null) { - negativeViewUsers = new LinkedList<>(); + public List<String> getNegativeViewActors() { + if (negativeViewActors == null) { + negativeViewActors = new LinkedList<>(); } - return negativeViewUsers; + return negativeViewActors; } public void addRole(String roleId, Map<String, Boolean> permissions) { @@ -243,16 +243,16 @@ public void addNegativeViewRole(String roleId) { negativeViewRoles.add(roleId); } - public void addUserRef(String userRefId, Map<String, Boolean> permissions) { - userRefs.put(userRefId, permissions); + public void addActorRef(String actorFieldId, Map<String, Boolean> permissions) { + actorRefs.put(actorFieldId, permissions); } - public void addUsers(Set<String> userIds, Map<String, Boolean> permissions) { - userIds.forEach(userId -> { - if (users.containsKey(userId) && users.get(userId) != null) { - compareExistingUserPermissions(userId, new HashMap<>(permissions)); + public void addActors(Set<String> actorIds, Map<String, Boolean> permissions) { + actorIds.forEach(actorId -> { + if (actors.containsKey(actorId) && actors.get(actorId) != null) { + compareExistingActorPermissions(actorId, new HashMap<>(permissions)); } else { - users.put(userId, new HashMap<>(permissions)); + actors.put(actorId, new HashMap<>(permissions)); } }); } @@ -302,30 +302,31 @@ public void resolveViewRoles() { }); } - public void resolveViewUserRefs() { - getViewUserRefs(); - this.viewUserRefs.clear(); - this.userRefs.forEach((userRef, perms) -> { + public void resolveViewActorRefs() { + getViewActorRefs(); + this.viewActorRefs.clear(); + this.actorRefs.forEach((actorRef, perms) -> { if (perms.containsKey(RolePermission.VIEW.getValue()) && perms.get(RolePermission.VIEW.getValue())) { - viewUserRefs.add(userRef); + viewActorRefs.add(actorRef); } }); } - public void resolveViewUsers() { - getViewUsers(); - this.viewUsers.clear(); - this.users.forEach((role, perms) -> { + public void resolveViewActors() { + getViewActors(); + this.viewActors.clear(); + this.actors.forEach((actorId, perms) -> { if (perms.containsKey(RolePermission.VIEW.getValue()) && perms.get(RolePermission.VIEW.getValue())) { - viewUsers.add(role); + viewActors.add(actorId); } }); } - private void compareExistingUserPermissions(String userId, Map<String, Boolean> permissions) { - permissions.forEach((id, perm) -> { - if ((users.containsKey(userId) && !users.get(userId).containsKey(id)) || (users.containsKey(userId) && users.get(userId).containsKey(id) && users.get(userId).get(id))) { - users.get(userId).put(id, perm); + private void compareExistingActorPermissions(String actorId, Map<String, Boolean> permissions) { + permissions.forEach((permType, permValue) -> { + if ((actors.containsKey(actorId) && !actors.get(actorId).containsKey(permType)) + || (actors.containsKey(actorId) && actors.get(actorId).containsKey(permType) && actors.get(actorId).get(permType))) { + actors.get(actorId).put(permType, permValue); } }); } diff --git a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/ActorField.java b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/ActorField.java new file mode 100644 index 00000000000..deb17b92d14 --- /dev/null +++ b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/ActorField.java @@ -0,0 +1,59 @@ +package com.netgrif.application.engine.adapter.spring.elastic.domain; + +import com.netgrif.application.engine.objects.elastic.domain.ActorMappingData; +import lombok.NoArgsConstructor; +import org.springframework.data.elasticsearch.annotations.Field; + +import java.util.Arrays; +import java.util.List; + +import static org.springframework.data.elasticsearch.annotations.FieldType.Text; + +@NoArgsConstructor +public class ActorField extends com.netgrif.application.engine.objects.elastic.domain.ActorField { + + public ActorField(ActorMappingData value) { + super(value); + } + + @Deprecated + public ActorField(ActorMappingData[] values) { + this(Arrays.asList(values)); + } + + public ActorField(List<ActorMappingData> values) { + super(values); + } + + @Override + @Field(type = Text) + public List<String> getFulltextValue() { + return super.getFulltextValue(); + } + + @Override + @Field(type = Text) + public List<String> getUsernameValue() { + return super.getUsernameValue(); + } + + @Override + @Field(type = Text) + public List<String> getFullNameValue() { + return super.getFullNameValue(); + } + + @Override + @Field(type = Text) + public List<String> getActorIdValue() { + return super.getActorIdValue(); + } + + @Override + @Field(type = Text) + public List<String> getActorRealmIdValue() { + return super.getActorRealmIdValue(); + } +} + + diff --git a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/ActorListField.java b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/ActorListField.java new file mode 100644 index 00000000000..ffb1326a039 --- /dev/null +++ b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/ActorListField.java @@ -0,0 +1,53 @@ +package com.netgrif.application.engine.adapter.spring.elastic.domain; + +import com.netgrif.application.engine.objects.elastic.domain.ActorMappingData; +import lombok.NoArgsConstructor; +import org.springframework.data.elasticsearch.annotations.Field; + +import java.util.Arrays; +import java.util.List; + +import static org.springframework.data.elasticsearch.annotations.FieldType.Text; + +@NoArgsConstructor +public class ActorListField extends com.netgrif.application.engine.objects.elastic.domain.ActorListField { + + @Deprecated + public ActorListField(ActorMappingData[] values) { + this(Arrays.asList(values)); + } + + public ActorListField(List<ActorMappingData> actorMappingDataList) { + super(actorMappingDataList); + } + + @Override + @Field(type = Text) + public List<String> getFulltextValue() { + return super.getFulltextValue(); + } + + @Override + @Field(type = Text) + public List<String> getUsernameValue() { + return super.getUsernameValue(); + } + + @Override + @Field(type = Text) + public List<String> getFullNameValue() { + return super.getFullNameValue(); + } + + @Override + @Field(type = Text) + public List<String> getActorIdValue() { + return super.getActorIdValue(); + } + + @Override + @Field(type = Text) + public List<String> getActorRealmIdValue() { + return super.getActorRealmIdValue(); + } +} diff --git a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/BooleanField.java b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/BooleanField.java index 32392622807..1873667374f 100644 --- a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/BooleanField.java +++ b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/BooleanField.java @@ -3,6 +3,8 @@ import lombok.NoArgsConstructor; import org.springframework.data.elasticsearch.annotations.Field; +import java.util.List; + import static org.springframework.data.elasticsearch.annotations.FieldType.Boolean; import static org.springframework.data.elasticsearch.annotations.FieldType.Text; @@ -19,12 +21,12 @@ public BooleanField(Boolean value) { @Override @Field(type = Text) - public String[] getFulltextValue() { + public List<String> getFulltextValue() { return super.getFulltextValue(); } @Field(type = Boolean) public Boolean getBooleanValue() { - return booleanValue; + return super.getBooleanValue(); } } diff --git a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/ButtonField.java b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/ButtonField.java index 5322cdd317f..ca048da7a2e 100644 --- a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/ButtonField.java +++ b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/ButtonField.java @@ -5,6 +5,8 @@ import lombok.NoArgsConstructor; import org.springframework.data.elasticsearch.annotations.Field; +import java.util.List; + import static org.springframework.data.elasticsearch.annotations.FieldType.Integer; import static org.springframework.data.elasticsearch.annotations.FieldType.Text; @@ -19,12 +21,12 @@ public ButtonField(Integer value) { @Override @Field(type = Text) - public String[] getFulltextValue() { + public List<String> getFulltextValue() { return super.getFulltextValue(); } @Field(type = Integer) public Integer getButtonValue() { - return buttonValue; + return super.getButtonValue(); } } diff --git a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/CaseField.java b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/CaseField.java index 7596000d6f1..5c3e4303b27 100644 --- a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/CaseField.java +++ b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/CaseField.java @@ -3,6 +3,7 @@ import lombok.NoArgsConstructor; import org.springframework.data.elasticsearch.annotations.Field; +import java.util.Arrays; import java.util.List; import static org.springframework.data.elasticsearch.annotations.FieldType.Text; @@ -10,19 +11,24 @@ @NoArgsConstructor public class CaseField extends com.netgrif.application.engine.objects.elastic.domain.CaseField { + @Deprecated public CaseField(String[] values, String[] allowedNets) { + this(Arrays.asList(values), Arrays.asList(allowedNets)); + } + + public CaseField(List<String> values, List<String> allowedNets) { super(values, allowedNets); } @Override @Field(type = Text) - public String[] getFulltextValue() { + public List<String> getFulltextValue() { return super.getFulltextValue(); } @Field(type = Text) - public String[] getAllowedNets() { - return super.allowedNets; + public List<String> getAllowedNets() { + return super.getAllowedNets(); } @Override diff --git a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/DateField.java b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/DateField.java index 2ce6f55f20f..25cbf362d6a 100644 --- a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/DateField.java +++ b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/DateField.java @@ -6,6 +6,7 @@ import org.springframework.data.elasticsearch.annotations.FieldType; import java.time.LocalDateTime; +import java.util.List; import static org.springframework.data.elasticsearch.annotations.FieldType.Long; import static org.springframework.data.elasticsearch.annotations.FieldType.Text; @@ -19,17 +20,17 @@ public DateField(String value, LocalDateTime dateTime) { @Override @Field(type = Text) - public String[] getFulltextValue() { + public List<String> getFulltextValue() { return super.getFulltextValue(); } @Field(type = FieldType.Date, format = DateFormat.date_hour_minute_second_millis) public LocalDateTime getDateValue() { - return dateValue; + return super.getDateValue(); } @Field(type = Long) public Long getTimestampValue() { - return timestampValue; + return super.getTimestampValue(); } } diff --git a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/ElasticCase.java b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/ElasticCase.java index cfb36a8446d..bb07113566c 100644 --- a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/ElasticCase.java +++ b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/ElasticCase.java @@ -104,13 +104,13 @@ public Set<String> getTaskMongoIds() { } @Field(type = Flattened) - public Map<String, Map<String, Boolean>> getUsers() { - return super.getUsers(); + public Map<String, Map<String, Boolean>> getActors() { + return super.getActors(); } @Field(type = Flattened) - public Map<String, Map<String, Boolean>> getUserRefs() { - return super.getUserRefs(); + public Map<String, Map<String, Boolean>> getActorRefs() { + return super.getActorRefs(); } @Field(type = Flattened) @@ -129,8 +129,8 @@ public Set<String> getViewRoles() { } @Field(type = Keyword) - public Set<String> getViewUserRefs() { - return super.getViewUserRefs(); + public Set<String> getViewActorRefs() { + return super.getViewActorRefs(); } @Field(type = Keyword) @@ -139,7 +139,7 @@ public Set<String> getNegativeViewRoles() { } @Field(type = Keyword) - public Set<String> getNegativeViewUsers() { - return super.getNegativeViewUsers(); + public Set<String> getNegativeViewActors() { + return super.getNegativeViewActors(); } } diff --git a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/ElasticTask.java b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/ElasticTask.java index 3752616217e..4d32ceab221 100644 --- a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/ElasticTask.java +++ b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/ElasticTask.java @@ -88,13 +88,13 @@ public String getTransactionId() { } @Field(type = Flattened) - public Map<String, Map<String, Boolean>> getUsers() { - return super.getUsers(); + public Map<String, Map<String, Boolean>> getActors() { + return super.getActors(); } @Field(type = Flattened) - public Map<String, Map<String, Boolean>> getUserRefs() { - return super.getUserRefs(); + public Map<String, Map<String, Boolean>> getActorRefs() { + return super.getActorRefs(); } @Field(type = Flattened) @@ -104,8 +104,8 @@ public Map<String, Map<String, Boolean>> getRoles() { @Field(type = Keyword) @Override - public Set<String> getViewUserRefs() { - return super.getViewUserRefs(); + public Set<String> getViewActorRefs() { + return super.getViewActorRefs(); } @Field(type = Keyword) @@ -122,14 +122,14 @@ public Set<String> getNegativeViewRoles() { @Field(type = Keyword) @Override - public Set<String> getViewUsers() { - return super.getViewUsers(); + public Set<String> getViewActors() { + return super.getViewActors(); } @Field(type = Keyword) @Override - public Set<String> getNegativeViewUsers() { - return super.getNegativeViewUsers(); + public Set<String> getNegativeViewActors() { + return super.getNegativeViewActors(); } @Field(type = Keyword) diff --git a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/FileField.java b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/FileField.java index 4990f7299fc..54f7760d15b 100644 --- a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/FileField.java +++ b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/FileField.java @@ -5,6 +5,11 @@ import lombok.NoArgsConstructor; import org.springframework.data.elasticsearch.annotations.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; + import static org.springframework.data.elasticsearch.annotations.FieldType.Keyword; import static org.springframework.data.elasticsearch.annotations.FieldType.Text; @@ -16,23 +21,32 @@ public FileField(FileFieldValue value) { super(value); } + @Deprecated public FileField(FileFieldValue[] values) { + this(Arrays.asList(values)); + } + + public FileField(List<FileFieldValue> values) { super(values); } + public FileField(HashSet<FileFieldValue> values) { + this(new ArrayList<>(values)); + } + @Override @Field(type = Text) - public String[] getFulltextValue() { + public List<String> getFulltextValue() { return super.getFulltextValue(); } @Field(type = Text) - public String[] getFileNameValue() { + public List<String> getFileNameValue() { return super.getFileNameValue(); } @Field(type = Keyword) - public String[] getFileExtensionValue() { + public List<String> getFileExtensionValue() { return super.getFileExtensionValue(); } } diff --git a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/FilterField.java b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/FilterField.java index e3322b1fe31..dcd0a9cccb7 100644 --- a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/FilterField.java +++ b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/FilterField.java @@ -3,6 +3,8 @@ import lombok.NoArgsConstructor; import org.springframework.data.elasticsearch.annotations.Field; +import java.util.Arrays; +import java.util.List; import java.util.Map; import static org.springframework.data.elasticsearch.annotations.FieldType.*; @@ -10,23 +12,28 @@ @NoArgsConstructor public class FilterField extends com.netgrif.application.engine.objects.elastic.domain.FilterField { + @Deprecated public FilterField(String value, String[] allowedNets, Map<String, Object> filterMetadata) { + this(value, Arrays.asList(allowedNets), filterMetadata); + } + + public FilterField(String value, List<String> allowedNets, Map<String, Object> filterMetadata) { super(value, allowedNets, filterMetadata); } @Override @Field(type = Text) - public String[] getFulltextValue() { + public List<String> getFulltextValue() { return super.getFulltextValue(); } @Field(type = Text) - public String[] getAllowedNets() { - return super.allowedNets; + public List<String> getAllowedNets() { + return super.getAllowedNets(); } @Field(type = Flattened) public Map<String, Object> getFilterMetadata() { - return super.filterMetadata; + return super.getFilterMetadata(); } } diff --git a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/I18nField.java b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/I18nField.java index 6e7345b5596..9a194fff246 100644 --- a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/I18nField.java +++ b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/I18nField.java @@ -3,6 +3,7 @@ import lombok.NoArgsConstructor; import org.springframework.data.elasticsearch.annotations.Field; +import java.util.List; import java.util.Map; import java.util.Set; @@ -18,12 +19,12 @@ public I18nField(Set<String> keys, Set<String> values, Map<String, String> trans @Override @Field(type = Text) - public String[] getFulltextValue() { + public List<String> getFulltextValue() { return super.getFulltextValue(); } @Field(type = Text) - public String[] getKeyValue() { + public Set<String> getKeyValue() { return super.getKeyValue(); } diff --git a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/MapField.java b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/MapField.java index 217ab8001da..46e685cff08 100644 --- a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/MapField.java +++ b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/MapField.java @@ -23,17 +23,17 @@ public MapField(List<Map.Entry<String, I18nString>> valuePairs) { @Override @Field(type = Text) - public String[] getFulltextValue() { + public List<String> getFulltextValue() { return super.getFulltextValue(); } @Field(type = Keyword) - public String[] getKeyValue() { + public List<String> getKeyValue() { return super.getKeyValue(); } @Field(type = Flattened, index = false) public Map<String, I18nString> getKeyValueTranslations() { - return super.keyValueTranslations; + return super.getKeyValueTranslations(); } } diff --git a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/NumberField.java b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/NumberField.java index f643393df65..b2d27ef0dcd 100644 --- a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/NumberField.java +++ b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/NumberField.java @@ -3,6 +3,8 @@ import lombok.NoArgsConstructor; import org.springframework.data.elasticsearch.annotations.Field; +import java.util.List; + import static org.springframework.data.elasticsearch.annotations.FieldType.Double; import static org.springframework.data.elasticsearch.annotations.FieldType.Text; @@ -15,7 +17,7 @@ public NumberField(Double value) { @Override @Field(type = Text) - public String[] getFulltextValue() { + public List<String> getFulltextValue() { return super.getFulltextValue(); } diff --git a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/StringCollectionField.java b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/StringCollectionField.java index 4786a4d2d4a..2c1eeca5a94 100644 --- a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/StringCollectionField.java +++ b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/StringCollectionField.java @@ -5,6 +5,9 @@ import lombok.NoArgsConstructor; import org.springframework.data.elasticsearch.annotations.Field; +import java.util.Arrays; +import java.util.List; + import static org.springframework.data.elasticsearch.annotations.FieldType.Keyword; import static org.springframework.data.elasticsearch.annotations.FieldType.Text; @@ -13,19 +16,24 @@ @EqualsAndHashCode(callSuper = true) public class StringCollectionField extends com.netgrif.application.engine.objects.elastic.domain.StringCollectionField { + @Deprecated public StringCollectionField(String[] values) { + super(Arrays.asList(values)); + } + + public StringCollectionField(List<String> values) { super(values); } @Override @Field(type = Text) - public String[] getFulltextValue() { + public List<String> getFulltextValue() { return super.getFulltextValue(); } @Override @Field(type = Keyword) - public String[] getCollectionValue() { + public List<String> getCollectionValue() { return super.getCollectionValue(); } diff --git a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/TextField.java b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/TextField.java index e1a09218675..f1d0c6e01bf 100644 --- a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/TextField.java +++ b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/TextField.java @@ -5,6 +5,9 @@ import lombok.NoArgsConstructor; import org.springframework.data.elasticsearch.annotations.Field; +import java.util.Arrays; +import java.util.List; + import static org.springframework.data.elasticsearch.annotations.FieldType.Text; @Data @@ -16,19 +19,24 @@ public TextField(String value) { super(value); } + @Deprecated public TextField(String[] values) { + this(Arrays.asList(values)); + } + + public TextField(List<String> values) { super(values); } @Override @Field(type = Text) - public String[] getFulltextValue() { + public List<String> getFulltextValue() { return super.getFulltextValue(); } @Override @Field(type = Text) - public String[] getTextValue() { + public List<String> getTextValue() { return super.getTextValue(); } } diff --git a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/UserField.java b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/UserField.java deleted file mode 100644 index 7268f5b9f91..00000000000 --- a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/UserField.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.netgrif.application.engine.adapter.spring.elastic.domain; - -import lombok.NoArgsConstructor; -import org.springframework.data.elasticsearch.annotations.Field; - -import static org.springframework.data.elasticsearch.annotations.FieldType.Text; - -@NoArgsConstructor -public class UserField extends com.netgrif.application.engine.objects.elastic.domain.UserField { - - public UserField(UserMappingData value) { - super(value); - } - - public UserField(UserMappingData[] values) { - super(values); - } - - @Override - @Field(type = Text) - public String[] getFulltextValue() { - return super.getFulltextValue(); - } - - @Override - @Field(type = Text) - public String[] getUsernameValue() { - return super.getUsernameValue(); - } - - @Override - @Field(type = Text) - public String[] getFullNameValue() { - return super.getFullNameValue(); - } - - @Override - @Field(type = Text) - public String[] getUserIdValue() { - return super.getUserIdValue(); - } - - @Override - @Field(type = Text) - public String[] getUserRealmIdValue() { - return super.getUserRealmIdValue(); - } -} - - diff --git a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/UserListField.java b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/UserListField.java deleted file mode 100644 index 8619879c718..00000000000 --- a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/UserListField.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.netgrif.application.engine.adapter.spring.elastic.domain; - -import lombok.NoArgsConstructor; -import org.springframework.data.elasticsearch.annotations.Field; - -import static org.springframework.data.elasticsearch.annotations.FieldType.Text; - -@NoArgsConstructor -public class UserListField extends com.netgrif.application.engine.objects.elastic.domain.UserListField { - - public UserListField(UserMappingData[] values) { - super(values); - } - - @Override - @Field(type = Text) - public String[] getFulltextValue() { - return super.getFulltextValue(); - } - - @Override - @Field(type = Text) - public String[] getUsernameValue() { - return super.getUsernameValue(); - } - - @Override - @Field(type = Text) - public String[] getFullNameValue() { - return super.getFullNameValue(); - } - - @Override - @Field(type = Text) - public String[] getUserIdValue() { - return super.getUserIdValue(); - } - - @Override - @Field(type = Text) - public String[] getUserRealmIdValue() { - return super.getUserRealmIdValue(); - } -} diff --git a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/workflow/domain/Case.java b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/workflow/domain/Case.java index 1eea8f7bb11..f96d9467880 100644 --- a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/workflow/domain/Case.java +++ b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/workflow/domain/Case.java @@ -92,14 +92,14 @@ public PetriNet getPetriNet() { @Override @JsonIgnore - public List<String> getViewUserRefs() { - return super.getViewUserRefs(); + public List<String> getViewActorRefs() { + return super.getViewActorRefs(); } @Override @JsonIgnore - public List<String> getViewUsers() { - return super.getViewUsers(); + public List<String> getViewActors() { + return super.getViewActors(); } @Override diff --git a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/workflow/domain/Task.java b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/workflow/domain/Task.java index ce9702a0f94..819569f8af1 100644 --- a/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/workflow/domain/Task.java +++ b/nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/workflow/domain/Task.java @@ -29,8 +29,18 @@ public Task() { } @Builder(builderMethodName = "with") - public Task(ProcessResourceId _id, String processId, String caseId, String transitionId, TaskLayout layout, I18nString title, String caseColor, String caseTitle, Integer priority, String userId, String userRealmId, AbstractUser user, List<Trigger> triggers, Map<String, Map<String, Boolean>> roles, Map<String, Map<String, Boolean>> userRefs, Map<String, Map<String, Boolean>> users, List<String> viewRoles, List<String> viewUserRefs, List<String> viewUsers, List<String> negativeViewRoles, List<String> negativeViewUsers, LocalDateTime startDate, LocalDateTime finishDate, String finishedBy, String transactionId, Boolean requiredFilled, LinkedHashSet<String> immediateDataFields, List<Field<?>> immediateData, String icon, AssignPolicy assignPolicy, DataFocusPolicy dataFocusPolicy, FinishPolicy finishPolicy, Map<EventType, I18nString> eventTitles, Map<String, Boolean> assignedUserPolicy, Map<String, Integer> consumedTokens, Map<String, String> tags) { - super(_id, processId, caseId, transitionId, layout, title, caseColor, caseTitle, priority, userId, userRealmId, user, triggers, roles, userRefs, users, viewRoles, viewUserRefs, viewUsers, negativeViewRoles, negativeViewUsers, startDate, finishDate, finishedBy, transactionId, requiredFilled, immediateDataFields, immediateData, icon, assignPolicy, dataFocusPolicy, finishPolicy, eventTitles, assignedUserPolicy, consumedTokens, tags); + public Task(ProcessResourceId _id, String processId, String caseId, String transitionId, TaskLayout layout, I18nString title, + String caseColor, String caseTitle, Integer priority, String userId, String userRealmId, AbstractUser user, + List<Trigger> triggers, Map<String, Map<String, Boolean>> roles, Map<String, Map<String, Boolean>> actorRefs, + Map<String, Map<String, Boolean>> actors, List<String> viewRoles, List<String> viewActorRefs, List<String> viewActors, + List<String> negativeViewRoles, List<String> negativeViewActors, LocalDateTime startDate, LocalDateTime finishDate, + String finishedBy, String transactionId, Boolean requiredFilled, LinkedHashSet<String> immediateDataFields, List<Field<?>> immediateData, + String icon, AssignPolicy assignPolicy, DataFocusPolicy dataFocusPolicy, FinishPolicy finishPolicy, Map<EventType, I18nString> eventTitles, + Map<String, Boolean> assignedUserPolicy, Map<String, Integer> consumedTokens, Map<String, String> tags) { + super(_id, processId, caseId, transitionId, layout, title, caseColor, caseTitle, priority, userId, userRealmId, user, + triggers, roles, actorRefs, actors, viewRoles, viewActorRefs, viewActors, negativeViewRoles, negativeViewActors, + startDate, finishDate, finishedBy, transactionId, requiredFilled, immediateDataFields, immediateData, icon, + assignPolicy, dataFocusPolicy, finishPolicy, eventTitles, assignedUserPolicy, consumedTokens, tags); } @Id