Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring

This commit is contained in:
Diamantis Tziotzios 2024-02-21 17:52:59 +02:00
commit 446268719d
14 changed files with 435 additions and 16 deletions

View File

@ -23,6 +23,10 @@ public class OutboxIntegrationEvent extends IntegrationEvent {
public static final String USER_REMOVE = "USER_REMOVE"; public static final String USER_REMOVE = "USER_REMOVE";
public static final String DMP_TOUCH = "DMP_TOUCH";
public static final String DESCRIPTION_TOUCH = "DESCRIPTION_TOUCH";
public static final String WHAT_YOU_KNOW_ABOUT_ME_COMPLETED = "WHAT_YOU_KNOW_ABOUT_ME_COMPLETED"; public static final String WHAT_YOU_KNOW_ABOUT_ME_COMPLETED = "WHAT_YOU_KNOW_ABOUT_ME_COMPLETED";
public static final String GENERATE_FILE = "GENERATE_FILE"; public static final String GENERATE_FILE = "GENERATE_FILE";

View File

@ -19,6 +19,10 @@ public class OutboxProperties {
private final String userTouchTopic; private final String userTouchTopic;
private final String dmpTouchTopic;
private final String descriptionTouchTopic;
private final String notifyTopic; private final String notifyTopic;
private final String forgetMeCompletedTopic; private final String forgetMeCompletedTopic;
@ -32,8 +36,8 @@ public class OutboxProperties {
String tenantRemovalTopic, String tenantRemovalTopic,
String tenantReactivationTopic, String tenantReactivationTopic,
String tenantUserInviteTopic, String tenantUserInviteTopic,
String userRemovalTopic, String userRemovalTopic,
String userTouchTopic, String userTouchTopic, String dmpTouchTopic, String descriptionTouchTopic,
String notifyTopic, String notifyTopic,
String forgetMeCompletedTopic, String forgetMeCompletedTopic,
String whatYouKnowAboutMeCompletedTopic, String whatYouKnowAboutMeCompletedTopic,
@ -46,6 +50,8 @@ public class OutboxProperties {
this.tenantUserInviteTopic = tenantUserInviteTopic; this.tenantUserInviteTopic = tenantUserInviteTopic;
this.userRemovalTopic = userRemovalTopic; this.userRemovalTopic = userRemovalTopic;
this.userTouchTopic = userTouchTopic; this.userTouchTopic = userTouchTopic;
this.dmpTouchTopic = dmpTouchTopic;
this.descriptionTouchTopic = descriptionTouchTopic;
this.notifyTopic = notifyTopic; this.notifyTopic = notifyTopic;
this.forgetMeCompletedTopic = forgetMeCompletedTopic; this.forgetMeCompletedTopic = forgetMeCompletedTopic;
this.whatYouKnowAboutMeCompletedTopic = whatYouKnowAboutMeCompletedTopic; this.whatYouKnowAboutMeCompletedTopic = whatYouKnowAboutMeCompletedTopic;
@ -80,6 +86,14 @@ public class OutboxProperties {
return userTouchTopic; return userTouchTopic;
} }
public String getDmpTouchTopic() {
return dmpTouchTopic;
}
public String getDescriptionTouchTopic() {
return descriptionTouchTopic;
}
public String getNotifyTopic() { public String getNotifyTopic() {
return notifyTopic; return notifyTopic;
} }

View File

@ -407,6 +407,14 @@ public class OutboxRepositoryImpl implements OutboxRepository {
routingKey = this.outboxProperties.getUserTouchTopic(); routingKey = this.outboxProperties.getUserTouchTopic();
break; break;
} }
case OutboxIntegrationEvent.DMP_TOUCH: {
routingKey = this.outboxProperties.getDmpTouchTopic();
break;
}
case OutboxIntegrationEvent.DESCRIPTION_TOUCH: {
routingKey = this.outboxProperties.getDescriptionTouchTopic();
break;
}
case OutboxIntegrationEvent.FORGET_ME_COMPLETED: { case OutboxIntegrationEvent.FORGET_ME_COMPLETED: {
routingKey = this.outboxProperties.getForgetMeCompletedTopic(); routingKey = this.outboxProperties.getForgetMeCompletedTopic();
break; break;

View File

@ -0,0 +1,102 @@
package eu.eudat.integrationevent.outbox.descriptiontouched;
import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.integrationevent.TrackedEvent;
import eu.eudat.model.persist.descriptionproperties.PropertyDefinitionPersist;
import java.util.List;
import java.util.UUID;
public class DescriptionTouchedIntegrationEvent extends TrackedEvent {
private UUID id;
private String label;
private UUID dmpId;
private UUID dmpDescriptionTemplateId;
private UUID descriptionTemplateId;
private DescriptionStatus status;
private String description;
private PropertyDefinitionPersist properties;
private List<String> tags;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public UUID getDmpId() {
return dmpId;
}
public void setDmpId(UUID dmpId) {
this.dmpId = dmpId;
}
public UUID getDmpDescriptionTemplateId() {
return dmpDescriptionTemplateId;
}
public void setDmpDescriptionTemplateId(UUID dmpDescriptionTemplateId) {
this.dmpDescriptionTemplateId = dmpDescriptionTemplateId;
}
public UUID getDescriptionTemplateId() {
return descriptionTemplateId;
}
public void setDescriptionTemplateId(UUID descriptionTemplateId) {
this.descriptionTemplateId = descriptionTemplateId;
}
public DescriptionStatus getStatus() {
return status;
}
public void setStatus(DescriptionStatus status) {
this.status = status;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public PropertyDefinitionPersist getProperties() {
return properties;
}
public void setProperties(PropertyDefinitionPersist properties) {
this.properties = properties;
}
public List<String> getTags() {
return tags;
}
public void setTags(List<String> tags) {
this.tags = tags;
}
}

View File

@ -0,0 +1,23 @@
package eu.eudat.integrationevent.outbox.descriptiontouched;
import eu.eudat.model.persist.DescriptionPersist;
public interface DescriptionTouchedIntegrationEventHandler {
void handle(DescriptionTouchedIntegrationEvent event);
static DescriptionTouchedIntegrationEvent buildEventFromPersistModel(DescriptionPersist persist) {
DescriptionTouchedIntegrationEvent event = new DescriptionTouchedIntegrationEvent();
event.setId(persist.getId());
event.setLabel(persist.getLabel());
event.setDmpId(persist.getDmpId());
event.setDmpDescriptionTemplateId(persist.getDmpDescriptionTemplateId());
event.setDescriptionTemplateId(persist.getDescriptionTemplateId());
event.setStatus(persist.getStatus());
event.setDescription(persist.getDescription());
event.setProperties(persist.getProperties());
event.setTags(persist.getTags());
return event;
}
}

View File

@ -0,0 +1,34 @@
package eu.eudat.integrationevent.outbox.descriptiontouched;
import eu.eudat.integrationevent.outbox.OutboxIntegrationEvent;
import eu.eudat.integrationevent.outbox.OutboxService;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DescriptionTouchedIntegrationEventHandlerImpl implements DescriptionTouchedIntegrationEventHandler {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTouchedIntegrationEventHandlerImpl.class));
private final OutboxService outboxService;
public DescriptionTouchedIntegrationEventHandlerImpl(OutboxService outboxService) {
this.outboxService = outboxService;
}
@Override
public void handle(DescriptionTouchedIntegrationEvent event) {
OutboxIntegrationEvent message = new OutboxIntegrationEvent();
message.setMessageId(UUID.randomUUID());
message.setType(OutboxIntegrationEvent.DESCRIPTION_TOUCH);
message.setEvent(event);
this.outboxService.publish(message);
}
}

View File

@ -0,0 +1,116 @@
package eu.eudat.integrationevent.outbox.dmptouched;
import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.integrationevent.TrackedEvent;
import eu.eudat.model.persist.DmpDescriptionTemplatePersist;
import eu.eudat.model.persist.dmpproperties.DmpBlueprintValuePersist;
import eu.eudat.model.persist.dmpproperties.DmpContactPersist;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class DmpTouchedIntegrationEvent extends TrackedEvent {
private UUID id;
private String label;
private DmpStatus status;
private List<DmpContactPersist> contacts;
private Map<UUID, DmpBlueprintValuePersist> dmpBlueprintValues;
private String description;
private String language;
private UUID blueprint;
private DmpAccessType accessType;
private List<DmpDescriptionTemplatePersist> descriptionTemplates;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public DmpStatus getStatus() {
return status;
}
public void setStatus(DmpStatus status) {
this.status = status;
}
public List<DmpContactPersist> getContacts() {
return contacts;
}
public void setContacts(List<DmpContactPersist> contacts) {
this.contacts = contacts;
}
public Map<UUID, DmpBlueprintValuePersist> getDmpBlueprintValues() {
return dmpBlueprintValues;
}
public void setDmpBlueprintValues(Map<UUID, DmpBlueprintValuePersist> dmpBlueprintValues) {
this.dmpBlueprintValues = dmpBlueprintValues;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public UUID getBlueprint() {
return blueprint;
}
public void setBlueprint(UUID blueprint) {
this.blueprint = blueprint;
}
public DmpAccessType getAccessType() {
return accessType;
}
public void setAccessType(DmpAccessType accessType) {
this.accessType = accessType;
}
public List<DmpDescriptionTemplatePersist> getDescriptionTemplates() {
return descriptionTemplates;
}
public void setDescriptionTemplates(List<DmpDescriptionTemplatePersist> descriptionTemplates) {
this.descriptionTemplates = descriptionTemplates;
}
}

View File

@ -0,0 +1,24 @@
package eu.eudat.integrationevent.outbox.dmptouched;
import eu.eudat.model.persist.DmpPersist;
public interface DmpTouchedIntegrationEventHandler {
void handle(DmpTouchedIntegrationEvent event);
static DmpTouchedIntegrationEvent buildEventFromPersistModel(DmpPersist persist) {
DmpTouchedIntegrationEvent event = new DmpTouchedIntegrationEvent();
event.setId(persist.getId());
event.setLabel(persist.getLabel());
event.setStatus(persist.getStatus());
event.setContacts(persist.getProperties().getContacts());
event.setDmpBlueprintValues(persist.getProperties().getDmpBlueprintValues());
event.setDescription(persist.getDescription());
event.setLanguage(persist.getLanguage());
event.setBlueprint(persist.getBlueprint());
event.setAccessType(persist.getAccessType());
event.setDescriptionTemplates(persist.getDescriptionTemplates());
return event;
}
}

View File

@ -0,0 +1,35 @@
package eu.eudat.integrationevent.outbox.dmptouched;
import eu.eudat.integrationevent.outbox.OutboxIntegrationEvent;
import eu.eudat.integrationevent.outbox.OutboxService;
import eu.eudat.integrationevent.outbox.tenantremoval.TenantRemovalIntegrationEventHandlerImpl;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DmpTouchedIntegrationEventHandlerImpl implements DmpTouchedIntegrationEventHandler {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpTouchedIntegrationEventHandlerImpl.class));
private final OutboxService outboxService;
public DmpTouchedIntegrationEventHandlerImpl(OutboxService outboxService) {
this.outboxService = outboxService;
}
@Override
public void handle(DmpTouchedIntegrationEvent event) {
OutboxIntegrationEvent message = new OutboxIntegrationEvent();
message.setMessageId(UUID.randomUUID());
message.setType(OutboxIntegrationEvent.DMP_TOUCH);
message.setEvent(event);
this.outboxService.publish(message);
}
}

View File

@ -20,6 +20,8 @@ import eu.eudat.data.*;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.event.DescriptionTouchedEvent; import eu.eudat.event.DescriptionTouchedEvent;
import eu.eudat.event.EventBroker; import eu.eudat.event.EventBroker;
import eu.eudat.integrationevent.outbox.descriptiontouched.DescriptionTouchedIntegrationEvent;
import eu.eudat.integrationevent.outbox.descriptiontouched.DescriptionTouchedIntegrationEventHandler;
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEvent; import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEvent;
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEventHandler; import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEventHandler;
import eu.eudat.model.*; import eu.eudat.model.*;
@ -94,22 +96,22 @@ public class DescriptionServiceImpl implements DescriptionService {
private final ValidatorFactory validatorFactory; private final ValidatorFactory validatorFactory;
private final StorageFileProperties storageFileConfig; private final StorageFileProperties storageFileConfig;
private final StorageFileService storageFileService; private final StorageFileService storageFileService;
private final DescriptionTouchedIntegrationEventHandler descriptionTouchedIntegrationEventHandler;
@Autowired @Autowired
public DescriptionServiceImpl( public DescriptionServiceImpl(
EntityManager entityManager, EntityManager entityManager,
AuthorizationService authorizationService, AuthorizationService authorizationService,
DeleterFactory deleterFactory, DeleterFactory deleterFactory,
BuilderFactory builderFactory, BuilderFactory builderFactory,
ConventionService conventionService, ConventionService conventionService,
ErrorThesaurusProperties errors, ErrorThesaurusProperties errors,
MessageSource messageSource, MessageSource messageSource,
EventBroker eventBroker, EventBroker eventBroker,
QueryFactory queryFactory, QueryFactory queryFactory,
JsonHandlingService jsonHandlingService, JsonHandlingService jsonHandlingService,
UserScope userScope, UserScope userScope,
XmlHandlingService xmlHandlingService, NotifyIntegrationEventHandler eventHandler, NotificationProperties notificationProperties, FileTransformerService fileTransformerService, ElasticService elasticService, ValidatorFactory validatorFactory, StorageFileProperties storageFileConfig, StorageFileService storageFileService) { XmlHandlingService xmlHandlingService, NotifyIntegrationEventHandler eventHandler, NotificationProperties notificationProperties, FileTransformerService fileTransformerService, ElasticService elasticService, ValidatorFactory validatorFactory, StorageFileProperties storageFileConfig, StorageFileService storageFileService, DescriptionTouchedIntegrationEventHandler descriptionTouchedIntegrationEventHandler) {
this.entityManager = entityManager; this.entityManager = entityManager;
this.authorizationService = authorizationService; this.authorizationService = authorizationService;
this.deleterFactory = deleterFactory; this.deleterFactory = deleterFactory;
@ -129,6 +131,7 @@ public class DescriptionServiceImpl implements DescriptionService {
this.validatorFactory = validatorFactory; this.validatorFactory = validatorFactory;
this.storageFileConfig = storageFileConfig; this.storageFileConfig = storageFileConfig;
this.storageFileService = storageFileService; this.storageFileService = storageFileService;
this.descriptionTouchedIntegrationEventHandler = descriptionTouchedIntegrationEventHandler;
} }
//region Persist //region Persist
@ -202,6 +205,8 @@ public class DescriptionServiceImpl implements DescriptionService {
//this.deleteOldFilesAndAddNew(datasetWizardModel, userInfo); //TODO //this.deleteOldFilesAndAddNew(datasetWizardModel, userInfo); //TODO
this.eventBroker.emit(new DescriptionTouchedEvent(data.getId())); this.eventBroker.emit(new DescriptionTouchedEvent(data.getId()));
this.descriptionTouchedIntegrationEventHandler.handle(DescriptionTouchedIntegrationEventHandler.buildEventFromPersistModel(model));
this.elasticService.persistDescription(data); this.elasticService.persistDescription(data);
return this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, Description._id), data); return this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, Description._id), data);
} }

View File

@ -23,6 +23,7 @@ import eu.eudat.data.*;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.event.DmpTouchedEvent; import eu.eudat.event.DmpTouchedEvent;
import eu.eudat.event.EventBroker; import eu.eudat.event.EventBroker;
import eu.eudat.integrationevent.outbox.dmptouched.DmpTouchedIntegrationEventHandler;
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEvent; import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEvent;
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEventHandler; import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEventHandler;
import eu.eudat.model.*; import eu.eudat.model.*;
@ -120,6 +121,8 @@ public class DmpServiceImpl implements DmpService {
private final ElasticService elasticService; private final ElasticService elasticService;
private final DmpTouchedIntegrationEventHandler dmpTouchedIntegrationEventHandler;
@Autowired @Autowired
public DmpServiceImpl( public DmpServiceImpl(
EntityManager entityManager, EntityManager entityManager,
@ -140,7 +143,7 @@ public class DmpServiceImpl implements DmpService {
ActionConfirmationService actionConfirmationService, ActionConfirmationService actionConfirmationService,
FileTransformerService fileTransformerService, FileTransformerService fileTransformerService,
ValidatorFactory validatorFactory, ValidatorFactory validatorFactory,
ElasticService elasticService) { ElasticService elasticService, DmpTouchedIntegrationEventHandler dmpTouchedIntegrationEventHandler) {
this.entityManager = entityManager; this.entityManager = entityManager;
this.authorizationService = authorizationService; this.authorizationService = authorizationService;
this.deleterFactory = deleterFactory; this.deleterFactory = deleterFactory;
@ -160,6 +163,7 @@ public class DmpServiceImpl implements DmpService {
this.actionConfirmationService = actionConfirmationService; this.actionConfirmationService = actionConfirmationService;
this.validatorFactory = validatorFactory; this.validatorFactory = validatorFactory;
this.elasticService = elasticService; this.elasticService = elasticService;
this.dmpTouchedIntegrationEventHandler = dmpTouchedIntegrationEventHandler;
} }
public Dmp persist(DmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, IOException { public Dmp persist(DmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, IOException {
@ -178,6 +182,8 @@ public class DmpServiceImpl implements DmpService {
this.eventBroker.emit(new DmpTouchedEvent(data.getId())); this.eventBroker.emit(new DmpTouchedEvent(data.getId()));
this.dmpTouchedIntegrationEventHandler.handle(DmpTouchedIntegrationEventHandler.buildEventFromPersistModel(model));
this.sendNotification(data); this.sendNotification(data);
this.elasticService.persistDmp(data); this.elasticService.persistDmp(data);

View File

@ -33,6 +33,8 @@ queue:
tenant-user-invite-topic: tenant.invite tenant-user-invite-topic: tenant.invite
user-touch-topic: user.touch user-touch-topic: user.touch
user-removal-topic: user.remove user-removal-topic: user.remove
dmp-touch-topic: dmp.touch
description-touch-topic: description.touch
what-you-know-about-me-completed-topic: whatyouknowaboutme.completed what-you-know-about-me-completed-topic: whatyouknowaboutme.completed
generate-file-topic: generate.file generate-file-topic: generate.file
rabbitmq: rabbitmq:

View File

@ -0,0 +1,22 @@
DO $$DECLARE
this_version CONSTANT varchar := '00.01.055';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
CREATE TABLE IF NOT EXISTS public."ant_Annotation"
(
"id" uuid NOT NULL,
"entity_id" uuid NOT NULL,
"entity_type" character varying(512) COLLATE pg_catalog."default" NOT NULL,
"anchor" character varying(512) COLLATE pg_catalog."default",
"payload" text COLLATE pg_catalog."default",
"created_at" timestamp without time zone NOT NULL,
"updated_at" timestamp without time zone NOT NULL,
"is_active" smallint NOT NULL,
CONSTRAINT "ant_Annotation_pkey" PRIMARY KEY (id),
);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.055', '2024-02-20 12:00:00.000000+02', now(), 'Add table ant_Annotation.');
END$$;

View File

@ -0,0 +1,24 @@
DO $$DECLARE
this_version CONSTANT varchar := '00.01.056';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
CREATE TABLE IF NOT EXISTS public."ant_EntityUser"
(
"id" uuid NOT NULL,
"entity_id" uuid NOT NULL,
"user_id" uuid NOT NULL,
"created_at" timestamp without time zone NOT NULL,
"updated_at" timestamp without time zone NOT NULL,
"is_active" smallint NOT NULL,
CONSTRAINT "ant_EntityUser_pkey" PRIMARY KEY (id),
CONSTRAINT "ant_EntityUser_user_fkey" FOREIGN KEY ("user_id")
REFERENCES public."ant_user" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.056', '2024-02-20 12:00:00.000000+02', now(), 'Add table ant_EntityUser.');
END$$;