Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring

# Conflicts:
#	dmp-frontend/src/app/core/services/utilities/enum-utils.service.ts
This commit is contained in:
Diamantis Tziotzios 2023-11-22 15:55:46 +02:00
commit 231efd05ac
170 changed files with 2544 additions and 3551 deletions

View File

@ -22,7 +22,8 @@ public final class Permission {
public static String PublicBrowseReference = "PublicBrowseReference"; public static String PublicBrowseReference = "PublicBrowseReference";
public static String PublicBrowseUser = "PublicBrowseUser"; public static String PublicBrowseUser = "PublicBrowseUser";
//Elastic
public static String ManageElastic = "ManageElastic";
//Language //Language
public static String BrowseLanguage = "BrowseLanguage"; public static String BrowseLanguage = "BrowseLanguage";

View File

@ -0,0 +1,25 @@
package eu.eudat.commons.types.dmp;
public class DmpBlueprintValueEntity {
private String fieldId;
private String value;
public String getFieldId() {
return fieldId;
}
public void setFieldId(String fieldId) {
this.fieldId = fieldId;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@ -1,6 +1,6 @@
package eu.eudat.model.persist.dmpproperties; package eu.eudat.commons.types.dmp;
public class DmpContact { public class DmpContactEntity {
String userId; String userId;

View File

@ -0,0 +1,27 @@
package eu.eudat.commons.types.dmp;
import java.util.List;
public class DmpPropertiesEntity {
private List<DmpBlueprintValueEntity> dmpBlueprintValues;
private List<DmpContactEntity> contacts;
public List<DmpBlueprintValueEntity> getDmpBlueprintValues() {
return dmpBlueprintValues;
}
public void setDmpBlueprintValues(List<DmpBlueprintValueEntity> dmpBlueprintValues) {
this.dmpBlueprintValues = dmpBlueprintValues;
}
public List<DmpContactEntity> getContacts() {
return contacts;
}
public void setContacts(List<DmpContactEntity> contacts) {
this.contacts = contacts;
}
}

View File

@ -5,6 +5,7 @@ import jakarta.xml.bind.annotation.XmlElement;
public class AuthenticationConfigurationEntity { public class AuthenticationConfigurationEntity {
private Boolean enabled;
private String authUrl; private String authUrl;
private ReferenceTypeExternalApiHTTPMethodType authMethod; private ReferenceTypeExternalApiHTTPMethodType authMethod;
private String authTokenPath; private String authTokenPath;
@ -15,6 +16,15 @@ public class AuthenticationConfigurationEntity {
return authUrl; return authUrl;
} }
public Boolean getEnabled() {
return enabled;
}
@XmlElement(name = "enabled")
public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}
@XmlElement(name = "authUrl") @XmlElement(name = "authUrl")
public void setAuthUrl(String authUrl) { public void setAuthUrl(String authUrl) {
this.authUrl = authUrl; this.authUrl = authUrl;

View File

@ -0,0 +1,44 @@
package eu.eudat.commons.types.referencetype;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "property")
@XmlAccessorType(XmlAccessType.FIELD)
public class DependencyPropertyEntity {
@XmlAttribute(name = "code")
private String code;
@XmlAttribute(name = "target")
private String target;
@XmlAttribute(name = "required")
private Boolean required;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getTarget() {
return target;
}
public void setTarget(String target) {
this.target = target;
}
public Boolean getRequired() {
return required;
}
public void setRequired(Boolean required) {
this.required = required;
}
}

View File

@ -2,6 +2,9 @@ package eu.eudat.commons.types.referencetype;
import eu.eudat.commons.enums.ReferenceTypeSourceType; import eu.eudat.commons.enums.ReferenceTypeSourceType;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import java.util.List;
public abstract class ReferenceTypeSourceBaseConfigurationEntity { public abstract class ReferenceTypeSourceBaseConfigurationEntity {
@ -12,7 +15,7 @@ public abstract class ReferenceTypeSourceBaseConfigurationEntity {
private Integer ordinal; private Integer ordinal;
private ReferenceTypeSourceType type; private ReferenceTypeSourceType type;
private List<ReferenceTypeSourceBaseDependencyEntity> dependencies;
public ReferenceTypeSourceType getType() { public ReferenceTypeSourceType getType() {
return type; return type;
} }
@ -48,4 +51,14 @@ public abstract class ReferenceTypeSourceBaseConfigurationEntity {
public void setType(ReferenceTypeSourceType type) { public void setType(ReferenceTypeSourceType type) {
this.type = type; this.type = type;
} }
public List<ReferenceTypeSourceBaseDependencyEntity> getDependencies() {
return dependencies;
}
@XmlElementWrapper
@XmlElement(name = "dependency")
public void setDependencies(List<ReferenceTypeSourceBaseDependencyEntity> dependencies) {
this.dependencies = dependencies;
}
} }

View File

@ -0,0 +1,55 @@
package eu.eudat.commons.types.referencetype;
import jakarta.xml.bind.annotation.*;
import java.util.List;
@XmlRootElement(name = "dependency")
@XmlAccessorType(XmlAccessType.FIELD)
public class ReferenceTypeSourceBaseDependencyEntity {
@XmlAttribute(name = "referenceTypeCode")
private String referenceTypeCode;
@XmlAttribute(name = "key")
private String key;
@XmlAttribute(name = "required")
private Boolean required;
@XmlElementWrapper(name = "properties")
@XmlElement(name = "property")
private List<DependencyPropertyEntity> properties;
public String getReferenceTypeCode() {
return referenceTypeCode;
}
public void setReferenceTypeCode(String referenceTypeCode) {
this.referenceTypeCode = referenceTypeCode;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public Boolean getRequired() {
return required;
}
public void setRequired(Boolean required) {
this.required = required;
}
public List<DependencyPropertyEntity> getProperties() {
return properties;
}
public void setProperties(List<DependencyPropertyEntity> properties) {
this.properties = properties;
}
}

View File

@ -7,6 +7,7 @@ public class AppElasticProperties {
private boolean enabled; private boolean enabled;
private String dmpIndexName; private String dmpIndexName;
private String descriptionIndexName; private String descriptionIndexName;
private int resetBatchSize;
private boolean enableIcuAnalysisPlugin; private boolean enableIcuAnalysisPlugin;
public String getDmpIndexName() { public String getDmpIndexName() {
@ -40,4 +41,12 @@ public class AppElasticProperties {
public void setDescriptionIndexName(String descriptionIndexName) { public void setDescriptionIndexName(String descriptionIndexName) {
this.descriptionIndexName = descriptionIndexName; this.descriptionIndexName = descriptionIndexName;
} }
public int getResetBatchSize() {
return resetBatchSize;
}
public void setResetBatchSize(int resetBatchSize) {
this.resetBatchSize = resetBatchSize;
}
} }

View File

@ -11,7 +11,7 @@ import java.util.UUID;
@Entity @Entity
@Table(name = "\"DmpDescriptionTemplate\"") @Table(name = "\"DmpDescriptionTemplate\"")
public class DmpDescriptionTemplateEntity implements DataEntity<DmpDescriptionTemplateEntity, UUID> { public class DmpDescriptionTemplateEntity {
@Id @Id
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
@ -105,19 +105,4 @@ public class DmpDescriptionTemplateEntity implements DataEntity<DmpDescriptionTe
public void setIsActive(IsActive isActive) { public void setIsActive(IsActive isActive) {
this.isActive = isActive; this.isActive = isActive;
} }
@Override
public void update(DmpDescriptionTemplateEntity entity) {
}
@Override
public UUID getKeys() {
return null;
}
@Override
public DmpDescriptionTemplateEntity buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
return null;
}
} }

View File

@ -13,7 +13,7 @@ import java.util.UUID;
@Entity @Entity
@Table(name = "\"DmpUser\"") @Table(name = "\"DmpUser\"")
public class DmpUserEntity implements DataEntity { public class DmpUserEntity {
@Id @Id
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
@ -108,19 +108,4 @@ public class DmpUserEntity implements DataEntity {
public void setIsActive(IsActive isActive) { public void setIsActive(IsActive isActive) {
this.isActive = isActive; this.isActive = isActive;
} }
@Override
public void update(Object entity) {
}
@Override
public Object getKeys() {
return null;
}
@Override
public Object buildFromTuple(List tuple, List fields, String base) {
return null;
}
} }

View File

@ -11,7 +11,7 @@ import java.util.UUID;
@Entity @Entity
@Table(name = "\"UserCredential\"") @Table(name = "\"UserCredential\"")
public class UserCredentialEntity implements DataEntity<UserCredentialEntity, UUID> { public class UserCredentialEntity {
@Id @Id
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
@ -63,22 +63,4 @@ public class UserCredentialEntity implements DataEntity<UserCredentialEntity, UU
public void setCreatedAt(Instant createdAt) { public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt; this.createdAt = createdAt;
} }
@Override
public void update(UserCredentialEntity entity) {
this.externalId = entity.getExternalId();
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public UserCredentialEntity 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

@ -14,7 +14,7 @@ import java.util.UUID;
@Entity @Entity
@Table(name = "\"UserDescriptionTemplate\"") @Table(name = "\"UserDescriptionTemplate\"")
public class UserDescriptionTemplateEntity implements DataEntity<UserDescriptionTemplateEntity, UUID> { public class UserDescriptionTemplateEntity {
@Id @Id
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
private UUID id; private UUID id;
@ -102,21 +102,4 @@ public class UserDescriptionTemplateEntity implements DataEntity<UserDescription
public void setRole(UserDescriptionTemplateRole role) { public void setRole(UserDescriptionTemplateRole role) {
this.role = role; this.role = role;
} }
@Override
public void update(UserDescriptionTemplateEntity entity) {
this.role = entity.getRole();
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public UserDescriptionTemplateEntity 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

@ -13,7 +13,7 @@ import java.util.*;
@Entity @Entity
@Table(name = "\"User\"") @Table(name = "\"User\"")
public class UserEntity implements DataEntity<UserEntity, UUID> { public class UserEntity {
@Id @Id
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
@ -92,25 +92,4 @@ public class UserEntity implements DataEntity<UserEntity, UUID> {
public void setUpdatedAt(Instant updatedAt) { public void setUpdatedAt(Instant updatedAt) {
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
@Override
public void update(UserEntity entity) {
this.name = entity.getName();
this.additionalInfo = entity.getAdditionalInfo();
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public UserEntity 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

@ -12,7 +12,7 @@ import java.util.UUID;
@Entity @Entity
@Table(name = "\"UserRole\"") @Table(name = "\"UserRole\"")
public class UserRoleEntity implements DataEntity<UserRoleEntity, UUID> { public class UserRoleEntity {
@Id @Id
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
private UUID id; private UUID id;
@ -65,20 +65,4 @@ public class UserRoleEntity implements DataEntity<UserRoleEntity, UUID> {
this.createdAt = createdAt; this.createdAt = createdAt;
} }
@Override
public void update(UserRoleEntity entity) {
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public UserRoleEntity 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

@ -122,7 +122,7 @@ public class FileUpload implements DataEntity<FileUpload, UUID> {
public FileUpload buildFromTuple(List<Tuple> tuple, List<String> fields, String base) { public FileUpload buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + "."; String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id"); if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
this.creator = tuple.stream().map(x -> new UserEntity().buildFromTuple(tuple, fields , base.isEmpty() ? "creator" : base + "." + "creator")).collect(Collectors.toList()).get(0); // this.creator = tuple.stream().map(x -> new UserEntity().buildFromTuple(tuple, fields , base.isEmpty() ? "creator" : base + "." + "creator")).collect(Collectors.toList()).get(0);
return this; return this;
} }
} }

View File

@ -292,8 +292,8 @@ public class Grant implements DataEntity<Grant, UUID> {
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id"); if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
// if (fields.contains(currentBase + "dmps")) // if (fields.contains(currentBase + "dmps"))
// this.dmps = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields, currentBase + "dmps")).collect(Collectors.toSet()); // this.dmps = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields, currentBase + "dmps")).collect(Collectors.toSet());
if (fields.contains(currentBase + "creationUser")) // if (fields.contains(currentBase + "creationUser"))
this.creationUser = tuple.stream().map(x -> new UserEntity().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0); // this.creationUser = tuple.stream().map(x -> new UserEntity().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0);
return this; return this;
} }
} }

View File

@ -282,8 +282,8 @@ public class Project implements DataEntity<Project, UUID> {
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id"); if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
// if (fields.contains(currentBase + "dmps")) // if (fields.contains(currentBase + "dmps"))
// this.dmps = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields, currentBase + "dmps")).collect(Collectors.toSet()); // this.dmps = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields, currentBase + "dmps")).collect(Collectors.toSet());
if (fields.contains(currentBase + "creationUser")) // if (fields.contains(currentBase + "creationUser"))
this.creationUser = tuple.stream().map(x -> new UserEntity().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0); // this.creationUser = tuple.stream().map(x -> new UserEntity().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0);
return this; return this;
} }
} }

View File

@ -22,7 +22,6 @@ public class NestedDescriptionTemplateElasticEntity {
public final static String _label = "label"; public final static String _label = "label";
@Field(value = NestedDescriptionTemplateElasticEntity._versionStatus, type = FieldType.Short) @Field(value = NestedDescriptionTemplateElasticEntity._versionStatus, type = FieldType.Short)
private DescriptionTemplateVersionStatus versionStatus; private DescriptionTemplateVersionStatus versionStatus;
public final static String _versionStatus = "versionStatus"; public final static String _versionStatus = "versionStatus";

View File

@ -49,6 +49,7 @@ public class AuthenticationConfigurationBuilder extends BaseBuilder<Authenticati
List<AuthenticationConfiguration> models = new ArrayList<>(); List<AuthenticationConfiguration> models = new ArrayList<>();
for (AuthenticationConfigurationEntity d : data) { for (AuthenticationConfigurationEntity d : data) {
AuthenticationConfiguration m = new AuthenticationConfiguration(); AuthenticationConfiguration m = new AuthenticationConfiguration();
if (fields.hasField(this.asIndexer(AuthenticationConfiguration._enabled))) m.setEnabled(d.getEnabled());
if (fields.hasField(this.asIndexer(AuthenticationConfiguration._authUrl))) m.setAuthUrl(d.getAuthUrl()); if (fields.hasField(this.asIndexer(AuthenticationConfiguration._authUrl))) m.setAuthUrl(d.getAuthUrl());
if (fields.hasField(this.asIndexer(AuthenticationConfiguration._authMethod))) m.setAuthMethod(d.getAuthMethod()); if (fields.hasField(this.asIndexer(AuthenticationConfiguration._authMethod))) m.setAuthMethod(d.getAuthMethod());
if (fields.hasField(this.asIndexer(AuthenticationConfiguration._authTokenPath))) m.setAuthTokenPath(d.getAuthTokenPath()); if (fields.hasField(this.asIndexer(AuthenticationConfiguration._authTokenPath))) m.setAuthTokenPath(d.getAuthTokenPath());

View File

@ -0,0 +1,59 @@
package eu.eudat.model.builder.referencetypedefinition;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.types.referencetype.DependencyPropertyEntity;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.builder.BaseBuilder;
import eu.eudat.model.referencetypedefinition.DependencyProperty;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.*;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DependencyPropertyBuilder extends BaseBuilder<DependencyProperty, DependencyPropertyEntity> {
private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
public DependencyPropertyBuilder(
ConventionService conventionService, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DependencyPropertyBuilder.class)));
this.builderFactory = builderFactory;
}
public DependencyPropertyBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<DependencyProperty> build(FieldSet fields, List<DependencyPropertyEntity> data) throws MyApplicationException {
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
this.logger.trace(new DataLogEntry("requested fields", fields));
if (fields == null || data == null || fields.isEmpty())
return new ArrayList<>();
List<DependencyProperty> models = new ArrayList<>();
for (DependencyPropertyEntity d : data) {
DependencyProperty m = new DependencyProperty();
if (fields.hasField(this.asIndexer(DependencyProperty._code))) m.setCode(d.getCode());
if (fields.hasField(this.asIndexer(DependencyProperty._target))) m.setTarget(d.getTarget());
if (fields.hasField(this.asIndexer(DependencyProperty._required))) m.setRequired(d.getRequired());
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
}

View File

@ -5,6 +5,7 @@ import eu.eudat.commons.types.referencetype.ReferenceTypeSourceBaseConfiguration
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.model.builder.BaseBuilder; import eu.eudat.model.builder.BaseBuilder;
import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceBaseConfiguration; import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceBaseConfiguration;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.DataLogEntry;
@ -21,12 +22,14 @@ import java.util.*;
public abstract class ReferenceTypeSourceBaseConfigurationBuilder<Model extends ReferenceTypeSourceBaseConfiguration, Entity extends ReferenceTypeSourceBaseConfigurationEntity> extends BaseBuilder<Model, Entity> { public abstract class ReferenceTypeSourceBaseConfigurationBuilder<Model extends ReferenceTypeSourceBaseConfiguration, Entity extends ReferenceTypeSourceBaseConfigurationEntity> extends BaseBuilder<Model, Entity> {
protected EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); protected EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
protected final BuilderFactory builderFactory;
@Autowired @Autowired
public ReferenceTypeSourceBaseConfigurationBuilder( public ReferenceTypeSourceBaseConfigurationBuilder(
ConventionService conventionService, ConventionService conventionService,
LoggerService logger) { LoggerService logger, BuilderFactory builderFactory) {
super(conventionService, logger); super(conventionService, logger);
this.builderFactory = builderFactory;
} }
public ReferenceTypeSourceBaseConfigurationBuilder authorize(EnumSet<AuthorizationFlags> values) { public ReferenceTypeSourceBaseConfigurationBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -44,6 +47,7 @@ public abstract class ReferenceTypeSourceBaseConfigurationBuilder<Model extends
if (fields == null || data == null || fields.isEmpty()) if (fields == null || data == null || fields.isEmpty())
return new ArrayList<>(); return new ArrayList<>();
FieldSet dependenciesFields = fields.extractPrefixed(this.asPrefix(Model._dependencies));
List<Model> models = new ArrayList<>(); List<Model> models = new ArrayList<>();
for (Entity d : data) { for (Entity d : data) {
Model m = this.getInstance(); Model m = this.getInstance();
@ -51,6 +55,8 @@ public abstract class ReferenceTypeSourceBaseConfigurationBuilder<Model extends
if (fields.hasField(this.asIndexer(Model._label))) m.setLabel(d.getLabel()); if (fields.hasField(this.asIndexer(Model._label))) m.setLabel(d.getLabel());
if (fields.hasField(this.asIndexer(Model._ordinal))) m.setOrdinal(d.getOrdinal()); if (fields.hasField(this.asIndexer(Model._ordinal))) m.setOrdinal(d.getOrdinal());
if (fields.hasField(this.asIndexer(Model._type))) m.setType(d.getType()); if (fields.hasField(this.asIndexer(Model._type))) m.setType(d.getType());
if (!dependenciesFields.isEmpty() && d.getDependencies() != null) m.setDependencies(this.builderFactory.builder(ReferenceTypeSourceBaseDependencyBuilder.class).authorize(this.authorize).build(dependenciesFields, d.getDependencies()));
this.buildChild(fields, d, m); this.buildChild(fields, d, m);
models.add(m); models.add(m);
} }

View File

@ -0,0 +1,62 @@
package eu.eudat.model.builder.referencetypedefinition;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.types.referencetype.ReferenceTypeSourceBaseDependencyEntity;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.builder.BaseBuilder;
import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceBaseDependency;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.*;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class ReferenceTypeSourceBaseDependencyBuilder extends BaseBuilder<ReferenceTypeSourceBaseDependency, ReferenceTypeSourceBaseDependencyEntity> {
private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
public ReferenceTypeSourceBaseDependencyBuilder(
ConventionService conventionService, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeSourceBaseDependencyBuilder.class)));
this.builderFactory = builderFactory;
}
public ReferenceTypeSourceBaseDependencyBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<ReferenceTypeSourceBaseDependency> build(FieldSet fields, List<ReferenceTypeSourceBaseDependencyEntity> data) throws MyApplicationException {
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
this.logger.trace(new DataLogEntry("requested fields", fields));
if (fields == null || data == null || fields.isEmpty())
return new ArrayList<>();
FieldSet propertiesFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeSourceBaseDependency._properties));
List<ReferenceTypeSourceBaseDependency> models = new ArrayList<>();
for (ReferenceTypeSourceBaseDependencyEntity d : data) {
ReferenceTypeSourceBaseDependency m = new ReferenceTypeSourceBaseDependency();
if (fields.hasField(this.asIndexer(ReferenceTypeSourceBaseDependency._referenceTypeCode))) m.setReferenceTypeCode(d.getReferenceTypeCode());
if (fields.hasField(this.asIndexer(ReferenceTypeSourceBaseDependency._key))) m.setKey(d.getKey());
if (fields.hasField(this.asIndexer(ReferenceTypeSourceBaseDependency._required))) m.setRequired(d.getRequired());
if (!propertiesFields.isEmpty() && d.getProperties() != null) m.setProperties(this.builderFactory.builder(DependencyPropertyBuilder.class).authorize(this.authorize).build(propertiesFields, d.getProperties()));
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
}

View File

@ -25,7 +25,7 @@ public class ReferenceTypeSourceExternalApiConfigurationBuilder extends Referenc
@Autowired @Autowired
public ReferenceTypeSourceExternalApiConfigurationBuilder( public ReferenceTypeSourceExternalApiConfigurationBuilder(
ConventionService conventionService, BuilderFactory builderFactory) { ConventionService conventionService, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeSourceExternalApiConfigurationBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeSourceExternalApiConfigurationBuilder.class)), builderFactory);
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
} }

View File

@ -25,7 +25,7 @@ public class ReferenceTypeSourceStaticOptionConfigurationBuilder extends Referen
@Autowired @Autowired
public ReferenceTypeSourceStaticOptionConfigurationBuilder( public ReferenceTypeSourceStaticOptionConfigurationBuilder(
ConventionService conventionService, BuilderFactory builderFactory) { ConventionService conventionService, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeSourceStaticOptionConfigurationBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeSourceStaticOptionConfigurationBuilder.class)), builderFactory);
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
} }

View File

@ -3,7 +3,7 @@ package eu.eudat.model.censorship;
import eu.eudat.authorization.Permission; import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.model.ReferenceType; import eu.eudat.model.ReferenceType;
import eu.eudat.model.censorship.referencetype.ReferenceTypeDefinitionCensor; import eu.eudat.model.censorship.referencetypedefinition.ReferenceTypeDefinitionCensor;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;

View File

@ -1,4 +1,4 @@
package eu.eudat.model.censorship.referencetype; package eu.eudat.model.censorship.referencetypedefinition;
import eu.eudat.authorization.Permission; import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
@ -16,13 +16,13 @@ import java.util.UUID;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class ReferenceTypeSourceBaseConfigurationCensor extends BaseCensor { public class DependencyPropertyCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceTypeSourceBaseConfigurationCensor.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DependencyPropertyCensor.class));
protected final AuthorizationService authService; protected final AuthorizationService authService;
public ReferenceTypeSourceBaseConfigurationCensor(ConventionService conventionService, public DependencyPropertyCensor(ConventionService conventionService,
AuthorizationService authService) { AuthorizationService authService) {
super(conventionService); super(conventionService);
this.authService = authService; this.authService = authService;

View File

@ -1,4 +1,4 @@
package eu.eudat.model.censorship.referencetype; package eu.eudat.model.censorship.referencetypedefinition;
import eu.eudat.authorization.Permission; import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;

View File

@ -1,4 +1,4 @@
package eu.eudat.model.censorship.referencetype; package eu.eudat.model.censorship.referencetypedefinition;
import eu.eudat.authorization.Permission; import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;

View File

@ -0,0 +1,45 @@
package eu.eudat.model.censorship.referencetypedefinition;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.censorship.BaseCensor;
import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceBaseConfiguration;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class ReferenceTypeSourceBaseConfigurationCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceTypeSourceBaseConfigurationCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public ReferenceTypeSourceBaseConfigurationCensor(ConventionService conventionService,
AuthorizationService authService, CensorFactory censorFactory) {
super(conventionService);
this.authService = authService;
this.censorFactory = censorFactory;
}
public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorizeForce(Permission.BrowseReferenceType);
FieldSet dependenciesFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeSourceBaseConfiguration._dependencies));
this.censorFactory.censor(ReferenceTypeSourceBaseDependencyCensor.class).censor(dependenciesFields, userId);
}
}

View File

@ -0,0 +1,45 @@
package eu.eudat.model.censorship.referencetypedefinition;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.censorship.BaseCensor;
import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceBaseDependency;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class ReferenceTypeSourceBaseDependencyCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceTypeSourceBaseDependencyCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public ReferenceTypeSourceBaseDependencyCensor(ConventionService conventionService,
AuthorizationService authService, CensorFactory censorFactory) {
super(conventionService);
this.authService = authService;
this.censorFactory = censorFactory;
}
public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorizeForce(Permission.BrowseReferenceType);
FieldSet propertiesFields = fields.extractPrefixed(this.asIndexerPrefix( ReferenceTypeSourceBaseDependency._properties));
this.censorFactory.censor(DependencyPropertyCensor.class).censor(propertiesFields, userId);
}
}

View File

@ -1,25 +0,0 @@
package eu.eudat.model.persist.dmpproperties;
public class DmpBlueprintValue {
private String fieldId;
private String fieldValue;
public String getFieldId() {
return fieldId;
}
public void setFieldId(String fieldId) {
this.fieldId = fieldId;
}
public String getFieldValue() {
return fieldValue;
}
public void setFieldValue(String fieldValue) {
this.fieldValue = fieldValue;
}
}

View File

@ -6,6 +6,8 @@ import jakarta.validation.constraints.NotNull;
public class AuthenticationConfigurationPersist { public class AuthenticationConfigurationPersist {
@NotNull(message = "{validation.empty}")
private Boolean enabled;
@NotNull(message = "{validation.empty}") @NotNull(message = "{validation.empty}")
private String authUrl; private String authUrl;
@ -19,6 +21,14 @@ public class AuthenticationConfigurationPersist {
@NotNull(message = "{validation.empty}") @NotNull(message = "{validation.empty}")
private String type; private String type;
public Boolean getEnabled() {
return enabled;
}
public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}
public String getAuthUrl() { public String getAuthUrl() {
return authUrl; return authUrl;
} }

View File

@ -0,0 +1,43 @@
package eu.eudat.model.persist.referencetypedefinition;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
public class DependencyPropertyPersist {
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String code;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String target;
@NotNull(message = "{validation.empty}")
private Boolean required;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getTarget() {
return target;
}
public void setTarget(String target) {
this.target = target;
}
public Boolean getRequired() {
return required;
}
public void setRequired(Boolean required) {
this.required = required;
}
}

View File

@ -4,9 +4,12 @@ import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeInfo;
import eu.eudat.commons.enums.ReferenceTypeSourceType; import eu.eudat.commons.enums.ReferenceTypeSourceType;
import eu.eudat.commons.validation.ValidEnum; import eu.eudat.commons.validation.ValidEnum;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.util.List;
@JsonTypeInfo( @JsonTypeInfo(
use = JsonTypeInfo.Id.NAME, use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY, include = JsonTypeInfo.As.PROPERTY,
@ -32,6 +35,8 @@ public abstract class ReferenceTypeSourceBaseConfigurationPersist {
@ValidEnum(message = "{validation.empty}") @ValidEnum(message = "{validation.empty}")
private ReferenceTypeSourceType type; private ReferenceTypeSourceType type;
@Valid
private List<ReferenceTypeSourceBaseDependencyPersist> dependencies;
public String getKey() { public String getKey() {
return key; return key;
@ -64,4 +69,12 @@ public abstract class ReferenceTypeSourceBaseConfigurationPersist {
public void setType(ReferenceTypeSourceType type) { public void setType(ReferenceTypeSourceType type) {
this.type = type; this.type = type;
} }
public List<ReferenceTypeSourceBaseDependencyPersist> getDependencies() {
return dependencies;
}
public void setDependencies(List<ReferenceTypeSourceBaseDependencyPersist> dependencies) {
this.dependencies = dependencies;
}
} }

View File

@ -0,0 +1,58 @@
package eu.eudat.model.persist.referencetypedefinition;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import java.util.List;
public class ReferenceTypeSourceBaseDependencyPersist {
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String referenceTypeCode;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String key;
@NotNull(message = "{validation.empty}")
private Boolean required;
@NotNull(message = "{validation.empty}")
@Valid
private List<DependencyPropertyPersist> properties;
public String getReferenceTypeCode() {
return referenceTypeCode;
}
public void setReferenceTypeCode(String referenceTypeCode) {
this.referenceTypeCode = referenceTypeCode;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public Boolean getRequired() {
return required;
}
public void setRequired(Boolean required) {
this.required = required;
}
public List<DependencyPropertyPersist> getProperties() {
return properties;
}
public void setProperties(List<DependencyPropertyPersist> properties) {
this.properties = properties;
}
}

View File

@ -4,6 +4,9 @@ import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
public class AuthenticationConfiguration { public class AuthenticationConfiguration {
public final static String _enabled = "enabled";
private Boolean enabled;
public final static String _authUrl = "authUrl"; public final static String _authUrl = "authUrl";
private String authUrl; private String authUrl;
@ -19,6 +22,14 @@ public class AuthenticationConfiguration {
public final static String _type = "type"; public final static String _type = "type";
private String type; private String type;
public Boolean getEnabled() {
return enabled;
}
public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}
public String getAuthUrl() { public String getAuthUrl() {
return authUrl; return authUrl;
} }

View File

@ -0,0 +1,38 @@
package eu.eudat.model.referencetypedefinition;
public class DependencyProperty {
public final static String _code = "code";
private String code;
public final static String _target = "target";
private String target;
public final static String _required = "required";
private Boolean required;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getTarget() {
return target;
}
public void setTarget(String target) {
this.target = target;
}
public Boolean getRequired() {
return required;
}
public void setRequired(Boolean required) {
this.required = required;
}
}

View File

@ -2,6 +2,8 @@ package eu.eudat.model.referencetypedefinition;
import eu.eudat.commons.enums.ReferenceTypeSourceType; import eu.eudat.commons.enums.ReferenceTypeSourceType;
import java.util.List;
public abstract class ReferenceTypeSourceBaseConfiguration { public abstract class ReferenceTypeSourceBaseConfiguration {
@ -17,6 +19,9 @@ public abstract class ReferenceTypeSourceBaseConfiguration {
public final static String _type = "type"; public final static String _type = "type";
private ReferenceTypeSourceType type; private ReferenceTypeSourceType type;
public final static String _dependencies = "dependencies";
private List<ReferenceTypeSourceBaseDependency> dependencies;
public ReferenceTypeSourceType getType() { public ReferenceTypeSourceType getType() {
return type; return type;
} }
@ -48,4 +53,12 @@ public abstract class ReferenceTypeSourceBaseConfiguration {
public void setOrdinal(Integer ordinal) { public void setOrdinal(Integer ordinal) {
this.ordinal = ordinal; this.ordinal = ordinal;
} }
public List<ReferenceTypeSourceBaseDependency> getDependencies() {
return dependencies;
}
public void setDependencies(List<ReferenceTypeSourceBaseDependency> dependencies) {
this.dependencies = dependencies;
}
} }

View File

@ -0,0 +1,52 @@
package eu.eudat.model.referencetypedefinition;
import java.util.List;
public class ReferenceTypeSourceBaseDependency {
public final static String _referenceTypeCode = "referenceTypeCode";
private String referenceTypeCode;
public final static String _key = "key";
private String key;
public final static String _required = "required";
private Boolean required;
public final static String _properties = "properties";
private List<DependencyProperty> properties;
public String getReferenceTypeCode() {
return referenceTypeCode;
}
public void setReferenceTypeCode(String referenceTypeCode) {
this.referenceTypeCode = referenceTypeCode;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public Boolean getRequired() {
return required;
}
public void setRequired(Boolean required) {
this.required = required;
}
public List<DependencyProperty> getProperties() {
return properties;
}
public void setProperties(List<DependencyProperty> properties) {
this.properties = properties;
}
}

View File

@ -142,7 +142,7 @@ public class ReferenceTypeQuery extends QueryBase<ReferenceTypeEntity> {
predicates.add(inClause); predicates.add(inClause);
} }
if (this.codes != null) { if (this.codes != null) {
CriteriaBuilder.In<String> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceEntity._type)); CriteriaBuilder.In<String> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceTypeEntity._code));
for (String item : this.codes) for (String item : this.codes)
inClause.value(item); inClause.value(item);
predicates.add(inClause); predicates.add(inClause);

View File

@ -23,8 +23,8 @@ import eu.eudat.service.entitydoi.EntityDoiService;
import eu.eudat.utilities.pdf.PDFUtils; import eu.eudat.utilities.pdf.PDFUtils;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.commons.web.oidc.apikey.ApiKeyCacheService; import gr.cite.commons.web.oidc.apikey.ApiKeyCacheService;
import gr.cite.commons.web.oidc.apikey.webflux.ApiKeyExchangeFilterFunction; //import gr.cite.commons.web.oidc.apikey.webflux.ApiKeyExchangeFilterFunction;
import gr.cite.commons.web.oidc.apikey.webflux.ApiKeyWebfluxModel; //import gr.cite.commons.web.oidc.apikey.webflux.ApiKeyWebfluxModel;
import gr.cite.tools.data.query.Ordering; import gr.cite.tools.data.query.Ordering;
import gr.cite.tools.fieldset.BaseFieldSet; import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
@ -83,11 +83,11 @@ public class RepositoryDepositService {
DepositProperties.DepositSource source = depositProperties.getSources().stream().filter(depositSource -> depositSource.getCodes().contains(repoId)).findFirst().orElse(null); DepositProperties.DepositSource source = depositProperties.getSources().stream().filter(depositSource -> depositSource.getCodes().contains(repoId)).findFirst().orElse(null);
if (source != null) { if (source != null) {
String host = URI.create(source.getUrl()).getHost(); String host = URI.create(source.getUrl()).getHost();
ApiKeyWebfluxModel apiKeyWebfluxModel = new ApiKeyWebfluxModel(host + "_" + source.getClientId(), source.getIssuerUrl(), source.getClientId(), source.getClientSecret(), source.getScope()); // ApiKeyWebfluxModel apiKeyWebfluxModel = new ApiKeyWebfluxModel(host + "_" + source.getClientId(), source.getIssuerUrl(), source.getClientId(), source.getClientSecret(), source.getScope());
ApiKeyExchangeFilterFunction apiKeyExchangeFilterFunction = new ApiKeyExchangeFilterFunction(this.apiKeyCacheService, apiKeyWebfluxModel); // ApiKeyExchangeFilterFunction apiKeyExchangeFilterFunction = new ApiKeyExchangeFilterFunction(this.apiKeyCacheService, apiKeyWebfluxModel);
DepositRepository repository = new DepositRepository(webClientBuilder.baseUrl(source.getUrl() + "/api/deposit").filters(exchangeFilterFunctions -> exchangeFilterFunctions.add(apiKeyExchangeFilterFunction)).build()); // DepositRepository repository = new DepositRepository(webClientBuilder.baseUrl(source.getUrl() + "/api/deposit").filters(exchangeFilterFunctions -> exchangeFilterFunctions.add(apiKeyExchangeFilterFunction)).build());
source.getCodes().forEach(code -> this.clients.put(code, repository)); // source.getCodes().forEach(code -> this.clients.put(code, repository));
return repository; // return repository;
} }
return null; return null;
} }

View File

@ -7,6 +7,9 @@ import eu.eudat.commons.JsonHandlingService;
import eu.eudat.commons.XmlHandlingService; import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.enums.*; import eu.eudat.commons.enums.*;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.commons.types.dmp.DmpBlueprintValueEntity;
import eu.eudat.commons.types.dmp.DmpContactEntity;
import eu.eudat.commons.types.dmp.DmpPropertiesEntity;
import eu.eudat.commons.types.reference.DefinitionEntity; import eu.eudat.commons.types.reference.DefinitionEntity;
import eu.eudat.commons.types.reference.FieldEntity; import eu.eudat.commons.types.reference.FieldEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
@ -22,6 +25,9 @@ import eu.eudat.model.deleter.DmpDescriptionTemplateDeleter;
import eu.eudat.model.deleter.DmpReferenceDeleter; import eu.eudat.model.deleter.DmpReferenceDeleter;
import eu.eudat.model.deleter.DmpUserDeleter; import eu.eudat.model.deleter.DmpUserDeleter;
import eu.eudat.model.persist.*; import eu.eudat.model.persist.*;
import eu.eudat.model.persist.dmpproperties.DmpBlueprintValuePersist;
import eu.eudat.model.persist.dmpproperties.DmpContactPersist;
import eu.eudat.model.persist.dmpproperties.DmpPropertiesPersist;
import eu.eudat.model.persist.referencedefinition.DefinitionPersist; import eu.eudat.model.persist.referencedefinition.DefinitionPersist;
import eu.eudat.model.persist.referencedefinition.FieldPersist; import eu.eudat.model.persist.referencedefinition.FieldPersist;
import eu.eudat.query.*; import eu.eudat.query.*;
@ -408,7 +414,7 @@ public class DmpServiceImpl implements DmpService {
} }
data.setLabel(model.getLabel()); data.setLabel(model.getLabel());
data.setProperties(this.jsonHandlingService.toJson(model.getProperties())); data.setProperties(this.jsonHandlingService.toJson(this.buildDmpPropertiesEntity(model.getProperties())));
data.setDescription(model.getDescription()); data.setDescription(model.getDescription());
data.setAccessType(model.getAccessType()); data.setAccessType(model.getAccessType());
data.setUpdatedAt(Instant.now()); data.setUpdatedAt(Instant.now());
@ -424,6 +430,46 @@ public class DmpServiceImpl implements DmpService {
return data; return data;
} }
private @NotNull DmpPropertiesEntity buildDmpPropertiesEntity(DmpPropertiesPersist persist){
DmpPropertiesEntity data = new DmpPropertiesEntity();
if (persist == null) return data;
if (!this.conventionService.isListNullOrEmpty(persist.getContacts())){
data.setContacts(new ArrayList<>());
for (DmpContactPersist contactPersist: persist.getContacts()) {
data.getContacts().add(this.buildDmpContactEntity(contactPersist));
}
}
if (!this.conventionService.isListNullOrEmpty(persist.getDmpBlueprintValues())){
data.setDmpBlueprintValues(new ArrayList<>());
for (DmpBlueprintValuePersist fieldValuePersist: persist.getDmpBlueprintValues()) {
data.getDmpBlueprintValues().add(this.buildDmpBlueprintValueEntity(fieldValuePersist));
}
}
return data;
}
private @NotNull DmpContactEntity buildDmpContactEntity(DmpContactPersist persist){
DmpContactEntity data = new DmpContactEntity();
if (persist == null) return data;
data.setEmail(persist.getEmail());
data.setLastName(persist.getLastName());
data.setFirstName(persist.getFirstName());
data.setUserId(persist.getUserId());
return data;
}
private @NotNull DmpBlueprintValueEntity buildDmpBlueprintValueEntity(DmpBlueprintValuePersist persist){
DmpBlueprintValueEntity data = new DmpBlueprintValueEntity();
if (persist == null) return data;
data.setValue(persist.getFieldValue());
data.setFieldId(persist.getFieldId());
return data;
}
private void patchAndSaveReferences(List<DmpReferencePersist> models, UUID dmpId) throws InvalidApplicationException { private void patchAndSaveReferences(List<DmpReferencePersist> models, UUID dmpId) throws InvalidApplicationException {
if (models == null || models.isEmpty()) if (models == null || models.isEmpty())
return; return;
@ -532,14 +578,14 @@ public class DmpServiceImpl implements DmpService {
if (!this.conventionService.isListNullOrEmpty(persist.getFields())){ if (!this.conventionService.isListNullOrEmpty(persist.getFields())){
data.setFields(new ArrayList<>()); data.setFields(new ArrayList<>());
for (FieldPersist fieldPersist: persist.getFields()) { for (FieldPersist fieldPersist: persist.getFields()) {
data.getFields().add(this.buildFieldEntity(fieldPersist)); data.getFields().add(this.buildDmpContactEntity(fieldPersist));
} }
} }
return data; return data;
} }
private @NotNull FieldEntity buildFieldEntity(FieldPersist persist){ private @NotNull FieldEntity buildDmpContactEntity(FieldPersist persist){
FieldEntity data = new FieldEntity(); FieldEntity data = new FieldEntity();
if (persist == null) return data; if (persist == null) return data;

View File

@ -24,4 +24,12 @@ public interface ElasticService {
void persistDescription(DescriptionEntity description) throws IOException; void persistDescription(DescriptionEntity description) throws IOException;
void deleteDescription(DescriptionEntity description) throws IOException; void deleteDescription(DescriptionEntity description) throws IOException;
void deleteDmpIndex() throws IOException;
void deleteDescriptionIndex() throws IOException;
void resetDmpIndex() throws IOException;
void resetDescriptionIndex() throws IOException;
} }

View File

@ -4,6 +4,7 @@ import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch._types.mapping.Property; import co.elastic.clients.elasticsearch._types.mapping.Property;
import co.elastic.clients.elasticsearch._types.mapping.TypeMapping; import co.elastic.clients.elasticsearch._types.mapping.TypeMapping;
import co.elastic.clients.elasticsearch.indices.*; import co.elastic.clients.elasticsearch.indices.*;
import eu.eudat.authorization.Permission;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.configurations.elastic.AppElasticProperties; import eu.eudat.configurations.elastic.AppElasticProperties;
import eu.eudat.data.DescriptionEntity; import eu.eudat.data.DescriptionEntity;
@ -17,12 +18,19 @@ import eu.eudat.model.Description;
import eu.eudat.model.Dmp; import eu.eudat.model.Dmp;
import eu.eudat.query.DescriptionQuery; import eu.eudat.query.DescriptionQuery;
import eu.eudat.query.DmpQuery; import eu.eudat.query.DmpQuery;
import eu.eudat.service.dmpblueprint.DmpBlueprintServiceImpl;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.Ordering;
import gr.cite.tools.data.query.Paging;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.elastic.ElasticConstants; import gr.cite.tools.elastic.ElasticConstants;
import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.fieldset.BaseFieldSet; import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.data.elasticsearch.annotations.FieldType; import org.springframework.data.elasticsearch.annotations.FieldType;
@ -33,10 +41,10 @@ import java.util.*;
import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate; import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.context.annotation.RequestScope;
@Service @Service
public class ElasticServiceImpl implements ElasticService { public class ElasticServiceImpl implements ElasticService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintServiceImpl.class));
public final AppElasticProperties appElasticProperties; public final AppElasticProperties appElasticProperties;
private final ElasticsearchClient restHighLevelClient; private final ElasticsearchClient restHighLevelClient;
private final ElasticsearchTemplate elasticsearchTemplate; private final ElasticsearchTemplate elasticsearchTemplate;
@ -44,8 +52,9 @@ public class ElasticServiceImpl implements ElasticService {
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private final EntityManager entityManager; private final EntityManager entityManager;
private final MessageSource messageSource; private final MessageSource messageSource;
private final AuthorizationService authorizationService;
public ElasticServiceImpl(AppElasticProperties appElasticProperties, ElasticsearchClient restHighLevelClient, ElasticsearchTemplate elasticsearchTemplate, QueryFactory queryFactory, BuilderFactory builderFactory, EntityManager entityManager, MessageSource messageSource) { public ElasticServiceImpl(AppElasticProperties appElasticProperties, ElasticsearchClient restHighLevelClient, ElasticsearchTemplate elasticsearchTemplate, QueryFactory queryFactory, BuilderFactory builderFactory, EntityManager entityManager, MessageSource messageSource, AuthorizationService authorizationService) {
this.appElasticProperties = appElasticProperties; this.appElasticProperties = appElasticProperties;
this.restHighLevelClient = restHighLevelClient; this.restHighLevelClient = restHighLevelClient;
this.elasticsearchTemplate = elasticsearchTemplate; this.elasticsearchTemplate = elasticsearchTemplate;
@ -53,6 +62,7 @@ public class ElasticServiceImpl implements ElasticService {
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.entityManager = entityManager; this.entityManager = entityManager;
this.messageSource = messageSource; this.messageSource = messageSource;
this.authorizationService = authorizationService;
} }
@Override @Override
@ -115,7 +125,7 @@ public class ElasticServiceImpl implements ElasticService {
indexSettingsAnalysis.analyzer("icu_analyzer_text", ab -> ab.custom(x-> x.filter("icu_folding", "english_stop", "english_stemmer").tokenizer("standard"))); indexSettingsAnalysis.analyzer("icu_analyzer_text", ab -> ab.custom(x-> x.filter("icu_folding", "english_stop", "english_stemmer").tokenizer("standard")));
} }
indexSettings.analysis(indexSettingsAnalysis.build()); indexSettings.analysis(indexSettingsAnalysis.build());
CreateIndexResponse createIndexResponse = restHighLevelClient.indices().create(new CreateIndexRequest.Builder().index(indexName).mappings(typeMapping.build()).settings(indexSettings.build()).build()); restHighLevelClient.indices().create(new CreateIndexRequest.Builder().index(indexName).mappings(typeMapping.build()).settings(indexSettings.build()).build());
} }
@ -252,6 +262,8 @@ public class ElasticServiceImpl implements ElasticService {
//endregion //endregion
//region persist delete
@Override @Override
public void persistDmp(DmpEntity dmp) throws IOException { public void persistDmp(DmpEntity dmp) throws IOException {
if (!this.enabled()) return; if (!this.enabled()) return;
@ -303,4 +315,83 @@ public class ElasticServiceImpl implements ElasticService {
this.elasticsearchTemplate.save(dmpElasticEntity, IndexCoordinates.of(this.appElasticProperties.getDmpIndexName())); this.elasticsearchTemplate.save(dmpElasticEntity, IndexCoordinates.of(this.appElasticProperties.getDmpIndexName()));
} }
} }
//endregion
//region manage
@Override
public void deleteDmpIndex() throws IOException {
logger.debug(new MapLogEntry("delete dmp index"));
this.authorizationService.authorizeForce(Permission.ManageElastic);
if (!this.enabled()) return;
boolean exists = this.existsDmpIndex();
if (exists) return ;
this.restHighLevelClient.indices().delete(new DeleteIndexRequest.Builder().index(this.appElasticProperties.getDmpIndexName()).build());
}
@Override
public void deleteDescriptionIndex() throws IOException {
logger.debug(new MapLogEntry("delete description index"));
this.authorizationService.authorizeForce(Permission.ManageElastic);
if (!this.enabled()) return;
boolean exists = this.existsDescriptionIndex();
if (exists) return ;
this.restHighLevelClient.indices().delete(new DeleteIndexRequest.Builder().index(this.appElasticProperties.getDescriptionIndexName()).build());
}
@Override
public void resetDmpIndex() throws IOException {
logger.debug(new MapLogEntry("reset dmp index"));
this.authorizationService.authorizeForce(Permission.ManageElastic);
if (!this.enabled()) return;
this.deleteDmpIndex();
int page = 0;
int pageSize = this.appElasticProperties.getResetBatchSize();
List<DmpEntity> items;
do {
DmpQuery query = this.queryFactory.query(DmpQuery.class);
query.setOrder(new Ordering().addAscending(Dmp._createdAt));
query.setPage(new Paging(page * pageSize, pageSize));
items = this.queryFactory.query(DmpQuery.class).collect();
if (items != null && !items.isEmpty()) {
List<DmpElasticEntity> elasticEntities = this.builderFactory.builder(DmpElasticBuilder.class).build(items);
elasticsearchTemplate.save(elasticEntities, IndexCoordinates.of(this.appElasticProperties.getDmpIndexName()));
page++;
}
} while (items != null && !items.isEmpty());
}
@Override
public void resetDescriptionIndex() throws IOException {
logger.debug(new MapLogEntry("reset description index"));
this.authorizationService.authorizeForce(Permission.ManageElastic);
if (!this.enabled()) return;
this.deleteDescriptionIndex();
int page = 0;
int pageSize = this.appElasticProperties.getResetBatchSize();
List<DescriptionEntity> items;
do {
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class);
query.setOrder(new Ordering().addAscending(Description._createdAt));
query.setPage(new Paging(page * pageSize, pageSize));
items = this.queryFactory.query(DescriptionQuery.class).collect();
if (items != null && !items.isEmpty()) {
List<DescriptionElasticEntity> elasticEntities = this.builderFactory.builder(DescriptionElasticBuilder.class).build(items);
elasticsearchTemplate.save(elasticEntities, IndexCoordinates.of(this.appElasticProperties.getDescriptionIndexName()));
page++;
}
} while (items != null && !items.isEmpty());
}
//endregion
} }

View File

@ -52,14 +52,13 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private final ConventionService conventionService; private final ConventionService conventionService;
private final MessageSource messageSource; private final MessageSource messageSource;
private final QueryFactory queryFactory;
private final XmlHandlingService xmlHandlingService; private final XmlHandlingService xmlHandlingService;
private final ErrorThesaurusProperties errors; private final ErrorThesaurusProperties errors;
public ReferenceTypeServiceImpl( public ReferenceTypeServiceImpl(
EntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory, EntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory,
ConventionService conventionService, MessageSource messageSource, QueryFactory queryFactory, ConventionService conventionService, MessageSource messageSource,
XmlHandlingService xmlHandlingService, ErrorThesaurusProperties errors) { XmlHandlingService xmlHandlingService, ErrorThesaurusProperties errors) {
this.entityManager = entityManager; this.entityManager = entityManager;
this.authorizationService = authorizationService; this.authorizationService = authorizationService;
@ -67,7 +66,6 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.conventionService = conventionService; this.conventionService = conventionService;
this.messageSource = messageSource; this.messageSource = messageSource;
this.queryFactory = queryFactory;
this.xmlHandlingService = xmlHandlingService; this.xmlHandlingService = xmlHandlingService;
this.errors = errors; this.errors = errors;
} }
@ -185,6 +183,13 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
data.setLabel(persist.getLabel()); data.setLabel(persist.getLabel());
data.setOrdinal(persist.getOrdinal()); data.setOrdinal(persist.getOrdinal());
if (!this.conventionService.isListNullOrEmpty(persist.getDependencies())){
data.setDependencies(new ArrayList<>());
for (ReferenceTypeSourceBaseDependencyPersist dependencyPersist: persist.getDependencies()) {
data.getDependencies().add(this.buildDependencyEntity(dependencyPersist));
}
}
return data; return data;
} }
@ -218,6 +223,7 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
AuthenticationConfigurationEntity data = new AuthenticationConfigurationEntity(); AuthenticationConfigurationEntity data = new AuthenticationConfigurationEntity();
if (persist == null) return data; if (persist == null) return data;
data.setEnabled(persist.getEnabled());
data.setAuthUrl(persist.getAuthUrl()); data.setAuthUrl(persist.getAuthUrl());
data.setAuthMethod(persist.getAuthMethod()); data.setAuthMethod(persist.getAuthMethod());
data.setAuthRequestBody(persist.getAuthRequestBody()); data.setAuthRequestBody(persist.getAuthRequestBody());
@ -249,6 +255,35 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
return data; return data;
} }
private @NotNull ReferenceTypeSourceBaseDependencyEntity buildDependencyEntity(ReferenceTypeSourceBaseDependencyPersist persist){
ReferenceTypeSourceBaseDependencyEntity data = new ReferenceTypeSourceBaseDependencyEntity();
if (persist == null) return data;
data.setReferenceTypeCode(persist.getReferenceTypeCode());
data.setKey(persist.getKey());
data.setRequired(persist.getRequired());
if (!this.conventionService.isListNullOrEmpty(persist.getProperties())){
data.setProperties(new ArrayList<>());
for (DependencyPropertyPersist propertyPersist: persist.getProperties()) {
data.getProperties().add(this.buildPropertyEntity(propertyPersist));
}
}
return data;
}
private @NotNull DependencyPropertyEntity buildPropertyEntity(DependencyPropertyPersist persist){
DependencyPropertyEntity data = new DependencyPropertyEntity();
if (persist == null) return data;
data.setCode(persist.getCode());
data.setTarget(persist.getTarget());
data.setRequired(persist.getRequired());
return data;
}
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException { public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
logger.debug("deleting : {}", id); logger.debug("deleting : {}", id);

View File

@ -1,10 +0,0 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.DmpDescriptionTemplateEntity;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.model.DmpDescriptionTemplate;
import java.util.UUID;
public interface DmpDatasetProfileDao extends DatabaseAccessLayer<DmpDescriptionTemplateEntity, UUID> {
}

View File

@ -1,53 +0,0 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.DmpDescriptionTemplateEntity;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.model.DmpDescriptionTemplate;
import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.management.InvalidApplicationException;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Service("dmpDatasetProfileDao")
public class DmpDatasetProfileDaoImpl extends DatabaseAccess<DmpDescriptionTemplateEntity> implements DmpDatasetProfileDao {
@Autowired
public DmpDatasetProfileDaoImpl(DatabaseService<DmpDescriptionTemplateEntity> databaseService) {
super(databaseService);
}
@Override
public DmpDescriptionTemplateEntity createOrUpdate(DmpDescriptionTemplateEntity item) {
return this.getDatabaseService().createOrUpdate(item, DmpDescriptionTemplateEntity.class);
}
@Override
@Async
public CompletableFuture<DmpDescriptionTemplateEntity> createOrUpdateAsync(DmpDescriptionTemplateEntity item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
}
@Override
public DmpDescriptionTemplateEntity find(UUID id) throws InvalidApplicationException {
return this.getDatabaseService().getQueryable(DmpDescriptionTemplateEntity.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
}
@Override
public DmpDescriptionTemplateEntity find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
@Override
public void delete(DmpDescriptionTemplateEntity item) {
this.getDatabaseService().delete(item);
}
@Override
public QueryableList<DmpDescriptionTemplateEntity> asQueryable() {
return this.getDatabaseService().getQueryable(DmpDescriptionTemplateEntity.class);
}
}

View File

@ -1,12 +0,0 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.UserDescriptionTemplateEntity;
import eu.eudat.data.dao.DatabaseAccessLayer;
import java.util.UUID;
/**
* Created by ikalyvas on 2/8/2018.
*/
public interface UserDatasetProfileDao extends DatabaseAccessLayer<UserDescriptionTemplateEntity, UUID> {
}

View File

@ -1,53 +0,0 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.UserDescriptionTemplateEntity;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import javax.management.InvalidApplicationException;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Component("userDatasetProfileDao")
public class UserDatasetProfileDaoImpl extends DatabaseAccess<UserDescriptionTemplateEntity> implements UserDatasetProfileDao {
@Autowired
public UserDatasetProfileDaoImpl(DatabaseService<UserDescriptionTemplateEntity> databaseService) {
super(databaseService);
}
@Override
public UserDescriptionTemplateEntity createOrUpdate(UserDescriptionTemplateEntity item) {
return this.getDatabaseService().createOrUpdate(item, UserDescriptionTemplateEntity.class);
}
@Override
public UserDescriptionTemplateEntity find(UUID id) throws InvalidApplicationException {
return this.getDatabaseService().getQueryable(UserDescriptionTemplateEntity.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingleOrDefault();
}
@Override
public void delete(UserDescriptionTemplateEntity item) {
this.getDatabaseService().delete(item);
}
@Override
public QueryableList<UserDescriptionTemplateEntity> asQueryable() {
return this.getDatabaseService().getQueryable(UserDescriptionTemplateEntity.class);
}
@Async
@Override
public CompletableFuture<UserDescriptionTemplateEntity> createOrUpdateAsync(UserDescriptionTemplateEntity item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
}
@Override
public UserDescriptionTemplateEntity find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
}

View File

@ -1,12 +0,0 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.DmpUserEntity;
import eu.eudat.data.dao.DatabaseAccessLayer;
import java.util.UUID;
/**
* Created by ikalyvas on 2/8/2018.
*/
public interface UserDmpDao extends DatabaseAccessLayer<DmpUserEntity, UUID> {
}

View File

@ -1,56 +0,0 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.DmpUserEntity;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import javax.management.InvalidApplicationException;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
/**
* Created by ikalyvas on 2/8/2018.
*/
@Component("userDmpDao")
public class UserDmpDaoImpl extends DatabaseAccess<DmpUserEntity> implements UserDmpDao {
@Autowired
public UserDmpDaoImpl(DatabaseService<DmpUserEntity> databaseService) {
super(databaseService);
}
@Override
public DmpUserEntity createOrUpdate(DmpUserEntity item) {
return this.getDatabaseService().createOrUpdate(item, DmpUserEntity.class);
}
@Override
public DmpUserEntity find(UUID id) throws InvalidApplicationException {
return this.getDatabaseService().getQueryable(DmpUserEntity.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingleOrDefault();
}
@Override
public void delete(DmpUserEntity item) {
this.getDatabaseService().delete(item);
}
@Override
public QueryableList<DmpUserEntity> asQueryable() {
return this.getDatabaseService().getQueryable(DmpUserEntity.class);
}
@Async
@Override
public CompletableFuture<DmpUserEntity> createOrUpdateAsync(DmpUserEntity item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
}
@Override
public DmpUserEntity find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
}

View File

@ -1,15 +0,0 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.dao.criteria.UserInfoCriteria;
import eu.eudat.data.UserEntity;
import eu.eudat.queryable.QueryableList;
import java.util.UUID;
public interface UserInfoDao extends DatabaseAccessLayer<UserEntity, UUID> {
QueryableList<UserEntity> getWithCriteria(UserInfoCriteria criteria);
QueryableList<UserEntity> getAuthenticated(QueryableList<UserEntity> users, UUID principalId);
}

View File

@ -1,82 +0,0 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.criteria.UserInfoCriteria;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.UserEntity;
import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import javax.management.InvalidApplicationException;
import java.util.Arrays;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Component("userInfoDao")
public class UserInfoDaoImpl extends DatabaseAccess<UserEntity> implements UserInfoDao {
@Autowired
public UserInfoDaoImpl(DatabaseService<UserEntity> databaseService) {
super(databaseService);
}
@Override
public QueryableList<UserEntity> getWithCriteria(UserInfoCriteria criteria) {
QueryableList<UserEntity> users = this.getDatabaseService().getQueryable(UserEntity.class);
users.where(((builder, root) -> builder.equal(root.get("userStatus"), 0)));
if (criteria.getAppRoles() != null && !criteria.getAppRoles().isEmpty())
users.where((builder, root) -> root.join("userRoles").get("role").in(criteria.getAppRoles()));
if (criteria.getLike() != null)
users.where((builder, root) -> builder.or(builder.like(builder.upper(root.get("name")), "%" + criteria.getLike().toUpperCase() + "%"), builder.like(root.get("email"), "%" + criteria.getLike() + "%")));
if (criteria.getEmail() != null)
users.where((builder, root) -> builder.equal(root.get("email"), criteria.getEmail()));
if (criteria.getCollaboratorLike() != null)
users.where((builder, root) -> builder.or(builder.like(builder.upper(root.get("name")), "%" + criteria.getCollaboratorLike().toUpperCase() + "%"), builder.like(root.get("email"), "%" + criteria.getCollaboratorLike() + "%")));
return users;
}
@Override
public QueryableList<UserEntity> getAuthenticated(QueryableList<UserEntity> users, UUID principalId) {
users.initSubQuery(UUID.class).where((builder, root) ->
builder.and(root.join("dmps").get("id").in(
users.subQuery((builder1, root1) -> builder1.equal(root1.get("id"), principalId),
Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmps:id")))),
builder.notEqual(root.get("id"), principalId)));
return users;
}
@Override
public UserEntity createOrUpdate(UserEntity item) {
return this.getDatabaseService().createOrUpdate(item, UserEntity.class);
}
@Override
public UserEntity find(UUID id) throws InvalidApplicationException {
return this.getDatabaseService().getQueryable(UserEntity.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
}
@Override
public void delete(UserEntity item) {
this.getDatabaseService().delete(item);
}
@Override
public QueryableList<UserEntity> asQueryable() {
return this.getDatabaseService().getQueryable(UserEntity.class);
}
@Async
@Override
public CompletableFuture<UserEntity> createOrUpdateAsync(UserEntity item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
}
@Override
public UserEntity find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
}

View File

@ -1,19 +0,0 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.dao.criteria.UserRoleCriteria;
import eu.eudat.data.UserEntity;
import eu.eudat.data.UserRoleEntity;
import eu.eudat.queryable.QueryableList;
import javax.management.InvalidApplicationException;
import java.util.List;
import java.util.UUID;
public interface UserRoleDao extends DatabaseAccessLayer<UserRoleEntity, UUID> {
QueryableList<UserRoleEntity> getWithCriteria(UserRoleCriteria criteria);
List<UserRoleEntity> getUserRoles(UserEntity userInfo) throws InvalidApplicationException;
}

View File

@ -1,72 +0,0 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.criteria.UserRoleCriteria;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.UserEntity;
import eu.eudat.data.UserRoleEntity;
import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import javax.management.InvalidApplicationException;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Component("userRoleDao")
public class UserRoleDaoImpl extends DatabaseAccess<UserRoleEntity> implements UserRoleDao {
@Autowired
public UserRoleDaoImpl(DatabaseService<UserRoleEntity> databaseService) {
super(databaseService);
}
@Override
public UserRoleEntity createOrUpdate(UserRoleEntity item) {
return this.getDatabaseService().createOrUpdate(item, UserRoleEntity.class);
}
@Override
public UserRoleEntity find(UUID id) throws InvalidApplicationException {
return this.getDatabaseService().getQueryable(UserRoleEntity.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingleOrDefault();
}
@Override
public List<UserRoleEntity> getUserRoles(UserEntity userInfo) throws InvalidApplicationException {
return this.getDatabaseService().getQueryable(UserRoleEntity.class).where((builder, root) -> builder.equal(root.get("userInfo"), userInfo)).toList();
}
@Override
public void delete(UserRoleEntity item) {
this.getDatabaseService().delete(item);
}
@Override
public QueryableList<UserRoleEntity> getWithCriteria(UserRoleCriteria criteria) {
QueryableList<UserRoleEntity> query = this.getDatabaseService().getQueryable(UserRoleEntity.class);
if (criteria.getLike() != null)
query.where((builder, root) -> builder.equal(root.get("userInfo").get("name"), criteria.getLike()));
if (criteria.getAppRoles() != null && !criteria.getAppRoles().isEmpty())
query.where((builder, root) -> root.get("role").in(criteria.getAppRoles()));
return query;
}
@Override
public QueryableList<UserRoleEntity> asQueryable() {
return this.getDatabaseService().getQueryable(UserRoleEntity.class);
}
@Async
@Override
public CompletableFuture<UserRoleEntity> createOrUpdateAsync(UserRoleEntity item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
}
@Override
public UserRoleEntity find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
}

View File

@ -1,13 +0,0 @@
package eu.eudat.data.dao.entities.security;
import eu.eudat.data.UserCredentialEntity;
import eu.eudat.data.dao.DatabaseAccessLayer;
import javax.management.InvalidApplicationException;
import java.util.UUID;
public interface CredentialDao extends DatabaseAccessLayer<UserCredentialEntity, UUID> {
UserCredentialEntity getLoggedInCredentials(String username, String secret, Integer provider) throws InvalidApplicationException;
}

View File

@ -1,62 +0,0 @@
package eu.eudat.data.dao.entities.security;
import eu.eudat.data.UserCredentialEntity;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.management.InvalidApplicationException;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Component("credentialDao")
public class CredentialDaoImpl extends DatabaseAccess<UserCredentialEntity> implements CredentialDao {
@Autowired
public CredentialDaoImpl(DatabaseService<UserCredentialEntity> databaseService) {
super(databaseService);
}
@Override
public UserCredentialEntity createOrUpdate(UserCredentialEntity item) {
return this.getDatabaseService().createOrUpdate(item, UserCredentialEntity.class);
}
@Override
public UserCredentialEntity find(UUID id) throws InvalidApplicationException {
return this.getDatabaseService().getQueryable(UserCredentialEntity.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingleOrDefault();
}
@Override
public UserCredentialEntity getLoggedInCredentials(String username, String secret, Integer provider) throws InvalidApplicationException {
return this.getDatabaseService().getQueryable(UserCredentialEntity.class).where(((builder, root) ->
builder.and(
builder.equal(root.get("publicValue"), username),
builder.equal(root.get("secret"), secret),
builder.equal(root.get("provider"), provider)
))).getSingleOrDefault();
}
@Override
public void delete(UserCredentialEntity item) {
this.getDatabaseService().delete(item);
}
@Override
public QueryableList<UserCredentialEntity> asQueryable() {
return this.getDatabaseService().getQueryable(UserCredentialEntity.class);
}
@Override
public CompletableFuture<UserCredentialEntity> createOrUpdateAsync(UserCredentialEntity item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
}
@Override
public UserCredentialEntity find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
}

View File

@ -1,21 +0,0 @@
package eu.eudat.data.query.items.item.userinfo;
import eu.eudat.data.dao.criteria.UserInfoCriteria;
import eu.eudat.data.UserEntity;
import eu.eudat.data.query.definition.Query;
import eu.eudat.queryable.QueryableList;
public class UserInfoRequestItem extends Query<UserInfoCriteria, UserEntity> {
@Override
public QueryableList<UserEntity> applyCriteria() {
QueryableList<UserEntity> users = this.getQuery();
if (this.getCriteria().getAppRoles() != null && !this.getCriteria().getAppRoles().isEmpty())
users.where((builder, root) -> root.join("userRoles").get("role").in(this.getCriteria().getAppRoles()));
if (this.getCriteria().getLike() != null)
users.where((builder, root) -> builder.or(builder.like(builder.upper(root.get("name")), "%" + this.getCriteria().getLike().toUpperCase() + "%"), builder.like(root.get("email"), "%" + this.getCriteria().getLike() + "%")));
if (this.getCriteria().getEmail() != null)
users.where((builder, root) -> builder.equal(root.get("email"), this.getCriteria().getEmail()));
return users;
}
}

View File

@ -1,29 +0,0 @@
package eu.eudat.data.query.items.table.userinfo;
import eu.eudat.data.dao.criteria.UserInfoCriteria;
import eu.eudat.data.UserEntity;
import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.queryable.QueryableList;
import java.util.UUID;
public class UserInfoTableRequestItem extends TableQuery<UserInfoCriteria, UserEntity, UUID> {
@Override
public QueryableList<UserEntity> applyCriteria() {
QueryableList<UserEntity> users = this.getQuery();
if (this.getCriteria().getAppRoles() != null && !this.getCriteria().getAppRoles().isEmpty())
users.where((builder, root) -> root.join("userRoles").get("role").in(this.getCriteria().getAppRoles()));
if (this.getCriteria().getLike() != null)
users.where((builder, root) -> builder.or(builder.like(builder.upper(root.get("name")), "%" + this.getCriteria().getLike().toUpperCase() + "%"), builder.like(root.get("email"), "%" + this.getCriteria().getLike() + "%")));
if (this.getCriteria().getEmail() != null)
users.where((builder, root) -> builder.equal(root.get("email"), this.getCriteria().getEmail()));
return users;
}
@Override
public QueryableList<UserEntity> applyPaging(QueryableList<UserEntity> items) {
return null;
}
}

View File

@ -23,7 +23,7 @@ public class DMPQuery extends Query<DmpEntity, UUID> {
private String label; private String label;
private int version; private int version;
private GrantQuery grantQuery; private GrantQuery grantQuery;
private UserQueryOld userQuery; // private UserQueryOld userQuery;
private DatasetQuery datasetQuery; private DatasetQuery datasetQuery;
private List<Integer> statuses; private List<Integer> statuses;
private Date created; private Date created;
@ -101,13 +101,13 @@ public class DMPQuery extends Query<DmpEntity, UUID> {
this.modified = modified; this.modified = modified;
} }
public UserQueryOld getUserQuery() { // public UserQueryOld getUserQuery() {
return userQuery; // return userQuery;
} // }
//
public void setUserQuery(UserQueryOld userQuery) { // public void setUserQuery(UserQueryOld userQuery) {
this.userQuery = userQuery; // this.userQuery = userQuery;
} // }
public DatasetQuery getDatasetQuery() { public DatasetQuery getDatasetQuery() {
return datasetQuery; return datasetQuery;
@ -129,10 +129,10 @@ public class DMPQuery extends Query<DmpEntity, UUID> {
if (this.getStatuses() != null && !this.getStatuses().isEmpty()) { if (this.getStatuses() != null && !this.getStatuses().isEmpty()) {
query.where((builder, root) -> root.get("status").in(this.getStatuses())); query.where((builder, root) -> root.get("status").in(this.getStatuses()));
} }
if (this.userQuery != null) { // if (this.userQuery != null) {
Subquery<UserEntity> userInfoSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id"))); // Subquery<UserEntity> userInfoSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
query.where((builder, root) -> root.get("creator").get("id").in(userInfoSubQuery)); // query.where((builder, root) -> root.get("creator").get("id").in(userInfoSubQuery));
} // }
if(this.datasetQuery != null){ if(this.datasetQuery != null){
Subquery<DescriptionEntity> datasetSubQuery = this.datasetQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:id"))); Subquery<DescriptionEntity> datasetSubQuery = this.datasetQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:id")));
query.where((builder, root) -> root.get("id").in(datasetSubQuery )); query.where((builder, root) -> root.get("id").in(datasetSubQuery ));

View File

@ -1,14 +0,0 @@
package eu.eudat.query;
public class DatasetProfileQuery {
private UserQueryOld userQuery;
public UserQueryOld getUserQuery() {
return userQuery;
}
public void setUserQuery(UserQueryOld userQuery) {
this.userQuery = userQuery;
}
}

View File

@ -23,7 +23,7 @@ public class GrantQuery extends Query<Grant, UUID> {
private List<Integer> statuses; private List<Integer> statuses;
private Date created; private Date created;
private Date modified; private Date modified;
private UserQueryOld userQuery; // private UserQueryOld userQuery;
public GrantQuery(DatabaseAccessLayer<Grant, UUID> databaseAccessLayer) { public GrantQuery(DatabaseAccessLayer<Grant, UUID> databaseAccessLayer) {
super(databaseAccessLayer); super(databaseAccessLayer);
@ -81,13 +81,13 @@ public class GrantQuery extends Query<Grant, UUID> {
this.modified = modified; this.modified = modified;
} }
public UserQueryOld getUserQuery() { // public UserQueryOld getUserQuery() {
return userQuery; // return userQuery;
} // }
//
public void setUserQuery(UserQueryOld userQuery) { // public void setUserQuery(UserQueryOld userQuery) {
this.userQuery = userQuery; // this.userQuery = userQuery;
} // }
@Override @Override
public QueryableList<Grant> getQuery() throws InvalidApplicationException { public QueryableList<Grant> getQuery() throws InvalidApplicationException {
@ -98,10 +98,10 @@ public class GrantQuery extends Query<Grant, UUID> {
query.where((builder, root) -> root.get("id").in(this.ids)); query.where((builder, root) -> root.get("id").in(this.ids));
if (this.getStatuses() != null && !this.getStatuses().isEmpty()) if (this.getStatuses() != null && !this.getStatuses().isEmpty())
query.where((builder, root) -> root.get("status").in(this.getStatuses())); query.where((builder, root) -> root.get("status").in(this.getStatuses()));
if (this.userQuery != null) { // if (this.userQuery != null) {
Subquery<UserEntity> userInfoSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id"))); // Subquery<UserEntity> userInfoSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
query.where((builder, root) -> root.get("creationUser").get("id").in(userInfoSubQuery)); // query.where((builder, root) -> root.get("creationUser").get("id").in(userInfoSubQuery));
} // }
if (!this.getSelectionFields().isEmpty() && this.getSelectionFields() != null) { if (!this.getSelectionFields().isEmpty() && this.getSelectionFields() != null) {
query.withFields(this.getSelectionFields()); query.withFields(this.getSelectionFields());
} }

View File

@ -19,7 +19,7 @@ public class LockQuery extends Query<Lock, UUID> {
private UUID id; private UUID id;
private UUID target; private UUID target;
private UserQueryOld userQuery; // private UserQueryOld userQuery;
private Date touchedAt; private Date touchedAt;
public UUID getId() { public UUID getId() {
@ -38,13 +38,13 @@ public class LockQuery extends Query<Lock, UUID> {
this.target = target; this.target = target;
} }
public UserQueryOld getUserQuery() { // public UserQueryOld getUserQuery() {
return userQuery; // return userQuery;
} // }
//
public void setUserQuery(UserQueryOld userQuery) { // public void setUserQuery(UserQueryOld userQuery) {
this.userQuery = userQuery; // this.userQuery = userQuery;
} // }
public Date getTouchedAt() { public Date getTouchedAt() {
return touchedAt; return touchedAt;
@ -71,10 +71,10 @@ public class LockQuery extends Query<Lock, UUID> {
if (this.target != null) { if (this.target != null) {
query.where(((builder, root) -> builder.equal(root.get("target"), this.target))); query.where(((builder, root) -> builder.equal(root.get("target"), this.target)));
} }
if (this.userQuery != null) { // if (this.userQuery != null) {
Subquery<UserEntity> userSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id"))); // Subquery<UserEntity> userSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
query.where((builder, root) -> root.get("lockedBy").get("id").in(userSubQuery)); // query.where((builder, root) -> root.get("lockedBy").get("id").in(userSubQuery));
} // }
return query; return query;
} }
} }

View File

@ -1,37 +0,0 @@
package eu.eudat.query;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.UserEntity;
import eu.eudat.queryable.QueryableList;
import java.util.List;
import java.util.UUID;
public class UserQueryOld extends Query<UserEntity, UUID> {
private UUID id;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public UserQueryOld(DatabaseAccessLayer<UserEntity, UUID> databaseAccessLayer) {
super(databaseAccessLayer);
}
public UserQueryOld(DatabaseAccessLayer<UserEntity, UUID> databaseAccessLayer, List<String> selectionFields) {
super(databaseAccessLayer, selectionFields);
}
@Override
public QueryableList<UserEntity> getQuery() {
QueryableList<UserEntity> query = this.databaseAccessLayer.asQueryable();
if (this.id != null)
query.where((builder, root) -> builder.equal(root.get("id"), this.id));
return query;
}
}

View File

@ -17,6 +17,7 @@ import eu.eudat.logic.managers.DataManagementPlanManager;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader; import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository; import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.model.DmpUser;
import eu.eudat.model.file.FileEnvelope; import eu.eudat.model.file.FileEnvelope;
import eu.eudat.utilities.pdf.PDFUtils; import eu.eudat.utilities.pdf.PDFUtils;
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel; import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
@ -27,7 +28,6 @@ import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.listingmodels.DataManagementPlanListingModel; import eu.eudat.models.data.listingmodels.DataManagementPlanListingModel;
import eu.eudat.models.data.listingmodels.DataManagementPlanOverviewModel; import eu.eudat.models.data.listingmodels.DataManagementPlanOverviewModel;
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
import eu.eudat.models.data.listingmodels.VersionListingModel; import eu.eudat.models.data.listingmodels.VersionListingModel;
import eu.eudat.query.DMPQuery; import eu.eudat.query.DMPQuery;
import eu.eudat.types.ApiMessageCode; import eu.eudat.types.ApiMessageCode;
@ -353,7 +353,7 @@ public class DMPs extends BaseController {
@RequestMapping(method = RequestMethod.POST, value = {"/updateusers/{id}"}) @RequestMapping(method = RequestMethod.POST, value = {"/updateusers/{id}"})
public ResponseEntity<ResponseItem<DmpEntity>> updateUsers(@PathVariable String id, @RequestBody List<UserInfoListingModel> users) { public ResponseEntity<ResponseItem<DmpEntity>> updateUsers(@PathVariable String id, @RequestBody List<DmpUser> users) {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole); this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
try { try {

View File

@ -5,7 +5,6 @@ import eu.eudat.exceptions.emailconfirmation.HasConfirmedEmailException;
import eu.eudat.exceptions.emailconfirmation.TokenExpiredException; import eu.eudat.exceptions.emailconfirmation.TokenExpiredException;
import eu.eudat.logic.managers.MergeEmailConfirmationManager; import eu.eudat.logic.managers.MergeEmailConfirmationManager;
import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.userinfo.UserMergeRequestModel;
import eu.eudat.types.ApiMessageCode; import eu.eudat.types.ApiMessageCode;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -48,19 +47,19 @@ public class EmailMergeConfirmation {
} }
} }
@Transactional // @Transactional
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") // @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public @ResponseBody // public @ResponseBody
ResponseEntity sendConfirmatioEmail(@RequestBody UserMergeRequestModel requestModel) { // ResponseEntity sendConfirmatioEmail(@RequestBody UserMergeRequestModel requestModel) {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole); // this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
try { // try {
this.emailConfirmationManager.sendConfirmationEmail(requestModel.getEmail(), requestModel.getUserId(), requestModel.getProvider()); // this.emailConfirmationManager.sendConfirmationEmail(requestModel.getEmail(), requestModel.getUserId(), requestModel.getProvider());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE)); // return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE));
} catch (Exception ex) { // } catch (Exception ex) {
if (ex instanceof HasConfirmedEmailException) { // if (ex instanceof HasConfirmedEmailException) {
return ResponseEntity.status(HttpStatus.FOUND).body(new ResponseItem().status(ApiMessageCode.WARN_MESSAGE)); // return ResponseEntity.status(HttpStatus.FOUND).body(new ResponseItem().status(ApiMessageCode.WARN_MESSAGE));
} // }
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE)); // return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE));
} // }
} // }
} }

View File

@ -5,7 +5,6 @@ import eu.eudat.exceptions.emailconfirmation.HasConfirmedEmailException;
import eu.eudat.exceptions.emailconfirmation.TokenExpiredException; import eu.eudat.exceptions.emailconfirmation.TokenExpiredException;
import eu.eudat.logic.managers.UnlinkEmailConfirmationManager; import eu.eudat.logic.managers.UnlinkEmailConfirmationManager;
import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.userinfo.UserUnlinkRequestModel;
import eu.eudat.types.ApiMessageCode; import eu.eudat.types.ApiMessageCode;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -48,16 +47,16 @@ public class EmailUnlinkConfirmation {
} }
} }
@Transactional // @Transactional
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") // @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public @ResponseBody // public @ResponseBody
ResponseEntity<ResponseItem> sendUnlinkConfirmationEmail(@RequestBody UserUnlinkRequestModel requestModel) { // ResponseEntity<ResponseItem> sendUnlinkConfirmationEmail(@RequestBody UserUnlinkRequestModel requestModel) {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole); // this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
try { // try {
this.unlinkEmailConfirmationManager.sendConfirmationEmail(requestModel.getEmail(), requestModel.getUserId(), requestModel.getProvider()); // this.unlinkEmailConfirmationManager.sendConfirmationEmail(requestModel.getEmail(), requestModel.getUserId(), requestModel.getProvider());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE)); // return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE));
} catch (Exception ex) { // } catch (Exception ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message("Could not send unlink email.")); // return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message("Could not send unlink email."));
} // }
} // }
} }

View File

@ -1,12 +1,10 @@
package eu.eudat.controllers; package eu.eudat.controllers;
import eu.eudat.authorization.Permission; import eu.eudat.authorization.Permission;
import eu.eudat.data.query.items.item.userinfo.UserInfoRequestItem;
import eu.eudat.logic.managers.InvitationsManager; import eu.eudat.logic.managers.InvitationsManager;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.invitation.Invitation; import eu.eudat.models.data.invitation.Invitation;
import eu.eudat.models.data.userinfo.UserInfoInvitationModel;
import eu.eudat.types.ApiMessageCode; import eu.eudat.types.ApiMessageCode;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -57,14 +55,14 @@ public class UserInvitationController extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(dmpId)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(dmpId));
} }
@RequestMapping(method = RequestMethod.POST, value = {"/getUsers"}, consumes = "application/json", produces = "application/json") // @RequestMapping(method = RequestMethod.POST, value = {"/getUsers"}, consumes = "application/json", produces = "application/json")
public @ResponseBody // public @ResponseBody
// ResponseEntity<ResponseItem<List<UserInfoInvitationModel>>> getUsers() throws IllegalAccessException, InstantiationException { //// ResponseEntity<ResponseItem<List<UserInfoInvitationModel>>> getUsers() throws IllegalAccessException, InstantiationException {
ResponseEntity<ResponseItem<List<UserInfoInvitationModel>>> getUsers(@RequestBody UserInfoRequestItem userInfoRequestItem) throws IllegalAccessException, InstantiationException, InvalidApplicationException { // ResponseEntity<ResponseItem<List<UserInfoInvitationModel>>> getUsers(@RequestBody UserInfoRequestItem userInfoRequestItem) throws IllegalAccessException, InstantiationException, InvalidApplicationException {
// List<UserInfoInvitationModel> users = invitationsManager.getUsers(principal); //// List<UserInfoInvitationModel> users = invitationsManager.getUsers(principal);
this.authorizationService.authorizeForce(Permission.AuthenticatedRole); // this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
//
List<UserInfoInvitationModel> users = invitationsManager.getUsersWithCriteria(userInfoRequestItem); // List<UserInfoInvitationModel> users = invitationsManager.getUsersWithCriteria(userInfoRequestItem);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<UserInfoInvitationModel>>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(users)); // return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<UserInfoInvitationModel>>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(users));
} // }
} }

View File

@ -107,6 +107,25 @@ public class ReferenceTypeController extends BaseController {
return model; return model;
} }
@GetMapping("code/{code}")
public ReferenceType get(@PathVariable("code") String code, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
logger.debug(new MapLogEntry("retrieving" + ReferenceType.class.getSimpleName()).And("code", code).And("fields", fieldSet));
this.censorFactory.censor(ReferenceTypeCensor.class).censor(fieldSet, null);
ReferenceTypeQuery query = this.queryFactory.query(ReferenceTypeQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).codes(code);
ReferenceType model = this.builderFactory.builder(ReferenceTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
if (model == null)
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{code, Reference.class.getSimpleName()}, LocaleContextHolder.getLocale()));
this.auditService.track(AuditableAction.ReferenceType_Lookup, Map.ofEntries(
new AbstractMap.SimpleEntry<String, Object>("code", code),
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
));
return model;
}
@PostMapping("persist") @PostMapping("persist")
@Transactional @Transactional
public ReferenceType persist(@MyValidate @RequestBody ReferenceTypePersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, JsonProcessingException, InvalidApplicationException { public ReferenceType persist(@MyValidate @RequestBody ReferenceTypePersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, JsonProcessingException, InvalidApplicationException {

View File

@ -143,7 +143,7 @@ public class DMPCriteria {
DMPQuery dmpQuery = new DMPQuery(dao.getDmpDao(), fields); DMPQuery dmpQuery = new DMPQuery(dao.getDmpDao(), fields);
if (this.id != null) dmpQuery.setId(this.id.getValue()); if (this.id != null) dmpQuery.setId(this.id.getValue());
if (this.grant != null) dmpQuery.setGrantQuery(this.grant.buildQuery(dao)); if (this.grant != null) dmpQuery.setGrantQuery(this.grant.buildQuery(dao));
if (this.creator != null) dmpQuery.setUserQuery(this.creator.buildQuery(dao)); // if (this.creator != null) dmpQuery.setUserQuery(this.creator.buildQuery(dao));
if (this.dataset != null) dmpQuery.setDatasetQuery(this.dataset.buildQuery(dao)); if (this.dataset != null) dmpQuery.setDatasetQuery(this.dataset.buildQuery(dao));
return dmpQuery; return dmpQuery;
} }

View File

@ -103,7 +103,7 @@ public class GrantCriteria {
List<String> fields = this.buildFields(""); List<String> fields = this.buildFields("");
GrantQuery query = new GrantQuery(dao.getGrantDao(), fields); GrantQuery query = new GrantQuery(dao.getGrantDao(), fields);
query.setId(this.id.getValue()); query.setId(this.id.getValue());
if (this.creator != null) query.setUserQuery(this.creator.buildQuery(dao)); // if (this.creator != null) query.setUserQuery(this.creator.buildQuery(dao));
return query; return query;
} }
} }

View File

@ -7,7 +7,8 @@ import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.node.JsonNodeType; import com.fasterxml.jackson.databind.node.JsonNodeType;
import eu.eudat.criteria.entities.Criteria; import eu.eudat.criteria.entities.Criteria;
import eu.eudat.logic.services.operations.DatabaseRepository; import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.query.UserQueryOld; import eu.eudat.model.User;
import eu.eudat.query.UserQuery;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
@ -57,10 +58,10 @@ public class UserCriteria {
return new LinkedList<>(fields); return new LinkedList<>(fields);
} }
public UserQueryOld buildQuery(DatabaseRepository dao) { public UserQuery buildQuery(DatabaseRepository dao) {
List<String> fields = this.buildFields(""); List<String> fields = this.buildFields("");
UserQueryOld query = new UserQueryOld(dao.getUserInfoDao(), fields); // UserQuery query = new UserQuery(dao.getUserInfoDao(), fields);
if (this.id != null) query.setId(this.id.getValue()); // if (this.id != null) query.setId(this.id.getValue());
return query; return null;
} }
} }

View File

@ -7,6 +7,7 @@ import eu.eudat.model.UserContactInfo;
import eu.eudat.models.data.ContactEmail.ContactEmailModel; import eu.eudat.models.data.ContactEmail.ContactEmailModel;
import eu.eudat.models.data.ContactEmail.PublicContactEmailModel; import eu.eudat.models.data.ContactEmail.PublicContactEmailModel;
import eu.eudat.query.UserContactInfoQuery; import eu.eudat.query.UserContactInfoQuery;
import eu.eudat.query.UserQuery;
import eu.eudat.service.mail.SimpleMail; import eu.eudat.service.mail.SimpleMail;
import gr.cite.tools.data.query.Ordering; import gr.cite.tools.data.query.Ordering;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
@ -34,7 +35,7 @@ public class ContactEmailManager {
} }
public void sendContactEmail(ContactEmailModel contactEmailModel) throws MessagingException, InvalidApplicationException { public void sendContactEmail(ContactEmailModel contactEmailModel) throws MessagingException, InvalidApplicationException {
UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first();
SimpleMail mail = new SimpleMail(); SimpleMail mail = new SimpleMail();
UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId()); UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId());
query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal)); query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal));

View File

@ -27,6 +27,7 @@ import eu.eudat.exceptions.security.ForbiddenException;
import eu.eudat.exceptions.security.UnauthorisedException; import eu.eudat.exceptions.security.UnauthorisedException;
import eu.eudat.logic.builders.entity.UserInfoBuilder; import eu.eudat.logic.builders.entity.UserInfoBuilder;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader; import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.model.DmpUser;
import eu.eudat.model.mapper.deposit.DMPToDepositMapper; import eu.eudat.model.mapper.deposit.DMPToDepositMapper;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.forms.VisibilityRuleService; import eu.eudat.logic.services.forms.VisibilityRuleService;
@ -34,7 +35,7 @@ import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl;
import eu.eudat.logic.services.operations.DatabaseRepository; import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.commons.types.xml.XmlBuilder; import eu.eudat.commons.types.xml.XmlBuilder;
import eu.eudat.model.file.FileEnvelope; import eu.eudat.model.file.FileEnvelope;
import eu.eudat.query.DmpDescriptionTemplateQuery; import eu.eudat.query.*;
import eu.eudat.utilities.pdf.PDFUtils; import eu.eudat.utilities.pdf.PDFUtils;
import eu.eudat.logic.utilities.documents.types.ParagraphStyle; import eu.eudat.logic.utilities.documents.types.ParagraphStyle;
import eu.eudat.logic.utilities.documents.word.WordBuilder; import eu.eudat.logic.utilities.documents.word.WordBuilder;
@ -55,9 +56,6 @@ import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.listingmodels.*; import eu.eudat.models.data.listingmodels.*;
import eu.eudat.models.data.project.ProjectDMPEditorModel; import eu.eudat.models.data.project.ProjectDMPEditorModel;
import eu.eudat.models.data.user.composite.PagedDatasetProfile; import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.models.data.userinfo.UserListingModel;
import eu.eudat.query.DescriptionTemplateQuery;
import eu.eudat.query.DmpBlueprintQuery;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import eu.eudat.service.dmpblueprint.DmpBlueprintService; import eu.eudat.service.dmpblueprint.DmpBlueprintService;
import eu.eudat.types.MetricNames; import eu.eudat.types.MetricNames;
@ -275,7 +273,7 @@ public class DataManagementPlanManager {
QueryableList<DescriptionEntity> datasetItems = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetCriteria) QueryableList<DescriptionEntity> datasetItems = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetCriteria)
.orderBy((builder, root) -> builder.desc(root.get("modified"))); .orderBy((builder, root) -> builder.desc(root.get("modified")));
if (principal != null) { if (principal != null) {
UserEntity userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal); UserEntity userInfo = this.queryFactory.query(UserQuery.class).ids(principal).first();
List<Integer> roles = new ArrayList<>(); List<Integer> roles = new ArrayList<>();
roles.add(0); roles.add(0);
roles.add(1); roles.add(1);
@ -505,7 +503,7 @@ public class DataManagementPlanManager {
if (newDmp.getStatus().equals(DmpStatus.Finalized)) { if (newDmp.getStatus().equals(DmpStatus.Finalized)) {
checkDmpValidationRules(newDmp); checkDmpValidationRules(newDmp);
} }
UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first();
newDmp.setCreatorId(user.getId()); newDmp.setCreatorId(user.getId());
DmpBlueprintEntity dmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class).ids(newDmp.getBlueprintId()).first(); DmpBlueprintEntity dmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class).ids(newDmp.getBlueprintId()).first();
@ -535,15 +533,14 @@ public class DataManagementPlanManager {
newDmp.setCreatedAt(dmp.getCreatedAt() == null ? Instant.now() : dmp.getCreatedAt()); newDmp.setCreatedAt(dmp.getCreatedAt() == null ? Instant.now() : dmp.getCreatedAt());
DmpEntity finalNewDmp = newDmp; DmpEntity finalNewDmp = newDmp;
this.databaseRepository.getUserDmpDao().asQueryable().where((builder, root) -> root.get("dmp").in(finalNewDmp.getId())).toList(); if (this.queryFactory.query(DmpUserQuery.class).dmpIds(finalNewDmp.getId()).collect() != null &&
if (this.databaseRepository.getUserDmpDao().asQueryable().where((builder, root) -> root.get("dmp").in(finalNewDmp.getId())).toList()!= null && this.queryFactory.query(DmpUserQuery.class).dmpIds(finalNewDmp.getId()).collect().stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUserId()))
this.databaseRepository.getUserDmpDao().asQueryable().where((builder, root) -> root.get("dmp").in(finalNewDmp.getId())).toList().stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUserId()))
.collect(Collectors.toList()).size() == 0) { .collect(Collectors.toList()).size() == 0) {
List<DmpUserEntity> userDMPList = new ArrayList<>(this.databaseRepository.getUserDmpDao().asQueryable().where((builder, root) -> root.get("dmp").in(finalNewDmp.getId())).toList()); List<DmpUserEntity> userDMPList = new ArrayList<>(this.queryFactory.query(DmpUserQuery.class).dmpIds(finalNewDmp.getId()).collect());
for (UserInfoListingModel userInfoListingModel : dataManagementPlan.getUsers()) { for (DmpUser userInfoListingModel : dataManagementPlan.getUsers()) {
for (DmpUserEntity userDMP : userDMPList) { for (DmpUserEntity userDMP : userDMPList) {
if (!(userDMP.getUserId().equals(userInfoListingModel.getId()))) { if (!(userDMP.getUserId().equals(userInfoListingModel.getId()))) {
apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().delete(userDMP); // apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().delete(userDMP);
} }
} }
} }
@ -581,9 +578,9 @@ public class DataManagementPlanManager {
if (dataManagementPlan.getUsers() != null && !dataManagementPlan.getUsers().isEmpty()) { if (dataManagementPlan.getUsers() != null && !dataManagementPlan.getUsers().isEmpty()) {
clearUsers(newDmp); clearUsers(newDmp);
for (UserInfoListingModel userListing : dataManagementPlan.getUsers()) { for (DmpUser userListing : dataManagementPlan.getUsers()) {
UserEntity tempUser = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userListing.getId()); UserEntity tempUser = this.queryFactory.query(UserQuery.class).ids(userListing.getId()).first();
assignUser(dmp, tempUser, DmpUserRole.of((short)userListing.getRole())); assignUser(dmp, tempUser, userListing.getRole());
} }
} }
@ -621,8 +618,8 @@ public class DataManagementPlanManager {
} }
} }
if (dataManagementPlan.getAssociatedUsers().size() == 0) // if (dataManagementPlan.getAssociatedUsers().size() == 0)
assignUser(newDmp, user); // assignUser(newDmp, user);
UUID dmpId = newDmp.getId(); UUID dmpId = newDmp.getId();
//TODO //TODO
@ -668,7 +665,7 @@ public class DataManagementPlanManager {
if (tempDMP.getStatus().equals(DmpStatus.Finalized)) { if (tempDMP.getStatus().equals(DmpStatus.Finalized)) {
checkDmpValidationRules(tempDMP); checkDmpValidationRules(tempDMP);
} }
UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first();
DmpBlueprintEntity dmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class).ids(tempDMP.getBlueprintId()).first(); DmpBlueprintEntity dmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class).ids(tempDMP.getBlueprintId()).first();
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Organizations)) { if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Organizations)) {
@ -782,14 +779,13 @@ public class DataManagementPlanManager {
copyDatasets(newDmp, databaseRepository.getDatasetDao()); copyDatasets(newDmp, databaseRepository.getDatasetDao());
databaseRepository this.queryFactory.query(DmpUserQuery.class).dmpIds(oldDmp.getId()).collect()
.getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), oldDmp.getId())) .stream().forEach(userDMP -> {
.toList().stream().forEach(userDMP -> {
DmpUserEntity temp = new DmpUserEntity(); DmpUserEntity temp = new DmpUserEntity();
temp.setUserId(userDMP.getUserId()); temp.setUserId(userDMP.getUserId());
temp.setRole(userDMP.getRole()); temp.setRole(userDMP.getRole());
temp.setDmp(newDmp.getId()); temp.setDmp(newDmp.getId());
apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().createOrUpdate(temp); // apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().createOrUpdate(temp);
}); });
//TODO //TODO
@ -1230,7 +1226,7 @@ public class DataManagementPlanManager {
// } // }
// }); // });
}); });
UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first();
sendNotification(dmp, user, NotificationType.DMP_PUBLISH); sendNotification(dmp, user, NotificationType.DMP_PUBLISH);
} }
@ -1316,7 +1312,7 @@ public class DataManagementPlanManager {
UUID dmpId = dmp.getId(); UUID dmpId = dmp.getId();
// dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList())); //TODO // dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList())); //TODO
//this.updateIndex(dmp); //TODO //this.updateIndex(dmp); //TODO
UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first();
sendNotification(dmp, user, NotificationType.DMP_FINALISED); sendNotification(dmp, user, NotificationType.DMP_FINALISED);
metricsManager.decreaseValue(MetricNames.DMP, 1, MetricNames.DRAFT); metricsManager.decreaseValue(MetricNames.DMP, 1, MetricNames.DRAFT);
metricsManager.increaseValue(MetricNames.DMP, 1, MetricNames.FINALIZED); metricsManager.increaseValue(MetricNames.DMP, 1, MetricNames.FINALIZED);
@ -1344,14 +1340,14 @@ public class DataManagementPlanManager {
metricsManager.increaseValue(MetricNames.DMP, 1, MetricNames.DRAFT); metricsManager.increaseValue(MetricNames.DMP, 1, MetricNames.DRAFT);
} }
public void updateUsers(UUID id, List<UserInfoListingModel> users) throws Exception { public void updateUsers(UUID id, List<DmpUser> users) throws Exception {
DmpEntity dmp = this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(id); DmpEntity dmp = this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(id);
if (!isUserOwnerOfDmp(dmp)) if (!isUserOwnerOfDmp(dmp))
throw new Exception("User does not have the privilege to do this action."); throw new Exception("User does not have the privilege to do this action.");
clearUsers(dmp); clearUsers(dmp);
for (UserInfoListingModel userListing : users) { for (DmpUser userListing : users) {
UserEntity tempUser = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userListing.getId()); UserEntity tempUser = this.queryFactory.query(UserQuery.class).ids(userListing.getId()).first();
assignUser(dmp, tempUser, DmpUserRole.of((short)userListing.getRole())); assignUser(dmp, tempUser, userListing.getRole());
} }
} }
@ -1824,14 +1820,14 @@ public class DataManagementPlanManager {
Element dmpContactName = xmlDoc.createElement("name"); Element dmpContactName = xmlDoc.createElement("name");
Element dmpContactEmail = xmlDoc.createElement("email"); Element dmpContactEmail = xmlDoc.createElement("email");
if(dmp.getCreatorId() != null){ if(dmp.getCreatorId() != null){
dmpContactName.setTextContent(this.databaseRepository.getUserInfoDao().find(dmp.getCreatorId()).getName()); dmpContactName.setTextContent(this.queryFactory.query(UserQuery.class).ids(dmp.getCreatorId()).first().getName());
//TODO dmpContactEmail.setTextContent(this.databaseRepository.getUserInfoDao().find(dmp.getCreator()).getEmail()); //TODO dmpContactEmail.setTextContent(this.databaseRepository.getUserInfoDao().find(dmp.getCreator()).getEmail());
} }
else{ else{
Iterator<DmpUserEntity> users = new ArrayList<DmpUserEntity>().iterator(); //TODO dmp.getUsers().iterator(); Iterator<DmpUserEntity> users = new ArrayList<DmpUserEntity>().iterator(); //TODO dmp.getUsers().iterator();
if(users.hasNext()){ if(users.hasNext()){
DmpUserEntity creator = users.next(); DmpUserEntity creator = users.next();
dmpContactName.setTextContent(this.databaseRepository.getUserInfoDao().find(creator.getUserId()).getName()); dmpContactName.setTextContent(this.queryFactory.query(UserQuery.class).ids(creator.getUserId()).first().getName());
//TODO .setTextContent(this.databaseRepository.getUserInfoDao().find(creator.getUser()).getEmail()); //TODO .setTextContent(this.databaseRepository.getUserInfoDao().find(creator.getUser()).getEmail());
} }
} }
@ -1846,7 +1842,7 @@ public class DataManagementPlanManager {
Element dmpContributorName = xmlDoc.createElement("name"); Element dmpContributorName = xmlDoc.createElement("name");
Element dmpContributorEmail= xmlDoc.createElement("email"); Element dmpContributorEmail= xmlDoc.createElement("email");
DmpUserEntity contributor = users.next(); DmpUserEntity contributor = users.next();
dmpContributorName.setTextContent(this.databaseRepository.getUserInfoDao().find(contributor.getUserId()).getName()); dmpContributorName.setTextContent(this.queryFactory.query(UserQuery.class).ids(contributor.getUserId()).first().getName());
//TODO dmpContributorEmail.setTextContent(this.databaseRepository.getUserInfoDao().find(contributor.getUser()).getEmail()); //TODO dmpContributorEmail.setTextContent(this.databaseRepository.getUserInfoDao().find(contributor.getUser()).getEmail());
dmpContributorElement.appendChild(dmpContributorName); dmpContributorElement.appendChild(dmpContributorName);
dmpContributorElement.appendChild(dmpContributorEmail); dmpContributorElement.appendChild(dmpContributorEmail);
@ -2245,7 +2241,7 @@ public class DataManagementPlanManager {
researchers.add(researcher); researchers.add(researcher);
} }
List<UserListingModel> associatedUsers = new LinkedList<>(); //List<UserListingModel> associatedUsers = new LinkedList<>();
List<DynamicFieldWithValue> dynamicFields = new LinkedList<>(); List<DynamicFieldWithValue> dynamicFields = new LinkedList<>();
// Sets properties. // Sets properties.
@ -2254,7 +2250,7 @@ public class DataManagementPlanManager {
dm.setProfiles(associatedProfiles); dm.setProfiles(associatedProfiles);
dm.setOrganisations(organisations); // Sets organisations property. dm.setOrganisations(organisations); // Sets organisations property.
dm.setResearchers(researchers); // Sets researchers property. dm.setResearchers(researchers); // Sets researchers property.
dm.setAssociatedUsers(associatedUsers); // Sets associatedUsers property. //dm.setAssociatedUsers(associatedUsers); // Sets associatedUsers property.
dm.setDynamicFields(dynamicFields); // Sets dynamicFields property. dm.setDynamicFields(dynamicFields); // Sets dynamicFields property.
//dm.setDefinition(dmpProfile); //dm.setDefinition(dmpProfile);
//ObjectMapper mapper = new ObjectMapper(); //ObjectMapper mapper = new ObjectMapper();
@ -2328,7 +2324,7 @@ public class DataManagementPlanManager {
for (MultipartFile file: files) { for (MultipartFile file: files) {
DmpEntity dmp = rdaManager.convertToEntity(new String(file.getBytes(), "UTF-8"), profiles); DmpEntity dmp = rdaManager.convertToEntity(new String(file.getBytes(), "UTF-8"), profiles);
dmp.setLabel(file.getOriginalFilename()); dmp.setLabel(file.getOriginalFilename());
UserEntity me = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); UserEntity me = this.queryFactory.query(UserQuery.class).ids(dmp.getCreatorId()).first();
dmp.setUpdatedAt(Instant.now()); dmp.setUpdatedAt(Instant.now());
dmp.setCreatorId(me.getId()); dmp.setCreatorId(me.getId());
//TODO //TODO
@ -2410,12 +2406,12 @@ public class DataManagementPlanManager {
userDMP.setDmp(dmp.getId()); userDMP.setDmp(dmp.getId());
userDMP.setUserId(userInfo.getId()); userDMP.setUserId(userInfo.getId());
userDMP.setRole(role); userDMP.setRole(role);
databaseRepository.getUserDmpDao().createOrUpdate(userDMP); // databaseRepository.getUserDmpDao().createOrUpdate(userDMP);
} }
private void clearUsers(DmpEntity dmp) throws InvalidApplicationException { private void clearUsers(DmpEntity dmp) throws InvalidApplicationException {
List<DmpUserEntity> userDMPs = apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where(((builder, root) -> builder.equal(root.get("dmp").get("id"), dmp.getId()))).toList(); List<DmpUserEntity> userDMPs = this.queryFactory.query(DmpUserQuery.class).dmpIds(dmp.getId()).collect();
userDMPs.forEach(userDMP -> apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().delete(userDMP)); // userDMPs.forEach(userDMP -> apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().delete(userDMP));
} }
private void assignGrandUserIfInternal(DmpEntity dmp, UserEntity user) { private void assignGrandUserIfInternal(DmpEntity dmp, UserEntity user) {
@ -2681,7 +2677,7 @@ public class DataManagementPlanManager {
* */ * */
private void sendNotification(DmpEntity dmp, UserEntity user, NotificationType notificationType) throws InvalidApplicationException { private void sendNotification(DmpEntity dmp, UserEntity user, NotificationType notificationType) throws InvalidApplicationException {
List<DmpUserEntity> userDMPS = databaseRepository.getUserDmpDao().asQueryable().where(((builder, root) -> builder.equal(root.get("dmp").get("id"), dmp.getId()))).toList(); List<DmpUserEntity> userDMPS = this.queryFactory.query(DmpUserQuery.class).dmpIds(dmp.getId()).collect();
for (DmpUserEntity userDMP : userDMPS) { for (DmpUserEntity userDMP : userDMPS) {
if (!userDMP.getUserId().equals(user.getId())) { if (!userDMP.getUserId().equals(user.getId())) {
Notification notification = new Notification(); Notification notification = new Notification();

View File

@ -51,6 +51,7 @@ import eu.eudat.models.data.listingmodels.DatasetListingModel;
import eu.eudat.models.data.user.composite.PagedDatasetProfile; import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.query.DescriptionTemplateQuery; import eu.eudat.query.DescriptionTemplateQuery;
import eu.eudat.query.DmpDescriptionTemplateQuery; import eu.eudat.query.DmpDescriptionTemplateQuery;
import eu.eudat.query.DmpUserQuery;
import eu.eudat.query.UserContactInfoQuery; import eu.eudat.query.UserContactInfoQuery;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import eu.eudat.types.MetricNames; import eu.eudat.types.MetricNames;
@ -728,7 +729,7 @@ public class DatasetManager {
} }
private void sendNotification(DescriptionEntity descriptionEntity, DmpEntity dmp, UserEntity user, NotificationType notificationType) throws InvalidApplicationException { private void sendNotification(DescriptionEntity descriptionEntity, DmpEntity dmp, UserEntity user, NotificationType notificationType) throws InvalidApplicationException {
List<DmpUserEntity> userDMPS = databaseRepository.getUserDmpDao().asQueryable().where(((builder, root) -> builder.equal(root.get("dmp").get("id"), dmp.getId()))).toList(); List<DmpUserEntity> userDMPS = this.queryFactory.query(DmpUserQuery.class).dmpIds(dmp.getId()).collect();
for (DmpUserEntity userDMP : userDMPS) { for (DmpUserEntity userDMP : userDMPS) {
if (!userDMP.getUserId().equals(user.getId())) { if (!userDMP.getUserId().equals(user.getId())) {
Notification notification = new Notification(); Notification notification = new Notification();

View File

@ -1,13 +1,14 @@
package eu.eudat.logic.managers; package eu.eudat.logic.managers;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.UserCredentialEntity;
import eu.eudat.data.old.EmailConfirmation; import eu.eudat.data.old.EmailConfirmation;
import eu.eudat.data.UserEntity; import eu.eudat.data.UserEntity;
import eu.eudat.exceptions.emailconfirmation.HasConfirmedEmailException; import eu.eudat.exceptions.emailconfirmation.HasConfirmedEmailException;
import eu.eudat.exceptions.emailconfirmation.TokenExpiredException; import eu.eudat.exceptions.emailconfirmation.TokenExpiredException;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository; import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.query.UserQuery;
import gr.cite.tools.data.query.QueryFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -20,12 +21,14 @@ public class EmailConfirmationManager {
private ApiContext apiContext; private ApiContext apiContext;
private DatabaseRepository databaseRepository; private DatabaseRepository databaseRepository;
private final UserScope userScope; private final UserScope userScope;
private final QueryFactory queryFactory;
@Autowired @Autowired
public EmailConfirmationManager(ApiContext apiContext, UserScope userScope) { public EmailConfirmationManager(ApiContext apiContext, UserScope userScope, QueryFactory queryFactory) {
this.apiContext = apiContext; this.apiContext = apiContext;
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository(); this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
this.userScope = userScope; this.userScope = userScope;
this.queryFactory = queryFactory;
} }
public void confirmEmail(String token) throws TokenExpiredException, HasConfirmedEmailException, InvalidApplicationException { public void confirmEmail(String token) throws TokenExpiredException, HasConfirmedEmailException, InvalidApplicationException {
@ -33,8 +36,7 @@ public class EmailConfirmationManager {
.getDatabaseRepository().getLoginConfirmationEmailDao().asQueryable() .getDatabaseRepository().getLoginConfirmationEmailDao().asQueryable()
.where((builder, root) -> builder.equal(root.get("token"), UUID.fromString(token))).getSingle(); .where((builder, root) -> builder.equal(root.get("token"), UUID.fromString(token))).getSingle();
UserEntity user = databaseRepository.getUserInfoDao().asQueryable() UserEntity user = this.queryFactory.query(UserQuery.class).ids(loginConfirmationEmail.getUserId()).first();
.where((builder, root) -> builder.equal(root.get("id"), loginConfirmationEmail.getUserId())).getSingle();
// if (user.getEmail() != null) //TODO // if (user.getEmail() != null) //TODO
// throw new HasConfirmedEmailException("User already has confirmed his Email."); // throw new HasConfirmedEmailException("User already has confirmed his Email.");
@ -45,12 +47,12 @@ public class EmailConfirmationManager {
loginConfirmationEmail.setIsConfirmed(true); loginConfirmationEmail.setIsConfirmed(true);
// Checks if mail is used by another user. If it is, merges the new the old. // Checks if mail is used by another user. If it is, merges the new the old.
Long existingUsers = databaseRepository.getUserInfoDao().asQueryable().where((builder, root) -> builder.equal(root.get("email"), loginConfirmationEmail.getEmail())).count(); Long existingUsers = this.queryFactory.query(UserQuery.class).emails(loginConfirmationEmail.getEmail()).count();
if (existingUsers > 0) { if (existingUsers > 0) {
UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userId"), user.getId())).getSingle(); // UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userId"), user.getId())).getSingle();
// credential.setEmail(loginConfirmationEmail.getEmail()); //TODO // credential.setEmail(loginConfirmationEmail.getEmail()); //TODO
databaseRepository.getCredentialDao().createOrUpdate(credential); // databaseRepository.getCredentialDao().createOrUpdate(credential);
UserEntity oldUser = databaseRepository.getUserInfoDao().asQueryable().where((builder, root) -> builder.equal(root.get("email"), loginConfirmationEmail.getEmail())).getSingle(); UserEntity oldUser = this.queryFactory.query(UserQuery.class).emails(loginConfirmationEmail.getEmail()).first();
mergeNewUserToOld(user, oldUser); mergeNewUserToOld(user, oldUser);
// expireUserToken(user); //TODO: Authn // expireUserToken(user); //TODO: Authn
databaseRepository.getLoginConfirmationEmailDao().createOrUpdate(loginConfirmationEmail); databaseRepository.getLoginConfirmationEmailDao().createOrUpdate(loginConfirmationEmail);
@ -58,9 +60,9 @@ public class EmailConfirmationManager {
} }
// user.setEmail(loginConfirmationEmail.getEmail()); //TODO // user.setEmail(loginConfirmationEmail.getEmail()); //TODO
databaseRepository.getUserInfoDao().createOrUpdate(user); // databaseRepository.getUserInfoDao().createOrUpdate(user);
UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable() // UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable()
.where((builder, root) -> builder.equal(root.get("userId"), user.getId())).getSingle(); // .where((builder, root) -> builder.equal(root.get("userId"), user.getId())).getSingle();
// if(credential.getEmail() == null){//TODO // if(credential.getEmail() == null){//TODO
// credential.setEmail(user.getEmail()); // credential.setEmail(user.getEmail());
// databaseRepository.getCredentialDao().createOrUpdate(credential); // databaseRepository.getCredentialDao().createOrUpdate(credential);
@ -69,7 +71,7 @@ public class EmailConfirmationManager {
} }
public void sendConfirmationEmail(String email) throws HasConfirmedEmailException, InvalidApplicationException { public void sendConfirmationEmail(String email) throws HasConfirmedEmailException, InvalidApplicationException {
UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first();
// if (user.getEmail() != null) //TODO // if (user.getEmail() != null) //TODO
// throw new HasConfirmedEmailException("User already has confirmed his Email."); // throw new HasConfirmedEmailException("User already has confirmed his Email.");
@ -82,8 +84,8 @@ public class EmailConfirmationManager {
} }
private void mergeNewUserToOld(UserEntity newUser, UserEntity oldUser) throws InvalidApplicationException { private void mergeNewUserToOld(UserEntity newUser, UserEntity oldUser) throws InvalidApplicationException {
UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userId"), newUser.getId())).getSingle(); // UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userId"), newUser.getId())).getSingle();
credential.setUserId(oldUser.getId()); // credential.setUserId(oldUser.getId());
databaseRepository.getCredentialDao().createOrUpdate(credential); // databaseRepository.getCredentialDao().createOrUpdate(credential);
} }
} }

View File

@ -5,11 +5,10 @@ import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.DmpEntity; import eu.eudat.data.DmpEntity;
import eu.eudat.data.DmpUserEntity; import eu.eudat.data.DmpUserEntity;
import eu.eudat.data.UserEntity; import eu.eudat.data.UserEntity;
import eu.eudat.data.query.items.item.userinfo.UserInfoRequestItem;
import eu.eudat.exceptions.security.UnauthorisedException; import eu.eudat.exceptions.security.UnauthorisedException;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.model.User;
import eu.eudat.models.data.invitation.Invitation; import eu.eudat.models.data.invitation.Invitation;
import eu.eudat.models.data.userinfo.UserInfoInvitationModel;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -49,8 +48,8 @@ public class InvitationsManager {
item.setId(existingUser.getId()); item.setId(existingUser.getId());
} }
}); });
List<UserInfoInvitationModel> alreadySignedInUsers = invitation.getUsers().stream().filter(item -> item.getId() != null).collect(Collectors.toList()); List<User> alreadySignedInUsers = invitation.getUsers().stream().filter(item -> item.getId() != null).collect(Collectors.toList());
List<UserEntity> alreadySignedInUsersEntities = alreadySignedInUsers.stream().map(UserInfoInvitationModel::toDataModel).collect(Collectors.toList()); List<UserEntity> alreadySignedInUsersEntities = new ArrayList<>(); //alreadySignedInUsers.stream().map(User::toDataModel).collect(Collectors.toList());
List<DmpUserEntity> userInfoToUserDmp = new LinkedList<>(); List<DmpUserEntity> userInfoToUserDmp = new LinkedList<>();
for (UserEntity userInfo : alreadySignedInUsersEntities) { for (UserEntity userInfo : alreadySignedInUsersEntities) {
DmpUserEntity userDMP = new DmpUserEntity(); DmpUserEntity userDMP = new DmpUserEntity();
@ -65,11 +64,11 @@ public class InvitationsManager {
}*/ }*/
} }
DmpEntity dataManagementPlan = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(invitation.getDataManagementPlan()); DmpEntity dataManagementPlan = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(invitation.getDataManagementPlan());
apiContext.getUtilitiesService().getInvitationService().createInvitations(apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao(), apiContext.getUtilitiesService().getMailService(), invitation.getUsers().stream().map(UserInfoInvitationModel::toDataModel).collect(Collectors.toList()), dataManagementPlan, invitation.getRole(), principalUser); // apiContext.getUtilitiesService().getInvitationService().createInvitations(apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao(), apiContext.getUtilitiesService().getMailService(), invitation.getUsers().stream().map(UserInfoInvitationModel::toDataModel).collect(Collectors.toList()), dataManagementPlan, invitation.getRole(), principalUser);
apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), userInfoToUserDmp, dataManagementPlan); apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), userInfoToUserDmp, dataManagementPlan);
} }
public List<UserInfoInvitationModel> getUsers() throws InstantiationException, IllegalAccessException, InvalidApplicationException { public List<User> getUsers() throws InstantiationException, IllegalAccessException, InvalidApplicationException {
/*UserInfo principalUser = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId()); /*UserInfo principalUser = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
List<UserInfo> users = apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().getAssociated(principalUser).stream().map(userAssociation -> { List<UserInfo> users = apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().getAssociated(principalUser).stream().map(userAssociation -> {
if (userAssociation.getFirstUser().getId().equals(principal.getId())) { if (userAssociation.getFirstUser().getId().equals(principal.getId())) {
@ -85,28 +84,28 @@ public class InvitationsManager {
// .where(((builder, root) -> builder.notEqual(root.get("isActive"), IsActive.Inactive))), this.userScope.getUserId(), Stream.of(0, 1).collect(Collectors.toList())) // .where(((builder, root) -> builder.notEqual(root.get("isActive"), IsActive.Inactive))), this.userScope.getUserId(), Stream.of(0, 1).collect(Collectors.toList()))
// .toList().stream().map(DmpEntity::getUsers).flatMap(Collection::stream).map(DmpUser::getUser) // .toList().stream().map(DmpEntity::getUsers).flatMap(Collection::stream).map(DmpUser::getUser)
// .filter(userInfo -> !userInfo.getId().equals(this.userScope.getUserIdSafe())).filter(StreamDistinctBy.distinctByKey(UserInfo::getId)).collect(Collectors.toList()); // .filter(userInfo -> !userInfo.getId().equals(this.userScope.getUserIdSafe())).filter(StreamDistinctBy.distinctByKey(UserInfo::getId)).collect(Collectors.toList());
List<UserInfoInvitationModel> userModels = users.stream().map(userInfo -> new UserInfoInvitationModel().fromDataModel(userInfo)).collect(Collectors.toList()); List<User> userModels = new ArrayList<>(); //users.stream().map(userInfo -> new User().fromDataModel(userInfo)).collect(Collectors.toList());
return userModels; return userModels;
} }
public List<UserInfoInvitationModel> getUsersWithCriteria(UserInfoRequestItem userInfoRequestItem) throws IllegalAccessException, InstantiationException, InvalidApplicationException { // public List<UserInfoInvitationModel> getUsersWithCriteria(UserInfoRequestItem userInfoRequestItem) throws IllegalAccessException, InstantiationException, InvalidApplicationException {
//TODO // //TODO
// List<UserInfo> users = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao() //// List<UserInfo> users = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao()
// .getAuthenticated(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable() //// .getAuthenticated(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable()
// .where(((builder, root) -> //// .where(((builder, root) ->
// builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()))), this.userScope.getUserId(), Stream.of(0, 1).collect(Collectors.toList())) //// builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()))), this.userScope.getUserId(), Stream.of(0, 1).collect(Collectors.toList()))
// .toList().stream().map(DMP::getUsers).flatMap(Collection::stream).map(UserDMP::getUser) //// .toList().stream().map(DMP::getUsers).flatMap(Collection::stream).map(UserDMP::getUser)
// .filter(userInfo -> !userInfo.getId().equals(this.userScope.getUserIdSafe())).filter(StreamDistinctBy.distinctByKey(UserInfo::getId)) //// .filter(userInfo -> !userInfo.getId().equals(this.userScope.getUserIdSafe())).filter(StreamDistinctBy.distinctByKey(UserInfo::getId))
// .filter(userInfo -> (userInfoRequestItem == null || userInfoRequestItem.getCriteria() == null || userInfoRequestItem.getCriteria().getLike() == null //// .filter(userInfo -> (userInfoRequestItem == null || userInfoRequestItem.getCriteria() == null || userInfoRequestItem.getCriteria().getLike() == null
// || userInfo.getName().toLowerCase().contains(userInfoRequestItem.getCriteria().getLike().toLowerCase()) //// || userInfo.getName().toLowerCase().contains(userInfoRequestItem.getCriteria().getLike().toLowerCase())
// || (userInfo.getEmail().toLowerCase().contains(userInfoRequestItem.getCriteria().getLike().toLowerCase())))) //// || (userInfo.getEmail().toLowerCase().contains(userInfoRequestItem.getCriteria().getLike().toLowerCase()))))
// .collect(Collectors.toList()); //// .collect(Collectors.toList());
//// .where((builder, root) -> builder.like(builder.upper(root.get("name")), "%" + userInfoRequestItem.getCriteria().getLike().toUpperCase() + "%")) ////// .where((builder, root) -> builder.like(builder.upper(root.get("name")), "%" + userInfoRequestItem.getCriteria().getLike().toUpperCase() + "%"))
// ////
// List<UserInfoInvitationModel> userModels = users.stream().map(userInfo -> new UserInfoInvitationModel().fromDataModel(userInfo)).collect(Collectors.toList()); //// List<UserInfoInvitationModel> userModels = users.stream().map(userInfo -> new UserInfoInvitationModel().fromDataModel(userInfo)).collect(Collectors.toList());
// return userModels; //// return userModels;
return new ArrayList<>(); // return new ArrayList<>();
} // }
public UUID assignUserAcceptedInvitation(UUID invitationID) throws UnauthorisedException, JAXBException, IOException, InvalidApplicationException { public UUID assignUserAcceptedInvitation(UUID invitationID) throws UnauthorisedException, JAXBException, IOException, InvalidApplicationException {
//TODO //TODO

View File

@ -2,7 +2,6 @@ package eu.eudat.logic.managers;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.UserCredentialEntity;
import eu.eudat.data.DmpUserEntity; import eu.eudat.data.DmpUserEntity;
import eu.eudat.data.old.EmailConfirmation; import eu.eudat.data.old.EmailConfirmation;
import eu.eudat.data.UserEntity; import eu.eudat.data.UserEntity;
@ -11,6 +10,8 @@ import eu.eudat.exceptions.emailconfirmation.TokenExpiredException;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository; import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.query.UserQuery;
import gr.cite.tools.data.query.QueryFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -30,13 +31,15 @@ public class MergeEmailConfirmationManager {
private DatabaseRepository databaseRepository; private DatabaseRepository databaseRepository;
// private DmpRepository dmpRepository; // private DmpRepository dmpRepository;
private final UserScope userScope; private final UserScope userScope;
private final QueryFactory queryFactory;
@Autowired @Autowired
public MergeEmailConfirmationManager(ApiContext apiContext, UserScope userScope) { public MergeEmailConfirmationManager(ApiContext apiContext, UserScope userScope, QueryFactory queryFactory) {
this.apiContext = apiContext; this.apiContext = apiContext;
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository(); this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
// this.dmpRepository = apiContext.getOperationsContext().getElasticRepository().getDmpRepository(); // this.dmpRepository = apiContext.getOperationsContext().getElasticRepository().getDmpRepository();
this.userScope = userScope; this.userScope = userScope;
this.queryFactory = queryFactory;
} }
@Transactional @Transactional
@ -48,14 +51,12 @@ public class MergeEmailConfirmationManager {
if (loginConfirmationEmail.getExpiresAt().compareTo(new Date()) < 0) if (loginConfirmationEmail.getExpiresAt().compareTo(new Date()) < 0)
throw new TokenExpiredException("Token has expired."); throw new TokenExpiredException("Token has expired.");
UserEntity userToBeMerged = databaseRepository.getUserInfoDao().asQueryable() UserEntity userToBeMerged = this.queryFactory.query(UserQuery.class).ids(loginConfirmationEmail.getUserId()).first();
.where((builder, root) -> builder.equal(root.get("id"), loginConfirmationEmail.getUserId())).getSingle();
String userToBeMergedEmail = ""; //TODO userToBeMerged.getEmail(); String userToBeMergedEmail = ""; //TODO userToBeMerged.getEmail();
try { try {
Map<String, Object> map = new ObjectMapper().readValue(loginConfirmationEmail.getData(), HashMap.class); Map<String, Object> map = new ObjectMapper().readValue(loginConfirmationEmail.getData(), HashMap.class);
UUID otherUserId = UUID.fromString((String) map.get("userId")); UUID otherUserId = UUID.fromString((String) map.get("userId"));
UserEntity user = databaseRepository.getUserInfoDao().asQueryable() UserEntity user = this.queryFactory.query(UserQuery.class).ids(otherUserId).first();
.where((builder, root) -> builder.equal(root.get("id"), otherUserId)).getSingle();
// Checks if mail is used by another user. If it is, merges the new the old. // Checks if mail is used by another user. If it is, merges the new the old.
mergeNewUserToOld(user, userToBeMerged, Integer.valueOf((String) map.get("provider"))); mergeNewUserToOld(user, userToBeMerged, Integer.valueOf((String) map.get("provider")));
@ -70,7 +71,7 @@ public class MergeEmailConfirmationManager {
} }
public void sendConfirmationEmail(String email, UUID userId, Integer provider) throws HasConfirmedEmailException, InvalidApplicationException { public void sendConfirmationEmail(String email, UUID userId, Integer provider) throws HasConfirmedEmailException, InvalidApplicationException {
UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first();
//TODO //TODO
// if (user.getEmail() != null && !user.getEmail().equals(email)) { // if (user.getEmail() != null && !user.getEmail().equals(email)) {
// apiContext.getUtilitiesService().getConfirmationEmailService().createMergeConfirmationEmail( // apiContext.getUtilitiesService().getConfirmationEmailService().createMergeConfirmationEmail(
@ -85,14 +86,14 @@ public class MergeEmailConfirmationManager {
@Transactional @Transactional
private void mergeNewUserToOld(UserEntity newUser, UserEntity oldUser, Integer provider) throws InvalidApplicationException { private void mergeNewUserToOld(UserEntity newUser, UserEntity oldUser, Integer provider) throws InvalidApplicationException {
UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.and(builder.equal(root.get("userId"), oldUser.getId()), builder.equal(root.get("provider"), provider))).getSingle(); // UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.and(builder.equal(root.get("userId"), oldUser.getId()), builder.equal(root.get("provider"), provider))).getSingle();
credential.setUserId(newUser.getId()); // credential.setUserId(newUser.getId());
databaseRepository.getCredentialDao().createOrUpdate(credential); // databaseRepository.getCredentialDao().createOrUpdate(credential);
List<DmpUserEntity> userDmps = databaseRepository.getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("user"), oldUser)).toList(); // List<DmpUserEntity> userDmps = databaseRepository.getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("user"), oldUser)).toList();
userDmps.forEach(userDmp -> { // userDmps.forEach(userDmp -> {
userDmp.setUserId(newUser.getId()); // userDmp.setUserId(newUser.getId());
databaseRepository.getUserDmpDao().createOrUpdate(userDmp); // databaseRepository.getUserDmpDao().createOrUpdate(userDmp);
}); // });
//TODO //TODO
// try { // try {
// //
@ -129,12 +130,12 @@ public class MergeEmailConfirmationManager {
// } // }
oldUser.setIsActive(IsActive.Inactive); oldUser.setIsActive(IsActive.Inactive);
//TODO oldUser.setEmail(null); //TODO oldUser.setEmail(null);
List<UserCredentialEntity> credentials = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userId"), oldUser.getId())).toList(); // List<UserCredentialEntity> credentials = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userId"), oldUser.getId())).toList();
credentials.forEach(cred -> { // credentials.forEach(cred -> {
if (cred.getId() != credential.getId()) { // if (cred.getId() != credential.getId()) {
databaseRepository.getCredentialDao().delete(cred); // databaseRepository.getCredentialDao().delete(cred);
} // }
}); // });
databaseRepository.getUserInfoDao().createOrUpdate(oldUser); // databaseRepository.getUserInfoDao().createOrUpdate(oldUser);
} }
} }

View File

@ -6,8 +6,10 @@ import eu.eudat.data.UserEntity;
import eu.eudat.commons.enums.old.notification.ActiveStatus; import eu.eudat.commons.enums.old.notification.ActiveStatus;
import eu.eudat.commons.enums.old.notification.NotifyState; import eu.eudat.commons.enums.old.notification.NotifyState;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.query.UserQuery;
import eu.eudat.service.mail.MailService; import eu.eudat.service.mail.MailService;
import eu.eudat.service.mail.SimpleMail; import eu.eudat.service.mail.SimpleMail;
import gr.cite.tools.data.query.QueryFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -26,12 +28,14 @@ public class NotificationManager {
private ApiContext apiContext; private ApiContext apiContext;
private Environment environment; private Environment environment;
private MailService mailService; private MailService mailService;
private final QueryFactory queryFactory;
@Autowired @Autowired
public NotificationManager(ApiContext apiContext, Environment environment, MailService mailService) { public NotificationManager(ApiContext apiContext, Environment environment, MailService mailService, QueryFactory queryFactory) {
this.apiContext = apiContext; this.apiContext = apiContext;
this.environment = environment; this.environment = environment;
this.mailService = mailService; this.mailService = mailService;
this.queryFactory = queryFactory;
} }
@Transactional @Transactional
@ -52,7 +56,7 @@ public class NotificationManager {
notification.setUpdatedAt(new Date()); notification.setUpdatedAt(new Date());
try { try {
Map<String, String> data = new ObjectMapper().readValue(notification.getData(), HashMap.class); Map<String, String> data = new ObjectMapper().readValue(notification.getData(), HashMap.class);
UserEntity userInfo = this.apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(UUID.fromString(data.get("userId"))); UserEntity userInfo = this.queryFactory.query(UserQuery.class).ids(UUID.fromString(data.get("userId"))).first();
String subjectTemplate = ""; String subjectTemplate = "";
String contentTemplate = ""; String contentTemplate = "";

View File

@ -9,6 +9,8 @@ import eu.eudat.data.old.*;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository; import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.models.data.dmp.DataManagementPlan; import eu.eudat.models.data.dmp.DataManagementPlan;
import eu.eudat.query.UserQuery;
import gr.cite.tools.data.query.QueryFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -23,12 +25,15 @@ public class QuickWizardManager {
private DatabaseRepository databaseRepository; private DatabaseRepository databaseRepository;
private DatasetManager datasetManager; private DatasetManager datasetManager;
private final QueryFactory queryFactory;
private final UserScope userScope; private final UserScope userScope;
@Autowired @Autowired
public QuickWizardManager(ApiContext apiContext, DatasetManager datasetManager, UserScope userScope) { public QuickWizardManager(ApiContext apiContext, DatasetManager datasetManager, QueryFactory queryFactory, UserScope userScope) {
this.apiContext = apiContext; this.apiContext = apiContext;
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository(); this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
this.datasetManager = datasetManager; this.datasetManager = datasetManager;
this.queryFactory = queryFactory;
this.userScope = userScope; this.userScope = userScope;
} }
@ -40,13 +45,13 @@ public class QuickWizardManager {
public Grant createOrUpdate(eu.eudat.models.data.grant.Grant grant) throws ParseException, IOException, InvalidApplicationException { public Grant createOrUpdate(eu.eudat.models.data.grant.Grant grant) throws ParseException, IOException, InvalidApplicationException {
Grant grantEntity = grant.toDataModel(); Grant grantEntity = grant.toDataModel();
grantEntity.setType(Grant.GrantType.INTERNAL.getValue()); grantEntity.setType(Grant.GrantType.INTERNAL.getValue());
grantEntity.setCreationUser(databaseRepository.getUserInfoDao().find(this.userScope.getUserId())); grantEntity.setCreationUser(this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first());
return databaseRepository.getGrantDao().createOrUpdate(grantEntity); return databaseRepository.getGrantDao().createOrUpdate(grantEntity);
} }
public Project createOrUpdate(eu.eudat.models.data.project.Project project) throws InvalidApplicationException { public Project createOrUpdate(eu.eudat.models.data.project.Project project) throws InvalidApplicationException {
Project projectEntity = project.toDataModel(); Project projectEntity = project.toDataModel();
projectEntity.setCreationUser(databaseRepository.getUserInfoDao().find(this.userScope.getUserId())); projectEntity.setCreationUser(this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first());
return databaseRepository.getProjectDao().createOrUpdate(projectEntity); return databaseRepository.getProjectDao().createOrUpdate(projectEntity);
} }
@ -56,7 +61,7 @@ public class QuickWizardManager {
//TODO //TODO
//newDmp.getGrant().setFunder(funderEntity); //newDmp.getGrant().setFunder(funderEntity);
} }
UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first();
createFunderIfItDoesntExist(newDmp, user); createFunderIfItDoesntExist(newDmp, user);
createGrantIfItDoesntExist(newDmp, user); createGrantIfItDoesntExist(newDmp, user);
//TODO //TODO
@ -69,8 +74,8 @@ public class QuickWizardManager {
//TODO //TODO
//apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant()); //apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant());
DmpEntity dmpret = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp); DmpEntity dmpret = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
if (dataManagementPlan.getAssociatedUsers().size() == 0) // if (dataManagementPlan.getAssociatedUsers().size() == 0)
assignUser(newDmp, user, apiContext); // assignUser(newDmp, user, apiContext);
// this.updateIndex(dmpret); // this.updateIndex(dmpret);
@ -88,7 +93,7 @@ public class QuickWizardManager {
userDMP.setDmp(dmp.getId()); userDMP.setDmp(dmp.getId());
userDMP.setUserId(userInfo.getId()); userDMP.setUserId(userInfo.getId());
userDMP.setRole(DmpUserRole.User); userDMP.setRole(DmpUserRole.User);
apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().createOrUpdate(userDMP); //apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().createOrUpdate(userDMP);
} }
private void createGrantIfItDoesntExist(DmpEntity newDmp, UserEntity userInfo) throws InvalidApplicationException { private void createGrantIfItDoesntExist(DmpEntity newDmp, UserEntity userInfo) throws InvalidApplicationException {

View File

@ -11,8 +11,10 @@ import eu.eudat.data.query.items.item.researcher.ResearcherCriteriaRequest;
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet; import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
import eu.eudat.logic.proxy.config.exceptions.NoURLFound; import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
import eu.eudat.logic.proxy.fetching.RemoteFetcher; import eu.eudat.logic.proxy.fetching.RemoteFetcher;
import eu.eudat.query.UserQuery;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import gr.cite.tools.data.query.QueryFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -31,18 +33,20 @@ public class ResearcherManager {
private RemoteFetcher remoteFetcher; private RemoteFetcher remoteFetcher;
private ConfigLoader configLoader; private ConfigLoader configLoader;
private final UserScope userScope; private final UserScope userScope;
private final QueryFactory queryFactory;
@Autowired @Autowired
public ResearcherManager(ApiContext apiContext, ConfigLoader configLoader, UserScope userScope) { public ResearcherManager(ApiContext apiContext, ConfigLoader configLoader, UserScope userScope, QueryFactory queryFactory) {
this.apiContext = apiContext; this.apiContext = apiContext;
this.remoteFetcher = apiContext.getOperationsContext().getRemoteFetcher(); this.remoteFetcher = apiContext.getOperationsContext().getRemoteFetcher();
this.configLoader = configLoader; this.configLoader = configLoader;
this.userScope = userScope; this.userScope = userScope;
this.queryFactory = queryFactory;
} }
public Researcher create(eu.eudat.models.data.researcher.Researcher researcher) throws Exception { public Researcher create(eu.eudat.models.data.researcher.Researcher researcher) throws Exception {
Researcher researcherEntity = researcher.toDataModel(); Researcher researcherEntity = researcher.toDataModel();
researcherEntity.setCreationUser(apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId())); researcherEntity.setCreationUser(this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first());
return apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().createOrUpdate(researcherEntity); return apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().createOrUpdate(researcherEntity);
} }

View File

@ -11,6 +11,7 @@ import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository; import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.model.UserContactInfo; import eu.eudat.model.UserContactInfo;
import eu.eudat.query.UserContactInfoQuery; import eu.eudat.query.UserContactInfoQuery;
import eu.eudat.query.UserQuery;
import gr.cite.tools.data.query.Ordering; import gr.cite.tools.data.query.Ordering;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -71,15 +72,15 @@ public class UnlinkEmailConfirmationManager {
@Transactional @Transactional
private void unlinkUser(String emailTobeUnlinked, Integer provider) throws InvalidApplicationException { private void unlinkUser(String emailTobeUnlinked, Integer provider) throws InvalidApplicationException {
UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable() // UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable()
.where((builder, root) -> builder.and(builder.equal(root.get("email"), emailTobeUnlinked), builder.equal(root.get("provider"), provider))).getSingle(); // .where((builder, root) -> builder.and(builder.equal(root.get("email"), emailTobeUnlinked), builder.equal(root.get("provider"), provider))).getSingle();
if(credential != null) { // if(credential != null) {
databaseRepository.getCredentialDao().delete(credential); // databaseRepository.getCredentialDao().delete(credential);
} // }
} }
public void sendConfirmationEmail(String email, UUID userId, Integer provider) throws InvalidApplicationException { public void sendConfirmationEmail(String email, UUID userId, Integer provider) throws InvalidApplicationException {
UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userId); UserEntity user = this.queryFactory.query(UserQuery.class).ids(userId).first();
UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId()); UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId());
query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal)); query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal));
if (query.first().getValue() != null && !query.first().getValue().equals(email)) { if (query.first().getValue() != null && !query.first().getValue().equals(email)) {

View File

@ -1,49 +1,27 @@
package eu.eudat.logic.managers; package eu.eudat.logic.managers;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.authorization.Permission;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity; import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
import eu.eudat.data.UserCredentialEntity;
import eu.eudat.data.DmpEntity;
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
import eu.eudat.data.dao.entities.UserInfoDao;
import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.data.UserEntity;
import eu.eudat.data.UserRoleEntity;
import eu.eudat.data.query.items.table.userinfo.UserInfoTableRequestItem;
import eu.eudat.logic.builders.entity.UserRoleBuilder;
import eu.eudat.logic.builders.model.models.DataTableDataBuilder;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.commons.types.xml.XmlBuilder; import eu.eudat.commons.types.xml.XmlBuilder;
import eu.eudat.models.HintedModelFactory; import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.models.data.dmp.DataManagementPlan; import eu.eudat.data.UserCredentialEntity;
import eu.eudat.models.data.helpers.common.DataTableData; import eu.eudat.data.UserEntity;
import eu.eudat.models.data.userinfo.UserCredential; import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.userinfo.UserListingModel;
import eu.eudat.models.data.userinfo.UserProfile;
import eu.eudat.query.UserCredentialQuery; import eu.eudat.query.UserCredentialQuery;
import eu.eudat.queryable.QueryableList;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import java.io.*; import java.util.ArrayList;
import java.nio.file.Files; import java.util.List;
import java.util.*; import java.util.UUID;
import java.util.stream.Collectors;
@Component @Component
public class UserManager { public class UserManager {
@ -75,125 +53,125 @@ public class UserManager {
return datasetprofile; return datasetprofile;
} }
public DataTableData<UserListingModel> getPaged(UserInfoTableRequestItem userInfoTableRequestItem) throws Exception { // public DataTableData<UserListingModel> getPaged(UserInfoTableRequestItem userInfoTableRequestItem) throws Exception {
QueryableList<UserEntity> users = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().getWithCriteria(userInfoTableRequestItem.getCriteria()).withHint(HintedModelFactory.getHint(UserListingModel.class)); // QueryableList<UserEntity> users = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().getWithCriteria(userInfoTableRequestItem.getCriteria()).withHint(HintedModelFactory.getHint(UserListingModel.class));
QueryableList<UserEntity> pagedUsers = PaginationManager.applyPaging(users, userInfoTableRequestItem); // QueryableList<UserEntity> pagedUsers = PaginationManager.applyPaging(users, userInfoTableRequestItem);
//
// List<UserListingModel> modelUsers = pagedUsers.select(item -> new UserListingModel().fromDataModel(item));
// return apiContext.getOperationsContext().getBuilderFactory().getBuilder(DataTableDataBuilder.class).totalCount(users.count()).data(modelUsers).build();
// }
List<UserListingModel> modelUsers = pagedUsers.select(item -> new UserListingModel().fromDataModel(item)); // public List<UserCredential> getCredentials(UUID userId) throws InvalidApplicationException {
return apiContext.getOperationsContext().getBuilderFactory().getBuilder(DataTableDataBuilder.class).totalCount(users.count()).data(modelUsers).build(); // List<UserCredential> results = new ArrayList<>();
} // UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userId);
// List<UserCredentialEntity> credentials = this.queryFactory.query(UserCredentialQuery.class).userIds(user.getId()).collect();
// credentials.forEach(credential -> {
// UserCredential userCredential = new UserCredential();
// results.add(userCredential);
// });
// return results;
// }
public List<UserCredential> getCredentials(UUID userId) throws InvalidApplicationException { // public UserProfile getSingle(UUID userId) throws Exception {
List<UserCredential> results = new ArrayList<>(); // UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userId);
UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userId); // UserProfile profile = new UserProfile().fromDataModel(user);
List<UserCredentialEntity> credentials = this.queryFactory.query(UserCredentialQuery.class).userIds(user.getId()).collect(); // List<Integer> roles = new LinkedList<>();
credentials.forEach(credential -> { // DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
UserCredential userCredential = new UserCredential(); // criteria.setAllVersions(false);
results.add(userCredential); // QueryableList<DmpEntity> items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria);
}); // List<DmpEntity> dmps = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(items, userId, roles).take(5).toList();
return results; // profile.setAssociatedDmps(dmps.stream().map(x -> new DataManagementPlan().fromDataModel(x)).collect(Collectors.toList()));
} // return profile;
// }
public UserProfile getSingle(UUID userId) throws Exception { // public void editRoles(UserListingModel user) throws InvalidApplicationException {
UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userId); // UserEntity userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(user.getId());
UserProfile profile = new UserProfile().fromDataModel(user); // //userInfo.getUserRoles().stream().forEach(item -> apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().delete(item)); //TODO
List<Integer> roles = new LinkedList<>(); // for (String role : user.getAppRoles()) {
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria(); // UserRoleEntity userRole = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserRoleBuilder.class).role(role).userInfo(userInfo).build();
criteria.setAllVersions(false); // apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().createOrUpdate(userRole);
QueryableList<DmpEntity> items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria); // }
List<DmpEntity> dmps = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(items, userId, roles).take(5).toList(); // }
profile.setAssociatedDmps(dmps.stream().map(x -> new DataManagementPlan().fromDataModel(x)).collect(Collectors.toList()));
return profile;
}
public void editRoles(UserListingModel user) throws InvalidApplicationException { // public void updateSettings(Map<String, Object> settings) throws IOException, InvalidApplicationException {
UserEntity userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(user.getId()); // UserEntity userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId());
//userInfo.getUserRoles().stream().forEach(item -> apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().delete(item)); //TODO // apiContext.getOperationsContext().getDatabaseRepository().detachEntity(userInfo);
for (String role : user.getAppRoles()) { // HashMap<String, Object> result =
UserRoleEntity userRole = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserRoleBuilder.class).role(role).userInfo(userInfo).build(); // new ObjectMapper().readValue(userInfo.getAdditionalInfo(), HashMap.class);
apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().createOrUpdate(userRole); // userInfo.setName(settings.entrySet().stream().filter(entry -> entry.getKey().equals("name")).filter(Objects::nonNull).map(entry -> entry.getValue().toString()).findFirst().orElse(userInfo.getName()));
} // settings.remove("name");
} // result.putAll(settings);
// userInfo.setAdditionalInfo(new JSONObject(result).toString());
public void updateSettings(Map<String, Object> settings) throws IOException, InvalidApplicationException { // apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao()
UserEntity userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); // .createOrUpdate(userInfo);
apiContext.getOperationsContext().getDatabaseRepository().detachEntity(userInfo); // }
HashMap<String, Object> result = //
new ObjectMapper().readValue(userInfo.getAdditionalInfo(), HashMap.class); // public DataTableData<UserListingModel> getCollaboratorsPaged(UserInfoTableRequestItem userInfoTableRequestItem) throws Exception {
userInfo.setName(settings.entrySet().stream().filter(entry -> entry.getKey().equals("name")).filter(Objects::nonNull).map(entry -> entry.getValue().toString()).findFirst().orElse(userInfo.getName())); // UserInfoDao userInfoDao = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao();
settings.remove("name"); // QueryableList<UserEntity> users = userInfoDao.getWithCriteria(userInfoTableRequestItem.getCriteria());
result.putAll(settings); //
userInfo.setAdditionalInfo(new JSONObject(result).toString()); // List<UserListingModel> colaborators = userInfoDao.getAuthenticated(users, this.userScope.getUserId())
apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao() // .withHint(HintedModelFactory.getHint(UserListingModel.class))
.createOrUpdate(userInfo); // .select(colaborator -> new UserListingModel().fromDataModel(colaborator));
} //
// DataTableData<UserListingModel> dataTableData = new DataTableData<>();
public DataTableData<UserListingModel> getCollaboratorsPaged(UserInfoTableRequestItem userInfoTableRequestItem) throws Exception { // dataTableData.setData(colaborators);
UserInfoDao userInfoDao = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao(); // dataTableData.setTotalCount((long) colaborators.size());
QueryableList<UserEntity> users = userInfoDao.getWithCriteria(userInfoTableRequestItem.getCriteria()); // return dataTableData;
// }
List<UserListingModel> colaborators = userInfoDao.getAuthenticated(users, this.userScope.getUserId()) //
.withHint(HintedModelFactory.getHint(UserListingModel.class)) // public ResponseEntity<byte[]> exportToCsv() throws IOException, InvalidApplicationException {
.select(colaborator -> new UserListingModel().fromDataModel(colaborator)); //
// this.authorizationService.authorizeForce(Permission.AdminRole);
DataTableData<UserListingModel> dataTableData = new DataTableData<>(); //
dataTableData.setData(colaborators); // List<UserEntity> users = this.apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().asQueryable().toList();
dataTableData.setTotalCount((long) colaborators.size()); // StringBuilder resultBuilder = new StringBuilder();
return dataTableData; // resultBuilder.append("User Id").append(",").append("User Name").append(",").append("User Email").append("\n");
} // users.stream().forEach(user -> resultBuilder.append(user.getId().toString()).append(",")
// .append(user.getName()).append(",")
public ResponseEntity<byte[]> exportToCsv() throws IOException, InvalidApplicationException { ////TODO .append(user.getEmail()).append("\n")
// );
this.authorizationService.authorizeForce(Permission.AdminRole); // String result = resultBuilder.toString();
// String fileName = "Users_dump";//dmp.getLabel();
List<UserEntity> users = this.apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().asQueryable().toList(); // fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", "");
StringBuilder resultBuilder = new StringBuilder(); // String uuid = UUID.randomUUID().toString();
resultBuilder.append("User Id").append(",").append("User Name").append(",").append("User Email").append("\n"); // File file = new File(this.environment.getProperty("temp.temp") + uuid + ".csv");
users.stream().forEach(user -> resultBuilder.append(user.getId().toString()).append(",") // OutputStream output = new FileOutputStream(file);
.append(user.getName()).append(",") // try {
//TODO .append(user.getEmail()).append("\n") //// mapper.writeValue(file, rdaExportModel);
); // output.write(result.getBytes());
String result = resultBuilder.toString(); // output.flush();
String fileName = "Users_dump";//dmp.getLabel(); // output.close();
fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", ""); // } catch (IOException e) {
String uuid = UUID.randomUUID().toString(); // logger.error(e.getMessage(), e);
File file = new File(this.environment.getProperty("temp.temp") + uuid + ".csv"); // }
OutputStream output = new FileOutputStream(file); //
try { // InputStream resource = new FileInputStream(file);
// mapper.writeValue(file, rdaExportModel); // HttpHeaders responseHeaders = new HttpHeaders();
output.write(result.getBytes()); // responseHeaders.setContentLength(file.length());
output.flush(); // responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
output.close(); // responseHeaders.set("Content-Disposition", "attachment;filename=" + fileName + ".csv");
} catch (IOException e) { // responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
logger.error(e.getMessage(), e); // responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
} //
// byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource);
InputStream resource = new FileInputStream(file); // resource.close();
HttpHeaders responseHeaders = new HttpHeaders(); // Files.deleteIfExists(file.toPath());
responseHeaders.setContentLength(file.length()); // return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK);
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM); // }
responseHeaders.set("Content-Disposition", "attachment;filename=" + fileName + ".csv"); //
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition"); // public UserProfile getFromEmail(String email) throws InvalidApplicationException {
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type"); // UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().asQueryable().where((builder, root) -> builder.equal(root.get("email"), email)).getSingle();
// return new UserProfile().fromDataModel(user);
byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource); // }
resource.close(); //
Files.deleteIfExists(file.toPath()); // public Long countActiveUsers(){ //TODO: Authn
return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK); // return 0L;
} // //return apiContext.getOperationsContext().getDatabaseRepository().getUserTokenDao().asQueryable().where(((builder, root) -> builder.greaterThan(root.get("expiresAt"), new Date()))).count();
// }
public UserProfile getFromEmail(String email) throws InvalidApplicationException { //
UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().asQueryable().where((builder, root) -> builder.equal(root.get("email"), email)).getSingle(); // public Long countAllUsers() throws InvalidApplicationException {
return new UserProfile().fromDataModel(user); // return apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().asQueryable().count();
} // }
public Long countActiveUsers(){ //TODO: Authn
return 0L;
//return apiContext.getOperationsContext().getDatabaseRepository().getUserTokenDao().asQueryable().where(((builder, root) -> builder.greaterThan(root.get("expiresAt"), new Date()))).count();
}
public Long countAllUsers() throws InvalidApplicationException {
return apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().asQueryable().count();
}
} }

View File

@ -1,7 +1,6 @@
package eu.eudat.logic.services.operations; package eu.eudat.logic.services.operations;
import eu.eudat.data.dao.entities.*; import eu.eudat.data.dao.entities.*;
import eu.eudat.data.dao.entities.security.CredentialDao;
public interface DatabaseRepository { public interface DatabaseRepository {
@ -13,8 +12,6 @@ public interface DatabaseRepository {
DMPDao getDmpDao(); DMPDao getDmpDao();
DmpDatasetProfileDao getDmpDatasetProfileDao();
OrganisationDao getOrganisationDao(); OrganisationDao getOrganisationDao();
GrantDao getGrantDao(); GrantDao getGrantDao();
@ -25,20 +22,10 @@ public interface DatabaseRepository {
ServiceDao getServiceDao(); ServiceDao getServiceDao();
UserInfoDao getUserInfoDao();
UserRoleDao getUserRoleDao();
InvitationDao getInvitationDao(); InvitationDao getInvitationDao();
CredentialDao getCredentialDao();
ExternalDatasetDao getExternalDatasetDao(); ExternalDatasetDao getExternalDatasetDao();
UserDatasetProfileDao getUserDatasetProfileDao();
UserDmpDao getUserDmpDao();
ContentDao getContentDao(); ContentDao getContentDao();
EmailConfirmationDao getLoginConfirmationEmailDao(); EmailConfirmationDao getLoginConfirmationEmailDao();

View File

@ -1,7 +1,6 @@
package eu.eudat.logic.services.operations; package eu.eudat.logic.services.operations;
import eu.eudat.data.dao.entities.*; import eu.eudat.data.dao.entities.*;
import eu.eudat.data.dao.entities.security.CredentialDao;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -17,8 +16,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
private DMPDao dmpDao; private DMPDao dmpDao;
private DmpDatasetProfileDao dmpDatasetProfileDao;
private OrganisationDao organisationDao; private OrganisationDao organisationDao;
private GrantDao GrantDao; private GrantDao GrantDao;
@ -29,20 +26,10 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
private ServiceDao serviceDao; private ServiceDao serviceDao;
private UserInfoDao userInfoDao;
private InvitationDao invitationDao; private InvitationDao invitationDao;
private CredentialDao credentialDao;
private ExternalDatasetDao externalDatasetDao; private ExternalDatasetDao externalDatasetDao;
private UserRoleDao userRoleDao;
private UserDatasetProfileDao userDatasetProfileDao;
private UserDmpDao userDmpDao;
private ContentDao contentDao; private ContentDao contentDao;
private EmailConfirmationDao loginConfirmationEmailDao; private EmailConfirmationDao loginConfirmationEmailDao;
@ -79,11 +66,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
this.dmpDao = dmpDao; this.dmpDao = dmpDao;
} }
@Autowired
private void setDmpDatasetProfileDao(DmpDatasetProfileDao dmpDatasetProfileDao) {
this.dmpDatasetProfileDao = dmpDatasetProfileDao;
}
@Autowired @Autowired
private void setOrganisationDao(OrganisationDao organisationDao) { private void setOrganisationDao(OrganisationDao organisationDao) {
this.organisationDao = organisationDao; this.organisationDao = organisationDao;
@ -110,10 +92,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
} }
@Autowired @Autowired
private void setUserInfoDao(UserInfoDao userInfoDao) {
this.userInfoDao = userInfoDao;
}
@Override @Override
public DataRepositoryDao getDataRepositoryDao() { public DataRepositoryDao getDataRepositoryDao() {
return dataRepositoryDao; return dataRepositoryDao;
@ -134,11 +112,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
return dmpDao; return dmpDao;
} }
@Override
public DmpDatasetProfileDao getDmpDatasetProfileDao() {
return dmpDatasetProfileDao;
}
@Override @Override
public OrganisationDao getOrganisationDao() { public OrganisationDao getOrganisationDao() {
return organisationDao; return organisationDao;
@ -164,11 +137,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
return serviceDao; return serviceDao;
} }
@Override
public UserInfoDao getUserInfoDao() {
return userInfoDao;
}
@Override @Override
public InvitationDao getInvitationDao() { public InvitationDao getInvitationDao() {
return invitationDao; return invitationDao;
@ -179,16 +147,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
this.invitationDao = invitationDao; this.invitationDao = invitationDao;
} }
@Override
public CredentialDao getCredentialDao() {
return credentialDao;
}
@Autowired
public void setCredentialDao(CredentialDao credentialDao) {
this.credentialDao = credentialDao;
}
@Override @Override
public ExternalDatasetDao getExternalDatasetDao() { public ExternalDatasetDao getExternalDatasetDao() {
return externalDatasetDao; return externalDatasetDao;
@ -199,31 +157,11 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
this.externalDatasetDao = externalDatasetDao; this.externalDatasetDao = externalDatasetDao;
} }
@Override
public UserRoleDao getUserRoleDao() {
return userRoleDao;
}
@Autowired
public void setUserRoleDao(UserRoleDao userRoleDao) {
this.userRoleDao = userRoleDao;
}
@Autowired @Autowired
public void setEntityManager(EntityManager entityManager) { public void setEntityManager(EntityManager entityManager) {
this.entityManager = entityManager; this.entityManager = entityManager;
} }
@Override
public UserDmpDao getUserDmpDao() {
return userDmpDao;
}
@Autowired
public void setUserDmpDao(UserDmpDao userDmpDao) {
this.userDmpDao = userDmpDao;
}
@Override @Override
public ContentDao getContentDao() { public ContentDao getContentDao() {
return this.contentDao; return this.contentDao;
@ -284,15 +222,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
this.notificationDao = notificationDao; this.notificationDao = notificationDao;
} }
@Override
public UserDatasetProfileDao getUserDatasetProfileDao() {
return userDatasetProfileDao;
}
@Autowired
public void setUserDatasetProfileDao(UserDatasetProfileDao userDatasetProfileDao) {
this.userDatasetProfileDao = userDatasetProfileDao;
}
@Override @Override
public FileUploadDao getFileUploadDao() { public FileUploadDao getFileUploadDao() {

View File

@ -51,6 +51,7 @@ import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.JAXBException;
import net.minidev.json.JSONArray;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
@ -323,7 +324,7 @@ public class ReferenceService {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
source.getOptions().forEach(option -> { source.getOptions().forEach(option -> {
map.put(option.getCode(), option.getValue()); map.put(option.getCode(), option.getValue());
map.put("label", source.getLabel()); map.put("tag", source.getLabel());
map.put("key", source.getKey()); map.put("key", source.getKey());
}); });
results.add(map); results.add(map);
@ -373,7 +374,7 @@ public class ReferenceService {
.collect(Collectors.toList())); .collect(Collectors.toList()));
} }
if (fetchStrategy == FetchStrategy.FIRST) if (fetchStrategy == FetchStrategy.FIRST)
return results.getResults().stream().peek(x -> x.put("label", label)).peek(x -> x.put("key", key)).collect(Collectors.toList()); return results.getResults().stream().peek(x -> x.put("tag", label)).peek(x -> x.put("key", key)).collect(Collectors.toList());
if (results.getPagination() != null && results.getPagination().get("pages") != null) //if has more pages, add them to the pages set if (results.getPagination() != null && results.getPagination().get("pages") != null) //if has more pages, add them to the pages set
for (int i = 2; i <= results.getPagination().get("pages"); i++) for (int i = 2; i <= results.getPagination().get("pages"); i++)
@ -394,7 +395,7 @@ public class ReferenceService {
Results remainingResults = optionalResults.orElseGet(Results::new); Results remainingResults = optionalResults.orElseGet(Results::new);
remainingResults.getResults().addAll(results.getResults()); remainingResults.getResults().addAll(results.getResults());
return remainingResults.getResults().stream().peek(x -> x.put("label", label)).peek(x -> x.put("key", key)).collect(Collectors.toList()); return remainingResults.getResults().stream().peek(x -> x.put("tag", label)).peek(x -> x.put("key", key)).collect(Collectors.toList());
} }
else { else {
return new LinkedList<>(); return new LinkedList<>();
@ -404,17 +405,29 @@ public class ReferenceService {
private String replaceLookupFields(String urlPath, ReferenceDefinitionSearchLookup lookup, String firstPage, List<QueryConfigEntity> queries){ private String replaceLookupFields(String urlPath, ReferenceDefinitionSearchLookup lookup, String firstPage, List<QueryConfigEntity> queries){
String completedPath = urlPath; String completedPath = urlPath;
if (urlPath.contains("{like}")){ if (urlPath.contains("openaire") || urlPath.contains("orcid") ){
if (lookup.getLike() != null) { if (lookup.getLike() != null) {
completedPath = completedPath.replace("{query}", lookup.getLike());
completedPath = completedPath.replace("{like}", lookup.getLike()); completedPath = completedPath.replace("{like}", lookup.getLike());
} else { } else {
completedPath = completedPath.replace("{query}", "*");
completedPath = completedPath.replace("{like}", "*"); completedPath = completedPath.replace("{like}", "*");
} }
} }
if (urlPath.contains("{page}")){ if (urlPath.contains("{like}")){
if (lookup.getLike() != null) {
completedPath = completedPath.replace("{like}", lookup.getLike());
} else {
completedPath = completedPath.replace("{like}", "");
}
}
if (urlPath.contains("{page}")) {
if (lookup.getPage() != null && lookup.getPage().getOffset() > 0) { if (lookup.getPage() != null && lookup.getPage().getOffset() > 0) {
completedPath = completedPath.replace("{page}", String.valueOf(lookup.getPage().getOffset())); completedPath = completedPath.replace("{page}", String.valueOf(lookup.getPage().getOffset()));
} else if (firstPage != null) {
completedPath = completedPath.replace("{page}", firstPage);
} else { } else {
completedPath = completedPath.replace("{page}", "1"); completedPath = completedPath.replace("{page}", "1");
} }
@ -428,13 +441,6 @@ public class ReferenceService {
} }
} }
if (urlPath.contains("openaire")){
if (lookup.getLike() != null) {
completedPath = completedPath.replace("{query}", lookup.getLike());
} else {
completedPath = completedPath.replace("{query}", "*");
}
}
return completedPath; return completedPath;
} }
@ -485,20 +491,76 @@ public class ReferenceService {
private static List<Map<String, String>> parseData (DocumentContext jsonContext, ResultsConfigurationEntity resultsEntity) { private static List<Map<String, String>> parseData (DocumentContext jsonContext, ResultsConfigurationEntity resultsEntity) {
List <Map<String, String>> rawData = jsonContext.read(resultsEntity.getResultsArrayPath()); List <Map<String, String>> rawData = jsonContext.read(resultsEntity.getResultsArrayPath());
List<Map<String, String>> parsedData = new ArrayList<>(); List<Map<String, String>> parsedData = new ArrayList<>();
rawData.forEach(stringObjectMap -> {
for (Map<String, String> stringObjectMap: rawData){
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
resultsEntity.getFieldsMapping().forEach(field ->{ for(ResultFieldsMappingConfigurationEntity field: resultsEntity.getFieldsMapping()){
String pathValue = field.getResponsePath(); String pathValue = field.getResponsePath();
if (stringObjectMap.containsKey(pathValue)){ if (!pathValue.contains(".")){
map.put(field.getCode(), stringObjectMap.get(pathValue)); if (stringObjectMap.containsKey(pathValue)) {
//map.put(field.getCode(), stringObjectMap.get(pathValue));
map.put(field.getCode(), normalizeValue(stringObjectMap.get(pathValue)));
}
}else {
if (stringObjectMap.containsKey(pathValue.split("\\.")[0])){
String value = null;
Object fieldObj = stringObjectMap.get(pathValue.split("\\.")[0]);
if (fieldObj != null){
if (fieldObj instanceof Map){
Object o = ((Map<String, Object>) fieldObj).get(pathValue.split("\\.")[1]);
if(o instanceof String){
value = (String)o;
}
else if(o instanceof Integer){
value = String.valueOf(o);
}
} else if (fieldObj instanceof List) {
Object o = ((List<Map<String,?>>) fieldObj).get(0).get(pathValue.split("\\.")[1]);
if(o instanceof String){
value = (String)o;
}
else if(o instanceof Integer){
value = String.valueOf(o);
}
}
}
if (value != null){
map.put(field.getCode(), value);
}
}
}
} }
});
parsedData.add(map); parsedData.add(map);
}
});
return parsedData; return parsedData;
} }
private static String normalizeValue(Object value) {
if (value instanceof JSONArray) {
JSONArray jarr = (JSONArray) value;
if (jarr.get(0) instanceof String) {
return jarr.get(0).toString();
} else {
for (Object o : jarr) {
if ((o instanceof Map) && ((Map) o).containsKey("content")) {
try {
return ((Map<String, String>) o).get("content");
}
catch (ClassCastException e){
if(((Map<?, ?>) o).get("content") instanceof Integer) {
return String.valueOf(((Map<?, ?>) o).get("content"));
}
return null;
}
}
}
}
} else if (value instanceof Map) {
String key = ((Map<String, String>)value).containsKey("$") ? "$" : "content";
return ((Map<String, String>)value).get(key);
}
return value != null ? value.toString() : null;
}
} }

View File

@ -1,11 +1,10 @@
package eu.eudat.models.data.admin.composite; package eu.eudat.models.data.admin.composite;
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity; import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
import eu.eudat.commons.types.descriptiontemplate.SectionEntity;
import eu.eudat.logic.utilities.builders.ModelBuilder; import eu.eudat.logic.utilities.builders.ModelBuilder;
import eu.eudat.model.DmpUser;
import eu.eudat.models.data.admin.components.datasetprofile.Page; import eu.eudat.models.data.admin.components.datasetprofile.Page;
import eu.eudat.models.data.admin.components.datasetprofile.Section; import eu.eudat.models.data.admin.components.datasetprofile.Section;
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -21,7 +20,7 @@ public class DatasetProfile {
private Short status; private Short status;
private Short version; private Short version;
private String language; private String language;
private List<UserInfoListingModel> users; private List<DmpUser> users;
public String getLabel() { public String getLabel() {
@ -74,10 +73,10 @@ public class DatasetProfile {
this.language = language; this.language = language;
} }
public List<UserInfoListingModel> getUsers() { public List<DmpUser> getUsers() {
return users; return users;
} }
public void setUsers(List<UserInfoListingModel> users) { public void setUsers(List<DmpUser> users) {
this.users = users; this.users = users;
} }

View File

@ -1,8 +1,8 @@
package eu.eudat.models.data.dashboard.recent.model; package eu.eudat.models.data.dashboard.recent.model;
import eu.eudat.model.DmpUser;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel; import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
import eu.eudat.data.old.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import java.util.Date; import java.util.Date;
@ -20,7 +20,7 @@ public abstract class RecentActivityModel<T extends DataEntity, S extends DataMo
private Date publishedAt; private Date publishedAt;
private DatasetProfileOverviewModel profile; private DatasetProfileOverviewModel profile;
private int type; private int type;
private List<UserInfoListingModel> users; private List<DmpUser> users;
private Boolean isPublic; private Boolean isPublic;
public String getId() { public String getId() {
@ -111,11 +111,11 @@ public abstract class RecentActivityModel<T extends DataEntity, S extends DataMo
this.type = type; this.type = type;
} }
public List<UserInfoListingModel> getUsers() { public List<DmpUser> getUsers() {
return users; return users;
} }
public void setUsers(List<UserInfoListingModel> users) { public void setUsers(List<DmpUser> users) {
this.users = users; this.users = users;
} }

View File

@ -1,11 +1,6 @@
package eu.eudat.models.data.dashboard.recent.model; package eu.eudat.models.data.dashboard.recent.model;
import eu.eudat.data.DescriptionEntity; import eu.eudat.data.DescriptionEntity;
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
import java.util.Date;
import java.util.stream.Collectors;
public class RecentDatasetModel extends RecentActivityModel<DescriptionEntity, RecentDatasetModel> { public class RecentDatasetModel extends RecentActivityModel<DescriptionEntity, RecentDatasetModel> {
private String dmp; private String dmp;

View File

@ -1,14 +1,12 @@
package eu.eudat.models.data.dashboard.recent.model; package eu.eudat.models.data.dashboard.recent.model;
import eu.eudat.data.DmpEntity; import eu.eudat.data.DmpEntity;
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
import eu.eudat.models.data.urls.DatasetUrlListing; import eu.eudat.models.data.urls.DatasetUrlListing;
import jakarta.transaction.Transactional; import jakarta.transaction.Transactional;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
public class RecentDmpModel extends RecentActivityModel<DmpEntity, RecentDmpModel> { public class RecentDmpModel extends RecentActivityModel<DmpEntity, RecentDmpModel> {
private Map<String, Object> extraProperties; private Map<String, Object> extraProperties;

View File

@ -2,17 +2,15 @@ package eu.eudat.models.data.dataset;
import eu.eudat.commons.enums.DescriptionStatus; import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.data.DescriptionEntity; import eu.eudat.data.DescriptionEntity;
import eu.eudat.model.DmpUser;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel; import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
import eu.eudat.models.data.grant.GrantOverviewModel; import eu.eudat.models.data.grant.GrantOverviewModel;
import eu.eudat.models.data.listingmodels.DataManagementPlanOverviewModel; import eu.eudat.models.data.listingmodels.DataManagementPlanOverviewModel;
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
import java.time.Instant; import java.time.Instant;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
public class DatasetOverviewModel implements DataModel<DescriptionEntity, DatasetOverviewModel> { public class DatasetOverviewModel implements DataModel<DescriptionEntity, DatasetOverviewModel> {
@ -20,7 +18,7 @@ public class DatasetOverviewModel implements DataModel<DescriptionEntity, Datase
private String label; private String label;
private DescriptionStatus status; private DescriptionStatus status;
private DatasetProfileOverviewModel datasetTemplate; private DatasetProfileOverviewModel datasetTemplate;
private List<UserInfoListingModel> users; private List<DmpUser> users;
private DataManagementPlanOverviewModel dmp; private DataManagementPlanOverviewModel dmp;
private GrantOverviewModel grant; private GrantOverviewModel grant;
private String description; private String description;
@ -56,11 +54,11 @@ public class DatasetOverviewModel implements DataModel<DescriptionEntity, Datase
this.datasetTemplate = datasetTemplate; this.datasetTemplate = datasetTemplate;
} }
public List<UserInfoListingModel> getUsers() { public List<DmpUser> getUsers() {
return users; return users;
} }
public void setUsers(List<UserInfoListingModel> users) { public void setUsers(List<DmpUser> users) {
this.users = users; this.users = users;
} }

View File

@ -1,26 +1,17 @@
package eu.eudat.models.data.dmp; package eu.eudat.models.data.dmp;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DmpBlueprintEntity;
import eu.eudat.data.DmpEntity; import eu.eudat.data.DmpEntity;
import eu.eudat.data.old.*; import eu.eudat.model.DmpUser;
import eu.eudat.model.doi.Doi; import eu.eudat.model.doi.Doi;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue; import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
import eu.eudat.models.data.funder.Funder; import eu.eudat.models.data.funder.Funder;
import eu.eudat.models.data.helpermodels.Tuple; import eu.eudat.models.data.helpermodels.Tuple;
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
import eu.eudat.models.data.grant.Grant; import eu.eudat.models.data.grant.Grant;
import eu.eudat.models.data.project.Project; import eu.eudat.models.data.project.Project;
import eu.eudat.models.data.userinfo.UserListingModel;
import net.minidev.json.JSONObject;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
public class DataManagementPlan implements DataModel<DmpEntity, DataManagementPlan> { public class DataManagementPlan implements DataModel<DmpEntity, DataManagementPlan> {
private UUID id; private UUID id;
@ -36,14 +27,12 @@ public class DataManagementPlan implements DataModel<DmpEntity, DataManagementPl
private Grant grant; private Grant grant;
private List<Organisation> organisations; private List<Organisation> organisations;
private List<Researcher> researchers; private List<Researcher> researchers;
private List<UserListingModel> associatedUsers;
private List<ExtraFieldModel> extraFields; private List<ExtraFieldModel> extraFields;
private eu.eudat.models.data.userinfo.UserInfo creator;
private Date modified; private Date modified;
private Date created; private Date created;
private List<DynamicFieldWithValue> dynamicFields; private List<DynamicFieldWithValue> dynamicFields;
private Map<String, Object> properties; private Map<String, Object> properties;
private List<UserInfoListingModel> users; private List<DmpUser> users;
private List<Doi> dois; private List<Doi> dois;
private Project project; private Project project;
private Funder funder; private Funder funder;
@ -78,13 +67,6 @@ public class DataManagementPlan implements DataModel<DmpEntity, DataManagementPl
this.groupId = groupId; this.groupId = groupId;
} }
public List<UserListingModel> getAssociatedUsers() {
return associatedUsers;
}
public void setAssociatedUsers(List<UserListingModel> associatedUsers) {
this.associatedUsers = associatedUsers;
}
public int getVersion() { public int getVersion() {
return version; return version;
} }
@ -120,13 +102,6 @@ public class DataManagementPlan implements DataModel<DmpEntity, DataManagementPl
this.grant = grant; this.grant = grant;
} }
public eu.eudat.models.data.userinfo.UserInfo getCreator() {
return creator;
}
public void setCreator(eu.eudat.models.data.userinfo.UserInfo creator) {
this.creator = creator;
}
public List<AssociatedProfile> getProfiles() { public List<AssociatedProfile> getProfiles() {
return profiles; return profiles;
} }
@ -191,10 +166,10 @@ public class DataManagementPlan implements DataModel<DmpEntity, DataManagementPl
this.datasets = datasets; this.datasets = datasets;
} }
public List<UserInfoListingModel> getUsers() { public List<DmpUser> getUsers() {
return users; return users;
} }
public void setUsers(List<UserInfoListingModel> users) { public void setUsers(List<DmpUser> users) {
this.users = users; this.users = users;
} }

View File

@ -1,23 +1,19 @@
package eu.eudat.models.data.dmp; package eu.eudat.models.data.dmp;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.DmpBlueprintEntity;
import eu.eudat.data.DmpEntity; import eu.eudat.data.DmpEntity;
import eu.eudat.data.old.*; import eu.eudat.model.DmpUser;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue; import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
import eu.eudat.models.data.funder.FunderDMPEditorModel; import eu.eudat.models.data.funder.FunderDMPEditorModel;
import eu.eudat.models.data.helpermodels.Tuple;
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
import eu.eudat.models.data.grant.GrantDMPEditorModel; import eu.eudat.models.data.grant.GrantDMPEditorModel;
import eu.eudat.models.data.helpermodels.Tuple;
import eu.eudat.models.data.project.ProjectDMPEditorModel; import eu.eudat.models.data.project.ProjectDMPEditorModel;
import eu.eudat.models.data.userinfo.UserListingModel;
import net.minidev.json.JSONObject;
import java.util.*; import java.util.Date;
import java.util.stream.Collectors; import java.util.List;
import java.util.Map;
import java.util.UUID;
public class DataManagementPlanEditorModel implements DataModel<DmpEntity, DataManagementPlanEditorModel> { public class DataManagementPlanEditorModel implements DataModel<DmpEntity, DataManagementPlanEditorModel> {
private UUID id; private UUID id;
@ -33,14 +29,12 @@ public class DataManagementPlanEditorModel implements DataModel<DmpEntity, DataM
private eu.eudat.models.data.grant.GrantDMPEditorModel grant; private eu.eudat.models.data.grant.GrantDMPEditorModel grant;
private List<Organisation> organisations; private List<Organisation> organisations;
private List<Researcher> researchers; private List<Researcher> researchers;
private List<UserListingModel> associatedUsers;
private List<ExtraFieldModel> extraFields; private List<ExtraFieldModel> extraFields;
private eu.eudat.models.data.userinfo.UserInfo creator;
private Date modified; private Date modified;
private Date created; private Date created;
private List<DynamicFieldWithValue> dynamicFields; private List<DynamicFieldWithValue> dynamicFields;
private Map<String, Object> properties; private Map<String, Object> properties;
private List<UserInfoListingModel> users; private List<DmpUser> users;
private List<UUID> datasetsToBeFinalized; private List<UUID> datasetsToBeFinalized;
private ProjectDMPEditorModel project; private ProjectDMPEditorModel project;
private FunderDMPEditorModel funder; private FunderDMPEditorModel funder;
@ -74,16 +68,6 @@ public class DataManagementPlanEditorModel implements DataModel<DmpEntity, DataM
this.groupId = groupId; this.groupId = groupId;
} }
public List<UserListingModel> getAssociatedUsers() {
return associatedUsers;
}
public void setAssociatedUsers(List<UserListingModel> associatedUsers) {
this.associatedUsers = associatedUsers;
}
public int getVersion() {
return version;
}
public void setVersion(int version) { public void setVersion(int version) {
this.version = version; this.version = version;
} }
@ -116,13 +100,6 @@ public class DataManagementPlanEditorModel implements DataModel<DmpEntity, DataM
this.grant = grant; this.grant = grant;
} }
public eu.eudat.models.data.userinfo.UserInfo getCreator() {
return creator;
}
public void setCreator(eu.eudat.models.data.userinfo.UserInfo creator) {
this.creator = creator;
}
public List<AssociatedProfile> getProfiles() { public List<AssociatedProfile> getProfiles() {
return profiles; return profiles;
} }
@ -187,10 +164,10 @@ public class DataManagementPlanEditorModel implements DataModel<DmpEntity, DataM
this.datasets = datasets; this.datasets = datasets;
} }
public List<UserInfoListingModel> getUsers() { public List<DmpUser> getUsers() {
return users; return users;
} }
public void setUsers(List<UserInfoListingModel> users) { public void setUsers(List<DmpUser> users) {
this.users = users; this.users = users;
} }

View File

@ -11,8 +11,6 @@ import eu.eudat.models.data.dataset.Dataset;
import eu.eudat.models.data.funder.FunderDMPEditorModel; import eu.eudat.models.data.funder.FunderDMPEditorModel;
import eu.eudat.models.data.grant.GrantDMPEditorModel; import eu.eudat.models.data.grant.GrantDMPEditorModel;
import eu.eudat.models.data.project.ProjectDMPEditorModel; import eu.eudat.models.data.project.ProjectDMPEditorModel;
import eu.eudat.models.data.userinfo.UserInfo;
import eu.eudat.models.data.userinfo.UserListingModel;
import net.minidev.json.JSONObject; import net.minidev.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -37,9 +35,6 @@ public class DataManagementPlanNewVersionModel implements DataModel<DmpEntity, D
private eu.eudat.models.data.grant.GrantDMPEditorModel grant; private eu.eudat.models.data.grant.GrantDMPEditorModel grant;
private List<Organisation> organisations; private List<Organisation> organisations;
private List<Researcher> researchers; private List<Researcher> researchers;
private List<UserListingModel> associatedUsers;
private eu.eudat.models.data.userinfo.UserInfo creator;
private Date created;
private List<Dataset> datasets; private List<Dataset> datasets;
private ProjectDMPEditorModel project; private ProjectDMPEditorModel project;
private FunderDMPEditorModel funder; private FunderDMPEditorModel funder;
@ -115,27 +110,6 @@ public class DataManagementPlanNewVersionModel implements DataModel<DmpEntity, D
this.researchers = researchers; this.researchers = researchers;
} }
public List<UserListingModel> getAssociatedUsers() {
return associatedUsers;
}
public void setAssociatedUsers(List<UserListingModel> associatedUsers) {
this.associatedUsers = associatedUsers;
}
public UserInfo getCreator() {
return creator;
}
public void setCreator(UserInfo creator) {
this.creator = creator;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public List<Dataset> getDatasets() { public List<Dataset> getDatasets() {
return datasets; return datasets;
} }

View File

@ -1,6 +1,6 @@
package eu.eudat.models.data.invitation; package eu.eudat.models.data.invitation;
import eu.eudat.models.data.userinfo.UserInfoInvitationModel; import eu.eudat.model.User;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -8,7 +8,7 @@ import java.util.UUID;
public class Invitation { public class Invitation {
private UUID dataManagementPlan; private UUID dataManagementPlan;
private List<UserInfoInvitationModel> users; private List<User> users;
private Integer role; private Integer role;
public UUID getDataManagementPlan() { public UUID getDataManagementPlan() {
@ -19,11 +19,11 @@ public class Invitation {
this.dataManagementPlan = dataManagementPlan; this.dataManagementPlan = dataManagementPlan;
} }
public List<UserInfoInvitationModel> getUsers() { public List<User> getUsers() {
return users; return users;
} }
public void setUsers(List<UserInfoInvitationModel> users) { public void setUsers(List<User> users) {
this.users = users; this.users = users;
} }

View File

@ -2,6 +2,7 @@ package eu.eudat.models.data.listingmodels;
import eu.eudat.data.DmpEntity; import eu.eudat.data.DmpEntity;
import eu.eudat.data.old.Grant; import eu.eudat.data.old.Grant;
import eu.eudat.model.DmpUser;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import eu.eudat.models.data.urls.DatasetUrlListing; import eu.eudat.models.data.urls.DatasetUrlListing;
@ -22,7 +23,7 @@ public class DataManagementPlanListingModel implements DataModel<DmpEntity, Data
private int status; private int status;
private UUID groupId; private UUID groupId;
private List<DatasetUrlListing> datasets; private List<DatasetUrlListing> datasets;
private List<UserInfoListingModel> users; private List<DmpUser> users;
private Date finalizedAt; private Date finalizedAt;
private Boolean isPublic; private Boolean isPublic;
private Date publishedAt; private Date publishedAt;
@ -91,10 +92,10 @@ public class DataManagementPlanListingModel implements DataModel<DmpEntity, Data
this.status = status; this.status = status;
} }
public List<UserInfoListingModel> getUsers() { public List<DmpUser> getUsers() {
return users; return users;
} }
public void setUsers(List<UserInfoListingModel> users) { public void setUsers(List<DmpUser> users) {
this.users = users; this.users = users;
} }

View File

@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.commons.enums.DescriptionStatus; import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DmpEntity; import eu.eudat.data.DmpEntity;
import eu.eudat.model.DmpUser;
import eu.eudat.model.doi.Doi; import eu.eudat.model.doi.Doi;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import eu.eudat.models.data.dataset.DatasetOverviewModel; import eu.eudat.models.data.dataset.DatasetOverviewModel;
@ -32,7 +33,7 @@ public class DataManagementPlanOverviewModel implements DataModel<DmpEntity, Dat
private List<DatasetOverviewModel> datasets; private List<DatasetOverviewModel> datasets;
private List<AssociatedProfile> associatedProfiles; private List<AssociatedProfile> associatedProfiles;
private List<Researcher> researchers; private List<Researcher> researchers;
private List<UserInfoListingModel> users; private List<DmpUser> users;
private String description; private String description;
private boolean isPublic; private boolean isPublic;
private Date publishedAt; private Date publishedAt;
@ -130,10 +131,10 @@ public class DataManagementPlanOverviewModel implements DataModel<DmpEntity, Dat
this.associatedProfiles = associatedProfiles; this.associatedProfiles = associatedProfiles;
} }
public List<UserInfoListingModel> getUsers() { public List<DmpUser> getUsers() {
return users; return users;
} }
public void setUsers(List<UserInfoListingModel> users) { public void setUsers(List<DmpUser> users) {
this.users = users; this.users = users;
} }

View File

@ -2,6 +2,7 @@ package eu.eudat.models.data.listingmodels;
import eu.eudat.commons.enums.DescriptionStatus; import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.data.DescriptionEntity; import eu.eudat.data.DescriptionEntity;
import eu.eudat.model.DmpUser;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel; import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
@ -23,7 +24,7 @@ public class DatasetListingModel implements DataModel<DescriptionEntity, Dataset
private Instant finalizedAt; private Instant finalizedAt;
private Instant dmpPublishedAt; private Instant dmpPublishedAt;
private int version; private int version;
private List<UserInfoListingModel> users; private List<DmpUser> users;
private Boolean isPublic; private Boolean isPublic;
public String getId() { public String getId() {
@ -118,11 +119,11 @@ public class DatasetListingModel implements DataModel<DescriptionEntity, Dataset
this.version = version; this.version = version;
} }
public List<UserInfoListingModel> getUsers() { public List<DmpUser> getUsers() {
return users; return users;
} }
public void setUsers(List<UserInfoListingModel> users) { public void setUsers(List<DmpUser> users) {
this.users = users; this.users = users;
} }

View File

@ -1,61 +0,0 @@
package eu.eudat.models.data.listingmodels;
import eu.eudat.commons.enums.DmpUserRole;
import eu.eudat.data.DmpUserEntity;
import eu.eudat.data.UserEntity;
import eu.eudat.models.DataModel;
import java.util.UUID;
public class UserInfoListingModel implements DataModel<DmpUserEntity, UserInfoListingModel> {
private UUID id;
private String name;
private int role;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getRole() {
return role;
}
public void setRole(int role) {
this.role = role;
}
@Override
public UserInfoListingModel fromDataModel(DmpUserEntity entity) {
// this.id = entity.getUser().getId(); //TODO
// this.name = entity.getUser().getName();
// this.role = entity.getRole();
// this.email = entity.getUser().getEmail();
return this;
}
@Override
public DmpUserEntity toDataModel() {
DmpUserEntity entity = new DmpUserEntity();
entity.setId(this.getId());
entity.setRole(DmpUserRole.of((short) this.getRole()));
UserEntity userInfo = new UserEntity();
userInfo.setName(this.getName());
// entity.setUser(userInfo);
return entity;
}
@Override
public String getHint() {
return "UserInfoListingModel";
}
}

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