Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring
This commit is contained in:
commit
1f90266057
|
@ -5,13 +5,24 @@ import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.authorization.authorizationcontentresolver.AuthorizationContentResolver;
|
import eu.eudat.authorization.authorizationcontentresolver.AuthorizationContentResolver;
|
||||||
import eu.eudat.commonmodels.models.FileEnvelopeModel;
|
import eu.eudat.commonmodels.models.FileEnvelopeModel;
|
||||||
import eu.eudat.commonmodels.models.dmp.DmpModel;
|
import eu.eudat.commonmodels.models.dmp.DmpModel;
|
||||||
|
import eu.eudat.commons.JsonHandlingService;
|
||||||
|
import eu.eudat.commons.enums.ContactInfoType;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.enums.StorageType;
|
import eu.eudat.commons.enums.StorageType;
|
||||||
|
import eu.eudat.commons.notification.NotificationProperties;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
|
import eu.eudat.commons.types.notification.*;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.DmpEntity;
|
import eu.eudat.data.DmpEntity;
|
||||||
|
import eu.eudat.data.DmpUserEntity;
|
||||||
|
import eu.eudat.data.UserEntity;
|
||||||
import eu.eudat.depositinterface.repository.DepositClient;
|
import eu.eudat.depositinterface.repository.DepositClient;
|
||||||
import eu.eudat.depositinterface.repository.DepositConfiguration;
|
import eu.eudat.depositinterface.repository.DepositConfiguration;
|
||||||
|
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEvent;
|
||||||
|
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEventHandler;
|
||||||
import eu.eudat.model.EntityDoi;
|
import eu.eudat.model.EntityDoi;
|
||||||
import eu.eudat.model.StorageFile;
|
import eu.eudat.model.StorageFile;
|
||||||
|
import eu.eudat.model.UserContactInfo;
|
||||||
import eu.eudat.model.builder.commonmodels.DepositConfigurationBuilder;
|
import eu.eudat.model.builder.commonmodels.DepositConfigurationBuilder;
|
||||||
import eu.eudat.model.builder.commonmodels.dmp.DmpCommonModelBuilder;
|
import eu.eudat.model.builder.commonmodels.dmp.DmpCommonModelBuilder;
|
||||||
import eu.eudat.model.persist.StorageFilePersist;
|
import eu.eudat.model.persist.StorageFilePersist;
|
||||||
|
@ -19,6 +30,9 @@ import eu.eudat.model.persist.deposit.DepositAuthenticateRequest;
|
||||||
import eu.eudat.model.persist.deposit.DepositRequest;
|
import eu.eudat.model.persist.deposit.DepositRequest;
|
||||||
import eu.eudat.model.persist.EntityDoiPersist;
|
import eu.eudat.model.persist.EntityDoiPersist;
|
||||||
import eu.eudat.query.DmpQuery;
|
import eu.eudat.query.DmpQuery;
|
||||||
|
import eu.eudat.query.DmpUserQuery;
|
||||||
|
import eu.eudat.query.UserContactInfoQuery;
|
||||||
|
import eu.eudat.query.UserQuery;
|
||||||
import eu.eudat.service.entitydoi.EntityDoiService;
|
import eu.eudat.service.entitydoi.EntityDoiService;
|
||||||
import eu.eudat.service.storage.StorageFileProperties;
|
import eu.eudat.service.storage.StorageFileProperties;
|
||||||
import eu.eudat.service.storage.StorageFileService;
|
import eu.eudat.service.storage.StorageFileService;
|
||||||
|
@ -28,6 +42,7 @@ import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeFilterFunction;
|
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeFilterFunction;
|
||||||
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeModel;
|
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeModel;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.data.query.Ordering;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
|
@ -42,11 +57,13 @@ import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.reactive.function.client.WebClient;
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
|
||||||
|
import javax.management.InvalidApplicationException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class DepositServiceImpl implements DepositService {
|
public class DepositServiceImpl implements DepositService {
|
||||||
|
@ -67,6 +84,10 @@ public class DepositServiceImpl implements DepositService {
|
||||||
private final ValidatorFactory validatorFactory;
|
private final ValidatorFactory validatorFactory;
|
||||||
private final StorageFileProperties storageFileProperties;
|
private final StorageFileProperties storageFileProperties;
|
||||||
private final AuthorizationContentResolver authorizationContentResolver;
|
private final AuthorizationContentResolver authorizationContentResolver;
|
||||||
|
private final ConventionService conventionService;
|
||||||
|
private final JsonHandlingService jsonHandlingService;
|
||||||
|
private final NotificationProperties notificationProperties;
|
||||||
|
private final NotifyIntegrationEventHandler eventHandler;
|
||||||
@Autowired
|
@Autowired
|
||||||
public DepositServiceImpl(DepositProperties depositProperties,
|
public DepositServiceImpl(DepositProperties depositProperties,
|
||||||
TokenExchangeCacheService tokenExchangeCacheService,
|
TokenExchangeCacheService tokenExchangeCacheService,
|
||||||
|
@ -74,7 +95,7 @@ public class DepositServiceImpl implements DepositService {
|
||||||
EntityDoiService doiService,
|
EntityDoiService doiService,
|
||||||
QueryFactory queryFactory,
|
QueryFactory queryFactory,
|
||||||
MessageSource messageSource,
|
MessageSource messageSource,
|
||||||
BuilderFactory builderFactory, DepositConfigurationCacheService depositConfigurationCacheService, FileTransformerService fileTransformerService, StorageFileService storageFileService, UserScope userScope, ValidatorFactory validatorFactory, StorageFileProperties storageFileProperties, AuthorizationContentResolver authorizationContentResolver) {
|
BuilderFactory builderFactory, DepositConfigurationCacheService depositConfigurationCacheService, FileTransformerService fileTransformerService, StorageFileService storageFileService, UserScope userScope, ValidatorFactory validatorFactory, StorageFileProperties storageFileProperties, AuthorizationContentResolver authorizationContentResolver, ConventionService conventionService, JsonHandlingService jsonHandlingService, NotificationProperties notificationProperties, NotifyIntegrationEventHandler eventHandler) {
|
||||||
this.depositProperties = depositProperties;
|
this.depositProperties = depositProperties;
|
||||||
this.tokenExchangeCacheService = tokenExchangeCacheService;
|
this.tokenExchangeCacheService = tokenExchangeCacheService;
|
||||||
this.authorizationService = authorizationService;
|
this.authorizationService = authorizationService;
|
||||||
|
@ -89,7 +110,11 @@ public class DepositServiceImpl implements DepositService {
|
||||||
this.validatorFactory = validatorFactory;
|
this.validatorFactory = validatorFactory;
|
||||||
this.storageFileProperties = storageFileProperties;
|
this.storageFileProperties = storageFileProperties;
|
||||||
this.authorizationContentResolver = authorizationContentResolver;
|
this.authorizationContentResolver = authorizationContentResolver;
|
||||||
this.clients = new HashMap<>();
|
this.conventionService = conventionService;
|
||||||
|
this.jsonHandlingService = jsonHandlingService;
|
||||||
|
this.notificationProperties = notificationProperties;
|
||||||
|
this.eventHandler = eventHandler;
|
||||||
|
this.clients = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private DepositClient getDepositClient(String repositoryId) {
|
private DepositClient getDepositClient(String repositoryId) {
|
||||||
|
@ -181,8 +206,47 @@ public class DepositServiceImpl implements DepositService {
|
||||||
doiPersist.setRepositoryId(dmpDepositModel.getRepositoryId());
|
doiPersist.setRepositoryId(dmpDepositModel.getRepositoryId());
|
||||||
doiPersist.setDoi(doi);
|
doiPersist.setDoi(doi);
|
||||||
doiPersist.setEntityId(dmpEntity.getId());
|
doiPersist.setEntityId(dmpEntity.getId());
|
||||||
|
this.sendNotification(dmpEntity);
|
||||||
return doiService.persist(doiPersist, dmpDepositModel.getProject());
|
return doiService.persist(doiPersist, dmpDepositModel.getProject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sendNotification(DmpEntity dmpEntity) throws InvalidApplicationException {
|
||||||
|
List<DmpUserEntity> dmpUsers = this.queryFactory.query(DmpUserQuery.class).ids(dmpEntity.getId()).isActives(IsActive.Active).collect();
|
||||||
|
if (this.conventionService.isListNullOrEmpty(dmpUsers)){
|
||||||
|
throw new MyNotFoundException("Dmp does not have Users");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<UserEntity> users = this.queryFactory.query(UserQuery.class).ids(dmpUsers.stream().map(x -> x.getUserId()).collect(Collectors.toList())).isActive(IsActive.Active).collect();
|
||||||
|
|
||||||
|
for (UserEntity user: users) {
|
||||||
|
if (!user.getId().equals(this.userScope.getUserIdSafe()) && !this.conventionService.isListNullOrEmpty(dmpUsers.stream().filter(x -> x.getUserId().equals(user.getId())).collect(Collectors.toList()))){
|
||||||
|
this.createDmpDepositNotificationEvent(dmpEntity, user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createDmpDepositNotificationEvent(DmpEntity dmp, UserEntity user) throws InvalidApplicationException {
|
||||||
|
NotifyIntegrationEvent event = new NotifyIntegrationEvent();
|
||||||
|
event.setUserId(user.getId());
|
||||||
|
UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId());
|
||||||
|
query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal));
|
||||||
|
|
||||||
|
List<ContactPair> contactPairs = new ArrayList<>();
|
||||||
|
contactPairs.add(new ContactPair(ContactInfoType.Email, query.first().getValue()));
|
||||||
|
NotificationContactData contactData = new NotificationContactData(contactPairs, null, null);
|
||||||
|
event.setContactHint(jsonHandlingService.toJsonSafe(contactData));
|
||||||
|
event.setNotificationType(notificationProperties.getDmpDepositType());
|
||||||
|
NotificationFieldData data = new NotificationFieldData();
|
||||||
|
List<FieldInfo> fieldInfoList = new ArrayList<>();
|
||||||
|
fieldInfoList.add(new FieldInfo("{recipient}", DataType.String, user.getName()));
|
||||||
|
fieldInfoList.add(new FieldInfo("{reasonName}", DataType.String, this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first().getName()));
|
||||||
|
fieldInfoList.add(new FieldInfo("{name}", DataType.String, dmp.getLabel()));
|
||||||
|
fieldInfoList.add(new FieldInfo("{id}", DataType.String, dmp.getId().toString()));
|
||||||
|
data.setFields(fieldInfoList);
|
||||||
|
event.setData(jsonHandlingService.toJsonSafe(data));
|
||||||
|
|
||||||
|
eventHandler.handle(event);
|
||||||
|
}
|
||||||
|
|
||||||
private String addFileToSharedStorage(eu.eudat.model.file.FileEnvelope file) throws IOException {
|
private String addFileToSharedStorage(eu.eudat.model.file.FileEnvelope file) throws IOException {
|
||||||
StorageFilePersist storageFilePersist = new StorageFilePersist();
|
StorageFilePersist storageFilePersist = new StorageFilePersist();
|
||||||
|
|
|
@ -302,8 +302,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
if (!dmpUser.getUserId().equals(this.userScope.getUserIdSafe())){
|
if (!dmpUser.getUserId().equals(this.userScope.getUserIdSafe())){
|
||||||
UserEntity user = this.queryFactory.query(UserQuery.class).ids(dmpUser.getUserId()).first();
|
UserEntity user = this.queryFactory.query(UserQuery.class).ids(dmpUser.getUserId()).first();
|
||||||
if (user != null){
|
if (user != null){
|
||||||
this.createDescriptionNotificationEvent(description, user, NotificationContactType.EMAIL);
|
this.createDescriptionNotificationEvent(description, user);
|
||||||
this.createDescriptionNotificationEvent(description, user, NotificationContactType.IN_APP);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -353,9 +352,9 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
return cleanData;
|
return cleanData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createDescriptionNotificationEvent(DescriptionEntity description, UserEntity user, NotificationContactType type) throws InvalidApplicationException {
|
private void createDescriptionNotificationEvent(DescriptionEntity description, UserEntity user) throws InvalidApplicationException {
|
||||||
NotifyIntegrationEvent event = new NotifyIntegrationEvent();
|
NotifyIntegrationEvent event = new NotifyIntegrationEvent();
|
||||||
event.setUserId(this.userScope.getUserId());
|
event.setUserId(user.getId());
|
||||||
|
|
||||||
UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId());
|
UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId());
|
||||||
query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal));
|
query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal));
|
||||||
|
@ -364,7 +363,6 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
contactPairs.add(new ContactPair(ContactInfoType.Email, query.first().getValue()));
|
contactPairs.add(new ContactPair(ContactInfoType.Email, query.first().getValue()));
|
||||||
NotificationContactData contactData = new NotificationContactData(contactPairs, null, null);
|
NotificationContactData contactData = new NotificationContactData(contactPairs, null, null);
|
||||||
event.setContactHint(jsonHandlingService.toJsonSafe(contactData));
|
event.setContactHint(jsonHandlingService.toJsonSafe(contactData));
|
||||||
event.setContactTypeHint(type);
|
|
||||||
|
|
||||||
event = this.applyNotificationType(description.getStatus(), event);
|
event = this.applyNotificationType(description.getStatus(), event);
|
||||||
NotificationFieldData data = new NotificationFieldData();
|
NotificationFieldData data = new NotificationFieldData();
|
||||||
|
@ -421,6 +419,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
this.eventBroker.emit(new DescriptionTouchedEvent(data.getId()));
|
this.eventBroker.emit(new DescriptionTouchedEvent(data.getId()));
|
||||||
|
|
||||||
this.annotationEntityTouchedIntegrationEventHandler.handleDescription(data.getId());
|
this.annotationEntityTouchedIntegrationEventHandler.handleDescription(data.getId());
|
||||||
|
if (data.getStatus().equals(DescriptionStatus.Finalized)) this.sendNotification(data);
|
||||||
}
|
}
|
||||||
return this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, Description._id), data);
|
return this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, Description._id), data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,8 +245,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
data.setRole(user.getRole());
|
data.setRole(user.getRole());
|
||||||
this.entityManager.persist(data);
|
this.entityManager.persist(data);
|
||||||
if (!this.userScope.getUserId().equals(user.getUserId())) {
|
if (!this.userScope.getUserId().equals(user.getUserId())) {
|
||||||
this.sendDescriptionTemplateInvitationEvent(data, NotificationContactType.EMAIL);
|
this.sendDescriptionTemplateInvitationEvent(data);
|
||||||
this.sendDescriptionTemplateInvitationEvent(data, NotificationContactType.IN_APP);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updatedCreatedIds.add(data.getUserId());
|
updatedCreatedIds.add(data.getUserId());
|
||||||
|
@ -256,13 +255,18 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
this.deleterFactory.deleter(UserDescriptionTemplateDeleter.class).delete(toDelete);
|
this.deleterFactory.deleter(UserDescriptionTemplateDeleter.class).delete(toDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendDescriptionTemplateInvitationEvent(UserDescriptionTemplateEntity userDescriptionTemplate, NotificationContactType type) throws InvalidApplicationException {
|
private void sendDescriptionTemplateInvitationEvent(UserDescriptionTemplateEntity userDescriptionTemplate) throws InvalidApplicationException {
|
||||||
NotifyIntegrationEvent event = new NotifyIntegrationEvent();
|
NotifyIntegrationEvent event = new NotifyIntegrationEvent();
|
||||||
event.setUserId(userScope.getUserIdSafe());
|
|
||||||
|
|
||||||
UserEntity user = this.entityManager.find(UserEntity.class, userDescriptionTemplate.getUserId());
|
UserEntity user = this.entityManager.find(UserEntity.class, userDescriptionTemplate.getUserId());
|
||||||
|
if (user == null){
|
||||||
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{userDescriptionTemplate.getUserId(), User.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
}
|
||||||
DescriptionTemplateEntity descriptionTemplate = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).ids(userDescriptionTemplate.getDescriptionTemplateId()).first();
|
DescriptionTemplateEntity descriptionTemplate = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).ids(userDescriptionTemplate.getDescriptionTemplateId()).first();
|
||||||
|
if (descriptionTemplate == null){
|
||||||
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{userDescriptionTemplate.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
}
|
||||||
|
event.setUserId(user.getId());
|
||||||
UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId());
|
UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId());
|
||||||
query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal));
|
query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal));
|
||||||
|
|
||||||
|
@ -270,7 +274,6 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
contactPairs.add(new ContactPair(ContactInfoType.Email, query.first().getValue()));
|
contactPairs.add(new ContactPair(ContactInfoType.Email, query.first().getValue()));
|
||||||
NotificationContactData contactData = new NotificationContactData(contactPairs, null, null);
|
NotificationContactData contactData = new NotificationContactData(contactPairs, null, null);
|
||||||
event.setContactHint(jsonHandlingService.toJsonSafe(contactData));
|
event.setContactHint(jsonHandlingService.toJsonSafe(contactData));
|
||||||
event.setContactTypeHint(type);
|
|
||||||
event.setNotificationType(notificationProperties.getDescriptionTemplateInvitationType());
|
event.setNotificationType(notificationProperties.getDescriptionTemplateInvitationType());
|
||||||
NotificationFieldData data = new NotificationFieldData();
|
NotificationFieldData data = new NotificationFieldData();
|
||||||
List<FieldInfo> fieldInfoList = new ArrayList<>();
|
List<FieldInfo> fieldInfoList = new ArrayList<>();
|
||||||
|
|
|
@ -258,16 +258,15 @@ public class DmpServiceImpl implements DmpService {
|
||||||
if (!dmpUser.getUserId().equals(this.userScope.getUserIdSafe())){
|
if (!dmpUser.getUserId().equals(this.userScope.getUserIdSafe())){
|
||||||
UserEntity user = this.queryFactory.query(UserQuery.class).ids(dmpUser.getUserId()).first();
|
UserEntity user = this.queryFactory.query(UserQuery.class).ids(dmpUser.getUserId()).first();
|
||||||
if (user != null){
|
if (user != null){
|
||||||
this.createDmpNotificationEvent(dmp, user, NotificationContactType.EMAIL);
|
this.createDmpNotificationEvent(dmp, user);
|
||||||
this.createDmpNotificationEvent(dmp, user, NotificationContactType.IN_APP);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createDmpNotificationEvent(DmpEntity dmp, UserEntity user, NotificationContactType type) throws InvalidApplicationException {
|
private void createDmpNotificationEvent(DmpEntity dmp, UserEntity user) throws InvalidApplicationException {
|
||||||
NotifyIntegrationEvent event = new NotifyIntegrationEvent();
|
NotifyIntegrationEvent event = new NotifyIntegrationEvent();
|
||||||
event.setUserId(this.userScope.getUserId());
|
event.setUserId(user.getId());
|
||||||
UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId());
|
UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId());
|
||||||
query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal));
|
query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal));
|
||||||
|
|
||||||
|
@ -275,7 +274,6 @@ public class DmpServiceImpl implements DmpService {
|
||||||
contactPairs.add(new ContactPair(ContactInfoType.Email, query.first().getValue()));
|
contactPairs.add(new ContactPair(ContactInfoType.Email, query.first().getValue()));
|
||||||
NotificationContactData contactData = new NotificationContactData(contactPairs, null, null);
|
NotificationContactData contactData = new NotificationContactData(contactPairs, null, null);
|
||||||
event.setContactHint(jsonHandlingService.toJsonSafe(contactData));
|
event.setContactHint(jsonHandlingService.toJsonSafe(contactData));
|
||||||
event.setContactTypeHint(type);
|
|
||||||
|
|
||||||
this.applyNotificationType(dmp.getStatus(), event);
|
this.applyNotificationType(dmp.getStatus(), event);
|
||||||
NotificationFieldData data = new NotificationFieldData();
|
NotificationFieldData data = new NotificationFieldData();
|
||||||
|
@ -1186,6 +1184,15 @@ public class DmpServiceImpl implements DmpService {
|
||||||
throw new InvalidApplicationException("Dmp does not exist!");
|
throw new InvalidApplicationException("Dmp does not exist!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<DmpUserEntity> existingUsers = this.queryFactory.query(DmpUserQuery.class)
|
||||||
|
.dmpIds(dmp.getId())
|
||||||
|
.isActives(IsActive.Active)
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
if (this.conventionService.isListNullOrEmpty(existingUsers)){
|
||||||
|
throw new InvalidApplicationException("Dmp does not have users!");
|
||||||
|
}
|
||||||
|
|
||||||
List<DmpUserPersist> usersToAssign = new ArrayList<>();
|
List<DmpUserPersist> usersToAssign = new ArrayList<>();
|
||||||
for (DmpUserPersist user :users) {
|
for (DmpUserPersist user :users) {
|
||||||
UUID userId = null;
|
UUID userId = null;
|
||||||
|
@ -1200,7 +1207,7 @@ public class DmpServiceImpl implements DmpService {
|
||||||
if (userId != null){
|
if (userId != null){
|
||||||
user.setUser(userId);
|
user.setUser(userId);
|
||||||
usersToAssign.add(user);
|
usersToAssign.add(user);
|
||||||
if (this.userScope.getUserId() != userId){
|
if (this.userScope.getUserId() != userId && !existingUsers.stream().map(x -> x.getUserId()).collect(Collectors.toList()).contains(userId)){
|
||||||
this.sendDmpInvitationExistingUser(user.getUser(), dmp, user.getRole());
|
this.sendDmpInvitationExistingUser(user.getUser(), dmp, user.getRole());
|
||||||
}
|
}
|
||||||
}else if (user.getEmail() != null) {
|
}else if (user.getEmail() != null) {
|
||||||
|
@ -1215,20 +1222,18 @@ public class DmpServiceImpl implements DmpService {
|
||||||
private void sendDmpInvitationExistingUser(UUID userId, DmpEntity dmp, DmpUserRole role) throws InvalidApplicationException {
|
private void sendDmpInvitationExistingUser(UUID userId, DmpEntity dmp, DmpUserRole role) throws InvalidApplicationException {
|
||||||
UserEntity recipient = this.queryFactory.query(UserQuery.class).ids(userId).isActive(IsActive.Active).first();
|
UserEntity recipient = this.queryFactory.query(UserQuery.class).ids(userId).isActive(IsActive.Active).first();
|
||||||
String email = this.queryFactory.query(UserContactInfoQuery.class).userIds(recipient.getId()).first().getValue();
|
String email = this.queryFactory.query(UserContactInfoQuery.class).userIds(recipient.getId()).first().getValue();
|
||||||
this.createDmpInvitationExistingUserEvent(recipient, dmp, role, email, NotificationContactType.EMAIL);
|
this.createDmpInvitationExistingUserEvent(recipient, dmp, role, email);
|
||||||
this.createDmpInvitationExistingUserEvent(recipient, dmp, role, email, NotificationContactType.IN_APP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createDmpInvitationExistingUserEvent(UserEntity recipient, DmpEntity dmp, DmpUserRole role, String email, NotificationContactType type) throws InvalidApplicationException {
|
private void createDmpInvitationExistingUserEvent(UserEntity recipient, DmpEntity dmp, DmpUserRole role, String email) throws InvalidApplicationException {
|
||||||
|
|
||||||
NotifyIntegrationEvent event = new NotifyIntegrationEvent();
|
NotifyIntegrationEvent event = new NotifyIntegrationEvent();
|
||||||
event.setUserId(this.userScope.getUserIdSafe());
|
event.setUserId(recipient.getId());
|
||||||
|
|
||||||
List<ContactPair> contactPairs = new ArrayList<>();
|
List<ContactPair> contactPairs = new ArrayList<>();
|
||||||
contactPairs.add(new ContactPair(ContactInfoType.Email, email));
|
contactPairs.add(new ContactPair(ContactInfoType.Email, email));
|
||||||
NotificationContactData contactData = new NotificationContactData(contactPairs, null, null);
|
NotificationContactData contactData = new NotificationContactData(contactPairs, null, null);
|
||||||
event.setContactHint(jsonHandlingService.toJsonSafe(contactData));
|
event.setContactHint(jsonHandlingService.toJsonSafe(contactData));
|
||||||
event.setContactTypeHint(type);
|
|
||||||
event.setNotificationType(notificationProperties.getDmpInvitationExistingUserType());
|
event.setNotificationType(notificationProperties.getDmpInvitationExistingUserType());
|
||||||
NotificationFieldData data = new NotificationFieldData();
|
NotificationFieldData data = new NotificationFieldData();
|
||||||
List<FieldInfo> fieldInfoList = new ArrayList<>();
|
List<FieldInfo> fieldInfoList = new ArrayList<>();
|
||||||
|
@ -1246,7 +1251,6 @@ public class DmpServiceImpl implements DmpService {
|
||||||
String token = this.createActionConfirmation(email, dmp, role);
|
String token = this.createActionConfirmation(email, dmp, role);
|
||||||
|
|
||||||
NotifyIntegrationEvent event = new NotifyIntegrationEvent();
|
NotifyIntegrationEvent event = new NotifyIntegrationEvent();
|
||||||
event.setUserId(this.userScope.getUserIdSafe());
|
|
||||||
|
|
||||||
List<ContactPair> contactPairs = new ArrayList<>();
|
List<ContactPair> contactPairs = new ArrayList<>();
|
||||||
contactPairs.add(new ContactPair(ContactInfoType.Email, email));
|
contactPairs.add(new ContactPair(ContactInfoType.Email, email));
|
||||||
|
|
|
@ -375,7 +375,6 @@ public class UserServiceImpl implements UserService {
|
||||||
|
|
||||||
String token = this.createMergeAccountConfirmation(model.getEmail());
|
String token = this.createMergeAccountConfirmation(model.getEmail());
|
||||||
createMergeNotificationEvent(token, user, model.getEmail(), NotificationContactType.EMAIL);
|
createMergeNotificationEvent(token, user, model.getEmail(), NotificationContactType.EMAIL);
|
||||||
createMergeNotificationEvent(token, user, model.getEmail(), NotificationContactType.IN_APP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createMergeNotificationEvent(String token, UserEntity user, String email, NotificationContactType type) throws InvalidApplicationException {
|
private void createMergeNotificationEvent(String token, UserEntity user, String email, NotificationContactType type) throws InvalidApplicationException {
|
||||||
|
@ -405,7 +404,6 @@ public class UserServiceImpl implements UserService {
|
||||||
|
|
||||||
String token = this.createRemoveConfirmation(data.getId());
|
String token = this.createRemoveConfirmation(data.getId());
|
||||||
this.createRemoveCredentialNotificationEvent(token, data.getUserId(), NotificationContactType.EMAIL);
|
this.createRemoveCredentialNotificationEvent(token, data.getUserId(), NotificationContactType.EMAIL);
|
||||||
this.createRemoveCredentialNotificationEvent(token, data.getUserId(), NotificationContactType.IN_APP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createRemoveCredentialNotificationEvent(String token, UUID userId, NotificationContactType type) throws InvalidApplicationException {
|
private void createRemoveCredentialNotificationEvent(String token, UUID userId, NotificationContactType type) throws InvalidApplicationException {
|
||||||
|
|
|
@ -99,9 +99,9 @@ export class InAppNotificationEditorComponent extends BaseComponent implements O
|
||||||
maxWidth: '300px',
|
maxWidth: '300px',
|
||||||
restoreFocus: false,
|
restoreFocus: false,
|
||||||
data: {
|
data: {
|
||||||
message: this.language.instant('COMMONS.CONFIRMATION-DIALOG.DELETE-ITEM'),
|
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'),
|
||||||
confirmButton: this.language.instant('COMMONS.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'),
|
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'),
|
||||||
cancelButton: this.language.instant('COMMONS.CONFIRMATION-DIALOG.ACTIONS.CANCEL')
|
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||||
|
|
Loading…
Reference in New Issue