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 PublicBrowseUser = "PublicBrowseUser";
//Elastic
public static String ManageElastic = "ManageElastic";
//Language
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;

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 {
private Boolean enabled;
private String authUrl;
private ReferenceTypeExternalApiHTTPMethodType authMethod;
private String authTokenPath;
@ -15,6 +16,15 @@ public class AuthenticationConfigurationEntity {
return authUrl;
}
public Boolean getEnabled() {
return enabled;
}
@XmlElement(name = "enabled")
public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}
@XmlElement(name = "authUrl")
public void setAuthUrl(String 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 jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import java.util.List;
public abstract class ReferenceTypeSourceBaseConfigurationEntity {
@ -12,7 +15,7 @@ public abstract class ReferenceTypeSourceBaseConfigurationEntity {
private Integer ordinal;
private ReferenceTypeSourceType type;
private List<ReferenceTypeSourceBaseDependencyEntity> dependencies;
public ReferenceTypeSourceType getType() {
return type;
}
@ -48,4 +51,14 @@ public abstract class ReferenceTypeSourceBaseConfigurationEntity {
public void setType(ReferenceTypeSourceType 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 String dmpIndexName;
private String descriptionIndexName;
private int resetBatchSize;
private boolean enableIcuAnalysisPlugin;
public String getDmpIndexName() {
@ -40,4 +41,12 @@ public class AppElasticProperties {
public void setDescriptionIndexName(String 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
@Table(name = "\"DmpDescriptionTemplate\"")
public class DmpDescriptionTemplateEntity implements DataEntity<DmpDescriptionTemplateEntity, UUID> {
public class DmpDescriptionTemplateEntity {
@Id
@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) {
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
@Table(name = "\"DmpUser\"")
public class DmpUserEntity implements DataEntity {
public class DmpUserEntity {
@Id
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
@ -108,19 +108,4 @@ public class DmpUserEntity implements DataEntity {
public void setIsActive(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
@Table(name = "\"UserCredential\"")
public class UserCredentialEntity implements DataEntity<UserCredentialEntity, UUID> {
public class UserCredentialEntity {
@Id
@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) {
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
@Table(name = "\"UserDescriptionTemplate\"")
public class UserDescriptionTemplateEntity implements DataEntity<UserDescriptionTemplateEntity, UUID> {
public class UserDescriptionTemplateEntity {
@Id
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
private UUID id;
@ -102,21 +102,4 @@ public class UserDescriptionTemplateEntity implements DataEntity<UserDescription
public void setRole(UserDescriptionTemplateRole 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
@Table(name = "\"User\"")
public class UserEntity implements DataEntity<UserEntity, UUID> {
public class UserEntity {
@Id
@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) {
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
@Table(name = "\"UserRole\"")
public class UserRoleEntity implements DataEntity<UserRoleEntity, UUID> {
public class UserRoleEntity {
@Id
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
private UUID id;
@ -65,20 +65,4 @@ public class UserRoleEntity implements DataEntity<UserRoleEntity, UUID> {
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) {
String currentBase = base.isEmpty() ? "" : base + ".";
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;
}
}

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 + "dmps"))
// this.dmps = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields, currentBase + "dmps")).collect(Collectors.toSet());
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);
// 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);
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 + "dmps"))
// this.dmps = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields, currentBase + "dmps")).collect(Collectors.toSet());
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);
// 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);
return this;
}
}

View File

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

View File

@ -49,6 +49,7 @@ public class AuthenticationConfigurationBuilder extends BaseBuilder<Authenticati
List<AuthenticationConfiguration> models = new ArrayList<>();
for (AuthenticationConfigurationEntity d : data) {
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._authMethod))) m.setAuthMethod(d.getAuthMethod());
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.model.builder.BaseBuilder;
import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceBaseConfiguration;
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;
@ -21,12 +22,14 @@ import java.util.*;
public abstract class ReferenceTypeSourceBaseConfigurationBuilder<Model extends ReferenceTypeSourceBaseConfiguration, Entity extends ReferenceTypeSourceBaseConfigurationEntity> extends BaseBuilder<Model, Entity> {
protected EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
protected final BuilderFactory builderFactory;
@Autowired
public ReferenceTypeSourceBaseConfigurationBuilder(
ConventionService conventionService,
LoggerService logger) {
LoggerService logger, BuilderFactory builderFactory) {
super(conventionService, logger);
this.builderFactory = builderFactory;
}
public ReferenceTypeSourceBaseConfigurationBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -44,6 +47,7 @@ public abstract class ReferenceTypeSourceBaseConfigurationBuilder<Model extends
if (fields == null || data == null || fields.isEmpty())
return new ArrayList<>();
FieldSet dependenciesFields = fields.extractPrefixed(this.asPrefix(Model._dependencies));
List<Model> models = new ArrayList<>();
for (Entity d : data) {
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._ordinal))) m.setOrdinal(d.getOrdinal());
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);
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
public ReferenceTypeSourceExternalApiConfigurationBuilder(
ConventionService conventionService, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeSourceExternalApiConfigurationBuilder.class)));
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeSourceExternalApiConfigurationBuilder.class)), builderFactory);
this.builderFactory = builderFactory;
}

View File

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

View File

@ -3,7 +3,7 @@ package eu.eudat.model.censorship;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
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.tools.data.censor.CensorFactory;
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.convention.ConventionService;
@ -16,14 +16,14 @@ import java.util.UUID;
@Component
@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;
public ReferenceTypeSourceBaseConfigurationCensor(ConventionService conventionService,
AuthorizationService authService) {
public DependencyPropertyCensor(ConventionService conventionService,
AuthorizationService authService) {
super(conventionService);
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.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.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 {
@NotNull(message = "{validation.empty}")
private Boolean enabled;
@NotNull(message = "{validation.empty}")
private String authUrl;
@ -19,6 +21,14 @@ public class AuthenticationConfigurationPersist {
@NotNull(message = "{validation.empty}")
private String type;
public Boolean getEnabled() {
return enabled;
}
public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}
public String getAuthUrl() {
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 eu.eudat.commons.enums.ReferenceTypeSourceType;
import eu.eudat.commons.validation.ValidEnum;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import java.util.List;
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
@ -32,6 +35,8 @@ public abstract class ReferenceTypeSourceBaseConfigurationPersist {
@ValidEnum(message = "{validation.empty}")
private ReferenceTypeSourceType type;
@Valid
private List<ReferenceTypeSourceBaseDependencyPersist> dependencies;
public String getKey() {
return key;
@ -64,4 +69,12 @@ public abstract class ReferenceTypeSourceBaseConfigurationPersist {
public void setType(ReferenceTypeSourceType 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 final static String _enabled = "enabled";
private Boolean enabled;
public final static String _authUrl = "authUrl";
private String authUrl;
@ -19,6 +22,14 @@ public class AuthenticationConfiguration {
public final static String _type = "type";
private String type;
public Boolean getEnabled() {
return enabled;
}
public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}
public String getAuthUrl() {
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 java.util.List;
public abstract class ReferenceTypeSourceBaseConfiguration {
@ -17,6 +19,9 @@ public abstract class ReferenceTypeSourceBaseConfiguration {
public final static String _type = "type";
private ReferenceTypeSourceType type;
public final static String _dependencies = "dependencies";
private List<ReferenceTypeSourceBaseDependency> dependencies;
public ReferenceTypeSourceType getType() {
return type;
}
@ -48,4 +53,12 @@ public abstract class ReferenceTypeSourceBaseConfiguration {
public void setOrdinal(Integer 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);
}
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)
inClause.value(item);
predicates.add(inClause);

View File

@ -23,8 +23,8 @@ import eu.eudat.service.entitydoi.EntityDoiService;
import eu.eudat.utilities.pdf.PDFUtils;
import gr.cite.commons.web.authz.service.AuthorizationService;
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.ApiKeyWebfluxModel;
//import gr.cite.commons.web.oidc.apikey.webflux.ApiKeyExchangeFilterFunction;
//import gr.cite.commons.web.oidc.apikey.webflux.ApiKeyWebfluxModel;
import gr.cite.tools.data.query.Ordering;
import gr.cite.tools.fieldset.BaseFieldSet;
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);
if (source != null) {
String host = URI.create(source.getUrl()).getHost();
ApiKeyWebfluxModel apiKeyWebfluxModel = new ApiKeyWebfluxModel(host + "_" + source.getClientId(), source.getIssuerUrl(), source.getClientId(), source.getClientSecret(), source.getScope());
ApiKeyExchangeFilterFunction apiKeyExchangeFilterFunction = new ApiKeyExchangeFilterFunction(this.apiKeyCacheService, apiKeyWebfluxModel);
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));
return repository;
// ApiKeyWebfluxModel apiKeyWebfluxModel = new ApiKeyWebfluxModel(host + "_" + source.getClientId(), source.getIssuerUrl(), source.getClientId(), source.getClientSecret(), source.getScope());
// ApiKeyExchangeFilterFunction apiKeyExchangeFilterFunction = new ApiKeyExchangeFilterFunction(this.apiKeyCacheService, apiKeyWebfluxModel);
// 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));
// return repository;
}
return null;
}

View File

@ -7,6 +7,9 @@ import eu.eudat.commons.JsonHandlingService;
import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.enums.*;
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.FieldEntity;
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.DmpUserDeleter;
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.FieldPersist;
import eu.eudat.query.*;
@ -408,7 +414,7 @@ public class DmpServiceImpl implements DmpService {
}
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.setAccessType(model.getAccessType());
data.setUpdatedAt(Instant.now());
@ -424,6 +430,46 @@ public class DmpServiceImpl implements DmpService {
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 {
if (models == null || models.isEmpty())
return;
@ -532,14 +578,14 @@ public class DmpServiceImpl implements DmpService {
if (!this.conventionService.isListNullOrEmpty(persist.getFields())){
data.setFields(new ArrayList<>());
for (FieldPersist fieldPersist: persist.getFields()) {
data.getFields().add(this.buildFieldEntity(fieldPersist));
data.getFields().add(this.buildDmpContactEntity(fieldPersist));
}
}
return data;
}
private @NotNull FieldEntity buildFieldEntity(FieldPersist persist){
private @NotNull FieldEntity buildDmpContactEntity(FieldPersist persist){
FieldEntity data = new FieldEntity();
if (persist == null) return data;

View File

@ -24,4 +24,12 @@ public interface ElasticService {
void persistDescription(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.TypeMapping;
import co.elastic.clients.elasticsearch.indices.*;
import eu.eudat.authorization.Permission;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.configurations.elastic.AppElasticProperties;
import eu.eudat.data.DescriptionEntity;
@ -17,12 +18,19 @@ import eu.eudat.model.Description;
import eu.eudat.model.Dmp;
import eu.eudat.query.DescriptionQuery;
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.query.Ordering;
import gr.cite.tools.data.query.Paging;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.elastic.ElasticConstants;
import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
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.core.mapping.IndexCoordinates;
import org.springframework.stereotype.Service;
import org.springframework.web.context.annotation.RequestScope;
@Service
public class ElasticServiceImpl implements ElasticService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintServiceImpl.class));
public final AppElasticProperties appElasticProperties;
private final ElasticsearchClient restHighLevelClient;
private final ElasticsearchTemplate elasticsearchTemplate;
@ -44,8 +52,9 @@ public class ElasticServiceImpl implements ElasticService {
private final BuilderFactory builderFactory;
private final EntityManager entityManager;
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.restHighLevelClient = restHighLevelClient;
this.elasticsearchTemplate = elasticsearchTemplate;
@ -53,6 +62,7 @@ public class ElasticServiceImpl implements ElasticService {
this.builderFactory = builderFactory;
this.entityManager = entityManager;
this.messageSource = messageSource;
this.authorizationService = authorizationService;
}
@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")));
}
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());
}
@ -251,6 +261,8 @@ public class ElasticServiceImpl implements ElasticService {
}
//endregion
//region persist delete
@Override
public void persistDmp(DmpEntity dmp) throws IOException {
@ -303,4 +315,83 @@ public class ElasticServiceImpl implements ElasticService {
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 ConventionService conventionService;
private final MessageSource messageSource;
private final QueryFactory queryFactory;
private final XmlHandlingService xmlHandlingService;
private final ErrorThesaurusProperties errors;
public ReferenceTypeServiceImpl(
EntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory,
ConventionService conventionService, MessageSource messageSource, QueryFactory queryFactory,
ConventionService conventionService, MessageSource messageSource,
XmlHandlingService xmlHandlingService, ErrorThesaurusProperties errors) {
this.entityManager = entityManager;
this.authorizationService = authorizationService;
@ -67,7 +66,6 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
this.builderFactory = builderFactory;
this.conventionService = conventionService;
this.messageSource = messageSource;
this.queryFactory = queryFactory;
this.xmlHandlingService = xmlHandlingService;
this.errors = errors;
}
@ -185,6 +183,13 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
data.setLabel(persist.getLabel());
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;
}
@ -218,6 +223,7 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
AuthenticationConfigurationEntity data = new AuthenticationConfigurationEntity();
if (persist == null) return data;
data.setEnabled(persist.getEnabled());
data.setAuthUrl(persist.getAuthUrl());
data.setAuthMethod(persist.getAuthMethod());
data.setAuthRequestBody(persist.getAuthRequestBody());
@ -249,6 +255,35 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
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 {
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 int version;
private GrantQuery grantQuery;
private UserQueryOld userQuery;
// private UserQueryOld userQuery;
private DatasetQuery datasetQuery;
private List<Integer> statuses;
private Date created;
@ -101,13 +101,13 @@ public class DMPQuery extends Query<DmpEntity, UUID> {
this.modified = modified;
}
public UserQueryOld getUserQuery() {
return userQuery;
}
public void setUserQuery(UserQueryOld userQuery) {
this.userQuery = userQuery;
}
// public UserQueryOld getUserQuery() {
// return userQuery;
// }
//
// public void setUserQuery(UserQueryOld userQuery) {
// this.userQuery = userQuery;
// }
public DatasetQuery getDatasetQuery() {
return datasetQuery;
@ -129,10 +129,10 @@ public class DMPQuery extends Query<DmpEntity, UUID> {
if (this.getStatuses() != null && !this.getStatuses().isEmpty()) {
query.where((builder, root) -> root.get("status").in(this.getStatuses()));
}
if (this.userQuery != null) {
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));
}
// if (this.userQuery != null) {
// 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));
// }
if(this.datasetQuery != null){
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 ));

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 Date created;
private Date modified;
private UserQueryOld userQuery;
// private UserQueryOld userQuery;
public GrantQuery(DatabaseAccessLayer<Grant, UUID> databaseAccessLayer) {
super(databaseAccessLayer);
@ -81,13 +81,13 @@ public class GrantQuery extends Query<Grant, UUID> {
this.modified = modified;
}
public UserQueryOld getUserQuery() {
return userQuery;
}
public void setUserQuery(UserQueryOld userQuery) {
this.userQuery = userQuery;
}
// public UserQueryOld getUserQuery() {
// return userQuery;
// }
//
// public void setUserQuery(UserQueryOld userQuery) {
// this.userQuery = userQuery;
// }
@Override
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));
if (this.getStatuses() != null && !this.getStatuses().isEmpty())
query.where((builder, root) -> root.get("status").in(this.getStatuses()));
if (this.userQuery != null) {
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));
}
// if (this.userQuery != null) {
// 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));
// }
if (!this.getSelectionFields().isEmpty() && this.getSelectionFields() != null) {
query.withFields(this.getSelectionFields());
}

View File

@ -19,7 +19,7 @@ public class LockQuery extends Query<Lock, UUID> {
private UUID id;
private UUID target;
private UserQueryOld userQuery;
// private UserQueryOld userQuery;
private Date touchedAt;
public UUID getId() {
@ -38,13 +38,13 @@ public class LockQuery extends Query<Lock, UUID> {
this.target = target;
}
public UserQueryOld getUserQuery() {
return userQuery;
}
public void setUserQuery(UserQueryOld userQuery) {
this.userQuery = userQuery;
}
// public UserQueryOld getUserQuery() {
// return userQuery;
// }
//
// public void setUserQuery(UserQueryOld userQuery) {
// this.userQuery = userQuery;
// }
public Date getTouchedAt() {
return touchedAt;
@ -71,10 +71,10 @@ public class LockQuery extends Query<Lock, UUID> {
if (this.target != null) {
query.where(((builder, root) -> builder.equal(root.get("target"), this.target)));
}
if (this.userQuery != null) {
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));
}
// if (this.userQuery != null) {
// 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));
// }
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.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.model.DmpUser;
import eu.eudat.model.file.FileEnvelope;
import eu.eudat.utilities.pdf.PDFUtils;
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.listingmodels.DataManagementPlanListingModel;
import eu.eudat.models.data.listingmodels.DataManagementPlanOverviewModel;
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
import eu.eudat.models.data.listingmodels.VersionListingModel;
import eu.eudat.query.DMPQuery;
import eu.eudat.types.ApiMessageCode;
@ -353,7 +353,7 @@ public class DMPs extends BaseController {
@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);
try {

View File

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

View File

@ -5,7 +5,6 @@ import eu.eudat.exceptions.emailconfirmation.HasConfirmedEmailException;
import eu.eudat.exceptions.emailconfirmation.TokenExpiredException;
import eu.eudat.logic.managers.UnlinkEmailConfirmationManager;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.userinfo.UserUnlinkRequestModel;
import eu.eudat.types.ApiMessageCode;
import gr.cite.commons.web.authz.service.AuthorizationService;
import org.springframework.beans.factory.annotation.Autowired;
@ -48,16 +47,16 @@ public class EmailUnlinkConfirmation {
}
}
@Transactional
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem> sendUnlinkConfirmationEmail(@RequestBody UserUnlinkRequestModel requestModel) {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
try {
this.unlinkEmailConfirmationManager.sendConfirmationEmail(requestModel.getEmail(), requestModel.getUserId(), requestModel.getProvider());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE));
} catch (Exception ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message("Could not send unlink email."));
}
}
// @Transactional
// @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
// public @ResponseBody
// ResponseEntity<ResponseItem> sendUnlinkConfirmationEmail(@RequestBody UserUnlinkRequestModel requestModel) {
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
// try {
// this.unlinkEmailConfirmationManager.sendConfirmationEmail(requestModel.getEmail(), requestModel.getUserId(), requestModel.getProvider());
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE));
// } catch (Exception ex) {
// 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;
import eu.eudat.authorization.Permission;
import eu.eudat.data.query.items.item.userinfo.UserInfoRequestItem;
import eu.eudat.logic.managers.InvitationsManager;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.invitation.Invitation;
import eu.eudat.models.data.userinfo.UserInfoInvitationModel;
import eu.eudat.types.ApiMessageCode;
import gr.cite.commons.web.authz.service.AuthorizationService;
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));
}
@RequestMapping(method = RequestMethod.POST, value = {"/getUsers"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
// ResponseEntity<ResponseItem<List<UserInfoInvitationModel>>> getUsers() throws IllegalAccessException, InstantiationException {
ResponseEntity<ResponseItem<List<UserInfoInvitationModel>>> getUsers(@RequestBody UserInfoRequestItem userInfoRequestItem) throws IllegalAccessException, InstantiationException, InvalidApplicationException {
// List<UserInfoInvitationModel> users = invitationsManager.getUsers(principal);
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
List<UserInfoInvitationModel> users = invitationsManager.getUsersWithCriteria(userInfoRequestItem);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<UserInfoInvitationModel>>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(users));
}
// @RequestMapping(method = RequestMethod.POST, value = {"/getUsers"}, consumes = "application/json", produces = "application/json")
// public @ResponseBody
//// ResponseEntity<ResponseItem<List<UserInfoInvitationModel>>> getUsers() throws IllegalAccessException, InstantiationException {
// ResponseEntity<ResponseItem<List<UserInfoInvitationModel>>> getUsers(@RequestBody UserInfoRequestItem userInfoRequestItem) throws IllegalAccessException, InstantiationException, InvalidApplicationException {
//// List<UserInfoInvitationModel> users = invitationsManager.getUsers(principal);
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
//
// List<UserInfoInvitationModel> users = invitationsManager.getUsersWithCriteria(userInfoRequestItem);
// 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;
}
@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")
@Transactional
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);
if (this.id != null) dmpQuery.setId(this.id.getValue());
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));
return dmpQuery;
}

View File

@ -103,7 +103,7 @@ public class GrantCriteria {
List<String> fields = this.buildFields("");
GrantQuery query = new GrantQuery(dao.getGrantDao(), fields);
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;
}
}

View File

@ -7,7 +7,8 @@ import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.node.JsonNodeType;
import eu.eudat.criteria.entities.Criteria;
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.util.*;
@ -57,10 +58,10 @@ public class UserCriteria {
return new LinkedList<>(fields);
}
public UserQueryOld buildQuery(DatabaseRepository dao) {
public UserQuery buildQuery(DatabaseRepository dao) {
List<String> fields = this.buildFields("");
UserQueryOld query = new UserQueryOld(dao.getUserInfoDao(), fields);
if (this.id != null) query.setId(this.id.getValue());
return query;
// UserQuery query = new UserQuery(dao.getUserInfoDao(), fields);
// if (this.id != null) query.setId(this.id.getValue());
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.PublicContactEmailModel;
import eu.eudat.query.UserContactInfoQuery;
import eu.eudat.query.UserQuery;
import eu.eudat.service.mail.SimpleMail;
import gr.cite.tools.data.query.Ordering;
import gr.cite.tools.data.query.QueryFactory;
@ -34,7 +35,7 @@ public class ContactEmailManager {
}
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();
UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId());
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.logic.builders.entity.UserInfoBuilder;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.model.DmpUser;
import eu.eudat.model.mapper.deposit.DMPToDepositMapper;
import eu.eudat.logic.services.ApiContext;
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.commons.types.xml.XmlBuilder;
import eu.eudat.model.file.FileEnvelope;
import eu.eudat.query.DmpDescriptionTemplateQuery;
import eu.eudat.query.*;
import eu.eudat.utilities.pdf.PDFUtils;
import eu.eudat.logic.utilities.documents.types.ParagraphStyle;
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.project.ProjectDMPEditorModel;
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.service.dmpblueprint.DmpBlueprintService;
import eu.eudat.types.MetricNames;
@ -275,7 +273,7 @@ public class DataManagementPlanManager {
QueryableList<DescriptionEntity> datasetItems = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetCriteria)
.orderBy((builder, root) -> builder.desc(root.get("modified")));
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<>();
roles.add(0);
roles.add(1);
@ -505,7 +503,7 @@ public class DataManagementPlanManager {
if (newDmp.getStatus().equals(DmpStatus.Finalized)) {
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());
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());
DmpEntity finalNewDmp = newDmp;
this.databaseRepository.getUserDmpDao().asQueryable().where((builder, root) -> root.get("dmp").in(finalNewDmp.getId())).toList();
if (this.databaseRepository.getUserDmpDao().asQueryable().where((builder, root) -> root.get("dmp").in(finalNewDmp.getId())).toList()!= null &&
this.databaseRepository.getUserDmpDao().asQueryable().where((builder, root) -> root.get("dmp").in(finalNewDmp.getId())).toList().stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUserId()))
if (this.queryFactory.query(DmpUserQuery.class).dmpIds(finalNewDmp.getId()).collect() != null &&
this.queryFactory.query(DmpUserQuery.class).dmpIds(finalNewDmp.getId()).collect().stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUserId()))
.collect(Collectors.toList()).size() == 0) {
List<DmpUserEntity> userDMPList = new ArrayList<>(this.databaseRepository.getUserDmpDao().asQueryable().where((builder, root) -> root.get("dmp").in(finalNewDmp.getId())).toList());
for (UserInfoListingModel userInfoListingModel : dataManagementPlan.getUsers()) {
List<DmpUserEntity> userDMPList = new ArrayList<>(this.queryFactory.query(DmpUserQuery.class).dmpIds(finalNewDmp.getId()).collect());
for (DmpUser userInfoListingModel : dataManagementPlan.getUsers()) {
for (DmpUserEntity userDMP : userDMPList) {
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()) {
clearUsers(newDmp);
for (UserInfoListingModel userListing : dataManagementPlan.getUsers()) {
UserEntity tempUser = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userListing.getId());
assignUser(dmp, tempUser, DmpUserRole.of((short)userListing.getRole()));
for (DmpUser userListing : dataManagementPlan.getUsers()) {
UserEntity tempUser = this.queryFactory.query(UserQuery.class).ids(userListing.getId()).first();
assignUser(dmp, tempUser, userListing.getRole());
}
}
@ -621,8 +618,8 @@ public class DataManagementPlanManager {
}
}
if (dataManagementPlan.getAssociatedUsers().size() == 0)
assignUser(newDmp, user);
// if (dataManagementPlan.getAssociatedUsers().size() == 0)
// assignUser(newDmp, user);
UUID dmpId = newDmp.getId();
//TODO
@ -668,7 +665,7 @@ public class DataManagementPlanManager {
if (tempDMP.getStatus().equals(DmpStatus.Finalized)) {
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();
if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Organizations)) {
@ -782,14 +779,13 @@ public class DataManagementPlanManager {
copyDatasets(newDmp, databaseRepository.getDatasetDao());
databaseRepository
.getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), oldDmp.getId()))
.toList().stream().forEach(userDMP -> {
this.queryFactory.query(DmpUserQuery.class).dmpIds(oldDmp.getId()).collect()
.stream().forEach(userDMP -> {
DmpUserEntity temp = new DmpUserEntity();
temp.setUserId(userDMP.getUserId());
temp.setRole(userDMP.getRole());
temp.setDmp(newDmp.getId());
apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().createOrUpdate(temp);
// apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().createOrUpdate(temp);
});
//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);
}
@ -1316,7 +1312,7 @@ public class DataManagementPlanManager {
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
//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);
metricsManager.decreaseValue(MetricNames.DMP, 1, MetricNames.DRAFT);
metricsManager.increaseValue(MetricNames.DMP, 1, MetricNames.FINALIZED);
@ -1344,14 +1340,14 @@ public class DataManagementPlanManager {
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);
if (!isUserOwnerOfDmp(dmp))
throw new Exception("User does not have the privilege to do this action.");
clearUsers(dmp);
for (UserInfoListingModel userListing : users) {
UserEntity tempUser = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userListing.getId());
assignUser(dmp, tempUser, DmpUserRole.of((short)userListing.getRole()));
for (DmpUser userListing : users) {
UserEntity tempUser = this.queryFactory.query(UserQuery.class).ids(userListing.getId()).first();
assignUser(dmp, tempUser, userListing.getRole());
}
}
@ -1824,14 +1820,14 @@ public class DataManagementPlanManager {
Element dmpContactName = xmlDoc.createElement("name");
Element dmpContactEmail = xmlDoc.createElement("email");
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());
}
else{
Iterator<DmpUserEntity> users = new ArrayList<DmpUserEntity>().iterator(); //TODO dmp.getUsers().iterator();
if(users.hasNext()){
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());
}
}
@ -1846,7 +1842,7 @@ public class DataManagementPlanManager {
Element dmpContributorName = xmlDoc.createElement("name");
Element dmpContributorEmail= xmlDoc.createElement("email");
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());
dmpContributorElement.appendChild(dmpContributorName);
dmpContributorElement.appendChild(dmpContributorEmail);
@ -2245,7 +2241,7 @@ public class DataManagementPlanManager {
researchers.add(researcher);
}
List<UserListingModel> associatedUsers = new LinkedList<>();
//List<UserListingModel> associatedUsers = new LinkedList<>();
List<DynamicFieldWithValue> dynamicFields = new LinkedList<>();
// Sets properties.
@ -2254,7 +2250,7 @@ public class DataManagementPlanManager {
dm.setProfiles(associatedProfiles);
dm.setOrganisations(organisations); // Sets organisations 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.setDefinition(dmpProfile);
//ObjectMapper mapper = new ObjectMapper();
@ -2328,7 +2324,7 @@ public class DataManagementPlanManager {
for (MultipartFile file: files) {
DmpEntity dmp = rdaManager.convertToEntity(new String(file.getBytes(), "UTF-8"), profiles);
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.setCreatorId(me.getId());
//TODO
@ -2410,12 +2406,12 @@ public class DataManagementPlanManager {
userDMP.setDmp(dmp.getId());
userDMP.setUserId(userInfo.getId());
userDMP.setRole(role);
databaseRepository.getUserDmpDao().createOrUpdate(userDMP);
// databaseRepository.getUserDmpDao().createOrUpdate(userDMP);
}
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();
userDMPs.forEach(userDMP -> apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().delete(userDMP));
List<DmpUserEntity> userDMPs = this.queryFactory.query(DmpUserQuery.class).dmpIds(dmp.getId()).collect();
// userDMPs.forEach(userDMP -> apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().delete(userDMP));
}
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 {
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) {
if (!userDMP.getUserId().equals(user.getId())) {
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.query.DescriptionTemplateQuery;
import eu.eudat.query.DmpDescriptionTemplateQuery;
import eu.eudat.query.DmpUserQuery;
import eu.eudat.query.UserContactInfoQuery;
import eu.eudat.queryable.QueryableList;
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 {
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) {
if (!userDMP.getUserId().equals(user.getId())) {
Notification notification = new Notification();

View File

@ -1,13 +1,14 @@
package eu.eudat.logic.managers;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.UserCredentialEntity;
import eu.eudat.data.old.EmailConfirmation;
import eu.eudat.data.UserEntity;
import eu.eudat.exceptions.emailconfirmation.HasConfirmedEmailException;
import eu.eudat.exceptions.emailconfirmation.TokenExpiredException;
import eu.eudat.logic.services.ApiContext;
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.stereotype.Component;
@ -20,12 +21,14 @@ public class EmailConfirmationManager {
private ApiContext apiContext;
private DatabaseRepository databaseRepository;
private final UserScope userScope;
private final QueryFactory queryFactory;
@Autowired
public EmailConfirmationManager(ApiContext apiContext, UserScope userScope) {
public EmailConfirmationManager(ApiContext apiContext, UserScope userScope, QueryFactory queryFactory) {
this.apiContext = apiContext;
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
this.userScope = userScope;
this.queryFactory = queryFactory;
}
public void confirmEmail(String token) throws TokenExpiredException, HasConfirmedEmailException, InvalidApplicationException {
@ -33,8 +36,7 @@ public class EmailConfirmationManager {
.getDatabaseRepository().getLoginConfirmationEmailDao().asQueryable()
.where((builder, root) -> builder.equal(root.get("token"), UUID.fromString(token))).getSingle();
UserEntity user = databaseRepository.getUserInfoDao().asQueryable()
.where((builder, root) -> builder.equal(root.get("id"), loginConfirmationEmail.getUserId())).getSingle();
UserEntity user = this.queryFactory.query(UserQuery.class).ids(loginConfirmationEmail.getUserId()).first();
// if (user.getEmail() != null) //TODO
// throw new HasConfirmedEmailException("User already has confirmed his Email.");
@ -45,12 +47,12 @@ public class EmailConfirmationManager {
loginConfirmationEmail.setIsConfirmed(true);
// 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) {
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
databaseRepository.getCredentialDao().createOrUpdate(credential);
UserEntity oldUser = databaseRepository.getUserInfoDao().asQueryable().where((builder, root) -> builder.equal(root.get("email"), loginConfirmationEmail.getEmail())).getSingle();
// databaseRepository.getCredentialDao().createOrUpdate(credential);
UserEntity oldUser = this.queryFactory.query(UserQuery.class).emails(loginConfirmationEmail.getEmail()).first();
mergeNewUserToOld(user, oldUser);
// expireUserToken(user); //TODO: Authn
databaseRepository.getLoginConfirmationEmailDao().createOrUpdate(loginConfirmationEmail);
@ -58,9 +60,9 @@ public class EmailConfirmationManager {
}
// user.setEmail(loginConfirmationEmail.getEmail()); //TODO
databaseRepository.getUserInfoDao().createOrUpdate(user);
UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable()
.where((builder, root) -> builder.equal(root.get("userId"), user.getId())).getSingle();
// databaseRepository.getUserInfoDao().createOrUpdate(user);
// UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable()
// .where((builder, root) -> builder.equal(root.get("userId"), user.getId())).getSingle();
// if(credential.getEmail() == null){//TODO
// credential.setEmail(user.getEmail());
// databaseRepository.getCredentialDao().createOrUpdate(credential);
@ -69,7 +71,7 @@ public class EmailConfirmationManager {
}
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
// 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 {
UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userId"), newUser.getId())).getSingle();
credential.setUserId(oldUser.getId());
databaseRepository.getCredentialDao().createOrUpdate(credential);
// UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userId"), newUser.getId())).getSingle();
// credential.setUserId(oldUser.getId());
// 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.DmpUserEntity;
import eu.eudat.data.UserEntity;
import eu.eudat.data.query.items.item.userinfo.UserInfoRequestItem;
import eu.eudat.exceptions.security.UnauthorisedException;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.model.User;
import eu.eudat.models.data.invitation.Invitation;
import eu.eudat.models.data.userinfo.UserInfoInvitationModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -49,8 +48,8 @@ public class InvitationsManager {
item.setId(existingUser.getId());
}
});
List<UserInfoInvitationModel> alreadySignedInUsers = invitation.getUsers().stream().filter(item -> item.getId() != null).collect(Collectors.toList());
List<UserEntity> alreadySignedInUsersEntities = alreadySignedInUsers.stream().map(UserInfoInvitationModel::toDataModel).collect(Collectors.toList());
List<User> alreadySignedInUsers = invitation.getUsers().stream().filter(item -> item.getId() != null).collect(Collectors.toList());
List<UserEntity> alreadySignedInUsersEntities = new ArrayList<>(); //alreadySignedInUsers.stream().map(User::toDataModel).collect(Collectors.toList());
List<DmpUserEntity> userInfoToUserDmp = new LinkedList<>();
for (UserEntity userInfo : alreadySignedInUsersEntities) {
DmpUserEntity userDMP = new DmpUserEntity();
@ -65,11 +64,11 @@ public class InvitationsManager {
}*/
}
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);
}
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());
List<UserInfo> users = apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().getAssociated(principalUser).stream().map(userAssociation -> {
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()))
// .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());
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;
}
public List<UserInfoInvitationModel> getUsersWithCriteria(UserInfoRequestItem userInfoRequestItem) throws IllegalAccessException, InstantiationException, InvalidApplicationException {
//TODO
// List<UserInfo> users = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao()
// .getAuthenticated(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable()
// .where(((builder, root) ->
// 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)
// .filter(userInfo -> !userInfo.getId().equals(this.userScope.getUserIdSafe())).filter(StreamDistinctBy.distinctByKey(UserInfo::getId))
// .filter(userInfo -> (userInfoRequestItem == null || userInfoRequestItem.getCriteria() == null || userInfoRequestItem.getCriteria().getLike() == null
// || userInfo.getName().toLowerCase().contains(userInfoRequestItem.getCriteria().getLike().toLowerCase())
// || (userInfo.getEmail().toLowerCase().contains(userInfoRequestItem.getCriteria().getLike().toLowerCase()))))
// .collect(Collectors.toList());
//// .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());
// return userModels;
return new ArrayList<>();
}
// public List<UserInfoInvitationModel> getUsersWithCriteria(UserInfoRequestItem userInfoRequestItem) throws IllegalAccessException, InstantiationException, InvalidApplicationException {
// //TODO
//// List<UserInfo> users = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao()
//// .getAuthenticated(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable()
//// .where(((builder, root) ->
//// 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)
//// .filter(userInfo -> !userInfo.getId().equals(this.userScope.getUserIdSafe())).filter(StreamDistinctBy.distinctByKey(UserInfo::getId))
//// .filter(userInfo -> (userInfoRequestItem == null || userInfoRequestItem.getCriteria() == null || userInfoRequestItem.getCriteria().getLike() == null
//// || userInfo.getName().toLowerCase().contains(userInfoRequestItem.getCriteria().getLike().toLowerCase())
//// || (userInfo.getEmail().toLowerCase().contains(userInfoRequestItem.getCriteria().getLike().toLowerCase()))))
//// .collect(Collectors.toList());
////// .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());
//// return userModels;
// return new ArrayList<>();
// }
public UUID assignUserAcceptedInvitation(UUID invitationID) throws UnauthorisedException, JAXBException, IOException, InvalidApplicationException {
//TODO

View File

@ -2,7 +2,6 @@ package eu.eudat.logic.managers;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.UserCredentialEntity;
import eu.eudat.data.DmpUserEntity;
import eu.eudat.data.old.EmailConfirmation;
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.operations.DatabaseRepository;
import eu.eudat.query.UserQuery;
import gr.cite.tools.data.query.QueryFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -30,13 +31,15 @@ public class MergeEmailConfirmationManager {
private DatabaseRepository databaseRepository;
// private DmpRepository dmpRepository;
private final UserScope userScope;
private final QueryFactory queryFactory;
@Autowired
public MergeEmailConfirmationManager(ApiContext apiContext, UserScope userScope) {
public MergeEmailConfirmationManager(ApiContext apiContext, UserScope userScope, QueryFactory queryFactory) {
this.apiContext = apiContext;
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
// this.dmpRepository = apiContext.getOperationsContext().getElasticRepository().getDmpRepository();
this.userScope = userScope;
this.queryFactory = queryFactory;
}
@Transactional
@ -48,14 +51,12 @@ public class MergeEmailConfirmationManager {
if (loginConfirmationEmail.getExpiresAt().compareTo(new Date()) < 0)
throw new TokenExpiredException("Token has expired.");
UserEntity userToBeMerged = databaseRepository.getUserInfoDao().asQueryable()
.where((builder, root) -> builder.equal(root.get("id"), loginConfirmationEmail.getUserId())).getSingle();
UserEntity userToBeMerged = this.queryFactory.query(UserQuery.class).ids(loginConfirmationEmail.getUserId()).first();
String userToBeMergedEmail = ""; //TODO userToBeMerged.getEmail();
try {
Map<String, Object> map = new ObjectMapper().readValue(loginConfirmationEmail.getData(), HashMap.class);
UUID otherUserId = UUID.fromString((String) map.get("userId"));
UserEntity user = databaseRepository.getUserInfoDao().asQueryable()
.where((builder, root) -> builder.equal(root.get("id"), otherUserId)).getSingle();
UserEntity user = this.queryFactory.query(UserQuery.class).ids(otherUserId).first();
// 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")));
@ -70,7 +71,7 @@ public class MergeEmailConfirmationManager {
}
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
// if (user.getEmail() != null && !user.getEmail().equals(email)) {
// apiContext.getUtilitiesService().getConfirmationEmailService().createMergeConfirmationEmail(
@ -85,14 +86,14 @@ public class MergeEmailConfirmationManager {
@Transactional
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();
credential.setUserId(newUser.getId());
databaseRepository.getCredentialDao().createOrUpdate(credential);
List<DmpUserEntity> userDmps = databaseRepository.getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("user"), oldUser)).toList();
userDmps.forEach(userDmp -> {
userDmp.setUserId(newUser.getId());
databaseRepository.getUserDmpDao().createOrUpdate(userDmp);
});
// 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());
// databaseRepository.getCredentialDao().createOrUpdate(credential);
// List<DmpUserEntity> userDmps = databaseRepository.getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("user"), oldUser)).toList();
// userDmps.forEach(userDmp -> {
// userDmp.setUserId(newUser.getId());
// databaseRepository.getUserDmpDao().createOrUpdate(userDmp);
// });
//TODO
// try {
//
@ -129,12 +130,12 @@ public class MergeEmailConfirmationManager {
// }
oldUser.setIsActive(IsActive.Inactive);
//TODO oldUser.setEmail(null);
List<UserCredentialEntity> credentials = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userId"), oldUser.getId())).toList();
credentials.forEach(cred -> {
if (cred.getId() != credential.getId()) {
databaseRepository.getCredentialDao().delete(cred);
}
});
databaseRepository.getUserInfoDao().createOrUpdate(oldUser);
// List<UserCredentialEntity> credentials = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userId"), oldUser.getId())).toList();
// credentials.forEach(cred -> {
// if (cred.getId() != credential.getId()) {
// databaseRepository.getCredentialDao().delete(cred);
// }
// });
// 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.NotifyState;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.query.UserQuery;
import eu.eudat.service.mail.MailService;
import eu.eudat.service.mail.SimpleMail;
import gr.cite.tools.data.query.QueryFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -26,12 +28,14 @@ public class NotificationManager {
private ApiContext apiContext;
private Environment environment;
private MailService mailService;
private final QueryFactory queryFactory;
@Autowired
public NotificationManager(ApiContext apiContext, Environment environment, MailService mailService) {
public NotificationManager(ApiContext apiContext, Environment environment, MailService mailService, QueryFactory queryFactory) {
this.apiContext = apiContext;
this.environment = environment;
this.mailService = mailService;
this.queryFactory = queryFactory;
}
@Transactional
@ -52,7 +56,7 @@ public class NotificationManager {
notification.setUpdatedAt(new Date());
try {
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 contentTemplate = "";

View File

@ -9,6 +9,8 @@ import eu.eudat.data.old.*;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository;
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.stereotype.Component;
@ -22,13 +24,16 @@ public class QuickWizardManager {
private ApiContext apiContext;
private DatabaseRepository databaseRepository;
private DatasetManager datasetManager;
private final QueryFactory queryFactory;
private final UserScope userScope;
@Autowired
public QuickWizardManager(ApiContext apiContext, DatasetManager datasetManager, UserScope userScope) {
public QuickWizardManager(ApiContext apiContext, DatasetManager datasetManager, QueryFactory queryFactory, UserScope userScope) {
this.apiContext = apiContext;
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
this.datasetManager = datasetManager;
this.queryFactory = queryFactory;
this.userScope = userScope;
}
@ -40,13 +45,13 @@ public class QuickWizardManager {
public Grant createOrUpdate(eu.eudat.models.data.grant.Grant grant) throws ParseException, IOException, InvalidApplicationException {
Grant grantEntity = grant.toDataModel();
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);
}
public Project createOrUpdate(eu.eudat.models.data.project.Project project) throws InvalidApplicationException {
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);
}
@ -56,7 +61,7 @@ public class QuickWizardManager {
//TODO
//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);
createGrantIfItDoesntExist(newDmp, user);
//TODO
@ -69,8 +74,8 @@ public class QuickWizardManager {
//TODO
//apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant());
DmpEntity dmpret = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
if (dataManagementPlan.getAssociatedUsers().size() == 0)
assignUser(newDmp, user, apiContext);
// if (dataManagementPlan.getAssociatedUsers().size() == 0)
// assignUser(newDmp, user, apiContext);
// this.updateIndex(dmpret);
@ -88,7 +93,7 @@ public class QuickWizardManager {
userDMP.setDmp(dmp.getId());
userDMP.setUserId(userInfo.getId());
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 {

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.NoURLFound;
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
import eu.eudat.query.UserQuery;
import eu.eudat.queryable.QueryableList;
import eu.eudat.logic.services.ApiContext;
import gr.cite.tools.data.query.QueryFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -31,18 +33,20 @@ public class ResearcherManager {
private RemoteFetcher remoteFetcher;
private ConfigLoader configLoader;
private final UserScope userScope;
private final QueryFactory queryFactory;
@Autowired
public ResearcherManager(ApiContext apiContext, ConfigLoader configLoader, UserScope userScope) {
public ResearcherManager(ApiContext apiContext, ConfigLoader configLoader, UserScope userScope, QueryFactory queryFactory) {
this.apiContext = apiContext;
this.remoteFetcher = apiContext.getOperationsContext().getRemoteFetcher();
this.configLoader = configLoader;
this.userScope = userScope;
this.queryFactory = queryFactory;
}
public Researcher create(eu.eudat.models.data.researcher.Researcher researcher) throws Exception {
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);
}

View File

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

View File

@ -1,49 +1,27 @@
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.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.models.HintedModelFactory;
import eu.eudat.models.data.dmp.DataManagementPlan;
import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.userinfo.UserCredential;
import eu.eudat.models.data.userinfo.UserListingModel;
import eu.eudat.models.data.userinfo.UserProfile;
import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.data.UserCredentialEntity;
import eu.eudat.data.UserEntity;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.query.UserCredentialQuery;
import eu.eudat.queryable.QueryableList;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.query.QueryFactory;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
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.w3c.dom.Document;
import org.w3c.dom.Element;
import javax.management.InvalidApplicationException;
import java.io.*;
import java.nio.file.Files;
import java.util.*;
import java.util.stream.Collectors;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@Component
public class UserManager {
@ -75,125 +53,125 @@ public class UserManager {
return datasetprofile;
}
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> 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();
}
// 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> 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();
// }
public List<UserCredential> getCredentials(UUID userId) throws InvalidApplicationException {
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 {
// 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 UserProfile getSingle(UUID userId) throws Exception {
UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userId);
UserProfile profile = new UserProfile().fromDataModel(user);
List<Integer> roles = new LinkedList<>();
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
criteria.setAllVersions(false);
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 UserProfile getSingle(UUID userId) throws Exception {
// UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userId);
// UserProfile profile = new UserProfile().fromDataModel(user);
// List<Integer> roles = new LinkedList<>();
// DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
// criteria.setAllVersions(false);
// 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 {
UserEntity userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(user.getId());
//userInfo.getUserRoles().stream().forEach(item -> apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().delete(item)); //TODO
for (String role : user.getAppRoles()) {
UserRoleEntity userRole = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserRoleBuilder.class).role(role).userInfo(userInfo).build();
apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().createOrUpdate(userRole);
}
}
// public void editRoles(UserListingModel user) throws InvalidApplicationException {
// UserEntity userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(user.getId());
// //userInfo.getUserRoles().stream().forEach(item -> apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().delete(item)); //TODO
// for (String role : user.getAppRoles()) {
// UserRoleEntity userRole = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserRoleBuilder.class).role(role).userInfo(userInfo).build();
// apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().createOrUpdate(userRole);
// }
// }
public void updateSettings(Map<String, Object> settings) throws IOException, InvalidApplicationException {
UserEntity userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId());
apiContext.getOperationsContext().getDatabaseRepository().detachEntity(userInfo);
HashMap<String, Object> result =
new ObjectMapper().readValue(userInfo.getAdditionalInfo(), HashMap.class);
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());
apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao()
.createOrUpdate(userInfo);
}
public DataTableData<UserListingModel> getCollaboratorsPaged(UserInfoTableRequestItem userInfoTableRequestItem) throws Exception {
UserInfoDao userInfoDao = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao();
QueryableList<UserEntity> users = userInfoDao.getWithCriteria(userInfoTableRequestItem.getCriteria());
List<UserListingModel> colaborators = userInfoDao.getAuthenticated(users, this.userScope.getUserId())
.withHint(HintedModelFactory.getHint(UserListingModel.class))
.select(colaborator -> new UserListingModel().fromDataModel(colaborator));
DataTableData<UserListingModel> dataTableData = new DataTableData<>();
dataTableData.setData(colaborators);
dataTableData.setTotalCount((long) colaborators.size());
return dataTableData;
}
public ResponseEntity<byte[]> exportToCsv() throws IOException, InvalidApplicationException {
this.authorizationService.authorizeForce(Permission.AdminRole);
List<UserEntity> users = this.apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().asQueryable().toList();
StringBuilder resultBuilder = new StringBuilder();
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(",")
//TODO .append(user.getEmail()).append("\n")
);
String result = resultBuilder.toString();
String fileName = "Users_dump";//dmp.getLabel();
fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", "");
String uuid = UUID.randomUUID().toString();
File file = new File(this.environment.getProperty("temp.temp") + uuid + ".csv");
OutputStream output = new FileOutputStream(file);
try {
// mapper.writeValue(file, rdaExportModel);
output.write(result.getBytes());
output.flush();
output.close();
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
InputStream resource = new FileInputStream(file);
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(file.length());
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
responseHeaders.set("Content-Disposition", "attachment;filename=" + fileName + ".csv");
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource);
resource.close();
Files.deleteIfExists(file.toPath());
return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK);
}
public UserProfile getFromEmail(String email) throws InvalidApplicationException {
UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().asQueryable().where((builder, root) -> builder.equal(root.get("email"), email)).getSingle();
return new UserProfile().fromDataModel(user);
}
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();
}
// public void updateSettings(Map<String, Object> settings) throws IOException, InvalidApplicationException {
// UserEntity userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId());
// apiContext.getOperationsContext().getDatabaseRepository().detachEntity(userInfo);
// HashMap<String, Object> result =
// new ObjectMapper().readValue(userInfo.getAdditionalInfo(), HashMap.class);
// 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());
// apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao()
// .createOrUpdate(userInfo);
// }
//
// public DataTableData<UserListingModel> getCollaboratorsPaged(UserInfoTableRequestItem userInfoTableRequestItem) throws Exception {
// UserInfoDao userInfoDao = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao();
// QueryableList<UserEntity> users = userInfoDao.getWithCriteria(userInfoTableRequestItem.getCriteria());
//
// List<UserListingModel> colaborators = userInfoDao.getAuthenticated(users, this.userScope.getUserId())
// .withHint(HintedModelFactory.getHint(UserListingModel.class))
// .select(colaborator -> new UserListingModel().fromDataModel(colaborator));
//
// DataTableData<UserListingModel> dataTableData = new DataTableData<>();
// dataTableData.setData(colaborators);
// dataTableData.setTotalCount((long) colaborators.size());
// return dataTableData;
// }
//
// public ResponseEntity<byte[]> exportToCsv() throws IOException, InvalidApplicationException {
//
// this.authorizationService.authorizeForce(Permission.AdminRole);
//
// List<UserEntity> users = this.apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().asQueryable().toList();
// StringBuilder resultBuilder = new StringBuilder();
// 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(",")
////TODO .append(user.getEmail()).append("\n")
// );
// String result = resultBuilder.toString();
// String fileName = "Users_dump";//dmp.getLabel();
// fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", "");
// String uuid = UUID.randomUUID().toString();
// File file = new File(this.environment.getProperty("temp.temp") + uuid + ".csv");
// OutputStream output = new FileOutputStream(file);
// try {
//// mapper.writeValue(file, rdaExportModel);
// output.write(result.getBytes());
// output.flush();
// output.close();
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// }
//
// InputStream resource = new FileInputStream(file);
// HttpHeaders responseHeaders = new HttpHeaders();
// responseHeaders.setContentLength(file.length());
// responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
// responseHeaders.set("Content-Disposition", "attachment;filename=" + fileName + ".csv");
// responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
// responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
//
// byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource);
// resource.close();
// Files.deleteIfExists(file.toPath());
// return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK);
// }
//
// public UserProfile getFromEmail(String email) throws InvalidApplicationException {
// UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().asQueryable().where((builder, root) -> builder.equal(root.get("email"), email)).getSingle();
// return new UserProfile().fromDataModel(user);
// }
//
// 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;
import eu.eudat.data.dao.entities.*;
import eu.eudat.data.dao.entities.security.CredentialDao;
public interface DatabaseRepository {
@ -13,8 +12,6 @@ public interface DatabaseRepository {
DMPDao getDmpDao();
DmpDatasetProfileDao getDmpDatasetProfileDao();
OrganisationDao getOrganisationDao();
GrantDao getGrantDao();
@ -25,20 +22,10 @@ public interface DatabaseRepository {
ServiceDao getServiceDao();
UserInfoDao getUserInfoDao();
UserRoleDao getUserRoleDao();
InvitationDao getInvitationDao();
CredentialDao getCredentialDao();
ExternalDatasetDao getExternalDatasetDao();
UserDatasetProfileDao getUserDatasetProfileDao();
UserDmpDao getUserDmpDao();
ContentDao getContentDao();
EmailConfirmationDao getLoginConfirmationEmailDao();

View File

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

View File

@ -51,6 +51,7 @@ import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import jakarta.xml.bind.JAXBException;
import net.minidev.json.JSONArray;
import org.jetbrains.annotations.NotNull;
import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource;
@ -323,7 +324,7 @@ public class ReferenceService {
Map<String, String> map = new HashMap<>();
source.getOptions().forEach(option -> {
map.put(option.getCode(), option.getValue());
map.put("label", source.getLabel());
map.put("tag", source.getLabel());
map.put("key", source.getKey());
});
results.add(map);
@ -373,7 +374,7 @@ public class ReferenceService {
.collect(Collectors.toList()));
}
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
for (int i = 2; i <= results.getPagination().get("pages"); i++)
@ -394,7 +395,7 @@ public class ReferenceService {
Results remainingResults = optionalResults.orElseGet(Results::new);
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 {
return new LinkedList<>();
@ -404,17 +405,29 @@ public class ReferenceService {
private String replaceLookupFields(String urlPath, ReferenceDefinitionSearchLookup lookup, String firstPage, List<QueryConfigEntity> queries){
String completedPath = urlPath;
if (urlPath.contains("{like}")){
if (urlPath.contains("openaire") || urlPath.contains("orcid") ){
if (lookup.getLike() != null) {
completedPath = completedPath.replace("{query}", lookup.getLike());
completedPath = completedPath.replace("{like}", lookup.getLike());
} else {
completedPath = completedPath.replace("{query}", "*");
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) {
completedPath = completedPath.replace("{page}", String.valueOf(lookup.getPage().getOffset()));
} else if (firstPage != null) {
completedPath = completedPath.replace("{page}", firstPage);
} else {
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;
}
@ -485,20 +491,76 @@ public class ReferenceService {
private static List<Map<String, String>> parseData (DocumentContext jsonContext, ResultsConfigurationEntity resultsEntity) {
List <Map<String, String>> rawData = jsonContext.read(resultsEntity.getResultsArrayPath());
List<Map<String, String>> parsedData = new ArrayList<>();
rawData.forEach(stringObjectMap -> {
for (Map<String, String> stringObjectMap: rawData){
Map<String, String> map = new HashMap<>();
resultsEntity.getFieldsMapping().forEach(field ->{
for(ResultFieldsMappingConfigurationEntity field: resultsEntity.getFieldsMapping()){
String pathValue = field.getResponsePath();
if (stringObjectMap.containsKey(pathValue)){
map.put(field.getCode(), stringObjectMap.get(pathValue));
if (!pathValue.contains(".")){
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);
});
}
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;
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
import eu.eudat.commons.types.descriptiontemplate.SectionEntity;
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.Section;
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
import java.util.ArrayList;
import java.util.Collections;
@ -21,7 +20,7 @@ public class DatasetProfile {
private Short status;
private Short version;
private String language;
private List<UserInfoListingModel> users;
private List<DmpUser> users;
public String getLabel() {
@ -74,10 +73,10 @@ public class DatasetProfile {
this.language = language;
}
public List<UserInfoListingModel> getUsers() {
public List<DmpUser> getUsers() {
return users;
}
public void setUsers(List<UserInfoListingModel> users) {
public void setUsers(List<DmpUser> users) {
this.users = users;
}

View File

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

View File

@ -1,11 +1,6 @@
package eu.eudat.models.data.dashboard.recent.model;
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> {
private String dmp;

View File

@ -1,14 +1,12 @@
package eu.eudat.models.data.dashboard.recent.model;
import eu.eudat.data.DmpEntity;
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
import eu.eudat.models.data.urls.DatasetUrlListing;
import jakarta.transaction.Transactional;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
public class RecentDmpModel extends RecentActivityModel<DmpEntity, RecentDmpModel> {
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.data.DescriptionEntity;
import eu.eudat.model.DmpUser;
import eu.eudat.models.DataModel;
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
import eu.eudat.models.data.grant.GrantOverviewModel;
import eu.eudat.models.data.listingmodels.DataManagementPlanOverviewModel;
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
import java.time.Instant;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
public class DatasetOverviewModel implements DataModel<DescriptionEntity, DatasetOverviewModel> {
@ -20,7 +18,7 @@ public class DatasetOverviewModel implements DataModel<DescriptionEntity, Datase
private String label;
private DescriptionStatus status;
private DatasetProfileOverviewModel datasetTemplate;
private List<UserInfoListingModel> users;
private List<DmpUser> users;
private DataManagementPlanOverviewModel dmp;
private GrantOverviewModel grant;
private String description;
@ -56,11 +54,11 @@ public class DatasetOverviewModel implements DataModel<DescriptionEntity, Datase
this.datasetTemplate = datasetTemplate;
}
public List<UserInfoListingModel> getUsers() {
public List<DmpUser> getUsers() {
return users;
}
public void setUsers(List<UserInfoListingModel> users) {
public void setUsers(List<DmpUser> users) {
this.users = users;
}

View File

@ -1,26 +1,17 @@
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.old.*;
import eu.eudat.model.DmpUser;
import eu.eudat.model.doi.Doi;
import eu.eudat.models.DataModel;
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
import eu.eudat.models.data.funder.Funder;
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.project.Project;
import eu.eudat.models.data.userinfo.UserListingModel;
import net.minidev.json.JSONObject;
import java.util.*;
import java.util.stream.Collectors;
public class DataManagementPlan implements DataModel<DmpEntity, DataManagementPlan> {
private UUID id;
@ -36,14 +27,12 @@ public class DataManagementPlan implements DataModel<DmpEntity, DataManagementPl
private Grant grant;
private List<Organisation> organisations;
private List<Researcher> researchers;
private List<UserListingModel> associatedUsers;
private List<ExtraFieldModel> extraFields;
private eu.eudat.models.data.userinfo.UserInfo creator;
private Date modified;
private Date created;
private List<DynamicFieldWithValue> dynamicFields;
private Map<String, Object> properties;
private List<UserInfoListingModel> users;
private List<DmpUser> users;
private List<Doi> dois;
private Project project;
private Funder funder;
@ -78,13 +67,6 @@ public class DataManagementPlan implements DataModel<DmpEntity, DataManagementPl
this.groupId = groupId;
}
public List<UserListingModel> getAssociatedUsers() {
return associatedUsers;
}
public void setAssociatedUsers(List<UserListingModel> associatedUsers) {
this.associatedUsers = associatedUsers;
}
public int getVersion() {
return version;
}
@ -120,13 +102,6 @@ public class DataManagementPlan implements DataModel<DmpEntity, DataManagementPl
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() {
return profiles;
}
@ -191,10 +166,10 @@ public class DataManagementPlan implements DataModel<DmpEntity, DataManagementPl
this.datasets = datasets;
}
public List<UserInfoListingModel> getUsers() {
public List<DmpUser> getUsers() {
return users;
}
public void setUsers(List<UserInfoListingModel> users) {
public void setUsers(List<DmpUser> users) {
this.users = users;
}

View File

@ -1,23 +1,19 @@
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.old.*;
import eu.eudat.model.DmpUser;
import eu.eudat.models.DataModel;
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
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.helpermodels.Tuple;
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.stream.Collectors;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class DataManagementPlanEditorModel implements DataModel<DmpEntity, DataManagementPlanEditorModel> {
private UUID id;
@ -33,14 +29,12 @@ public class DataManagementPlanEditorModel implements DataModel<DmpEntity, DataM
private eu.eudat.models.data.grant.GrantDMPEditorModel grant;
private List<Organisation> organisations;
private List<Researcher> researchers;
private List<UserListingModel> associatedUsers;
private List<ExtraFieldModel> extraFields;
private eu.eudat.models.data.userinfo.UserInfo creator;
private Date modified;
private Date created;
private List<DynamicFieldWithValue> dynamicFields;
private Map<String, Object> properties;
private List<UserInfoListingModel> users;
private List<DmpUser> users;
private List<UUID> datasetsToBeFinalized;
private ProjectDMPEditorModel project;
private FunderDMPEditorModel funder;
@ -74,16 +68,6 @@ public class DataManagementPlanEditorModel implements DataModel<DmpEntity, DataM
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) {
this.version = version;
}
@ -116,13 +100,6 @@ public class DataManagementPlanEditorModel implements DataModel<DmpEntity, DataM
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() {
return profiles;
}
@ -187,10 +164,10 @@ public class DataManagementPlanEditorModel implements DataModel<DmpEntity, DataM
this.datasets = datasets;
}
public List<UserInfoListingModel> getUsers() {
public List<DmpUser> getUsers() {
return users;
}
public void setUsers(List<UserInfoListingModel> users) {
public void setUsers(List<DmpUser> 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.grant.GrantDMPEditorModel;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -37,9 +35,6 @@ public class DataManagementPlanNewVersionModel implements DataModel<DmpEntity, D
private eu.eudat.models.data.grant.GrantDMPEditorModel grant;
private List<Organisation> organisations;
private List<Researcher> researchers;
private List<UserListingModel> associatedUsers;
private eu.eudat.models.data.userinfo.UserInfo creator;
private Date created;
private List<Dataset> datasets;
private ProjectDMPEditorModel project;
private FunderDMPEditorModel funder;
@ -115,27 +110,6 @@ public class DataManagementPlanNewVersionModel implements DataModel<DmpEntity, D
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() {
return datasets;
}

View File

@ -1,6 +1,6 @@
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.UUID;
@ -8,7 +8,7 @@ import java.util.UUID;
public class Invitation {
private UUID dataManagementPlan;
private List<UserInfoInvitationModel> users;
private List<User> users;
private Integer role;
public UUID getDataManagementPlan() {
@ -19,11 +19,11 @@ public class Invitation {
this.dataManagementPlan = dataManagementPlan;
}
public List<UserInfoInvitationModel> getUsers() {
public List<User> getUsers() {
return users;
}
public void setUsers(List<UserInfoInvitationModel> users) {
public void setUsers(List<User> 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.old.Grant;
import eu.eudat.model.DmpUser;
import eu.eudat.models.DataModel;
import eu.eudat.models.data.urls.DatasetUrlListing;
@ -22,7 +23,7 @@ public class DataManagementPlanListingModel implements DataModel<DmpEntity, Data
private int status;
private UUID groupId;
private List<DatasetUrlListing> datasets;
private List<UserInfoListingModel> users;
private List<DmpUser> users;
private Date finalizedAt;
private Boolean isPublic;
private Date publishedAt;
@ -91,10 +92,10 @@ public class DataManagementPlanListingModel implements DataModel<DmpEntity, Data
this.status = status;
}
public List<UserInfoListingModel> getUsers() {
public List<DmpUser> getUsers() {
return users;
}
public void setUsers(List<UserInfoListingModel> users) {
public void setUsers(List<DmpUser> 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.IsActive;
import eu.eudat.data.DmpEntity;
import eu.eudat.model.DmpUser;
import eu.eudat.model.doi.Doi;
import eu.eudat.models.DataModel;
import eu.eudat.models.data.dataset.DatasetOverviewModel;
@ -32,7 +33,7 @@ public class DataManagementPlanOverviewModel implements DataModel<DmpEntity, Dat
private List<DatasetOverviewModel> datasets;
private List<AssociatedProfile> associatedProfiles;
private List<Researcher> researchers;
private List<UserInfoListingModel> users;
private List<DmpUser> users;
private String description;
private boolean isPublic;
private Date publishedAt;
@ -130,10 +131,10 @@ public class DataManagementPlanOverviewModel implements DataModel<DmpEntity, Dat
this.associatedProfiles = associatedProfiles;
}
public List<UserInfoListingModel> getUsers() {
public List<DmpUser> getUsers() {
return users;
}
public void setUsers(List<UserInfoListingModel> users) {
public void setUsers(List<DmpUser> 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.data.DescriptionEntity;
import eu.eudat.model.DmpUser;
import eu.eudat.models.DataModel;
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
@ -23,7 +24,7 @@ public class DatasetListingModel implements DataModel<DescriptionEntity, Dataset
private Instant finalizedAt;
private Instant dmpPublishedAt;
private int version;
private List<UserInfoListingModel> users;
private List<DmpUser> users;
private Boolean isPublic;
public String getId() {
@ -118,11 +119,11 @@ public class DatasetListingModel implements DataModel<DescriptionEntity, Dataset
this.version = version;
}
public List<UserInfoListingModel> getUsers() {
public List<DmpUser> getUsers() {
return users;
}
public void setUsers(List<UserInfoListingModel> users) {
public void setUsers(List<DmpUser> 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