rename annotation status integration event

This commit is contained in:
amentis 2024-07-02 17:30:18 +03:00
parent 6689722799
commit 78772e2371
9 changed files with 61 additions and 46 deletions

View File

@ -15,7 +15,7 @@ public class NotificationProperties {
private UUID descriptionModifiedType;
private UUID descriptionFinalisedType;
private UUID descriptionAnnotationCreated;
private UUID descriptionAnnotationStatusResolved;
private UUID descriptionAnnotationStatusChanged;
private UUID mergeAccountConfirmationType;
private UUID removeCredentialConfirmationType;
private UUID dmpDepositType;
@ -155,12 +155,12 @@ public class NotificationProperties {
this.descriptionAnnotationCreated = descriptionAnnotationCreated;
}
public UUID getDescriptionAnnotationStatusResolved() {
return descriptionAnnotationStatusResolved;
public UUID getDescriptionAnnotationStatusChanged() {
return descriptionAnnotationStatusChanged;
}
public void setDescriptionAnnotationStatusResolved(UUID descriptionAnnotationStatusResolved) {
this.descriptionAnnotationStatusResolved = descriptionAnnotationStatusResolved;
public void setDescriptionAnnotationStatusChanged(UUID descriptionAnnotationStatusChanged) {
this.descriptionAnnotationStatusChanged = descriptionAnnotationStatusChanged;
}
public UUID getTenantSpecificInvitationExternalUserType() {

View File

@ -33,7 +33,7 @@ public class AppRabbitConfigurer extends RabbitConfigurer {
public InboxBindings inboxBindingsCreator() {
List<String> bindingItems = new ArrayList<>();
if (this.inboxProperties.getAnnotationCreatedTopic() != null) bindingItems.addAll(this.inboxProperties.getAnnotationCreatedTopic());
if (this.inboxProperties.getAnnotationStatusResolvedTopic() != null) bindingItems.addAll(this.inboxProperties.getAnnotationStatusResolvedTopic());
if (this.inboxProperties.getAnnotationStatusChangedTopic() != null) bindingItems.addAll(this.inboxProperties.getAnnotationStatusChangedTopic());
return new InboxBindings(bindingItems);
}

View File

@ -16,13 +16,13 @@ public class InboxProperties {
private final List<String> annotationCreatedTopic;
private final List<String> annotationStatusResolvedTopic;
private final List<String> annotationStatusChangedTopic;
public InboxProperties(
String exchange, List<String> annotationCreatedTopic, List<String> annotationStatusResolvedTopic) {
String exchange, List<String> annotationCreatedTopic, List<String> annotationStatusChangedTopic) {
this.exchange = exchange;
this.annotationCreatedTopic = annotationCreatedTopic;
this.annotationStatusResolvedTopic = annotationStatusResolvedTopic;
this.annotationStatusChangedTopic = annotationStatusChangedTopic;
}
public String getExchange() {
@ -33,7 +33,7 @@ public class InboxProperties {
return annotationCreatedTopic;
}
public List<String> getAnnotationStatusResolvedTopic() {
return annotationStatusResolvedTopic;
public List<String> getAnnotationStatusChangedTopic() {
return annotationStatusChangedTopic;
}
}

View File

@ -16,7 +16,7 @@ import org.opencdmp.commons.fake.FakeRequestScope;
import org.opencdmp.data.QueueInboxEntity;
import org.opencdmp.data.TenantEntityManager;
import org.opencdmp.integrationevent.inbox.annotationentitycreated.AnnotationEntityCreatedIntegrationEventHandler;
import org.opencdmp.integrationevent.inbox.annotationstatusentityresolved.AnnotationStatusEntityResolvedIntegrationEventHandler;
import org.opencdmp.integrationevent.inbox.annotationstatusentitychanged.AnnotationStatusEntityChangedIntegrationEventHandler;
import org.opencdmp.query.QueueInboxQuery;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
@ -394,8 +394,8 @@ public class InboxRepositoryImpl implements InboxRepository {
logger.debug("Processing message with routing key '{}'", queueInboxMessage.getRoute());
if (this.routingKeyMatched(queueInboxMessage.getRoute(), this.inboxProperties.getAnnotationCreatedTopic()))
handler = this.applicationContext.getBean(AnnotationEntityCreatedIntegrationEventHandler.class);
else if (this.routingKeyMatched(queueInboxMessage.getRoute(), this.inboxProperties.getAnnotationStatusResolvedTopic()))
handler = this.applicationContext.getBean(AnnotationStatusEntityResolvedIntegrationEventHandler.class);
else if (this.routingKeyMatched(queueInboxMessage.getRoute(), this.inboxProperties.getAnnotationStatusChangedTopic()))
handler = this.applicationContext.getBean(AnnotationStatusEntityChangedIntegrationEventHandler.class);
else {
logger.error("No handler found for message routing key '{}'. Discarding.", queueInboxMessage.getRoute());
handler = null;

View File

@ -1,4 +1,4 @@
package org.opencdmp.integrationevent.inbox.annotationstatusentityresolved;
package org.opencdmp.integrationevent.inbox.annotationstatusentitychanged;
import gr.cite.tools.validation.ValidatorFactory;
import gr.cite.tools.validation.specification.Specification;
@ -16,7 +16,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.UUID;
public class AnnotationStatusEntityResolvedIntegrationEvent extends TrackedEvent {
public class AnnotationStatusEntityChangedIntegrationEvent extends TrackedEvent {
private UUID id;
public static final String _id = "id";
@ -39,6 +39,9 @@ public class AnnotationStatusEntityResolvedIntegrationEvent extends TrackedEvent
private String anchor;
public static final String _anchor = "anchor";
private String statusLabel;
public static final String _statusLabel = "statusLabel";
public UUID getId() {
return id;
}
@ -95,51 +98,62 @@ public class AnnotationStatusEntityResolvedIntegrationEvent extends TrackedEvent
this.anchor = anchor;
}
@Component(AnnotationStatusEntityResolvedIntegrationEventValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class AnnotationStatusEntityResolvedIntegrationEventValidator extends BaseValidator<AnnotationStatusEntityResolvedIntegrationEvent> {
public String getStatusLabel() {
return statusLabel;
}
public static final String ValidatorName = "AnnotationStatusEntityResolvedIntegrationEventValidator";
public void setStatusLabel(String statusLabel) {
this.statusLabel = statusLabel;
}
@Component(AnnotationStatusEntityChangedIntegrationEventValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class AnnotationStatusEntityChangedIntegrationEventValidator extends BaseValidator<AnnotationStatusEntityChangedIntegrationEvent> {
public static final String ValidatorName = "AnnotationStatusEntityChangedIntegrationEventValidator";
private final MessageSource messageSource;
private final ValidatorFactory validatorFactory;
protected AnnotationStatusEntityResolvedIntegrationEventValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
protected AnnotationStatusEntityChangedIntegrationEventValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
super(conventionService, errors);
this.messageSource = messageSource;
this.validatorFactory = validatorFactory;
}
@Override
protected Class<AnnotationStatusEntityResolvedIntegrationEvent> modelClass() {
return AnnotationStatusEntityResolvedIntegrationEvent.class;
protected Class<AnnotationStatusEntityChangedIntegrationEvent> modelClass() {
return AnnotationStatusEntityChangedIntegrationEvent.class;
}
@Override
protected List<Specification> specifications(AnnotationStatusEntityResolvedIntegrationEvent item) {
protected List<Specification> specifications(AnnotationStatusEntityChangedIntegrationEvent item) {
return Arrays.asList(
this.spec()
.must(() -> this.isValidGuid(item.getId()))
.failOn(AnnotationStatusEntityResolvedIntegrationEvent._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{AnnotationStatusEntityResolvedIntegrationEvent._id}, LocaleContextHolder.getLocale())),
.failOn(AnnotationStatusEntityChangedIntegrationEvent._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{AnnotationStatusEntityChangedIntegrationEvent._id}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> this.isValidGuid(item.getAnnotationId()))
.failOn(AnnotationStatusEntityResolvedIntegrationEvent._annotationId).failWith(messageSource.getMessage("Validation_Required", new Object[]{AnnotationStatusEntityResolvedIntegrationEvent._annotationId}, LocaleContextHolder.getLocale())),
.failOn(AnnotationStatusEntityChangedIntegrationEvent._annotationId).failWith(messageSource.getMessage("Validation_Required", new Object[]{AnnotationStatusEntityChangedIntegrationEvent._annotationId}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> this.isValidGuid(item.getStatusId()))
.failOn(AnnotationStatusEntityResolvedIntegrationEvent._statusId).failWith(messageSource.getMessage("Validation_Required", new Object[]{AnnotationStatusEntityResolvedIntegrationEvent._statusId}, LocaleContextHolder.getLocale())),
.failOn(AnnotationStatusEntityChangedIntegrationEvent._statusId).failWith(messageSource.getMessage("Validation_Required", new Object[]{AnnotationStatusEntityChangedIntegrationEvent._statusId}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> this.isValidGuid(item.getSubjectId()))
.failOn(AnnotationStatusEntityResolvedIntegrationEvent._subjectId).failWith(messageSource.getMessage("Validation_Required", new Object[]{AnnotationStatusEntityResolvedIntegrationEvent._subjectId}, LocaleContextHolder.getLocale())),
.failOn(AnnotationStatusEntityChangedIntegrationEvent._subjectId).failWith(messageSource.getMessage("Validation_Required", new Object[]{AnnotationStatusEntityChangedIntegrationEvent._subjectId}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> this.isValidGuid(item.getEntityId()))
.failOn(AnnotationStatusEntityResolvedIntegrationEvent._entityId).failWith(messageSource.getMessage("Validation_Required", new Object[]{AnnotationStatusEntityResolvedIntegrationEvent._entityId}, LocaleContextHolder.getLocale())),
.failOn(AnnotationStatusEntityChangedIntegrationEvent._entityId).failWith(messageSource.getMessage("Validation_Required", new Object[]{AnnotationStatusEntityChangedIntegrationEvent._entityId}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getEntityType()))
.failOn(AnnotationStatusEntityResolvedIntegrationEvent._entityType).failWith(messageSource.getMessage("Validation_Required", new Object[]{AnnotationStatusEntityResolvedIntegrationEvent._entityType}, LocaleContextHolder.getLocale())),
.failOn(AnnotationStatusEntityChangedIntegrationEvent._entityType).failWith(messageSource.getMessage("Validation_Required", new Object[]{AnnotationStatusEntityChangedIntegrationEvent._entityType}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getAnchor()))
.failOn(AnnotationStatusEntityResolvedIntegrationEvent._anchor).failWith(messageSource.getMessage("Validation_Required", new Object[]{AnnotationStatusEntityResolvedIntegrationEvent._anchor}, LocaleContextHolder.getLocale()))
.failOn(AnnotationStatusEntityChangedIntegrationEvent._anchor).failWith(messageSource.getMessage("Validation_Required", new Object[]{AnnotationStatusEntityChangedIntegrationEvent._anchor}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getStatusLabel()))
.failOn(AnnotationStatusEntityChangedIntegrationEvent._statusLabel).failWith(messageSource.getMessage("Validation_Required", new Object[]{AnnotationStatusEntityChangedIntegrationEvent._statusLabel}, LocaleContextHolder.getLocale()))
);
}
}

View File

@ -1,6 +1,6 @@
package org.opencdmp.integrationevent.inbox.annotationstatusentityresolved;
package org.opencdmp.integrationevent.inbox.annotationstatusentitychanged;
import org.opencdmp.integrationevent.inbox.IntegrationEventHandler;
public interface AnnotationStatusEntityResolvedIntegrationEventHandler extends IntegrationEventHandler {
public interface AnnotationStatusEntityChangedIntegrationEventHandler extends IntegrationEventHandler {
}

View File

@ -1,4 +1,4 @@
package org.opencdmp.integrationevent.inbox.annotationstatusentityresolved;
package org.opencdmp.integrationevent.inbox.annotationstatusentitychanged;
import gr.cite.commons.web.oidc.principal.CurrentPrincipalResolver;
import gr.cite.commons.web.oidc.principal.extractor.ClaimExtractorProperties;
@ -45,9 +45,9 @@ import java.util.*;
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class AnnotationStatusEntityResolvedIntegrationEventHandlerImpl implements AnnotationStatusEntityResolvedIntegrationEventHandler {
public class AnnotationStatusEntityChangedIntegrationEventHandlerImpl implements AnnotationStatusEntityChangedIntegrationEventHandler {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(AnnotationStatusEntityResolvedIntegrationEventHandlerImpl.class));
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(AnnotationStatusEntityChangedIntegrationEventHandlerImpl.class));
private final QueryFactory queryFactory;
private final JsonHandlingService jsonHandlingService;
@ -63,7 +63,7 @@ public class AnnotationStatusEntityResolvedIntegrationEventHandlerImpl implement
private final ValidatorFactory validatorFactory;
private final AuditService auditService;
public AnnotationStatusEntityResolvedIntegrationEventHandlerImpl(QueryFactory queryFactory, JsonHandlingService jsonHandlingService, NotificationProperties notificationProperties, TenantScope tenantScope, NotifyIntegrationEventHandler notifyIntegrationEventHandler, CurrentPrincipalResolver currentPrincipalResolver, ClaimExtractorProperties claimExtractorProperties, MessageSource messageSource, UserScope userScope, ErrorThesaurusProperties errors, TenantEntityManager tenantEntityManager, ValidatorFactory validatorFactory, AuditService auditService) {
public AnnotationStatusEntityChangedIntegrationEventHandlerImpl(QueryFactory queryFactory, JsonHandlingService jsonHandlingService, NotificationProperties notificationProperties, TenantScope tenantScope, NotifyIntegrationEventHandler notifyIntegrationEventHandler, CurrentPrincipalResolver currentPrincipalResolver, ClaimExtractorProperties claimExtractorProperties, MessageSource messageSource, UserScope userScope, ErrorThesaurusProperties errors, TenantEntityManager tenantEntityManager, ValidatorFactory validatorFactory, AuditService auditService) {
this.queryFactory = queryFactory;
this.jsonHandlingService = jsonHandlingService;
this.notificationProperties = notificationProperties;
@ -81,12 +81,12 @@ public class AnnotationStatusEntityResolvedIntegrationEventHandlerImpl implement
@Override
public EventProcessingStatus handle(IntegrationEventProperties properties, String message) throws InvalidApplicationException {
AnnotationStatusEntityResolvedIntegrationEvent event = this.jsonHandlingService.fromJsonSafe(AnnotationStatusEntityResolvedIntegrationEvent.class, message);
AnnotationStatusEntityChangedIntegrationEvent event = this.jsonHandlingService.fromJsonSafe(AnnotationStatusEntityChangedIntegrationEvent.class, message);
if (event == null)
return EventProcessingStatus.Error;
logger.debug("Handling {}", AnnotationStatusEntityResolvedIntegrationEvent.class.getSimpleName());
this.validatorFactory.validator(AnnotationStatusEntityResolvedIntegrationEvent.AnnotationStatusEntityResolvedIntegrationEventValidator.class).validateForce(event);
logger.debug("Handling {}", AnnotationStatusEntityChangedIntegrationEvent.class.getSimpleName());
this.validatorFactory.validator(AnnotationStatusEntityChangedIntegrationEvent.AnnotationStatusEntityChangedIntegrationEventValidator.class).validateForce(event);
EventProcessingStatus status = EventProcessingStatus.Success;
try {
@ -123,7 +123,7 @@ public class AnnotationStatusEntityResolvedIntegrationEventHandlerImpl implement
return status;
}
private void sendNotification(AnnotationStatusEntityResolvedIntegrationEvent event) throws InvalidApplicationException {
private void sendNotification(AnnotationStatusEntityChangedIntegrationEvent event) throws InvalidApplicationException {
DescriptionEntity descriptionEntity = this.queryFactory.query(DescriptionQuery.class).disableTracking().ids(event.getEntityId()).first();
@ -150,16 +150,16 @@ public class AnnotationStatusEntityResolvedIntegrationEventHandlerImpl implement
UserEntity user = this.queryFactory.query(UserQuery.class).disableTracking().ids(dmpUserId).first();
if (user == null || user.getIsActive().equals(IsActive.Inactive))
throw new MyValidationException(this.errors.getDmpInactiveUser().getCode(), this.errors.getDmpInactiveUser().getMessage());
this.createAnnotationStatusResolvedNotificationEvent(user, descriptionEntity, sender.getName(), event.getAnchor());
this.createAnnotationStatusChangedNotificationEvent(user, descriptionEntity, sender.getName(), event.getAnchor(), event.getStatusLabel());
}
}
private void createAnnotationStatusResolvedNotificationEvent(UserEntity user, DescriptionEntity description, String reasonName, String anchor) throws InvalidApplicationException, InvalidApplicationException {
private void createAnnotationStatusChangedNotificationEvent(UserEntity user, DescriptionEntity description, String reasonName, String anchor, String statusLabel) throws InvalidApplicationException, InvalidApplicationException {
NotifyIntegrationEvent notifyIntegrationEvent = new NotifyIntegrationEvent();
notifyIntegrationEvent.setUserId(user.getId());
notifyIntegrationEvent.setNotificationType(this.notificationProperties.getDescriptionAnnotationStatusResolved());
notifyIntegrationEvent.setNotificationType(this.notificationProperties.getDescriptionAnnotationStatusChanged());
NotificationFieldData data = new NotificationFieldData();
List<FieldInfo> fieldInfoList = new ArrayList<>();
@ -167,6 +167,7 @@ public class AnnotationStatusEntityResolvedIntegrationEventHandlerImpl implement
fieldInfoList.add(new FieldInfo("{reasonName}", DataType.String, reasonName));
fieldInfoList.add(new FieldInfo("{name}", DataType.String, description.getLabel()));
fieldInfoList.add(new FieldInfo("{id}", DataType.String, description.getId().toString()));
fieldInfoList.add(new FieldInfo("{status}", DataType.String, statusLabel));
String anchorUrl = "f/"+anchor+"/annotation";
fieldInfoList.add(new FieldInfo("{anchor}", DataType.String, anchorUrl));
if(this.tenantScope.getTenantCode() != null && !this.tenantScope.getTenantCode().equals(this.tenantScope.getDefaultTenantCode())){

View File

@ -7,7 +7,7 @@ notification:
descriptionModifiedType: 4FDBFA80-7A71-4A69-B854-67CBB70648F1
descriptionFinalisedType: 33790bad-94d4-488a-8ee2-7f6295ca18ea
descriptionAnnotationCreated: db1e99d2-a240-4e75-9bb2-ef25b234c1f0
descriptionAnnotationStatusResolved: 3189e3a6-91e6-40c6-8ff8-275a68445aec
descriptionAnnotationStatusChanged: 3189e3a6-91e6-40c6-8ff8-275a68445aec
mergeAccountConfirmationType: BFE68845-CB05-4C5A-A03D-29161A7C9660
removeCredentialConfirmationType: C9BC3F16-057E-4BBA-8A5F-36BD835E5604
dmpDepositType: 55736F7A-83AB-4190-AF43-9D031A6F9612

View File

@ -59,7 +59,7 @@ queue:
options:
exchange: null
annotation-created-topic: annotation.created
annotation-status-resolved-topic: annotationStatus.resolved
annotation-status-changed-topic: annotationStatus.changed
rabbitmq:
enable: true
interval-seconds: 3