add Public Entity Doi
This commit is contained in:
parent
76d1d50850
commit
7d42777aa0
|
@ -57,6 +57,9 @@ public class PublicDmp {
|
||||||
private List<PublicDescription> descriptions;
|
private List<PublicDescription> descriptions;
|
||||||
public static final String _descriptions = "descriptions";
|
public static final String _descriptions = "descriptions";
|
||||||
|
|
||||||
|
private List<PublicEntityDoi> entityDois;
|
||||||
|
public static final String _entityDois = "entityDois";
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -160,4 +163,12 @@ public class PublicDmp {
|
||||||
public void setDescriptions(List<PublicDescription> descriptions) {
|
public void setDescriptions(List<PublicDescription> descriptions) {
|
||||||
this.descriptions = descriptions;
|
this.descriptions = descriptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<PublicEntityDoi> getEntityDois() {
|
||||||
|
return entityDois;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEntityDois(List<PublicEntityDoi> entityDois) {
|
||||||
|
this.entityDois = entityDois;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
package eu.eudat.model;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.EntityType;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class PublicEntityDoi {
|
||||||
|
|
||||||
|
private UUID id;
|
||||||
|
|
||||||
|
public static final String _id = "id";
|
||||||
|
|
||||||
|
private EntityType entityType;
|
||||||
|
|
||||||
|
public static final String _entityType = "entityType";
|
||||||
|
|
||||||
|
private String repositoryId;
|
||||||
|
|
||||||
|
public static final String _repositoryId = "repositoryId";
|
||||||
|
|
||||||
|
private String doi;
|
||||||
|
|
||||||
|
public static final String _doi = "doi";
|
||||||
|
|
||||||
|
private UUID entityId;
|
||||||
|
|
||||||
|
public static final String _entityId = "entityId";
|
||||||
|
|
||||||
|
|
||||||
|
public UUID getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(UUID id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityType getEntityType() {
|
||||||
|
return entityType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEntityType(EntityType entityType) {
|
||||||
|
this.entityType = entityType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRepositoryId() {
|
||||||
|
return repositoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRepositoryId(String repositoryId) {
|
||||||
|
this.repositoryId = repositoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDoi() {
|
||||||
|
return doi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDoi(String doi) {
|
||||||
|
this.doi = doi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getEntityId() {
|
||||||
|
return entityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEntityId(UUID entityId) {
|
||||||
|
this.entityId = entityId;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,14 @@
|
||||||
package eu.eudat.model.builder;
|
package eu.eudat.model.builder;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.EntityType;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.DmpEntity;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.model.*;
|
import eu.eudat.model.*;
|
||||||
import eu.eudat.query.DescriptionQuery;
|
import eu.eudat.query.DescriptionQuery;
|
||||||
import eu.eudat.query.DmpReferenceQuery;
|
import eu.eudat.query.DmpReferenceQuery;
|
||||||
import eu.eudat.query.DmpUserQuery;
|
import eu.eudat.query.DmpUserQuery;
|
||||||
|
import eu.eudat.query.EntityDoiQuery;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
@ -66,6 +67,9 @@ public class PublicDmpBuilder extends BaseBuilder<PublicDmp, DmpEntity> {
|
||||||
FieldSet descriptionsFields = fields.extractPrefixed(this.asPrefix(PublicDmp._descriptions));
|
FieldSet descriptionsFields = fields.extractPrefixed(this.asPrefix(PublicDmp._descriptions));
|
||||||
Map<UUID, List<PublicDescription>> descriptionsMap = this.collectDmpDescriptions(descriptionsFields, data);
|
Map<UUID, List<PublicDescription>> descriptionsMap = this.collectDmpDescriptions(descriptionsFields, data);
|
||||||
|
|
||||||
|
FieldSet entityDoisFields = fields.extractPrefixed(this.asPrefix(PublicDmp._entityDois));
|
||||||
|
Map<UUID, List<PublicEntityDoi>> entityDoisMap = this.collectEntityDois(entityDoisFields, data);
|
||||||
|
|
||||||
for (DmpEntity d : data) {
|
for (DmpEntity d : data) {
|
||||||
PublicDmp m = new PublicDmp();
|
PublicDmp m = new PublicDmp();
|
||||||
if (fields.hasField(this.asIndexer(PublicDmp._id))) m.setId(d.getId());
|
if (fields.hasField(this.asIndexer(PublicDmp._id))) m.setId(d.getId());
|
||||||
|
@ -82,6 +86,7 @@ public class PublicDmpBuilder extends BaseBuilder<PublicDmp, DmpEntity> {
|
||||||
if (dmpReferenceMap != null && !dmpReferenceMap.isEmpty() && dmpReferenceMap.containsKey(d.getId())) m.setDmpReferences(dmpReferenceMap.get(d.getId()));
|
if (dmpReferenceMap != null && !dmpReferenceMap.isEmpty() && dmpReferenceMap.containsKey(d.getId())) m.setDmpReferences(dmpReferenceMap.get(d.getId()));
|
||||||
if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId())) m.setDmpUsers(dmpUsersMap.get(d.getId()));
|
if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId())) m.setDmpUsers(dmpUsersMap.get(d.getId()));
|
||||||
if (descriptionsMap != null && !descriptionsMap.isEmpty() && descriptionsMap.containsKey(d.getId())) m.setDescriptions(descriptionsMap.get(d.getId()));
|
if (descriptionsMap != null && !descriptionsMap.isEmpty() && descriptionsMap.containsKey(d.getId())) m.setDescriptions(descriptionsMap.get(d.getId()));
|
||||||
|
if (entityDoisMap != null && !entityDoisMap.isEmpty() && entityDoisMap.containsKey(d.getId())) m.setEntityDois(entityDoisMap.get(d.getId()));
|
||||||
|
|
||||||
models.add(m);
|
models.add(m);
|
||||||
}
|
}
|
||||||
|
@ -144,4 +149,22 @@ public class PublicDmpBuilder extends BaseBuilder<PublicDmp, DmpEntity> {
|
||||||
return itemMap;
|
return itemMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<UUID, List<PublicEntityDoi>> collectEntityDois(FieldSet fields, List<DmpEntity> data) throws MyApplicationException {
|
||||||
|
if (fields.isEmpty() || data.isEmpty()) return null;
|
||||||
|
this.logger.debug("checking related - {}", PublicEntityDoi.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<UUID, List<PublicEntityDoi>> itemMap;
|
||||||
|
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PublicEntityDoi._entityId));
|
||||||
|
EntityDoiQuery query = this.queryFactory.query(EntityDoiQuery.class).authorize(this.authorize).types(EntityType.DMP).entityIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
|
||||||
|
itemMap = this.builderFactory.builder(PublicEntityDoiBuilder.class).authorize(this.authorize).asMasterKey(query, clone, PublicEntityDoi::getEntityId);
|
||||||
|
|
||||||
|
if (!fields.hasField(this.asIndexer(PublicEntityDoi._entityId))) {
|
||||||
|
itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getEntityId() != null).peek(x -> {
|
||||||
|
x.setEntityId(null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
package eu.eudat.model.builder;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.data.EntityDoiEntity;
|
||||||
|
import eu.eudat.model.*;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class PublicEntityDoiBuilder extends BaseBuilder<PublicEntityDoi, EntityDoiEntity> {
|
||||||
|
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public PublicEntityDoiBuilder(
|
||||||
|
ConventionService conventionService,
|
||||||
|
QueryFactory queryFactory,
|
||||||
|
BuilderFactory builderFactory) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicEntityDoiBuilder.class)));
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PublicEntityDoiBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PublicEntityDoi> build(FieldSet fields, List<EntityDoiEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
|
||||||
|
this.logger.trace(new DataLogEntry("requested fields", fields));
|
||||||
|
if (fields == null || data == null || fields.isEmpty())
|
||||||
|
return new ArrayList<>();
|
||||||
|
|
||||||
|
List<PublicEntityDoi> models = new ArrayList<>();
|
||||||
|
for (EntityDoiEntity d : data) {
|
||||||
|
PublicEntityDoi m = new PublicEntityDoi();
|
||||||
|
if (fields.hasField(this.asIndexer(PublicEntityDoi._id))) m.setId(d.getId());
|
||||||
|
if (fields.hasField(this.asIndexer(PublicEntityDoi._entityType))) m.setEntityType(d.getEntityType());
|
||||||
|
if (fields.hasField(this.asIndexer(PublicEntityDoi._repositoryId))) m.setRepositoryId(d.getRepositoryId());
|
||||||
|
if (fields.hasField(this.asIndexer(PublicEntityDoi._doi))) m.setDoi(d.getDoi());
|
||||||
|
if (fields.hasField(this.asIndexer(PublicEntityDoi._entityId))) m.setEntityId(d.getEntityId());
|
||||||
|
|
||||||
|
models.add(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -13,6 +13,7 @@ import { DmpAssociatedUser, User } from "../user/user";
|
||||||
import { DmpReference } from './dmp-reference';
|
import { DmpReference } from './dmp-reference';
|
||||||
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
||||||
import { AppPermission } from '@app/core/common/enum/permission.enum';
|
import { AppPermission } from '@app/core/common/enum/permission.enum';
|
||||||
|
import { EntityType } from '@app/core/common/enum/entity-type';
|
||||||
|
|
||||||
export interface Dmp extends BaseEntity {
|
export interface Dmp extends BaseEntity {
|
||||||
label?: string;
|
label?: string;
|
||||||
|
@ -166,6 +167,7 @@ export interface PublicDmp extends BaseEntity {
|
||||||
dmpReferences: PublicDmpReference[];
|
dmpReferences: PublicDmpReference[];
|
||||||
dmpUsers: PublicDmpUser[];
|
dmpUsers: PublicDmpUser[];
|
||||||
descriptions: PublicDescription[];
|
descriptions: PublicDescription[];
|
||||||
|
entityDois: PublicEntityDoi[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PublicDmpReference {
|
export interface PublicDmpReference {
|
||||||
|
@ -201,3 +203,10 @@ export interface PublicUser {
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PublicEntityDoi {
|
||||||
|
id: Guid;
|
||||||
|
entityType: EntityType;
|
||||||
|
entityId: Guid;
|
||||||
|
repositoryId: string;
|
||||||
|
doi: string;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue