Renamed DMP -> Dmp to be consistent with the other entities

This commit is contained in:
Thomas Georgios Giannos 2023-10-23 11:31:07 +03:00
parent 10df3db7aa
commit 61f2810fcc
14 changed files with 124 additions and 124 deletions

View File

@ -4,13 +4,13 @@ import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DMPStatus implements DatabaseEnum<Short> {
public enum DmpStatus implements DatabaseEnum<Short> {
ACTIVE((short) 0), FINALISED((short) 1),DELETED((short) 99);
private final Short value;
DMPStatus(Short value) {
DmpStatus(Short value) {
this.value = value;
}
@ -19,9 +19,9 @@ public enum DMPStatus implements DatabaseEnum<Short> {
return null;
}
private static final Map<Short, DMPStatus> map = EnumUtils.getEnumValueMap(DMPStatus.class);
private static final Map<Short, DmpStatus> map = EnumUtils.getEnumValueMap(DmpStatus.class);
public static DMPStatus of(Short i) {
public static DmpStatus of(Short i) {
return map.get(i);
}

View File

@ -1,6 +1,6 @@
package eu.eudat.data;
import eu.eudat.commons.enums.DMPStatus;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.converters.enums.IsActiveConverter;
@ -13,7 +13,7 @@ import java.util.UUID;
//TODO: (thgiannos) Wire up when all other dependent entities are refactored
//@Entity
//@Table(name = "\"DMP\"")
public class DMPEntity {
public class DmpEntity {
@Id
@GeneratedValue
@ -35,7 +35,7 @@ public class DMPEntity {
@Enumerated(EnumType.STRING)
@Column(name = "status", nullable = false)
private DMPStatus status;
private DmpStatus status;
public static final String _status = "status";
@ -182,11 +182,11 @@ public class DMPEntity {
this.version = version;
}
public DMPStatus getStatus() {
public DmpStatus getStatus() {
return status;
}
public void setStatus(DMPStatus status) {
public void setStatus(DmpStatus status) {
this.status = status;
}

View File

@ -1,14 +0,0 @@
package eu.eudat.data.converters.enums;
import eu.eudat.commons.enums.DMPStatus;
import jakarta.persistence.Converter;
@Converter
public class DMPStatusConverter extends DatabaseEnumConverter<DMPStatus, Short> {
@Override
protected DMPStatus of(Short i) {
return DMPStatus.of(i);
}
}

View File

@ -0,0 +1,14 @@
package eu.eudat.data.converters.enums;
import eu.eudat.commons.enums.DmpStatus;
import jakarta.persistence.Converter;
@Converter
public class DmpStatusConverter extends DatabaseEnumConverter<DmpStatus, Short> {
@Override
protected DmpStatus of(Short i) {
return DmpStatus.of(i);
}
}

View File

@ -1,12 +1,12 @@
package eu.eudat.model;
import eu.eudat.commons.enums.DMPStatus;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.IsActive;
import java.time.Instant;
import java.util.UUID;
public class DMP {
public class Dmp {
private UUID id;
@ -20,7 +20,7 @@ public class DMP {
public static final String _version = "version";
private DMPStatus status;
private DmpStatus status;
public static final String _status = "status";
@ -112,11 +112,11 @@ public class DMP {
this.version = version;
}
public DMPStatus getStatus() {
public DmpStatus getStatus() {
return status;
}
public void setStatus(DMPStatus status) {
public void setStatus(DmpStatus status) {
this.status = status;
}

View File

@ -2,8 +2,8 @@ package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.DMPEntity;
import eu.eudat.model.DMP;
import eu.eudat.data.DmpEntity;
import eu.eudat.model.Dmp;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
@ -18,45 +18,45 @@ import java.util.*;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DMPBuilder extends BaseBuilder<DMP, DMPEntity> {
public class DmpBuilder extends BaseBuilder<Dmp, DmpEntity> {
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
public DMPBuilder(ConventionService conventionService) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DMPBuilder.class)));
public DmpBuilder(ConventionService conventionService) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpBuilder.class)));
}
public DMPBuilder authorize(EnumSet<AuthorizationFlags> values) {
public DmpBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<DMP> build(FieldSet fields, List<DMPEntity> data) throws MyApplicationException {
public List<Dmp> build(FieldSet fields, List<DmpEntity> 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<DMP> models = new ArrayList<>();
for (DMPEntity d : data) {
DMP m = new DMP();
if (fields.hasField(this.asIndexer(DMP._id))) m.setId(d.getId());
if (fields.hasField(this.asIndexer(DMP._label))) m.setLabel(d.getLabel());
if (fields.hasField(this.asIndexer(DMP._version))) m.setVersion(d.getVersion());
if (fields.hasField(this.asIndexer(DMP._status))) m.setStatus(d.getStatus());
if (fields.hasField(this.asIndexer(DMP._properties))) m.setProperties(d.getProperties());
if (fields.hasField(this.asIndexer(DMP._dmpProperties))) m.setDmpProperties(d.getDmpProperties());
if (fields.hasField(this.asIndexer(DMP._groupId))) m.setGroupId(d.getGroupId());
if (fields.hasField(this.asIndexer(DMP._description))) m.setDescription(d.getDescription());
if (fields.hasField(this.asIndexer(DMP._isPublic))) m.setIsPublic(d.getIsPublic());
if (fields.hasField(this.asIndexer(DMP._extraProperties))) m.setExtraProperties(d.getExtraProperties());
if (fields.hasField(this.asIndexer(DMP._createdAt))) m.setCreatedAt(d.getCreatedAt());
if (fields.hasField(this.asIndexer(DMP._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(DMP._isActive))) m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(DMP._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt());
if (fields.hasField(this.asIndexer(DMP._publishedAt))) m.setPublishedAt(d.getPublishedAt());
if (fields.hasField(this.asIndexer(DMP._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
List<Dmp> models = new ArrayList<>();
for (DmpEntity d : data) {
Dmp m = new Dmp();
if (fields.hasField(this.asIndexer(Dmp._id))) m.setId(d.getId());
if (fields.hasField(this.asIndexer(Dmp._label))) m.setLabel(d.getLabel());
if (fields.hasField(this.asIndexer(Dmp._version))) m.setVersion(d.getVersion());
if (fields.hasField(this.asIndexer(Dmp._status))) m.setStatus(d.getStatus());
if (fields.hasField(this.asIndexer(Dmp._properties))) m.setProperties(d.getProperties());
if (fields.hasField(this.asIndexer(Dmp._dmpProperties))) m.setDmpProperties(d.getDmpProperties());
if (fields.hasField(this.asIndexer(Dmp._groupId))) m.setGroupId(d.getGroupId());
if (fields.hasField(this.asIndexer(Dmp._description))) m.setDescription(d.getDescription());
if (fields.hasField(this.asIndexer(Dmp._isPublic))) m.setIsPublic(d.getIsPublic());
if (fields.hasField(this.asIndexer(Dmp._extraProperties))) m.setExtraProperties(d.getExtraProperties());
if (fields.hasField(this.asIndexer(Dmp._createdAt))) m.setCreatedAt(d.getCreatedAt());
if (fields.hasField(this.asIndexer(Dmp._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(Dmp._isActive))) m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(Dmp._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt());
if (fields.hasField(this.asIndexer(Dmp._publishedAt))) m.setPublishedAt(d.getPublishedAt());
if (fields.hasField(this.asIndexer(Dmp._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));

View File

@ -1,5 +1,5 @@
package eu.eudat.model.censorship;
public class DMPCensor {
public class DmpCensor {
}

View File

@ -1,5 +1,5 @@
package eu.eudat.model.deleter;
public class DMPDeleter {
public class DmpDeleter {
}

View File

@ -1,5 +1,5 @@
package eu.eudat.model.persist;
public class DMPPersist {
public class DmpPersist {
}

View File

@ -1,11 +1,11 @@
package eu.eudat.query;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.enums.DMPStatus;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.DMPEntity;
import eu.eudat.model.DMP;
import eu.eudat.data.DmpEntity;
import eu.eudat.model.Dmp;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryBase;
@ -22,7 +22,7 @@ import java.util.*;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DMPQueryV2 extends QueryBase<DMPEntity> {
public class DmpQuery extends QueryBase<DmpEntity> {
private String like;
@ -30,7 +30,7 @@ public class DMPQueryV2 extends QueryBase<DMPEntity> {
private Collection<IsActive> isActives;
private Collection<DMPStatus> statuses;
private Collection<DmpStatus> statuses;
private Collection<UUID> excludedIds;
@ -40,77 +40,77 @@ public class DMPQueryV2 extends QueryBase<DMPEntity> {
private final AuthorizationService authService;
public DMPQueryV2(UserScope userScope, AuthorizationService authService) {
public DmpQuery(UserScope userScope, AuthorizationService authService) {
this.userScope = userScope;
this.authService = authService;
}
public DMPQueryV2 like(String value) {
public DmpQuery like(String value) {
this.like = value;
return this;
}
public DMPQueryV2 ids(UUID value) {
public DmpQuery ids(UUID value) {
this.ids = List.of(value);
return this;
}
public DMPQueryV2 ids(UUID... value) {
public DmpQuery ids(UUID... value) {
this.ids = Arrays.asList(value);
return this;
}
public DMPQueryV2 ids(Collection<UUID> values) {
public DmpQuery ids(Collection<UUID> values) {
this.ids = values;
return this;
}
public DMPQueryV2 isActive(IsActive value) {
public DmpQuery isActive(IsActive value) {
this.isActives = List.of(value);
return this;
}
public DMPQueryV2 isActive(IsActive... value) {
public DmpQuery isActive(IsActive... value) {
this.isActives = Arrays.asList(value);
return this;
}
public DMPQueryV2 isActive(Collection<IsActive> values) {
public DmpQuery isActive(Collection<IsActive> values) {
this.isActives = values;
return this;
}
public DMPQueryV2 statuses(DMPStatus value) {
public DmpQuery statuses(DmpStatus value) {
this.statuses = List.of(value);
return this;
}
public DMPQueryV2 statuses(DMPStatus... value) {
public DmpQuery statuses(DmpStatus... value) {
this.statuses = Arrays.asList(value);
return this;
}
public DMPQueryV2 statuses(Collection<DMPStatus> values) {
public DmpQuery statuses(Collection<DmpStatus> values) {
this.statuses = values;
return this;
}
public DMPQueryV2 excludedIds(Collection<UUID> values) {
public DmpQuery excludedIds(Collection<UUID> values) {
this.excludedIds = values;
return this;
}
public DMPQueryV2 excludedIds(UUID value) {
public DmpQuery excludedIds(UUID value) {
this.excludedIds = List.of(value);
return this;
}
public DMPQueryV2 excludedIds(UUID... value) {
public DmpQuery excludedIds(UUID... value) {
this.excludedIds = Arrays.asList(value);
return this;
}
public DMPQueryV2 authorize(EnumSet<AuthorizationFlags> values) {
public DmpQuery authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@ -121,37 +121,37 @@ public class DMPQueryV2 extends QueryBase<DMPEntity> {
}
@Override
protected Class<DMPEntity> entityClass() {
return DMPEntity.class;
protected Class<DmpEntity> entityClass() {
return DmpEntity.class;
}
@Override
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
List<Predicate> predicates = new ArrayList<>();
if (this.ids != null) {
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DMPEntity._id));
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._id));
for (UUID item : this.ids)
inClause.value(item);
predicates.add(inClause);
}
if (this.like != null && !this.like.isEmpty()) {
predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(DMPEntity._label), this.like));
predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(DmpEntity._label), this.like));
}
if (this.isActives != null) {
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DMPEntity._isActive));
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._isActive));
for (IsActive item : this.isActives)
inClause.value(item);
predicates.add(inClause);
}
if (this.statuses != null) {
CriteriaBuilder.In<DMPStatus> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DMPEntity._status));
for (DMPStatus item : this.statuses)
CriteriaBuilder.In<DmpStatus> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._status));
for (DmpStatus item : this.statuses)
inClause.value(item);
predicates.add(inClause);
}
if (this.excludedIds != null) {
CriteriaBuilder.In<UUID> notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DMPEntity._id));
CriteriaBuilder.In<UUID> notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._id));
for (UUID item : this.excludedIds)
notInClause.value(item);
predicates.add(notInClause.not());
@ -166,42 +166,42 @@ public class DMPQueryV2 extends QueryBase<DMPEntity> {
@Override
protected String fieldNameOf(FieldResolver item) {
if (item.match(DMP._id)) return DMPEntity._id;
else if (item.match(DMP._label)) return DMPEntity._label;
else if (item.match(DMP._version)) return DMPEntity._version;
else if (item.match(DMP._status)) return DMPEntity._status;
else if (item.match(DMP._properties)) return DMPEntity._properties;
else if (item.match(DMP._dmpProperties)) return DMPEntity._dmpProperties;
else if (item.match(DMP._groupId)) return DMPEntity._groupId;
else if (item.match(DMP._description)) return DMPEntity._description;
else if (item.match(DMP._isPublic)) return DMPEntity._isPublic;
else if (item.match(DMP._extraProperties)) return DMPEntity._extraProperties;
else if (item.match(DMP._createdAt)) return DMPEntity._createdAt;
else if (item.match(DMP._updatedAt)) return DMPEntity._updatedAt;
else if (item.match(DMP._isActive)) return DMPEntity._isActive;
else if (item.match(DMP._finalizedAt)) return DMPEntity._finalizedAt;
else if (item.match(DMP._publishedAt)) return DMPEntity._publishedAt;
if (item.match(Dmp._id)) return DmpEntity._id;
else if (item.match(Dmp._label)) return DmpEntity._label;
else if (item.match(Dmp._version)) return DmpEntity._version;
else if (item.match(Dmp._status)) return DmpEntity._status;
else if (item.match(Dmp._properties)) return DmpEntity._properties;
else if (item.match(Dmp._dmpProperties)) return DmpEntity._dmpProperties;
else if (item.match(Dmp._groupId)) return DmpEntity._groupId;
else if (item.match(Dmp._description)) return DmpEntity._description;
else if (item.match(Dmp._isPublic)) return DmpEntity._isPublic;
else if (item.match(Dmp._extraProperties)) return DmpEntity._extraProperties;
else if (item.match(Dmp._createdAt)) return DmpEntity._createdAt;
else if (item.match(Dmp._updatedAt)) return DmpEntity._updatedAt;
else if (item.match(Dmp._isActive)) return DmpEntity._isActive;
else if (item.match(Dmp._finalizedAt)) return DmpEntity._finalizedAt;
else if (item.match(Dmp._publishedAt)) return DmpEntity._publishedAt;
else return null;
}
@Override
protected DMPEntity convert(Tuple tuple, Set<String> columns) {
DMPEntity item = new DMPEntity();
item.setId(QueryBase.convertSafe(tuple, columns, DMPEntity._id, UUID.class));
item.setLabel(QueryBase.convertSafe(tuple, columns, DMPEntity._label, String.class));
item.setVersion(QueryBase.convertSafe(tuple, columns, DMPEntity._version, Integer.class));
item.setStatus(QueryBase.convertSafe(tuple, columns, DMPEntity._status, DMPStatus.class));
item.setProperties(QueryBase.convertSafe(tuple, columns, DMPEntity._properties, String.class));
item.setDmpProperties(QueryBase.convertSafe(tuple, columns, DMPEntity._dmpProperties, String.class));
item.setGroupId(QueryBase.convertSafe(tuple, columns, DMPEntity._groupId, UUID.class));
item.setDescription(QueryBase.convertSafe(tuple, columns, DMPEntity._description, String.class));
item.setIsPublic(QueryBase.convertSafe(tuple, columns, DMPEntity._isPublic, Boolean.class));
item.setExtraProperties(QueryBase.convertSafe(tuple, columns, DMPEntity._extraProperties, String.class));
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DMPEntity._createdAt, Instant.class));
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DMPEntity._updatedAt, Instant.class));
item.setIsActive(QueryBase.convertSafe(tuple, columns, DMPEntity._isActive, IsActive.class));
item.setFinalizedAt(QueryBase.convertSafe(tuple, columns, DMPEntity._finalizedAt, Instant.class));
item.setPublishedAt(QueryBase.convertSafe(tuple, columns, DMPEntity._publishedAt, Instant.class));
protected DmpEntity convert(Tuple tuple, Set<String> columns) {
DmpEntity item = new DmpEntity();
item.setId(QueryBase.convertSafe(tuple, columns, DmpEntity._id, UUID.class));
item.setLabel(QueryBase.convertSafe(tuple, columns, DmpEntity._label, String.class));
item.setVersion(QueryBase.convertSafe(tuple, columns, DmpEntity._version, Integer.class));
item.setStatus(QueryBase.convertSafe(tuple, columns, DmpEntity._status, DmpStatus.class));
item.setProperties(QueryBase.convertSafe(tuple, columns, DmpEntity._properties, String.class));
item.setDmpProperties(QueryBase.convertSafe(tuple, columns, DmpEntity._dmpProperties, String.class));
item.setGroupId(QueryBase.convertSafe(tuple, columns, DmpEntity._groupId, UUID.class));
item.setDescription(QueryBase.convertSafe(tuple, columns, DmpEntity._description, String.class));
item.setIsPublic(QueryBase.convertSafe(tuple, columns, DmpEntity._isPublic, Boolean.class));
item.setExtraProperties(QueryBase.convertSafe(tuple, columns, DmpEntity._extraProperties, String.class));
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DmpEntity._createdAt, Instant.class));
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DmpEntity._updatedAt, Instant.class));
item.setIsActive(QueryBase.convertSafe(tuple, columns, DmpEntity._isActive, IsActive.class));
item.setFinalizedAt(QueryBase.convertSafe(tuple, columns, DmpEntity._finalizedAt, Instant.class));
item.setPublishedAt(QueryBase.convertSafe(tuple, columns, DmpEntity._publishedAt, Instant.class));
return item;
}

View File

@ -1,5 +1,5 @@
package eu.eudat.query.lookup;
public class DMPLookup {
public class DmpLookup {
}

View File

@ -1,5 +0,0 @@
package eu.eudat.service.dmp;
public class DMPServiceImpl implements DMPService {
}

View File

@ -1,5 +1,5 @@
package eu.eudat.service.dmp;
public interface DMPService {
public interface DmpService {
}

View File

@ -0,0 +1,5 @@
package eu.eudat.service.dmp;
public class DmpServiceImpl implements DmpService {
}