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

# Conflicts:
#	dmp-frontend/src/app/ui/description/editor/description-editor.component.ts
#	dmp-frontend/src/app/ui/description/editor/description-editor.model.ts
This commit is contained in:
Sofia Papacharalampous 2024-04-19 18:41:55 +03:00
commit 8ae7f61bf4
208 changed files with 28363 additions and 1044 deletions

1
.gitignore vendored
View File

@ -54,3 +54,4 @@ dmp-backend/web/src/main/resources/certificates/
/storage/
dmp-backend/target/classes/
dmp-backend/core/target/maven-archiver/
dmp-backend/node_modules/.yarn-integrity

View File

@ -51,17 +51,17 @@
<dependency>
<groupId>gr.cite.opendmp</groupId>
<artifactId>repositorydepositbase</artifactId>
<version>2.0.3</version>
<version>2.0.6</version>
</dependency>
<dependency>
<groupId>gr.cite.opendmp</groupId>
<artifactId>common-models</artifactId>
<version>0.0.8</version>
<version>0.0.9</version>
</dependency>
<dependency>
<groupId>gr.cite.opendmp</groupId>
<artifactId>file-transformer-base</artifactId>
<version>0.0.11</version>
<version>0.0.13</version>
</dependency>
<dependency>
<groupId>gr.cite</groupId>

View File

@ -168,6 +168,11 @@ public final class Permission {
public static String DeleteTenant = "DeleteTenant";
public static String AllowNoTenant = "AllowNoTenant";
//TenantConfiguration
public static String BrowseTenantConfiguration = "BrowseTenantConfiguration";
public static String EditTenantConfiguration = "EditTenantConfiguration";
public static String DeleteTenantConfiguration = "DeleteTenantConfiguration";
//TenantUser
public static String BrowseTenantUser = "BrowseTenantUser";
public static String EditTenantUser = "EditTenantUser";

View File

@ -0,0 +1,33 @@
package eu.eudat.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum TenantConfigurationType implements DatabaseEnum<Short> {
DepositPlugins((short) 0),
FileTransformerPlugins((short) 1),
DefaultUserLocale((short) 2),
Logo((short) 3),
CssColors((short) 4);
private final Short value;
TenantConfigurationType(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, TenantConfigurationType> map = EnumUtils.getEnumValueMap(TenantConfigurationType.class);
public static TenantConfigurationType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,77 @@
package eu.eudat.commons.types.deposit;
public class DepositSourceEntity {
private String repositoryId;
private String url;
private String issuerUrl;
private String clientId;
private String clientSecret;
private String scope;
private String pdfTransformerId;
private String rdaTransformerId;
public String getRepositoryId() {
return repositoryId;
}
public void setRepositoryId(String repositoryId) {
this.repositoryId = repositoryId;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getIssuerUrl() {
return issuerUrl;
}
public void setIssuerUrl(String issuerUrl) {
this.issuerUrl = issuerUrl;
}
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public String getClientSecret() {
return clientSecret;
}
public void setClientSecret(String clientSecret) {
this.clientSecret = clientSecret;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
public String getPdfTransformerId() {
return pdfTransformerId;
}
public void setPdfTransformerId(String pdfTransformerId) {
this.pdfTransformerId = pdfTransformerId;
}
public String getRdaTransformerId() {
return rdaTransformerId;
}
public void setRdaTransformerId(String rdaTransformerId) {
this.rdaTransformerId = rdaTransformerId;
}
}

View File

@ -12,6 +12,8 @@ public class ReferenceTypeFieldEntity extends FieldEntity {
@XmlAttribute(name="referenceTypeId")
private UUID referenceTypeId;
@XmlAttribute(name = "multipleSelect")
private Boolean multipleSelect;
public UUID getReferenceTypeId() {
return referenceTypeId;
}
@ -19,4 +21,12 @@ public class ReferenceTypeFieldEntity extends FieldEntity {
public void setReferenceTypeId(UUID referenceTypeId) {
this.referenceTypeId = referenceTypeId;
}
public Boolean getMultipleSelect() {
return multipleSelect;
}
public void setMultipleSelect(Boolean multipleSelect) {
this.multipleSelect = multipleSelect;
}
}

View File

@ -24,6 +24,9 @@ public class ReferenceTypeFieldImportExport {
@XmlAttribute(name = "required")
private boolean required;
@XmlAttribute(name = "multipleSelect")
private Boolean multipleSelect;
public UUID getId() {
return id;
}
@ -80,5 +83,11 @@ public class ReferenceTypeFieldImportExport {
this.required = required;
}
public Boolean getMultipleSelect() {
return multipleSelect;
}
public void setMultipleSelect(Boolean multipleSelect) {
this.multipleSelect = multipleSelect;
}
}

View File

@ -0,0 +1,59 @@
package eu.eudat.commons.types.filetransformer;
public class FileTransformerSourceEntity {
private String url;
private String transformerId;
private String issuerUrl;
private String clientId;
private String clientSecret;
private String scope;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getTransformerId() {
return transformerId;
}
public void setTransformerId(String transformerId) {
this.transformerId = transformerId;
}
public String getIssuerUrl() {
return issuerUrl;
}
public void setIssuerUrl(String issuerUrl) {
this.issuerUrl = issuerUrl;
}
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public String getClientSecret() {
return clientSecret;
}
public void setClientSecret(String clientSecret) {
this.clientSecret = clientSecret;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
}

View File

@ -0,0 +1,40 @@
package eu.eudat.commons.types.tenantconfiguration;
public class CssColorsTenantConfigurationEntity {
private String primaryColor;
private String primaryColor2;
private String primaryColor3;
private String secondaryColor;
public String getPrimaryColor() {
return primaryColor;
}
public void setPrimaryColor(String primaryColor) {
this.primaryColor = primaryColor;
}
public String getPrimaryColor2() {
return primaryColor2;
}
public void setPrimaryColor2(String primaryColor2) {
this.primaryColor2 = primaryColor2;
}
public String getPrimaryColor3() {
return primaryColor3;
}
public void setPrimaryColor3(String primaryColor3) {
this.primaryColor3 = primaryColor3;
}
public String getSecondaryColor() {
return secondaryColor;
}
public void setSecondaryColor(String secondaryColor) {
this.secondaryColor = secondaryColor;
}
}

View File

@ -0,0 +1,32 @@
package eu.eudat.commons.types.tenantconfiguration;
public class DefaultUserLocaleTenantConfigurationEntity {
private String timezone;
private String language;
private String culture;
public String getTimezone() {
return timezone;
}
public void setTimezone(String timezone) {
this.timezone = timezone;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public String getCulture() {
return culture;
}
public void setCulture(String culture) {
this.culture = culture;
}
}

View File

@ -0,0 +1,17 @@
package eu.eudat.commons.types.tenantconfiguration;
import eu.eudat.commons.types.deposit.DepositSourceEntity;
import java.util.List;
public class DepositTenantConfigurationEntity {
private List<DepositSourceEntity> sources;
public List<DepositSourceEntity> getSources() {
return sources;
}
public void setSources(List<DepositSourceEntity> sources) {
this.sources = sources;
}
}

View File

@ -0,0 +1,18 @@
package eu.eudat.commons.types.tenantconfiguration;
import eu.eudat.commons.types.filetransformer.FileTransformerSourceEntity;
import java.util.List;
public class FileTransformerTenantConfigurationEntity {
private List<FileTransformerSourceEntity> sources;
public List<FileTransformerSourceEntity> getSources() {
return sources;
}
public void setSources(List<FileTransformerSourceEntity> sources) {
this.sources = sources;
}
}

View File

@ -0,0 +1,15 @@
package eu.eudat.commons.types.tenantconfiguration;
import java.util.UUID;
public class LogoTenantConfigurationEntity {
private UUID storageFileId;
public UUID getStorageFileId() {
return storageFileId;
}
public void setStorageFileId(UUID storageFileId) {
this.storageFileId = storageFileId;
}
}

View File

@ -0,0 +1,92 @@
package eu.eudat.data;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.enums.TenantConfigurationType;
import eu.eudat.data.converters.enums.IsActiveConverter;
import eu.eudat.data.converters.enums.TenantConfigurationTypeConverter;
import eu.eudat.data.tenant.TenantScopedBaseEntity;
import jakarta.persistence.*;
import java.time.Instant;
import java.util.UUID;
@Entity
@Table(name = "\"TenantConfiguration\"")
public class TenantConfigurationEntity extends TenantScopedBaseEntity {
@Id
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
private UUID id;
public final static String _id = "id";
@Column(name = "value", nullable = false)
private String value;
public final static String _value = "value";
@Column(name = "type", nullable = false)
@Convert(converter = TenantConfigurationTypeConverter.class)
private TenantConfigurationType type;
public final static String _type = "type";
@Column(name = "is_active", nullable = false)
@Convert(converter = IsActiveConverter.class)
private IsActive isActive;
public final static String _isActive = "isActive";
@Column(name = "created_at", nullable = false)
private Instant createdAt;
public final static String _createdAt = "createdAt";
@Column(name = "updated_at", nullable = false)
private Instant updatedAt;
public final static String _updatedAt = "updatedAt";
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public TenantConfigurationType getType() {
return type;
}
public void setType(TenantConfigurationType type) {
this.type = type;
}
public IsActive getIsActive() {
return isActive;
}
public void setIsActive(IsActive isActive) {
this.isActive = isActive;
}
public Instant getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
public Instant getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Instant updatedAt) {
this.updatedAt = updatedAt;
}
}

View File

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

View File

@ -10,7 +10,7 @@ public class Prefilling {
private String label;
public static final String _label = "label";
private Map<String, Object> data;
private Map<String, String> data;
public static final String _data = "data";
private String key;
public static final String _key = "key";
@ -33,11 +33,11 @@ public class Prefilling {
this.label = label;
}
public Map<String, Object> getData() {
public Map<String, String> getData() {
return data;
}
public void setData(Map<String, Object> data) {
public void setData(Map<String, String> data) {
this.data = data;
}

View File

@ -4,6 +4,7 @@ import eu.eudat.commonmodels.models.dmpblueprint.ReferenceTypeFieldModel;
import eu.eudat.commons.types.dmpblueprint.ReferenceTypeFieldEntity;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.builder.commonmodels.ReferenceTypeCommonModelBuilder;
import eu.eudat.model.dmpblueprintdefinition.ReferenceTypeField;
import eu.eudat.query.ReferenceTypeQuery;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
@ -31,6 +32,7 @@ public class ReferenceTypeFieldCommonModelBuilder extends FieldCommonModelBuilde
protected ReferenceTypeFieldModel buildChild(ReferenceTypeFieldEntity data, ReferenceTypeFieldModel model) {
if (data.getReferenceTypeId() != null ) model.setReferenceType(this.builderFactory.builder(ReferenceTypeCommonModelBuilder.class).build(this.queryFactory.query(ReferenceTypeQuery.class).ids(data.getReferenceTypeId()).first())); //TODO: Optimize
model.setMultipleSelect(data.getMultipleSelect());
return model;
}

View File

@ -40,8 +40,9 @@ public class ReferenceFieldBuilder extends FieldBuilder<ReferenceTypeField, Refe
protected ReferenceTypeField buildChild(FieldSet fields, ReferenceTypeFieldEntity data, ReferenceTypeField model) {
FieldSet referenceTypeFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeField._referenceType));
if (data.getReferenceTypeId() != null && !referenceTypeFields.isEmpty() ) model.setReferenceType(this.builderFactory.builder(ReferenceTypeBuilder.class).build(referenceTypeFields, this.queryFactory.query(ReferenceTypeQuery.class).ids(data.getReferenceTypeId()).first())); //TODO: Optimize
if (fields.hasField(this.asIndexer(ReferenceTypeField._multipleSelect))) model.setMultipleSelect(data.getMultipleSelect());
return model;
}
}

View File

@ -0,0 +1,38 @@
package eu.eudat.model.censorship.deposit;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.censorship.BaseCensor;
import gr.cite.commons.web.authz.service.AuthorizationService;
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 DepositSourceCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DepositSourceCensor.class));
protected final AuthorizationService authService;
public DepositSourceCensor(ConventionService conventionService, AuthorizationService authService) {
super(conventionService);
this.authService = authService;
}
public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorize(Permission.BrowseTenantConfiguration);
}
}

View File

@ -0,0 +1,40 @@
package eu.eudat.model.censorship.filetransformer;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.censorship.BaseCensor;
import eu.eudat.model.censorship.deposit.DepositSourceCensor;
import eu.eudat.model.tenantconfiguration.DepositTenantConfiguration;
import gr.cite.commons.web.authz.service.AuthorizationService;
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 FileTransformerSourceCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(FileTransformerSourceCensor.class));
protected final AuthorizationService authService;
public FileTransformerSourceCensor(ConventionService conventionService, AuthorizationService authService) {
super(conventionService);
this.authService = authService;
}
public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorize(Permission.BrowseTenantConfiguration);
}
}

View File

@ -0,0 +1,38 @@
package eu.eudat.model.censorship.tenantconfiguration;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.censorship.BaseCensor;
import gr.cite.commons.web.authz.service.AuthorizationService;
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 CssColorsTenantConfigurationCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(CssColorsTenantConfigurationCensor.class));
protected final AuthorizationService authService;
public CssColorsTenantConfigurationCensor(ConventionService conventionService, AuthorizationService authService) {
super(conventionService);
this.authService = authService;
}
public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorize(Permission.BrowseTenantConfiguration);
}
}

View File

@ -0,0 +1,38 @@
package eu.eudat.model.censorship.tenantconfiguration;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.censorship.BaseCensor;
import gr.cite.commons.web.authz.service.AuthorizationService;
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 DefaultUserLocaleTenantConfigurationCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DefaultUserLocaleTenantConfigurationCensor.class));
protected final AuthorizationService authService;
public DefaultUserLocaleTenantConfigurationCensor(ConventionService conventionService, AuthorizationService authService) {
super(conventionService);
this.authService = authService;
}
public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorize(Permission.BrowseTenantConfiguration);
}
}

View File

@ -0,0 +1,47 @@
package eu.eudat.model.censorship.tenantconfiguration;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.censorship.BaseCensor;
import eu.eudat.model.censorship.deposit.DepositSourceCensor;
import eu.eudat.model.tenantconfiguration.DepositTenantConfiguration;
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 DepositTenantConfigurationCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DepositTenantConfigurationCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public DepositTenantConfigurationCensor(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.authorize(Permission.BrowseTenantConfiguration);
FieldSet sourcesFields = fields.extractPrefixed(this.asIndexerPrefix(DepositTenantConfiguration._sources));
this.censorFactory.censor(DepositSourceCensor.class).censor(sourcesFields, userId);
}
}

View File

@ -0,0 +1,50 @@
package eu.eudat.model.censorship.tenantconfiguration;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.censorship.BaseCensor;
import eu.eudat.model.censorship.deposit.DepositSourceCensor;
import eu.eudat.model.censorship.filetransformer.FileTransformerSourceCensor;
import eu.eudat.model.filetransformer.FileTransformerSource;
import eu.eudat.model.tenantconfiguration.DepositTenantConfiguration;
import eu.eudat.model.tenantconfiguration.FileTransformerTenantConfiguration;
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 FileTransformerTenantConfigurationCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(FileTransformerTenantConfigurationCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public FileTransformerTenantConfigurationCensor(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.authorize(Permission.BrowseTenantConfiguration);
FieldSet sourcesFields = fields.extractPrefixed(this.asIndexerPrefix(FileTransformerTenantConfiguration._sources));
this.censorFactory.censor(FileTransformerSourceCensor.class).censor(sourcesFields, userId);
}
}

View File

@ -0,0 +1,38 @@
package eu.eudat.model.censorship.tenantconfiguration;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.censorship.BaseCensor;
import gr.cite.commons.web.authz.service.AuthorizationService;
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 LogoTenantConfigurationCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(LogoTenantConfigurationCensor.class));
protected final AuthorizationService authService;
public LogoTenantConfigurationCensor(ConventionService conventionService, AuthorizationService authService) {
super(conventionService);
this.authService = authService;
}
public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorize(Permission.BrowseTenantConfiguration);
}
}

View File

@ -0,0 +1,60 @@
package eu.eudat.model.censorship.tenantconfiguration;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.Description;
import eu.eudat.model.censorship.BaseCensor;
import eu.eudat.model.censorship.DescriptionReferenceCensor;
import eu.eudat.model.tenantconfiguration.TenantConfiguration;
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 TenantConfigurationCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TenantConfigurationCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public TenantConfigurationCensor(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.authorize(Permission.BrowseTenantConfiguration);
FieldSet cssColorsFields = fields.extractPrefixed(this.asIndexerPrefix(TenantConfiguration._cssColors));
this.censorFactory.censor(CssColorsTenantConfigurationCensor.class).censor(cssColorsFields, userId);
FieldSet defaultUserLocaleFields = fields.extractPrefixed(this.asIndexerPrefix(TenantConfiguration._defaultUserLocale));
this.censorFactory.censor(DefaultUserLocaleTenantConfigurationCensor.class).censor(defaultUserLocaleFields, userId);
FieldSet depositPluginsFields = fields.extractPrefixed(this.asIndexerPrefix(TenantConfiguration._depositPlugins));
this.censorFactory.censor(DepositTenantConfigurationCensor.class).censor(depositPluginsFields, userId);
FieldSet fileTransformerPluginsFields = fields.extractPrefixed(this.asIndexerPrefix(TenantConfiguration._fileTransformerPlugins));
this.censorFactory.censor(FileTransformerTenantConfigurationCensor.class).censor(fileTransformerPluginsFields, userId);
FieldSet logoFields = fields.extractPrefixed(this.asIndexerPrefix(TenantConfiguration._logo));
this.censorFactory.censor(LogoTenantConfigurationCensor.class).censor(logoFields, userId);
}
}

View File

@ -0,0 +1,85 @@
package eu.eudat.model.deposit;
public class DepositSource {
private String repositoryId;
public static final String _repositoryId = "repositoryId";
private String url;
public static final String _url = "url";
private String issuerUrl;
public static final String _issuerUrl = "issuerUrl";
private String clientId;
public static final String _clientId = "clientId";
private String clientSecret;
public static final String _clientSecret = "clientSecret";
private String scope;
public static final String _scope = "scope";
private String pdfTransformerId;
public static final String _pdfTransformerId = "pdfTransformerId";
private String rdaTransformerId;
public static final String _rdaTransformerId = "rdaTransformerId";
public String getRepositoryId() {
return repositoryId;
}
public void setRepositoryId(String repositoryId) {
this.repositoryId = repositoryId;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getIssuerUrl() {
return issuerUrl;
}
public void setIssuerUrl(String issuerUrl) {
this.issuerUrl = issuerUrl;
}
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public String getClientSecret() {
return clientSecret;
}
public void setClientSecret(String clientSecret) {
this.clientSecret = clientSecret;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
public String getPdfTransformerId() {
return pdfTransformerId;
}
public void setPdfTransformerId(String pdfTransformerId) {
this.pdfTransformerId = pdfTransformerId;
}
public String getRdaTransformerId() {
return rdaTransformerId;
}
public void setRdaTransformerId(String rdaTransformerId) {
this.rdaTransformerId = rdaTransformerId;
}
}

View File

@ -9,6 +9,9 @@ public class ReferenceTypeField extends Field {
public final static String _referenceType = "referenceType";
private ReferenceType referenceType;
public final static String _multipleSelect = "multipleSelect";
private Boolean multipleSelect;
public ReferenceType getReferenceType() {
return referenceType;
}
@ -16,4 +19,12 @@ public class ReferenceTypeField extends Field {
public void setReferenceType(ReferenceType referenceType) {
this.referenceType = referenceType;
}
public Boolean getMultipleSelect() {
return multipleSelect;
}
public void setMultipleSelect(Boolean multipleSelect) {
this.multipleSelect = multipleSelect;
}
}

View File

@ -1,18 +1,24 @@
package eu.eudat.model.file;
import eu.eudat.file.transformer.enums.FileTransformerEntityType;
import eu.eudat.file.transformer.models.misc.FileFormat;
import java.util.List;
public class RepositoryFileFormat {
private String format;
private Boolean hasLogo;
private String icon;
private String repositoryId;
public RepositoryFileFormat(String repositoryId, FileFormat format) {
private List<FileTransformerEntityType> entityTypes;
public RepositoryFileFormat(String repositoryId, FileFormat format, List<FileTransformerEntityType> entityTypes) {
this.repositoryId = repositoryId;
this.format = format.getFormat();
this.hasLogo = format.getHasLogo();
this.icon = format.getIcon();
this.entityTypes = entityTypes;
}
public String getFormat() {
@ -46,4 +52,12 @@ public class RepositoryFileFormat {
public void setRepositoryId(String repositoryId) {
this.repositoryId = repositoryId;
}
public List<FileTransformerEntityType> getEntityTypes() {
return entityTypes;
}
public void setEntityTypes(List<FileTransformerEntityType> entityTypes) {
this.entityTypes = entityTypes;
}
}

View File

@ -0,0 +1,65 @@
package eu.eudat.model.filetransformer;
public class FileTransformerSource {
private String url;
public static final String _url = "url";
private String transformerId;
public static final String _transformerId = "transformerId";
private String issuerUrl;
public static final String _issuerUrl = "issuerUrl";
private String clientId;
public static final String _clientId = "clientId";
private String clientSecret;
public static final String _clientSecret = "clientSecret";
private String scope;
public static final String _scope = "scope";
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getTransformerId() {
return transformerId;
}
public void setTransformerId(String transformerId) {
this.transformerId = transformerId;
}
public String getIssuerUrl() {
return issuerUrl;
}
public void setIssuerUrl(String issuerUrl) {
this.issuerUrl = issuerUrl;
}
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public String getClientSecret() {
return clientSecret;
}
public void setClientSecret(String clientSecret) {
this.clientSecret = clientSecret;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
}

View File

@ -1,6 +1,7 @@
package eu.eudat.model.persist;
import eu.eudat.commons.validation.BaseValidator;
import gr.cite.tools.validation.ValidatorFactory;
import gr.cite.tools.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
@ -16,14 +17,11 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
public class DescriptionProfilingRequest {
public class DescriptionPrefillingRequest {
private Map<String, String> data;
private DescriptionPrefillingRequestData data;
public static final String _data = "data";
private String prefillId;
public static final String _prefillId = "prefillId";
private UUID prefillingSourceId;
public static final String _prefillingSourceId = "prefillingSourceId";
@ -35,22 +33,14 @@ public class DescriptionProfilingRequest {
private BaseFieldSet project;
public static final String _project = "project";
public Map<String, String> getData() {
public DescriptionPrefillingRequestData getData() {
return data;
}
public void setData(Map<String, String> data) {
public void setData(DescriptionPrefillingRequestData data) {
this.data = data;
}
public String getPrefillId() {
return prefillId;
}
public void setPrefillId(String prefillId) {
this.prefillId = prefillId;
}
public UUID getPrefillingSourceId() {
return prefillingSourceId;
}
@ -77,44 +67,46 @@ public class DescriptionProfilingRequest {
@Component(DescriptionProfilingRequestValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class DescriptionProfilingRequestValidator extends BaseValidator<DescriptionProfilingRequest> {
public static class DescriptionProfilingRequestValidator extends BaseValidator<DescriptionPrefillingRequest> {
public static final String ValidatorName = "DescriptionProfilingRequestValidator";
private final MessageSource messageSource;
private final ValidatorFactory validatorFactory;
protected DescriptionProfilingRequestValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
protected DescriptionProfilingRequestValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
super(conventionService, errors);
this.messageSource = messageSource;
this.validatorFactory = validatorFactory;
}
@Override
protected Class<DescriptionProfilingRequest> modelClass() {
return DescriptionProfilingRequest.class;
protected Class<DescriptionPrefillingRequest> modelClass() {
return DescriptionPrefillingRequest.class;
}
@Override
protected List<Specification> specifications(DescriptionProfilingRequest item) {
protected List<Specification> specifications(DescriptionPrefillingRequest item) {
return Arrays.asList(
this.spec()
.must(() -> this.isValidGuid(item.getDescriptionTemplateId()))
.failOn(DescriptionProfilingRequest._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._descriptionTemplateId}, LocaleContextHolder.getLocale())),
.failOn(DescriptionPrefillingRequest._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPrefillingRequest._descriptionTemplateId}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> this.isValidGuid(item.getPrefillingSourceId()))
.failOn(DescriptionProfilingRequest._prefillingSourceId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._prefillingSourceId}, LocaleContextHolder.getLocale())),
.failOn(DescriptionPrefillingRequest._prefillingSourceId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPrefillingRequest._prefillingSourceId}, LocaleContextHolder.getLocale())),
this.refSpec()
.iff(() -> !this.isNull(item.getData()))
.on(DescriptionReferencePersist._reference)
.over(item.getData())
.using(() -> this.validatorFactory.validator(DescriptionPrefillingRequestData.DescriptionPrefillingRequestDataValidator.class)),
this.spec()
.must(() -> !this.isEmpty(item.getPrefillId()))
.failOn(DescriptionProfilingRequest._prefillId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._prefillId}, LocaleContextHolder.getLocale()))
// this.spec()
// .must(() -> item.getData() != null)
// .failOn(DescriptionProfilingWithDataRequest._data).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._data}, LocaleContextHolder.getLocale()))
// this.spec()
// .must(() -> item.getProject() != null)
// .failOn(DescriptionProfilingWithDataRequest._project).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._project}, LocaleContextHolder.getLocale()))
.must(() -> !this.isNull(item.getData()))
.failOn(DescriptionPrefillingRequest._data).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPrefillingRequest._data}, LocaleContextHolder.getLocale()))
);
}
}
}

View File

@ -0,0 +1,71 @@
package eu.eudat.model.persist;
import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import gr.cite.tools.validation.specification.Specification;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class DescriptionPrefillingRequestData {
private HashMap<String, String> data;
public static final String _data = "data";
private String id;
public static final String _id = "id";
public HashMap<String, String> getData() {
return data;
}
public void setData(HashMap<String, String> data) {
this.data = data;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@Component(DescriptionPrefillingRequestDataValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class DescriptionPrefillingRequestDataValidator extends BaseValidator<DescriptionPrefillingRequestData> {
public static final String ValidatorName = "DescriptionPrefillingRequestDataValidator";
private final MessageSource messageSource;
protected DescriptionPrefillingRequestDataValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors);
this.messageSource = messageSource;
}
@Override
protected Class<DescriptionPrefillingRequestData> modelClass() {
return DescriptionPrefillingRequestData.class;
}
@Override
protected List<Specification> specifications(DescriptionPrefillingRequestData item) {
return Arrays.asList(
this.spec()
.must(() -> !this.isEmpty(item.getId()))
.failOn(DescriptionPrefillingRequestData._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPrefillingRequestData._id}, LocaleContextHolder.getLocale()))
);
}
}
}

View File

@ -9,6 +9,7 @@ import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
@ -18,6 +19,11 @@ public class ReferenceTypeFieldPersist extends FieldPersist {
public static final String _referenceTypeId = "referenceTypeId";
private Boolean multipleSelect;
public static final String _multipleSelect = "multipleSelect";
public UUID getReferenceTypeId() {
return referenceTypeId;
}
@ -26,6 +32,14 @@ public class ReferenceTypeFieldPersist extends FieldPersist {
this.referenceTypeId = referenceTypeId;
}
public Boolean getMultipleSelect() {
return multipleSelect;
}
public void setMultipleSelect(Boolean multipleSelect) {
this.multipleSelect = multipleSelect;
}
@Component(ReferenceFieldPersistPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class ReferenceFieldPersistPersistValidator extends BaseFieldPersistValidator<ReferenceTypeFieldPersist> {
@ -44,10 +58,14 @@ public class ReferenceTypeFieldPersist extends FieldPersist {
@Override
protected List<Specification> specifications(ReferenceTypeFieldPersist item) {
List<Specification> specifications = getBaseSpecifications(item);
specifications.add(
specifications.addAll(Arrays.asList(
this.spec()
.must(() -> !this.isNull(item.getReferenceTypeId()))
.failOn(ReferenceTypeFieldPersist._referenceTypeId).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeFieldPersist._referenceTypeId}, LocaleContextHolder.getLocale()))
.failOn(ReferenceTypeFieldPersist._referenceTypeId).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeFieldPersist._referenceTypeId}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getMultipleSelect()))
.failOn(ReferenceTypeFieldPersist._multipleSelect).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeFieldPersist._multipleSelect}, LocaleContextHolder.getLocale())))
);
return specifications;
}

View File

@ -33,6 +33,8 @@ public class DmpBlueprintValuePersist {
public static final String _fieldValue = "fieldValue";
private List<ReferencePersist> references;
public static final String _references = "references";
private ReferencePersist reference;
public static final String _reference = "reference";
public UUID getFieldId() {
return fieldId;
@ -58,6 +60,14 @@ public class DmpBlueprintValuePersist {
this.references = references;
}
public ReferencePersist getReference() {
return reference;
}
public void setReference(ReferencePersist reference) {
this.reference = reference;
}
@Component(DmpBlueprintValuePersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class DmpBlueprintValuePersistValidator extends BaseValidator<DmpBlueprintValuePersist> {
@ -97,16 +107,27 @@ public class DmpBlueprintValuePersist {
.must(() -> !this.isEmpty(item.getFieldValue()))
.failOn(DmpBlueprintValuePersist._fieldValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{fieldEntity.getLabel()}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> fieldEntity.getCategory().equals(DmpBlueprintFieldCategory.ReferenceType) && this.isEmpty(item.getFieldValue()) && required)
.iff(() -> fieldEntity.getCategory().equals(DmpBlueprintFieldCategory.ReferenceType) && this.isEmpty(item.getFieldValue()) && ((ReferenceTypeFieldEntity)fieldEntity).getMultipleSelect() && required)
.must(() -> !this.isListNullOrEmpty(item.getReferences()))
// TODO: Cast Exception
// .failOn(DmpBlueprintValuePersist._references).failWith(messageSource.getMessage("Validation_Required", new Object[]{!this.isEmpty(fieldEntity.getLabel()) ? fieldEntity.getLabel() : this.getReferenceTypeName(fieldEntity)}, LocaleContextHolder.getLocale())),
.failOn(DmpBlueprintValuePersist._references).failWith(messageSource.getMessage("Validation_Required", new Object[]{!this.isEmpty(fieldEntity.getLabel()) ? fieldEntity.getLabel() : DmpBlueprintValuePersist._references}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> fieldEntity.getCategory().equals(DmpBlueprintFieldCategory.ReferenceType) && this.isEmpty(item.getFieldValue()) && !((ReferenceTypeFieldEntity)fieldEntity).getMultipleSelect() && required)
.must(() -> !this.isNull(item.getReference()))
// TODO: Cast Exception
// .failOn(DmpBlueprintValuePersist._references).failWith(messageSource.getMessage("Validation_Required", new Object[]{!this.isEmpty(fieldEntity.getLabel()) ? fieldEntity.getLabel() : this.getReferenceTypeName(fieldEntity)}, LocaleContextHolder.getLocale())),
.failOn(DmpBlueprintValuePersist._reference).failWith(messageSource.getMessage("Validation_Required", new Object[]{!this.isEmpty(fieldEntity.getLabel()) ? fieldEntity.getLabel() : DmpBlueprintValuePersist._reference}, LocaleContextHolder.getLocale())),
this.navSpec()
.iff(() -> !this.isListNullOrEmpty(item.getReferences()))
.on(DmpBlueprintValuePersist._references)
.over(item.getReferences())
.using((itm) -> this.validatorFactory.validator(ReferencePersist.ReferenceWithoutTypePersistValidator.class))
.using((itm) -> this.validatorFactory.validator(ReferencePersist.ReferenceWithoutTypePersistValidator.class)),
this.refSpec()
.iff(() -> !this.isNull(item.getReference()))
.on(DmpBlueprintValuePersist._reference)
.over(item.getReferences())
.using(() -> this.validatorFactory.validator(ReferencePersist.ReferenceWithoutTypePersistValidator.class))
);
}

View File

@ -0,0 +1,44 @@
package eu.eudat.model.tenantconfiguration;
public class CssColorsTenantConfiguration {
private String primaryColor;
public static final String _primaryColor = "primaryColor";
private String primaryColor2;
public static final String _primaryColor2 = "primaryColor2";
private String primaryColor3;
public static final String _primaryColor3 = "primaryColor3";
private String secondaryColor;
public static final String _secondaryColor = "secondaryColor";
public String getPrimaryColor() {
return primaryColor;
}
public void setPrimaryColor(String primaryColor) {
this.primaryColor = primaryColor;
}
public String getPrimaryColor2() {
return primaryColor2;
}
public void setPrimaryColor2(String primaryColor2) {
this.primaryColor2 = primaryColor2;
}
public String getPrimaryColor3() {
return primaryColor3;
}
public void setPrimaryColor3(String primaryColor3) {
this.primaryColor3 = primaryColor3;
}
public String getSecondaryColor() {
return secondaryColor;
}
public void setSecondaryColor(String secondaryColor) {
this.secondaryColor = secondaryColor;
}
}

View File

@ -0,0 +1,35 @@
package eu.eudat.model.tenantconfiguration;
public class DefaultUserLocaleTenantConfiguration {
private String timezone;
public static final String _timezone = "timezone";
private String language;
public static final String _language = "language";
private String culture;
public static final String _culture = "culture";
public String getTimezone() {
return timezone;
}
public void setTimezone(String timezone) {
this.timezone = timezone;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public String getCulture() {
return culture;
}
public void setCulture(String culture) {
this.culture = culture;
}
}

View File

@ -0,0 +1,18 @@
package eu.eudat.model.tenantconfiguration;
import eu.eudat.commons.types.deposit.DepositSourceEntity;
import java.util.List;
public class DepositTenantConfiguration {
private List<DepositSourceEntity> sources;
public static final String _sources = "sources";
public List<DepositSourceEntity> getSources() {
return sources;
}
public void setSources(List<DepositSourceEntity> sources) {
this.sources = sources;
}
}

View File

@ -0,0 +1,19 @@
package eu.eudat.model.tenantconfiguration;
import eu.eudat.commons.types.filetransformer.FileTransformerSourceEntity;
import java.util.List;
public class FileTransformerTenantConfiguration {
private List<FileTransformerSourceEntity> sources;
public static final String _sources = "sources";
public List<FileTransformerSourceEntity> getSources() {
return sources;
}
public void setSources(List<FileTransformerSourceEntity> sources) {
this.sources = sources;
}
}

View File

@ -0,0 +1,16 @@
package eu.eudat.model.tenantconfiguration;
import java.util.UUID;
public class LogoTenantConfiguration {
private UUID storageFileId;
public static final String _storageFileId = "storageFileId";
public UUID getStorageFileId() {
return storageFileId;
}
public void setStorageFileId(UUID storageFileId) {
this.storageFileId = storageFileId;
}
}

View File

@ -0,0 +1,129 @@
package eu.eudat.model.tenantconfiguration;
import eu.eudat.commons.enums.IsActive;
import java.time.Instant;
import java.util.UUID;
public class TenantConfiguration {
private UUID id;
public static final String _id = "id";
private Instant createdAt;
public static final String _createdAt = "createdAt";
private CssColorsTenantConfiguration cssColors;
public static final String _cssColors = "cssColors";
private DefaultUserLocaleTenantConfiguration defaultUserLocale;
public static final String _defaultUserLocale = "defaultUserLocale";
private DepositTenantConfiguration depositPlugins;
public static final String _depositPlugins = "depositPlugins";
private FileTransformerTenantConfiguration fileTransformerPlugins;
public static final String _fileTransformerPlugins = "fileTransformerPlugins";
private LogoTenantConfiguration logo;
public static final String _logo = "logo";
private Instant updatedAt;
public static final String _updatedAt = "updatedAt";
private IsActive isActive;
public static final String _isActive = "isActive";
private String hash;
public static final String _hash = "hash";
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public Instant getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
public CssColorsTenantConfiguration getCssColors() {
return cssColors;
}
public void setCssColors(CssColorsTenantConfiguration cssColors) {
this.cssColors = cssColors;
}
public DefaultUserLocaleTenantConfiguration getDefaultUserLocale() {
return defaultUserLocale;
}
public void setDefaultUserLocale(DefaultUserLocaleTenantConfiguration defaultUserLocale) {
this.defaultUserLocale = defaultUserLocale;
}
public DepositTenantConfiguration getDepositPlugins() {
return depositPlugins;
}
public void setDepositPlugins(DepositTenantConfiguration depositPlugins) {
this.depositPlugins = depositPlugins;
}
public FileTransformerTenantConfiguration getFileTransformerPlugins() {
return fileTransformerPlugins;
}
public void setFileTransformerPlugins(FileTransformerTenantConfiguration fileTransformerPlugins) {
this.fileTransformerPlugins = fileTransformerPlugins;
}
public LogoTenantConfiguration getLogo() {
return logo;
}
public void setLogo(LogoTenantConfiguration logo) {
this.logo = logo;
}
public Instant getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Instant updatedAt) {
this.updatedAt = updatedAt;
}
public IsActive getIsActive() {
return isActive;
}
public void setIsActive(IsActive isActive) {
this.isActive = isActive;
}
public String getHash() {
return hash;
}
public void setHash(String hash) {
this.hash = hash;
}
}

View File

@ -4,6 +4,7 @@ import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.data.DmpDescriptionTemplateEntity;
import eu.eudat.data.DmpEntity;
import eu.eudat.model.DmpDescriptionTemplate;
@ -41,6 +42,8 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
private Instant after;
private DescriptionTemplateQuery descriptionTemplateQuery;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
public DmpDescriptionTemplateQuery ids(UUID value) {
@ -138,6 +141,11 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
return this;
}
public DmpDescriptionTemplateQuery descriptionTemplateSubQuery(DescriptionTemplateQuery value) {
this.descriptionTemplateQuery = value;
return this;
}
public DmpDescriptionTemplateQuery authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
@ -229,9 +237,13 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
predicates.add(inClause);
}
if (this.after != null) {
Predicate afterClause = queryContext.CriteriaBuilder.greaterThanOrEqualTo(queryContext.Root.get(DmpEntity._createdAt), this.after);
Predicate afterClause = queryContext.CriteriaBuilder.greaterThanOrEqualTo(queryContext.Root.get(DmpDescriptionTemplateEntity._createdAt), this.after);
predicates.add(afterClause);
}
if (this.descriptionTemplateQuery != null) {
QueryContext<DescriptionTemplateEntity, UUID> subQuery = this.applySubQuery(this.descriptionTemplateQuery, queryContext, UUID.class, descriptionTemplateEntityRoot -> descriptionTemplateEntityRoot.get(DescriptionTemplateEntity._groupId));
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpDescriptionTemplateEntity._descriptionTemplateGroupId)).value(subQuery.Query));
}
if (!predicates.isEmpty()) {
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);

View File

@ -1,96 +1,20 @@
package eu.eudat.service.deposit;
import eu.eudat.commons.types.deposit.DepositSourceEntity;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.bind.ConstructorBinding;
import java.util.List;
@ConfigurationProperties(prefix = "deposit")
public class DepositProperties {
private List<DepositSource> sources;
private List<DepositSourceEntity> sources;
public List<DepositSource> getSources() {
public List<DepositSourceEntity> getSources() {
return sources;
}
public void setSources(List<DepositSource> sources) {
public void setSources(List<DepositSourceEntity> sources) {
this.sources = sources;
}
public static class DepositSource {
private String repositoryId;
private String url;
private String issuerUrl;
private String clientId;
private String clientSecret;
private String scope;
private String pdfTransformerId;
private String rdaTransformerId;
public String getRepositoryId() {
return repositoryId;
}
public void setRepositoryId(String repositoryId) {
this.repositoryId = repositoryId;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getIssuerUrl() {
return issuerUrl;
}
public void setIssuerUrl(String issuerUrl) {
this.issuerUrl = issuerUrl;
}
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public String getClientSecret() {
return clientSecret;
}
public void setClientSecret(String clientSecret) {
this.clientSecret = clientSecret;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
public String getPdfTransformerId() {
return pdfTransformerId;
}
public void setPdfTransformerId(String pdfTransformerId) {
this.pdfTransformerId = pdfTransformerId;
}
public String getRdaTransformerId() {
return rdaTransformerId;
}
public void setRdaTransformerId(String rdaTransformerId) {
this.rdaTransformerId = rdaTransformerId;
}
}
}

View File

@ -11,6 +11,7 @@ import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.enums.StorageType;
import eu.eudat.commons.notification.NotificationProperties;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.commons.types.deposit.DepositSourceEntity;
import eu.eudat.commons.types.notification.*;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.DmpEntity;
@ -36,7 +37,7 @@ import eu.eudat.query.UserQuery;
import eu.eudat.service.entitydoi.EntityDoiService;
import eu.eudat.service.storage.StorageFileProperties;
import eu.eudat.service.storage.StorageFileService;
import eu.eudat.service.transformer.FileTransformerService;
import eu.eudat.service.filetransformer.FileTransformerService;
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeCacheService;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeFilterFunction;
@ -121,7 +122,7 @@ public class DepositServiceImpl implements DepositService {
if (this.clients.containsKey(repositoryId)) return this.clients.get(repositoryId);
//GK: It's register time
DepositProperties.DepositSource source = depositProperties.getSources().stream().filter(depositSource -> depositSource.getRepositoryId().equals(repositoryId)).findFirst().orElse(null);
DepositSourceEntity source = depositProperties.getSources().stream().filter(depositSource -> depositSource.getRepositoryId().equals(repositoryId)).findFirst().orElse(null);
if (source != null) {
String host = URI.create(source.getUrl()).getHost();
TokenExchangeModel tokenExchangeModel = new TokenExchangeModel("deposit:" + source.getRepositoryId(), source.getIssuerUrl(), source.getClientId(), source.getClientSecret(), source.getScope());
@ -141,7 +142,7 @@ public class DepositServiceImpl implements DepositService {
List<eu.eudat.model.deposit.DepositConfiguration> configurations = new ArrayList<>();
for (DepositProperties.DepositSource depositSource : depositProperties.getSources()) {
for (DepositSourceEntity depositSource : depositProperties.getSources()) {
DepositConfigurationCacheService.DepositConfigurationCacheValue cacheValue = this.depositConfigurationCacheService.lookup(this.depositConfigurationCacheService.buildKey(depositSource.getRepositoryId()));
if (cacheValue == null){
DepositClient depositClient = getDepositClient(depositSource.getRepositoryId());
@ -171,8 +172,8 @@ public class DepositServiceImpl implements DepositService {
//GK: Forth make the required files to be uploaded with the deposit
//TODO: Properly create required files
DepositProperties.DepositSource source = depositProperties.getSources().stream().filter(depositSource -> depositSource.getRepositoryId().equals(dmpDepositModel.getRepositoryId())).findFirst().orElse(null);
if (source == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDepositModel.getRepositoryId(), DepositProperties.DepositSource.class.getSimpleName()}, LocaleContextHolder.getLocale()));
DepositSourceEntity source = depositProperties.getSources().stream().filter(depositSource -> depositSource.getRepositoryId().equals(dmpDepositModel.getRepositoryId())).findFirst().orElse(null);
if (source == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDepositModel.getRepositoryId(), DepositSourceEntity.class.getSimpleName()}, LocaleContextHolder.getLocale()));
eu.eudat.model.file.FileEnvelope pdfFile = this.fileTransformerService.exportDmp(dmpEntity.getId(), source.getPdfTransformerId(),"pdf");
eu.eudat.model.file.FileEnvelope rda = this.fileTransformerService.exportDmp(dmpEntity.getId(), source.getRdaTransformerId(),"json");
@ -211,7 +212,7 @@ public class DepositServiceImpl implements DepositService {
}
private void sendNotification(DmpEntity dmpEntity) throws InvalidApplicationException {
List<DmpUserEntity> dmpUsers = this.queryFactory.query(DmpUserQuery.class).ids(dmpEntity.getId()).isActives(IsActive.Active).collect();
List<DmpUserEntity> dmpUsers = this.queryFactory.query(DmpUserQuery.class).dmpIds(dmpEntity.getId()).isActives(IsActive.Active).collect();
if (this.conventionService.isListNullOrEmpty(dmpUsers)){
throw new MyNotFoundException("Dmp does not have Users");
}

View File

@ -7,7 +7,6 @@ import eu.eudat.authorization.authorizationcontentresolver.AuthorizationContentR
import eu.eudat.commons.JsonHandlingService;
import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.enums.*;
import eu.eudat.commons.enums.notification.NotificationContactType;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.commons.types.description.*;
@ -41,7 +40,7 @@ import eu.eudat.query.*;
import eu.eudat.service.elastic.ElasticService;
import eu.eudat.service.storage.StorageFileProperties;
import eu.eudat.service.storage.StorageFileService;
import eu.eudat.service.transformer.FileTransformerService;
import eu.eudat.service.filetransformer.FileTransformerService;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.deleter.DeleterFactory;
@ -611,7 +610,7 @@ public class DescriptionServiceImpl implements DescriptionService {
Map<String, List<UUID>> fieldToReferenceMap = new HashMap<>();
List<DescriptionReferenceEntity> descriptionReferences = this.queryFactory.query(DescriptionReferenceQuery.class).descriptionIds(descriptionId).collect();
List<DescriptionReferenceEntity> descriptionReferences = this.queryFactory.query(DescriptionReferenceQuery.class).isActive(IsActive.Active).descriptionIds(descriptionId).collect();
Map<UUID, List<DescriptionReferenceEntity>> descriptionReferenceEntityByReferenceId = new HashMap<>();
for (DescriptionReferenceEntity descriptionReferenceEntity : descriptionReferences){
List<DescriptionReferenceEntity> descriptionReferenceEntities = descriptionReferenceEntityByReferenceId.getOrDefault(descriptionReferenceEntity.getReferenceId(), null);

View File

@ -48,7 +48,7 @@ import eu.eudat.query.*;
import eu.eudat.service.actionconfirmation.ActionConfirmationService;
import eu.eudat.service.description.DescriptionService;
import eu.eudat.service.elastic.ElasticService;
import eu.eudat.service.transformer.FileTransformerService;
import eu.eudat.service.filetransformer.FileTransformerService;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.deleter.DeleterFactory;
@ -750,6 +750,10 @@ public class DmpServiceImpl implements DmpService {
List<DmpReferencePersist> dmpReferencePersists = new ArrayList<>();
if (persist.getDmpBlueprintValues() != null && !persist.getDmpBlueprintValues().isEmpty()){
for (DmpBlueprintValuePersist fieldValuePersist: persist.getDmpBlueprintValues().values()) {
if (fieldValuePersist.getReference() != null) {
if (fieldValuePersist.getReferences() == null) fieldValuePersist.setReferences(new ArrayList<>());
fieldValuePersist.getReferences().add(fieldValuePersist.getReference());
}
if (this.conventionService.isNullOrEmpty(fieldValuePersist.getFieldValue()) && !this.conventionService.isListNullOrEmpty( fieldValuePersist.getReferences())) {
for (ReferencePersist referencePersist : fieldValuePersist.getReferences()) {
DmpReferencePersist dmpReferencePersist = new DmpReferencePersist();
@ -767,7 +771,7 @@ public class DmpServiceImpl implements DmpService {
private void patchAndSaveReferences(List<DmpReferencePersist> models, UUID dmpId, eu.eudat.commons.types.dmpblueprint.DefinitionEntity blueprintDefinition) throws InvalidApplicationException {
if (models == null) models = new ArrayList<>();
List<DmpReferenceEntity> dmpReferences = this.queryFactory.query(DmpReferenceQuery.class).dmpIds(dmpId).collect();
List<DmpReferenceEntity> dmpReferences = this.queryFactory.query(DmpReferenceQuery.class).dmpIds(dmpId).isActives(IsActive.Active).collect();
Map<UUID, List<DmpReferenceEntity>> dmpReferenceEntityByReferenceId = new HashMap<>();
for (DmpReferenceEntity dmpReferenceEntity : dmpReferences){
List<DmpReferenceEntity> dmpReferenceEntities = dmpReferenceEntityByReferenceId.getOrDefault(dmpReferenceEntity.getReferenceId(), null);
@ -1070,7 +1074,7 @@ public class DmpServiceImpl implements DmpService {
if (!this.conventionService.isListNullOrEmpty(sectionEntity.getFields())){
for (eu.eudat.commons.types.dmpblueprint.FieldEntity fieldEntity: sectionEntity.getFields()) {
if (!this.conventionService.isListNullOrEmpty(dmpReferenceEntities)) {
if (!this.conventionService.isListNullOrEmpty(dmpReferenceEntities) && fieldEntity.getCategory().equals(DmpBlueprintFieldCategory.ReferenceType)) {
List<ReferencePersist> referencePersists = new ArrayList<>();
for (DmpReferenceEntity dmpReferenceEntity : dmpReferenceEntities) {
DmpReferenceData referenceData = this.jsonHandlingService.fromJsonSafe(DmpReferenceData.class, dmpReferenceEntity.getData());
@ -1078,21 +1082,21 @@ public class DmpServiceImpl implements DmpService {
ReferenceEntity reference = referencesFromAllFields.stream().filter(x -> x.getId().equals(dmpReferenceEntity.getReferenceId())).collect(Collectors.toList()).getFirst();
if (referenceData.getBlueprintFieldId().equals(fieldEntity.getId()) && reference != null) {
referencePersists.add(this.buildReferencePersist(reference));
// found reference
dmpBlueprintValues.put(fieldEntity.getId(), this.buildDmpBlueprintValuePersist(fieldEntity.getId(), null, referencePersists));
}
// put references
dmpBlueprintValues.put(fieldEntity.getId(), this.buildDmpBlueprintValuePersist(fieldEntity.getId(), null, referencePersists, ((ReferenceTypeFieldEntity)fieldEntity).getMultipleSelect()));
}
} else if (!this.conventionService.isListNullOrEmpty(data.getDmpBlueprintValues())) {
for (DmpBlueprintValueEntity value : data.getDmpBlueprintValues()) {
if (value.getFieldId().equals(fieldEntity.getId())) {
// found value
dmpBlueprintValues.put(fieldEntity.getId(), this.buildDmpBlueprintValuePersist(fieldEntity.getId(), value.getValue(), null));
dmpBlueprintValues.put(fieldEntity.getId(), this.buildDmpBlueprintValuePersist(fieldEntity.getId(), value.getValue(), null, null));
} else {
dmpBlueprintValues.put(fieldEntity.getId(), this.buildDmpBlueprintValuePersist(fieldEntity.getId(), null, null));
dmpBlueprintValues.put(fieldEntity.getId(), this.buildDmpBlueprintValuePersist(fieldEntity.getId(), null, null, null));
}
}
} else {
dmpBlueprintValues.put(fieldEntity.getId(), this.buildDmpBlueprintValuePersist(fieldEntity.getId(), null, null));
dmpBlueprintValues.put(fieldEntity.getId(), this.buildDmpBlueprintValuePersist(fieldEntity.getId(), null, null, null));
}
}
@ -1153,13 +1157,15 @@ public class DmpServiceImpl implements DmpService {
return persist;
}
private @NotNull DmpBlueprintValuePersist buildDmpBlueprintValuePersist(UUID fieldId, String fieldValue, List<ReferencePersist> referencePersists){
private @NotNull DmpBlueprintValuePersist buildDmpBlueprintValuePersist(UUID fieldId, String fieldValue, List<ReferencePersist> referencePersists, Boolean multipleSelect){
DmpBlueprintValuePersist persist = new DmpBlueprintValuePersist();
persist.setFieldId(fieldId);
if (!this.conventionService.isListNullOrEmpty(referencePersists)){
if (!this.conventionService.isListNullOrEmpty(referencePersists) && multipleSelect){
persist.setReferences(referencePersists);
}else if (!this.conventionService.isListNullOrEmpty(referencePersists)){
persist.setReference(referencePersists.getFirst());
}else if (fieldValue != null){
persist.setFieldValue(fieldValue);
}

View File

@ -265,6 +265,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
case ReferenceType -> {
ReferenceTypeFieldEntity dataTyped = new ReferenceTypeFieldEntity();
dataTyped.setReferenceTypeId(((ReferenceTypeFieldPersist) persist).getReferenceTypeId());
dataTyped.setMultipleSelect(((ReferenceTypeFieldPersist) persist).getMultipleSelect());
data = dataTyped;
}
default -> throw new InternalError("unknown type: " + persist.getCategory());
@ -540,6 +541,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
xml.setDescription(entity.getDescription());
xml.setOrdinal(entity.getOrdinal());
xml.setRequired(entity.isRequired());
xml.setMultipleSelect(entity.getMultipleSelect());
return xml;
}
@ -670,6 +672,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
persist.setDescription(importXml.getDescription());
persist.setOrdinal(importXml.getOrdinal());
persist.setRequired(importXml.isRequired());
persist.setMultipleSelect(importXml.getMultipleSelect());
return persist;
}

View File

@ -1,4 +1,4 @@
package eu.eudat.service.transformer;
package eu.eudat.service.filetransformer;
import gr.cite.tools.cache.CacheOptions;
import org.springframework.boot.context.properties.ConfigurationProperties;

View File

@ -1,4 +1,4 @@
package eu.eudat.service.transformer;
package eu.eudat.service.filetransformer;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;

View File

@ -1,4 +1,4 @@
package eu.eudat.service.transformer;
package eu.eudat.service.filetransformer;
import eu.eudat.model.file.TransformerCacheModel;

View File

@ -0,0 +1,20 @@
package eu.eudat.service.filetransformer;
import eu.eudat.commons.types.filetransformer.FileTransformerSourceEntity;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.List;
@ConfigurationProperties(prefix = "file-transformer")
public class FileTransformerProperties {
private List<FileTransformerSourceEntity> sources;
public List<FileTransformerSourceEntity> getSources() {
return sources;
}
public void setSources(List<FileTransformerSourceEntity> sources) {
this.sources = sources;
}
}

View File

@ -1,4 +1,4 @@
package eu.eudat.service.transformer;
package eu.eudat.service.filetransformer;
import eu.eudat.commonmodels.models.FileEnvelopeModel;
import eu.eudat.commonmodels.models.description.DescriptionModel;

View File

@ -1,6 +1,5 @@
package eu.eudat.service.transformer;
package eu.eudat.service.filetransformer;
import eu.eudat.file.transformer.models.misc.FileFormat;
import eu.eudat.model.file.RepositoryFileFormat;
import java.util.List;

View File

@ -1,4 +1,4 @@
package eu.eudat.service.transformer;
package eu.eudat.service.filetransformer;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission;
@ -6,6 +6,7 @@ import eu.eudat.commonmodels.models.FileEnvelopeModel;
import eu.eudat.commonmodels.models.description.DescriptionModel;
import eu.eudat.commonmodels.models.dmp.DmpModel;
import eu.eudat.commons.enums.StorageType;
import eu.eudat.commons.types.filetransformer.FileTransformerSourceEntity;
import eu.eudat.file.transformer.interfaces.FileTransformerConfiguration;
import eu.eudat.model.Description;
import eu.eudat.model.Dmp;
@ -68,7 +69,7 @@ public class FileTransformerServiceImpl implements FileTransformerService {
if (this.clients.containsKey(repoId)) return this.clients.get(repoId);
//GK: It's register time
FileTransformerProperties.TransformerSource source = fileTransformerProperties.getSources().stream().filter(depositSource -> depositSource.getTransformerId().equals(repoId)).findFirst().orElse(null);
FileTransformerSourceEntity source = fileTransformerProperties.getSources().stream().filter(depositSource -> depositSource.getTransformerId().equals(repoId)).findFirst().orElse(null);
if (source != null) {
String host = URI.create(source.getUrl()).getHost();
TokenExchangeModel tokenExchangeModel = new TokenExchangeModel(host + "_" + source.getClientId(), source.getIssuerUrl(), source.getClientId(), source.getClientSecret(), source.getScope());
@ -91,7 +92,7 @@ public class FileTransformerServiceImpl implements FileTransformerService {
List<FileTransformerConfiguration> configurations = this.getAvailableConfigurations();
if(configurations != null){
for (FileTransformerConfiguration configuration : configurations){
if (configuration != null && configuration.getExportVariants() != null) formats.addAll(configuration.getExportVariants().stream().map(x-> new RepositoryFileFormat(configuration.getFileTransformerId(), x)).toList());
if (configuration != null && configuration.getExportVariants() != null) formats.addAll(configuration.getExportVariants().stream().map(x-> new RepositoryFileFormat(configuration.getFileTransformerId(), x, configuration.getExportEntityTypes())).toList());
}
}
return formats;

View File

@ -1,24 +1,6 @@
package eu.eudat.service.maintenance;
import eu.eudat.model.Description;
import eu.eudat.model.Prefilling;
import eu.eudat.model.PrefillingSource;
import eu.eudat.model.persist.DescriptionProfilingRequest;
import eu.eudat.model.persist.PrefillingSearchRequest;
import eu.eudat.model.persist.PrefillingSourcePersist;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.exception.MyForbiddenException;
import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.exception.MyValidationException;
import gr.cite.tools.fieldset.FieldSet;
import jakarta.xml.bind.JAXBException;
import org.xml.sax.SAXException;
import javax.management.InvalidApplicationException;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
public interface MaintenanceService {

View File

@ -3,11 +3,13 @@ package eu.eudat.service.metrics;
import eu.eudat.commons.enums.*;
import eu.eudat.commons.metrics.MetricLabels;
import eu.eudat.commons.metrics.MetricNames;
import eu.eudat.data.DmpDescriptionTemplateEntity;
import eu.eudat.data.TenantEntityManager;
import eu.eudat.query.*;
import eu.eudat.service.keycloak.MyKeycloakAdminRestApi;
import gr.cite.commons.web.keycloak.api.configuration.KeycloakClientProperties;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.logging.LoggerService;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import io.prometheus.client.Gauge;
@ -298,20 +300,20 @@ public class MetricsServiceImpl implements MetricsService {
}
private double calculateFinalizedTemplates(boolean forNexus) {
DescriptionTemplateQuery descriptionTemplateQuery = this.queryFactory.query(DescriptionTemplateQuery.class).statuses(DescriptionTemplateStatus.Finalized).isActive(IsActive.Active);
DescriptionTemplateQuery descriptionTemplateQuery = this.queryFactory.query(DescriptionTemplateQuery.class).statuses(DescriptionTemplateStatus.Finalized).versionStatuses(DescriptionTemplateVersionStatus.Current).isActive(IsActive.Active);
if (forNexus)
descriptionTemplateQuery.after(_config.getNexusDate());
return descriptionTemplateQuery.count();
}
private double calculateUsedTemplates(boolean forNexus) {
DescriptionTemplateQuery descriptionTemplateQuery = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active);
descriptionTemplateQuery.setDistinct(true);
if (forNexus)
descriptionTemplateQuery.after(_config.getNexusDate());
DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery = this.queryFactory.query(DmpDescriptionTemplateQuery.class);
descriptionTemplateQuery.dmpDescriptionTemplateSubQuery(dmpDescriptionTemplateQuery);
return descriptionTemplateQuery.count();
DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery = this.queryFactory.query(DmpDescriptionTemplateQuery.class).isActive(IsActive.Active);
dmpDescriptionTemplateQuery.setDistinct(true);
if (forNexus) {
DescriptionTemplateQuery descriptionTemplateQuery = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).after(_config.getNexusDate());
dmpDescriptionTemplateQuery.descriptionTemplateSubQuery(descriptionTemplateQuery);
}
return dmpDescriptionTemplateQuery.collectAs(new BaseFieldSet().ensure(DmpDescriptionTemplateEntity._descriptionTemplateGroupId)).size();
}
private double calculateActiveUsers() {

View File

@ -4,7 +4,7 @@ import eu.eudat.model.Description;
import eu.eudat.model.Prefilling;
import eu.eudat.model.PrefillingSource;
import eu.eudat.model.persist.PrefillingSearchRequest;
import eu.eudat.model.persist.DescriptionProfilingRequest;
import eu.eudat.model.persist.DescriptionPrefillingRequest;
import eu.eudat.model.persist.PrefillingSourcePersist;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.exception.MyForbiddenException;
@ -28,6 +28,6 @@ public interface PrefillingSourceService {
List<Prefilling> searchPrefillings(PrefillingSearchRequest model);
Description getPrefilledDescription(DescriptionProfilingRequest model, FieldSet fields) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException;
Description getPrefilledDescription(DescriptionPrefillingRequest model, FieldSet fields) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException;
}

View File

@ -24,8 +24,9 @@ import eu.eudat.model.builder.DescriptionTemplateBuilder;
import eu.eudat.model.builder.PrefillingSourceBuilder;
import eu.eudat.model.deleter.PrefillingSourceDeleter;
import eu.eudat.model.descriptionproperties.*;
import eu.eudat.model.descriptionreference.DescriptionReferenceData;
import eu.eudat.model.persist.PrefillingSearchRequest;
import eu.eudat.model.persist.DescriptionProfilingRequest;
import eu.eudat.model.persist.DescriptionPrefillingRequest;
import eu.eudat.model.persist.PrefillingSourcePersist;
import eu.eudat.model.persist.externalfetcher.*;
import eu.eudat.model.persist.prefillingsourcedefinition.PrefillingSourceDefinitionFieldPersist;
@ -330,6 +331,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
prefilling.setLabel(result.getOrDefault(Prefilling._label, null));
prefilling.setKey(result.getOrDefault(Prefilling._key, null));
prefilling.setTag(result.getOrDefault(Prefilling._tag, null));
if (prefillingSourceDefinition.getGetConfiguration() == null) prefilling.setData(result);
prefillings.add(prefilling);
}
@ -339,7 +341,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
return prefillings;
}
public Description getPrefilledDescription(DescriptionProfilingRequest model, FieldSet fieldSet) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
public Description getPrefilledDescription(DescriptionPrefillingRequest model, FieldSet fieldSet) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
PrefillingSourceEntity prefillingSourceEntity = this.queryFactory.query(PrefillingSourceQuery.class).ids(model.getPrefillingSourceId()).first();
if (prefillingSourceEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale()));
@ -347,12 +349,16 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
PrefillingSourceDefinitionEntity prefillingSourceDefinition = this.xmlHandlingService.fromXmlSafe(PrefillingSourceDefinitionEntity.class, prefillingSourceEntity.getDefinition());
if (prefillingSourceDefinition == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSourceDefinition.class.getSimpleName()}, LocaleContextHolder.getLocale()));
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria();
externalReferenceCriteria.setLike(model.getPrefillId());
ExternalDataResult externalData = this.externalFetcherService.getExternalData(Stream.of(prefillingSourceDefinition.getGetConfiguration()).collect(Collectors.toList()), externalReferenceCriteria, null);
if (externalData == null || this.conventionService.isListNullOrEmpty(externalData.getResults())) {
return null;
Map<String, String> data = new HashMap<>();
if (prefillingSourceDefinition.getGetConfiguration() != null){
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria();
externalReferenceCriteria.setLike(model.getData().getId());
ExternalDataResult externalData = this.externalFetcherService.getExternalData(Stream.of(prefillingSourceDefinition.getGetConfiguration()).collect(Collectors.toList()), externalReferenceCriteria, null);
if (externalData != null && !this.conventionService.isListNullOrEmpty(externalData.getResults())) {
data = externalData.getResults().getFirst();
}
} else {
data = model.getData() == null ? new HashMap<>() : model.getData().getData();
}
DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getDescriptionTemplateId());
@ -363,42 +369,44 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
FieldSet descriptionTemplateFields = fieldSet.extractPrefixed(this.conventionService.asPrefix(Description._descriptionTemplate));
description.setDescriptionTemplate(this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(descriptionTemplateFields, descriptionTemplateEntity));
return mapPrefilledEntityToDescription(description, descriptionTemplateDefinition, prefillingSourceDefinition, prefillingSourceEntity.getLabel(), externalData.getResults().getFirst());//TODO
return mapPrefilledEntityToDescription(description, descriptionTemplateDefinition, prefillingSourceDefinition, prefillingSourceEntity.getLabel(), data);
}
private Description mapPrefilledEntityToDescription(Description description, DefinitionEntity descriptionTemplateDefinition, PrefillingSourceDefinitionEntity prefillingSourceDefinition, String type, Map<String, String> externalData){
List<DescriptionReference> descriptionReferences = new ArrayList<>();
if (!this.conventionService.isListNullOrEmpty(prefillingSourceDefinition.getFields())) {
for (PrefillingSourceDefinitionFieldEntity field : prefillingSourceDefinition.getFields()) {
String sourceValue = externalData.get(field.getCode());
this.prefillSystemValueToDescription(description, field.getSystemFieldTarget(), sourceValue);
this.prefillSemanticValueToDescription(description, field.getSemanticTarget(), sourceValue, descriptionTemplateDefinition, type);
this.prefillSemanticValueToDescription(description, descriptionReferences, field.getSemanticTarget(), sourceValue, descriptionTemplateDefinition, type);
}
}
if (!this.conventionService.isListNullOrEmpty(prefillingSourceDefinition.getFixedValueFields())){
for (PrefillingSourceDefinitionFixedValueFieldEntity field: prefillingSourceDefinition.getFixedValueFields()) {
this.prefillSystemValueToDescription(description, field.getSystemFieldTarget(), field.getFixedValue());
this.prefillSemanticValueToDescription(description, field.getSemanticTarget(), field.getFixedValue(), descriptionTemplateDefinition, type);
this.prefillSemanticValueToDescription(description, descriptionReferences, field.getSemanticTarget(), field.getFixedValue(), descriptionTemplateDefinition, type);
}
}
if (!this.conventionService.isListNullOrEmpty(prefillingSourceDefinition.getFields())) {
for (PrefillingSourceDefinitionFieldEntity field : prefillingSourceDefinition.getFields()) {
String sourceValue = externalData.get(field.getCode());
this.ensureZenodoFields(description, field.getSemanticTarget(), sourceValue, descriptionTemplateDefinition, type);
this.ensureZenodoFields(description, descriptionReferences, field.getSemanticTarget(), sourceValue, descriptionTemplateDefinition, type);
}
}
if (!this.conventionService.isListNullOrEmpty(prefillingSourceDefinition.getFixedValueFields())) {
for (PrefillingSourceDefinitionFixedValueFieldEntity field : prefillingSourceDefinition.getFixedValueFields()) {
this.ensureZenodoFields(description, field.getSemanticTarget(), field.getFixedValue(), descriptionTemplateDefinition, type);
this.ensureZenodoFields(description, descriptionReferences, field.getSemanticTarget(), field.getFixedValue(), descriptionTemplateDefinition, type);
}
}
description.setDescriptionReferences(descriptionReferences);
return description;
}
private void ensureZenodoFields(Description description, String semanticTarget, String value, DefinitionEntity definition, String type) {
private void ensureZenodoFields(Description description, List<DescriptionReference> descriptionReferences,String semanticTarget, String value, DefinitionEntity definition, String type) {
if (!this.conventionService.isNullOrEmpty(type) && !this.conventionService.isNullOrEmpty(semanticTarget) && !this.conventionService.isNullOrEmpty(value) && type.equals(Zenodo)) {
if (semanticTarget.equals("rda.dataset.distribution.data_access")) {
if (value.equals("open")) {
@ -416,7 +424,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
this.ensureFieldSetEntity(description, licStartFieldSetEntity);
for (FieldEntity licStartDateNode : licStartEntities) {
description.getProperties().getFieldSets().get(licStartFieldSetEntity.getId()).getItems().getFirst().getFields().put(licStartDateNode.getId(), buildPropertyDefinitionFieldItemValue(licStartDateNode, semanticTarget, issuedValue, type));
description.getProperties().getFieldSets().get(licStartFieldSetEntity.getId()).getItems().getFirst().getFields().put(licStartDateNode.getId(), buildPropertyDefinitionFieldItemValue(descriptionReferences,licStartDateNode, semanticTarget, issuedValue, type));
}
}
}
@ -437,7 +445,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
if (description.getProperties().getFieldSets().get(fieldSetEntity.getId()).getItems().getFirst().getOrdinal() == null) description.getProperties().getFieldSets().get(fieldSetEntity.getId()).getItems().getFirst().setOrdinal(0);
}
private void prefillSemanticValueToDescription(Description description, String semanticTarget, String parsedValue, DefinitionEntity definition, String type) {
private void prefillSemanticValueToDescription(Description description, List<DescriptionReference> descriptionReferences, String semanticTarget, String parsedValue, DefinitionEntity definition, String type) {
if (this.conventionService.isNullOrEmpty(semanticTarget) || this.conventionService.isNullOrEmpty(parsedValue)) return;
List<FieldSetEntity> fieldSetsEntities = definition.getAllFieldSets().stream().filter(x-> x.getAllField() != null && x.getAllField().stream().anyMatch(y-> !this.conventionService.isListNullOrEmpty(y.getSchematics()) && y.getSchematics().contains(semanticTarget))).toList();
for (FieldSetEntity fieldSetEntity: fieldSetsEntities) {
@ -445,7 +453,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
if (!this.conventionService.isListNullOrEmpty(fieldEntities)) {
this.ensureFieldSetEntity(description, fieldSetEntity);
for (FieldEntity fieldEntity : fieldEntities){
description.getProperties().getFieldSets().get(fieldSetEntity.getId()).getItems().getFirst().getFields().put(fieldEntity.getId() , buildPropertyDefinitionFieldItemValue(fieldEntity, semanticTarget, parsedValue, type));
description.getProperties().getFieldSets().get(fieldSetEntity.getId()).getItems().getFirst().getFields().put(fieldEntity.getId() , buildPropertyDefinitionFieldItemValue(descriptionReferences, fieldEntity, semanticTarget, parsedValue, type));
}
}
}
@ -474,7 +482,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
}
}
private Field buildPropertyDefinitionFieldItemValue(FieldEntity fieldEntity, String semanticTarget, String value, String type) {
private Field buildPropertyDefinitionFieldItemValue(List<DescriptionReference> descriptionReferences, FieldEntity fieldEntity, String semanticTarget, String value, String type) {
Field field = new Field();
if (fieldEntity == null || fieldEntity.getData() == null || fieldEntity.getData().getFieldType() == null || this.conventionService.isNullOrEmpty(value)) return field;
try{
@ -512,9 +520,11 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
SelectDataEntity selectDataEntity = (SelectDataEntity) fieldEntity.getData();
if (selectDataEntity == null || selectDataEntity.getOptions() == null) throw new MyApplicationException("Can not cast fieldEntity data");
field.setTextListValue(new ArrayList<>());
for (SelectDataEntity.OptionEntity entity : selectDataEntity.getOptions()){
if (finalValue.contains(entity.getValue()) || finalValue.contains(entity.getLabel())){
field.getTextListValue().add(entity.getValue());
if (selectDataEntity.getMultipleSelect()) field.getTextListValue().add(entity.getValue());
else field.setTextValue(entity.getValue());
}
}
}
@ -537,11 +547,13 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
.ensure(Reference._id)
.ensure(Reference._label)
.ensure(Reference._type)
.ensure(this.conventionService.asIndexer(Reference._type, ReferenceType._id))
.ensure(Reference._description)
.ensure(this.conventionService.asIndexer(Reference._description, Definition._fields, eu.eudat.model.referencedefinition.Field._code))
.ensure(this.conventionService.asIndexer(Reference._description, Definition._fields, eu.eudat.model.referencedefinition.Field._dataType))
.ensure(this.conventionService.asIndexer(Reference._description, Definition._fields, eu.eudat.model.referencedefinition.Field._value))
.ensure(Reference._reference)
.ensure(Reference._sourceType)
.ensure(Reference._abbreviation)
.ensure(Reference._source)
.ensure(Reference._isActive)
@ -554,6 +566,13 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
for (Reference reference : references){
if (reference.getReference().equals(like) || reference.getLabel().toUpperCase(Locale.ROOT).contains(like.toUpperCase(Locale.ROOT))) {
field.getReferences().add(reference);
DescriptionReference descriptionReference = new DescriptionReference();
descriptionReference.setReference(reference);
DescriptionReferenceData descriptionReferenceData = new DescriptionReferenceData();
descriptionReferenceData.setFieldId(fieldEntity.getId());
descriptionReference.setData(descriptionReferenceData);
descriptionReference.setIsActive(IsActive.Active);
descriptionReferences.add(descriptionReference);
}
}
}

View File

@ -1,65 +0,0 @@
package eu.eudat.service.transformer;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.bind.ConstructorBinding;
import java.util.List;
@ConfigurationProperties(prefix = "file-transformer")
public class FileTransformerProperties {
private final List<TransformerSource> sources;
@ConstructorBinding
public FileTransformerProperties(List<TransformerSource> sources) {
this.sources = sources;
}
public List<TransformerSource> getSources() {
return sources;
}
public static class TransformerSource {
private final String url;
private final String transformerId;
private final String issuerUrl;
private final String clientId;
private final String clientSecret;
private final String scope;
@ConstructorBinding
public TransformerSource(String url, String transformerId, String issuerUrl, String clientId, String clientSecret, String scope) {
this.url = url;
this.transformerId = transformerId;
this.issuerUrl = issuerUrl;
this.clientId = clientId;
this.clientSecret = clientSecret;
this.scope = scope;
}
public String getUrl() {
return url;
}
public String getIssuerUrl() {
return issuerUrl;
}
public String getClientId() {
return clientId;
}
public String getClientSecret() {
return clientSecret;
}
public String getScope() {
return scope;
}
public String getTransformerId() {
return transformerId;
}
}
}

View File

@ -1,30 +0,0 @@
package eu.eudat.controllers;
import eu.eudat.authorization.Permission;
import eu.eudat.logic.services.ExternalValidationService;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.exception.MyNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping(path = {"api/validation"})
public class ExternalValidationController {
private ExternalValidationService externalValidationService;
private final AuthorizationService authorizationService;
@Autowired
public ExternalValidationController(ExternalValidationService externalValidationService, AuthorizationService authorizationService) {
this.externalValidationService = externalValidationService;
this.authorizationService = authorizationService;
}
@GetMapping(path = {""}, produces = "application/json")
public @ResponseBody Boolean validate(@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
) throws MyNotFoundException {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
return this.externalValidationService.validateIdentifier(query, type);
}
}

View File

@ -4,7 +4,7 @@ import eu.eudat.audit.AuditableAction;
import eu.eudat.model.file.ExportRequestModel;
import eu.eudat.model.file.FileEnvelope;
import eu.eudat.model.file.RepositoryFileFormat;
import eu.eudat.service.transformer.FileTransformerService;
import eu.eudat.service.filetransformer.FileTransformerService;
import gr.cite.tools.auditing.AuditService;
import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry;

View File

@ -12,13 +12,12 @@ import eu.eudat.model.censorship.DescriptionCensor;
import eu.eudat.model.censorship.PrefillingCensor;
import eu.eudat.model.censorship.PrefillingSourceCensor;
import eu.eudat.model.persist.PrefillingSearchRequest;
import eu.eudat.model.persist.DescriptionProfilingRequest;
import eu.eudat.model.persist.DescriptionPrefillingRequest;
import eu.eudat.model.persist.PrefillingSourcePersist;
import eu.eudat.model.result.QueryResult;
import eu.eudat.query.PrefillingSourceQuery;
import eu.eudat.query.lookup.PrefillingSourceLookup;
import eu.eudat.service.prefillingsource.PrefillingSourceService;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.auditing.AuditService;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.censor.CensorFactory;
@ -63,7 +62,6 @@ public class PrefillingSourceController {
private final MessageSource messageSource;
private final AuthorizationService authorizationService;
private final PrefillingSourceService prefillingSourceService;
@ -73,13 +71,12 @@ public class PrefillingSourceController {
AuditService auditService,
CensorFactory censorFactory,
QueryFactory queryFactory,
MessageSource messageSource, AuthorizationService authorizationService, PrefillingSourceService prefillingSourceService) {
MessageSource messageSource, PrefillingSourceService prefillingSourceService) {
this.builderFactory = builderFactory;
this.auditService = auditService;
this.censorFactory = censorFactory;
this.queryFactory = queryFactory;
this.messageSource = messageSource;
this.authorizationService = authorizationService;
this.prefillingSourceService = prefillingSourceService;
}
@ -162,8 +159,8 @@ public class PrefillingSourceController {
}
@PostMapping("generate")
@ValidationFilterAnnotation(validator = DescriptionProfilingRequest.DescriptionProfilingRequestValidator.ValidatorName, argumentName = "model")
public Description generate(@RequestBody DescriptionProfilingRequest model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
@ValidationFilterAnnotation(validator = DescriptionPrefillingRequest.DescriptionProfilingRequestValidator.ValidatorName, argumentName = "model")
public Description generate(@RequestBody DescriptionPrefillingRequest model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
logger.debug(new MapLogEntry("persisting" + Prefilling.class.getSimpleName()).And("model", model));
this.censorFactory.censor(DescriptionCensor.class).censor(fieldSet, null);

View File

@ -1,425 +0,0 @@
package eu.eudat.logic.managers;
import eu.eudat.commons.enums.DescriptionTemplateStatus;
import eu.eudat.commons.metrics.MetricLabels;
import eu.eudat.commons.metrics.MetricNames;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import io.prometheus.client.Gauge;
import jakarta.annotation.PostConstruct;
import jakarta.transaction.Transactional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.management.InvalidApplicationException;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Component
public class MetricsManager {
private final static Logger logger = LoggerFactory.getLogger(MetricsManager.class);
private final Map<String, Gauge> gauges;
public static final Map<Short, String> datasetTemplateStatus = Stream.of(new Object[][] {
{ DescriptionTemplateStatus.Draft.getValue(), MetricLabels.DRAFT },
{ DescriptionTemplateStatus.Finalized.getValue(), MetricLabels.ACTIVE },
}).collect(Collectors.toMap(data -> (Short) data[0], data -> (String) data[1]));
public void increaseValue(String name, int amount, String label) {
if(label != null) {
gauges.get(name).labels(label).inc(amount);
} else {
gauges.get(name).inc(amount);
}
}
public void decreaseValue(String name, int amount, String label) {
if(label != null) {
gauges.get(name).labels(label).dec(amount);
} else {
gauges.get(name).dec(amount);
}
}
public Integer getValue(String name, String label) {
if(label != null) {
return Double.valueOf(gauges.get(name).labels(label).get()).intValue();
} else {
return Double.valueOf(gauges.get(name).get()).intValue();
}
}
public void calculateValue(String name, int amount, String label) {
Integer orig = getValue(name, label);
int diff = orig - amount;
if (diff != 0) {
if (diff > 0) {
decreaseValue(name, diff, label);
} else {
increaseValue(name, Math.abs(diff), label);
}
}
}
@Autowired
public MetricsManager(PrometheusMeterRegistry registry) {
registry.clear();
this.gauges = Stream.of( new Object[][]{
// {MetricNames.DMP, Gauge.build().name(MetricNames.DMP).help("Number of managed DMPs").labelNames("status").register(registry.getPrometheusRegistry())},
// {MetricNames.NEXUS + MetricNames.DMP, Gauge.build().name(MetricNames.NEXUS + MetricNames.DMP).help("Number of managed DMPs during Nexus").labelNames("status").register(registry.getPrometheusRegistry())},
//
// {MetricNames.FUNDERS, Gauge.build().name(MetricNames.FUNDERS).help("Number of registered Funders").register(registry.getPrometheusRegistry())},
// {MetricNames.GRANTS, Gauge.build().name(MetricNames.GRANTS).help("Number of registered Grants").register(registry.getPrometheusRegistry())},
// {MetricNames.PROJECT, Gauge.build().name(MetricNames.PROJECT).help("Number of registered Projects").register(registry.getPrometheusRegistry())},
// {MetricNames.RESEARCHER, Gauge.build().name(MetricNames.RESEARCHER).help("Number of Colaborators/Researchers").register(registry.getPrometheusRegistry())},
//
// {MetricNames.NEXUS + MetricNames.FUNDERS, Gauge.build().name(MetricNames.NEXUS + MetricNames.FUNDERS).help("Number of registered Funders during Nexus").register(registry.getPrometheusRegistry())},
// {MetricNames.NEXUS + MetricNames.GRANTS, Gauge.build().name(MetricNames.NEXUS + MetricNames.GRANTS).help("Number of registered Grants during Nexus").register(registry.getPrometheusRegistry())},
// {MetricNames.NEXUS + MetricNames.PROJECT, Gauge.build().name(MetricNames.NEXUS + MetricNames.PROJECT).help("Number of registered Projects during Nexus").register(registry.getPrometheusRegistry())},
// {MetricNames.NEXUS + MetricNames.RESEARCHER, Gauge.build().name(MetricNames.NEXUS + MetricNames.RESEARCHER).help("Number of Colaborators/Researchers during Nexus").register(registry.getPrometheusRegistry())},
//
// {MetricNames.DATASET, Gauge.build().name(MetricNames.DATASET).help("Number of managed Dataset Descriptions").labelNames("status").register(registry.getPrometheusRegistry())},
//
// {MetricNames.NEXUS + MetricNames.DATASET, Gauge.build().name(MetricNames.NEXUS + MetricNames.DATASET).help("Number of managed Dataset Descriptions during Nexus").labelNames("status").register(registry.getPrometheusRegistry())},
//
// {MetricNames.DATASET_TEMPLATE, Gauge.build().name(MetricNames.DATASET_TEMPLATE).help("Number of dataset Templates").labelNames("status").register(registry.getPrometheusRegistry())},
//
// {MetricNames.NEXUS + MetricNames.DATASET_TEMPLATE, Gauge.build().name(MetricNames.NEXUS + MetricNames.DATASET_TEMPLATE).help("Number of dataset Templates during Nexus").labelNames("status").register(registry.getPrometheusRegistry())},
//
// {MetricNames.USERS, Gauge.build().name(MetricNames.USERS).help("Number of users").labelNames("type").register(registry.getPrometheusRegistry())},
//
// {MetricNames.LANGUAGES, Gauge.build().name(MetricNames.LANGUAGES).help("Number of Languages").register(registry.getPrometheusRegistry())},
//
// {MetricNames.DMP_WITH_GRANT, Gauge.build().name(MetricNames.DMP_WITH_GRANT).help("Number of Grants based on the status of the DMP that is using them").labelNames("status").register(registry.getPrometheusRegistry())},
//
// {MetricNames.NEXUS + MetricNames.DMP_WITH_GRANT, Gauge.build().name(MetricNames.NEXUS + MetricNames.DMP_WITH_GRANT).help("Number of Grants based on the status of the DMP that is using them during Nexus").labelNames("status").register(registry.getPrometheusRegistry())},
//
// {MetricNames.INSTALLATIONS, Gauge.build().name(MetricNames.INSTALLATIONS).help("Number of Installations").register(registry.getPrometheusRegistry())},
// {MetricNames.NEXUS + MetricNames.INSTALLATIONS, Gauge.build().name(MetricNames.NEXUS + MetricNames.INSTALLATIONS).help("Number of Installations").register(registry.getPrometheusRegistry())},
}).collect(Collectors.toMap(data -> (String)data[0], data -> (Gauge) data[1]));
}
@PostConstruct
@Transactional
@Scheduled(initialDelay = 1000 * 60 * 60, fixedDelay = 1000 * 60 * 60)
public void init() throws IOException, InvalidApplicationException {
logger.info("Start calculating Metrics");
// calculateValue(MetricNames.DMP, (int) countAllDraftDMPs(), MetricNames.DRAFT);
// calculateValue(MetricNames.DMP, (int) countAllFinalizedDMPs(), MetricNames.FINALIZED);
// calculateValue(MetricNames.DMP, (int) countAllPublishedDMPs(), MetricNames.PUBLISHED);
// calculateValue(MetricNames.DMP, (int) countAllDoiedDMPs(), MetricNames.DOIED);
//
// calculateValue(MetricNames.NEXUS + MetricNames.DMP, (int) countAllDraftDMPs(true), MetricNames.DRAFT);
// calculateValue(MetricNames.NEXUS + MetricNames.DMP, (int) countAllFinalizedDMPs(true), MetricNames.FINALIZED);
// calculateValue(MetricNames.NEXUS + MetricNames.DMP, (int) countAllPublishedDMPs(true), MetricNames.PUBLISHED);
// calculateValue(MetricNames.NEXUS + MetricNames.DMP, (int) countAllDoiedDMPs(true), MetricNames.DOIED);
//
// calculateValue(MetricNames.DMP_WITH_GRANT, (int) countAllDraftDMPsWithGrantId(), MetricNames.DRAFT);
// calculateValue(MetricNames.DMP_WITH_GRANT, (int) countAllFinalizedDMPsWithGrantId(), MetricNames.FINALIZED);
// calculateValue(MetricNames.DMP_WITH_GRANT, (int) countAllPublishedDMPsWithGrantId(), MetricNames.PUBLISHED);
// calculateValue(MetricNames.DMP_WITH_GRANT, (int) countAllDoiedDMPsWithGrantId(), MetricNames.DOIED);
//
// calculateValue(MetricNames.NEXUS + MetricNames.DMP_WITH_GRANT, (int) countAllDraftDMPsWithGrantId(true), MetricNames.DRAFT);
// calculateValue(MetricNames.NEXUS + MetricNames.DMP_WITH_GRANT, (int) countAllFinalizedDMPsWithGrantId(true), MetricNames.FINALIZED);
// calculateValue(MetricNames.NEXUS + MetricNames.DMP_WITH_GRANT, (int) countAllPublishedDMPsWithGrantId(true), MetricNames.PUBLISHED);
// calculateValue(MetricNames.NEXUS + MetricNames.DMP_WITH_GRANT, (int) countAllDoiedDMPsWithGrantId(true), MetricNames.DOIED);
//
// calculateValue(MetricNames.FUNDERS, (int) countAllFunders(), null);
// calculateValue(MetricNames.GRANTS, (int) countAllGrants(), null);
// calculateValue(MetricNames.PROJECT, (int) countAllProjects(), null);
// calculateValue(MetricNames.RESEARCHER, (int) countAllResearchers(), null);
//
// calculateValue(MetricNames.NEXUS + MetricNames.FUNDERS, (int) countAllFunders(true), null);
// calculateValue(MetricNames.NEXUS + MetricNames.GRANTS, (int) countAllGrants(true), null);
// calculateValue(MetricNames.NEXUS + MetricNames.PROJECT, (int) countAllProjects(true), null);
// calculateValue(MetricNames.NEXUS + MetricNames.RESEARCHER, (int) countAllResearchers(true), null);
//
// calculateValue(MetricNames.DATASET, (int) countAllDraftDatasets(), MetricNames.DRAFT);
// calculateValue(MetricNames.DATASET, (int) countAllFinalizedDatasets(), MetricNames.FINALIZED);
// calculateValue(MetricNames.DATASET, (int) countAllPublicDatasets(), MetricNames.PUBLISHED);
// calculateValue(MetricNames.DATASET, (int) countAllDatasetsWithDoi(), MetricNames.DOIED);
//
// calculateValue(MetricNames.NEXUS + MetricNames.DATASET, (int) countAllDraftDatasets(true), MetricNames.DRAFT);
// calculateValue(MetricNames.NEXUS + MetricNames.DATASET, (int) countAllFinalizedDatasets(true), MetricNames.FINALIZED);
// calculateValue(MetricNames.NEXUS + MetricNames.DATASET, (int) countAllPublicDatasets(true), MetricNames.PUBLISHED);
// calculateValue(MetricNames.NEXUS + MetricNames.DATASET, (int) countAllDatasetsWithDoi(true), MetricNames.DOIED);
//
// calculateValue(MetricNames.DATASET_TEMPLATE, (int) countAllDraftTemplates(), MetricNames.DRAFT);
// calculateValue(MetricNames.DATASET_TEMPLATE, (int) countAllFinalizedTemplates(), MetricNames.ACTIVE);
// calculateValue(MetricNames.DATASET_TEMPLATE, (int) countAllUsedTemplates(), MetricNames.USED);
//
// calculateValue(MetricNames.NEXUS + MetricNames.DATASET_TEMPLATE, (int) countAllDraftTemplates(true), MetricNames.DRAFT);
// calculateValue(MetricNames.NEXUS + MetricNames.DATASET_TEMPLATE, (int) countAllFinalizedTemplates(true), MetricNames.ACTIVE);
// calculateValue(MetricNames.NEXUS + MetricNames.DATASET_TEMPLATE, (int) countAllUsedTemplates(true), MetricNames.USED);
//
// calculateValue(MetricNames.USERS, (int) userManager.countActiveUsers().intValue(), MetricNames.LOGGEDIN);
// calculateValue(MetricNames.USERS, (int) userManager.countAllUsers().intValue(), MetricNames.TOTAL);
//
// try (Stream<Path> paths = Files.list(Paths.get(Objects.requireNonNull(this.environment.getProperty("userguide.path"))))) {
// long files = paths.count();
// calculateValue(MetricNames.LANGUAGES, (int) files, null);
// } catch (Exception e) {
// logger.error("Could not calculate languages.");
// }
//
// calculateValue(MetricNames.INSTALLATIONS, 1, null);
// calculateValue(MetricNames.NEXUS + MetricNames.INSTALLATIONS, 1, null);
logger.info("Metrics calculation Completed");
}
private Date getNexusDate() {
try {
return new SimpleDateFormat("yyyy-MM-dd").parse("2021-01-01");
} catch (ParseException e) {
logger.error(e.getLocalizedMessage(), e);
}
return Date.from(LocalDate.of(2021, 1, 1).atStartOfDay(ZoneId.systemDefault()).toInstant());
}
private long countAllDraftDMPs() throws InvalidApplicationException {
return countAllDraftDMPs(false);
}
private long countAllDraftDMPs(boolean countNexus) throws InvalidApplicationException {
// DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
// criteria.setStatus(0);
// if (countNexus) criteria.setPeriodStart(getNexusDate());
// return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).count();
return 0;
}
private long countAllFinalizedDMPs() throws InvalidApplicationException {
return countAllFinalizedDMPs(false);
}
private long countAllFinalizedDMPs(boolean countNexus) throws InvalidApplicationException {
// DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
// criteria.setStatus(1);
// if (countNexus) criteria.setPeriodStart(getNexusDate());
// return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).count();
return 0;
}
private long countAllPublishedDMPs() throws InvalidApplicationException {
return countAllPublishedDMPs(false);
}
private long countAllPublishedDMPs(boolean countNexus) throws InvalidApplicationException {
// DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
// criteria.setIsPublic(true);
// criteria.setOnlyPublic(true);
// if (countNexus) criteria.setPeriodStart(getNexusDate());
// return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).count();
return 0;
}
private long countAllDoiedDMPs() throws InvalidApplicationException {
return countAllDoiedDMPs(false);
}
private long countAllDoiedDMPs(boolean countNexus) throws InvalidApplicationException {
// DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
// criteria.setHasDoi(true);
// if (countNexus) criteria.setPeriodStart(getNexusDate());
// return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).count();
return 0;
}
private long countAllDraftDMPsWithGrantId() throws InvalidApplicationException {
return countAllDraftDMPsWithGrantId(false);
}
private long countAllDraftDMPsWithGrantId(boolean countNexus) throws InvalidApplicationException {
// DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
// criteria.setStatus(0);
// if (countNexus) criteria.setPeriodStart(getNexusDate());
// return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).groupBy((builder, root) -> root.get("grant")).count();
return 0;
}
private long countAllFinalizedDMPsWithGrantId() throws InvalidApplicationException {
return countAllFinalizedDMPsWithGrantId(false);
}
private long countAllFinalizedDMPsWithGrantId(boolean countNexus) throws InvalidApplicationException {
// DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
// criteria.setStatus(1);
// if (countNexus) criteria.setPeriodStart(getNexusDate());
// return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).groupBy((builder, root) -> root.get("grant")).count();
return 0;
}
private long countAllPublishedDMPsWithGrantId() throws InvalidApplicationException {
return countAllPublishedDMPsWithGrantId(false);
}
private long countAllPublishedDMPsWithGrantId(boolean countNexus) throws InvalidApplicationException {
// DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
// criteria.setIsPublic(true);
// criteria.setOnlyPublic(true);
// if (countNexus) criteria.setPeriodStart(getNexusDate());
// return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).groupBy((builder, root) -> root.get("grant")).count();
return 0;
}
private long countAllDoiedDMPsWithGrantId() throws InvalidApplicationException {
return countAllDoiedDMPsWithGrantId(false);
}
private long countAllDoiedDMPsWithGrantId(boolean countNexus) throws InvalidApplicationException {
// DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
// criteria.setHasDoi(true);
// if (countNexus) criteria.setPeriodStart(getNexusDate());
// return apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).groupBy((builder, root) -> root.get("grant")).count();
return 0;
}
private long countAllResearchers() throws InvalidApplicationException {
return countAllResearchers(false);
}
private long countAllResearchers(boolean countNexus) throws InvalidApplicationException {
// ResearcherCriteria criteria = new ResearcherCriteria();
// if (countNexus) criteria.setPeriodStart(getNexusDate());
// return apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().getWithCriteria(criteria).count();
return 0;
}
private long countAllProjects() throws InvalidApplicationException {
return countAllProjects(false);
}
private long countAllProjects(boolean countNexus) throws InvalidApplicationException {
// ProjectCriteria criteria = new ProjectCriteria();
// if (countNexus) criteria.setPeriodStart(getNexusDate());
// return apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getWithCritetia(criteria).count();
return 0;
}
private long countAllFunders() throws InvalidApplicationException {
return countAllFunders(false);
}
private long countAllFunders(boolean countNexus) throws InvalidApplicationException {
// FunderCriteria criteria = new FunderCriteria();
// if (countNexus) criteria.setPeriodStart(getNexusDate());
// return apiContext.getOperationsContext().getDatabaseRepository().getFunderDao().getWithCritetia(criteria).count();
return 0;
}
private long countAllGrants() throws InvalidApplicationException {
return countAllGrants(false);
}
private long countAllGrants(boolean countNexus) throws InvalidApplicationException {
// GrantCriteria criteria = new GrantCriteria();
// if (countNexus) criteria.setPeriodStart(getNexusDate());
// return apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getWithCriteria(criteria).count();
return 0;
}
public long countAllDraftDatasets() throws InvalidApplicationException {
return countAllDraftDatasets(false);
}
public long countAllDraftDatasets(boolean countNexus) throws InvalidApplicationException {
// eu.eudat.data.dao.criteria.DatasetCriteria criteria = new eu.eudat.data.dao.criteria.DatasetCriteria();
// criteria.setStatus(0);
// if (countNexus) criteria.setPeriodStart(getNexusDate());
// return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(criteria).count();
return 0;
}
public long countAllFinalizedDatasets() throws InvalidApplicationException {
return countAllFinalizedDatasets(false);
}
public long countAllFinalizedDatasets(boolean countNexus) throws InvalidApplicationException {
// eu.eudat.data.dao.criteria.DatasetCriteria criteria = new eu.eudat.data.dao.criteria.DatasetCriteria();
// criteria.setStatus(1);
// if (countNexus) criteria.setPeriodStart(getNexusDate());
// return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(criteria).count();
return 0;
}
public long countAllPublicDatasets() throws InvalidApplicationException {
return countAllPublicDatasets(false);
}
public long countAllPublicDatasets(boolean countNexus) throws InvalidApplicationException {
// eu.eudat.data.dao.criteria.DatasetCriteria criteria = new eu.eudat.data.dao.criteria.DatasetCriteria();
// criteria.setIsPublic(true);
// if (countNexus) criteria.setPeriodStart(getNexusDate());
// return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(criteria).count();
return 0;
}
public long countAllDatasetsWithDoi() throws InvalidApplicationException {
return countAllDatasetsWithDoi(false);
}
public long countAllDatasetsWithDoi(boolean countNexus) throws InvalidApplicationException {
// eu.eudat.data.dao.criteria.DatasetCriteria criteria = new eu.eudat.data.dao.criteria.DatasetCriteria();
// criteria.setHasDoi(true);
// if (countNexus) criteria.setPeriodStart(getNexusDate());
// return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(criteria).count();
return 0;
}
public long countAllDraftTemplates() throws InvalidApplicationException {
return countAllDraftTemplates(false);
}
public long countAllDraftTemplates(boolean countNexus) throws InvalidApplicationException {
// DatasetProfileCriteria criteria = new DatasetProfileCriteria();
// criteria.setStatus(0);
// if (countNexus) criteria.setPeriodStart(getNexusDate());
return 0;
//return apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).count();
}
public long countAllFinalizedTemplates() throws InvalidApplicationException {
return countAllFinalizedTemplates(false);
}
public long countAllFinalizedTemplates(boolean countNexus) throws InvalidApplicationException {
// DatasetProfileCriteria criteria = new DatasetProfileCriteria();
// criteria.setStatus(1);
// if (countNexus) criteria.setPeriodStart(getNexusDate());
return 0;
// return apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).count();
}
@Transactional
public long countAllUsedTemplates() throws InvalidApplicationException {
return countAllUsedTemplates(false);
}
@Transactional
public long countAllUsedTemplates(boolean countNexus) throws InvalidApplicationException {
// DatasetProfileCriteria criteria = new DatasetProfileCriteria();
// criteria.setStatus(1);
// criteria.setAllVersions(false);
// if (countNexus) criteria.setPeriodStart(getNexusDate());
// List<DescriptionTemplateEntity> descriptionTemplateEntities = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).withFields(Collections.singletonList("id")).toList();
// DatasetCriteria datasetCriteria = new DatasetCriteria();
// datasetCriteria.setDatasetTemplates(descriptionTemplateEntities.stream().map(DescriptionTemplateEntity::getId).collect(Collectors.toList()));
// return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetCriteria).select(root -> root.getDescriptionTemplateId()).stream().distinct().count();
return 0;
}
}

View File

@ -1,31 +0,0 @@
package eu.eudat.logic.services;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria;
import gr.cite.tools.exception.MyNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ExternalValidationService {
// private RemoteFetcherService remoteFetcherService;
private final UserScope userScope;
@Autowired
public ExternalValidationService(UserScope userScope) {
super();
// this.remoteFetcherService = remoteFetcherService;
this.userScope = userScope;
}
public Boolean validateIdentifier(String identifier, String type) throws MyNotFoundException {
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(identifier, null);
// Integer count = this.remoteFetcherService.countEntries(externalReferenceCriteria, type);
Integer count = 1;
return userScope.isSet() && count > 0;
}
}

View File

@ -135,6 +135,26 @@ permissions:
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
# TenantConfiguration
BrowseTenantConfiguration:
roles:
- TenantAdmin
claims: [ ]
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
EditTenantConfiguration:
roles:
- TenantAdmin
clients: [ ]
allowAnonymous: true
allowAuthenticated: true
DeleteTenantConfiguration:
roles:
- TenantAdmin
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
# Language
BrowseLanguage:
roles: [ ]

4
dmp-backend/yarn.lock Normal file
View File

@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,25 @@
DO $$DECLARE
this_version CONSTANT varchar := '00.01.063';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
CREATE TABLE public."TenantConfiguration"
(
id uuid NOT NULL,
value character varying NOT NULL,
type smallint NOT NULL,
is_active smallint NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
tenant uuid,
PRIMARY KEY (id),
FOREIGN KEY (tenant)
REFERENCES public."Tenant" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID
);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.063', '2024-04-19 12:00:00.000000+02', now(), 'Add TenantConfiguration Table.');
END$$;

View File

@ -0,0 +1,4 @@
export enum FileTransformerEntityType {
Dmp = 0,
Description = 1
}

View File

@ -5,10 +5,14 @@ export interface PrefillingSearchRequest {
prefillingSourceId: Guid;
}
export interface DescriptionProfilingRequest {
export interface DescriptionPrefillingRequest {
prefillingSourceId: Guid;
descriptionTemplateId: Guid;
data: Map<String, Object>;
prefillId: string;
data: DescriptionPrefillingRequestData;
project: string[];
}
}
export interface DescriptionPrefillingRequestData {
data: Map<string, string>;
id: string;
}

View File

@ -60,11 +60,12 @@ export interface ExtraFieldInSection extends FieldInSection {
export interface ReferenceTypeFieldInSection extends FieldInSection {
referenceType: ReferenceType;
multipleSelect: boolean;
}
//
//
// Persist
//
//
export interface DmpBlueprintPersist extends BaseEntityPersist {
label: string;
definition: DmpBlueprintDefinitionPersist;
@ -120,4 +121,5 @@ export interface ExtraFieldInSectionPersist extends FieldInSectionPersist {
export interface ReferenceTypeFieldInSectionPersist extends FieldInSectionPersist {
referenceTypeId: Guid;
}
multipleSelect: boolean;
}

View File

@ -95,6 +95,7 @@ export interface DmpBlueprintValuePersist {
fieldId: Guid;
fieldValue: string;
references: DmpReferencePersist[];
reference: DmpReferencePersist;
}
export interface DmpContactPersist {

View File

@ -1,6 +1,9 @@
import { FileTransformerEntityType } from "@app/core/common/enum/file-transformer-entity-type";
export interface RepositoryFileFormat {
format: string;
hasLogo: boolean;
icon: string;
repositoryId: string;
entityTypes: FileTransformerEntityType[];
}

View File

@ -32,6 +32,7 @@ export interface Prefilling {
label: string,
key: string,
tag: string
data: Map<string, string>
}
// Persist

View File

@ -8,6 +8,7 @@ import { MatomoService } from '../matomo/matomo-service';
import { FileUtils } from '../utilities/file-utils.service';
import { AuthService } from '../auth/auth.service';
import { RepositoryFileFormat } from '@app/core/model/file/file-format.model';
import { FileTransformerEntityType } from '@app/core/common/enum/file-transformer-entity-type';
@Injectable()
export class FileTransformerService extends BaseService {
@ -32,6 +33,13 @@ export class FileTransformerService extends BaseService {
return this._availableFormats;
}
public availableFormatsFor(entityType: FileTransformerEntityType) {
if (this.availableFormats) {
return this.availableFormats.filter(x => x.entityTypes.includes(entityType));
}
return [];
}
init() {
this._loading = true;
// console.log('init');

View File

@ -12,7 +12,7 @@ import { catchError, map } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof';
import { ConfigurationService } from '../configuration/configuration.service';
import { BaseHttpV2Service } from '../http/base-http-v2.service';
import { PrefillingSearchRequest, DescriptionProfilingRequest } from '@app/core/model/description-profiling-request/description-profiling-request';
import { DescriptionPrefillingRequest, PrefillingSearchRequest } from '@app/core/model/description-profiling-request/description-profiling-request';
import { Description } from '@app/core/model/description/description';
@Injectable()
@ -65,7 +65,7 @@ export class PrefillingSourceService {
catchError((error: any) => throwError(error)));
}
generate(item: DescriptionProfilingRequest, reqFields: string[] = []): Observable<Description> {
generate(item: DescriptionPrefillingRequest, reqFields: string[] = []): Observable<Description> {
const url = `${this.apiBase}/generate`;
const options = { params: { f: reqFields } };
@ -113,4 +113,4 @@ export class PrefillingSourceService {
return lookup;
}
}
}

View File

@ -1,76 +1,86 @@
<div class="row multiple-auto-complete" ng-form>
<mat-chip-grid #chipList ngDefaultControl class="chip-list">
<ng-container *ngIf="value as values;">
<mat-chip-row *ngFor="let value of values" [disabled]="disabled" [selectable]="selectable" [removable]="removable" [ngClass]="computeClass(value)" class="chip-row">
<ng-container *ngIf="getSelectedItem(value) as selectedItem;">
<ng-template #cellTemplate *ngIf="_selectedValueTemplate(selectedItem)" [ngTemplateOutlet]="_selectedValueTemplate(selectedItem)" [ngTemplateOutletContext]="{
<div class="col">
<div class="row">
<div class="col-12">
<mat-chip-grid #chipList ngDefaultControl class="chip-list">
<ng-container *ngIf="value as values;">
<mat-chip-row *ngFor="let value of values" [disabled]="disabled" [selectable]="selectable" [removable]="removable" [ngClass]="computeClass(value)" class="chip-row">
<ng-container *ngIf="getSelectedItem(value) as selectedItem;">
<ng-template #cellTemplate *ngIf="_selectedValueTemplate(selectedItem)" [ngTemplateOutlet]="_selectedValueTemplate(selectedItem)" [ngTemplateOutletContext]="{
item: selectedItem
}" />
<span *ngIf="!_selectedValueTemplate(selectedItem)" class="chip-text" [title]="_displayFn(selectedItem)">{{_displayFn(selectedItem)}}</span>
</ng-container>
<button matChipRemove *ngIf="!disabled && removable" (click)="_removeSelectedItem(getSelectedItem(value), $event)">
<mat-icon>cancel</mat-icon>
</button>
</mat-chip-row>
</ng-container>
</mat-chip-grid>
<input matInput #autocompleteInput class="col" [name]="id" autocomplete="nope" #autocompleteTrigger="matAutocompleteTrigger" autocomplete="off" [placeholder]="placeholder" [matAutocomplete]="autocomplete" [value]="inputValue" (keyup)="onKeyUp($event)" [disabled]="disabled" (focus)="_onInputFocus()" (blur)="onBlur($event)" [matChipInputFor]="chipList" [matChipInputSeparatorKeyCodes]="separatorKeysCodes" [matChipInputAddOnBlur]="autoSelectFirstOptionOnBlur" (matChipInputTokenEnd)="_addItem($event)">
<mat-icon *ngIf="!disabled" class="align-arrow-right" matSuffix>arrow_drop_down</mat-icon>
<mat-autocomplete #autocomplete="matAutocomplete" [displayWith]="_displayFn.bind(this)" (optionSelected)="_optionSelected($event)">
<span *ngIf="_groupedItems">
<mat-optgroup *ngFor="let group of _groupedItems | async" [label]="group.title">
<mat-option *ngFor="let item of group.items" [value]="item" class="option" [class.two-line-mat-option]="_subtitleFn(item) && !_optionTemplate(item) && !_optionComponent(item)">
<!-- <img style="vertical-align:middle;" aria-hidden src="{{state.flag}}" height="25" /> -->
<ng-container *ngIf="_optionComponent(item)">
<ng-container *ngComponentOutlet="_optionComponent(item); inputs: { item };" />
<span *ngIf="!_selectedValueTemplate(selectedItem)" class="chip-text" [title]="_displayFn(selectedItem)">{{_displayFn(selectedItem)}}</span>
</ng-container>
<button matChipRemove *ngIf="!disabled && removable" (click)="_removeSelectedItem(getSelectedItem(value), $event)">
<mat-icon>cancel</mat-icon>
</button>
</mat-chip-row>
</ng-container>
<ng-template #cellTemplate *ngIf="_optionTemplate(item) && !_optionComponent(item)" [ngTemplateOutlet]="_optionTemplate(item)" [ngTemplateOutletContext]="{
</mat-chip-grid>
</div>
<div class="col-12">
<input matInput #autocompleteInput [name]="id" autocomplete="nope" #autocompleteTrigger="matAutocompleteTrigger" autocomplete="off" [placeholder]="placeholder" [matAutocomplete]="autocomplete" [value]="inputValue" (keyup)="onKeyUp($event)" [disabled]="disabled" (focus)="_onInputFocus()" (blur)="onBlur($event)" [matChipInputFor]="chipList" [matChipInputSeparatorKeyCodes]="separatorKeysCodes" [matChipInputAddOnBlur]="autoSelectFirstOptionOnBlur" (matChipInputTokenEnd)="_addItem($event)">
</div>
<mat-autocomplete #autocomplete="matAutocomplete" [displayWith]="_displayFn.bind(this)" (optionSelected)="_optionSelected($event)">
<span *ngIf="_groupedItems">
<mat-optgroup *ngFor="let group of _groupedItems | async" [label]="group.title">
<mat-option *ngFor="let item of group.items" [value]="item" class="option" [class.two-line-mat-option]="_subtitleFn(item) && !_optionTemplate(item) && !_optionComponent(item)">
<!-- <img style="vertical-align:middle;" aria-hidden src="{{state.flag}}" height="25" /> -->
<ng-container *ngIf="_optionComponent(item)">
<ng-container *ngComponentOutlet="_optionComponent(item); inputs: { item };" />
</ng-container>
<ng-template #cellTemplate *ngIf="_optionTemplate(item) && !_optionComponent(item)" [ngTemplateOutlet]="_optionTemplate(item)" [ngTemplateOutletContext]="{
item: item
}"></ng-template>
<div *ngIf="!_optionTemplate(item)" class="d-flex">
<div class="title-subtitle-fn">
<div class="title-fn">
<div class="title-fn-inner">
<span *ngIf="!_optionTemplate(item)" class="title-text">{{_titleFn(item)}}</span>
<div *ngIf="!_optionTemplate(item)" class="d-flex">
<div class="title-subtitle-fn">
<div class="title-fn">
<div class="title-fn-inner">
<span *ngIf="!_optionTemplate(item)" class="title-text">{{_titleFn(item)}}</span>
</div>
</div>
<div *ngIf="_subtitleFn(item)" class="subtitle-fn">
<div class="subtitle-fn-inner">
<small [innerHTML]="_subtitleFn(item)" class="subtitle-text"></small>
</div>
</div>
</div>
<span *ngIf="popupItemActionIcon" class="option-icon" (click)="_optionActionClick(item, $event)"><mat-icon>{{popupItemActionIcon}}</mat-icon></span>
</div>
<div *ngIf="_subtitleFn(item)" class="subtitle-fn">
<div class="subtitle-fn-inner">
<small [innerHTML]="_subtitleFn(item)" class="subtitle-text"></small>
</div>
</div>
</div>
<span *ngIf="popupItemActionIcon" class="option-icon" (click)="_optionActionClick(item, $event)"><mat-icon>{{popupItemActionIcon}}</mat-icon></span>
</div>
</mat-option>
</mat-optgroup>
</span>
<span *ngIf="!_groupedItems">
<div *ngIf="_items | async as autocompleteItems; else loading">
<ng-container *ngIf="autocompleteItems.length; else noItems">
<mat-option *ngFor="let item of autocompleteItems" class="option" [value]="item" [class.two-line-mat-option]="_subtitleFn(item) && !_optionTemplate(item) && !_optionComponent(item)">
<!-- <img style="vertical-align:middle;" aria-hidden src="{{state.flag}}" height="25" /> -->
<ng-container *ngIf="_optionComponent(item)">
<ng-container *ngComponentOutlet="_optionComponent(item); inputs: { item };" />
</ng-container>
<ng-template #cellTemplate *ngIf="_optionTemplate(item) && !_optionComponent(item)" [ngTemplateOutlet]="_optionTemplate(item)" [ngTemplateOutletContext]="{
</mat-option>
</mat-optgroup>
</span>
<span *ngIf="!_groupedItems">
<div *ngIf="_items | async as autocompleteItems; else loading">
<ng-container *ngIf="autocompleteItems.length; else noItems">
<mat-option *ngFor="let item of autocompleteItems" class="option" [value]="item" [class.two-line-mat-option]="_subtitleFn(item) && !_optionTemplate(item) && !_optionComponent(item)">
<!-- <img style="vertical-align:middle;" aria-hidden src="{{state.flag}}" height="25" /> -->
<ng-container *ngIf="_optionComponent(item)">
<ng-container *ngComponentOutlet="_optionComponent(item); inputs: { item };" />
</ng-container>
<ng-template #cellTemplate *ngIf="_optionTemplate(item) && !_optionComponent(item)" [ngTemplateOutlet]="_optionTemplate(item)" [ngTemplateOutletContext]="{
item: item
}"></ng-template>
<div *ngIf="!_optionTemplate(item) && !_optionComponent(item)">
<span class="title-text">{{_titleFn(item)}}</span>
<br *ngIf="_subtitleFn(item)">
<small *ngIf="_subtitleFn(item)" class="subtitle-text">{{_subtitleFn(item)}}</small>
<span *ngIf="popupItemActionIcon" class="option-icon" (click)="_optionActionClick(item, $event)"><mat-icon>{{popupItemActionIcon}}</mat-icon></span>
</div>
</mat-option>
</ng-container>
<ng-template #noItems>
<mat-option disabled="true">No results found!</mat-option>
</ng-template>
</div>
<ng-template #loading>
<mat-option disabled="true">loading...</mat-option>
</ng-template>
</span>
</mat-autocomplete>
<div *ngIf="!_optionTemplate(item) && !_optionComponent(item)">
<span class="title-text">{{_titleFn(item)}}</span>
<br *ngIf="_subtitleFn(item)">
<small *ngIf="_subtitleFn(item)" class="subtitle-text">{{_subtitleFn(item)}}</small>
<span *ngIf="popupItemActionIcon" class="option-icon" (click)="_optionActionClick(item, $event)"><mat-icon>{{popupItemActionIcon}}</mat-icon></span>
</div>
</mat-option>
</ng-container>
<ng-template #noItems>
<mat-option disabled="true">No results found!</mat-option>
</ng-template>
</div>
<ng-template #loading>
<mat-option disabled="true">loading...</mat-option>
</ng-template>
</span>
</mat-autocomplete>
</div>
</div>
<div class="col-auto d-flex">
<mat-icon *ngIf="!disabled" class="align-arrow-right" matSuffix>arrow_drop_down</mat-icon>
</div>
</div>

View File

@ -33,10 +33,10 @@
}
.chip-list {
max-width: calc(100% - 30px);
padding-left: 0.8em;
}
// .chip-list {
// max-width: calc(100% - 30px);
// padding-left: 0.8em;
// }
.title-subtitle-fn {
height: auto;

View File

@ -178,6 +178,12 @@
<mat-error *ngIf="field.get('semantics').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-auto section-field" *ngIf="field.get('category').value === dmpBlueprintSectionFieldCategory.ReferenceType">
<mat-checkbox [disabled]="formGroup.disabled" [checked]="field.get('multipleSelect').value" (change)="field.get('multipleSelect').setValue($event.checked)"><span>{{'DMP-BLUEPRINT-EDITOR.FIELDS.FIELD-MULTIPLE-SELECT' | translate}}</span></mat-checkbox>
<mat-error *ngIf="field.get('multipleSelect')?.hasError('backendError')">{{field.get('multipleSelect')?.getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('multipleSelect')?.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</div>
</div>
</div>
<div class="col-12 col-xl-auto">

View File

@ -71,6 +71,7 @@ export class DmpBlueprintEditorModel extends BaseEditorModel implements DmpBluep
const field: FieldInSectionEditorModel = new FieldInSectionEditorModel(this.validationErrorModel);
field.id = Guid.create();
field.ordinal = index + 1;
field.multipleSelect = false;
return field.buildForm({ rootPath: 'definition.sections[' + sectionIndex + '].fields[' + index + '].' });
}
@ -91,7 +92,7 @@ export class DmpBlueprintEditorModel extends BaseEditorModel implements DmpBluep
rootPath: `definition.`,
validationErrorModel: validationErrorModel
});
formGroup.updateValueAndValidity();
formGroup.updateValueAndValidity();
}
}
@ -308,6 +309,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
public dataType: DmpBlueprintExtraFieldDataType;
public systemFieldType: DmpBlueprintSystemFieldType;
public referenceTypeId: Guid;
public multipleSelect: boolean;
static get alwaysRequiredSystemFieldTypes(): DmpBlueprintSystemFieldType[] {
return [DmpBlueprintSystemFieldType.Title, DmpBlueprintSystemFieldType.Description, DmpBlueprintSystemFieldType.Language, DmpBlueprintSystemFieldType.AccessRights];
@ -338,6 +340,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
this.dataType = (item as ExtraFieldInSection).dataType;
} else if (this.category == DmpBlueprintFieldCategory.ReferenceType) {
this.referenceTypeId = (item as ReferenceTypeFieldInSection).referenceType?.id;
this.multipleSelect= (item as ReferenceTypeFieldInSection).multipleSelect;
}
return this;
@ -369,6 +372,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
dataType: [{ value: this.dataType, disabled: disabled }, context.getValidation('dataType').validators],
systemFieldType: [{ value: this.systemFieldType, disabled: disabled }, context.getValidation('systemFieldType').validators],
referenceTypeId: [{ value: this.referenceTypeId, disabled: disabled }, context.getValidation('referenceTypeId').validators],
multipleSelect: [{ value: this.multipleSelect, disabled: disabled }, context.getValidation('multipleSelect').validators],
});
}
@ -394,6 +398,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
baseValidationArray.push({ key: 'dataType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}dataType`)] });
baseValidationArray.push({ key: 'systemFieldType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}systemFieldType`)] });
baseValidationArray.push({ key: 'referenceTypeId', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}referenceTypeId`)] });
baseValidationArray.push({ key: 'multipleSelect', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}multipleSelect`)] });
baseContext.validation = baseValidationArray;
return baseContext;
@ -411,7 +416,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
validationErrorModel
});
['id', 'category', 'dataType', 'systemFieldType', 'referenceTypeId', 'label', 'placeholder', 'description', 'semantics', 'required', 'ordinal'].forEach(keyField => {
['id', 'category', 'dataType', 'systemFieldType', 'referenceTypeId', 'multipleSelect', 'label', 'placeholder', 'description', 'semantics', 'required', 'ordinal'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
if (keyField == 'label') {
@ -419,7 +424,10 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
} else if (keyField == 'referenceTypeId') {
if (formGroup.get('category').value === DmpBlueprintFieldCategory.ReferenceType) control?.addValidators([Validators.required, ...context.getValidation('referenceTypeId').validators]);
else control?.addValidators([...context.getValidation('referenceTypeId').validators]);
} else if (keyField == 'systemFieldType') {
} else if (keyField == 'multipleSelect') {
if (formGroup.get('category').value === DmpBlueprintFieldCategory.ReferenceType) control?.addValidators([Validators.required, ...context.getValidation('multipleSelect').validators]);
else control?.addValidators([...context.getValidation('multipleSelect').validators]);
}else if (keyField == 'systemFieldType') {
if (formGroup.get('category').value === DmpBlueprintFieldCategory.System) control?.addValidators([Validators.required, ...context.getValidation('systemFieldType').validators]);
else control?.addValidators([...context.getValidation('systemFieldType').validators]);
} else if (keyField == 'dataType') {
@ -508,4 +516,4 @@ export class DescriptionTemplatesInSectionEditorModel implements DescriptionTemp
control?.addValidators(context.getValidation(keyField).validators);
})
}
}
}

View File

@ -42,6 +42,7 @@ export class DmpBlueprintEditorResolver extends BaseEditorResolver {
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.referenceType), nameof<ReferenceType>(x => x.id)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.referenceType), nameof<ReferenceType>(x => x.name)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.referenceType), nameof<ReferenceType>(x => x.code)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.multipleSelect)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateGroupId)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'),
@ -50,7 +51,7 @@ export class DmpBlueprintEditorResolver extends BaseEditorResolver {
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.prefillingSources), nameof<PrefillingSource>(x => x.id)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.prefillingSources), nameof<PrefillingSource>(x => x.label)].join('.'),
nameof<DmpBlueprint>(x => x.createdAt),
nameof<DmpBlueprint>(x => x.hash),
nameof<DmpBlueprint>(x => x.isActive)

View File

@ -191,6 +191,7 @@ export class PrefillingSourceEditorComponent extends BaseEditor<PrefillingSource
}else{
const definition = this.formGroup.get('definition') as UntypedFormGroup;
if (definition.get('getConfiguration')) definition.removeControl('getConfiguration');
this.submitFields();
}
}
@ -253,7 +254,14 @@ export class PrefillingSourceEditorComponent extends BaseEditor<PrefillingSource
for (let i = 0; i < fieldsFormArray.length; i++) {
const code = fieldsFormArray.at(i).get('code').value;
// this.addFieldMapping(code, "searchConfiguration");
if(this.formGroup.get('definition').get('getEnabled').value == true) this.addFieldMapping(code, "getConfiguration");
if (this.formGroup.get('definition').get('getEnabled').value == true) {
this.addFieldMapping(code, "getConfiguration");
this.removeFieldMapping((this.formGroup.get('definition').get('searchConfiguration') as FormGroup), code);
}
else {
this.addFieldMapping(code, "searchConfiguration");
this.removeFieldMapping((this.formGroup.get('definition').get('getConfiguration') as FormGroup), code);
}
}
}
}

View File

@ -34,7 +34,7 @@
<mat-icon [disabled]="isDirty()" style="width: 14px;">expand_more</mat-icon>
</button>
<mat-menu #exportMenu="matMenu" xPosition="before">
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormats' (click)="fileTransformerService.exportDescription(formGroup.get('id').value, fileTransformer.repositoryId, fileTransformer.format)">
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormatsFor(fileTransformerEntityTypeEnum.Description)' (click)="fileTransformerService.exportDescription(formGroup.get('id').value, fileTransformer.repositoryId, fileTransformer.format)">
<i class="fa pr-2" [ngClass]="fileTransformer.icon ? fileTransformer.icon : 'fa-file-o'"></i>
<span>{{'GENERAL.FILE-TRANSFORMER.' + fileTransformer?.format?.toUpperCase() | translate}}</span>
</button>

View File

@ -46,9 +46,7 @@ import { FileTransformerService } from '@app/core/services/file-transformer/file
import { DmpBlueprintDefinitionSection } from '@app/core/model/dmp-blueprint/dmp-blueprint';
import { DescriptionTemplate, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplatePage, DescriptionTemplateSection } from '@app/core/model/description-template/description-template';
import { DmpDescriptionTemplate } from '@app/core/model/dmp/dmp';
import { BehaviorSubject } from 'rxjs';
import { UUID } from 'crypto';
import { AbstractControl } from '@angular/forms';
import { FileTransformerEntityType } from '@app/core/common/enum/file-transformer-entity-type';
@Component({
selector: 'app-description-editor-component',
@ -62,6 +60,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
isDeleted = false;
item: Description;
fieldsetIdWithFocus: string;
fileTransformerEntityTypeEnum = FileTransformerEntityType;
viewOnly = false;
lockStatus: Boolean;
@ -645,7 +644,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
this.descriptionIsOnceSaved = true;
if (this.formGroup.get('status').value == DescriptionStatus.Finalized) this.isFinalized = true;
},
error => {
error => {
if (this.formGroup.get('status').value == DescriptionStatus.Finalized){
this.formGroup.get('status').setValue(DescriptionStatus.Draft);
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-FINALIZE'), SnackBarNotificationLevel.Error);

View File

@ -233,6 +233,25 @@ export class DescriptionPropertyDefinitionEditorModel implements DescriptionProp
} as DescriptionPropertyDefinitionFieldSetItem]
}
// preffiling item case we ned to ensure tha all fields of fieldset are contained
for (let i = 0; i < definitionFieldSet.fields.length; i++) {
const definitionField = definitionFieldSet.fields[i];
for (let j = 0; j < fieldSetValue.items.length; j++) {
const fieldSetValueItem = fieldSetValue.items[j];
const descriptionField = fieldSetValueItem.fields[definitionField.id];
if (!descriptionField) {
fieldSetValueItem.fields[definitionField.id] = {
textValue: undefined,
textListValue: undefined,
dateValue: undefined,
externalIdentifier: undefined,
references: undefined
};
}
}
}
return new DescriptionPropertyDefinitionFieldSetEditorModel(this.validationErrorModel).fromModel(fieldSetValue, descriptionReferences, definitionFieldSet);
}

View File

@ -12,7 +12,7 @@ export class VisibilityRulesService {
private form: AbstractControl;
private definition: DescriptionTemplateDefinition;
private rulesBySources: Map<String, RuleWithTarget[]> ;
public isVisibleMap: { [key: string]: boolean } = null;
public isVisibleMap: { [key: string]: boolean } = {};
private _isVisibleMap: { [key: string]: boolean } = null;
private allDescriptionTemplateFields: DescriptionTemplateField[] = null;

View File

@ -0,0 +1,41 @@
import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
import { DescriptionPrefillingRequest, DescriptionPrefillingRequestData } from "@app/core/model/description-profiling-request/description-profiling-request";
import { BackendErrorValidator } from "@common/forms/validation/custom-validator";
import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model";
import { Validation, ValidationContext } from "@common/forms/validation/validation-context";
import { Guid } from "@common/types/guid";
export class DescriptionPrefillingRequestEditorModel implements DescriptionPrefillingRequest {
prefillingSourceId: Guid;
descriptionTemplateId: Guid;
data: DescriptionPrefillingRequestData;
project: string[];
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup {
if (context == null) { context = this.createValidationContext(); }
return this.formBuilder.group({
prefillingSourceId: [{ value: this.prefillingSourceId, disabled: disabled }, context.getValidation('prefillingSourceId').validators],
descriptionTemplateId: [{ value: this.descriptionTemplateId, disabled: disabled }, context.getValidation('descriptionTemplateId').validators],
data: [{ value: this.data, disabled: disabled }, context.getValidation('data').validators],
});
}
createValidationContext(): ValidationContext {
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'prefillingSourceId', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, `prefillingSourceId`)] });
baseValidationArray.push({ key: 'descriptionTemplateId', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, `descriptionTemplateId`)] });
baseValidationArray.push({ key: 'data', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, `data`)] });
baseContext.validation = baseValidationArray;
return baseContext;
}
}

View File

@ -51,7 +51,7 @@
<h4 class="col-auto heading">{{'PREFILL-DESCRIPTION-DIALOG.SEARCH-HEADER' | translate}}</h4>
</div>
<mat-form-field class="col-md-12">
<app-single-auto-complete [required]="true" [formControl]="prefillForm.get('prefillId')"
<app-single-auto-complete [required]="true" [formControl]="prefillForm.get('data')"
placeholder="{{'PREFILL-DESCRIPTION-DIALOG.SEARCH' | translate}}"
[configuration]="prefillAutoCompleteConfiguration">
</app-single-auto-complete>

View File

@ -1,26 +1,24 @@
import { Component, Inject, OnInit } from "@angular/core";
import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from "@angular/material/dialog";
import { PrefillingSearchRequest, DescriptionProfilingRequest } from "@app/core/model/description-profiling-request/description-profiling-request";
import { DescriptionPrefillingRequest, PrefillingSearchRequest } from "@app/core/model/description-profiling-request/description-profiling-request";
import { DescriptionTemplate } from "@app/core/model/description-template/description-template";
import { Dmp } from "@app/core/model/dmp/dmp";
import { Prefilling } from "@app/core/model/prefilling-source/prefilling-source";
import { DmpBlueprintService } from "@app/core/services/dmp/dmp-blueprint.service";
import { PrefillingSourceService } from "@app/core/services/prefilling-source/prefilling-source.service";
import { ProgressIndicationService } from "@app/core/services/progress-indication/progress-indication-service";
import { SingleAutoCompleteConfiguration } from "@app/library/auto-complete/single/single-auto-complete-configuration";
import { DescriptionTemplateEditorResolver } from "@app/ui/admin/description-template/editor/description-template-editor.resolver";
import { BaseComponent } from "@common/base/base.component";
import { FormService } from "@common/forms/form-service";
import { Guid } from "@common/types/guid";
import { TranslateService } from "@ngx-translate/core";
import { UUID } from "crypto";
import { Observable } from "rxjs";
import { map, takeUntil } from "rxjs/operators";
import { DescriptionEditorResolver } from "../description-editor.resolver";
import { nameof } from "ts-simple-nameof";
import { Description } from "@app/core/model/description/description";
import { IsActive } from "@app/core/common/enum/is-active.enum";
import { DescriptionPrefillingRequestEditorModel } from "./prefill-description-editor.model";
@Component({
selector: 'prefill-description-component',
@ -39,11 +37,7 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements
availableDescriptionTemplates: DescriptionTemplate[] = [];
constructor(public dialogRef: MatDialogRef<PrefillDescriptionDialogComponent>,
// private dmpBlueprintService: DmpBlueprintService,
// private dialog: MatDialog,
// private language: TranslateService,
private progressIndicationService: ProgressIndicationService,
private fb: UntypedFormBuilder,
public prefillingSourceService: PrefillingSourceService,
private formService: FormService,
@Inject(MAT_DIALOG_DATA) public data: any) {
@ -58,128 +52,24 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements
this.progressIndicationService.getProgressIndicationObservable().pipe(takeUntil(this._destroyed)).subscribe(x => {
setTimeout(() => { this.progressIndication = x; });
});
this.prefillForm = this.fb.group({
type: this.fb.control(false),
descriptionTemplateId: this.fb.control(null, Validators.required),
prefillingSourceId: this.fb.control(null, Validators.required),
prefillId: this.fb.control(null, Validators.required),
})
// if (this.data.availableProfiles && this.data.availableProfiles.length === 1) {
// this.addProfileIfUsedLessThanMax(this.data.availableProfiles[0]);
// }
const editorModel = new DescriptionPrefillingRequestEditorModel();
this.prefillForm = editorModel.buildForm(null, false);
this.prefillAutoCompleteConfiguration = {
filterFn: this.searchDescriptions.bind(this),
loadDataOnStart: false,
displayFn: (item) => (item['label'].length > 60) ? (item['label'].substr(0, 60) + "...") : item['label'],
titleFn: (item) => item['label'],
subtitleFn: (item) => item['id'],
valueAssign: (item) => item['id'],
displayFn: (item: Prefilling) => (item.label.length > 60) ? (item.label.substr(0, 60) + "...") : item.label,
titleFn: (item: Prefilling) => item.label,
subtitleFn: (item: Prefilling) => item.id,
valueAssign: (item: Prefilling) => item,
uniqueAssign: (item: Prefilling) => item.id,
};
}
changePreffillingSource(){
this.prefillForm.get('prefillId').setValue(null);
this.prefillForm.get('data').setValue(null);
}
// addProfileIfUsedLessThanMax(profile: DescriptionProfileModel) {
// const dmpSectionIndex = this.data.datasetFormGroup.get('dmpSectionIndex').value;
// const blueprintId = this.data.datasetFormGroup.get('dmp').value.profile.id;
// this.dmpBlueprintService.getSingle(blueprintId, this.getBlueprintDefinitionFields())
// .pipe(takeUntil(this._destroyed))
// .subscribe(result => {
// const section = result.definition.sections[dmpSectionIndex];
// if (section.hasTemplates) {
// const foundTemplate = section.descriptionTemplates.find(template => template.descriptionTemplateId === Guid.parse(profile.id));
// if (foundTemplate !== undefined) {
// let count = 0;
// if (this.data.datasetFormGroup.get('dmp').value.datasets != null) {
// for (let dataset of this.data.datasetFormGroup.get('dmp').value.datasets) {
// if (dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId) {
// count++;
// }
// }
// if (count < foundTemplate.maxMultiplicity) {
// this.prefillForm.get('profile').patchValue(profile);
// }
// }
// }
// else {
// this.prefillForm.get('profile').patchValue(profile);
// }
// }
// else {
// this.prefillForm.get('profile').patchValue(profile);
// }
// });
// }
// checkMinMax(event, profile: DescriptionProfileModel) {
// event.stopPropagation();
// const dmpSectionIndex = this.data.datasetFormGroup.get('dmpSectionIndex').value;
// const blueprintId = this.data.datasetFormGroup.get('dmp').value.profile.id;
// this.dmpBlueprintService.getSingle(blueprintId, this.getBlueprintDefinitionFields())
// .pipe(takeUntil(this._destroyed))
// .subscribe(result => {
// const section = result.definition.sections[dmpSectionIndex];
// if (section.hasTemplates) {
// const foundTemplate = section.descriptionTemplates.find(template => template.descriptionTemplateId === Guid.parse(profile.id));
// if (foundTemplate !== undefined) {
// let count = 0;
// if (this.data.datasetFormGroup.get('dmp').value.datasets != null) {
// for (let dataset of this.data.datasetFormGroup.get('dmp').value.datasets) {
// if (dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId) {
// count++;
// }
// }
// if (count === foundTemplate.maxMultiplicity) {
// this.dialog.open(PopupNotificationDialogComponent, {
// data: {
// title: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.TITLE'),
// message: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.MESSAGE')
// }, maxWidth: '30em'
// });
// }
// else {
// this.prefillForm.get('profile').setValue(profile);
// }
// }
// }
// else {
// this.prefillForm.get('profile').setValue(profile);
// }
// }
// else {
// this.prefillForm.get('profile').setValue(profile);
// }
// });
// }
// private getBlueprintDefinitionFields() {
// return [
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.id)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.label)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.description)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.ordinal)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.hasTemplates)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.id)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.category)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.dataType)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.systemFieldType)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.label)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.placeholder)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.description)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.required)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.ordinal)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.id)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateId)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.minMultiplicity)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.maxMultiplicity)].join('.'),
// ]
// }
public compareWith(object1: any, object2: any) {
return object1 && object2 && object1.id === object2.id;
}
@ -194,23 +84,7 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements
}
next() {
// if (this.isPrefilled) {
// if (this.prefillForm.get('prefill').value.data == null) {
// this.prefillingService.getPrefillingDescription(this.prefillForm.get('prefill').value.pid, this.prefillForm.get('profile').value.id, this.prefillForm.get('prefill').value.key).subscribe(wizard => {
// wizard.profile = this.prefillForm.get('profile').value;
// this.closeDialog(wizard);
// });
// }
// else {
// this.prefillingService.getPrefillingDescriptionUsingData(this.prefillForm.get('prefill').value.data, this.prefillForm.get('profile').value.id, this.prefillForm.get('prefill').value.key).subscribe(wizard => {
// wizard.profile = this.prefillForm.get('profile').value;
// this.closeDialog(wizard);
// });
// }
// } else {
// this.closeDialog();
// }
const formData = this.formService.getValue(this.prefillForm.value) as DescriptionProfilingRequest;
const formData = this.formService.getValue(this.prefillForm.value) as DescriptionPrefillingRequest;
this.prefillingSourceService.generate(formData, DescriptionEditorResolver.descriptionTemplateLookupFields(nameof<Description>(x => x.descriptionTemplate)))
.pipe(takeUntil(this._destroyed)).subscribe(description => {
@ -226,4 +100,4 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements
closeDialog(result = null): void {
this.dialogRef.close(result);
}
}
}

View File

@ -24,7 +24,7 @@
</div>
</a>
<div class="description-card-actions">
<a class="col-auto border-right pointer" *ngIf="fileTransformerService.availableFormats && fileTransformerService.availableFormats.length > 0" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DESCRIPTION-LISTING.ACTIONS.EXPORT' | translate}}</a>
<a class="col-auto border-right pointer" *ngIf="fileTransformerService.availableFormatsFor(fileTransformerEntityTypeEnum.Description) && fileTransformerService.availableFormatsFor(fileTransformerEntityTypeEnum.Description).length > 0" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DESCRIPTION-LISTING.ACTIONS.EXPORT' | translate}}</a>
<a class="col-auto border-right pointer" *ngIf="canInviteDmpUsers" (click)="openShareDialog()"><span class="material-icons icon-align pr-2">group_add</span>{{'DESCRIPTION-LISTING.ACTIONS.INVITE-SHORT' | translate}}</a>
<a class="col-auto border-right pointer" *ngIf="isAuthenticated()" (click)="copyToDmp(description)"><span class="material-icons icon-align pr-2">file_copy</span>{{'DESCRIPTION-LISTING.ACTIONS.COPY-DESCRIPTION' | translate}}</a>
<a class="col-auto border-right pointer" *ngIf="canDelete" (click)="deleteClicked(description.id)"><span class="material-icons icon-align pr-2">delete</span>{{ 'DESCRIPTION-LISTING.ACTIONS.DELETE' | translate }}</a>
@ -38,7 +38,7 @@
</button>
</mat-menu>
<mat-menu #exportMenu="matMenu" xPosition="before">
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormats' (click)="fileTransformerService.exportDescription(description.id, fileTransformer.repositoryId, fileTransformer.format)">
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormatsFor(fileTransformerEntityTypeEnum.Description)' (click)="fileTransformerService.exportDescription(description.id, fileTransformer.repositoryId, fileTransformer.format)">
<i class="fa pr-2" [ngClass]="fileTransformer.icon ? fileTransformer.icon : 'fa-file-o'"></i>
<span>{{'GENERAL.FILE-TRANSFORMER.' + fileTransformer.format.toUpperCase() | translate}}</span>
</button>

View File

@ -27,6 +27,7 @@ import { takeUntil } from 'rxjs/operators';
import { DescriptionStatus } from '../../../../core/common/enum/description-status';
import { DescriptionCopyDialogComponent } from '../../description-copy-dialog/description-copy-dialog.component';
import { AppPermission } from '@app/core/common/enum/permission.enum';
import { FileTransformerEntityType } from '@app/core/common/enum/file-transformer-entity-type';
@Component({
selector: 'app-description-listing-item-component',
@ -44,6 +45,7 @@ export class DescriptionListingItemComponent extends BaseComponent implements On
isDeleted: boolean;
isUserOwner: boolean;
descriptionStatusEnum = DescriptionStatus;
fileTransformerEntityTypeEnum = FileTransformerEntityType;
dmpAccessTypeEnum = DmpAccessType;
canDelete: boolean = false;
canEdit: boolean = false;

View File

@ -147,7 +147,7 @@
</div>
</div>
</ng-container>
<ng-container *ngIf="fileTransformerService.availableFormats.length > 0">
<ng-container *ngIf="fileTransformerService.availableFormatsFor(fileTransformerEntityTypeEnum.Description).length > 0">
<div class="row mb-3 align-items-center">
<div class="col-auto pr-0">
<button mat-mini-fab class="frame-btn" [matMenuTriggerFor]="exportMenu">
@ -160,7 +160,7 @@
</div>
</ng-container>
<mat-menu #exportMenu="matMenu" xPosition="before">
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormats' (click)="fileTransformerService.exportDescription(description.id, fileTransformer.repositoryId, fileTransformer.format)">
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormatsFor(fileTransformerEntityTypeEnum.Description)' (click)="fileTransformerService.exportDescription(description.id, fileTransformer.repositoryId, fileTransformer.format)">
<i class="fa pr-2" [ngClass]="fileTransformer.icon ? fileTransformer.icon : 'fa-file-o'"></i>
<span>{{'GENERAL.FILE-TRANSFORMER.' + fileTransformer.format.toUpperCase() | translate}}</span>
</button>

View File

@ -40,6 +40,7 @@ import { PopupNotificationDialogComponent } from '@app/library/notification/popu
import { IsActive } from '@app/core/common/enum/is-active.enum';
import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dialog/dmp-invitation-dialog.component';
import { DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection } from '@app/core/model/dmp-blueprint/dmp-blueprint';
import { FileTransformerEntityType } from '@app/core/common/enum/file-transformer-entity-type';
@Component({
@ -62,6 +63,7 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni
dmpAccessTypeEnum = DmpAccessType;
dmpStatusEnum = DmpStatus;
dmpUserRoleEnum = DmpUserRole;
fileTransformerEntityTypeEnum = FileTransformerEntityType;
canEdit = false;
canDelete = false;

View File

@ -91,7 +91,7 @@
<div class="d-flex flex-direction-row">
<div class="label" matTooltip="{{description.label}}">{{'DMP-EDITOR.DESCRIPTION' | translate}}: {{ description.label }}</div>
<mat-icon *ngIf="description.status !== descriptionStatusEnum.Finalized && canDeleteSection(section.id) && !formGroup.disabled" [ngClass]="{'drag-handle-disabled': formGroup.disabled}" class="ml-2 mr-2 remove-description size-16" matTooltip="{{'DMP-EDITOR.ACTIONS.DELETE' | translate}}" (click)="$event.stopPropagation(); removeDescription(description.id)">close</mat-icon>
<mat-icon *ngIf="description.status === descriptionStatusEnum.Finalized" class="ml-2 mr-2 status-icon check-icon size-16" matTooltip="{{'TYPES.DESCRIPTION-STATUS.FINALISED' | translate}}">check</mat-icon>
<mat-icon *ngIf="description.status === descriptionStatusEnum.Finalized" class="ml-2 mr-2 status-icon check-icon size-16" matTooltip="{{'TYPES.DESCRIPTION-STATUS.FINALIZED' | translate}}">check</mat-icon>
</div>
</li>
</ol>
@ -215,7 +215,7 @@
</div>
</div>
<div class="col-12 col-xl-auto">
<button [disabled]="formGroup.disabled" mat-icon-button class="action-list-icon" matTooltip="{{'DMP-EDITOR.ACTIONS1.REMOVE-CONTACT' | translate}}" (click)="removeContact(contactIndex)" [disabled]="formGroup.disabled">
<button [disabled]="formGroup.disabled" mat-icon-button class="action-list-icon" matTooltip="{{'DMP-EDITOR.ACTIONS.REMOVE-CONTACT' | translate}}" (click)="removeContact(contactIndex)" [disabled]="formGroup.disabled">
<mat-icon>delete</mat-icon>
</button>
</div>
@ -249,9 +249,12 @@
</div>
</div>
<div *ngIf="field.category === dmpBlueprintSectionFieldCategoryEnum.ReferenceType">
<div>
<app-reference-field-component [form]="formGroup.get('properties').get('dmpBlueprintValues').get(field.id).get('references')" [dependencies]="formGroup.get('properties').get('dmpBlueprintValues')" [label]= "field.label" [placeholder]="field.placeholder ?? field.label" [referenceType]="field.referenceType"></app-reference-field-component>
</div>
<ng-container *ngIf="field.multipleSelect">
<app-reference-field-component [form]="formGroup.get('properties').get('dmpBlueprintValues').get(field.id).get('references')" [dependencies]="formGroup.get('properties').get('dmpBlueprintValues')" [label]= "field.label" [placeholder]="field.placeholder ?? field.label" [referenceType]="field.referenceType" [multiple]="true"></app-reference-field-component>
</ng-container>
<ng-container *ngIf="!(field.multipleSelect)">
<app-reference-field-component [form]="formGroup.get('properties').get('dmpBlueprintValues').get(field.id).get('reference')" [dependencies]="formGroup.get('properties').get('dmpBlueprintValues')" [label]= "field.label" [placeholder]="field.placeholder ?? field.label" [referenceType]="field.referenceType" [multiple]="false"></app-reference-field-component>
</ng-container>
</div>
<div *ngIf="field.category === dmpBlueprintSectionFieldCategoryEnum.Extra">
<div *ngIf="field.dataType === dmpBlueprintExtraFieldDataTypeEnum.Text">
@ -296,7 +299,7 @@
<div class="heading">{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES' | translate}}</div>
<mat-form-field class="w-100">
<mat-label>{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}</mat-label>
<app-multiple-auto-complete placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}" [hidePlaceholder]="true" required='true' [formControl]="formGroup.get('descriptionTemplates').get(section.id)" [configuration]="descriptionTemplateService.descriptionTempalteGroupMultipleAutocompleteConfiguration" (optionActionClicked)="onPreviewDescriptionTemplate($event, section.id)">
<app-multiple-auto-complete placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}" [hidePlaceholder]="true" required='true' [formControl]="formGroup.get('descriptionTemplates').get(section.id)" [configuration]="descriptionTemplateService.descriptionTempalteGroupMultipleAutocompleteConfiguration" (optionActionClicked)="onPreviewDescriptionTemplate($event, section.id)" (optionRemoved)="onRemoveDescriptionTemplate($event, section.id)">
</app-multiple-auto-complete>
<mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).hasError('backendError')">{{formGroup.get('descriptionTemplates').get(section.id).getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>

View File

@ -562,6 +562,28 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
});
}
onRemoveDescriptionTemplate(event, sectionId: Guid){
let foundDescription = false;
const descriptionsInSection = this.descriptionsInSection(sectionId);
let descriptionTemplatesInSection = this.formGroup.get('descriptionTemplates').get(sectionId.toString()).value as Guid[];
if (descriptionsInSection && descriptionsInSection.length > 0){
for (let index = 0; index < descriptionsInSection.length; index++) {
const description = descriptionsInSection[index];
if(description.dmpDescriptionTemplate?.descriptionTemplateGroupId === event.groupId) {
foundDescription = true;
this.uiNotificationService.snackBarNotification(this.language.instant('DMP-EDITOR.UNSUCCESSFUL-REMOVE-TEMPLATE'), SnackBarNotificationLevel.Error);
break;
}
}
if(foundDescription) {
if (descriptionTemplatesInSection) this.formGroup.get('descriptionTemplates').get(sectionId.toString()).patchValue(descriptionTemplatesInSection);
else this.formGroup.get('descriptionTemplates').get(sectionId.toString()).patchValue([]);
}
}
}
//
//
// Misc

View File

@ -6,7 +6,7 @@ import { DmpStatus } from "@app/core/common/enum/dmp-status";
import { DmpUserRole } from "@app/core/common/enum/dmp-user-role";
import { DmpUserType } from "@app/core/common/enum/dmp-user-type";
import { IsActive } from "@app/core/common/enum/is-active.enum";
import { DmpBlueprint, FieldInSection } from "@app/core/model/dmp-blueprint/dmp-blueprint";
import { DmpBlueprint, FieldInSection, ReferenceTypeFieldInSection } from "@app/core/model/dmp-blueprint/dmp-blueprint";
import { Dmp, DmpBlueprintValue, DmpBlueprintValuePersist, DmpContact, DmpContactPersist, DmpDescriptionTemplate, DmpDescriptionTemplatePersist, DmpPersist, DmpProperties, DmpPropertiesPersist, DmpReferenceDataPersist, DmpReferencePersist, DmpUser, DmpUserPersist } from "@app/core/model/dmp/dmp";
import { DmpReference } from "@app/core/model/dmp/dmp-reference";
import { ReferencePersist } from "@app/core/model/reference/reference";
@ -291,7 +291,8 @@ export class DmpPropertiesEditorModel implements DmpPropertiesPersist {
formGroup: control as UntypedFormGroup,
rootPath: `${rootPath}dmpBlueprintValues[${key}].`,
validationErrorModel: validationErrorModel,
isRequired: params.blueprint.definition.sections.flatMap(x => x.fields).find(x => x.id.toString() == key).required
isRequired: params.blueprint.definition.sections.flatMap(x => x.fields).find(x => x.id.toString() == key).required,
multipleSelect: (params.blueprint.definition.sections.flatMap(x => x.fields).find(x => x.id.toString() == key) as ReferenceTypeFieldInSection).multipleSelect
})
});
@ -309,7 +310,9 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
fieldId: Guid;
fieldValue: string;
references: DmpReferencePersist[] = [];
reference: DmpReferencePersist;
isRequired: boolean = false;
multipleSelect: boolean = false;
category: DmpBlueprintFieldCategory;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
@ -321,7 +324,7 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
fromModel(item: DmpBlueprintValue, dmpReferences: DmpReference[], field: FieldInSection): DmpBlueprintValueEditorModel {
this.fieldId = item.fieldId;
this.fieldValue = item.fieldValue;
this.references = dmpReferences?.filter(x => x.data.blueprintFieldId == this.fieldId && x.isActive == IsActive.Active).map(x => {
const references = dmpReferences?.filter(x => x.data.blueprintFieldId == this.fieldId && x.isActive == IsActive.Active).map(x => {
return {
data: x.data,
reference: {
@ -337,7 +340,18 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
}
}
});
if ((field as ReferenceTypeFieldInSection).multipleSelect) {
this.references = references;
this.multipleSelect = true;
} else {
if (references?.length == 1) this.reference = references[0];
if (references?.length > 1) {
console.error("multiple references on single reference field: " + references);
this.reference = references[0];
}
this.multipleSelect = false;
}
this.isRequired = field.required;
if (this.isRequired) console.log(field);
this.category = field.category;
@ -355,7 +369,8 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
context = DmpBlueprintValueEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath,
isRequired: this.isRequired
isRequired: this.isRequired,
multipleSelect: this.multipleSelect
});
}
@ -365,6 +380,7 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
switch (this.category) {
case DmpBlueprintFieldCategory.ReferenceType:
formGroup.addControl('references', new FormControl({ value: this.references?.map(x => x.reference), disabled: disabled }, context.getValidation('references').validators));
formGroup.addControl('reference', new FormControl({ value: this.reference?.reference, disabled: disabled }, context.getValidation('reference').validators));
break;
case DmpBlueprintFieldCategory.System:
case DmpBlueprintFieldCategory.Extra:
@ -378,6 +394,7 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel,
multipleSelect: boolean,
isRequired: boolean,
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
@ -386,7 +403,8 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'fieldId', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}fieldId`)] });
baseValidationArray.push({ key: 'fieldValue', validators: params.isRequired ? [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}fieldValue`)] : [BackendErrorValidator(validationErrorModel, `${rootPath}fieldValue`)] });
baseValidationArray.push({ key: 'references', validators: params.isRequired ? [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}references`)] : [BackendErrorValidator(validationErrorModel, `${rootPath}references`)] });
baseValidationArray.push({ key: 'references', validators: params.isRequired && params.multipleSelect ? [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}references`)] : [BackendErrorValidator(validationErrorModel, `${rootPath}references`)] });
baseValidationArray.push({ key: 'reference', validators: params.isRequired && !params.multipleSelect ? [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}reference`)] : [BackendErrorValidator(validationErrorModel, `${rootPath}reference`)] });
baseContext.validation = baseValidationArray;
return baseContext;
@ -397,13 +415,15 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
validationErrorModel: ValidationErrorModel,
rootPath: string,
isRequired: boolean
multipleSelect: boolean
}): void {
const { formGroup, rootPath, validationErrorModel } = params;
const context = DmpBlueprintValueEditorModel.createValidationContext({
rootPath,
validationErrorModel,
isRequired: params.isRequired
isRequired: params.isRequired,
multipleSelect: params.multipleSelect
});
['fieldId', 'fieldValue', 'references'].forEach(keyField => {
@ -710,4 +730,4 @@ export class DmpDescriptionTemplateEditorModel implements DmpDescriptionTemplate
control?.addValidators(context.getValidation(keyField).validators);
})
}
}
}

View File

@ -121,6 +121,7 @@ export class DmpEditorResolver extends BaseEditorResolver {
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.referenceType), nameof<ReferenceType>(x => x.id)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.referenceType), nameof<ReferenceType>(x => x.name)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.referenceType), nameof<ReferenceType>(x => x.code)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.multipleSelect)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.referenceType), nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x=> x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x=> x.referenceTypeDependencies) , nameof<ReferenceType>(x => x.id)].join('.'),
]
}

View File

@ -80,7 +80,7 @@
</mat-form-field>
</div>
<div class="col-12 col-xl-auto">
<button mat-icon-button class="action-list-icon" matTooltip="{{'DMP-EDITOR.ACTIONS1.REMOVE-USER' | translate}}" (click)="removeUser(userIndex)" [disabled]="form.disabled">
<button mat-icon-button class="action-list-icon" matTooltip="{{'DMP-EDITOR.ACTIONS.REMOVE-USER' | translate}}" (click)="removeUser(userIndex)" [disabled]="form.disabled">
<mat-icon>delete</mat-icon>
</button>
</div>

View File

@ -28,7 +28,7 @@
<a class="d-flex justify-content-center pb-3 show-more" *ngIf="dmp.descriptions?.length > 3" [routerLink]="isPublic ? ['/explore-plans/overview/public/' + dmp.id] : ['/plans/overview/' + dmp.id]"><u>{{'GENERAL.ACTIONS.SHOW-MORE' | translate}}</u></a>
</a>
<div class="dmp-card-actions">
<a class="col-auto border-right pointer" *ngIf="canExportDmp(dmp) && fileTransformerService.availableFormats.length > 0" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DMP-LISTING.ACTIONS.EXPORT' | translate}}</a>
<a class="col-auto border-right pointer" *ngIf="canExportDmp(dmp) && fileTransformerService.availableFormatsFor(fileTransformerEntityTypeEnum.Dmp).length > 0" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DMP-LISTING.ACTIONS.EXPORT' | translate}}</a>
<a class="col-auto border-right pointer" *ngIf="isDraftDmp(dmp) && canEditDmp(dmp)" [routerLink]="['/plans/edit/' + dmp.id]" target="_blank"><span class="material-icons icon-align">add</span>{{'DMP-LISTING.ACTIONS.ADD-DESCRIPTION-SHORT' | translate}}</a>
<a class="col-auto border-right pointer" *ngIf="canInviteDmpUsers(dmp)" (click)="inviteToDmp()"><span class="material-icons icon-align pr-2">group_add</span>{{'DMP-LISTING.ACTIONS.INVITE-SHORT' | translate}}</a>
<a class="col-auto border-right pointer" *ngIf="canCloneDmp(dmp)" (click)="cloneClicked()"><span class="material-icons icon-align pr-2">filter_none</span>{{'DMP-LISTING.ACTIONS.CLONE' | translate}}</a>
@ -38,7 +38,7 @@
<a class="col-auto pointer" *ngIf="isAuthenticated()" [matMenuTriggerFor]="actionsMenu"><span class="material-icons icon-align pl-2">more_horiz</span></a>
</div>
<mat-menu #exportMenu="matMenu" xPosition="before">
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormats' (click)="fileTransformerService.exportDmp(dmp.id, fileTransformer.repositoryId, fileTransformer.format)">
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormatsFor(fileTransformerEntityTypeEnum.Dmp)' (click)="fileTransformerService.exportDmp(dmp.id, fileTransformer.repositoryId, fileTransformer.format)">
<i class="fa pr-2" [ngClass]="fileTransformer.hasLogo ? fileTransformer.icon : 'fa-file-o'"></i>
<span>{{'GENERAL.FILE-TRANSFORMER.' + fileTransformer.format.toUpperCase() | translate}}</span>
</button>

View File

@ -27,6 +27,7 @@ import { CloneDmpDialogComponent } from '../../clone-dialog/dmp-clone-dialog.com
import { DmpInvitationDialogComponent } from '../../invitation/dialog/dmp-invitation-dialog.component';
import { NewVersionDmpDialogComponent } from '../../new-version-dialog/dmp-new-version-dialog.component';
import { AppPermission } from '@app/core/common/enum/permission.enum';
import { FileTransformerEntityType } from '@app/core/common/enum/file-transformer-entity-type';
@Component({
selector: 'app-dmp-listing-item-component',
@ -44,6 +45,7 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
isFinalized: boolean;
isPublished: boolean;
dmpStatusEnum = DmpStatus;
fileTransformerEntityTypeEnum = FileTransformerEntityType;
constructor(
private router: Router,

View File

@ -196,7 +196,7 @@
</div>
</div>
</ng-container>
<ng-container *ngIf="canExportDmp() && fileTransformerService.availableFormats.length > 0">
<ng-container *ngIf="canExportDmp() && fileTransformerService.availableFormatsFor(fileTransformerEntityTypeEnum.Dmp).length > 0">
<div class="row mb-3 align-items-center">
<div class="col-auto pr-0">
<button mat-mini-fab class="frame-btn" [matMenuTriggerFor]="exportMenu">
@ -221,7 +221,7 @@
</div>
</ng-container>
<mat-menu #exportMenu="matMenu" xPosition="before">
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormats' (click)="fileTransformerService.exportDmp(dmp.id, fileTransformer.repositoryId, fileTransformer.format)">
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormatsFor(fileTransformerEntityTypeEnum.Dmp)' (click)="fileTransformerService.exportDmp(dmp.id, fileTransformer.repositoryId, fileTransformer.format)">
<i class="fa pr-2" [ngClass]="fileTransformer.icon ? fileTransformer.icon : 'fa-file-o'"></i>
<span>{{'GENERAL.FILE-TRANSFORMER.' + fileTransformer?.format?.toUpperCase() | translate}}</span>
</button>

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