diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/EntityDoiEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/EntityDoiEntity.java index 761e043a5..3637bee88 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/data/EntityDoiEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/data/EntityDoiEntity.java @@ -53,9 +53,8 @@ public class EntityDoiEntity { public static final String _isActive = "isActive"; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "entity_id", nullable = false) - private DMP entityId; + @Column(name = "entity_id", nullable = false) + private UUID entityId; public static final String _entityId = "entityId"; @@ -115,11 +114,11 @@ public class EntityDoiEntity { this.isActive = isActive; } - public DMP getEntityId() { + public UUID getEntityId() { return entityId; } - public void setEntityId(DMP entityId) { + public void setEntityId(UUID entityId) { this.entityId = entityId; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/EntityDoiBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/EntityDoiBuilder.java index 0dbe42042..a4cff8bd7 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/EntityDoiBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/EntityDoiBuilder.java @@ -48,7 +48,7 @@ public class EntityDoiBuilder extends BaseBuilder { if (fields.hasField(this.asIndexer(EntityDoi._doi))) m.setDoi(d.getDoi()); if (fields.hasField(this.asIndexer(EntityDoi._entityId))) - m.setEntityId(d.getEntityId().getId()); + m.setEntityId(d.getEntityId()); if (fields.hasField(this.asIndexer(EntityDoi._entityType))) m.setEntityType(d.getEntityType()); if (fields.hasField(this.asIndexer(EntityDoi._repositoryId))) diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/DmpReferenceQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/DmpReferenceQuery.java index 72c837fe3..497a2c350 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/query/DmpReferenceQuery.java +++ b/dmp-backend/core/src/main/java/eu/eudat/query/DmpReferenceQuery.java @@ -120,7 +120,7 @@ public class DmpReferenceQuery extends QueryBase { } if (this.referenceIds != null) { CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpReferenceEntity._referenceId)); - for (UUID item : this.ids) + for (UUID item : this.referenceIds) inClause.value(item); predicates.add(inClause); } @@ -136,7 +136,7 @@ public class DmpReferenceQuery extends QueryBase { protected DmpReferenceEntity convert(Tuple tuple, Set columns) { DmpReferenceEntity item = new DmpReferenceEntity(); item.setId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._id, UUID.class)); - item.setReferenceId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._dmpId, UUID.class)); + item.setDmpId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._dmpId, UUID.class)); item.setReferenceId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._referenceId, UUID.class)); item.setData(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._data, String.class)); item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._createdAt, Instant.class)); diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/EntityDoiQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/EntityDoiQuery.java index b03ca28cc..46541a002 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/query/EntityDoiQuery.java +++ b/dmp-backend/core/src/main/java/eu/eudat/query/EntityDoiQuery.java @@ -6,6 +6,7 @@ import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.scope.user.UserScope; import eu.eudat.data.EntityDoiEntity; import eu.eudat.data.old.DMP; +import eu.eudat.model.EntityDoi; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; @@ -211,7 +212,7 @@ public class EntityDoiQuery extends QueryBase { item.setId(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._id, UUID.class)); item.setDoi(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._doi, String.class)); item.setRepositoryId(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._repositoryId, String.class)); - item.setEntityId(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._entityId, DMP.class)); + item.setEntityId(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._entityId, UUID.class)); item.setEntityType(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._entityType, EntityType.class)); item.setCreatedAt(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._createdAt, Instant.class)); item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._updatedAt, Instant.class)); @@ -221,21 +222,21 @@ public class EntityDoiQuery extends QueryBase { @Override protected String fieldNameOf(FieldResolver item) { - if (item.match(EntityDoiEntity._id)) + if (item.match(EntityDoi._id)) return EntityDoiEntity._id; - else if (item.match(EntityDoiEntity._doi)) + else if (item.match(EntityDoi._doi)) return EntityDoiEntity._doi; - else if (item.match(EntityDoiEntity._repositoryId)) + else if (item.match(EntityDoi._repositoryId)) return EntityDoiEntity._repositoryId; - else if (item.match(EntityDoiEntity._entityId)) + else if (item.match(EntityDoi._entityId)) return EntityDoiEntity._entityId; - else if (item.match(EntityDoiEntity._entityType)) + else if (item.match(EntityDoi._entityType)) return EntityDoiEntity._entityType; - else if (item.match(EntityDoiEntity._createdAt)) + else if (item.match(EntityDoi._createdAt)) return EntityDoiEntity._createdAt; - else if (item.match(EntityDoiEntity._updatedAt)) + else if (item.match(EntityDoi._updatedAt)) return EntityDoiEntity._updatedAt; - else if (item.match(EntityDoiEntity._isActive)) + else if (item.match(EntityDoi._isActive)) return EntityDoiEntity._isActive; else return null; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/deposit/RepositoryDepositService.java b/dmp-backend/core/src/main/java/eu/eudat/service/deposit/RepositoryDepositService.java index d66581e7b..7014175eb 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/deposit/RepositoryDepositService.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/deposit/RepositoryDepositService.java @@ -203,7 +203,7 @@ public class RepositoryDepositService { if (uuid.equals(currentId)) continue; doiEntity = dois.stream() - .filter(entityDoiEntity -> entityDoiEntity.getEntityId().getId().equals(uuid)).findFirst().orElse(null); + .filter(entityDoiEntity -> entityDoiEntity.getEntityId().equals(uuid)).findFirst().orElse(null); if (doiEntity != null) break; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/entitydoi/EntityDoiServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/entitydoi/EntityDoiServiceImpl.java index d17a2f439..149b36064 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/entitydoi/EntityDoiServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/entitydoi/EntityDoiServiceImpl.java @@ -100,9 +100,7 @@ public class EntityDoiServiceImpl implements EntityDoiService { } data.setEntityType(EntityType.DMP); - DMP dmp = new DMP(); - dmp.setId(model.getEntityId()); - data.setEntityId(dmp); + data.setEntityId(model.getEntityId()); data.setRepositoryId(model.getRepositoryId()); data.setDoi(model.getDoi()); data.setUpdatedAt(Instant.now()); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 276770177..22137afbf 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -2556,7 +2556,7 @@ public class DataManagementPlanManager { doiEntity.setRepositoryId(depositRequest.getRepositoryId()); doiEntity.setCreatedAt(Instant.now()); doiEntity.setUpdatedAt(Instant.now()); - doiEntity.setEntityId(dmp); + doiEntity.setEntityId(dmp.getId()); //TODO: Save doi // apiContext.getOperationsContext().getDatabaseRepository().getEntityDoiDao().createOrUpdate(doiEntity);