add version status to dmp, description template

This commit is contained in:
Efstratios Giannopoulos 2023-11-14 18:18:20 +02:00
parent e103f40763
commit 332ee8c59e
35 changed files with 443 additions and 152 deletions

View File

@ -0,0 +1,30 @@
package eu.eudat.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DescriptionTemplateVersionStatus implements DatabaseEnum<Short> {
Current((short) 0), Previous ((short) 1);
private final Short value;
DescriptionTemplateVersionStatus(Short value) {
this.value = value;
}
@Override
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DescriptionTemplateVersionStatus> map = EnumUtils.getEnumValueMap(DescriptionTemplateVersionStatus.class);
public static DescriptionTemplateVersionStatus of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,30 @@
package eu.eudat.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DmpVersionStatus implements DatabaseEnum<Short> {
Current((short) 0), Previous ((short) 1);
private final Short value;
DmpVersionStatus(Short value) {
this.value = value;
}
@Override
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DmpVersionStatus> map = EnumUtils.getEnumValueMap(DmpVersionStatus.class);
public static DmpVersionStatus of(Short i) {
return map.get(i);
}
}

View File

@ -40,7 +40,6 @@ public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
@Column(name = "status", nullable = false)
@Convert(converter = DescriptionStatusConverter.class)
private DescriptionStatus status;
public static final String _status = "status";
@Column(name = "description")

View File

@ -2,8 +2,10 @@ package eu.eudat.data;
import eu.eudat.commons.enums.DescriptionTemplateStatus;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.enums.DescriptionTemplateStatusConverter;
import eu.eudat.data.converters.enums.DescriptionTemplateVersionStatusConverter;
import eu.eudat.data.converters.enums.IsActiveConverter;
import eu.eudat.data.old.queryableentity.DataEntity;
import jakarta.persistence.*;
@ -61,6 +63,11 @@ public class DescriptionTemplateEntity implements DataEntity<DescriptionTemplate
private Short version;
public static final String _version = "version";
@Column(name = "version_status", nullable = false)
@Convert(converter = DescriptionTemplateVersionStatusConverter.class)
private DescriptionTemplateVersionStatus versionStatus;
public static final String _versionStatus = "versionStatus";
@Column(name = "\"language\"", nullable = false)
private String language;
public static final String _language = "language";
@ -148,6 +155,14 @@ public class DescriptionTemplateEntity implements DataEntity<DescriptionTemplate
this.typeId = typeId;
}
public DescriptionTemplateVersionStatus getVersionStatus() {
return versionStatus;
}
public void setVersionStatus(DescriptionTemplateVersionStatus versionStatus) {
this.versionStatus = versionStatus;
}
@Override
public void update(DescriptionTemplateEntity entity) {
}

View File

@ -2,6 +2,7 @@ package eu.eudat.data;
import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.DmpVersionStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.converters.enums.DmpAccessTypeConverter;
@ -32,6 +33,12 @@ public class DmpEntity {
public static final String _version = "version";
@Column(name = "version_status", nullable = false)
@Convert(converter = DmpStatusConverter.class)
private DmpVersionStatus versionStatus;
public static final String _versionStatus = "versionStatus";
@Column(name = "status", nullable = false)
@Convert(converter = DmpStatusConverter.class)
private DmpStatus status;
@ -229,4 +236,12 @@ public class DmpEntity {
public void setPublicAfter(Instant publicAfter) {
this.publicAfter = publicAfter;
}
public DmpVersionStatus getVersionStatus() {
return versionStatus;
}
public void setVersionStatus(DmpVersionStatus versionStatus) {
this.versionStatus = versionStatus;
}
}

View File

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

View File

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

View File

@ -19,7 +19,7 @@ import java.util.List;
@ConditionalOnProperty(prefix = "elastic", name = "enabled", matchIfMissing = false)
public class ElasticConfiguration extends AbstractElasticConfiguration {
public ElasticConfiguration(ApplicationContext applicationContext, ElasticProperties elasticProperties, ElasticCertificateProvider elasticCertificateProvider) {
public ElasticConfiguration(ElasticProperties elasticProperties, ElasticCertificateProvider elasticCertificateProvider) {
super(elasticProperties, elasticCertificateProvider);
}
@ -29,9 +29,11 @@ public class ElasticConfiguration extends AbstractElasticConfiguration {
return new ElasticsearchCustomConversions(
List.of(
new DmpUserRoleToShortConverter(),
new DescriptionStatusToShortConverter(),
new DescriptionTemplateVersionStatusToShortConverter(),
new DmpStatusToShortConverter(),
new IsActiveToShortConverter(),
new DescriptionTemplateVersionStatusToShortConverter(),
new DmpVersionStatusToShortConverter(),
new DmpAccessTypeToShortConverter()
));
}

View File

@ -0,0 +1,13 @@
package eu.eudat.elastic.converter;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter;
@WritingConverter
public class DescriptionTemplateVersionStatusToShortConverter implements Converter<DescriptionTemplateVersionStatus, Short> {
@Override
public Short convert(DescriptionTemplateVersionStatus source) {
return source.getValue();
}
}

View File

@ -1,13 +1,13 @@
package eu.eudat.elastic.converter;
import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.commons.enums.DmpVersionStatus;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter;
@WritingConverter
public class DescriptionStatusToShortConverter implements Converter<DescriptionStatus, Short> {
public class DmpVersionStatusToShortConverter implements Converter<DmpVersionStatus, Short> {
@Override
public Short convert(DescriptionStatus source) {
public Short convert(DmpVersionStatus source) {
return source.getValue();
}
}

View File

@ -1,6 +1,7 @@
package eu.eudat.elastic.data;
import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import eu.eudat.elastic.data.nested.*;
import gr.cite.tools.elastic.ElasticConstants;
import org.springframework.data.annotation.Id;

View File

@ -2,6 +2,7 @@ package eu.eudat.elastic.data;
import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.DmpVersionStatus;
import eu.eudat.elastic.data.nested.*;
import gr.cite.tools.elastic.ElasticConstants;
import org.springframework.data.annotation.Id;
@ -39,6 +40,9 @@ public class DmpElasticEntity {
@Field(value = DmpElasticEntity._accessType, type = FieldType.Short)
private DmpAccessType accessType;
public final static String _accessType = "accessType";
@Field(value = DmpElasticEntity._versionStatus, type = FieldType.Short)
private DmpVersionStatus versionStatus;
public final static String _versionStatus = "versionStatus";
@Field(value = DmpElasticEntity._language, type = FieldType.Keyword)
private String language;
@ -195,4 +199,12 @@ public class DmpElasticEntity {
public void setDois(List<NestedDoiElasticEntity> dois) {
this.dois = dois;
}
public DmpVersionStatus getVersionStatus() {
return versionStatus;
}
public void setVersionStatus(DmpVersionStatus versionStatus) {
this.versionStatus = versionStatus;
}
}

View File

@ -1,5 +1,7 @@
package eu.eudat.elastic.data.nested;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import eu.eudat.elastic.data.DescriptionElasticEntity;
import gr.cite.tools.elastic.ElasticConstants;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;
@ -19,6 +21,12 @@ public class NestedDescriptionTemplateElasticEntity {
private String label;
public final static String _label = "label";
@Field(value = NestedDescriptionTemplateElasticEntity._versionStatus, type = FieldType.Short)
private DescriptionTemplateVersionStatus versionStatus;
public final static String _versionStatus = "versionStatus";
public UUID getId() {
return id;
}
@ -34,4 +42,12 @@ public class NestedDescriptionTemplateElasticEntity {
public void setLabel(String label) {
this.label = label;
}
public DescriptionTemplateVersionStatus getVersionStatus() {
return versionStatus;
}
public void setVersionStatus(DescriptionTemplateVersionStatus versionStatus) {
this.versionStatus = versionStatus;
}
}

View File

@ -2,6 +2,8 @@ package eu.eudat.elastic.data.nested;
import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.DmpVersionStatus;
import eu.eudat.elastic.data.DmpElasticEntity;
import gr.cite.tools.elastic.ElasticConstants;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;
@ -30,6 +32,10 @@ public class NestedDmpElasticEntity {
private Short version;
public final static String _version = "version";
@Field(value = NestedDmpElasticEntity._versionStatus, type = FieldType.Short)
private DmpVersionStatus versionStatus;
public final static String _versionStatus = "versionStatus";
@Field(value = NestedDmpElasticEntity._status, type = FieldType.Short)
private DmpStatus status;
public final static String _status = "status";
@ -169,4 +175,12 @@ public class NestedDmpElasticEntity {
public void setDois(List<NestedDoiElasticEntity> dois) {
this.dois = dois;
}
public DmpVersionStatus getVersionStatus() {
return versionStatus;
}
public void setVersionStatus(DmpVersionStatus versionStatus) {
this.versionStatus = versionStatus;
}
}

View File

@ -54,6 +54,7 @@ public class DmpElasticBuilder extends BaseElasticBuilder<DmpElasticEntity, DmpE
m.setLabel(d.getLabel());
m.setDescription(d.getDescription());
m.setVersion(d.getVersion());
m.setVersionStatus(d.getVersionStatus());
m.setStatus(d.getStatus());
m.setAccessType(d.getAccessType());
m.setLanguage(d.getLanguage());

View File

@ -35,6 +35,7 @@ public class NestedDescriptionTemplateElasticBuilder extends BaseElasticBuilder<
for (DescriptionTemplateEntity d : data) {
NestedDescriptionTemplateElasticEntity m = new NestedDescriptionTemplateElasticEntity();
m.setId(d.getId());
m.setVersionStatus(d.getVersionStatus());
m.setLabel(d.getLabel());
models.add(m);
}

View File

@ -63,6 +63,7 @@ public class NestedDmpElasticBuilder extends BaseElasticBuilder<NestedDmpElastic
m.setBlueprintId(d.getBlueprint());
m.setGroupId(d.getGroupId());
m.setGroupId(d.getGroupId());
m.setVersionStatus(d.getVersionStatus());
m.setFinalizedAt(Date.from(d.getFinalizedAt()));
if (referenceElasticEntityMap != null) m.setReferences(referenceElasticEntityMap.getOrDefault(d.getId(), null));
if (collaboratorElasticEntityMap != null) m.setCollaborators(collaboratorElasticEntityMap.getOrDefault(d.getId(), null));

View File

@ -3,6 +3,7 @@ import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.DmpVersionStatus;
import eu.eudat.configurations.elastic.AppElasticProperties;
import eu.eudat.elastic.data.DmpElasticEntity;
import eu.eudat.service.elastic.ElasticService;
@ -112,6 +113,8 @@ public class DmpElasticQuery extends ElasticQuery<DmpElasticEntity, UUID> {
if (columns.contains(DmpElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._label), String.class));
if (columns.contains(DmpElasticEntity._description)) mocDoc.setDescription(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._description), String.class));
if (columns.contains(DmpElasticEntity._status)) mocDoc.setStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._status), DmpStatus.class));
if (columns.contains(DmpElasticEntity._versionStatus)) mocDoc.setVersionStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._versionStatus), DmpVersionStatus.class));
if (columns.contains(DmpElasticEntity._version)) mocDoc.setVersion(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._version), Short.class));
if (columns.contains(DmpElasticEntity._groupId)) mocDoc.setGroupId(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._groupId), UUID.class));
if (columns.contains(DmpElasticEntity._accessType)) mocDoc.setAccessType(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._accessType), DmpAccessType.class));
if (columns.contains(DmpElasticEntity._finalizedAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._finalizedAt), Date.class));
@ -128,6 +131,8 @@ public class DmpElasticQuery extends ElasticQuery<DmpElasticEntity, UUID> {
else if (item.match(DmpElasticEntity._label)) return this.elasticFieldOf(DmpElasticEntity._label);
else if (item.match(DmpElasticEntity._description)) return this.elasticFieldOf(DmpElasticEntity._description);
else if (item.match(DmpElasticEntity._status)) return this.elasticFieldOf(DmpElasticEntity._status);
else if (item.match(DmpElasticEntity._version)) return this.elasticFieldOf(DmpElasticEntity._version);
else if (item.match(DmpElasticEntity._versionStatus)) return this.elasticFieldOf(DmpElasticEntity._versionStatus);
else if (item.match(DmpElasticEntity._groupId)) return this.elasticFieldOf(DmpElasticEntity._groupId);
else if (item.match(DmpElasticEntity._finalizedAt)) return this.elasticFieldOf(DmpElasticEntity._finalizedAt);
else if (item.match(DmpElasticEntity._accessType)) return this.elasticFieldOf(DmpElasticEntity._accessType);

View File

@ -1,6 +1,7 @@
package eu.eudat.elastic.query;
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import eu.eudat.elastic.data.nested.NestedDescriptionTemplateElasticEntity;
import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.elastic.configuration.ElasticProperties;
@ -62,6 +63,7 @@ public class InnerObjectDescriptionTemplateElasticQuery extends ElasticInnerObje
NestedDescriptionTemplateElasticEntity mocDoc = new NestedDescriptionTemplateElasticEntity();
if (columns.contains(NestedDescriptionTemplateElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionTemplateElasticEntity._id), UUID.class));
if (columns.contains(NestedDescriptionTemplateElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionTemplateElasticEntity._label), String.class));
if (columns.contains(NestedDescriptionTemplateElasticEntity._versionStatus)) mocDoc.setVersionStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionTemplateElasticEntity._versionStatus), DescriptionTemplateVersionStatus.class));
return mocDoc;
}
@ -69,6 +71,7 @@ public class InnerObjectDescriptionTemplateElasticQuery extends ElasticInnerObje
protected ElasticField fieldNameOf(FieldResolver item) {
if (item.match(NestedDescriptionTemplateElasticEntity._id)) return this.elasticFieldOf(NestedDescriptionTemplateElasticEntity._id).disableInfer(true);
else if (item.match(NestedDescriptionTemplateElasticEntity._label)) return this.elasticFieldOf(NestedDescriptionTemplateElasticEntity._label).disableInfer(true);
else if (item.match(NestedDescriptionTemplateElasticEntity._versionStatus)) return this.elasticFieldOf(NestedDescriptionTemplateElasticEntity._versionStatus).disableInfer(true);
else return null;
}

View File

@ -2,6 +2,8 @@ package eu.eudat.elastic.query;
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.DmpVersionStatus;
import eu.eudat.elastic.data.DmpElasticEntity;
import eu.eudat.elastic.data.nested.NestedDmpElasticEntity;
import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryFactory;
@ -61,6 +63,8 @@ public class InnerObjectDmpElasticQuery extends ElasticInnerObjectQuery<InnerObj
if (columns.contains(NestedDmpElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._label), String.class));
if (columns.contains(NestedDmpElasticEntity._description)) mocDoc.setDescription(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._description), String.class));
if (columns.contains(NestedDmpElasticEntity._status)) mocDoc.setStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._status), DmpStatus.class));
if (columns.contains(NestedDmpElasticEntity._versionStatus)) mocDoc.setVersionStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._versionStatus), DmpVersionStatus.class));
if (columns.contains(NestedDmpElasticEntity._version)) mocDoc.setVersion(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._version), Short.class));
if (columns.contains(NestedDmpElasticEntity._groupId)) mocDoc.setGroupId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._groupId), UUID.class));
if (columns.contains(NestedDmpElasticEntity._accessType)) mocDoc.setAccessType(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._accessType), DmpAccessType.class));
if (columns.contains(NestedDmpElasticEntity._finalizedAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._finalizedAt), Date.class));
@ -75,6 +79,8 @@ public class InnerObjectDmpElasticQuery extends ElasticInnerObjectQuery<InnerObj
else if (item.match(NestedDmpElasticEntity._label)) return this.elasticFieldOf(NestedDmpElasticEntity._label);
else if (item.match(NestedDmpElasticEntity._description)) return this.elasticFieldOf(NestedDmpElasticEntity._description);
else if (item.match(NestedDmpElasticEntity._status)) return this.elasticFieldOf(NestedDmpElasticEntity._status);
else if (item.match(NestedDmpElasticEntity._versionStatus)) return this.elasticFieldOf(NestedDmpElasticEntity._versionStatus);
else if (item.match(NestedDmpElasticEntity._version)) return this.elasticFieldOf(NestedDmpElasticEntity._version);
else if (item.match(NestedDmpElasticEntity._groupId)) return this.elasticFieldOf(NestedDmpElasticEntity._groupId);
else if (item.match(NestedDmpElasticEntity._finalizedAt)) return this.elasticFieldOf(NestedDmpElasticEntity._finalizedAt);
else if (item.match(NestedDmpElasticEntity._accessType)) return this.elasticFieldOf(NestedDmpElasticEntity._accessType);

View File

@ -1,6 +1,7 @@
package eu.eudat.elastic.query;
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import eu.eudat.elastic.data.nested.NestedDescriptionTemplateElasticEntity;
import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.elastic.configuration.ElasticProperties;
@ -61,6 +62,7 @@ public class NestedDescriptionTemplateElasticQuery extends ElasticNestedQuery<Ne
NestedDescriptionTemplateElasticEntity mocDoc = new NestedDescriptionTemplateElasticEntity();
if (columns.contains(NestedDescriptionTemplateElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionTemplateElasticEntity._id), UUID.class));
if (columns.contains(NestedDescriptionTemplateElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionTemplateElasticEntity._label), String.class));
if (columns.contains(NestedDescriptionTemplateElasticEntity._versionStatus)) mocDoc.setVersionStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionTemplateElasticEntity._versionStatus), DescriptionTemplateVersionStatus.class));
return mocDoc;
}
@ -68,6 +70,7 @@ public class NestedDescriptionTemplateElasticQuery extends ElasticNestedQuery<Ne
protected ElasticField fieldNameOf(FieldResolver item) {
if (item.match(NestedDescriptionTemplateElasticEntity._id)) return this.elasticFieldOf(NestedDescriptionTemplateElasticEntity._id).disableInfer(true);
else if (item.match(NestedDescriptionTemplateElasticEntity._label)) return this.elasticFieldOf(NestedDescriptionTemplateElasticEntity._label).disableInfer(true);
else if (item.match(NestedDescriptionTemplateElasticEntity._versionStatus)) return this.elasticFieldOf(NestedDescriptionTemplateElasticEntity._versionStatus).disableInfer(true);
else return null;
}

View File

@ -2,6 +2,7 @@ package eu.eudat.model;
import eu.eudat.commons.enums.DescriptionTemplateStatus;
import eu.eudat.commons.enums.DescriptionTemplateTypeStatus;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.model.descriptiontemplatedefinition.Definition;
@ -23,6 +24,9 @@ public class DescriptionTemplate {
public final static String _groupId = "groupId";
private UUID groupId;
public static final String _versionStatus = "versionStatus";
private DescriptionTemplateVersionStatus versionStatus;
public final static String _version = "version";
private Short version;
@ -164,4 +168,12 @@ public class DescriptionTemplate {
public void setHash(String hash) {
this.hash = hash;
}
public DescriptionTemplateVersionStatus getVersionStatus() {
return versionStatus;
}
public void setVersionStatus(DescriptionTemplateVersionStatus versionStatus) {
this.versionStatus = versionStatus;
}
}

View File

@ -2,6 +2,7 @@ package eu.eudat.model;
import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.DmpVersionStatus;
import eu.eudat.commons.enums.IsActive;
import java.time.Instant;
@ -26,6 +27,10 @@ public class Dmp {
public static final String _status = "status";
private DmpVersionStatus versionStatus;
public static final String _versionStatus = "versionStatus";
private String properties;
public static final String _properties = "properties";
@ -250,4 +255,11 @@ public class Dmp {
this.dmpUsers = dmpUsers;
}
public DmpVersionStatus getVersionStatus() {
return versionStatus;
}
public void setVersionStatus(DmpVersionStatus versionStatus) {
this.versionStatus = versionStatus;
}
}

View File

@ -1,6 +1,7 @@
package eu.eudat.model;
import eu.eudat.commons.enums.DescriptionTemplateStatus;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.model.descriptiontemplatedefinition.Definition;

View File

@ -76,6 +76,7 @@ public class DescriptionTemplateBuilder extends BaseBuilder<DescriptionTemplate,
if (fields.hasField(this.asIndexer(DescriptionTemplate._createdAt))) m.setCreatedAt(d.getCreatedAt());
if (fields.hasField(this.asIndexer(DescriptionTemplate._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(DescriptionTemplate._isActive))) m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(DescriptionTemplate._versionStatus))) m.setVersionStatus(d.getVersionStatus());
if (fields.hasField(this.asIndexer(DescriptionTemplate._status))) m.setStatus(d.getStatus());
if (fields.hasField(this.asIndexer(DescriptionTemplate._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
if (!definitionFields.isEmpty() && d.getDefinition() != null){

View File

@ -64,44 +64,25 @@ public class DmpBuilder extends BaseBuilder<Dmp, DmpEntity> {
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._groupId)))
m.setGroupId(d.getGroupId());
if (fields.hasField(this.asIndexer(Dmp._description)))
m.setDescription(d.getDescription());
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._accessType)))
m.setAccessType(d.getAccessType());
if (fields.hasField(this.asIndexer(Dmp._blueprint)))
m.setBlueprint(d.getBlueprint());
if (fields.hasField(this.asIndexer(Dmp._language)))
m.setLanguage(d.getLanguage());
if (fields.hasField(this.asIndexer(Dmp._publicAfter)))
m.setPublicAfter(d.getPublicAfter());
if (fields.hasField(this.asIndexer(Dmp._hash)))
m.setHash(this.hashValue(d.getUpdatedAt()));
if (dmpReferencesMap != null && !dmpReferencesMap.isEmpty() && dmpReferencesMap.containsKey(d.getId()))
m.setDmpReferences(dmpReferencesMap.get(d.getId()));
if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId()))
m.setDmpUsers(dmpUsersMap.get(d.getId()));
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._groupId))) m.setGroupId(d.getGroupId());
if (fields.hasField(this.asIndexer(Dmp._description))) m.setDescription(d.getDescription());
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._accessType))) m.setAccessType(d.getAccessType());
if (fields.hasField(this.asIndexer(Dmp._blueprint))) m.setBlueprint(d.getBlueprint());
if (fields.hasField(this.asIndexer(Dmp._language))) m.setLanguage(d.getLanguage());
if (fields.hasField(this.asIndexer(Dmp._versionStatus))) m.setVersionStatus(d.getVersionStatus());
if (fields.hasField(this.asIndexer(Dmp._publicAfter))) m.setPublicAfter(d.getPublicAfter());
if (fields.hasField(this.asIndexer(Dmp._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
if (dmpReferencesMap != null && !dmpReferencesMap.isEmpty() && dmpReferencesMap.containsKey(d.getId())) m.setDmpReferences(dmpReferencesMap.get(d.getId()));
if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId())) m.setDmpUsers(dmpUsersMap.get(d.getId()));
models.add(m);
}

View File

@ -3,6 +3,7 @@ package eu.eudat.query;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission;
import eu.eudat.commons.enums.DescriptionTemplateStatus;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.DescriptionEntity;
@ -38,6 +39,8 @@ public class DescriptionTemplateQuery extends QueryBase<DescriptionTemplateEntit
private Collection<IsActive> isActives;
private Collection<DescriptionTemplateVersionStatus> versionStatuses;
private Collection<DescriptionTemplateStatus> statuses;
private Collection<UUID> excludedIds;
@ -126,6 +129,21 @@ public class DescriptionTemplateQuery extends QueryBase<DescriptionTemplateEntit
return this;
}
public DescriptionTemplateQuery versionStatuses(DescriptionTemplateVersionStatus value) {
this.versionStatuses = List.of(value);
return this;
}
public DescriptionTemplateQuery versionStatuses(DescriptionTemplateVersionStatus... value) {
this.versionStatuses = Arrays.asList(value);
return this;
}
public DescriptionTemplateQuery versionStatuses(Collection<DescriptionTemplateVersionStatus> values) {
this.versionStatuses = values;
return this;
}
public DescriptionTemplateQuery excludedIds(Collection<UUID> values) {
this.excludedIds = values;
return this;
@ -163,7 +181,7 @@ public class DescriptionTemplateQuery extends QueryBase<DescriptionTemplateEntit
@Override
protected Boolean isFalseQuery() {
return this.isEmpty(this.ids) || this.isEmpty(this.typeIds) || this.isEmpty(this.groupIds) ||this.isEmpty(this.isActives) || this.isEmpty(this.excludedIds) || this.isEmpty(this.statuses);
return this.isEmpty(this.ids) || this.isEmpty(this.typeIds) || this.isEmpty(this.versionStatuses) || this.isEmpty(this.groupIds) ||this.isEmpty(this.isActives) || this.isEmpty(this.excludedIds) || this.isEmpty(this.statuses);
}
@Override
@ -186,7 +204,7 @@ public class DescriptionTemplateQuery extends QueryBase<DescriptionTemplateEntit
));
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateEntity._id)).value(dmpDescriptionTemplateSubquery));
}
if (predicates.size() > 0) {
if (!predicates.isEmpty()) {
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
return queryContext.CriteriaBuilder.and(predicatesArray);
} else {
@ -226,6 +244,12 @@ public class DescriptionTemplateQuery extends QueryBase<DescriptionTemplateEntit
inClause.value(item);
predicates.add(inClause);
}
if (this.versionStatuses != null) {
CriteriaBuilder.In<DescriptionTemplateVersionStatus> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateEntity._versionStatus));
for (DescriptionTemplateVersionStatus item : this.versionStatuses)
inClause.value(item);
predicates.add(inClause);
}
if (this.statuses != null) {
CriteriaBuilder.In<DescriptionTemplateStatus> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateEntity._status));
@ -262,6 +286,7 @@ public class DescriptionTemplateQuery extends QueryBase<DescriptionTemplateEntit
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._updatedAt, Instant.class));
item.setIsActive(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._isActive, IsActive.class));
item.setStatus(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._status, DescriptionTemplateStatus.class));
item.setVersionStatus(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._versionStatus, DescriptionTemplateVersionStatus.class));
return item;
}
@ -280,6 +305,7 @@ public class DescriptionTemplateQuery extends QueryBase<DescriptionTemplateEntit
else if (item.match(DescriptionTemplate._updatedAt)) return DescriptionTemplateEntity._updatedAt;
else if (item.match(DescriptionTemplate._isActive)) return DescriptionTemplateEntity._isActive;
else if (item.match(DescriptionTemplate._status)) return DescriptionTemplateEntity._status;
else if (item.match(DescriptionTemplate._versionStatus)) return DescriptionTemplateEntity._versionStatus;
else return null;
}

View File

@ -4,10 +4,13 @@ import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission;
import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.DmpVersionStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.data.DmpEntity;
import eu.eudat.data.DmpUserEntity;
import eu.eudat.model.DescriptionTemplate;
import eu.eudat.model.Dmp;
import eu.eudat.model.PublicDmp;
import eu.eudat.query.utils.BuildSubQueryInput;
@ -40,6 +43,7 @@ public class DmpQuery extends QueryBase<DmpEntity> {
private Collection<IsActive> isActives;
private Collection<DmpStatus> statuses;
private Collection<DmpVersionStatus> versionStatuses;
private Collection<DmpAccessType> accessTypes;
private Collection<Integer> versions;
@ -108,6 +112,21 @@ public class DmpQuery extends QueryBase<DmpEntity> {
return this;
}
public DmpQuery versionStatuses(DmpVersionStatus value) {
this.versionStatuses = List.of(value);
return this;
}
public DmpQuery versionStatuses(DmpVersionStatus... value) {
this.versionStatuses = Arrays.asList(value);
return this;
}
public DmpQuery versionStatuses(Collection<DmpVersionStatus> values) {
this.versionStatuses = values;
return this;
}
public DmpQuery accessTypes(DmpAccessType value) {
this.accessTypes = List.of(value);
return this;
@ -175,7 +194,7 @@ public class DmpQuery extends QueryBase<DmpEntity> {
@Override
protected Boolean isFalseQuery() {
return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.excludedIds) || this.isEmpty(this.accessTypes)|| this.isEmpty(this.statuses);
return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.versionStatuses) || this.isEmpty(this.excludedIds) || this.isEmpty(this.accessTypes)|| this.isEmpty(this.statuses);
}
@Override
@ -240,6 +259,12 @@ public class DmpQuery extends QueryBase<DmpEntity> {
inClause.value(item);
predicates.add(inClause);
}
if (this.versionStatuses != null) {
CriteriaBuilder.In<DmpVersionStatus> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._versionStatus));
for (DmpVersionStatus item : this.versionStatuses)
inClause.value(item);
predicates.add(inClause);
}
if (this.accessTypes != null) {
CriteriaBuilder.In<DmpAccessType> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._accessType));
for (DmpAccessType item : this.accessTypes)
@ -284,6 +309,7 @@ public class DmpQuery extends QueryBase<DmpEntity> {
else if (item.match(Dmp._blueprint)) return DmpEntity._blueprint;
else if (item.match(Dmp._language)) return DmpEntity._language;
else if (item.match(Dmp._publicAfter)) return DmpEntity._publicAfter;
else if (item.match(Dmp._versionStatus)) return DmpEntity._versionStatus;
else return null;
}
@ -294,6 +320,7 @@ public class DmpQuery extends QueryBase<DmpEntity> {
item.setLabel(QueryBase.convertSafe(tuple, columns, DmpEntity._label, String.class));
item.setVersion(QueryBase.convertSafe(tuple, columns, DmpEntity._version, Short.class));
item.setStatus(QueryBase.convertSafe(tuple, columns, DmpEntity._status, DmpStatus.class));
item.setVersionStatus(QueryBase.convertSafe(tuple, columns, DmpEntity._versionStatus, DmpVersionStatus.class));
item.setProperties(QueryBase.convertSafe(tuple, columns, DmpEntity._properties, String.class));
item.setGroupId(QueryBase.convertSafe(tuple, columns, DmpEntity._groupId, UUID.class));
item.setDescription(QueryBase.convertSafe(tuple, columns, DmpEntity._description, String.class));

View File

@ -1,6 +1,7 @@
package eu.eudat.query.lookup;
import eu.eudat.commons.enums.DescriptionTemplateStatus;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.query.DescriptionTemplateQuery;
import gr.cite.tools.data.query.Lookup;
@ -18,6 +19,7 @@ public class DescriptionTemplateLookup extends Lookup {
private List<UUID> groupIds;
private List<DescriptionTemplateStatus> statuses;
private List<DescriptionTemplateVersionStatus> versionStatuses;
private List<UUID> ids;
@ -81,22 +83,24 @@ public class DescriptionTemplateLookup extends Lookup {
this.groupIds = groupIds;
}
public List<DescriptionTemplateVersionStatus> getVersionStatuses() {
return versionStatuses;
}
public void setVersionStatuses(List<DescriptionTemplateVersionStatus> versionStatuses) {
this.versionStatuses = versionStatuses;
}
public DescriptionTemplateQuery enrich(QueryFactory queryFactory) {
DescriptionTemplateQuery query = queryFactory.query(DescriptionTemplateQuery.class);
if (this.like != null)
query.like(this.like);
if (this.isActive != null)
query.isActive(this.isActive);
if (this.groupIds != null)
query.groupIds(this.groupIds);
if (this.statuses != null)
query.statuses(this.statuses);
if (this.ids != null)
query.ids(this.ids);
if (this.excludedIds != null)
query.excludedIds(this.excludedIds);
if (this.typeIds != null)
query.typeIds(this.typeIds);
if (this.like != null) query.like(this.like);
if (this.isActive != null) query.isActive(this.isActive);
if (this.groupIds != null) query.groupIds(this.groupIds);
if (this.statuses != null) query.statuses(this.statuses);
if (this.ids != null) query.ids(this.ids);
if (this.excludedIds != null) query.excludedIds(this.excludedIds);
if (this.typeIds != null) query.typeIds(this.typeIds);
if (this.versionStatuses != null) query.versionStatuses(this.versionStatuses);
this.enrichCommon(query);

View File

@ -2,6 +2,7 @@ package eu.eudat.query.lookup;
import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.DmpVersionStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.query.DmpQuery;
import gr.cite.tools.data.query.Lookup;
@ -19,6 +20,7 @@ public class DmpLookup extends Lookup {
private List<UUID> excludedIds;
private List<IsActive> isActive;
private List<DmpVersionStatus> versionStatuses;
private List<DmpStatus> statuses;
private List<DmpAccessType> accessTypes;
@ -81,6 +83,14 @@ public class DmpLookup extends Lookup {
this.accessTypes = accessTypes;
}
public List<DmpVersionStatus> getVersionStatuses() {
return versionStatuses;
}
public void setVersionStatuses(List<DmpVersionStatus> versionStatuses) {
this.versionStatuses = versionStatuses;
}
public DmpQuery enrich(QueryFactory queryFactory) {
DmpQuery query = queryFactory.query(DmpQuery.class);
if (this.like != null) query.like(this.like);
@ -90,6 +100,7 @@ public class DmpLookup extends Lookup {
if (this.isActive != null) query.isActive(this.isActive);
if (this.statuses != null) query.statuses(this.statuses);
if (this.versions != null) query.versions(this.versions);
if (this.versionStatuses != null) query.versionStatuses(this.versionStatuses);
this.enrichCommon(query);

View File

@ -5,11 +5,8 @@ import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission;
import eu.eudat.commons.JsonHandlingService;
import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.enums.*;
import eu.eudat.configurations.filepath.FilePathsProperties;
import eu.eudat.commons.enums.DescriptionTemplateStatus;
import eu.eudat.commons.enums.FieldType;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.enums.UserDescriptionTemplateRole;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.commons.types.descriptiontemplate.*;
import eu.eudat.commons.types.descriptiontemplate.fielddata.BaseFieldDataEntity;
@ -157,6 +154,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
data.setIsActive(IsActive.Active);
data.setCreatedAt(Instant.now());
data.setGroupId(UUID.randomUUID());
data.setVersionStatus(DescriptionTemplateVersionStatus.Current);
data.setVersion((short)1);
}
@ -462,10 +460,12 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
DescriptionTemplateEntity oldDescriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getId());
if (oldDescriptionTemplateEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
if (!this.conventionService.hashValue(oldDescriptionTemplateEntity.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
DescriptionTemplateQuery latestVersionDescriptionTemplateEntityQuery = this.queryFactory.query(DescriptionTemplateQuery.class).groupIds(oldDescriptionTemplateEntity.getGroupId());
latestVersionDescriptionTemplateEntityQuery.setOrder(new Ordering().addDescending(DescriptionTemplateEntity._version));
DescriptionTemplateEntity latestVersionDescriptionTemplateEntity = latestVersionDescriptionTemplateEntityQuery.first();
if (!latestVersionDescriptionTemplateEntity.getVersion().equals(oldDescriptionTemplateEntity.getVersion())){
DescriptionTemplateQuery latestVersionDescriptionTemplateEntityQuery = this.queryFactory.query(DescriptionTemplateQuery.class).versionStatuses(DescriptionTemplateVersionStatus.Current).groupIds(oldDescriptionTemplateEntity.getGroupId());
List<DescriptionTemplateEntity> latestVersionDescriptionTemplates = latestVersionDescriptionTemplateEntityQuery.collect();
if (latestVersionDescriptionTemplates.isEmpty()) throw new MyValidationException("Previous template not found");
if (latestVersionDescriptionTemplates.size() > 1) throw new MyValidationException("Multiple previous template found");
if (!latestVersionDescriptionTemplates.get(0).getVersion().equals(oldDescriptionTemplateEntity.getVersion())){
throw new MyValidationException(this.errors.getDescriptionTemplateNewVersionConflict().getCode(), this.errors.getDescriptionTemplateNewVersionConflict().getMessage());
}
@ -474,6 +474,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
data.setIsActive(IsActive.Active);
data.setCreatedAt(Instant.now());
data.setUpdatedAt(Instant.now());
data.setVersionStatus(DescriptionTemplateVersionStatus.Current);
data.setGroupId(oldDescriptionTemplateEntity.getGroupId());
data.setVersion((short)(oldDescriptionTemplateEntity.getVersion() + 1));
data.setDescription(model.getDescription());
@ -489,6 +490,9 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
//this.addOwner(data);
oldDescriptionTemplateEntity.setVersionStatus(DescriptionTemplateVersionStatus.Previous);
this.entityManager.merge(oldDescriptionTemplateEntity);
this.entityManager.flush();
return this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrPermissionOrMemberOrPublic).build(BaseFieldSet.build(fields, DescriptionTemplate._id), data);

View File

@ -5,9 +5,7 @@ import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission;
import eu.eudat.commons.JsonHandlingService;
import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.DmpUserRole;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.enums.*;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.commons.types.reference.DefinitionEntity;
import eu.eudat.commons.types.reference.FieldEntity;
@ -150,10 +148,11 @@ public class DmpServiceImpl implements DmpService {
DmpEntity oldDmpEntity = this.entityManager.find(DmpEntity.class, model.getId());
if (oldDmpEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
if (!this.conventionService.hashValue(oldDmpEntity.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
DmpQuery latestVersionDmpEntityQuery = this.queryFactory.query(DmpQuery.class).groupIds(oldDmpEntity.getGroupId());
latestVersionDmpEntityQuery.setOrder(new Ordering().addDescending(Dmp._version));
DmpEntity latestVersionDmpEntity = latestVersionDmpEntityQuery.first();
if (!latestVersionDmpEntity.getVersion().equals(oldDmpEntity.getVersion())){
DmpQuery latestVersionDmpEntityQuery = this.queryFactory.query(DmpQuery.class).groupIds(oldDmpEntity.getGroupId()).versionStatuses(DmpVersionStatus.Current);
List<DmpEntity> latestVersionDmps = latestVersionDmpEntityQuery.collect();
if (latestVersionDmps.isEmpty()) throw new MyValidationException("Previous dmp not found");
if (latestVersionDmps.size() > 1) throw new MyValidationException("Multiple previous dmps found");
if (!latestVersionDmps.get(0).getVersion().equals(oldDmpEntity.getVersion())){
throw new MyValidationException(this.errors.getDmpNewVersionConflict().getCode(), this.errors.getDmpNewVersionConflict().getMessage());
}
@ -163,6 +162,7 @@ public class DmpServiceImpl implements DmpService {
newDmp.setCreatedAt(Instant.now());
newDmp.setUpdatedAt(Instant.now());
newDmp.setGroupId(oldDmpEntity.getGroupId());
newDmp.setVersionStatus(DmpVersionStatus.Current);
newDmp.setVersion((short)(oldDmpEntity.getVersion() + 1));
newDmp.setDescription(model.getDescription());
newDmp.setLabel(model.getLabel());
@ -229,6 +229,9 @@ public class DmpServiceImpl implements DmpService {
this.entityManager.persist(newDmp);
oldDmpEntity.setVersionStatus(DmpVersionStatus.Previous);
this.entityManager.merge(oldDmpEntity);
this.entityManager.flush();
return this.builderFactory.builder(DmpBuilder.class).build(BaseFieldSet.build(fields, Dmp._id), newDmp);
@ -391,6 +394,7 @@ public class DmpServiceImpl implements DmpService {
data.setGroupId(UUID.randomUUID());
data.setVersion((short) 1);
data.setStatus(DmpStatus.Draft);
data.setVersionStatus(DmpVersionStatus.Current);
data.setCreator(userScope.getUserId());
data.setBlueprint(model.getBlueprint());
data.setIsActive(IsActive.Active);

View File

@ -91,53 +91,53 @@ public class Datasets extends BaseController {
* Data Retrieval
* */
@RequestMapping(method = RequestMethod.POST, value = {"paged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DatasetListingModel>>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest) throws Exception {
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
DataTableData<DatasetListingModel> dataTable = this.datasetManager.getPaged(datasetTableRequest);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
}
@RequestMapping(method = RequestMethod.POST, value = {"/public/paged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DatasetListingModel>>> getPublicPaged(@RequestBody DatasetPublicTableRequest datasetTableRequest) throws Exception {
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
DataTableData<DatasetListingModel> dataTable = this.datasetManager.getPaged(datasetTableRequest);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
}
@RequestMapping(method = RequestMethod.GET, value = {"/overview/{id}"})
public @ResponseBody
ResponseEntity getOverviewSingle(@PathVariable String id) {
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
try {
DatasetOverviewModel dataset = this.datasetManager.getOverviewSingle(id, false);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
} catch (Exception e) {
if (e instanceof UnauthorisedException) {
return ResponseEntity.status(HttpStatus.FORBIDDEN).body(new ResponseItem<DatasetOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
} else {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ResponseItem<DatasetOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
}
}
}
@RequestMapping(method = RequestMethod.GET, value = {"/publicOverview/{id}"})
public @ResponseBody
ResponseEntity<ResponseItem<DatasetOverviewModel>> getOverviewSinglePublic(@PathVariable String id) throws Exception {
this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
// try {
DatasetOverviewModel dataset = this.datasetManager.getOverviewSingle(id, true);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
// } catch (Exception ex) {
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
// @RequestMapping(method = RequestMethod.POST, value = {"paged"}, consumes = "application/json", produces = "application/json")
// public @ResponseBody
// ResponseEntity<ResponseItem<DataTableData<DatasetListingModel>>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest) throws Exception {
// this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
//
// DataTableData<DatasetListingModel> dataTable = this.datasetManager.getPaged(datasetTableRequest);
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
// }
//
// @RequestMapping(method = RequestMethod.POST, value = {"/public/paged"}, consumes = "application/json", produces = "application/json")
// public @ResponseBody
// ResponseEntity<ResponseItem<DataTableData<DatasetListingModel>>> getPublicPaged(@RequestBody DatasetPublicTableRequest datasetTableRequest) throws Exception {
// this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
//
// DataTableData<DatasetListingModel> dataTable = this.datasetManager.getPaged(datasetTableRequest);
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
// }
//
// @RequestMapping(method = RequestMethod.GET, value = {"/overview/{id}"})
// public @ResponseBody
// ResponseEntity getOverviewSingle(@PathVariable String id) {
// this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
//
// try {
// DatasetOverviewModel dataset = this.datasetManager.getOverviewSingle(id, false);
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
// } catch (Exception e) {
// if (e instanceof UnauthorisedException) {
// return ResponseEntity.status(HttpStatus.FORBIDDEN).body(new ResponseItem<DatasetOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
// } else {
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ResponseItem<DatasetOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
// }
// }
// }
//
// @RequestMapping(method = RequestMethod.GET, value = {"/publicOverview/{id}"})
// public @ResponseBody
// ResponseEntity<ResponseItem<DatasetOverviewModel>> getOverviewSinglePublic(@PathVariable String id) throws Exception {
// this.authorizationService.authorizeForce(Permission.AdminRole, Permission.ManagerRole, Permission.UserRole, Permission.AnonymousRole);
//
// // try {
// DatasetOverviewModel dataset = this.datasetManager.getOverviewSingle(id, true);
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
//// } catch (Exception ex) {
//// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
//// }
// }
}
@Transactional
@RequestMapping(method = RequestMethod.GET, value = {"{id}"}, produces = "application/json")
@ -182,14 +182,14 @@ public class Datasets extends BaseController {
}
}
@RequestMapping(method = RequestMethod.POST, value = {"/datasetProfilesUsedByDatasets/paged"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DatasetProfileListingModel>>> getUsingDatasetProfilesPaged(@RequestBody DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws InvalidApplicationException {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
DataTableData<DatasetProfileListingModel> datasetProfileTableData = this.datasetManager.getDatasetProfilesUsedByDatasets(datasetProfileTableRequestItem);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
}
// @RequestMapping(method = RequestMethod.POST, value = {"/datasetProfilesUsedByDatasets/paged"}, produces = "application/json")
// public @ResponseBody
// ResponseEntity<ResponseItem<DataTableData<DatasetProfileListingModel>>> getUsingDatasetProfilesPaged(@RequestBody DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws InvalidApplicationException {
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
//
// DataTableData<DatasetProfileListingModel> datasetProfileTableData = this.datasetManager.getDatasetProfilesUsedByDatasets(datasetProfileTableRequestItem);
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
// }
// @RequestMapping(method = RequestMethod.POST, value = {"/userDmps"}, produces = "application/json")
// public @ResponseBody
@ -209,26 +209,26 @@ public class Datasets extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<AssociatedProfile>>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlans));
}
@RequestMapping(method = RequestMethod.GET, value = {"/public/{id}"}, produces = "application/json")
public @ResponseBody
ResponseEntity getSinglePublic(@PathVariable String id) throws Exception {
try {
DatasetWizardModel dataset = this.datasetManager.getSinglePublic(id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
}
catch (Exception ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
}
}
// @RequestMapping(method = RequestMethod.GET, value = {"/public/{id}"}, produces = "application/json")
// public @ResponseBody
// ResponseEntity getSinglePublic(@PathVariable String id) throws Exception {
// try {
// DatasetWizardModel dataset = this.datasetManager.getSinglePublic(id);
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
// }
// catch (Exception ex) {
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
// }
// }
@RequestMapping(method = RequestMethod.GET, value = {"/get/{id}"}, produces = "application/json")
public ResponseEntity<ResponseItem<PagedDatasetProfile>> getSingle(@PathVariable String id) throws InvalidApplicationException {
DescriptionTemplateEntity profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(profile);
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<PagedDatasetProfile>().status(ApiMessageCode.NO_MESSAGE).payload(pagedDatasetProfile));
}
// @RequestMapping(method = RequestMethod.GET, value = {"/get/{id}"}, produces = "application/json")
// public ResponseEntity<ResponseItem<PagedDatasetProfile>> getSingle(@PathVariable String id) throws InvalidApplicationException {
// DescriptionTemplateEntity profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
// eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(profile);
// PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
// pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile);
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<PagedDatasetProfile>().status(ApiMessageCode.NO_MESSAGE).payload(pagedDatasetProfile));
// }
/*
* Data Export

View File

@ -19,6 +19,7 @@ CREATE TABLE IF NOT EXISTS public."Dmp"
"created_at" timestamp without time zone NOT NULL DEFAULT now(),
"updated_at" timestamp without time zone NOT NULL DEFAULT now(),
"is_active" smallint NOT NULL DEFAULT 1,
"version_status" smallint NOT NULL DEFAULT 1,
"finalized_at" timestamp without time zone,
"published_at" timestamp without time zone,
CONSTRAINT "Dmp_pkey" PRIMARY KEY (id),

View File

@ -32,3 +32,18 @@ UPDATE public."DescriptionTemplate" SET is_active = 0 where status = 99;
UPDATE public."DescriptionTemplate" SET status = 0 where is_active = 0;
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN is_active SET NOT NULL;
ALTER TABLE public."DescriptionTemplate" ADD COLUMN version_status smallint;
UPDATE public."DescriptionTemplate" SET version_status = 1;
UPDATE public."DescriptionTemplate" SET version_status = 0 where id in (
select dt.id from public."DescriptionTemplate" as dt
where dt.version =
(
select Max(f.version)
from public."DescriptionTemplate" as f where f.group_id=dt.group_id
)
);
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN version_status SET NOT NULL;