Project

General

Profile

Actions

Task #2709

closed

Import role attributes with the assigned roles

Added by Alena Peterová about 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Peter Štrunc
Target version:
Start date:
03/04/2021
Due date:
% Done:

100%

Estimated time:
Owner:

Description

We need to import assigned roles to users together with their role attributes.

Please extend ImportCSVUserContractRolesTaskExecutor. New task parameters:
  • Role attributes definition (code)
  • Prefix of column name with role attributes names
  • Prefix of column name with role attributes values

Example settings:
  • Column with roles: role
  • Column with username: login
  • Roles assignment contract type: primeContract
  • Role attributes definition (code): roleParameters
  • Prefix of column name with role attributes names: roleattrname
  • Prefix of column name with role attributes values: roleattrvalue

Example CSV:
login;role;roleattrname1;roleattrvalue1;roleattrname2;roleattrvalue2
t123456;PRISTUP;idCardNumber;123456789;idCardType;OP

The role is set like this:

The result of the import is following assignment of the role:


Files

role_with_attributes.png (15.4 KB) role_with_attributes.png Alena Peterová, 03/04/2021 08:07 PM
role_parameters.png (34.3 KB) role_parameters.png Alena Peterová, 03/04/2021 08:07 PM
Actions #2

Updated by Alena Peterová about 3 years ago

  • Assignee set to Peter Štrunc
Actions #3

Updated by Peter Štrunc about 3 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 20
Actions #4

Updated by Peter Štrunc about 3 years ago

  • Status changed from In Progress to Needs feedback
  • Assignee changed from Peter Štrunc to Alena Peterová
  • % Done changed from 20 to 80

I implemented feature in develop (https://github.com/bcvsolutions/czechidm-extras/commit/56b5fbe3be26ae9498f70d79762317dfcf439db8). Current implementation can set single values for both single and multivalued SHORTTEXT role attributes. LRT parameter with form definition was not needed since each role has single form definition. Documentation can be found here https://wiki.czechidm.com/tutorial/adm/assign_roles_to_contract_-_import_of_data_from_csv. @apeterova would you please review this ticket?

Actions #5

Updated by Alena Peterová about 3 years ago

  • Assignee changed from Alena Peterová to Peter Štrunc
I made review, it works nice, thanks!
Remarks:
  • roleattributevalueprefix - english help message "Use in combination with 'Prefix of column with role parameter value", but should be "... name"
  • when some of the attributes have some validation - required, unique - it may break the import if:
    A) if the attribute must be unique/required and the value is non-unique/empty in some of the record in CSV, none of the role is imported from the whole CSV. We don't see which record was at fault in the error message.
    B) if the attribute must be unique and there are 2 same values in the CSV for different users, then the roles with attributes are assigned. When we display one of the users, we see some form validation error and we can't unassign the role.

Error message for A:

eu.bcvsolutions.idm.core.api.exception.InvalidFormException: Form is not valid. Attributes: [[Attribute code [idCardNumber] - missingValue [true]]].
eu.bcvsolutions.idm.core.api.exception.InvalidFormException: Form is not valid. Attributes: [[Attribute code [idCardNumber] - uniqueValue [OP-1234335]]].
    at eu.bcvsolutions.idm.core.eav.processor.FormInstanceValidateProcessor.process(FormInstanceValidateProcessor.java:81)
    at eu.bcvsolutions.idm.core.api.event.AbstractEntityEventProcessor.onApplicationEvent(AbstractEntityEventProcessor.java:239)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:373)
    at eu.bcvsolutions.idm.core.model.service.impl.DefaultEntityEventManager.process(DefaultEntityEventManager.java:252)
    at eu.bcvsolutions.idm.core.model.service.impl.DefaultEntityEventManager.process(DefaultEntityEventManager.java:179)
    at eu.bcvsolutions.idm.core.model.service.impl.DefaultEntityEventManager$$FastClassBySpringCGLIB$$1694e58f.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:752)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)
    at eu.bcvsolutions.idm.core.model.service.impl.DefaultEntityEventManager$$EnhancerBySpringCGLIB$$b124e93f.process(<generated>)
    at eu.bcvsolutions.idm.core.eav.service.impl.DefaultFormService.saveFormInstance(DefaultFormService.java:469)
    at eu.bcvsolutions.idm.core.eav.service.impl.DefaultFormService.saveValues(DefaultFormService.java:424)
    at eu.bcvsolutions.idm.core.eav.service.impl.DefaultFormService$$FastClassBySpringCGLIB$$f7e12749.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:752)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)
    at eu.bcvsolutions.idm.core.eav.service.impl.DefaultFormService$$EnhancerBySpringCGLIB$$413b92ad.saveValues(<generated>)
    at eu.bcvsolutions.idm.core.model.service.impl.DefaultIdmConceptRoleRequestService.saveInternal(DefaultIdmConceptRoleRequestService.java:287)
    at eu.bcvsolutions.idm.core.model.service.impl.DefaultIdmConceptRoleRequestService.saveInternal(DefaultIdmConceptRoleRequestService.java:88)
    at eu.bcvsolutions.idm.core.api.service.AbstractReadWriteDtoService.save(AbstractReadWriteDtoService.java:80)
    at eu.bcvsolutions.idm.core.api.service.AbstractReadWriteDtoService$$FastClassBySpringCGLIB$$f52da88.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:752)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)
    at eu.bcvsolutions.idm.core.model.service.impl.DefaultIdmConceptRoleRequestService$$EnhancerBySpringCGLIB$$2c49eef3.save(<generated>)
    at eu.bcvsolutions.idm.extras.scheduler.task.impl.ImportCSVUserContractRolesTaskExecutor.addRolesToContract(ImportCSVUserContractRolesTaskExecutor.java:318)
    at eu.bcvsolutions.idm.extras.scheduler.task.impl.ImportCSVUserContractRolesTaskExecutor.processRecords(ImportCSVUserContractRolesTaskExecutor.java:115)
    at eu.bcvsolutions.idm.extras.scheduler.task.impl.AbstractCsvImportTask.process(AbstractCsvImportTask.java:96)
    at eu.bcvsolutions.idm.extras.scheduler.task.impl.AbstractCsvImportTask.process(AbstractCsvImportTask.java:42)
    at eu.bcvsolutions.idm.core.scheduler.api.service.AbstractLongRunningTaskExecutor.call(AbstractLongRunningTaskExecutor.java:265)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at eu.bcvsolutions.idm.core.config.DelegatingTransactionContextRunnable.run(DelegatingTransactionContextRunnable.java:39)
    at org.springframework.security.concurrent.DelegatingSecurityContextRunnable.run(DelegatingSecurityContextRunnable.java:84)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)

Error message for B

2021-05-10 20:58:47.787 ERROR 2099624 --- [http-nio-127.0.0.1-8080-exec-7] e.b.i.c.e.ExceptionControllerAdvice.log : [core:INTERNAL_SERVER_ERROR:e083b063-3bc6-4313-80b8-9c63f180c916] Type definition error: [simple type, class java.io.Serializable]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `java.io.Serializable` (no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
 at [Source: (PushbackInputStream); line: 1, column: 12322] (through reference chain: eu.bcvsolutions.idm.core.api.dto.IdmRequestIdentityRoleDto["_eav"]->java.util.ArrayList[0]->eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto["validationErrors"]->java.util.ArrayList[0]->eu.bcvsolutions.idm.core.eav.api.dto.InvalidFormAttributeDto["ownerId"]) ({})
org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class java.io.Serializable]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `java.io.Serializable` (no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
 at [Source: (PushbackInputStream); line: 1, column: 12322] (through reference chain: eu.bcvsolutions.idm.core.api.dto.IdmRequestIdentityRoleDto["_eav"]->java.util.ArrayList[0]->eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto["validationErrors"]->java.util.ArrayList[0]->eu.bcvsolutions.idm.core.eav.api.dto.InvalidFormAttributeDto["ownerId"])

Actions #6

Updated by Peter Štrunc about 3 years ago

  • Assignee changed from Peter Štrunc to Alena Peterová

Thanks for the feedback @apeterova. I fixed localization and added more info to the error that is thrown when the role attribute does not pass form validation. All are in https://github.com/bcvsolutions/czechidm-extras/commit/1b1434f6fc01192a8109183d47e1593d9e4d4a4d.

As for the error "B", I haven't found a better way of solving the issue than doing role requests synchronously, which is not ideal as we discussed. So I left it unpatched and added warning to documentation here: https://wiki.czechidm.com/tutorial/adm/assign_roles_to_contract_-_import_of_data_from_csv#fill_all_attributes

Actions #7

Updated by Alena Peterová about 3 years ago

  • Assignee changed from Alena Peterová to Peter Štrunc

Final feedback and testing, works fine, thanks!

Note: If the role attribute does not pass form validation, the import is stopped at that point - the remaining records are not imported. Other approach would be to import at least other role assignments for other users in the imported CSV. However, current behavior is good for now.

Actions #8

Updated by Peter Štrunc about 3 years ago

  • Status changed from Needs feedback to Closed
  • Target version changed from 2.8.0 to 3.0.0
  • % Done changed from 80 to 100

Thanks

Actions

Also available in: Atom PDF