Fix on entity doi entity id, removed reference on Dmps, fix on dmp reference query

This commit is contained in:
Thomas Georgios Giannos 2023-11-07 11:09:54 +02:00
parent 05f73889be
commit ea58ed2e44
7 changed files with 20 additions and 22 deletions

View File

@ -53,9 +53,8 @@ public class EntityDoiEntity {
public static final String _isActive = "isActive"; public static final String _isActive = "isActive";
@ManyToOne(fetch = FetchType.LAZY) @Column(name = "entity_id", nullable = false)
@JoinColumn(name = "entity_id", nullable = false) private UUID entityId;
private DMP entityId;
public static final String _entityId = "entityId"; public static final String _entityId = "entityId";
@ -115,11 +114,11 @@ public class EntityDoiEntity {
this.isActive = isActive; this.isActive = isActive;
} }
public DMP getEntityId() { public UUID getEntityId() {
return entityId; return entityId;
} }
public void setEntityId(DMP entityId) { public void setEntityId(UUID entityId) {
this.entityId = entityId; this.entityId = entityId;
} }

View File

@ -48,7 +48,7 @@ public class EntityDoiBuilder extends BaseBuilder<EntityDoi, EntityDoiEntity> {
if (fields.hasField(this.asIndexer(EntityDoi._doi))) if (fields.hasField(this.asIndexer(EntityDoi._doi)))
m.setDoi(d.getDoi()); m.setDoi(d.getDoi());
if (fields.hasField(this.asIndexer(EntityDoi._entityId))) if (fields.hasField(this.asIndexer(EntityDoi._entityId)))
m.setEntityId(d.getEntityId().getId()); m.setEntityId(d.getEntityId());
if (fields.hasField(this.asIndexer(EntityDoi._entityType))) if (fields.hasField(this.asIndexer(EntityDoi._entityType)))
m.setEntityType(d.getEntityType()); m.setEntityType(d.getEntityType());
if (fields.hasField(this.asIndexer(EntityDoi._repositoryId))) if (fields.hasField(this.asIndexer(EntityDoi._repositoryId)))

View File

@ -120,7 +120,7 @@ public class DmpReferenceQuery extends QueryBase<DmpReferenceEntity> {
} }
if (this.referenceIds != null) { if (this.referenceIds != null) {
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpReferenceEntity._referenceId)); CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpReferenceEntity._referenceId));
for (UUID item : this.ids) for (UUID item : this.referenceIds)
inClause.value(item); inClause.value(item);
predicates.add(inClause); predicates.add(inClause);
} }
@ -136,7 +136,7 @@ public class DmpReferenceQuery extends QueryBase<DmpReferenceEntity> {
protected DmpReferenceEntity convert(Tuple tuple, Set<String> columns) { protected DmpReferenceEntity convert(Tuple tuple, Set<String> columns) {
DmpReferenceEntity item = new DmpReferenceEntity(); DmpReferenceEntity item = new DmpReferenceEntity();
item.setId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._id, UUID.class)); 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.setReferenceId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._referenceId, UUID.class));
item.setData(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._data, String.class)); item.setData(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._data, String.class));
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._createdAt, Instant.class)); item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._createdAt, Instant.class));

View File

@ -6,6 +6,7 @@ import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.EntityDoiEntity; import eu.eudat.data.EntityDoiEntity;
import eu.eudat.data.old.DMP; import eu.eudat.data.old.DMP;
import eu.eudat.model.EntityDoi;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryBase;
@ -211,7 +212,7 @@ public class EntityDoiQuery extends QueryBase<EntityDoiEntity> {
item.setId(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._id, UUID.class));
item.setDoi(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._doi, String.class)); item.setDoi(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._doi, String.class));
item.setRepositoryId(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._repositoryId, 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.setEntityType(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._entityType, EntityType.class));
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._createdAt, Instant.class)); item.setCreatedAt(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._createdAt, Instant.class));
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._updatedAt, Instant.class)); item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._updatedAt, Instant.class));
@ -221,21 +222,21 @@ public class EntityDoiQuery extends QueryBase<EntityDoiEntity> {
@Override @Override
protected String fieldNameOf(FieldResolver item) { protected String fieldNameOf(FieldResolver item) {
if (item.match(EntityDoiEntity._id)) if (item.match(EntityDoi._id))
return EntityDoiEntity._id; return EntityDoiEntity._id;
else if (item.match(EntityDoiEntity._doi)) else if (item.match(EntityDoi._doi))
return EntityDoiEntity._doi; return EntityDoiEntity._doi;
else if (item.match(EntityDoiEntity._repositoryId)) else if (item.match(EntityDoi._repositoryId))
return EntityDoiEntity._repositoryId; return EntityDoiEntity._repositoryId;
else if (item.match(EntityDoiEntity._entityId)) else if (item.match(EntityDoi._entityId))
return EntityDoiEntity._entityId; return EntityDoiEntity._entityId;
else if (item.match(EntityDoiEntity._entityType)) else if (item.match(EntityDoi._entityType))
return EntityDoiEntity._entityType; return EntityDoiEntity._entityType;
else if (item.match(EntityDoiEntity._createdAt)) else if (item.match(EntityDoi._createdAt))
return EntityDoiEntity._createdAt; return EntityDoiEntity._createdAt;
else if (item.match(EntityDoiEntity._updatedAt)) else if (item.match(EntityDoi._updatedAt))
return EntityDoiEntity._updatedAt; return EntityDoiEntity._updatedAt;
else if (item.match(EntityDoiEntity._isActive)) else if (item.match(EntityDoi._isActive))
return EntityDoiEntity._isActive; return EntityDoiEntity._isActive;
else else
return null; return null;

View File

@ -203,7 +203,7 @@ public class RepositoryDepositService {
if (uuid.equals(currentId)) if (uuid.equals(currentId))
continue; continue;
doiEntity = dois.stream() 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) if (doiEntity != null)
break; break;
} }

View File

@ -100,9 +100,7 @@ public class EntityDoiServiceImpl implements EntityDoiService {
} }
data.setEntityType(EntityType.DMP); data.setEntityType(EntityType.DMP);
DMP dmp = new DMP(); data.setEntityId(model.getEntityId());
dmp.setId(model.getEntityId());
data.setEntityId(dmp);
data.setRepositoryId(model.getRepositoryId()); data.setRepositoryId(model.getRepositoryId());
data.setDoi(model.getDoi()); data.setDoi(model.getDoi());
data.setUpdatedAt(Instant.now()); data.setUpdatedAt(Instant.now());

View File

@ -2556,7 +2556,7 @@ public class DataManagementPlanManager {
doiEntity.setRepositoryId(depositRequest.getRepositoryId()); doiEntity.setRepositoryId(depositRequest.getRepositoryId());
doiEntity.setCreatedAt(Instant.now()); doiEntity.setCreatedAt(Instant.now());
doiEntity.setUpdatedAt(Instant.now()); doiEntity.setUpdatedAt(Instant.now());
doiEntity.setEntityId(dmp); doiEntity.setEntityId(dmp.getId());
//TODO: Save doi //TODO: Save doi
// apiContext.getOperationsContext().getDatabaseRepository().getEntityDoiDao().createOrUpdate(doiEntity); // apiContext.getOperationsContext().getDatabaseRepository().getEntityDoiDao().createOrUpdate(doiEntity);