remove old notification

This commit is contained in:
Efstratios Giannopoulos 2024-01-04 13:23:16 +02:00
parent a53396e38a
commit c056e04a89
8 changed files with 18 additions and 182 deletions

View File

@ -1,27 +0,0 @@
package eu.eudat.commons.enums.old.notification;
public enum ActiveStatus {
ACTIVE(0),
INACTIVE(1);
private int status;
ActiveStatus(int status) {
this.status = status;
}
public int getStatus() {
return status;
}
public ActiveStatus fromInteger(int status) {
switch (status) {
case 0:
return ACTIVE;
case 1:
return INACTIVE;
default:
throw new RuntimeException("Unsupported Active Status");
}
}
}

View File

@ -1,24 +0,0 @@
package eu.eudat.commons.enums.old.notification;
public enum ContactType {
EMAIL(0);
private int type;
ContactType(int type) {
this.type = type;
}
public int getType() {
return type;
}
public ContactType fromInteger(int type) {
switch (type) {
case 0:
return EMAIL;
default:
throw new RuntimeException("Unsupported Contact Type");
}
}
}

View File

@ -1,39 +0,0 @@
package eu.eudat.commons.enums.old.notification;
public enum NotificationType {
DMP_MODIFIED(0),
DATASET_MODIFIED(1),
DMP_PUBLISH(2),
DMP_FINALISED(3),
DMP_MODIFIED_FINALISED(4),
DATASET_MODIFIED_FINALISED(5);
private int type;
NotificationType(int type) {
this.type = type;
}
public int getType() {
return type;
}
public NotificationType fromInteger(int type) {
switch (type) {
case 0:
return DMP_MODIFIED;
case 1:
return DATASET_MODIFIED;
case 2:
return DMP_PUBLISH;
case 3:
return DMP_FINALISED;
case 4:
return DMP_MODIFIED_FINALISED;
case 5:
return DATASET_MODIFIED_FINALISED;
default:
throw new RuntimeException("Unsupported Notification Type");
}
}
}

View File

@ -1,36 +0,0 @@
package eu.eudat.commons.enums.old.notification;
public enum NotifyState {
PENDING(0),
PROCESSING(1),
SENDING(2),
SUCCEEDED(3),
ERROR(4);
private int state;
NotifyState(int state) {
this.state = state;
}
public int getState() {
return state;
}
public NotifyState fromInteger(int state) {
switch (state) {
case 0:
return PENDING;
case 1:
return PROCESSING;
case 2:
return SENDING;
case 3:
return SUCCEEDED;
case 4:
return ERROR;
default:
throw new RuntimeException("Unsupported Notify State");
}
}
}

View File

@ -1,7 +1,6 @@
package eu.eudat.integrationevent.outbox.notification; package eu.eudat.integrationevent.outbox.notification;
import eu.eudat.commons.enums.notification.NotificationContactType; import eu.eudat.commons.enums.notification.NotificationContactType;
import eu.eudat.commons.enums.old.notification.NotificationType;
import eu.eudat.integrationevent.TrackedEvent; import eu.eudat.integrationevent.TrackedEvent;
import java.util.UUID; import java.util.UUID;

View File

@ -1,26 +0,0 @@
package eu.eudat.data.dao.criteria;
import eu.eudat.commons.enums.old.notification.ActiveStatus;
import eu.eudat.commons.enums.old.notification.NotifyState;
public class NotificationCriteria {
private ActiveStatus isActive;
private NotifyState notifyState;
public ActiveStatus getIsActive() {
return isActive;
}
public void setIsActive(ActiveStatus isActive) {
this.isActive = isActive;
}
public NotifyState getNotifyState() {
return notifyState;
}
public void setNotifyState(NotifyState notifyState) {
this.notifyState = notifyState;
}
}

View File

@ -12,10 +12,6 @@ import eu.eudat.data.*;
import eu.eudat.data.dao.criteria.*; import eu.eudat.data.dao.criteria.*;
import eu.eudat.data.dao.entities.*; import eu.eudat.data.dao.entities.*;
import eu.eudat.data.old.*; import eu.eudat.data.old.*;
import eu.eudat.commons.enums.old.notification.ActiveStatus;
import eu.eudat.commons.enums.old.notification.ContactType;
import eu.eudat.commons.enums.old.notification.NotificationType;
import eu.eudat.commons.enums.old.notification.NotifyState;
import eu.eudat.data.query.items.table.dataset.DatasetTableRequest; import eu.eudat.data.query.items.table.dataset.DatasetTableRequest;
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem; import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest; import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
@ -94,12 +90,12 @@ public class DataManagementPlanManager {
private static final Logger logger = LoggerFactory.getLogger(DataManagementPlanManager.class); private static final Logger logger = LoggerFactory.getLogger(DataManagementPlanManager.class);
private final ObjectMapper objectMapper; private final ObjectMapper objectMapper;
private final Map<NotificationType, String> notificationPaths = Stream.of(new Object[][] { // private final Map<NotificationType, String> notificationPaths = Stream.of(new Object[][] {
{NotificationType.DMP_MODIFIED, "/plans/edit"}, // {NotificationType.DMP_MODIFIED, "/plans/edit"},
{NotificationType.DMP_PUBLISH, "/plans/publicEdit"}, // {NotificationType.DMP_PUBLISH, "/plans/publicEdit"},
{NotificationType.DMP_FINALISED, "/plans/edit"}, // {NotificationType.DMP_FINALISED, "/plans/edit"},
{NotificationType.DMP_MODIFIED_FINALISED, "/plans/edit"} // {NotificationType.DMP_MODIFIED_FINALISED, "/plans/edit"}
}).collect(Collectors.toMap(data -> (NotificationType) data[0], data -> (String) data[1])); // }).collect(Collectors.toMap(data -> (NotificationType) data[0], data -> (String) data[1]));
private ApiContext apiContext; private ApiContext apiContext;
private DatasetManager datasetManager; private DatasetManager datasetManager;
@ -624,9 +620,9 @@ public class DataManagementPlanManager {
if (setNotification) { if (setNotification) {
if (newDmp.getStatus().equals(DmpStatus.Finalized.getValue())) { if (newDmp.getStatus().equals(DmpStatus.Finalized.getValue())) {
this.sendNotification(newDmp, user, NotificationType.DMP_MODIFIED); this.sendNotification(newDmp, user/*, NotificationType.DMP_MODIFIED*/);
} else { } else {
this.sendNotification(newDmp, user, NotificationType.DMP_MODIFIED_FINALISED); this.sendNotification(newDmp, user/*, , NotificationType.DMP_MODIFIED_FINALISED*/);
} }
} }
@ -1222,7 +1218,7 @@ public class DataManagementPlanManager {
// }); // });
}); });
UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first(); UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first();
sendNotification(dmp, user, NotificationType.DMP_PUBLISH); sendNotification(dmp, user/*, , NotificationType.DMP_PUBLISH*/);
} }
@Transactional @Transactional
@ -1308,7 +1304,7 @@ public class DataManagementPlanManager {
// dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList())); //TODO // dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList())); //TODO
//this.updateIndex(dmp); //TODO //this.updateIndex(dmp); //TODO
UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first(); UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first();
sendNotification(dmp, user, NotificationType.DMP_FINALISED); sendNotification(dmp, user/*, , NotificationType.DMP_FINALISED*/);
metricsManager.decreaseValue(MetricNames.DMP, 1, MetricNames.DRAFT); metricsManager.decreaseValue(MetricNames.DMP, 1, MetricNames.DRAFT);
metricsManager.increaseValue(MetricNames.DMP, 1, MetricNames.FINALIZED); metricsManager.increaseValue(MetricNames.DMP, 1, MetricNames.FINALIZED);
//this.updateDatasetsIndex(indexDescriptionEntities); //TODO //this.updateDatasetsIndex(indexDescriptionEntities); //TODO
@ -2668,7 +2664,7 @@ public class DataManagementPlanManager {
* Misc * Misc
* */ * */
private void sendNotification(DmpEntity dmp, UserEntity user, NotificationType notificationType) throws InvalidApplicationException { private void sendNotification(DmpEntity dmp, UserEntity user/*, NotificationType notificationType*/) throws InvalidApplicationException {
List<DmpUserEntity> userDMPS = this.queryFactory.query(DmpUserQuery.class).dmpIds(dmp.getId()).collect(); List<DmpUserEntity> userDMPS = this.queryFactory.query(DmpUserQuery.class).dmpIds(dmp.getId()).collect();
for (DmpUserEntity userDMP : userDMPS) { for (DmpUserEntity userDMP : userDMPS) {
if (!userDMP.getUserId().equals(user.getId())) { if (!userDMP.getUserId().equals(user.getId())) {

View File

@ -13,16 +13,13 @@ import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.*; import eu.eudat.data.*;
import eu.eudat.data.dao.criteria.*; import eu.eudat.data.dao.criteria.*;
import eu.eudat.data.dao.entities.DatasetDao; import eu.eudat.data.dao.entities.DatasetDao;
import eu.eudat.commons.enums.old.notification.ActiveStatus;
import eu.eudat.commons.enums.old.notification.ContactType;
import eu.eudat.commons.enums.old.notification.NotificationType;
import eu.eudat.commons.enums.old.notification.NotifyState;
import eu.eudat.data.old.*; import eu.eudat.data.old.*;
import eu.eudat.data.query.items.table.dataset.DatasetPublicTableRequest; import eu.eudat.data.query.items.table.dataset.DatasetPublicTableRequest;
import eu.eudat.data.query.items.table.dataset.DatasetTableRequest; import eu.eudat.data.query.items.table.dataset.DatasetTableRequest;
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem; import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
import eu.eudat.exceptions.security.ForbiddenException; import eu.eudat.exceptions.security.ForbiddenException;
import eu.eudat.exceptions.security.UnauthorisedException; import eu.eudat.exceptions.security.UnauthorisedException;
import eu.eudat.file.transformer.enums.old.notification.NotificationType;
import eu.eudat.logic.builders.BuilderFactory; import eu.eudat.logic.builders.BuilderFactory;
import eu.eudat.logic.builders.entity.UserInfoBuilder; import eu.eudat.logic.builders.entity.UserInfoBuilder;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader; import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
@ -30,7 +27,6 @@ import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.forms.VisibilityRuleService; import eu.eudat.logic.services.forms.VisibilityRuleService;
import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl; import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl;
import eu.eudat.logic.services.operations.DatabaseRepository; import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.model.UserContactInfo;
import eu.eudat.model.file.FileEnvelope; import eu.eudat.model.file.FileEnvelope;
import eu.eudat.logic.utilities.documents.types.ParagraphStyle; import eu.eudat.logic.utilities.documents.types.ParagraphStyle;
import eu.eudat.logic.utilities.documents.word.WordBuilder; import eu.eudat.logic.utilities.documents.word.WordBuilder;
@ -43,18 +39,15 @@ import eu.eudat.models.data.datasetImport.DatasetImportPagedDatasetProfile;
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel; import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.data.dmp.AssociatedProfile; import eu.eudat.models.data.dmp.AssociatedProfile;
import eu.eudat.models.data.dmp.DataManagementPlan;
import eu.eudat.models.data.helpers.common.DataTableData; import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.listingmodels.DatasetListingModel; import eu.eudat.models.data.listingmodels.DatasetListingModel;
import eu.eudat.models.data.user.composite.PagedDatasetProfile; import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.query.DescriptionTemplateQuery; import eu.eudat.query.DescriptionTemplateQuery;
import eu.eudat.query.DmpDescriptionTemplateQuery; import eu.eudat.query.DmpDescriptionTemplateQuery;
import eu.eudat.query.DmpUserQuery; import eu.eudat.query.DmpUserQuery;
import eu.eudat.query.UserContactInfoQuery;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import eu.eudat.types.MetricNames; import eu.eudat.types.MetricNames;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.query.Ordering;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor; import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument;
@ -102,10 +95,10 @@ import java.util.stream.Stream;
public class DatasetManager { public class DatasetManager {
private static final Logger logger = LoggerFactory.getLogger(DatasetManager.class); private static final Logger logger = LoggerFactory.getLogger(DatasetManager.class);
private final Map<NotificationType, String> notificationPaths = Stream.of(new Object[][] { // private final Map<NotificationType, String> notificationPaths = Stream.of(new Object[][] {
{NotificationType.DATASET_MODIFIED, "/datasets/edit"}, // {NotificationType.DATASET_MODIFIED, "/datasets/edit"},
{NotificationType.DATASET_MODIFIED_FINALISED, "/datasets/edit"} // {NotificationType.DATASET_MODIFIED_FINALISED, "/datasets/edit"}
}).collect(Collectors.toMap(data -> (NotificationType) data[0], data -> (String) data[1])); // }).collect(Collectors.toMap(data -> (NotificationType) data[0], data -> (String) data[1]));
private ApiContext apiContext; private ApiContext apiContext;
private DatabaseRepository databaseRepository; private DatabaseRepository databaseRepository;
@ -676,9 +669,9 @@ public class DatasetManager {
//updateTags(descriptionEntity1, datasetWizardModel.getTags()); //TODO //updateTags(descriptionEntity1, datasetWizardModel.getTags()); //TODO
if (sendNotification) { if (sendNotification) {
if (descriptionEntity1.getStatus() != DescriptionStatus.Finalized) { if (descriptionEntity1.getStatus() != DescriptionStatus.Finalized) {
this.sendNotification(descriptionEntity1, dmp1, userInfo, NotificationType.DATASET_MODIFIED); this.sendNotification(descriptionEntity1, dmp1, userInfo, null/*NotificationType.DATASET_MODIFIED*/);
} else { } else {
this.sendNotification(descriptionEntity1, dmp1, userInfo, NotificationType.DATASET_MODIFIED_FINALISED); this.sendNotification(descriptionEntity1, dmp1, userInfo, null/*NotificationType.DATASET_MODIFIED_FINALISED*/);
} }
} }