Merge remote-tracking branch 'origin/dmp-refactoring' into dmp-refactoring

This commit is contained in:
George Kalampokis 2024-01-18 10:10:23 +02:00
commit 3749365e87
787 changed files with 15189 additions and 12984 deletions

View File

@ -24,10 +24,15 @@
<artifactId>commons-csv</artifactId> <artifactId>commons-csv</artifactId>
<version>1.10.0</version> <version>1.10.0</version>
</dependency> </dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.8.0</version>
</dependency>
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>validation</artifactId> <artifactId>validation</artifactId>
<version>2.1.0</version> <version>3.0.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>

View File

@ -37,6 +37,7 @@ public class AuditableAction {
public static final EventId Dmp_RemoveUser = new EventId(5007, "Dmp_RemoveUser"); public static final EventId Dmp_RemoveUser = new EventId(5007, "Dmp_RemoveUser");
public static final EventId Dmp_Invite_Users = new EventId(5008, "Dmp_Invite_Users"); public static final EventId Dmp_Invite_Users = new EventId(5008, "Dmp_Invite_Users");
public static final EventId Dmp_Invite_Accept = new EventId(5009, "Dmp_Invite_Accept"); public static final EventId Dmp_Invite_Accept = new EventId(5009, "Dmp_Invite_Accept");
public static final EventId Dmp_PublicQuery = new EventId(5010, "Dmp_PublicQuery");
public static final EventId Description_Query = new EventId(6000, "Description_Query"); public static final EventId Description_Query = new EventId(6000, "Description_Query");
public static final EventId Description_Lookup = new EventId(6001, "Description_Lookup"); public static final EventId Description_Lookup = new EventId(6001, "Description_Lookup");
@ -129,5 +130,14 @@ public class AuditableAction {
public static final EventId ContactSupport_Sent = new EventId(210000, "ContactSupport_Sent"); public static final EventId ContactSupport_Sent = new EventId(210000, "ContactSupport_Sent");
public static final EventId ContactSupport_PublicSent = new EventId(210001, "ContactSupport_PublicSent"); public static final EventId ContactSupport_PublicSent = new EventId(210001, "ContactSupport_PublicSent");
public static final EventId Prefilling_Query = new EventId(220000, "Prefilling_Query");
public static final EventId Prefilling_Generate = new EventId(210001, "Prefilling_Generate");
public static final EventId Prefilling_GenerateWithData = new EventId(210002, "Prefilling_GenerateWithData");
public static final EventId Maintenance_GenerateElastic = new EventId(220000, "Maintenance_GenerateElastic");
public static final EventId Maintenance_ClearElastic = new EventId(230000, "Maintenance_ClearElastic");
public static final EventId Principal_Lookup = new EventId(240000, "Principal_Lookup");
} }

View File

@ -0,0 +1,5 @@
package eu.eudat.authorization;
public class ClaimNames {
public static final String ExternalProviderName = "ExternalProviderName";
}

View File

@ -165,6 +165,10 @@ public final class Permission {
public static String EditTenantUser = "EditTenantUser"; public static String EditTenantUser = "EditTenantUser";
public static String DeleteTenantUser = "DeleteTenantUser"; public static String DeleteTenantUser = "DeleteTenantUser";
//Prefilling
public static String BrowsePrefilling = "BrowsePrefilling";
//Lock //Lock
public static String BrowseLock = "BrowseLock"; public static String BrowseLock = "BrowseLock";
public static String EditLock = "EditLock"; public static String EditLock = "EditLock";

View File

@ -5,9 +5,9 @@ import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement; import jakarta.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "email-confirmation") @XmlRootElement(name = "merge-account-confirmation")
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class EmailConfirmationEntity { public class MergeAccountConfirmationEntity {
@XmlAttribute(name = "email") @XmlAttribute(name = "email")
private String email; private String email;

View File

@ -0,0 +1,24 @@
package eu.eudat.commons.types.actionconfirmation;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
import java.util.UUID;
@XmlRootElement(name = "remove-credential-confirmation")
@XmlAccessorType(XmlAccessType.FIELD)
public class RemoveCredentialRequestEntity {
@XmlAttribute(name = "credential-id")
private UUID credentialId;
public UUID getCredentialId() {
return credentialId;
}
public void setCredentialId(UUID credentialId) {
this.credentialId = credentialId;
}
}

View File

@ -77,15 +77,18 @@ public class DefinitionEntity implements XmlSerializable<DefinitionEntity> {
} }
return this; return this;
} }
public List<FieldEntity> getFieldById(String id){ public List<FieldEntity> getAllField(){
List<FieldEntity> fieldEntities = new ArrayList<>(); List<FieldEntity> fieldEntities = new ArrayList<>();
if (id == null || id.isBlank()) return fieldEntities;
if (this.getSections() != null){ if (this.getSections() != null){
for (SectionEntity sectionEntity: this.getSections()) { for (SectionEntity sectionEntity: this.getSections()) {
fieldEntities.addAll(sectionEntity.getFieldById(id)); fieldEntities.addAll(sectionEntity.getAllField());
} }
} }
return fieldEntities; return fieldEntities;
} }
public List<FieldEntity> getFieldById(String id) {
return this.getAllField().stream().filter(x-> id.equals(x.getId())).toList();
}
} }

View File

@ -191,10 +191,7 @@ public class FieldSetEntity implements DatabaseViewStyleDefinition, XmlSerializa
return this; return this;
} }
public List<FieldEntity> getAllField() {
public List<FieldEntity> getFieldById(String id){ return this.getFields() == null ? new ArrayList<>() : this.getFields();
if (this.getFields() == null || id == null || id.isBlank()) return new ArrayList<>();
return this.getFields().stream().filter(x-> id.equals(x.getId())).toList();
} }
} }

View File

@ -209,17 +209,16 @@ public class SectionEntity implements DatabaseViewStyleDefinition, XmlSerializab
return this; return this;
} }
public List<FieldEntity> getFieldById(String id){ public List<FieldEntity> getAllField(){
List<FieldEntity> fieldEntities = new ArrayList<>(); List<FieldEntity> fieldEntities = new ArrayList<>();
if (id == null || id.isBlank()) return fieldEntities;
if (this.getFieldSets() != null){ if (this.getFieldSets() != null){
for (FieldSetEntity fieldSetEntity: this.getFieldSets()) { for (FieldSetEntity fieldSetEntity: this.getFieldSets()) {
fieldEntities.addAll(fieldSetEntity.getFieldById(id)); fieldEntities.addAll(fieldSetEntity.getAllField());
} }
} }
if (this.getSections() != null){ if (this.getSections() != null){
for (SectionEntity sectionEntity: this.getSections()) { for (SectionEntity sectionEntity: this.getSections()) {
fieldEntities.addAll(sectionEntity.getFieldById(id)); fieldEntities.addAll(sectionEntity.getAllField());
} }
} }
return fieldEntities; return fieldEntities;

View File

@ -15,6 +15,9 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class AutoCompleteDataEntity extends ComboBoxDataEntity<AutoCompleteDataEntity> { public class AutoCompleteDataEntity extends ComboBoxDataEntity<AutoCompleteDataEntity> {
public AutoCompleteDataEntity() {
super(FieldType.AUTO_COMPLETE);
}
public static class AuthAutoCompleteData { public static class AuthAutoCompleteData {
private String url; private String url;
@ -145,11 +148,6 @@ public class AutoCompleteDataEntity extends ComboBoxDataEntity<AutoCompleteDataE
return FieldDataComboBoxType.Autocomplete; return FieldDataComboBoxType.Autocomplete;
} }
@Override
public FieldType getFieldType() {
return FieldType.AUTO_COMPLETE;
}
@Override @Override
public Element toXml(Document doc) { public Element toXml(Document doc) {
Element root = super.toXml(doc); Element root = super.toXml(doc);

View File

@ -8,9 +8,19 @@ import org.w3c.dom.Element;
import java.util.Map; import java.util.Map;
public abstract class BaseFieldDataEntity<T> implements XmlSerializable<T> { public abstract class BaseFieldDataEntity<T> implements XmlSerializable<T> {
private final FieldType fieldType;
public BaseFieldDataEntity(FieldType fieldType) {
this.fieldType = fieldType;
}
private String label; private String label;
public abstract FieldType getFieldType();
public FieldType getFieldType() {
return fieldType;
}
public String getLabel() { public String getLabel() {
return label; return label;

View File

@ -1,16 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class BooleanDecisionDataEntity extends BaseFieldDataEntity<BooleanDecisionDataEntity> {
@Override
public FieldType getFieldType() {
return FieldType.BOOLEAN_DECISION;
}
}

View File

@ -1,16 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class CheckBoxDataEntity extends BaseFieldDataEntity<CheckBoxDataEntity> {
@Override
public FieldType getFieldType() {
return FieldType.CHECK_BOX;
}
}

View File

@ -1,6 +1,7 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata; package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldDataComboBoxType; import eu.eudat.commons.enums.FieldDataComboBoxType;
import eu.eudat.commons.enums.FieldType;
import eu.eudat.commons.types.xml.XmlSerializable; import eu.eudat.commons.types.xml.XmlSerializable;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
@ -10,6 +11,10 @@ import java.util.Map;
public abstract class ComboBoxDataEntity<T> extends BaseFieldDataEntity<T> { public abstract class ComboBoxDataEntity<T> extends BaseFieldDataEntity<T> {
public ComboBoxDataEntity(FieldType fieldType) {
super(fieldType);
}
public abstract FieldDataComboBoxType getFieldSubType(); public abstract FieldDataComboBoxType getFieldSubType();
public static class Option implements XmlSerializable<Option> { public static class Option implements XmlSerializable<Option> {

View File

@ -1,15 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class CurrencyDataEntity extends BaseFieldDataEntity<CurrencyDataEntity> {
@Override
public FieldType getFieldType() {
return FieldType.CURRENCY;
}
}

View File

@ -1,41 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class DataRepositoryDataEntity extends BaseFieldDataEntity<DataRepositoryDataEntity> {
@Override
public FieldType getFieldType() {
return FieldType.DATA_REPOSITORIES;
}
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
@Override
public Element toXml(Document doc) {
Element root = super.toXml(doc);
if (this.getMultiAutoComplete() != null) {
root.setAttribute("multiAutoComplete", this.getMultiAutoComplete().toString());
}
return root;
}
@Override
public DataRepositoryDataEntity fromXml(Element item) {
super.fromXml(item);
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
return this;
}
}

View File

@ -1,47 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldDataComboBoxType;
import eu.eudat.commons.enums.FieldDataInternalDmpEntryType;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class DatasetAutoCompleteDataEntity extends InternalDmpBaseDataEntity<DatasetAutoCompleteDataEntity> {
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
@Override
public FieldDataInternalDmpEntryType getFieldSubType() {
return FieldDataInternalDmpEntryType.Datasets;
}
@Override
public FieldType getFieldType() {
return FieldType.INTERNAL_DMP_ENTRIES_DATASETS;
}
@Override
public Element toXml(Document doc) {
Element root = super.toXml(doc);
root.setAttribute("multiAutoComplete", this.multiAutoComplete.toString());
return root;
}
@Override
public DatasetAutoCompleteDataEntity fromXml(Element item) {
super.fromXml(item);
this.multiAutoComplete = Boolean.parseBoolean(item.getAttribute("multiAutoComplete"));
return this;
}
}

View File

@ -1,15 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class DatasetIdentifierDataEntity extends BaseFieldDataEntity<DatasetIdentifierDataEntity> {
@Override
public FieldType getFieldType() {
return FieldType.DATASET_IDENTIFIER;
}
}

View File

@ -1,15 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class DatePickerDataEntity extends BaseFieldDataEntity<DatePickerDataEntity> {
@Override
public FieldType getFieldType() {
return FieldType.DATE_PICKER;
}
}

View File

@ -1,45 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldDataInternalDmpEntryType;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class DmpAutoCompleteDataEntity extends InternalDmpBaseDataEntity<DmpAutoCompleteDataEntity> {
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
@Override
public FieldDataInternalDmpEntryType getFieldSubType() {
return FieldDataInternalDmpEntryType.Dmps;
}
@Override
public FieldType getFieldType() {
return FieldType.INTERNAL_DMP_ENTRIES_DMPS;
}
@Override
public Element toXml(Document doc) {
Element root = super.toXml(doc);
root.setAttribute("multiAutoComplete", this.multiAutoComplete.toString());
return root;
}
@Override
public DmpAutoCompleteDataEntity fromXml(Element item) {
super.fromXml(item);
this.multiAutoComplete = Boolean.parseBoolean(item.getAttribute("multiAutoComplete"));
return this;
}
}

View File

@ -9,10 +9,10 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class ExternalDatasetDataEntity extends BaseFieldDataEntity<ExternalDatasetDataEntity> { public class ExternalDatasetDataEntity extends BaseFieldDataEntity<ExternalDatasetDataEntity> {
@Override public ExternalDatasetDataEntity() {
public FieldType getFieldType() { super(FieldType.EXTERNAL_DATASETS);
return FieldType.EXTERNAL_DATASETS;
} }
private Boolean multiAutoComplete; private Boolean multiAutoComplete;
private FieldDataExternalDatasetType type; private FieldDataExternalDatasetType type;

View File

@ -26,41 +26,43 @@ public class FieldDataHelper {
if (subType != null && !subType.isBlank()) { if (subType != null && !subType.isBlank()) {
switch (FieldDataInternalDmpEntryType.of(subType)){ switch (FieldDataInternalDmpEntryType.of(subType)){
case Dmps: { case Dmps: {
return new DmpAutoCompleteDataEntity(); return new InternalDmpBaseDataEntity(FieldType.INTERNAL_DMP_ENTRIES_DMPS, FieldDataInternalDmpEntryType.Dmps);
} }
case Datasets: { case Datasets: {
return new DatasetAutoCompleteDataEntity(); return new InternalDmpBaseDataEntity(FieldType.INTERNAL_DMP_ENTRIES_DATASETS, FieldDataInternalDmpEntryType.Datasets);
} }
case Researchers : { case Researchers : {
return new ResearcherAutoCompleteDataEntity(); return new InternalDmpBaseDataEntity(FieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS, FieldDataInternalDmpEntryType.Researchers);
} }
} }
} }
break; break;
} }
case BOOLEAN_DECISION: return new BooleanDecisionDataEntity(); case LICENSES:
case ORGANIZATIONS:
case PUBLICATIONS:
case REGISTRIES:
case RESEARCHERS:
case SERVICES:
case TAXONOMIES:
case DATA_REPOSITORIES:
case JOURNAL_REPOSITORIES:
case PUB_REPOSITORIES:
case BOOLEAN_DECISION: return new LabelAndMultiplicityDataEntity(type);
case FREE_TEXT:
case DATE_PICKER:
case RICH_TEXT_AREA:
case TAGS:
case TEXT_AREA:
case VALIDATION:
case DATASET_IDENTIFIER:
case CURRENCY:
case CHECK_BOX: return new LabelDataEntity(type);
case RADIO_BOX: return new RadioBoxDataEntity(); case RADIO_BOX: return new RadioBoxDataEntity();
case CHECK_BOX: return new CheckBoxDataEntity();
case FREE_TEXT: return new FreeTextDataEntity();
case TEXT_AREA: return new TextAreaDataEntity();
case RICH_TEXT_AREA: return new RichTextAreaDataEntity();
case UPLOAD: return new UploadDataEntity(); case UPLOAD: return new UploadDataEntity();
case DATE_PICKER: return new DatePickerDataEntity();
case EXTERNAL_DATASETS: return new ExternalDatasetDataEntity(); case EXTERNAL_DATASETS: return new ExternalDatasetDataEntity();
case DATA_REPOSITORIES: return new DataRepositoryDataEntity();
case PUB_REPOSITORIES: return new PublicationRepositoryDataEntity();
case JOURNAL_REPOSITORIES: return new JournalRepositoryDataEntity();
case TAXONOMIES: return new TaxonomyDataEntity();
case LICENSES: return new LicenseDataEntity();
case PUBLICATIONS: return new PublicationDataEntity();
case REGISTRIES: return new RegistryDataEntity();
case SERVICES: return new ServiceDataEntity();
case TAGS: return new TagDataEntity();
case RESEARCHERS: return new ResearcherDataEntity();
case ORGANIZATIONS: return new OrganizationDataEntity();
case DATASET_IDENTIFIER: return new DatasetIdentifierDataEntity();
case CURRENCY: return new CurrencyDataEntity();
case VALIDATION: return new ValidationDataEntity();
default: return null; default: return null;
} }

View File

@ -1,16 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class FreeTextDataEntity extends BaseFieldDataEntity<FreeTextDataEntity> {
@Override
public FieldType getFieldType() {
return FieldType.FREE_TEXT;
}
}

View File

@ -1,15 +1,24 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata; package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldDataInternalDmpEntryType; import eu.eudat.commons.enums.FieldDataInternalDmpEntryType;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public abstract class InternalDmpBaseDataEntity<T> extends BaseFieldDataEntity<T> { public class InternalDmpBaseDataEntity extends LabelAndMultiplicityDataEntity {
public abstract FieldDataInternalDmpEntryType getFieldSubType(); private final FieldDataInternalDmpEntryType fieldSubType;
public InternalDmpBaseDataEntity(FieldType fieldType, FieldDataInternalDmpEntryType fieldSubType) {
super(fieldType);
this.fieldSubType = fieldSubType;
}
public FieldDataInternalDmpEntryType getFieldSubType() {
return fieldSubType;
}
@Override @Override
public Element toXml(Document doc) { public Element toXml(Document doc) {
@ -19,8 +28,8 @@ public abstract class InternalDmpBaseDataEntity<T> extends BaseFieldDataEntity<T
} }
@Override @Override
public T fromXml(Element item) { public InternalDmpBaseDataEntity fromXml(Element item) {
super.fromXml(item); super.fromXml(item);
return (T) this; return this;
} }
} }

View File

@ -1,41 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class JournalRepositoryDataEntity extends BaseFieldDataEntity<JournalRepositoryDataEntity> {
@Override
public FieldType getFieldType() {
return FieldType.JOURNAL_REPOSITORIES;
}
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
@Override
public Element toXml(Document doc) {
Element root = super.toXml(doc);
if (this.getMultiAutoComplete() != null) {
root.setAttribute("multiAutoComplete", this.getMultiAutoComplete().toString());
}
return root;
}
@Override
public JournalRepositoryDataEntity fromXml(Element item) {
super.fromXml(item);
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
return this;
}
}

View File

@ -4,14 +4,11 @@ import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import java.util.HashMap; public class LabelAndMultiplicityDataEntity extends BaseFieldDataEntity<LabelAndMultiplicityDataEntity> {
import java.util.Map; public LabelAndMultiplicityDataEntity(FieldType fieldType) {
super(fieldType);
public class TaxonomyDataEntity extends BaseFieldDataEntity<TaxonomyDataEntity> {
@Override
public FieldType getFieldType() {
return FieldType.TAXONOMIES;
} }
private Boolean multiAutoComplete; private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() { public Boolean getMultiAutoComplete() {
@ -32,7 +29,7 @@ public class TaxonomyDataEntity extends BaseFieldDataEntity<TaxonomyDataEntity>
} }
@Override @Override
public TaxonomyDataEntity fromXml(Element item) { public LabelAndMultiplicityDataEntity fromXml(Element item) {
super.fromXml(item); super.fromXml(item);
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete"))); this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
return this; return this;

View File

@ -0,0 +1,10 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldType;
public class LabelDataEntity extends BaseFieldDataEntity<LabelDataEntity> {
public LabelDataEntity(FieldType fieldType) {
super(fieldType);
}
}

View File

@ -1,40 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class LicenseDataEntity extends BaseFieldDataEntity<LicenseDataEntity> {
@Override
public FieldType getFieldType() {
return FieldType.LICENSES;
}
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
@Override
public Element toXml(Document doc) {
Element root = super.toXml(doc);
if (this.getMultiAutoComplete() != null) {
root.setAttribute("multiAutoComplete", this.getMultiAutoComplete().toString());
}
return root;
}
@Override
public LicenseDataEntity fromXml(Element item) {
super.fromXml(item);
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
return this;
}
}

View File

@ -1,40 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class OrganizationDataEntity extends BaseFieldDataEntity<OrganizationDataEntity> {
@Override
public FieldType getFieldType() {
return FieldType.ORGANIZATIONS;
}
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
@Override
public Element toXml(Document doc) {
Element root = super.toXml(doc);
if (this.getMultiAutoComplete() != null) {
root.setAttribute("multiAutoComplete", this.getMultiAutoComplete().toString());
}
return root;
}
@Override
public OrganizationDataEntity fromXml(Element item) {
super.fromXml(item);
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
return this;
}
}

View File

@ -1,39 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class PublicationDataEntity extends BaseFieldDataEntity<PublicationDataEntity> {
@Override
public FieldType getFieldType() {
return FieldType.PUBLICATIONS;
}
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
@Override
public Element toXml(Document doc) {
Element root = super.toXml(doc);
if (this.getMultiAutoComplete() != null) {
root.setAttribute("multiAutoComplete", this.getMultiAutoComplete().toString());
}
return root;
}
@Override
public PublicationDataEntity fromXml(Element item) {
super.fromXml(item);
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
return this;
}
}

View File

@ -1,41 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class PublicationRepositoryDataEntity extends BaseFieldDataEntity<PublicationRepositoryDataEntity> {
@Override
public FieldType getFieldType() {
return FieldType.PUB_REPOSITORIES;
}
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
@Override
public Element toXml(Document doc) {
Element root = super.toXml(doc);
if (this.getMultiAutoComplete() != null) {
root.setAttribute("multiAutoComplete", this.getMultiAutoComplete().toString());
}
return root;
}
@Override
public PublicationRepositoryDataEntity fromXml(Element item) {
super.fromXml(item);
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
return this;
}
}

View File

@ -13,10 +13,10 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class RadioBoxDataEntity extends BaseFieldDataEntity<RadioBoxDataEntity> { public class RadioBoxDataEntity extends BaseFieldDataEntity<RadioBoxDataEntity> {
@Override public RadioBoxDataEntity() {
public FieldType getFieldType() { super(FieldType.RADIO_BOX);
return FieldType.RADIO_BOX;
} }
public static class Option implements XmlSerializable<Option> { public static class Option implements XmlSerializable<Option> {
private String label; private String label;
private String value; private String value;

View File

@ -1,39 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class RegistryDataEntity extends BaseFieldDataEntity<RegistryDataEntity> {
@Override
public FieldType getFieldType() {
return FieldType.REGISTRIES;
}
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
@Override
public Element toXml(Document doc) {
Element root = super.toXml(doc);
if (this.getMultiAutoComplete() != null) {
root.setAttribute("multiAutoComplete", this.getMultiAutoComplete().toString());
}
return root;
}
@Override
public RegistryDataEntity fromXml(Element item) {
super.fromXml(item);
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
return this;
}
}

View File

@ -1,46 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldDataInternalDmpEntryType;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class ResearcherAutoCompleteDataEntity extends InternalDmpBaseDataEntity<ResearcherAutoCompleteDataEntity> {
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
@Override
public FieldDataInternalDmpEntryType getFieldSubType() {
return FieldDataInternalDmpEntryType.Researchers;
}
@Override
public FieldType getFieldType() {
return FieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS;
}
@Override
public Element toXml(Document doc) {
Element root = super.toXml(doc);
root.setAttribute("multiAutoComplete", this.multiAutoComplete != null ? this.multiAutoComplete.toString() : "false");
return root;
}
@Override
public ResearcherAutoCompleteDataEntity fromXml(Element item) {
super.fromXml(item);
this.multiAutoComplete = Boolean.parseBoolean(item.getAttribute("multiAutoComplete"));
return this;
}
}

View File

@ -1,40 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class ResearcherDataEntity extends BaseFieldDataEntity<ResearcherDataEntity> {
@Override
public FieldType getFieldType() {
return FieldType.RESEARCHERS;
}
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
@Override
public Element toXml(Document doc) {
Element root = super.toXml(doc);
if (this.getMultiAutoComplete() != null) {
root.setAttribute("multiAutoComplete", this.getMultiAutoComplete().toString());
}
return root;
}
@Override
public ResearcherDataEntity fromXml(Element item) {
super.fromXml(item);
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
return this;
}
}

View File

@ -1,16 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class RichTextAreaDataEntity extends BaseFieldDataEntity<RichTextAreaDataEntity> {
@Override
public FieldType getFieldType() {
return FieldType.RICH_TEXT_AREA;
}
}

View File

@ -1,40 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class ServiceDataEntity extends BaseFieldDataEntity<ServiceDataEntity> {
@Override
public FieldType getFieldType() {
return FieldType.SERVICES;
}
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
@Override
public Element toXml(Document doc) {
Element root = super.toXml(doc);
if (this.getMultiAutoComplete() != null) {
root.setAttribute("multiAutoComplete", this.getMultiAutoComplete().toString());
}
return root;
}
@Override
public ServiceDataEntity fromXml(Element item) {
super.fromXml(item);
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
return this;
}
}

View File

@ -1,15 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class TagDataEntity extends BaseFieldDataEntity<TagDataEntity> {
@Override
public FieldType getFieldType() {
return FieldType.TAGS;
}
}

View File

@ -1,16 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class TextAreaDataEntity extends BaseFieldDataEntity<TextAreaDataEntity> {
@Override
public FieldType getFieldType() {
return FieldType.TEXT_AREA;
}
}

View File

@ -14,10 +14,10 @@ import java.util.Map;
public class UploadDataEntity extends BaseFieldDataEntity<UploadDataEntity> { public class UploadDataEntity extends BaseFieldDataEntity<UploadDataEntity> {
@Override public UploadDataEntity() {
public FieldType getFieldType() { super(FieldType.UPLOAD);
return FieldType.UPLOAD;
} }
public static class Option implements XmlSerializable<UploadDataEntity.Option> { public static class Option implements XmlSerializable<UploadDataEntity.Option> {
private String label; private String label;
private String value; private String value;

View File

@ -1,15 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class ValidationDataEntity extends BaseFieldDataEntity<ValidationDataEntity> {
@Override
public FieldType getFieldType() {
return FieldType.VALIDATION;
}
}

View File

@ -13,6 +13,10 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class WordListDataEntity extends ComboBoxDataEntity<WordListDataEntity> { public class WordListDataEntity extends ComboBoxDataEntity<WordListDataEntity> {
public WordListDataEntity() {
super(FieldType.WORD_LIST);
}
private List<Option> options; private List<Option> options;
private Boolean multiList; private Boolean multiList;
@ -38,11 +42,6 @@ public class WordListDataEntity extends ComboBoxDataEntity<WordListDataEntity> {
return FieldDataComboBoxType.Wordlist; return FieldDataComboBoxType.Wordlist;
} }
@Override
public FieldType getFieldType() {
return FieldType.WORD_LIST;
}
@Override @Override
public Element toXml(Document doc) { public Element toXml(Document doc) {
Element root = super.toXml(doc); Element root = super.toXml(doc);

View File

@ -41,34 +41,34 @@ public class FieldImportExport {
private FieldType fieldType; private FieldType fieldType;
@XmlElements({ @XmlElements({
@XmlElement(name = FieldType.Names.CheckBox, type = CheckBoxDataImportExport.class), @XmlElement(name = FieldType.Names.CheckBox, type = LabelDataImportExport.class),
@XmlElement(name = FieldType.Names.Validation, type = ValidationDataImportExport.class), @XmlElement(name = FieldType.Names.Validation, type = LabelDataImportExport.class),
@XmlElement(name = FieldType.Names.TextArea, type = TextAreaDataImportExport.class), @XmlElement(name = FieldType.Names.TextArea, type = LabelDataImportExport.class),
@XmlElement(name = FieldType.Names.Taxonomies, type = TaxonomyDataImportExport.class), @XmlElement(name = FieldType.Names.Taxonomies, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.Tags, type = TagDataImportExport.class), @XmlElement(name = FieldType.Names.Tags, type = LabelDataImportExport.class),
@XmlElement(name = FieldType.Names.Services, type = ServiceDataImportExport.class), @XmlElement(name = FieldType.Names.Services, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.RichTextarea, type = RichTextAreaDataImportExport.class), @XmlElement(name = FieldType.Names.RichTextarea, type = LabelDataImportExport.class),
@XmlElement(name = FieldType.Names.Researchers, type = ResearcherDataImportExport.class), @XmlElement(name = FieldType.Names.Researchers, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.Registries, type = RegistryDataImportExport.class), @XmlElement(name = FieldType.Names.Registries, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.PubRepositories, type = PublicationRepositoryDataImportExport.class), @XmlElement(name = FieldType.Names.PubRepositories, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.Publications, type = PublicationDataImportExport.class), @XmlElement(name = FieldType.Names.Publications, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.Organizations, type = OrganizationDataImportExport.class), @XmlElement(name = FieldType.Names.Organizations, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.Licenses, type = LicenseDataImportExport.class), @XmlElement(name = FieldType.Names.Licenses, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.JournalRepositories, type = JournalRepositoryDataImportExport.class), @XmlElement(name = FieldType.Names.JournalRepositories, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.FreeText, type = FreeTextDataImportExport.class), @XmlElement(name = FieldType.Names.FreeText, type = LabelDataImportExport.class),
@XmlElement(name = FieldType.Names.ExternalDatasets, type = ExternalDatasetDataImportExport.class), @XmlElement(name = FieldType.Names.ExternalDatasets, type = ExternalDatasetDataImportExport.class),
@XmlElement(name = FieldType.Names.DatePicker, type = DatePickerDataImportExport.class), @XmlElement(name = FieldType.Names.DatePicker, type = LabelDataImportExport.class),
@XmlElement(name = FieldType.Names.DatasetIdentifier, type = DatasetIdentifierDataImportExport.class), @XmlElement(name = FieldType.Names.DatasetIdentifier, type = LabelDataImportExport.class),
@XmlElement(name = FieldType.Names.DataRepositories, type = DataRepositoryDataImportExport.class), @XmlElement(name = FieldType.Names.DataRepositories, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.Currency, type = CurrencyDataImportExport.class), @XmlElement(name = FieldType.Names.Currency, type = LabelDataImportExport.class),
@XmlElement(name = FieldType.Names.BooleanDecision, type = BooleanDecisionDataImportExport.class), @XmlElement(name = FieldType.Names.BooleanDecision, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.Upload, type = UploadDataImportExport.class), @XmlElement(name = FieldType.Names.Upload, type = UploadDataImportExport.class),
@XmlElement(name = FieldType.Names.RadioBox, type = RadioBoxDataImportExport.class), @XmlElement(name = FieldType.Names.RadioBox, type = RadioBoxDataImportExport.class),
@XmlElement(name = FieldType.Names.Wordlist, type = WordListDataImportExport.class), @XmlElement(name = FieldType.Names.Wordlist, type = WordListDataImportExport.class),
@XmlElement(name = FieldType.Names.Autocomplete, type = AutoCompleteDataImportExport.class), @XmlElement(name = FieldType.Names.Autocomplete, type = AutoCompleteDataImportExport.class),
@XmlElement(name = FieldType.Names.InternalDmpDatasets, type = DatasetAutoCompleteDataImportExport.class), @XmlElement(name = FieldType.Names.InternalDmpDatasets, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.InternalDmpDmps, type = DmpAutoCompleteDataImportExport.class), @XmlElement(name = FieldType.Names.InternalDmpDmps, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.InternalDmpResearchers, type = ResearcherAutoCompleteDataImportExport.class), @XmlElement(name = FieldType.Names.InternalDmpResearchers, type = LabelAndMultiplicityDataImportExport.class),
}) })
private BaseFieldDataImportExport data; private BaseFieldDataImportExport data;

View File

@ -1,9 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
@XmlAccessorType(XmlAccessType.FIELD)
public class BooleanDecisionDataImportExport extends BaseFieldDataImportExport {
}

View File

@ -1,13 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
import eu.eudat.commons.enums.FieldType;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
@XmlAccessorType(XmlAccessType.FIELD)
public class CheckBoxDataImportExport extends BaseFieldDataImportExport {
}

View File

@ -1,8 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
@XmlAccessorType(XmlAccessType.FIELD)
public class CurrencyDataImportExport extends BaseFieldDataImportExport {
}

View File

@ -1,19 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
@XmlAccessorType(XmlAccessType.FIELD)
public class DatasetAutoCompleteDataImportExport extends BaseFieldDataImportExport {
@XmlAttribute(name = "multiAutoComplete")
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
}

View File

@ -1,9 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
@XmlAccessorType(XmlAccessType.FIELD)
public class DatasetIdentifierDataImportExport extends BaseFieldDataImportExport {
}

View File

@ -1,9 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
@XmlAccessorType(XmlAccessType.FIELD)
public class DatePickerDataImportExport extends BaseFieldDataImportExport {
}

View File

@ -1,19 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
@XmlAccessorType(XmlAccessType.FIELD)
public class DmpAutoCompleteDataImportExport extends BaseFieldDataImportExport {
@XmlAttribute(name = "multiAutoComplete")
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
}

View File

@ -1,9 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
@XmlAccessorType(XmlAccessType.FIELD)
public class FreeTextDataImportExport extends BaseFieldDataImportExport {
}

View File

@ -1,20 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
@XmlAccessorType(XmlAccessType.FIELD)
public class JournalRepositoryDataImportExport extends BaseFieldDataImportExport {
@XmlAttribute(name = "multiAutoComplete")
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
}

View File

@ -5,7 +5,7 @@ import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlAttribute;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class DataRepositoryDataImportExport extends BaseFieldDataImportExport { public class LabelAndMultiplicityDataImportExport extends BaseFieldDataImportExport {
@XmlAttribute(name = "multiAutoComplete") @XmlAttribute(name = "multiAutoComplete")
private Boolean multiAutoComplete; private Boolean multiAutoComplete;

View File

@ -4,5 +4,6 @@ import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class TagDataImportExport extends BaseFieldDataImportExport { public class LabelDataImportExport extends BaseFieldDataImportExport {
} }

View File

@ -1,20 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
@XmlAccessorType(XmlAccessType.FIELD)
public class LicenseDataImportExport extends BaseFieldDataImportExport {
@XmlAttribute(name = "multiAutoComplete")
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
}

View File

@ -1,24 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
@XmlAccessorType(XmlAccessType.FIELD)
public class OrganizationDataImportExport extends BaseFieldDataImportExport {
@XmlAttribute(name = "multiAutoComplete")
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
}

View File

@ -1,20 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
@XmlAccessorType(XmlAccessType.FIELD)
public class PublicationDataImportExport extends BaseFieldDataImportExport {
@XmlAttribute(name = "multiAutoComplete")
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
}

View File

@ -1,20 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
@XmlAccessorType(XmlAccessType.FIELD)
public class PublicationRepositoryDataImportExport extends BaseFieldDataImportExport {
@XmlAttribute(name = "multiAutoComplete")
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
}

View File

@ -1,20 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
@XmlAccessorType(XmlAccessType.FIELD)
public class RegistryDataImportExport extends BaseFieldDataImportExport {
@XmlAttribute(name = "multiAutoComplete")
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
}

View File

@ -1,19 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
@XmlAccessorType(XmlAccessType.FIELD)
public class ResearcherAutoCompleteDataImportExport extends BaseFieldDataImportExport {
@XmlAttribute(name = "multiAutoComplete")
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
}

View File

@ -1,20 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
@XmlAccessorType(XmlAccessType.FIELD)
public class ResearcherDataImportExport extends BaseFieldDataImportExport {
@XmlAttribute(name = "multiAutoComplete")
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
}

View File

@ -1,9 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
@XmlAccessorType(XmlAccessType.FIELD)
public class RichTextAreaDataImportExport extends BaseFieldDataImportExport {
}

View File

@ -1,19 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
@XmlAccessorType(XmlAccessType.FIELD)
public class ServiceDataImportExport extends BaseFieldDataImportExport {
@XmlAttribute(name = "multiAutoComplete")
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
}

View File

@ -1,19 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
@XmlAccessorType(XmlAccessType.FIELD)
public class TaxonomyDataImportExport extends BaseFieldDataImportExport {
@XmlAttribute(name = "multiAutoComplete")
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
}

View File

@ -1,9 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
@XmlAccessorType(XmlAccessType.FIELD)
public class TextAreaDataImportExport extends BaseFieldDataImportExport {
}

View File

@ -1,8 +0,0 @@
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
@XmlAccessorType(XmlAccessType.FIELD)
public class ValidationDataImportExport extends BaseFieldDataImportExport {
}

View File

@ -1,16 +1,18 @@
package eu.eudat.commons.types.dmp; package eu.eudat.commons.types.dmp;
import java.util.UUID;
public class DmpBlueprintValueEntity { public class DmpBlueprintValueEntity {
private String fieldId; private UUID fieldId;
private String value; private String value;
public String getFieldId() { public UUID getFieldId() {
return fieldId; return fieldId;
} }
public void setFieldId(String fieldId) { public void setFieldId(UUID fieldId) {
this.fieldId = fieldId; this.fieldId = fieldId;
} }

View File

@ -1,20 +1,22 @@
package eu.eudat.commons.types.dmp; package eu.eudat.commons.types.dmp;
import java.util.UUID;
public class DmpContactEntity { public class DmpContactEntity {
String userId; private UUID userId;
String firstName; private String firstName;
String lastName; private String lastName;
String email; private String email;
public String getUserId() { public UUID getUserId() {
return userId; return userId;
} }
public void setUserId(String userId) { public void setUserId(UUID userId) {
this.userId = userId; this.userId = userId;
} }

View File

@ -0,0 +1,15 @@
package eu.eudat.commons.types.dmpreference;
import java.util.UUID;
public class DmpReferenceDataEntity {
private UUID blueprintFieldId;
public UUID getBlueprintFieldId() {
return blueprintFieldId;
}
public void setBlueprintFieldId(UUID blueprintFieldId) {
this.blueprintFieldId = blueprintFieldId;
}
}

View File

@ -0,0 +1,65 @@
package eu.eudat.commons.types.prefilling;
import eu.eudat.commons.JsonHandlingService;
import java.util.Map;
public class PrefillingEntity {
private String pid;
private String name;
private Map<String, Object> data;
private String key;
private String tag;
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, Object> getData() {
return data;
}
public void setData(Map<String, Object> data) {
this.data = data;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public static PrefillingEntity build(Map<String, String> fetchedData, JsonHandlingService jsonHandlingService){
PrefillingEntity m = new PrefillingEntity();
m.setPid(fetchedData.getOrDefault("pid", null));
m.setName(fetchedData.getOrDefault("name", null));
m.setKey(fetchedData.getOrDefault("key", null));
m.setTag(fetchedData.getOrDefault("tag", null));
m.setData(jsonHandlingService.fromJsonSafe(Map.class,fetchedData.getOrDefault("data", null)));
return m;
}
}

View File

@ -0,0 +1,24 @@
package eu.eudat.commons.types.usercredential;
import java.util.List;
public class UserCredentialDataEntity {
private List<String> externalProviderNames;
private String email;
public List<String> getExternalProviderNames() {
return externalProviderNames;
}
public void setExternalProviderNames(List<String> externalProviderNames) {
this.externalProviderNames = externalProviderNames;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}

View File

@ -1,119 +0,0 @@
package eu.eudat.commons.validation;
import eu.eudat.commons.validation.specification.*;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import gr.cite.tools.exception.MyValidationException;
import org.springframework.validation.BeanPropertyBindingResult;
import org.springframework.validation.Errors;
import org.springframework.validation.FieldError;
import org.springframework.validation.ValidationUtils;
import java.text.MessageFormat;
import java.util.*;
public abstract class AbstractValidator<T> implements Validator {
private BeanPropertyBindingResult bindingResult;
protected abstract Class<T> modelClass();
protected abstract List<Specification> specifications(T item);
@Override
public boolean supports(Class clazz) {
return clazz == null ? false : this.modelClass().equals(clazz);
}
@Override
public void validate(Object obj, Errors e) {
if (obj == null) return;
T item = this.modelClass().cast(obj);
List<Specification> specifications = this.specifications(item);
if (specifications == null) return;;
List<PropertySpecification> propertySpecifications = specifications.stream().filter(x-> x instanceof PropertySpecification).map(x-> (PropertySpecification)x).toList();
for (PropertySpecification propertySpecification : propertySpecifications){
if ((propertySpecification.getPrecondition() == null || propertySpecification.getPrecondition().get()) &&
(propertySpecification.getSpecification() == null || !propertySpecification.getSpecification().get())
){
e.rejectValue(propertySpecification.getErrorKey(), propertySpecification.getErrorCode(), propertySpecification.getErrorMessage());
}
}
List<NavigationReferenceSpecification> navigationReferenceSpecifications = specifications.stream().filter(x-> x instanceof NavigationReferenceSpecification).map(x-> (NavigationReferenceSpecification)x).toList();
for (NavigationReferenceSpecification navigationReferenceSpecification : navigationReferenceSpecifications){
if (navigationReferenceSpecification.getReference() != null && (navigationReferenceSpecification.getPrecondition() == null || navigationReferenceSpecification.getPrecondition().get())){
try {
e.pushNestedPath(navigationReferenceSpecification.getKey());
ValidationUtils.invokeValidator(navigationReferenceSpecification.getValidator().get(), navigationReferenceSpecification.getReference(), e);
} finally {
e.popNestedPath();
}
}
}
List<NavigationDetailsSpecification> navigationDetailsSpecifications = specifications.stream().filter(x-> x instanceof NavigationDetailsSpecification).map(x-> (NavigationDetailsSpecification)x).toList();
for (NavigationDetailsSpecification navigationDetailsSpecification : navigationDetailsSpecifications){
if (navigationDetailsSpecification.getDetails() != null && (navigationDetailsSpecification.getPrecondition() == null || navigationDetailsSpecification.getPrecondition().get())){
for (int i = 0; i < navigationDetailsSpecification.getDetails().size(); i++) {
try {
e.pushNestedPath(MessageFormat.format("{0}[{1}]", navigationDetailsSpecification.getKey(), i));
ValidationUtils.invokeValidator(navigationDetailsSpecification.getValidator().get(), navigationDetailsSpecification.getDetails().get(i), e);
} finally {
e.popNestedPath();
}
}
}
}
}
@Override
public void validate(Object target){
this.bindingResult = new BeanPropertyBindingResult(target, target.getClass().getName());
if (target instanceof Collection<?>) {
((Collection<?>) target).forEach(x -> this.validate(x, this.bindingResult));
} else {
this.validate(target, this.bindingResult);
}
}
@Override
public ValidationResult result() {
ValidationResult validationResult = new ValidationResult();
if (this.bindingResult != null && bindingResult.hasErrors()){
for (FieldError fieldError : bindingResult.getFieldErrors()){
validationResult.add(new ValidationFailure(fieldError.getField(), fieldError.getDefaultMessage()));
}
}
return validationResult;
}
protected List<Map.Entry<String, List<String>>> flattenValidationResult() {
ValidationResult result = result();
List<Map.Entry<String, List<String>>> errorsMap = new ArrayList<>();
for (ValidationFailure fieldError : result.getErrors()){
Map.Entry<String, List<String>> entry = errorsMap.stream().filter(x-> Objects.equals(x.getKey(), fieldError.getErrorKey())).findFirst().orElse(null);
if (entry == null) {
entry = new AbstractMap.SimpleEntry<>(fieldError.getErrorKey(), new ArrayList<>());
errorsMap.add(entry);
}
entry.getValue().add(fieldError.getErrorMessage());
}
return errorsMap;
}
protected PropertySpecificationBuilder spec() {
return new PropertySpecificationBuilder();
}
protected NavigationReferenceSpecificationBuilder refSpec() {
return new NavigationReferenceSpecificationBuilder();
}
protected NavigationDetailsSpecificationBuilder navSpec()
{
return new NavigationDetailsSpecificationBuilder();
}
}

View File

@ -3,6 +3,10 @@ package eu.eudat.commons.validation;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
import gr.cite.tools.exception.MyValidationException; import gr.cite.tools.exception.MyValidationException;
import gr.cite.tools.validation.AbstractValidator;
import gr.cite.tools.validation.ValidationResult;
import org.apache.commons.validator.routines.EmailValidator;
import java.util.*; import java.util.*;
public abstract class BaseValidator<T> extends AbstractValidator<T> { public abstract class BaseValidator<T> extends AbstractValidator<T> {
@ -27,6 +31,9 @@ public abstract class BaseValidator<T> extends AbstractValidator<T> {
protected Boolean isValidGuid(UUID guid) { protected Boolean isValidGuid(UUID guid) {
return this.conventionService.isValidGuid(guid); return this.conventionService.isValidGuid(guid);
} }
protected Boolean isValidEmail(String value) {
return EmailValidator.getInstance().isValid(value);
}
protected Boolean isValidHash(String hash) { protected Boolean isValidHash(String hash) {
return this.conventionService.isValidHash(hash); return this.conventionService.isValidHash(hash);
@ -35,6 +42,9 @@ public abstract class BaseValidator<T> extends AbstractValidator<T> {
protected Boolean isEmpty(String value) { protected Boolean isEmpty(String value) {
return this.conventionService.isNullOrEmpty(value); return this.conventionService.isNullOrEmpty(value);
} }
protected Boolean isListNullOrEmpty(List<?> value) {
return this.conventionService.isListNullOrEmpty(value);
}
protected Boolean isNull(Object value) { protected Boolean isNull(Object value) {
return value == null; return value == null;
} }

View File

@ -1,24 +0,0 @@
package eu.eudat.commons.validation;
public class ValidationFailure {
public String errorKey;
public String errorMessage;
public ValidationFailure(String errorMessage) {
this.errorMessage = errorMessage;
}
public ValidationFailure(String errorKey, String errorMessage) {
this.errorKey = errorKey;
this.errorMessage = errorMessage;
}
public String getErrorKey() {
return errorKey;
}
public String getErrorMessage() {
return errorMessage;
}
}

View File

@ -1,12 +0,0 @@
package eu.eudat.commons.validation;
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Inherited
public @interface ValidationFilterAnnotation {
public String validator();
public String argumentName();
}

View File

@ -1,34 +0,0 @@
package eu.eudat.commons.validation;
import java.util.ArrayList;
import java.util.List;
public class ValidationResult {
private final List<ValidationFailure> errors;
public ValidationResult() {
this.errors = new ArrayList<>();
}
public Boolean isValid() {
return this.errors.isEmpty();
}
public ValidationResult add(ValidationFailure failure) {
if (failure != null) {
errors.add(failure);
}
return this;
}
public ValidationResult addAll(List<ValidationFailure> failures) {
if (failures != null) {
errors.addAll(failures);
}
return this;
}
public List<ValidationFailure> getErrors() {
return errors;
}
}

View File

@ -1,9 +0,0 @@
package eu.eudat.commons.validation;
import org.springframework.validation.Errors;
public interface Validator extends org.springframework.validation.Validator {
void validate(Object target);
void validateForce(Object target);
ValidationResult result();
}

View File

@ -1,33 +0,0 @@
package eu.eudat.commons.validation;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
@Service
public class ValidatorFactory {
private final ApplicationContext applicationContext;
public ValidatorFactory(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
public <T extends Validator> T validator(Class<T> type){
T item = this.applicationContext.getBean(type);
if (item == null || !(item instanceof Validator)) throw new RuntimeException("unrecognized validator " + type.getSimpleName());
return item;
}
public Validator validator(String validtor){
Validator item = this.applicationContext.getBean(validtor, Validator.class);
if (item == null || !(item instanceof Validator)) throw new RuntimeException("unrecognized validator " + validtor);
return item;
}
}

View File

@ -1,16 +0,0 @@
package eu.eudat.commons.validation.specification;
import eu.eudat.commons.validation.Validator;
import java.util.List;
import java.util.function.Supplier;
public interface NavigationDetailsSpecification extends Specification {
Supplier<Boolean> getPrecondition();
String getKey();
List<?> getDetails();
Supplier<Validator> getValidator();
}

View File

@ -1,53 +0,0 @@
package eu.eudat.commons.validation.specification;
import eu.eudat.commons.validation.Validator;
import java.util.List;
import java.util.function.Supplier;
public class NavigationDetailsSpecificationBuilder implements NavigationDetailsSpecification {
private Supplier<Boolean> precondition;
private String key;
private List<?> details;
private Supplier<Validator> validator;
public NavigationDetailsSpecificationBuilder iff(Supplier<Boolean> value){
this.precondition = value;
return this;
}
public NavigationDetailsSpecificationBuilder on(String value){
this.key = value;
return this;
}
public NavigationDetailsSpecificationBuilder over(List<?> value){
this.details = value;
return this;
}
public NavigationDetailsSpecificationBuilder using(Supplier<Validator> value){
this.validator = value;
return this;
}
@Override
public Supplier<Boolean> getPrecondition() {
return precondition;
}
@Override
public String getKey() {
return key;
}
@Override
public List<?> getDetails() {
return details;
}
@Override
public Supplier<Validator> getValidator() {
return validator;
}
}

View File

@ -1,15 +0,0 @@
package eu.eudat.commons.validation.specification;
import eu.eudat.commons.validation.Validator;
import java.util.function.Supplier;
public interface NavigationReferenceSpecification extends Specification{
Supplier<Boolean> getPrecondition();
String getKey();
Object getReference();
Supplier<Validator> getValidator();
}

View File

@ -1,53 +0,0 @@
package eu.eudat.commons.validation.specification;
import eu.eudat.commons.validation.Validator;
import java.util.function.Supplier;
public class NavigationReferenceSpecificationBuilder implements NavigationReferenceSpecification {
private Supplier<Boolean> precondition;
private String key;
private Object reference;
private Supplier<Validator> validator;
public NavigationReferenceSpecificationBuilder iff(Supplier<Boolean> value){
this.precondition = value;
return this;
}
public NavigationReferenceSpecificationBuilder on(String value){
this.key = value;
return this;
}
public NavigationReferenceSpecificationBuilder over(Object value){
this.reference = value;
return this;
}
public NavigationReferenceSpecificationBuilder using(Supplier<Validator> value){
this.validator = value;
return this;
}
@Override
public Supplier<Boolean> getPrecondition() {
return precondition;
}
@Override
public String getKey() {
return key;
}
@Override
public Object getReference() {
return reference;
}
@Override
public Supplier<Validator> getValidator() {
return validator;
}
}

View File

@ -1,15 +0,0 @@
package eu.eudat.commons.validation.specification;
import java.util.function.Supplier;
public interface PropertySpecification extends Specification {
Supplier<Boolean> getPrecondition();
Supplier<Boolean> getSpecification();
String getErrorKey();
String getErrorMessage();
String getErrorCode();
}

View File

@ -1,62 +0,0 @@
package eu.eudat.commons.validation.specification;
import java.util.function.Supplier;
public class PropertySpecificationBuilder implements PropertySpecification{
private Supplier<Boolean> precondition;
private Supplier<Boolean> specification;
private String errorKey;
private String errorMessage;
private String errorCode = "validationerror";
public PropertySpecificationBuilder iff(Supplier<Boolean> value){
this.precondition = value;
return this;
}
public PropertySpecificationBuilder must(Supplier<Boolean> value){
this.specification = value;
return this;
}
public PropertySpecificationBuilder failOn(String value){
this.errorKey = value;
return this;
}
public PropertySpecificationBuilder failWith(String value){
this.errorMessage = value;
return this;
}
public PropertySpecificationBuilder failWithCode(String value){
this.errorCode = value;
return this;
}
@Override
public Supplier<Boolean> getPrecondition() {
return precondition;
}
@Override
public Supplier<Boolean> getSpecification() {
return specification;
}
@Override
public String getErrorKey() {
return errorKey;
}
@Override
public String getErrorMessage() {
return errorMessage;
}
@Override
public String getErrorCode() {
return errorCode;
}
}

View File

@ -1,6 +0,0 @@
package eu.eudat.commons.validation.specification;
import java.util.function.Supplier;
public interface Specification {
}

View File

@ -0,0 +1,20 @@
package eu.eudat.configurations.locale;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableConfigurationProperties(LocaleProperties.class)
public class LocaleConfiguration {
private final LocaleProperties properties;
@Autowired
public LocaleConfiguration(LocaleProperties properties) {
this.properties = properties;
}
public LocaleProperties getProperties() {
return properties;
}
}

View File

@ -0,0 +1,34 @@
package eu.eudat.configurations.locale;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "locale")
public class LocaleProperties {
private String timezone;
private String language;
private String culture;
public String getTimezone() {
return timezone;
}
public void setTimezone(String timezone) {
this.timezone = timezone;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public String getCulture() {
return culture;
}
public void setCulture(String culture) {
this.culture = culture;
}
}

View File

@ -18,10 +18,10 @@ public class DescriptionReferenceEntity extends TenantScopedBaseEntity {
public static final String _id = "id"; public static final String _id = "id";
// @Column(name = "data") @Column(name = "data")
// private String data; private String data;
//
// public static final String _data = "data"; public static final String _data = "data";
@Column(name = "description_id", columnDefinition = "uuid", nullable = false) @Column(name = "description_id", columnDefinition = "uuid", nullable = false)
private UUID descriptionId; private UUID descriptionId;
@ -97,4 +97,11 @@ public class DescriptionReferenceEntity extends TenantScopedBaseEntity {
this.isActive = isActive; this.isActive = isActive;
} }
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
} }

View File

@ -22,6 +22,10 @@ public class UserCredentialEntity extends TenantScopedBaseEntity {
private UUID userId; private UUID userId;
public final static String _userId = "userId"; public final static String _userId = "userId";
@Column(name = "data", nullable = true)
private String data;
public final static String _data = "data";
@Column(name = "\"external_id\"", length = UserCredentialEntity._externalIdLength, nullable = false) @Column(name = "\"external_id\"", length = UserCredentialEntity._externalIdLength, nullable = false)
private String externalId; private String externalId;
public final static String _externalId = "externalId"; public final static String _externalId = "externalId";
@ -63,4 +67,12 @@ public class UserCredentialEntity extends TenantScopedBaseEntity {
public void setCreatedAt(Instant createdAt) { public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt; this.createdAt = createdAt;
} }
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
} }

View File

@ -1,100 +0,0 @@
package eu.eudat.data.old;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.old.queryableentity.DataEntity;
import jakarta.persistence.*;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@Entity
@Table(name = "\"EmailConfirmation\"")
public class EmailConfirmation implements DataEntity<EmailConfirmation, UUID> {
@Id
@GeneratedValue
@Column(name = "\"ID\"", updatable = false, nullable = false)
private UUID id;
@Column(name = "\"email\"", nullable = false)
private String email;
@Column(name = "\"isConfirmed\"", nullable = false)
private boolean isConfirmed;
@Column(name = "\"token\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID token;
@Column(name = "\"userId\"", nullable = false)
private UUID userId;
@Column(name = "\"data\"")
private String data;
@Column(name = "\"expiresAt\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date expiresAt;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public boolean getIsConfirmed() {
return isConfirmed;
}
public void setIsConfirmed(boolean confirmed) {
isConfirmed = confirmed;
}
public UUID getToken() {
return token;
}
public void setToken(UUID token) {
this.token = token;
}
public UUID getUserId() {
return userId;
}
public void setUserId(UUID userId) {
this.userId = userId;
}
public Date getExpiresAt() {
return expiresAt;
}
public void setExpiresAt(Date expiresAt) {
this.expiresAt = expiresAt;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
@Override
public void update(EmailConfirmation entity) {
}
@Override
public UUID getKeys() {
return null;
}
@Override
public EmailConfirmation buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
return null;
}
}

View File

@ -1,113 +0,0 @@
package eu.eudat.data.old;
import eu.eudat.data.UserEntity;
import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.data.old.queryableentity.DataEntity;
import jakarta.persistence.*;
import java.util.List;
import java.util.UUID;
@Entity
@Table(name = "\"Invitation\"")
public class Invitation implements DataEntity<Invitation, UUID> {
@Id
@GeneratedValue
@Column(name = "\"Id\"", updatable = false, nullable = false)
private UUID id;
@Column(name = "\"InvitationEmail\"", nullable = false)
private String invitationEmail;
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"CreationUser\"", nullable = false)
private UserEntity user;
// @OneToOne(fetch = FetchType.EAGER)
// @JoinColumn(name = "\"Dmp\"", nullable = false)
// private DMP dmp;
@Column(name = "\"Token\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID token;
@Column(name = "\"AcceptedInvitation\"", nullable = false)
private boolean acceptedInvitation;
@Column(name = "\"Properties\"", nullable = true)
private String properties;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getInvitationEmail() {
return invitationEmail;
}
public void setInvitationEmail(String invitationEmail) {
this.invitationEmail = invitationEmail;
}
public UserEntity getUser() {
return user;
}
public void setUser(UserEntity user) {
this.user = user;
}
// public DMP getDmp() {
// return dmp;
// }
//
// public void setDmp(DMP dmp) {
// this.dmp = dmp;
// }
public UUID getToken() {
return token;
}
public void setToken(UUID token) {
this.token = token;
}
public String getProperties() {
return properties;
}
public void setProperties(String properties) {
this.properties = properties;
}
public boolean getAcceptedInvitation() {
return acceptedInvitation;
}
public void setAcceptedInvitation(boolean acceptedInvitation) {
this.acceptedInvitation = acceptedInvitation;
}
@Override
public void update(Invitation entity) {
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public Invitation buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
}

View File

@ -68,10 +68,6 @@ public class DmpElasticEntity {
private List<NestedCollaboratorElasticEntity> collaborators; private List<NestedCollaboratorElasticEntity> collaborators;
public final static String _collaborators = "collaborators"; public final static String _collaborators = "collaborators";
@Field(value = DmpElasticEntity._descriptionTemplates, type = FieldType.Nested)
private List<NestedDescriptionTemplateElasticEntity> descriptionTemplates;
public final static String _descriptionTemplates = "descriptionTemplates";
@Field(value = DmpElasticEntity._descriptions, type = FieldType.Nested) @Field(value = DmpElasticEntity._descriptions, type = FieldType.Nested)
private List<NestedDescriptionElasticEntity> descriptions; private List<NestedDescriptionElasticEntity> descriptions;
public final static String _descriptions = "descriptions"; public final static String _descriptions = "descriptions";
@ -176,14 +172,6 @@ public class DmpElasticEntity {
this.collaborators = collaborators; this.collaborators = collaborators;
} }
public List<NestedDescriptionTemplateElasticEntity> getDescriptionTemplates() {
return descriptionTemplates;
}
public void setDescriptionTemplates(List<NestedDescriptionTemplateElasticEntity> descriptionTemplates) {
this.descriptionTemplates = descriptionTemplates;
}
public List<NestedDescriptionElasticEntity> getDescriptions() { public List<NestedDescriptionElasticEntity> getDescriptions() {
return descriptions; return descriptions;
} }

View File

@ -1,6 +1,7 @@
package eu.eudat.elastic.data.nested; package eu.eudat.elastic.data.nested;
import eu.eudat.commons.enums.DescriptionStatus; import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.elastic.data.DescriptionElasticEntity;
import gr.cite.tools.elastic.ElasticConstants; import gr.cite.tools.elastic.ElasticConstants;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*; import org.springframework.data.elasticsearch.annotations.*;
@ -46,6 +47,10 @@ public class NestedDescriptionElasticEntity {
private List<NestedReferenceElasticEntity> references; private List<NestedReferenceElasticEntity> references;
public final static String _references = "references"; public final static String _references = "references";
@Field(value = DescriptionElasticEntity._descriptionTemplate, type = FieldType.Object)
private NestedDescriptionTemplateElasticEntity descriptionTemplate;
public final static String _descriptionTemplate = "descriptionTemplate";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -109,4 +114,12 @@ public class NestedDescriptionElasticEntity {
public void setReferences(List<NestedReferenceElasticEntity> references) { public void setReferences(List<NestedReferenceElasticEntity> references) {
this.references = references; this.references = references;
} }
public NestedDescriptionTemplateElasticEntity getDescriptionTemplate() {
return descriptionTemplate;
}
public void setDescriptionTemplate(NestedDescriptionTemplateElasticEntity descriptionTemplate) {
this.descriptionTemplate = descriptionTemplate;
}
} }

View File

@ -42,10 +42,9 @@ public class DmpElasticBuilder extends BaseElasticBuilder<DmpElasticEntity, DmpE
return new ArrayList<>(); return new ArrayList<>();
Map<UUID, List<NestedReferenceElasticEntity>> referenceElasticEntityMap = this.collectDmpReferences(data); Map<UUID, List<NestedReferenceElasticEntity>> referenceElasticEntityMap = this.collectDmpReferences(data);
Map<UUID, List<NestedDescriptionElasticEntity>> dmpElasticEntityMap = this.collectDescriptions(data); Map<UUID, List<NestedDescriptionElasticEntity>> descriptionElasticEntityMap = this.collectDescriptions(data);
Map<UUID, List<NestedCollaboratorElasticEntity>> collaboratorElasticEntityMap = this.collectCollaborators(data); Map<UUID, List<NestedCollaboratorElasticEntity>> collaboratorElasticEntityMap = this.collectCollaborators(data);
Map<UUID, List<NestedDoiElasticEntity>> doiElasticEntityMap = this.collectDois(data); Map<UUID, List<NestedDoiElasticEntity>> doiElasticEntityMap = this.collectDois(data);
Map<UUID, List<NestedDescriptionTemplateElasticEntity>> descriptionTemplateElasticEntityMap = this.collectDescriptionTemplates(data);
List<DmpElasticEntity> models = new ArrayList<>(); List<DmpElasticEntity> models = new ArrayList<>();
for (DmpEntity d : data) { for (DmpEntity d : data) {
@ -64,10 +63,9 @@ public class DmpElasticBuilder extends BaseElasticBuilder<DmpElasticEntity, DmpE
m.setFinalizedAt(Date.from(d.getFinalizedAt())); m.setFinalizedAt(Date.from(d.getFinalizedAt()));
} }
if (referenceElasticEntityMap != null) m.setReferences(referenceElasticEntityMap.getOrDefault(d.getId(), null)); if (referenceElasticEntityMap != null) m.setReferences(referenceElasticEntityMap.getOrDefault(d.getId(), null));
if (dmpElasticEntityMap != null) m.setDescriptions(dmpElasticEntityMap.getOrDefault(d.getId(), null)); if (descriptionElasticEntityMap != null) m.setDescriptions(descriptionElasticEntityMap.getOrDefault(d.getId(), null));
if (collaboratorElasticEntityMap != null) m.setCollaborators(collaboratorElasticEntityMap.getOrDefault(d.getId(), null)); if (collaboratorElasticEntityMap != null) m.setCollaborators(collaboratorElasticEntityMap.getOrDefault(d.getId(), null));
if (doiElasticEntityMap != null) m.setDois(doiElasticEntityMap.getOrDefault(d.getId(), null)); if (doiElasticEntityMap != null) m.setDois(doiElasticEntityMap.getOrDefault(d.getId(), null));
if (descriptionTemplateElasticEntityMap != null) m.setDescriptionTemplates(descriptionTemplateElasticEntityMap.getOrDefault(d.getId(), null));
models.add(m); models.add(m);
} }
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
@ -94,26 +92,6 @@ public class DmpElasticBuilder extends BaseElasticBuilder<DmpElasticEntity, DmpE
return itemMap; return itemMap;
} }
private Map<UUID, List<NestedDescriptionTemplateElasticEntity>> collectDescriptionTemplates(List<DmpEntity> data) throws MyApplicationException {
if (data.isEmpty()) return null;
this.logger.debug("checking related - {}", DmpReference.class.getSimpleName());
DmpDescriptionTemplateQuery associationQuery = this.queryFactory.query(DmpDescriptionTemplateQuery.class).dmpIds(data.stream().map(DmpEntity::getId).collect(Collectors.toList())).isActive(IsActive.Active);
List<DmpDescriptionTemplateEntity> associationEntities = associationQuery.collect();
DescriptionTemplateQuery query = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).groupIds(associationEntities.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplateGroupId).distinct().collect(Collectors.toList()));
Map<UUID, NestedDescriptionTemplateElasticEntity> itemMapById = this.builderFactory.builder(NestedDescriptionTemplateElasticBuilder.class).asForeignKey(query, NestedDescriptionTemplateElasticEntity::getId);
Map<UUID, List<NestedDescriptionTemplateElasticEntity>> itemMap = new HashMap<>();
for (DmpDescriptionTemplateEntity associationEntity : associationEntities){
if (!itemMap.containsKey(associationEntity.getDmpId())) itemMap.put(associationEntity.getDmpId(), new ArrayList<>());
NestedDescriptionTemplateElasticEntity item = itemMapById.getOrDefault(associationEntity.getDescriptionTemplateGroupId(), null);
if (item != null) itemMap.get(associationEntity.getDmpId()).add(item);
}
return itemMap;
}
private Map<UUID, List<NestedDescriptionElasticEntity>> collectDescriptions(List<DmpEntity> data) throws MyApplicationException { private Map<UUID, List<NestedDescriptionElasticEntity>> collectDescriptions(List<DmpEntity> data) throws MyApplicationException {
if (data.isEmpty()) if (data.isEmpty())
return null; return null;

View File

@ -6,15 +6,14 @@ import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.DescriptionReferenceEntity; import eu.eudat.data.DescriptionReferenceEntity;
import eu.eudat.data.DescriptionTagEntity; import eu.eudat.data.DescriptionTagEntity;
import eu.eudat.elastic.data.nested.NestedDescriptionElasticEntity; import eu.eudat.elastic.data.nested.NestedDescriptionElasticEntity;
import eu.eudat.elastic.data.nested.NestedDescriptionTemplateElasticEntity;
import eu.eudat.elastic.data.nested.NestedReferenceElasticEntity; import eu.eudat.elastic.data.nested.NestedReferenceElasticEntity;
import eu.eudat.elastic.data.nested.NestedTagElasticEntity; import eu.eudat.elastic.data.nested.NestedTagElasticEntity;
import eu.eudat.elastic.elasticbuilder.BaseElasticBuilder; import eu.eudat.elastic.elasticbuilder.BaseElasticBuilder;
import eu.eudat.model.DescriptionReference; import eu.eudat.model.DescriptionReference;
import eu.eudat.model.DescriptionTag; import eu.eudat.model.DescriptionTag;
import eu.eudat.query.DescriptionReferenceQuery; import eu.eudat.model.DescriptionTemplate;
import eu.eudat.query.DescriptionTagQuery; import eu.eudat.query.*;
import eu.eudat.query.ReferenceQuery;
import eu.eudat.query.TagQuery;
import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
@ -50,6 +49,7 @@ public class NestedDescriptionElasticBuilder extends BaseElasticBuilder<NestedDe
Map<UUID, List<NestedReferenceElasticEntity>> referenceElasticEntityMap = this.collectDescriptionReferences(data); Map<UUID, List<NestedReferenceElasticEntity>> referenceElasticEntityMap = this.collectDescriptionReferences(data);
Map<UUID, List<NestedTagElasticEntity>> tagElasticEntityMap = this.collectDescriptionTags(data); Map<UUID, List<NestedTagElasticEntity>> tagElasticEntityMap = this.collectDescriptionTags(data);
Map<UUID, NestedDescriptionTemplateElasticEntity> descriptionTemplateElasticEntityMap = this.collectDescriptionTemplates(data);
List<NestedDescriptionElasticEntity> models = new ArrayList<>(); List<NestedDescriptionElasticEntity> models = new ArrayList<>();
for (DescriptionEntity d : data) { for (DescriptionEntity d : data) {
@ -109,4 +109,16 @@ public class NestedDescriptionElasticBuilder extends BaseElasticBuilder<NestedDe
return itemMap; return itemMap;
} }
private Map<UUID, NestedDescriptionTemplateElasticEntity> collectDescriptionTemplates(List<DescriptionEntity> data) throws MyApplicationException {
if (data.isEmpty())
return null;
this.logger.debug("checking related - {}", DescriptionTemplate.class.getSimpleName());
Map<UUID, NestedDescriptionTemplateElasticEntity> itemMap;
DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList()));
itemMap = this.builderFactory.builder(NestedDescriptionTemplateElasticBuilder.class).asForeignKey(q, NestedDescriptionTemplateElasticEntity::getId);
return itemMap;
}
} }

View File

@ -1,5 +1,6 @@
package eu.eudat.elastic.query; package eu.eudat.elastic.query;
import co.elastic.clients.elasticsearch._types.query_dsl.Query; import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission; import eu.eudat.authorization.Permission;
import eu.eudat.commons.enums.DescriptionStatus; import eu.eudat.commons.enums.DescriptionStatus;
@ -196,9 +197,26 @@ public class DescriptionElasticQuery extends ElasticQuery<DescriptionElasticEnti
if (!like.startsWith("*")) like = "*" + like; if (!like.startsWith("*")) like = "*" + like;
if (!like.endsWith("*")) like = like + "*"; if (!like.endsWith("*")) like = like + "*";
ElasticFields elasticFields = this.elasticFieldsOf(); ElasticFields elasticFields = this.elasticFieldsOf();
elasticFields.add(DescriptionElasticEntity._label); elasticFields.add("*", null, true);
elasticFields.add(DescriptionElasticEntity._description);
predicates.add(this.like(elasticFields, List.of(like))._toQuery()); predicates.add(this.or(
this.like(elasticFields, List.of(like))._toQuery(),
QueryBuilders.nested().path(DescriptionElasticEntity._tags).query(
this.like(elasticFields, List.of(like))._toQuery()
).build()._toQuery(),
QueryBuilders.nested().path(DescriptionElasticEntity._references).query(
this.like(elasticFields, List.of(like))._toQuery()
).build()._toQuery(),
QueryBuilders.nested().path(DescriptionElasticEntity._dmp + "." + NestedDmpElasticEntity._references).query(
this.like(elasticFields, List.of(like))._toQuery()
).build()._toQuery(),
QueryBuilders.nested().path(DescriptionElasticEntity._dmp + "." + NestedDmpElasticEntity._collaborators).query(
this.like(elasticFields, List.of(like))._toQuery()
).build()._toQuery(),
QueryBuilders.nested().path(DescriptionElasticEntity._dmp + "." + NestedDmpElasticEntity._dois).query(
this.like(elasticFields, List.of(like))._toQuery()
).build()._toQuery()
)._toQuery());
} }
if (ids != null) { if (ids != null) {
predicates.add(this.containsUUID(this.elasticFieldOf(DescriptionElasticEntity._id), ids)._toQuery()); predicates.add(this.containsUUID(this.elasticFieldOf(DescriptionElasticEntity._id), ids)._toQuery());

View File

@ -1,5 +1,6 @@
package eu.eudat.elastic.query; package eu.eudat.elastic.query;
import co.elastic.clients.elasticsearch._types.query_dsl.Query; import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission; import eu.eudat.authorization.Permission;
import eu.eudat.commons.enums.DmpAccessType; import eu.eudat.commons.enums.DmpAccessType;
@ -9,7 +10,9 @@ import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.configurations.elastic.AppElasticProperties; import eu.eudat.configurations.elastic.AppElasticProperties;
import eu.eudat.data.DmpEntity; import eu.eudat.data.DmpEntity;
import eu.eudat.elastic.data.DescriptionElasticEntity;
import eu.eudat.elastic.data.DmpElasticEntity; import eu.eudat.elastic.data.DmpElasticEntity;
import eu.eudat.elastic.data.nested.NestedDescriptionElasticEntity;
import eu.eudat.query.DmpQuery; import eu.eudat.query.DmpQuery;
import eu.eudat.query.utils.QueryUtilsService; import eu.eudat.query.utils.QueryUtilsService;
import eu.eudat.service.elastic.ElasticService; import eu.eudat.service.elastic.ElasticService;
@ -215,12 +218,31 @@ public class DmpElasticQuery extends ElasticQuery<DmpElasticEntity, UUID> {
List<Query> predicates = new ArrayList<>(); List<Query> predicates = new ArrayList<>();
if (like != null && !like.isBlank()) { if (like != null && !like.isBlank()) {
if (!like.startsWith("*")) like = "*" + like; if (!like.startsWith("*")) like = "*" + like;
if (!like.endsWith("*")) like = like + "*"; if (!like.endsWith("*")) like = like + "*";
ElasticFields elasticFields = this.elasticFieldsOf(); ElasticFields elasticFields = this.elasticFieldsOf();
elasticFields.add(DmpElasticEntity._label); elasticFields.add("*", null, true);
elasticFields.add(DmpElasticEntity._descriptions);
predicates.add(this.like(elasticFields, List.of(like))._toQuery()); predicates.add(this.or(
this.like(elasticFields, List.of(like))._toQuery(),
QueryBuilders.nested().path(DmpElasticEntity._collaborators).query(
this.like(elasticFields, List.of(like))._toQuery()
).build()._toQuery(),
QueryBuilders.nested().path(DmpElasticEntity._references).query(
this.like(elasticFields, List.of(like))._toQuery()
).build()._toQuery(),
QueryBuilders.nested().path(DmpElasticEntity._descriptions + "." + NestedDescriptionElasticEntity._references).query(
this.like(elasticFields, List.of(like))._toQuery()
).build()._toQuery(),
QueryBuilders.nested().path(DmpElasticEntity._descriptions + "." + NestedDescriptionElasticEntity._tags).query(
this.like(elasticFields, List.of(like))._toQuery()
).build()._toQuery(),
QueryBuilders.nested().path(DmpElasticEntity._descriptions).query(
this.like(elasticFields, List.of(like))._toQuery()
).build()._toQuery()
)._toQuery());
} }
if (ids != null) { if (ids != null) {
predicates.add(this.containsUUID(this.elasticFieldOf(DmpElasticEntity._id), ids)._toQuery()); predicates.add(this.containsUUID(this.elasticFieldOf(DmpElasticEntity._id), ids)._toQuery());
@ -265,7 +287,6 @@ public class DmpElasticQuery extends ElasticQuery<DmpElasticEntity, UUID> {
if (columns.contains(DmpElasticEntity._finalizedAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._finalizedAt), Date.class)); if (columns.contains(DmpElasticEntity._finalizedAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._finalizedAt), Date.class));
mocDoc.setCollaborators(this.convertNested(rawData, columns, this.queryFactory.query(NestedCollaboratorElasticQuery.class), DmpElasticEntity._collaborators, null)); mocDoc.setCollaborators(this.convertNested(rawData, columns, this.queryFactory.query(NestedCollaboratorElasticQuery.class), DmpElasticEntity._collaborators, null));
mocDoc.setReferences(this.convertNested(rawData, columns, this.queryFactory.query(NestedReferenceElasticQuery.class), DmpElasticEntity._references, null)); mocDoc.setReferences(this.convertNested(rawData, columns, this.queryFactory.query(NestedReferenceElasticQuery.class), DmpElasticEntity._references, null));
mocDoc.setDescriptionTemplates(this.convertNested(rawData, columns, this.queryFactory.query(NestedDescriptionTemplateElasticQuery.class), DmpElasticEntity._descriptionTemplates, null));
mocDoc.setDescriptions(this.convertNested(rawData, columns, this.queryFactory.query(NestedDescriptionElasticQuery.class), DmpElasticEntity._descriptions, null)); mocDoc.setDescriptions(this.convertNested(rawData, columns, this.queryFactory.query(NestedDescriptionElasticQuery.class), DmpElasticEntity._descriptions, null));
return mocDoc; return mocDoc;
} }
@ -283,7 +304,6 @@ public class DmpElasticQuery extends ElasticQuery<DmpElasticEntity, UUID> {
else if (item.match(DmpElasticEntity._accessType)) return this.elasticFieldOf(DmpElasticEntity._accessType); else if (item.match(DmpElasticEntity._accessType)) return this.elasticFieldOf(DmpElasticEntity._accessType);
else if (item.prefix(DmpElasticEntity._collaborators)) return this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(DmpElasticEntity._collaborators).fieldNameOf(this.extractPrefixed(item, DmpElasticEntity._collaborators)); else if (item.prefix(DmpElasticEntity._collaborators)) return this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(DmpElasticEntity._collaborators).fieldNameOf(this.extractPrefixed(item, DmpElasticEntity._collaborators));
else if (item.prefix(DmpElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(DmpElasticEntity._references).fieldNameOf(this.extractPrefixed(item, DmpElasticEntity._references)); else if (item.prefix(DmpElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(DmpElasticEntity._references).fieldNameOf(this.extractPrefixed(item, DmpElasticEntity._references));
else if (item.prefix(DmpElasticEntity._descriptionTemplates)) return this.queryFactory.query(NestedDescriptionTemplateElasticQuery.class).nestedPath(DmpElasticEntity._descriptionTemplates).fieldNameOf(this.extractPrefixed(item, DmpElasticEntity._descriptionTemplates));
else if (item.prefix(DmpElasticEntity._descriptions)) return this.queryFactory.query(NestedDescriptionElasticQuery.class).nestedPath(DmpElasticEntity._descriptions).fieldNameOf(this.extractPrefixed(item, DmpElasticEntity._descriptions)); else if (item.prefix(DmpElasticEntity._descriptions)) return this.queryFactory.query(NestedDescriptionElasticQuery.class).nestedPath(DmpElasticEntity._descriptions).fieldNameOf(this.extractPrefixed(item, DmpElasticEntity._descriptions));
else return null; else return null;
} }
@ -314,7 +334,6 @@ public class DmpElasticQuery extends ElasticQuery<DmpElasticEntity, UUID> {
protected ElasticNestedQuery<?, ?, ?> nestedQueryOf(FieldResolver item) { protected ElasticNestedQuery<?, ?, ?> nestedQueryOf(FieldResolver item) {
if (item.prefix(DmpElasticEntity._collaborators)) return this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(DmpElasticEntity._collaborators); if (item.prefix(DmpElasticEntity._collaborators)) return this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(DmpElasticEntity._collaborators);
else if (item.prefix(DmpElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(DmpElasticEntity._references); else if (item.prefix(DmpElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(DmpElasticEntity._references);
else if (item.prefix(DmpElasticEntity._descriptionTemplates)) return this.queryFactory.query(NestedDescriptionTemplateElasticQuery.class).nestedPath(DmpElasticEntity._descriptionTemplates);
else if (item.prefix(DmpElasticEntity._descriptions)) return this.queryFactory.query(NestedDescriptionElasticQuery.class).nestedPath(DmpElasticEntity._descriptions); else if (item.prefix(DmpElasticEntity._descriptions)) return this.queryFactory.query(NestedDescriptionElasticQuery.class).nestedPath(DmpElasticEntity._descriptions);
else return null; else return null;
} }

View File

@ -3,6 +3,7 @@ package eu.eudat.elastic.query;
import co.elastic.clients.elasticsearch._types.query_dsl.Query; import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import eu.eudat.commons.enums.DescriptionStatus; import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.elastic.data.DescriptionElasticEntity;
import eu.eudat.elastic.data.nested.NestedDescriptionElasticEntity; import eu.eudat.elastic.data.nested.NestedDescriptionElasticEntity;
import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
@ -74,6 +75,7 @@ public class NestedDescriptionElasticQuery extends ElasticNestedQuery<NestedDesc
if (columns.contains(NestedDescriptionElasticEntity._finalizedAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionElasticEntity._finalizedAt), Date.class)); if (columns.contains(NestedDescriptionElasticEntity._finalizedAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionElasticEntity._finalizedAt), Date.class));
mocDoc.setReferences(this.convertNested(rawData, columns, this.queryFactory.query(NestedReferenceElasticQuery.class), NestedDescriptionElasticEntity._references, this.getNestedPath())); mocDoc.setReferences(this.convertNested(rawData, columns, this.queryFactory.query(NestedReferenceElasticQuery.class), NestedDescriptionElasticEntity._references, this.getNestedPath()));
mocDoc.setTags(this.convertNested(rawData, columns, this.queryFactory.query(NestedTagElasticQuery.class), NestedDescriptionElasticEntity._tags, this.getNestedPath())); mocDoc.setTags(this.convertNested(rawData, columns, this.queryFactory.query(NestedTagElasticQuery.class), NestedDescriptionElasticEntity._tags, this.getNestedPath()));
mocDoc.setDescriptionTemplate(this.convertInnerObject(rawData, columns, this.queryFactory.query(InnerObjectDescriptionTemplateElasticQuery.class), NestedDescriptionElasticEntity._descriptionTemplate, null));
return mocDoc; return mocDoc;
} }
@ -87,6 +89,7 @@ public class NestedDescriptionElasticQuery extends ElasticNestedQuery<NestedDesc
else if (item.match(NestedDescriptionElasticEntity._finalizedAt)) return this.elasticFieldOf(NestedDescriptionElasticEntity._finalizedAt); else if (item.match(NestedDescriptionElasticEntity._finalizedAt)) return this.elasticFieldOf(NestedDescriptionElasticEntity._finalizedAt);
else if (item.prefix(NestedDescriptionElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(this.conventionService.asIndexer(this.getNestedPath(), NestedDescriptionElasticEntity._references)).fieldNameOf(this.extractPrefixed(item, NestedDescriptionElasticEntity._references)); else if (item.prefix(NestedDescriptionElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(this.conventionService.asIndexer(this.getNestedPath(), NestedDescriptionElasticEntity._references)).fieldNameOf(this.extractPrefixed(item, NestedDescriptionElasticEntity._references));
else if (item.prefix(NestedDescriptionElasticEntity._tags)) return this.queryFactory.query(NestedTagElasticQuery.class).nestedPath(this.conventionService.asIndexer(this.getNestedPath(), NestedDescriptionElasticEntity._tags)).fieldNameOf(this.extractPrefixed(item, NestedDescriptionElasticEntity._tags)); else if (item.prefix(NestedDescriptionElasticEntity._tags)) return this.queryFactory.query(NestedTagElasticQuery.class).nestedPath(this.conventionService.asIndexer(this.getNestedPath(), NestedDescriptionElasticEntity._tags)).fieldNameOf(this.extractPrefixed(item, NestedDescriptionElasticEntity._tags));
else if (item.prefix(NestedDescriptionElasticEntity._descriptionTemplate)) return this.queryFactory.query(InnerObjectDescriptionTemplateElasticQuery.class).innerPath(this.conventionService.asIndexer(this.getNestedPath(), NestedDescriptionElasticEntity._descriptionTemplate)).fieldNameOf(this.extractPrefixed(item, NestedDescriptionElasticEntity._description));
else return null; else return null;
} }

View File

@ -9,6 +9,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
@Configuration @Configuration
@EnableConfigurationProperties({InboxProperties.class}) @EnableConfigurationProperties({InboxProperties.class})

View File

@ -25,14 +25,12 @@ import org.springframework.context.ApplicationContext;
import java.time.Instant; import java.time.Instant;
import java.util.List; import java.util.List;
import java.util.Random;
import java.util.UUID; import java.util.UUID;
import java.util.function.Function; import java.util.function.Function;
public class InboxRepositoryImpl implements InboxRepository { public class InboxRepositoryImpl implements InboxRepository {
protected final ApplicationContext applicationContext; protected final ApplicationContext applicationContext;
private final Random random = new Random();
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(InboxRepositoryImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(InboxRepositoryImpl.class));
private final JsonHandlingService jsonHandlingService; private final JsonHandlingService jsonHandlingService;
private final InboxProperties inboxProperties; private final InboxProperties inboxProperties;
@ -85,18 +83,18 @@ public class InboxRepositoryImpl implements InboxRepository {
transaction.commit(); transaction.commit();
} catch (OptimisticLockException ex) { } catch (OptimisticLockException ex) {
// we get this if/when someone else already modified the notifications. We want to essentially ignore this, and keep working // we get this if/when someone else already modified the notifications. We want to essentially ignore this, and keep working
this.logger.debug("Concurrency exception getting queue inbox. Skipping: {} ", ex.getMessage()); logger.debug("Concurrency exception getting queue inbox. Skipping: {} ", ex.getMessage());
if (transaction != null) transaction.rollback(); if (transaction != null) transaction.rollback();
candidate = null; candidate = null;
} catch (Exception ex) { } catch (Exception ex) {
this.logger.error("Problem getting list of queue inbox. Skipping: {}", ex.getMessage(), ex); logger.error("Problem getting list of queue inbox. Skipping: {}", ex.getMessage(), ex);
if (transaction != null) transaction.rollback(); if (transaction != null) transaction.rollback();
candidate = null; candidate = null;
} finally { } finally {
if (entityManager != null) entityManager.close(); if (entityManager != null) entityManager.close();
} }
} catch (Exception ex) { } catch (Exception ex) {
this.logger.error("Problem getting list of queue inbox. Skipping: {}", ex.getMessage(), ex); logger.error("Problem getting list of queue inbox. Skipping: {}", ex.getMessage(), ex);
} }
return candidate; return candidate;

Some files were not shown because too many files have changed in this diff Show More