rename sourceType to referenceSourceType

This commit is contained in:
amentis 2023-10-27 18:29:06 +03:00
parent 92c165e904
commit 9d3cc9e3d2
14 changed files with 69 additions and 65 deletions

View File

@ -4,14 +4,14 @@ import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map; import java.util.Map;
public enum SourceType implements DatabaseEnum<Short> { public enum ReferenceSourceType implements DatabaseEnum<Short> {
Internal((short) 0), Internal((short) 0),
External((short) 1); External((short) 1);
private final Short value; private final Short value;
SourceType(Short value) { ReferenceSourceType(Short value) {
this.value = value; this.value = value;
} }
@ -20,9 +20,9 @@ public enum SourceType implements DatabaseEnum<Short> {
return value; return value;
} }
private static final Map<Short, SourceType> map = EnumUtils.getEnumValueMap(SourceType.class); private static final Map<Short, ReferenceSourceType> map = EnumUtils.getEnumValueMap(ReferenceSourceType.class);
public static SourceType of(Short i) { public static ReferenceSourceType of(Short i) {
return map.get(i); return map.get(i);
} }
} }

View File

@ -1,6 +1,7 @@
package eu.eudat.configurations.referencetype; package eu.eudat.configurations.referencetype;
import eu.eudat.model.persist.referencedefinition.DefinitionPersist; import eu.eudat.model.persist.referencedefinition.DefinitionPersist;
import eu.eudat.model.referencedefinition.Field;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.bind.ConstructorBinding; import org.springframework.boot.context.properties.bind.ConstructorBinding;
@ -18,7 +19,7 @@ public class ReferenceTypeProperties {
private Map<String, List<ReferenceTypeField>> project; private Map<String, List<ReferenceTypeField>> project;
private Map<String, List<ReferenceTypeField>> organisation; private Map<String, List<ReferenceTypeField>> organisation;
private Map<String, List<ReferenceTypeField>> dataset; private Map<String, List<ReferenceTypeField>> dataset;
private Map<String, List<ReferenceTypeField>> dataRepository; private Map<String, List<Field>> dataRepository;
private Map<String, List<ReferenceTypeField>> pubRepository; private Map<String, List<ReferenceTypeField>> pubRepository;
private Map<String, List<ReferenceTypeField>> journal; private Map<String, List<ReferenceTypeField>> journal;
private Map<String, List<ReferenceTypeField>> publication; private Map<String, List<ReferenceTypeField>> publication;
@ -30,7 +31,7 @@ public class ReferenceTypeProperties {
Map<String, List<ReferenceTypeField>> researcher, Map<String, List<ReferenceTypeField>> service, Map<String, List<ReferenceTypeField>> researcher, Map<String, List<ReferenceTypeField>> service,
Map<String, List<ReferenceTypeField>> registry, Map<String, List<ReferenceTypeField>> project, Map<String, List<ReferenceTypeField>> registry, Map<String, List<ReferenceTypeField>> project,
Map<String, List<ReferenceTypeField>> organisation, Map<String, List<ReferenceTypeField>> dataset, Map<String, List<ReferenceTypeField>> organisation, Map<String, List<ReferenceTypeField>> dataset,
Map<String, List<ReferenceTypeField>> dataRepository, Map<String, List<ReferenceTypeField>> pubRepository, Map<String, List<Field>> dataRepository, Map<String, List<ReferenceTypeField>> pubRepository,
Map<String, List<ReferenceTypeField>> journal, Map<String, List<ReferenceTypeField>> publication, Map<String, List<ReferenceTypeField>> journal, Map<String, List<ReferenceTypeField>> publication,
Map<String, List<ReferenceTypeField>> licence, Map<String, List<ReferenceTypeField>> taxonomy) { Map<String, List<ReferenceTypeField>> licence, Map<String, List<ReferenceTypeField>> taxonomy) {
this.grant = grant; this.grant = grant;
@ -113,11 +114,11 @@ public class ReferenceTypeProperties {
this.dataset = dataset; this.dataset = dataset;
} }
public Map<String, List<ReferenceTypeField>> getDataRepository() { public Map<String, List<Field>> getDataRepository() {
return dataRepository; return dataRepository;
} }
public void setDataRepository(Map<String, List<ReferenceTypeField>> dataRepository) { public void setDataRepository(Map<String, List<Field>> dataRepository) {
this.dataRepository = dataRepository; this.dataRepository = dataRepository;
} }

View File

@ -2,7 +2,8 @@ package eu.eudat.data;
import eu.eudat.commons.enums.ReferenceType; import eu.eudat.commons.enums.ReferenceType;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.enums.SourceType; import eu.eudat.commons.enums.ReferenceSourceType;
import eu.eudat.data.converters.enums.ReferenceSourceTypeConverter;
import eu.eudat.data.converters.enums.ReferenceTypeConverter; import eu.eudat.data.converters.enums.ReferenceTypeConverter;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import jakarta.persistence.*; import jakarta.persistence.*;
@ -51,7 +52,8 @@ public class ReferenceEntity {
public static final String _source = "source"; public static final String _source = "source";
@Column(name = "source_type", nullable = false) @Column(name = "source_type", nullable = false)
private SourceType sourceType; @Convert(converter = ReferenceSourceTypeConverter.class)
private ReferenceSourceType referenceSourceType;
public static final String _sourceType = "sourceType"; public static final String _sourceType = "sourceType";
@Column(name = "is_active", nullable = false) @Column(name = "is_active", nullable = false)
@ -135,12 +137,12 @@ public class ReferenceEntity {
this.source = source; this.source = source;
} }
public SourceType getSourceType() { public ReferenceSourceType getReferenceSourceType() {
return sourceType; return referenceSourceType;
} }
public void setSourceType(SourceType sourceType) { public void setReferenceSourceType(ReferenceSourceType referenceSourceType) {
this.sourceType = sourceType; this.referenceSourceType = referenceSourceType;
} }
public IsActive getIsActive() { public IsActive getIsActive() {

View File

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

View File

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

View File

@ -2,7 +2,7 @@ package eu.eudat.model;
import eu.eudat.commons.enums.ReferenceType; import eu.eudat.commons.enums.ReferenceType;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.enums.SourceType; import eu.eudat.commons.enums.ReferenceSourceType;
import eu.eudat.model.referencedefinition.Definition; import eu.eudat.model.referencedefinition.Definition;
import java.time.Instant; import java.time.Instant;
@ -35,7 +35,7 @@ public class Reference {
private String source; private String source;
public static final String _source = "source"; public static final String _source = "source";
private SourceType sourceType; private ReferenceSourceType referenceSourceType;
public static final String _sourceType = "sourceType"; public static final String _sourceType = "sourceType";
private IsActive isActive; private IsActive isActive;
@ -117,12 +117,12 @@ public class Reference {
this.source = source; this.source = source;
} }
public SourceType getSourceType() { public ReferenceSourceType getReferenceSourceType() {
return sourceType; return referenceSourceType;
} }
public void setSourceType(SourceType sourceType) { public void setReferenceSourceType(ReferenceSourceType referenceSourceType) {
this.sourceType = sourceType; this.referenceSourceType = referenceSourceType;
} }
public IsActive getIsActive() { public IsActive getIsActive() {

View File

@ -78,7 +78,7 @@ public class ReferenceBuilder extends BaseBuilder<Reference, ReferenceEntity>{
if (fields.hasField(this.asIndexer(Reference._abbreviation))) m.setAbbreviation(d.getAbbreviation()); if (fields.hasField(this.asIndexer(Reference._abbreviation))) m.setAbbreviation(d.getAbbreviation());
if (fields.hasField(this.asIndexer(Reference._description))) m.setDescription(d.getDescription()); if (fields.hasField(this.asIndexer(Reference._description))) m.setDescription(d.getDescription());
if (fields.hasField(this.asIndexer(Reference._source))) m.setSource(d.getSource()); if (fields.hasField(this.asIndexer(Reference._source))) m.setSource(d.getSource());
if (fields.hasField(this.asIndexer(Reference._sourceType))) m.setSourceType(d.getSourceType()); if (fields.hasField(this.asIndexer(Reference._sourceType))) m.setReferenceSourceType(d.getReferenceSourceType());
if (fields.hasField(this.asIndexer(Reference._type))) m.setType(d.getType()); if (fields.hasField(this.asIndexer(Reference._type))) m.setType(d.getType());
// if (!userInfoFields.isEmpty() && d.getCreatedBy() != null){ // if (!userInfoFields.isEmpty() && d.getCreatedBy() != null){
// //ToDo // //ToDo

View File

@ -1,7 +1,7 @@
package eu.eudat.model.persist; package eu.eudat.model.persist;
import eu.eudat.commons.enums.ReferenceType; import eu.eudat.commons.enums.ReferenceType;
import eu.eudat.commons.enums.SourceType; import eu.eudat.commons.enums.ReferenceSourceType;
import eu.eudat.commons.validation.FieldNotNullIfOtherSet; import eu.eudat.commons.validation.FieldNotNullIfOtherSet;
import eu.eudat.commons.validation.ValidEnum; import eu.eudat.commons.validation.ValidEnum;
import eu.eudat.commons.validation.ValidId; import eu.eudat.commons.validation.ValidId;
@ -44,7 +44,7 @@ public class ReferencePersist {
private String source; private String source;
@ValidEnum(message = "{validation.empty}") @ValidEnum(message = "{validation.empty}")
private SourceType sourceType; private ReferenceSourceType referenceSourceType;
//private UserInfoPersist createdBy; ToDo //private UserInfoPersist createdBy; ToDo
@ -113,11 +113,11 @@ public class ReferencePersist {
this.source = source; this.source = source;
} }
public SourceType getSourceType() { public ReferenceSourceType getReferenceSourceType() {
return sourceType; return referenceSourceType;
} }
public void setSourceType(SourceType sourceType) { public void setReferenceSourceType(ReferenceSourceType referenceSourceType) {
this.sourceType = sourceType; this.referenceSourceType = referenceSourceType;
} }
} }

View File

@ -3,7 +3,7 @@ package eu.eudat.query;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.enums.ReferenceType; import eu.eudat.commons.enums.ReferenceType;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.enums.SourceType; import eu.eudat.commons.enums.ReferenceSourceType;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.ReferenceEntity; import eu.eudat.data.ReferenceEntity;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
@ -30,7 +30,7 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
private Collection<IsActive> isActives; private Collection<IsActive> isActives;
private Collection<SourceType> sourceTypes; private Collection<ReferenceSourceType> referenceSourceTypes;
private Collection<ReferenceType> referenceTypes; private Collection<ReferenceType> referenceTypes;
@ -103,18 +103,18 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
return this; return this;
} }
public ReferenceQuery sourceTypes(SourceType value) { public ReferenceQuery referenceSourceTypes(ReferenceSourceType value) {
this.sourceTypes = List.of(value); this.referenceSourceTypes = List.of(value);
return this; return this;
} }
public ReferenceQuery sourceTypes(SourceType... value) { public ReferenceQuery referenceSourceTypes(ReferenceSourceType... value) {
this.sourceTypes = Arrays.asList(value); this.referenceSourceTypes = Arrays.asList(value);
return this; return this;
} }
public ReferenceQuery sourceTypes(Collection<SourceType> values) { public ReferenceQuery referenceSourceTypes(Collection<ReferenceSourceType> values) {
this.sourceTypes = values; this.referenceSourceTypes = values;
return this; return this;
} }
@ -142,7 +142,7 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
@Override @Override
protected Boolean isFalseQuery() { protected Boolean isFalseQuery() {
return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.excludedIds) || this.isEmpty(this.referenceTypes) || this.isEmpty(this.sourceTypes); return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.excludedIds) || this.isEmpty(this.referenceTypes) || this.isEmpty(this.referenceSourceTypes);
} }
@Override @Override
@ -165,9 +165,9 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
inClause.value(item); inClause.value(item);
predicates.add(inClause); predicates.add(inClause);
} }
if (this.sourceTypes != null) { if (this.referenceSourceTypes != null) {
CriteriaBuilder.In<SourceType> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceEntity._sourceType)); CriteriaBuilder.In<ReferenceSourceType> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceEntity._sourceType));
for (SourceType item : this.sourceTypes) for (ReferenceSourceType item : this.referenceSourceTypes)
inClause.value(item); inClause.value(item);
predicates.add(inClause); predicates.add(inClause);
} }
@ -204,7 +204,7 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
item.setAbbreviation(QueryBase.convertSafe(tuple, columns, ReferenceEntity._abbreviation, String.class)); item.setAbbreviation(QueryBase.convertSafe(tuple, columns, ReferenceEntity._abbreviation, String.class));
item.setReference(QueryBase.convertSafe(tuple, columns, ReferenceEntity._reference, String.class)); item.setReference(QueryBase.convertSafe(tuple, columns, ReferenceEntity._reference, String.class));
item.setSource(QueryBase.convertSafe(tuple, columns, ReferenceEntity._source, String.class)); item.setSource(QueryBase.convertSafe(tuple, columns, ReferenceEntity._source, String.class));
item.setSourceType(QueryBase.convertSafe(tuple, columns, ReferenceEntity._sourceType, SourceType.class)); item.setReferenceSourceType(QueryBase.convertSafe(tuple, columns, ReferenceEntity._sourceType, ReferenceSourceType.class));
item.setType(QueryBase.convertSafe(tuple, columns, ReferenceEntity._type, ReferenceType.class)); item.setType(QueryBase.convertSafe(tuple, columns, ReferenceEntity._type, ReferenceType.class));
item.setCreatedBy(QueryBase.convertSafe(tuple, columns, ReferenceEntity._createdBy, UUID.class)); item.setCreatedBy(QueryBase.convertSafe(tuple, columns, ReferenceEntity._createdBy, UUID.class));
return item; return item;

View File

@ -2,7 +2,7 @@ package eu.eudat.query.lookup;
import eu.eudat.commons.enums.ReferenceType; import eu.eudat.commons.enums.ReferenceType;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.enums.SourceType; import eu.eudat.commons.enums.ReferenceSourceType;
import eu.eudat.query.ReferenceQuery; import eu.eudat.query.ReferenceQuery;
import gr.cite.tools.data.query.Lookup; import gr.cite.tools.data.query.Lookup;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
@ -17,7 +17,7 @@ public class ReferenceLookup extends Lookup {
private List<IsActive> isActive; private List<IsActive> isActive;
private Collection<SourceType> sourceTypes; private Collection<ReferenceSourceType> referenceSourceTypes;
private Collection<ReferenceType> referenceTypes; private Collection<ReferenceType> referenceTypes;
@ -57,12 +57,12 @@ public class ReferenceLookup extends Lookup {
this.excludedIds = excludeIds; this.excludedIds = excludeIds;
} }
public Collection<SourceType> getSourceTypes() { public Collection<ReferenceSourceType> getReferenceSourceTypes() {
return sourceTypes; return referenceSourceTypes;
} }
public void setSourceTypes(Collection<SourceType> sourceTypes) { public void setReferenceSourceTypes(Collection<ReferenceSourceType> referenceSourceTypes) {
this.sourceTypes = sourceTypes; this.referenceSourceTypes = referenceSourceTypes;
} }
public Collection<ReferenceType> getReferenceTypes() { public Collection<ReferenceType> getReferenceTypes() {
@ -78,7 +78,7 @@ public class ReferenceLookup extends Lookup {
if (this.like != null) query.like(this.like); if (this.like != null) query.like(this.like);
if (this.isActive != null) query.isActive(this.isActive); if (this.isActive != null) query.isActive(this.isActive);
if (this.referenceTypes != null) query.referenceTypes(this.referenceTypes); if (this.referenceTypes != null) query.referenceTypes(this.referenceTypes);
if (this.sourceTypes != null) query.sourceTypes(this.sourceTypes); if (this.referenceSourceTypes != null) query.referenceSourceTypes(this.referenceSourceTypes);
if (this.ids != null) query.ids(this.ids); if (this.ids != null) query.ids(this.ids);
if (this.excludedIds != null) query.excludedIds(this.excludedIds); if (this.excludedIds != null) query.excludedIds(this.excludedIds);

View File

@ -127,6 +127,7 @@ public class ReferenceService {
data.setReference(model.getReference()); data.setReference(model.getReference());
data.setAbbreviation(model.getAbbreviation()); data.setAbbreviation(model.getAbbreviation());
data.setSource(model.getSource()); data.setSource(model.getSource());
data.setReferenceSourceType(model.getReferenceSourceType());
if (isUpdate) this.entityManager.merge(data); if (isUpdate) this.entityManager.merge(data);
else this.entityManager.persist(data); else this.entityManager.persist(data);

View File

@ -0,0 +1,4 @@
export enum ReferenceSourceType {
Internal = 0,
External = 1
}

View File

@ -1,4 +0,0 @@
export enum SourceType {
Internal = 0,
External = 1
}

View File

@ -1,6 +1,6 @@
import { ReferenceType } from "@app/core/common/enum/reference-type"; import { ReferenceType } from "@app/core/common/enum/reference-type";
import { IsActive } from "@app/core/common/enum/is-active.enum"; import { IsActive } from "@app/core/common/enum/is-active.enum";
import { SourceType } from "@app/core/common/enum/source-type"; import { ReferenceSourceType } from "@app/core/common/enum/reference-source-type";
import { UUID } from "crypto"; import { UUID } from "crypto";
import { DmpModel } from "../dmp/dmp"; import { DmpModel } from "../dmp/dmp";
import { ReferenceFieldDataType } from "@app/core/common/enum/reference-field-data-type"; import { ReferenceFieldDataType } from "@app/core/common/enum/reference-field-data-type";
@ -14,7 +14,7 @@ export interface Reference {
reference: string; reference: string;
abbreviation: string; abbreviation: string;
source: string; source: string;
sourceType: SourceType; referenceSourceType: ReferenceSourceType;
isActive: IsActive; isActive: IsActive;
createdAt: Date; createdAt: Date;
updatedAt: Date; updatedAt: Date;
@ -70,7 +70,7 @@ export interface ReferencePersist {
reference: string; reference: string;
abbreviation: string; abbreviation: string;
source: string; source: string;
sourceType: SourceType; referenceSourceType: ReferenceSourceType;
} }
export interface DefinitionPersist { export interface DefinitionPersist {