add boolean value to description
This commit is contained in:
parent
5f796edc62
commit
2d2750c44c
|
@ -47,7 +47,7 @@ public enum FieldType implements DatabaseEnum<String> {
|
|||
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
return value;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
private static final Map<String, FieldType> map = EnumUtils.getEnumValueMap(FieldType.class);
|
||||
|
@ -62,8 +62,8 @@ public enum FieldType implements DatabaseEnum<String> {
|
|||
}
|
||||
|
||||
public static boolean isTextType(FieldType fieldType){
|
||||
return fieldType.equals(FieldType.FREE_TEXT) || fieldType.equals(FieldType.CHECK_BOX) || fieldType.equals(FieldType.TEXT_AREA) ||
|
||||
fieldType.equals(FieldType.RICH_TEXT_AREA) || fieldType.equals(FieldType.UPLOAD) || fieldType.equals(FieldType.BOOLEAN_DECISION) ||
|
||||
return fieldType.equals(FieldType.FREE_TEXT) || fieldType.equals(FieldType.TEXT_AREA) ||
|
||||
fieldType.equals(FieldType.RICH_TEXT_AREA) || fieldType.equals(FieldType.UPLOAD) ||
|
||||
fieldType.equals(FieldType.RADIO_BOX);
|
||||
}
|
||||
|
||||
|
@ -75,6 +75,9 @@ public enum FieldType implements DatabaseEnum<String> {
|
|||
public static boolean isDateType(FieldType fieldType){
|
||||
return fieldType.equals(FieldType.DATE_PICKER);
|
||||
}
|
||||
public static boolean isBooleanType(FieldType fieldType){
|
||||
return fieldType.equals(FieldType.BOOLEAN_DECISION) || fieldType.equals(FieldType.CHECK_BOX);
|
||||
}
|
||||
|
||||
public static boolean isExternalIdentifierType(FieldType fieldType){
|
||||
return fieldType.equals(FieldType.VALIDATION) || fieldType.equals(FieldType.DATASET_IDENTIFIER) ;
|
||||
|
|
|
@ -8,6 +8,7 @@ public class FieldEntity {
|
|||
private String textValue;
|
||||
private List<String> textListValue;
|
||||
private Instant dateValue;
|
||||
private Boolean booleanValue;
|
||||
private ExternalIdentifierEntity externalIdentifier;
|
||||
|
||||
public String getTextValue() {
|
||||
|
@ -41,4 +42,12 @@ public class FieldEntity {
|
|||
public void setExternalIdentifier(ExternalIdentifierEntity externalIdentifier) {
|
||||
this.externalIdentifier = externalIdentifier;
|
||||
}
|
||||
|
||||
public Boolean getBooleanValue() {
|
||||
return this.booleanValue;
|
||||
}
|
||||
|
||||
public void setBooleanValue(Boolean booleanValue) {
|
||||
this.booleanValue = booleanValue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@ public class DescriptionFieldImportExport {
|
|||
private List<String> textListValue;
|
||||
@XmlElement(name = "dateValue")
|
||||
private Instant dateValue;
|
||||
|
||||
@XmlElement(name = "booleanValue")
|
||||
private Boolean booleanValue;
|
||||
@XmlElement(name = "externalIdentifier")
|
||||
private DescriptionExternalIdentifierImportExport externalIdentifier;
|
||||
|
||||
|
@ -56,6 +59,14 @@ public class DescriptionFieldImportExport {
|
|||
this.dateValue = dateValue;
|
||||
}
|
||||
|
||||
public Boolean getBooleanValue() {
|
||||
return this.booleanValue;
|
||||
}
|
||||
|
||||
public void setBooleanValue(Boolean booleanValue) {
|
||||
this.booleanValue = booleanValue;
|
||||
}
|
||||
|
||||
public DescriptionExternalIdentifierImportExport getExternalIdentifier() {
|
||||
return this.externalIdentifier;
|
||||
}
|
||||
|
|
|
@ -18,11 +18,14 @@ public class RuleEntity {
|
|||
|
||||
@XmlElement(name = "dateValue")
|
||||
private Instant dateValue;
|
||||
|
||||
@XmlElement(name = "booleanValue")
|
||||
private Boolean booleanValue;
|
||||
@XmlElement(name="externalIdentifier")
|
||||
private ExternalIdentifierEntity externalIdentifier;
|
||||
|
||||
public String getTarget() {
|
||||
return target;
|
||||
return this.target;
|
||||
}
|
||||
|
||||
public void setTarget(String target) {
|
||||
|
@ -30,7 +33,7 @@ public class RuleEntity {
|
|||
}
|
||||
|
||||
public String getTextValue() {
|
||||
return textValue;
|
||||
return this.textValue;
|
||||
}
|
||||
|
||||
public void setTextValue(String textValue) {
|
||||
|
@ -38,7 +41,7 @@ public class RuleEntity {
|
|||
}
|
||||
|
||||
public List<String> getTextListValue() {
|
||||
return textListValue;
|
||||
return this.textListValue;
|
||||
}
|
||||
|
||||
public void setTextListValue(List<String> textListValue) {
|
||||
|
@ -46,15 +49,23 @@ public class RuleEntity {
|
|||
}
|
||||
|
||||
public Instant getDateValue() {
|
||||
return dateValue;
|
||||
return this.dateValue;
|
||||
}
|
||||
|
||||
public void setDateValue(Instant dateValue) {
|
||||
this.dateValue = dateValue;
|
||||
}
|
||||
|
||||
public Boolean getBooleanValue() {
|
||||
return this.booleanValue;
|
||||
}
|
||||
|
||||
public void setBooleanValue(Boolean booleanValue) {
|
||||
this.booleanValue = booleanValue;
|
||||
}
|
||||
|
||||
public ExternalIdentifierEntity getExternalIdentifier() {
|
||||
return externalIdentifier;
|
||||
return this.externalIdentifier;
|
||||
}
|
||||
|
||||
public void setExternalIdentifier(ExternalIdentifierEntity externalIdentifier) {
|
||||
|
|
|
@ -18,12 +18,15 @@ public class DescriptionTemplateRuleImportExport {
|
|||
private List<String> textListValue;
|
||||
@XmlElement(name = "dateValue")
|
||||
private Instant dateValue;
|
||||
|
||||
@XmlElement(name = "booleanValue")
|
||||
private Boolean booleanValue;
|
||||
|
||||
@XmlElement(name="externalIdentifier")
|
||||
private DescriptionTemplateExternalIdentifierImportExport externalIdentifier;
|
||||
|
||||
public String getTarget() {
|
||||
return target;
|
||||
return this.target;
|
||||
}
|
||||
|
||||
public void setTarget(String target) {
|
||||
|
@ -31,7 +34,7 @@ public class DescriptionTemplateRuleImportExport {
|
|||
}
|
||||
|
||||
public String getTextValue() {
|
||||
return textValue;
|
||||
return this.textValue;
|
||||
}
|
||||
|
||||
public void setTextValue(String textValue) {
|
||||
|
@ -39,7 +42,7 @@ public class DescriptionTemplateRuleImportExport {
|
|||
}
|
||||
|
||||
public List<String> getTextListValue() {
|
||||
return textListValue;
|
||||
return this.textListValue;
|
||||
}
|
||||
|
||||
public void setTextListValue(List<String> textListValue) {
|
||||
|
@ -47,15 +50,23 @@ public class DescriptionTemplateRuleImportExport {
|
|||
}
|
||||
|
||||
public Instant getDateValue() {
|
||||
return dateValue;
|
||||
return this.dateValue;
|
||||
}
|
||||
|
||||
public void setDateValue(Instant dateValue) {
|
||||
this.dateValue = dateValue;
|
||||
}
|
||||
|
||||
public Boolean getBooleanValue() {
|
||||
return this.booleanValue;
|
||||
}
|
||||
|
||||
public void setBooleanValue(Boolean booleanValue) {
|
||||
this.booleanValue = booleanValue;
|
||||
}
|
||||
|
||||
public DescriptionTemplateExternalIdentifierImportExport getExternalIdentifier() {
|
||||
return externalIdentifier;
|
||||
return this.externalIdentifier;
|
||||
}
|
||||
|
||||
public void setExternalIdentifier(DescriptionTemplateExternalIdentifierImportExport externalIdentifier) {
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.aspectj.lang.annotation.AfterReturning;
|
|||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.hibernate.Session;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
|
@ -14,6 +15,7 @@ import javax.management.InvalidApplicationException;
|
|||
|
||||
@Aspect
|
||||
@Component
|
||||
@ConditionalOnMissingBean(TenantScope.class)
|
||||
public class TenantFilterAspect {
|
||||
|
||||
private final TenantScope tenantScope;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package org.opencdmp.data.tenant;
|
||||
|
||||
import org.opencdmp.commons.scope.tenant.TenantScoped;
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
import org.hibernate.annotations.Filter;
|
||||
import org.hibernate.annotations.FilterDef;
|
||||
import org.hibernate.annotations.ParamDef;
|
||||
|
||||
import org.opencdmp.commons.scope.tenant.TenantScoped;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
|
@ -14,11 +14,11 @@ import java.util.UUID;
|
|||
//@Getter
|
||||
//@Setter
|
||||
//@NoArgsConstructor
|
||||
@FilterDef(name = TenantScopedBaseEntity.TENANT_FILTER, parameters = {@ParamDef(name = TenantScopedBaseEntity.TENANT_FILTER_TENANT_PARAM, type = String.class)})
|
||||
@FilterDef(name = TenantScopedBaseEntity.TENANT_FILTER, parameters = @ParamDef(name = TenantScopedBaseEntity.TENANT_FILTER_TENANT_PARAM, type = String.class))
|
||||
@FilterDef(name = TenantScopedBaseEntity.DEFAULT_TENANT_FILTER)
|
||||
@Filter(name = TenantScopedBaseEntity.DEFAULT_TENANT_FILTER, condition = "(tenant = tenant is null)")
|
||||
@Filter(name = TenantScopedBaseEntity.TENANT_FILTER, condition = "(tenant = (cast(:tenantId as uuid)) or tenant is null)")
|
||||
@EntityListeners(TenantListener.class)
|
||||
//@EntityListeners(TenantListener.class)
|
||||
public abstract class TenantScopedBaseEntity implements TenantScoped, Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final String TENANT_FILTER = "tenantFilter";
|
||||
|
@ -29,7 +29,7 @@ public abstract class TenantScopedBaseEntity implements TenantScoped, Serializab
|
|||
private UUID tenantId;
|
||||
public static final String _tenantId = "tenantId";
|
||||
public UUID getTenantId() {
|
||||
return tenantId;
|
||||
return this.tenantId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
package org.opencdmp.model.builder.commonmodels.description;
|
||||
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import gr.cite.tools.validation.ValidatorFactory;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.opencdmp.authorization.AuthorizationFlags;
|
||||
import org.opencdmp.commonmodels.models.FileEnvelopeModel;
|
||||
import org.opencdmp.commonmodels.models.description.FieldModel;
|
||||
|
@ -21,13 +28,6 @@ import org.opencdmp.query.ReferenceQuery;
|
|||
import org.opencdmp.query.StorageFileQuery;
|
||||
import org.opencdmp.service.storage.StorageFileProperties;
|
||||
import org.opencdmp.service.storage.StorageFileService;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import gr.cite.tools.validation.ValidatorFactory;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
|
@ -41,7 +41,7 @@ import java.util.*;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
@Component("commonmodels.description")
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class FieldCommonModelBuilder extends BaseCommonModelBuilder<FieldModel, FieldEntity> {
|
||||
private final BuilderFactory builderFactory;
|
||||
private final QueryFactory queryFactory;
|
||||
|
@ -91,8 +91,9 @@ public class FieldCommonModelBuilder extends BaseCommonModelBuilder<FieldModel,
|
|||
List<CommonModelBuilderItemResponse<FieldModel, FieldEntity>> models = new ArrayList<>();
|
||||
for (FieldEntity d : data) {
|
||||
FieldModel m = new FieldModel();
|
||||
if (this.fieldEntity != null) m.setId(fieldEntity.getId());
|
||||
if (this.fieldEntity != null) m.setId(this.fieldEntity.getId());
|
||||
if (FieldType.isDateType(fieldType)) m.setDateValue(d.getDateValue());
|
||||
//if (FieldType.isBooleanType(fieldType)) m.setDateValue(d.getBooleanValue()); //TODO: Common field
|
||||
if (FieldType.isTextType(fieldType)) m.setTextValue(d.getTextValue());
|
||||
if (FieldType.isTextListType(fieldType)) m.setTextListValue(d.getTextListValue());
|
||||
if (FieldType.isReferenceType(fieldType) && referenceItemsMap != null && d.getTextListValue() != null && !d.getTextListValue().isEmpty()) {
|
||||
|
@ -110,13 +111,13 @@ public class FieldCommonModelBuilder extends BaseCommonModelBuilder<FieldModel,
|
|||
fileEnvelopeModel.setFile(bytes);
|
||||
fileEnvelopeModel.setFilename(storageFile.getName() + (storageFile.getExtension().startsWith(".") ? "" : ".") + storageFile.getExtension());
|
||||
fileEnvelopeModel.setMimeType(storageFile.getMimeType());
|
||||
if (!useSharedStorage){
|
||||
if (!this.useSharedStorage){
|
||||
fileEnvelopeModel.setFile(bytes);
|
||||
} else {
|
||||
fileEnvelopeModel.setFileRef(this.addFileToSharedStorage(bytes, storageFile));
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.error(e.getMessage());
|
||||
this.logger.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
if (d.getExternalIdentifier() != null && FieldType.isExternalIdentifierType(fieldType)) m.setExternalIdentifier(this.builderFactory.builder(ExternalIdentifierCommonModelBuilder.class).authorize(this.authorize).build(d.getExternalIdentifier()));
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
package org.opencdmp.model.builder.descriptionpropertiesdefinition;
|
||||
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.DataLogEntry;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.opencdmp.authorization.AuthorizationFlags;
|
||||
import org.opencdmp.commons.enums.FieldType;
|
||||
import org.opencdmp.commons.types.description.FieldEntity;
|
||||
|
@ -11,13 +18,6 @@ import org.opencdmp.model.builder.BaseBuilder;
|
|||
import org.opencdmp.model.builder.ReferenceBuilder;
|
||||
import org.opencdmp.model.descriptionproperties.Field;
|
||||
import org.opencdmp.query.ReferenceQuery;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.DataLogEntry;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
|
@ -28,7 +28,7 @@ import java.util.*;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
@Component("description.FieldBuilder")
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class FieldBuilder extends BaseBuilder<Field, FieldEntity> {
|
||||
private final BuilderFactory builderFactory;
|
||||
private final QueryFactory queryFactory;
|
||||
|
@ -71,6 +71,7 @@ public class FieldBuilder extends BaseBuilder<Field, FieldEntity> {
|
|||
for (FieldEntity d : data) {
|
||||
Field m = new Field();
|
||||
if (fields.hasField(this.asIndexer(Field._dateValue)) && FieldType.isDateType(fieldType)) m.setDateValue(d.getDateValue());
|
||||
if (fields.hasField(this.asIndexer(Field._booleanValue)) && FieldType.isBooleanType(fieldType)) m.setBooleanValue(d.getBooleanValue());
|
||||
if (fields.hasField(this.asIndexer(Field._textValue)) && FieldType.isTextType(fieldType)) m.setTextValue(d.getTextValue());
|
||||
if (fields.hasField(this.asIndexer(Field._textListValue)) && FieldType.isTextListType(fieldType)) {
|
||||
boolean isMultiSelect = true;
|
||||
|
@ -127,7 +128,7 @@ public class FieldBuilder extends BaseBuilder<Field, FieldEntity> {
|
|||
}
|
||||
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Reference._id);
|
||||
ReferenceQuery q = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).ids(ids);
|
||||
itemMap = this.builderFactory.builder(ReferenceBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Reference::getId);;
|
||||
itemMap = this.builderFactory.builder(ReferenceBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Reference::getId);
|
||||
}
|
||||
|
||||
if (!fields.hasField(Reference._id)) {
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
package org.opencdmp.model.builder.descriptiontemplatedefinition;
|
||||
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.DataLogEntry;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.opencdmp.authorization.AuthorizationFlags;
|
||||
import org.opencdmp.commons.enums.FieldType;
|
||||
import org.opencdmp.commons.types.descriptiontemplate.RuleEntity;
|
||||
|
@ -9,13 +16,6 @@ import org.opencdmp.model.builder.BaseBuilder;
|
|||
import org.opencdmp.model.builder.ReferenceBuilder;
|
||||
import org.opencdmp.model.descriptiontemplatedefinition.Rule;
|
||||
import org.opencdmp.query.ReferenceQuery;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.DataLogEntry;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
|
@ -26,7 +26,7 @@ import java.util.*;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class RuleBuilder extends BaseBuilder<Rule, RuleEntity> {
|
||||
|
||||
private final BuilderFactory builderFactory;
|
||||
|
@ -70,6 +70,7 @@ public class RuleBuilder extends BaseBuilder<Rule, RuleEntity> {
|
|||
Rule m = new Rule();
|
||||
if (fields.hasField(this.asIndexer(Rule._target))) m.setTarget(d.getTarget());
|
||||
if (fields.hasField(this.asIndexer(Rule._dateValue)) && FieldType.isDateType(fieldType)) m.setDateValue(d.getDateValue());
|
||||
if (fields.hasField(this.asIndexer(Rule._booleanValue)) && FieldType.isBooleanType(fieldType)) m.setBooleanValue(d.getBooleanValue());
|
||||
if (fields.hasField(this.asIndexer(Rule._textValue)) && FieldType.isTextType(fieldType)) m.setTextValue(d.getTextValue());
|
||||
if (fields.hasField(this.asIndexer(Rule._textListValue)) && FieldType.isTextListType(fieldType)) m.setTextListValue(d.getTextListValue());
|
||||
if (!referenceFields.isEmpty() && FieldType.isReferenceType(fieldType) && referenceItemsMap != null && d.getTextListValue() != null && !d.getTextListValue().isEmpty()) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.opencdmp.model.descriptionproperties;
|
||||
|
||||
|
||||
import org.opencdmp.commons.enums.FieldType;
|
||||
import org.opencdmp.model.Reference;
|
||||
|
||||
import java.time.Instant;
|
||||
|
@ -18,6 +17,9 @@ public class Field {
|
|||
private Instant dateValue;
|
||||
public static final String _dateValue = "dateValue";
|
||||
|
||||
private Boolean booleanValue;
|
||||
public static final String _booleanValue = "booleanValue";
|
||||
|
||||
private List<Reference> references;
|
||||
public static final String _references = "references";
|
||||
|
||||
|
@ -25,7 +27,7 @@ public class Field {
|
|||
public static final String _externalIdentifier = "externalIdentifier";
|
||||
|
||||
public String getTextValue() {
|
||||
return textValue;
|
||||
return this.textValue;
|
||||
}
|
||||
|
||||
public void setTextValue(String textValue) {
|
||||
|
@ -33,7 +35,7 @@ public class Field {
|
|||
}
|
||||
|
||||
public List<String> getTextListValue() {
|
||||
return textListValue;
|
||||
return this.textListValue;
|
||||
}
|
||||
|
||||
public void setTextListValue(List<String> textListValue) {
|
||||
|
@ -41,15 +43,23 @@ public class Field {
|
|||
}
|
||||
|
||||
public Instant getDateValue() {
|
||||
return dateValue;
|
||||
return this.dateValue;
|
||||
}
|
||||
|
||||
public void setDateValue(Instant dateValue) {
|
||||
this.dateValue = dateValue;
|
||||
}
|
||||
|
||||
public Boolean getBooleanValue() {
|
||||
return this.booleanValue;
|
||||
}
|
||||
|
||||
public void setBooleanValue(Boolean booleanValue) {
|
||||
this.booleanValue = booleanValue;
|
||||
}
|
||||
|
||||
public List<Reference> getReferences() {
|
||||
return references;
|
||||
return this.references;
|
||||
}
|
||||
|
||||
public void setReferences(List<Reference> references) {
|
||||
|
@ -57,7 +67,7 @@ public class Field {
|
|||
}
|
||||
|
||||
public ExternalIdentifier getExternalIdentifier() {
|
||||
return externalIdentifier;
|
||||
return this.externalIdentifier;
|
||||
}
|
||||
|
||||
public void setExternalIdentifier(ExternalIdentifier externalIdentifier) {
|
||||
|
|
|
@ -20,6 +20,9 @@ public class Rule {
|
|||
private Instant dateValue;
|
||||
public static final String _dateValue = "dateValue";
|
||||
|
||||
private Boolean booleanValue;
|
||||
public static final String _booleanValue = "booleanValue";
|
||||
|
||||
private List<Reference> references;
|
||||
public static final String _references = "references";
|
||||
|
||||
|
@ -28,7 +31,7 @@ public class Rule {
|
|||
|
||||
|
||||
public String getTarget() {
|
||||
return target;
|
||||
return this.target;
|
||||
}
|
||||
|
||||
public void setTarget(String target) {
|
||||
|
@ -36,7 +39,7 @@ public class Rule {
|
|||
}
|
||||
|
||||
public String getTextValue() {
|
||||
return textValue;
|
||||
return this.textValue;
|
||||
}
|
||||
|
||||
public void setTextValue(String textValue) {
|
||||
|
@ -44,7 +47,7 @@ public class Rule {
|
|||
}
|
||||
|
||||
public List<String> getTextListValue() {
|
||||
return textListValue;
|
||||
return this.textListValue;
|
||||
}
|
||||
|
||||
public void setTextListValue(List<String> textListValue) {
|
||||
|
@ -52,15 +55,23 @@ public class Rule {
|
|||
}
|
||||
|
||||
public Instant getDateValue() {
|
||||
return dateValue;
|
||||
return this.dateValue;
|
||||
}
|
||||
|
||||
public void setDateValue(Instant dateValue) {
|
||||
this.dateValue = dateValue;
|
||||
}
|
||||
|
||||
public Boolean getBooleanValue() {
|
||||
return this.booleanValue;
|
||||
}
|
||||
|
||||
public void setBooleanValue(Boolean booleanValue) {
|
||||
this.booleanValue = booleanValue;
|
||||
}
|
||||
|
||||
public List<Reference> getReferences() {
|
||||
return references;
|
||||
return this.references;
|
||||
}
|
||||
|
||||
public void setReferences(List<Reference> references) {
|
||||
|
@ -68,7 +79,7 @@ public class Rule {
|
|||
}
|
||||
|
||||
public ExternalIdentifier getExternalIdentifier() {
|
||||
return externalIdentifier;
|
||||
return this.externalIdentifier;
|
||||
}
|
||||
|
||||
public void setExternalIdentifier(ExternalIdentifier externalIdentifier) {
|
||||
|
|
|
@ -3,9 +3,9 @@ package org.opencdmp.model.mapper.publicapi;
|
|||
import org.opencdmp.commons.types.descriptiontemplate.ExternalIdentifierEntity;
|
||||
import org.opencdmp.commons.types.descriptiontemplate.RuleEntity;
|
||||
import org.opencdmp.model.publicapi.datasetwizard.DefaultValueEntity;
|
||||
import org.opencdmp.model.publicapi.datasetwizard.Field;
|
||||
import org.opencdmp.model.publicapi.datasetwizard.FieldDescriptionEntity;
|
||||
import org.opencdmp.model.publicapi.datasetwizard.VisibilityEntity;
|
||||
import org.opencdmp.model.publicapi.datasetwizard.Field;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
|
@ -29,7 +29,7 @@ public class DescriptionFieldToDatasetFieldMapper {
|
|||
visibilityEntity.setRules(field.getVisibilityRules().stream().map(x -> {
|
||||
RuleEntity ruleEntity = new RuleEntity();
|
||||
ruleEntity.setDateValue(x.getDateValue());
|
||||
ruleEntity.setTextValue(x.getTextValue());
|
||||
ruleEntity.setBooleanValue(x.getBooleanValue());
|
||||
ruleEntity.setTextListValue(x.getTextListValue());
|
||||
if (x.getExternalIdentifier() != null){
|
||||
ruleEntity.setExternalIdentifier(new ExternalIdentifierEntity());
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
package org.opencdmp.model.persist.descriptionproperties;
|
||||
|
||||
import gr.cite.tools.validation.ValidatorFactory;
|
||||
import gr.cite.tools.validation.specification.Specification;
|
||||
import org.opencdmp.commons.enums.DescriptionStatus;
|
||||
import org.opencdmp.commons.enums.FieldType;
|
||||
import org.opencdmp.commons.enums.FieldValidationType;
|
||||
import org.opencdmp.commons.types.descriptiontemplate.FieldEntity;
|
||||
import org.opencdmp.commons.types.descriptiontemplate.RuleEntity;
|
||||
import org.opencdmp.commons.validation.BaseValidator;
|
||||
import org.opencdmp.model.persist.ReferencePersist;
|
||||
import org.opencdmp.service.visibility.VisibilityService;
|
||||
import gr.cite.tools.validation.ValidatorFactory;
|
||||
import gr.cite.tools.validation.specification.Specification;
|
||||
import org.opencdmp.convention.ConventionService;
|
||||
import org.opencdmp.errorcode.ErrorThesaurusProperties;
|
||||
import org.opencdmp.model.persist.ReferencePersist;
|
||||
import org.opencdmp.service.visibility.VisibilityService;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -30,6 +29,9 @@ public class FieldPersist {
|
|||
|
||||
private Instant dateValue;
|
||||
public static final String _dateValue = "dateValue";
|
||||
|
||||
private Boolean booleanValue;
|
||||
public static final String _booleanValue = "booleanValue";
|
||||
|
||||
private List<ReferencePersist> references;
|
||||
public static final String _references = "references";
|
||||
|
@ -41,7 +43,7 @@ public class FieldPersist {
|
|||
public static final String _externalIdentifier = "externalIdentifier";
|
||||
|
||||
public String getTextValue() {
|
||||
return textValue;
|
||||
return this.textValue;
|
||||
}
|
||||
|
||||
public void setTextValue(String textValue) {
|
||||
|
@ -49,7 +51,7 @@ public class FieldPersist {
|
|||
}
|
||||
|
||||
public List<String> getTextListValue() {
|
||||
return textListValue;
|
||||
return this.textListValue;
|
||||
}
|
||||
|
||||
public void setTextListValue(List<String> textListValue) {
|
||||
|
@ -57,15 +59,23 @@ public class FieldPersist {
|
|||
}
|
||||
|
||||
public Instant getDateValue() {
|
||||
return dateValue;
|
||||
return this.dateValue;
|
||||
}
|
||||
|
||||
public void setDateValue(Instant dateValue) {
|
||||
this.dateValue = dateValue;
|
||||
}
|
||||
|
||||
public Boolean getBooleanValue() {
|
||||
return this.booleanValue;
|
||||
}
|
||||
|
||||
public void setBooleanValue(Boolean booleanValue) {
|
||||
this.booleanValue = booleanValue;
|
||||
}
|
||||
|
||||
public List<ReferencePersist> getReferences() {
|
||||
return references;
|
||||
return this.references;
|
||||
}
|
||||
|
||||
public void setReferences(List<ReferencePersist> references) {
|
||||
|
@ -73,7 +83,7 @@ public class FieldPersist {
|
|||
}
|
||||
|
||||
public ReferencePersist getReference() {
|
||||
return reference;
|
||||
return this.reference;
|
||||
}
|
||||
|
||||
public void setReference(ReferencePersist reference) {
|
||||
|
@ -81,7 +91,7 @@ public class FieldPersist {
|
|||
}
|
||||
|
||||
public ExternalIdentifierPersist getExternalIdentifier() {
|
||||
return externalIdentifier;
|
||||
return this.externalIdentifier;
|
||||
}
|
||||
|
||||
public void setExternalIdentifier(ExternalIdentifierPersist externalIdentifier) {
|
||||
|
@ -115,40 +125,40 @@ public class FieldPersist {
|
|||
protected List<Specification> specifications(FieldPersist item) {
|
||||
FieldType fieldType = this.fieldEntity != null && this.fieldEntity.getData() != null ? this.fieldEntity.getData().getFieldType() : FieldType.FREE_TEXT;
|
||||
boolean required = this.fieldEntity != null && this.fieldEntity.getValidations() != null ? this.fieldEntity.getValidations().contains(FieldValidationType.Required) : false;
|
||||
boolean isVisible = this.visibilityService.isVisible(fieldEntity.getId(), ordinal);
|
||||
boolean isVisible = this.fieldEntity != null ? this.visibilityService.isVisible(this.fieldEntity.getId(), this.ordinal) : true;
|
||||
return Arrays.asList(
|
||||
this.spec()
|
||||
.iff(()-> FieldType.isTextType(fieldType) && !fieldType.equals(FieldType.CHECK_BOX) && DescriptionStatus.Finalized.equals(this.status) && isVisible && required)
|
||||
.iff(()-> FieldType.isTextType(fieldType) && DescriptionStatus.Finalized.equals(this.status) && isVisible && required)
|
||||
.must(() -> !this.isEmpty(item.getTextValue()))
|
||||
.failOn(FieldPersist._textValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._textValue}, LocaleContextHolder.getLocale())),
|
||||
.failOn(FieldPersist._textValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._textValue}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(()-> FieldType.isDateType(fieldType) && DescriptionStatus.Finalized.equals(this.status) && isVisible && required)
|
||||
.must(() -> !this.isNull(item.getDateValue()))
|
||||
.failOn(FieldPersist._dateValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._dateValue}, LocaleContextHolder.getLocale())),
|
||||
.failOn(FieldPersist._dateValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._dateValue}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(()-> FieldType.isBooleanType(fieldType) && DescriptionStatus.Finalized.equals(this.status) && isVisible && required)
|
||||
.must(() -> !this.isNull(item.getBooleanValue()))
|
||||
.failOn(FieldPersist._booleanValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._booleanValue}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(()-> FieldType.isExternalIdentifierType(fieldType) && DescriptionStatus.Finalized.equals(this.status) && isVisible && required)
|
||||
.must(() -> !this.isNull(item.getExternalIdentifier()))
|
||||
.failOn(FieldPersist._externalIdentifier).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._externalIdentifier}, LocaleContextHolder.getLocale())),
|
||||
.failOn(FieldPersist._externalIdentifier).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._externalIdentifier}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(()-> FieldType.isTextListType(fieldType) && DescriptionStatus.Finalized.equals(this.status) && isVisible && required && !fieldType.equals(FieldType.TAGS))
|
||||
.must(() -> !this.isListNullOrEmpty(item.getTextListValue()) || !this.isEmpty(item.getTextValue()))
|
||||
.failOn(FieldPersist._textListValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._textListValue}, LocaleContextHolder.getLocale())),
|
||||
.failOn(FieldPersist._textListValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._textListValue}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(()-> fieldType.equals(FieldType.TAGS) && DescriptionStatus.Finalized.equals(this.status) && isVisible && required)
|
||||
.must(() -> !this.isListNullOrEmpty(item.getTextListValue()))
|
||||
.failOn(FieldPersist._textListValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._textListValue}, LocaleContextHolder.getLocale())),
|
||||
.failOn(FieldPersist._textListValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._textListValue}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(()-> FieldType.isReferenceType(fieldType) && DescriptionStatus.Finalized.equals(this.status) && isVisible && required)
|
||||
.must(() -> !this.isListNullOrEmpty(item.getReferences()) || !this.isNull(item.getReference()))
|
||||
.failOn(FieldPersist._textListValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._textListValue}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(()-> !this.isEmpty(item.getTextValue()) && (fieldType.equals(FieldType.CHECK_BOX) || fieldType.equals(FieldType.BOOLEAN_DECISION)))
|
||||
.must(() -> this.isBoolean(item.getTextValue()))
|
||||
.failOn(FieldPersist._textValue).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{FieldPersist._textValue}, LocaleContextHolder.getLocale())),
|
||||
.failOn(FieldPersist._textListValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._textListValue}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(()-> !this.isNull(item.getTextListValue()) && (fieldType.equals(FieldType.INTERNAL_ENTRIES_DMPS) || fieldType.equals(FieldType.INTERNAL_ENTRIES_DESCRIPTIONS)))
|
||||
.must(() -> item.getTextListValue().stream().allMatch(this::isUUID))
|
||||
.failOn(FieldPersist._textListValue).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{FieldPersist._textListValue}, LocaleContextHolder.getLocale())),
|
||||
.failOn(FieldPersist._textListValue).failWith(this.messageSource.getMessage("Validation_UnexpectedValue", new Object[]{FieldPersist._textListValue}, LocaleContextHolder.getLocale())),
|
||||
this.navSpec()
|
||||
.iff(() -> FieldType.isReferenceType(fieldType) && !this.isListNullOrEmpty(item.getReferences()))
|
||||
.on(FieldPersist._references)
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package org.opencdmp.model.persist.descriptiontemplatedefinition;
|
||||
|
||||
import org.opencdmp.commons.enums.FieldType;
|
||||
import org.opencdmp.commons.validation.BaseValidator;
|
||||
import org.opencdmp.model.persist.ReferencePersist;
|
||||
import org.opencdmp.model.persist.descriptionproperties.FieldPersist;
|
||||
import gr.cite.tools.validation.ValidatorFactory;
|
||||
import gr.cite.tools.validation.specification.Specification;
|
||||
import org.opencdmp.commons.enums.FieldType;
|
||||
import org.opencdmp.commons.validation.BaseValidator;
|
||||
import org.opencdmp.convention.ConventionService;
|
||||
import org.opencdmp.errorcode.ErrorThesaurusProperties;
|
||||
import org.opencdmp.model.persist.ReferencePersist;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
|
@ -20,7 +19,7 @@ import java.util.List;
|
|||
|
||||
public class RulePersist {
|
||||
|
||||
private String target = null;
|
||||
private String target;
|
||||
|
||||
public static final String _target = "target";
|
||||
|
||||
|
@ -33,6 +32,9 @@ public class RulePersist {
|
|||
private Instant dateValue;
|
||||
public static final String _dateValue = "dateValue";
|
||||
|
||||
private Boolean booleanValue;
|
||||
public static final String _booleanValue = "booleanValue";
|
||||
|
||||
private List<ReferencePersist> references;
|
||||
public static final String _references = "references";
|
||||
|
||||
|
@ -41,7 +43,7 @@ public class RulePersist {
|
|||
public static final String _externalIdentifier = "externalIdentifier";
|
||||
|
||||
public String getTarget() {
|
||||
return target;
|
||||
return this.target;
|
||||
}
|
||||
|
||||
public void setTarget(String target) {
|
||||
|
@ -49,7 +51,7 @@ public class RulePersist {
|
|||
}
|
||||
|
||||
public String getTextValue() {
|
||||
return textValue;
|
||||
return this.textValue;
|
||||
}
|
||||
|
||||
public void setTextValue(String textValue) {
|
||||
|
@ -57,7 +59,7 @@ public class RulePersist {
|
|||
}
|
||||
|
||||
public List<String> getTextListValue() {
|
||||
return textListValue;
|
||||
return this.textListValue;
|
||||
}
|
||||
|
||||
public void setTextListValue(List<String> textListValue) {
|
||||
|
@ -65,15 +67,23 @@ public class RulePersist {
|
|||
}
|
||||
|
||||
public Instant getDateValue() {
|
||||
return dateValue;
|
||||
return this.dateValue;
|
||||
}
|
||||
|
||||
public void setDateValue(Instant dateValue) {
|
||||
this.dateValue = dateValue;
|
||||
}
|
||||
|
||||
public Boolean getBooleanValue() {
|
||||
return this.booleanValue;
|
||||
}
|
||||
|
||||
public void setBooleanValue(Boolean booleanValue) {
|
||||
this.booleanValue = booleanValue;
|
||||
}
|
||||
|
||||
public List<ReferencePersist> getReferences() {
|
||||
return references;
|
||||
return this.references;
|
||||
}
|
||||
|
||||
public void setReferences(List<ReferencePersist> references) {
|
||||
|
@ -81,7 +91,7 @@ public class RulePersist {
|
|||
}
|
||||
|
||||
public ExternalIdentifierPersist getExternalIdentifier() {
|
||||
return externalIdentifier;
|
||||
return this.externalIdentifier;
|
||||
}
|
||||
|
||||
public void setExternalIdentifier(ExternalIdentifierPersist externalIdentifier) {
|
||||
|
@ -120,43 +130,43 @@ public class RulePersist {
|
|||
return Arrays.asList(
|
||||
this.spec()
|
||||
.must(() -> !this.isEmpty(item.getTarget()))
|
||||
.failOn(RulePersist._target).failWith(messageSource.getMessage("Validation_Required", new Object[]{RulePersist._target}, LocaleContextHolder.getLocale())),
|
||||
.failOn(RulePersist._target).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{RulePersist._target}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(()-> FieldType.isTextType(fieldType))
|
||||
.must(() -> !this.isEmpty(item.getTextValue()))
|
||||
.failOn(FieldPersist._textValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._textValue}, LocaleContextHolder.getLocale())),
|
||||
.failOn(RulePersist._textValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{RulePersist._textValue}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(()-> FieldType.isDateType(fieldType))
|
||||
.must(() -> !this.isNull(item.getDateValue()))
|
||||
.failOn(FieldPersist._dateValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._dateValue}, LocaleContextHolder.getLocale())),
|
||||
.failOn(RulePersist._dateValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{RulePersist._dateValue}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(()-> FieldType.isBooleanType(fieldType))
|
||||
.must(() -> !this.isNull(item.getBooleanValue()))
|
||||
.failOn(RulePersist._booleanValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{RulePersist._booleanValue}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(()-> FieldType.isExternalIdentifierType(fieldType))
|
||||
.must(() -> !this.isNull(item.getExternalIdentifier()))
|
||||
.failOn(FieldPersist._externalIdentifier).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._externalIdentifier}, LocaleContextHolder.getLocale())),
|
||||
.failOn(RulePersist._externalIdentifier).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{RulePersist._externalIdentifier}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(()-> FieldType.isTextListType(fieldType))
|
||||
.must(() -> !this.isNull(item.getTextListValue()))
|
||||
.failOn(FieldPersist._textListValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._textListValue}, LocaleContextHolder.getLocale())),
|
||||
.failOn(RulePersist._textListValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{RulePersist._textListValue}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(()-> FieldType.isReferenceType(fieldType))
|
||||
.must(() -> !this.isNull(item.getTextListValue()))
|
||||
.failOn(FieldPersist._textListValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._textListValue}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(()-> !this.isEmpty(item.getTextValue()) && fieldType.equals(FieldType.CHECK_BOX) || fieldType.equals(FieldType.BOOLEAN_DECISION) )
|
||||
.must(() -> this.isBoolean(item.getTextValue()))
|
||||
.failOn(FieldPersist._textValue).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{FieldPersist._textValue}, LocaleContextHolder.getLocale())),
|
||||
.failOn(RulePersist._textListValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{RulePersist._textListValue}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(()-> !this.isNull(item.getTextListValue()) && (fieldType.equals(FieldType.INTERNAL_ENTRIES_DMPS) || fieldType.equals(FieldType.INTERNAL_ENTRIES_DESCRIPTIONS)))
|
||||
.must(() -> item.getTextListValue().stream().allMatch(this::isUUID))
|
||||
.failOn(FieldPersist._textListValue).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{FieldPersist._textListValue}, LocaleContextHolder.getLocale())),
|
||||
.failOn(RulePersist._textListValue).failWith(this.messageSource.getMessage("Validation_UnexpectedValue", new Object[]{RulePersist._textListValue}, LocaleContextHolder.getLocale())),
|
||||
this.navSpec()
|
||||
.iff(() -> FieldType.isReferenceType(fieldType) && !this.isListNullOrEmpty(item.getReferences()))
|
||||
.on(FieldPersist._references)
|
||||
.on(RulePersist._references)
|
||||
.over(item.getReferences())
|
||||
.using((itm) -> this.validatorFactory.validator(ReferencePersist.ReferencePersistValidator.class)),
|
||||
this.refSpec()
|
||||
.iff(() -> FieldType.isExternalIdentifierType(fieldType) && !this.isNull(item.getExternalIdentifier()))
|
||||
.on(FieldPersist._externalIdentifier)
|
||||
.on(RulePersist._externalIdentifier)
|
||||
.over(item.getExternalIdentifier())
|
||||
.using(() -> this.validatorFactory.validator(ExternalIdentifierPersist.PersistValidator.class))
|
||||
);
|
||||
|
|
|
@ -9,7 +9,7 @@ public class Rule {
|
|||
private String type;
|
||||
|
||||
public String getSourceField() {
|
||||
return sourceField;
|
||||
return this.sourceField;
|
||||
}
|
||||
|
||||
public void setSourceField(String sourceField) {
|
||||
|
@ -17,7 +17,7 @@ public class Rule {
|
|||
}
|
||||
|
||||
public String getTargetField() {
|
||||
return targetField;
|
||||
return this.targetField;
|
||||
}
|
||||
|
||||
public void setTargetField(String targetField) {
|
||||
|
@ -25,7 +25,7 @@ public class Rule {
|
|||
}
|
||||
|
||||
public String getRequiredValue() {
|
||||
return requiredValue;
|
||||
return this.requiredValue;
|
||||
}
|
||||
|
||||
public void setRequiredValue(String requiredValue) {
|
||||
|
@ -33,7 +33,7 @@ public class Rule {
|
|||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
|
@ -45,6 +45,7 @@ public class Rule {
|
|||
//TODO
|
||||
if (rule.getTextValue() != null && !rule.getTextListValue().isEmpty()) this.requiredValue = rule.getTextValue();
|
||||
else if (rule.getDateValue() != null) this.requiredValue = rule.getDateValue().toString();
|
||||
else if (rule.getBooleanValue() != null) this.requiredValue = rule.getBooleanValue().toString();
|
||||
else if (rule.getTextListValue() != null) this.requiredValue = String.join(", ", rule.getTextListValue());
|
||||
else if (rule.getExternalIdentifier() != null) this.requiredValue = rule.getExternalIdentifier().getIdentifier();
|
||||
return this;
|
||||
|
|
|
@ -567,6 +567,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
|||
if (referenceIds != null) data.setTextListValue(referenceIds.stream().map(UUID::toString).toList());
|
||||
}
|
||||
else if (FieldType.isDateType(fieldType)) data.setDateValue(persist.getDateValue());
|
||||
else if (FieldType.isBooleanType(fieldType)) data.setBooleanValue(persist.getBooleanValue());
|
||||
else if (FieldType.isExternalIdentifierType(fieldType) && persist.getExternalIdentifier() != null) data.setExternalIdentifier(this.buildExternalIdentifierEntity(persist.getExternalIdentifier()));
|
||||
|
||||
return data;
|
||||
|
@ -1068,6 +1069,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
|||
if (FieldType.isTextType(fieldType)) persist.setTextValue(data.getTextValue());
|
||||
else if (FieldType.isTextListType(fieldType)) persist.setTextListValue(data.getTextListValue());
|
||||
else if (FieldType.isDateType(fieldType)) persist.setDateValue(persist.getDateValue());
|
||||
else if (FieldType.isBooleanType(fieldType)) persist.setBooleanValue(persist.getBooleanValue());
|
||||
else if (FieldType.isExternalIdentifierType(fieldType) && data.getExternalIdentifier() != null) persist.setExternalIdentifier(this.buildExternalIdentifierPersist(data.getExternalIdentifier()));
|
||||
else if (FieldType.isReferenceType(fieldType) && fieldEntity != null ) {
|
||||
if (!this.conventionService.isListNullOrEmpty(data.getTextListValue()) && !this.conventionService.isListNullOrEmpty(references)){
|
||||
|
@ -1254,6 +1256,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
|||
if (entity == null) return xml;
|
||||
|
||||
xml.setDateValue(entity.getDateValue());
|
||||
xml.setBooleanValue(entity.getBooleanValue());
|
||||
xml.setTextValue(entity.getTextValue());
|
||||
xml.setTextListValue(entity.getTextListValue());
|
||||
if (entity.getExternalIdentifier() != null) {
|
||||
|
|
|
@ -1,39 +1,6 @@
|
|||
package org.opencdmp.service.descriptiontemplate;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.opencdmp.authorization.AuthorizationFlags;
|
||||
import org.opencdmp.authorization.Permission;
|
||||
import org.opencdmp.commons.JsonHandlingService;
|
||||
import org.opencdmp.commons.XmlHandlingService;
|
||||
import org.opencdmp.commons.enums.*;
|
||||
import org.opencdmp.commons.scope.tenant.TenantScope;
|
||||
import org.opencdmp.commons.scope.user.UserScope;
|
||||
import org.opencdmp.commons.types.descriptiontemplate.*;
|
||||
import org.opencdmp.commons.types.descriptiontemplate.fielddata.BaseFieldDataEntity;
|
||||
import org.opencdmp.commons.types.descriptiontemplate.fielddata.ReferenceTypeDataEntity;
|
||||
import org.opencdmp.commons.types.descriptiontemplate.importexport.*;
|
||||
import org.opencdmp.commons.types.notification.*;
|
||||
import org.opencdmp.commons.notification.NotificationProperties;
|
||||
import org.opencdmp.convention.ConventionService;
|
||||
import org.opencdmp.data.*;
|
||||
import org.opencdmp.errorcode.ErrorThesaurusProperties;
|
||||
import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEvent;
|
||||
import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEventHandler;
|
||||
import org.opencdmp.model.*;
|
||||
import org.opencdmp.model.builder.DescriptionTemplateBuilder;
|
||||
import org.opencdmp.model.deleter.DescriptionTemplateDeleter;
|
||||
import org.opencdmp.model.deleter.UserDescriptionTemplateDeleter;
|
||||
import org.opencdmp.model.descriptiontemplatedefinition.Definition;
|
||||
import org.opencdmp.model.descriptiontemplatedefinition.Field;
|
||||
import org.opencdmp.model.descriptiontemplatedefinition.Page;
|
||||
import org.opencdmp.model.descriptiontemplatedefinition.Section;
|
||||
import org.opencdmp.model.persist.*;
|
||||
import org.opencdmp.model.persist.descriptiontemplatedefinition.*;
|
||||
import org.opencdmp.model.persist.descriptiontemplatedefinition.fielddata.BaseFieldDataPersist;
|
||||
import org.opencdmp.query.*;
|
||||
import org.opencdmp.service.fielddatahelper.FieldDataHelperService;
|
||||
import org.opencdmp.service.fielddatahelper.FieldDataHelperServiceProvider;
|
||||
import org.opencdmp.service.responseutils.ResponseUtilsService;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||
|
@ -51,6 +18,42 @@ import gr.cite.tools.validation.ValidatorFactory;
|
|||
import jakarta.xml.bind.JAXBException;
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.opencdmp.authorization.AuthorizationFlags;
|
||||
import org.opencdmp.authorization.Permission;
|
||||
import org.opencdmp.commons.JsonHandlingService;
|
||||
import org.opencdmp.commons.XmlHandlingService;
|
||||
import org.opencdmp.commons.enums.*;
|
||||
import org.opencdmp.commons.notification.NotificationProperties;
|
||||
import org.opencdmp.commons.scope.tenant.TenantScope;
|
||||
import org.opencdmp.commons.scope.user.UserScope;
|
||||
import org.opencdmp.commons.types.descriptiontemplate.*;
|
||||
import org.opencdmp.commons.types.descriptiontemplate.fielddata.BaseFieldDataEntity;
|
||||
import org.opencdmp.commons.types.descriptiontemplate.fielddata.ReferenceTypeDataEntity;
|
||||
import org.opencdmp.commons.types.descriptiontemplate.importexport.*;
|
||||
import org.opencdmp.commons.types.notification.*;
|
||||
import org.opencdmp.convention.ConventionService;
|
||||
import org.opencdmp.data.*;
|
||||
import org.opencdmp.errorcode.ErrorThesaurusProperties;
|
||||
import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEvent;
|
||||
import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEventHandler;
|
||||
import org.opencdmp.model.*;
|
||||
import org.opencdmp.model.builder.DescriptionTemplateBuilder;
|
||||
import org.opencdmp.model.deleter.DescriptionTemplateDeleter;
|
||||
import org.opencdmp.model.deleter.UserDescriptionTemplateDeleter;
|
||||
import org.opencdmp.model.descriptiontemplatedefinition.Definition;
|
||||
import org.opencdmp.model.descriptiontemplatedefinition.Field;
|
||||
import org.opencdmp.model.descriptiontemplatedefinition.Page;
|
||||
import org.opencdmp.model.descriptiontemplatedefinition.Section;
|
||||
import org.opencdmp.model.persist.DescriptionTemplatePersist;
|
||||
import org.opencdmp.model.persist.NewVersionDescriptionTemplatePersist;
|
||||
import org.opencdmp.model.persist.ReferencePersist;
|
||||
import org.opencdmp.model.persist.UserDescriptionTemplatePersist;
|
||||
import org.opencdmp.model.persist.descriptiontemplatedefinition.*;
|
||||
import org.opencdmp.model.persist.descriptiontemplatedefinition.fielddata.BaseFieldDataPersist;
|
||||
import org.opencdmp.query.*;
|
||||
import org.opencdmp.service.fielddatahelper.FieldDataHelperService;
|
||||
import org.opencdmp.service.fielddatahelper.FieldDataHelperServiceProvider;
|
||||
import org.opencdmp.service.responseutils.ResponseUtilsService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.MessageSource;
|
||||
|
@ -419,6 +422,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
|||
if (!referenceIds.isEmpty()) data.setTextListValue(referenceIds.stream().map(UUID::toString).toList());
|
||||
}
|
||||
else if (FieldType.isDateType(fieldType)) data.setDateValue(persist.getDateValue());
|
||||
else if (FieldType.isBooleanType(fieldType)) data.setBooleanValue(persist.getBooleanValue());
|
||||
else if (FieldType.isExternalIdentifierType(fieldType) && persist.getExternalIdentifier() != null) data.setExternalIdentifier(this.buildExternalIdentifierEntity(persist.getExternalIdentifier()));
|
||||
|
||||
return data;
|
||||
|
@ -864,6 +868,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
|||
RulePersist ruleEntity = new RulePersist();
|
||||
ruleEntity.setTarget(importExport.getTarget());
|
||||
ruleEntity.setDateValue(importExport.getDateValue());
|
||||
ruleEntity.setBooleanValue(importExport.getBooleanValue());
|
||||
//ruleEntity.setReferences(importExport.get()); //TODO
|
||||
ruleEntity.setTextValue(importExport.getTextValue());
|
||||
ruleEntity.setTextListValue(importExport.getTextListValue());
|
||||
|
@ -1016,6 +1021,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
|||
DescriptionTemplateRuleImportExport xml = new DescriptionTemplateRuleImportExport();
|
||||
xml.setTarget(entity.getTarget());
|
||||
xml.setDateValue(entity.getDateValue());
|
||||
xml.setBooleanValue(entity.getBooleanValue());
|
||||
xml.setTextListValue(entity.getTextListValue());
|
||||
xml.setTextValue(entity.getTextValue());
|
||||
if (entity.getExternalIdentifier() != null){
|
||||
|
|
|
@ -1,5 +1,20 @@
|
|||
package org.opencdmp.service.prefillingsource;
|
||||
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
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.BaseFieldSet;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import gr.cite.tools.logging.MapLogEntry;
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.opencdmp.authorization.AuthorizationFlags;
|
||||
import org.opencdmp.authorization.Permission;
|
||||
import org.opencdmp.commons.JsonHandlingService;
|
||||
|
@ -25,8 +40,8 @@ import org.opencdmp.model.builder.PrefillingSourceBuilder;
|
|||
import org.opencdmp.model.deleter.PrefillingSourceDeleter;
|
||||
import org.opencdmp.model.descriptionproperties.*;
|
||||
import org.opencdmp.model.descriptionreference.DescriptionReferenceData;
|
||||
import org.opencdmp.model.persist.PrefillingSearchRequest;
|
||||
import org.opencdmp.model.persist.DescriptionPrefillingRequest;
|
||||
import org.opencdmp.model.persist.PrefillingSearchRequest;
|
||||
import org.opencdmp.model.persist.PrefillingSourcePersist;
|
||||
import org.opencdmp.model.persist.externalfetcher.*;
|
||||
import org.opencdmp.model.persist.prefillingsourcedefinition.PrefillingSourceDefinitionFieldPersist;
|
||||
|
@ -40,21 +55,6 @@ import org.opencdmp.service.externalfetcher.ExternalFetcherService;
|
|||
import org.opencdmp.service.externalfetcher.criteria.ExternalReferenceCriteria;
|
||||
import org.opencdmp.service.externalfetcher.models.ExternalDataResult;
|
||||
import org.opencdmp.service.reference.ReferenceService;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
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.BaseFieldSet;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import gr.cite.tools.logging.MapLogEntry;
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
|
@ -123,7 +123,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
|
|||
if (isUpdate) {
|
||||
data = this.entityManager.find(PrefillingSourceEntity.class, model.getId());
|
||||
if (data == null)
|
||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
|
||||
} else {
|
||||
|
||||
|
@ -310,11 +310,11 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
|
|||
public List<Prefilling> searchPrefillings(PrefillingSearchRequest model) {
|
||||
PrefillingSourceEntity prefillingSourceEntity = this.queryFactory.query(PrefillingSourceQuery.class).ids(model.getPrefillingSourceId()).isActive(IsActive.Active).first();
|
||||
if (prefillingSourceEntity == null)
|
||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
|
||||
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()));
|
||||
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSourceDefinition.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
|
||||
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria();
|
||||
externalReferenceCriteria.setLike(model.getLike());
|
||||
|
@ -344,10 +344,10 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
|
|||
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()));
|
||||
if (prefillingSourceEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
|
||||
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()));
|
||||
if (prefillingSourceDefinition == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSourceDefinition.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
|
||||
Map<String, String> data = new HashMap<>();
|
||||
if (prefillingSourceDefinition.getGetConfiguration() != null){
|
||||
|
@ -362,14 +362,14 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
|
|||
}
|
||||
|
||||
DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getDescriptionTemplateId());
|
||||
if (descriptionTemplateEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
if (descriptionTemplateEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
org.opencdmp.commons.types.descriptiontemplate.DefinitionEntity descriptionTemplateDefinition = this.xmlHandlingService.fromXml(org.opencdmp.commons.types.descriptiontemplate.DefinitionEntity.class, descriptionTemplateEntity.getDefinition());
|
||||
|
||||
Description description = new Description();
|
||||
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(), data);
|
||||
return this.mapPrefilledEntityToDescription(description, descriptionTemplateDefinition, prefillingSourceDefinition, prefillingSourceEntity.getLabel(), data);
|
||||
}
|
||||
|
||||
private Description mapPrefilledEntityToDescription(Description description, DefinitionEntity descriptionTemplateDefinition, PrefillingSourceDefinitionEntity prefillingSourceDefinition, String type, Map<String, String> externalData){
|
||||
|
@ -408,8 +408,8 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
|
|||
|
||||
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")) {
|
||||
if ("rda.dataset.distribution.data_access".equals(semanticTarget)) {
|
||||
if ("open".equals(value)) {
|
||||
List<FieldEntity> issuedFieldEntities = definition.getAllField().stream().filter(x -> x.getSchematics() != null && x.getSchematics().contains("rda.dataset.issued")).toList();
|
||||
if (!this.conventionService.isListNullOrEmpty(issuedFieldEntities)) {
|
||||
String issuedIdNode = issuedFieldEntities.getFirst().getId();
|
||||
|
@ -424,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(descriptionReferences,licStartDateNode, semanticTarget, issuedValue, type));
|
||||
description.getProperties().getFieldSets().get(licStartFieldSetEntity.getId()).getItems().getFirst().getFields().put(licStartDateNode.getId(), this.buildPropertyDefinitionFieldItemValue(descriptionReferences,licStartDateNode, semanticTarget, issuedValue, type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -453,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(descriptionReferences, fieldEntity, semanticTarget, parsedValue, type));
|
||||
description.getProperties().getFieldSets().get(fieldSetEntity.getId()).getItems().getFirst().getFields().put(fieldEntity.getId() , this.buildPropertyDefinitionFieldItemValue(descriptionReferences, fieldEntity, semanticTarget, parsedValue, type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -489,11 +489,15 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
|
|||
try{
|
||||
switch (fieldEntity.getData().getFieldType()){
|
||||
case FREE_TEXT, TEXT_AREA, RICH_TEXT_AREA, RADIO_BOX -> field.setTextValue(value.toLowerCase(Locale.ROOT));
|
||||
case CHECK_BOX, BOOLEAN_DECISION -> field.setTextValue(value.trim().toLowerCase(Locale.ROOT));
|
||||
case DATE_PICKER ->{
|
||||
case CHECK_BOX, BOOLEAN_DECISION ->{
|
||||
if (!this.conventionService.isNullOrEmpty(value)) {
|
||||
field.setBooleanValue("true".equals(value.trim().toLowerCase(Locale.ROOT)));
|
||||
}
|
||||
}
|
||||
case DATE_PICKER -> {
|
||||
Instant instant = null;
|
||||
try {
|
||||
if (!this.conventionService.isNullOrEmpty(type) && type.equals(Zenodo) && semanticTarget.equals("rda.dataset.distribution.available_until") ) {
|
||||
if (!this.conventionService.isNullOrEmpty(type) && type.equals(Zenodo) && "rda.dataset.distribution.available_until".equals(semanticTarget) ) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd");
|
||||
LocalDate date = LocalDate.parse(value, formatter);
|
||||
date = date.plusYears(20);
|
||||
|
@ -503,7 +507,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
|
|||
}
|
||||
} catch (DateTimeParseException ex) {
|
||||
instant = LocalDate.parse(value).atStartOfDay().toInstant(ZoneOffset.UTC);
|
||||
if (!this.conventionService.isNullOrEmpty(type) && type.equals(Zenodo) && semanticTarget.equals("rda.dataset.distribution.available_until") ) {
|
||||
if (!this.conventionService.isNullOrEmpty(type) && type.equals(Zenodo) && "rda.dataset.distribution.available_until".equals(semanticTarget) ) {
|
||||
instant.plus(20, ChronoUnit.YEARS);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ public class Field {
|
|||
private final List<String> textListValue;
|
||||
|
||||
private final Instant dateValue;
|
||||
private final Boolean booleanValue;
|
||||
|
||||
private final ExternalIdentifier externalIdentifier;
|
||||
|
||||
|
@ -31,6 +32,9 @@ public class Field {
|
|||
return this.dateValue;
|
||||
}
|
||||
|
||||
public Boolean getBooleanValue() {
|
||||
return this.booleanValue;
|
||||
}
|
||||
|
||||
public ExternalIdentifier getExternalIdentifier() {
|
||||
return this.externalIdentifier;
|
||||
|
@ -41,6 +45,7 @@ public class Field {
|
|||
List<String> tempTextListValue;
|
||||
this.textValue = persist.getTextValue();
|
||||
this.dateValue = persist.getDateValue();
|
||||
this.booleanValue = persist.getBooleanValue();
|
||||
tempTextListValue = persist.getTextListValue();
|
||||
if (persist.getExternalIdentifier() != null) this.externalIdentifier = new ExternalIdentifier(persist.getExternalIdentifier());
|
||||
else this.externalIdentifier = null;
|
||||
|
@ -58,6 +63,7 @@ public class Field {
|
|||
public Field(FieldEntity entity){
|
||||
this.textValue = entity.getTextValue();
|
||||
this.dateValue = entity.getDateValue();
|
||||
this.booleanValue = entity.getBooleanValue();
|
||||
this.textListValue = entity.getTextListValue();
|
||||
if (entity.getExternalIdentifier() != null) this.externalIdentifier = new ExternalIdentifier(entity.getExternalIdentifier());
|
||||
else this.externalIdentifier = null;
|
||||
|
|
|
@ -12,6 +12,7 @@ public class RuleWithTarget{
|
|||
private final String textValue;
|
||||
private final List<String> textListValue;
|
||||
private final Instant dateValue;
|
||||
private final Boolean booleanValue;
|
||||
private final FieldEntity fieldEntity;
|
||||
|
||||
public RuleWithTarget(String source, RuleEntity rule, FieldEntity fieldEntity) {
|
||||
|
@ -21,29 +22,34 @@ public class RuleWithTarget{
|
|||
this.textValue = rule.getTextValue();
|
||||
this.textListValue = rule.getTextListValue();
|
||||
this.dateValue = rule.getDateValue();
|
||||
this.booleanValue = rule.getBooleanValue();
|
||||
}
|
||||
|
||||
public String getTarget() {
|
||||
return target;
|
||||
return this.target;
|
||||
}
|
||||
|
||||
public String getSource() {
|
||||
return source;
|
||||
return this.source;
|
||||
}
|
||||
|
||||
public String getTextValue() {
|
||||
return textValue;
|
||||
return this.textValue;
|
||||
}
|
||||
|
||||
public List<String> getTextListValue() {
|
||||
return textListValue;
|
||||
return this.textListValue;
|
||||
}
|
||||
|
||||
public Instant getDateValue() {
|
||||
return dateValue;
|
||||
return this.dateValue;
|
||||
}
|
||||
|
||||
public Boolean getBooleanValue() {
|
||||
return this.booleanValue;
|
||||
}
|
||||
|
||||
public FieldEntity getFieldEntity() {
|
||||
return fieldEntity;
|
||||
return this.fieldEntity;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package org.opencdmp.service.visibility;
|
||||
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
import org.opencdmp.commons.types.description.PropertyDefinitionEntity;
|
||||
import org.opencdmp.commons.types.descriptiontemplate.*;
|
||||
import org.opencdmp.model.persist.descriptionproperties.PropertyDefinitionPersist;
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
@ -363,15 +363,11 @@ public class VisibilityServiceImpl implements VisibilityService {
|
|||
new HashSet<>(field.getTextListValue()).containsAll(rule.getTextListValue());
|
||||
}
|
||||
else if (org.opencdmp.commons.enums.FieldType.isDateType(fieldType) && field.getDateValue() != null) return field.getDateValue().equals(rule.getDateValue());
|
||||
else if (org.opencdmp.commons.enums.FieldType.isBooleanType(fieldType) && field.getBooleanValue() != null) return field.getBooleanValue().equals(rule.getBooleanValue());
|
||||
else if (org.opencdmp.commons.enums.FieldType.isExternalIdentifierType(fieldType) && field.getExternalIdentifier() != null) {
|
||||
throw new NotImplementedException("External identifier rule not supported");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,27 +1,5 @@
|
|||
package org.opencdmp.controllers.publicapi;
|
||||
|
||||
import org.opencdmp.authorization.AuthorizationFlags;
|
||||
import org.opencdmp.commons.enums.IsActive;
|
||||
import org.opencdmp.controllers.publicapi.request.dataset.DatasetPublicTableRequest;
|
||||
import org.opencdmp.controllers.publicapi.response.DataTableData;
|
||||
import org.opencdmp.data.DescriptionEntity;
|
||||
import org.opencdmp.model.*;
|
||||
import org.opencdmp.model.builder.DescriptionBuilder;
|
||||
import org.opencdmp.model.builder.DmpBuilder;
|
||||
import org.opencdmp.model.descriptiontemplatedefinition.*;
|
||||
import org.opencdmp.model.descriptiontemplatedefinition.fielddata.BaseFieldData;
|
||||
import org.opencdmp.model.mapper.publicapi.DescriptionToPublicApiDatasetListingMapper;
|
||||
import org.opencdmp.model.mapper.publicapi.DescriptionToPublicApiDatasetMapper;
|
||||
import org.opencdmp.model.mapper.publicapi.DmpToPublicApiDmpListingMapper;
|
||||
import org.opencdmp.model.publicapi.listingmodels.DatasetPublicListingModel;
|
||||
import org.opencdmp.model.publicapi.overviewmodels.DatasetPublicModel;
|
||||
import org.opencdmp.controllers.publicapi.types.ResponseItem;
|
||||
import org.opencdmp.query.DescriptionQuery;
|
||||
import org.opencdmp.query.DmpQuery;
|
||||
import org.opencdmp.query.lookup.DescriptionLookup;
|
||||
import org.opencdmp.query.lookup.DmpLookup;
|
||||
import org.opencdmp.service.publicapi.PublicApiProperties;
|
||||
import org.opencdmp.controllers.publicapi.types.ApiMessageCode;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.exception.MyNotFoundException;
|
||||
|
@ -34,6 +12,28 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
|||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.opencdmp.authorization.AuthorizationFlags;
|
||||
import org.opencdmp.commons.enums.IsActive;
|
||||
import org.opencdmp.controllers.publicapi.request.dataset.DatasetPublicTableRequest;
|
||||
import org.opencdmp.controllers.publicapi.response.DataTableData;
|
||||
import org.opencdmp.controllers.publicapi.types.ApiMessageCode;
|
||||
import org.opencdmp.controllers.publicapi.types.ResponseItem;
|
||||
import org.opencdmp.data.DescriptionEntity;
|
||||
import org.opencdmp.model.*;
|
||||
import org.opencdmp.model.builder.DescriptionBuilder;
|
||||
import org.opencdmp.model.builder.DmpBuilder;
|
||||
import org.opencdmp.model.descriptiontemplatedefinition.*;
|
||||
import org.opencdmp.model.descriptiontemplatedefinition.fielddata.BaseFieldData;
|
||||
import org.opencdmp.model.mapper.publicapi.DescriptionToPublicApiDatasetListingMapper;
|
||||
import org.opencdmp.model.mapper.publicapi.DescriptionToPublicApiDatasetMapper;
|
||||
import org.opencdmp.model.mapper.publicapi.DmpToPublicApiDmpListingMapper;
|
||||
import org.opencdmp.model.publicapi.listingmodels.DatasetPublicListingModel;
|
||||
import org.opencdmp.model.publicapi.overviewmodels.DatasetPublicModel;
|
||||
import org.opencdmp.query.DescriptionQuery;
|
||||
import org.opencdmp.query.DmpQuery;
|
||||
import org.opencdmp.query.lookup.DescriptionLookup;
|
||||
import org.opencdmp.query.lookup.DmpLookup;
|
||||
import org.opencdmp.service.publicapi.PublicApiProperties;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -53,7 +53,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
|||
@Tag(name = "Datasets Description", description = "Provides Dataset description public API's.")
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/public/datasets/"})
|
||||
@RequestMapping("/api/public/datasets/")
|
||||
public class PublicDatasetsDescriptionDocumentation {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PublicDatasetsDescriptionDocumentation.class);
|
||||
|
@ -89,13 +89,11 @@ public class PublicDatasetsDescriptionDocumentation {
|
|||
}
|
||||
|
||||
@Operation(summary = "This method is used to get a listing of public datasets.", description = PublicApiStaticHelpers.Description.getPagedNotes)
|
||||
@io.swagger.v3.oas.annotations.responses.ApiResponses(value = {@io.swagger.v3.oas.annotations.responses.ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "The following example is generated using body: *{\"criteria\": {},\"length\": 2,\"offset\": 0,\"orderings\": {\"fields\": []} }*",
|
||||
content = @Content(mediaType = APPLICATION_JSON_VALUE, examples = {@ExampleObject(
|
||||
value = PublicApiStaticHelpers.Description.getPagedResponseExample
|
||||
)})
|
||||
)})
|
||||
@io.swagger.v3.oas.annotations.responses.ApiResponses(@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "The following example is generated using body: *{\"criteria\": {},\"length\": 2,\"offset\": 0,\"orderings\": {\"fields\": []} }*",
|
||||
content = @Content(mediaType = APPLICATION_JSON_VALUE, examples = @ExampleObject(PublicApiStaticHelpers.Description.getPagedResponseExample))
|
||||
))
|
||||
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody ResponseEntity<ResponseItem<DataTableData<DatasetPublicListingModel>>> getPaged(
|
||||
@Valid @RequestBody @io.swagger.v3.oas.annotations.parameters.RequestBody(description = PublicApiStaticHelpers.Description.getPagedRequestBodyDescription) DatasetPublicTableRequest datasetTableRequest
|
||||
|
@ -113,14 +111,12 @@ public class PublicDatasetsDescriptionDocumentation {
|
|||
}
|
||||
|
||||
@Operation(summary = "This method is used to get the overview of a public dataset.", description = PublicApiStaticHelpers.Description.getOverviewSinglePublicNotes)
|
||||
@io.swagger.v3.oas.annotations.responses.ApiResponses(value = {@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "The following example is generated using id: *ef7dfbdc-c5c1-46a7-a37b-c8d8692f1c0e*",
|
||||
content = @Content(mediaType = APPLICATION_JSON_VALUE, examples = {@ExampleObject(
|
||||
value = PublicApiStaticHelpers.Description.getOverviewSinglePublicResponseExample
|
||||
)})
|
||||
)})
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/{id}"}, produces = "application/json")
|
||||
@io.swagger.v3.oas.annotations.responses.ApiResponses(@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "The following example is generated using id: *ef7dfbdc-c5c1-46a7-a37b-c8d8692f1c0e*",
|
||||
content = @Content(mediaType = APPLICATION_JSON_VALUE, examples = @ExampleObject(PublicApiStaticHelpers.Description.getOverviewSinglePublicResponseExample))
|
||||
))
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/{id}", produces = "application/json")
|
||||
public @ResponseBody ResponseEntity<ResponseItem<DatasetPublicModel>> getOverviewSinglePublic(
|
||||
@PathVariable @Parameter(description = "fetch the dataset with the given id", example = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") String id
|
||||
) {
|
||||
|
@ -128,7 +124,7 @@ public class PublicDatasetsDescriptionDocumentation {
|
|||
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(EnumSet.of(AuthorizationFlags.Public)).ids(UUID.fromString(id)).isActive(IsActive.Active);
|
||||
Description model = this.builderFactory.builder(DescriptionBuilder.class).build(lookup.getProject(), query.firstAs(lookup.getProject()));
|
||||
if (model == null)
|
||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
|
||||
DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).ids(model.getDmp().getId()).isActive(IsActive.Active);
|
||||
DmpLookup dmpLookup = getDmpLookup();
|
||||
|
@ -193,6 +189,7 @@ public class PublicDatasetsDescriptionDocumentation {
|
|||
String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._fields, Field._validations),
|
||||
String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._fields, Field._visibilityRules, Rule._target),
|
||||
String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._fields, Field._visibilityRules, Rule._dateValue),
|
||||
String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._fields, Field._visibilityRules, Rule._booleanValue),
|
||||
String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._fields, Field._visibilityRules, Rule._textListValue),
|
||||
String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._fields, Field._visibilityRules, Rule._textValue),
|
||||
String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._fields, Field._visibilityRules, Rule._externalIdentifier),
|
||||
|
|
|
@ -86,6 +86,7 @@ export interface DescriptionTemplateRulePersist {
|
|||
textValue: string;
|
||||
textListValue: string[];
|
||||
dateValue: Date;
|
||||
booleanValue: boolean;
|
||||
}
|
||||
|
||||
export interface DescriptionTemplateMultiplicityPersist {
|
||||
|
|
|
@ -84,6 +84,7 @@ export interface DescriptionTemplateRule {
|
|||
textValue: string;
|
||||
textListValue: string[];
|
||||
dateValue: Date;
|
||||
booleanValue: boolean;
|
||||
}
|
||||
|
||||
export interface DescriptionTemplateMultiplicity {
|
||||
|
|
|
@ -42,6 +42,7 @@ export interface DescriptionField {
|
|||
textValue: string;
|
||||
textListValue: string[];
|
||||
dateValue: Date;
|
||||
booleanValue: boolean;
|
||||
externalIdentifier?: DescriptionExternalIdentifier;
|
||||
references: Reference[];
|
||||
}
|
||||
|
@ -98,6 +99,7 @@ export interface DescriptionFieldPersist {
|
|||
textValue: string;
|
||||
textListValue: string[];
|
||||
dateValue: Date;
|
||||
booleanValue: boolean;
|
||||
references: ReferencePersist[];
|
||||
reference: ReferencePersist;
|
||||
externalIdentifier?: DescriptionExternalIdentifierPersist;
|
||||
|
|
|
@ -28,9 +28,9 @@ export class FieldValuePipe implements PipeTransform {
|
|||
if (field?.data?.fieldType && controlValue) {
|
||||
switch (field.data.fieldType) {
|
||||
case DescriptionTemplateFieldType.BOOLEAN_DECISION:
|
||||
return of(controlValue.textValue == 'true' ? 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES' : 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO');
|
||||
return of(controlValue.booleanValue ? 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES' : 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO');
|
||||
case DescriptionTemplateFieldType.CHECK_BOX:
|
||||
return of(controlValue.textValue == 'true' ? 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES' : 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO');
|
||||
return of(controlValue.booleanValue ? 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES' : 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO');
|
||||
case DescriptionTemplateFieldType.RADIO_BOX: {
|
||||
const data = <DescriptionTemplateRadioBoxData>field.data;
|
||||
if (data?.options) {
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
<div class="col" *ngIf="isDateType(fieldTypeForCheck)">
|
||||
<app-description-template-editor-default-value-component [fieldType]="fieldTypeForCheck" [form]="ruleFormGroup.get('dateValue')" [formArrayOptions]="formArrayOptionsForCheck" placeHolder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.RULE.FIELDS.RULE-IF'| translate}}" required="true"></app-description-template-editor-default-value-component>
|
||||
</div>
|
||||
<div class="col" *ngIf="isBooleanType(fieldTypeForCheck)">
|
||||
<app-description-template-editor-default-value-component [fieldType]="fieldTypeForCheck" [form]="ruleFormGroup.get('booleanValue')" [formArrayOptions]="formArrayOptionsForCheck" placeHolder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.RULE.FIELDS.RULE-IF'| translate}}" required="true"></app-description-template-editor-default-value-component>
|
||||
</div>
|
||||
<div class="col" *ngIf="isTextListType(fieldTypeForCheck)">
|
||||
<app-description-template-editor-default-value-component [fieldType]="fieldTypeForCheck" [form]="ruleFormGroup.get('textListValue')" [formArrayOptions]="formArrayOptionsForCheck" placeHolder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.RULE.FIELDS.RULE-IF'| translate}}" required="true"></app-description-template-editor-default-value-component>
|
||||
</div>
|
||||
|
@ -48,4 +51,4 @@
|
|||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -40,13 +40,13 @@ export class DescriptionTemplateEditorRuleComponent implements OnInit {
|
|||
}
|
||||
|
||||
isTextType(type: DescriptionTemplateFieldType){
|
||||
return type == DescriptionTemplateFieldType.FREE_TEXT || type == DescriptionTemplateFieldType.CHECK_BOX ||
|
||||
return type == DescriptionTemplateFieldType.FREE_TEXT ||
|
||||
type == DescriptionTemplateFieldType.TEXT_AREA || type == DescriptionTemplateFieldType.RICH_TEXT_AREA ||
|
||||
type == DescriptionTemplateFieldType.BOOLEAN_DECISION || type == DescriptionTemplateFieldType.RADIO_BOX;
|
||||
type == DescriptionTemplateFieldType.BOOLEAN_DECISION ;
|
||||
}
|
||||
|
||||
isTextListType(type: DescriptionTemplateFieldType){
|
||||
return type == DescriptionTemplateFieldType.TAGS || type == DescriptionTemplateFieldType.INTERNAL_ENTRIES_DMPS ||
|
||||
return type == DescriptionTemplateFieldType.TAGS || type == DescriptionTemplateFieldType.INTERNAL_ENTRIES_DMPS ||
|
||||
type == DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS || type == DescriptionTemplateFieldType.SELECT;
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,10 @@ export class DescriptionTemplateEditorRuleComponent implements OnInit {
|
|||
return type == DescriptionTemplateFieldType.DATE_PICKER;
|
||||
}
|
||||
|
||||
isBooleanType(type: DescriptionTemplateFieldType){
|
||||
return type == DescriptionTemplateFieldType.CHECK_BOX || type == DescriptionTemplateFieldType.RADIO_BOX;
|
||||
}
|
||||
|
||||
isReferenceType(type: DescriptionTemplateFieldType){
|
||||
return type == DescriptionTemplateFieldType.REFERENCE_TYPES;
|
||||
}
|
||||
|
@ -250,4 +254,4 @@ interface OptionItem {
|
|||
parentsIds: string[],
|
||||
form: UntypedFormGroup,
|
||||
hiddenBy: string[]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -880,6 +880,7 @@ export class DescriptionTemplateRuleEditorModel implements DescriptionTemplateRu
|
|||
textValue: string;
|
||||
textListValue: string[];
|
||||
dateValue: Date;
|
||||
booleanValue: boolean;
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
|
@ -893,6 +894,7 @@ export class DescriptionTemplateRuleEditorModel implements DescriptionTemplateRu
|
|||
this.textValue = item.textValue;
|
||||
this.textListValue = item.textListValue;
|
||||
this.dateValue = item.dateValue;
|
||||
this.booleanValue = item.booleanValue;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -914,7 +916,8 @@ export class DescriptionTemplateRuleEditorModel implements DescriptionTemplateRu
|
|||
target: [{ value: this.target, disabled: disabled }, context.getValidation('target').validators],
|
||||
textValue: [{ value: this.textValue, disabled: disabled }, context.getValidation('textValue').validators],
|
||||
textListValue: [{ value: this.textListValue, disabled: disabled }, context.getValidation('textListValue').validators],
|
||||
dateValue: [{ value: this.dateValue, disabled: disabled }, context.getValidation('dateValue').validators]
|
||||
dateValue: [{ value: this.dateValue, disabled: disabled }, context.getValidation('dateValue').validators],
|
||||
booleanValue: [{ value: this.booleanValue, disabled: disabled }, context.getValidation('booleanValue').validators]
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -930,6 +933,7 @@ export class DescriptionTemplateRuleEditorModel implements DescriptionTemplateRu
|
|||
baseValidationArray.push({ key: 'textValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}textValue`)] });
|
||||
baseValidationArray.push({ key: 'textListValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}textListValue`)] });
|
||||
baseValidationArray.push({ key: 'dateValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}dateValue`)] });
|
||||
baseValidationArray.push({ key: 'booleanValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}booleanValue`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
|
@ -947,7 +951,7 @@ export class DescriptionTemplateRuleEditorModel implements DescriptionTemplateRu
|
|||
validationErrorModel
|
||||
});
|
||||
|
||||
['target', 'textValue', 'textListValue', 'dateValue'].forEach(keyField => {
|
||||
['target', 'textValue', 'textListValue', 'dateValue', 'booleanValue'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
|
|
|
@ -70,6 +70,7 @@ export class DescriptionTemplateEditorResolver extends BaseEditorResolver {
|
|||
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.visibilityRules), nameof<DescriptionTemplateRule>(x => x.textValue)].join('.'),
|
||||
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.visibilityRules), nameof<DescriptionTemplateRule>(x => x.textListValue)].join('.'),
|
||||
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.visibilityRules), nameof<DescriptionTemplateRule>(x => x.dateValue)].join('.'),
|
||||
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.visibilityRules), nameof<DescriptionTemplateRule>(x => x.booleanValue)].join('.'),
|
||||
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.data), nameof<DescriptionTemplateBaseFieldData>(x => x.label)].join('.'),
|
||||
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.data), nameof<DescriptionTemplateBaseFieldData>(x => x.fieldType)].join('.'),
|
||||
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.data), nameof<DescriptionTemplateSelectData>(x => x.multipleSelect)].join('.'),
|
||||
|
|
|
@ -223,6 +223,7 @@ export class DescriptionPropertyDefinitionEditorModel implements DescriptionProp
|
|||
textValue: undefined,
|
||||
textListValue: undefined,
|
||||
dateValue: undefined,
|
||||
booleanValue: definitionField.defaultValue && definitionField.defaultValue.length > 0 ? definitionField.defaultValue.trim().toLocaleLowerCase() == "true" : false, //TODO: booleanValue default value
|
||||
externalIdentifier: undefined,
|
||||
references: undefined
|
||||
});
|
||||
|
@ -244,6 +245,7 @@ export class DescriptionPropertyDefinitionEditorModel implements DescriptionProp
|
|||
textValue: undefined,
|
||||
textListValue: undefined,
|
||||
dateValue: undefined,
|
||||
booleanValue: undefined,
|
||||
externalIdentifier: undefined,
|
||||
references: undefined
|
||||
};
|
||||
|
@ -432,6 +434,7 @@ export class DescriptionFieldEditorModel implements DescriptionFieldPersist {
|
|||
textValue: string;
|
||||
textListValue: string[];
|
||||
dateValue: Date;
|
||||
booleanValue: boolean;
|
||||
references: ReferencePersist[] = [];
|
||||
reference: ReferencePersist;
|
||||
externalIdentifier?: DescriptionExternalIdentifierEditorModel = new DescriptionExternalIdentifierEditorModel(this.validationErrorModel);
|
||||
|
@ -447,6 +450,7 @@ export class DescriptionFieldEditorModel implements DescriptionFieldPersist {
|
|||
this.textValue = item.textValue;
|
||||
this.textListValue = item.textListValue;
|
||||
this.dateValue = item.dateValue;
|
||||
this.booleanValue = item.booleanValue;
|
||||
|
||||
const references = descriptionReferences?.filter(x => x.data?.fieldId == descriptionTemplateField?.id && x.isActive == IsActive.Active).map(x => {
|
||||
return {
|
||||
|
@ -494,6 +498,7 @@ export class DescriptionFieldEditorModel implements DescriptionFieldPersist {
|
|||
textValue: [{ value: this.textValue, disabled: disabled }, context.getValidation('textValue').validators],
|
||||
textListValue: [{ value: this.textListValue, disabled: disabled }, context.getValidation('textListValue').validators],
|
||||
dateValue: [{ value: this.dateValue, disabled: disabled }, context.getValidation('dateValue').validators],
|
||||
booleanValue: [{ value: this.booleanValue, disabled: disabled }, context.getValidation('booleanValue').validators],
|
||||
references: [{ value: this.references, disabled: disabled }, context.getValidation('references').validators],
|
||||
reference: [{ value: this.reference, disabled: disabled }, context.getValidation('reference').validators],
|
||||
externalIdentifier: this.externalIdentifier.buildForm({
|
||||
|
@ -513,6 +518,7 @@ export class DescriptionFieldEditorModel implements DescriptionFieldPersist {
|
|||
baseValidationArray.push({ key: 'textValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}textValue`)] });
|
||||
baseValidationArray.push({ key: 'textListValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}textListValue`)] });
|
||||
baseValidationArray.push({ key: 'dateValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}dateValue`)] });
|
||||
baseValidationArray.push({ key: 'booleanValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}booleanValue`)] });
|
||||
baseValidationArray.push({ key: 'references', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}references`)] });
|
||||
baseValidationArray.push({ key: 'reference', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}references`)] });
|
||||
baseValidationArray.push({ key: 'externalIdentifier', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}externalIdentifier`)] });
|
||||
|
@ -532,7 +538,7 @@ export class DescriptionFieldEditorModel implements DescriptionFieldPersist {
|
|||
validationErrorModel
|
||||
});
|
||||
|
||||
['textValue', 'textListValue', 'dateValue'].forEach(keyField => {
|
||||
['textValue', 'textListValue', 'dateValue', 'booleanValue'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
|
@ -709,8 +715,6 @@ export class DescriptionFieldIndicator {
|
|||
switch (type) {
|
||||
case DescriptionTemplateFieldType.FREE_TEXT:
|
||||
case DescriptionTemplateFieldType.BOOLEAN_DECISION:
|
||||
case DescriptionTemplateFieldType.CHECK_BOX:
|
||||
case DescriptionTemplateFieldType.RADIO_BOX:
|
||||
case DescriptionTemplateFieldType.TEXT_AREA:
|
||||
case DescriptionTemplateFieldType.UPLOAD:
|
||||
case DescriptionTemplateFieldType.RICH_TEXT_AREA:
|
||||
|
@ -723,6 +727,10 @@ export class DescriptionFieldIndicator {
|
|||
case DescriptionTemplateFieldType.DATE_PICKER:
|
||||
this.type = "dateValue";
|
||||
break;
|
||||
case DescriptionTemplateFieldType.CHECK_BOX:
|
||||
case DescriptionTemplateFieldType.RADIO_BOX:
|
||||
this.type = "booleanValue";
|
||||
break;
|
||||
case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS:
|
||||
if (multipleSelect) this.type = "textListValue";
|
||||
else this.type = "textValue"
|
||||
|
|
|
@ -66,6 +66,7 @@ export class DescriptionEditorResolver extends BaseEditorResolver {
|
|||
[nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.fields), nameof<DescriptionField>(x => x.textValue)].join('.'),
|
||||
[nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.fields), nameof<DescriptionField>(x => x.textListValue)].join('.'),
|
||||
[nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.fields), nameof<DescriptionField>(x => x.dateValue)].join('.'),
|
||||
[nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.fields), nameof<DescriptionField>(x => x.booleanValue)].join('.'),
|
||||
[nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.fields), nameof<DescriptionField>(x => x.externalIdentifier), nameof<DescriptionExternalIdentifier>(x => x.identifier)].join('.'),
|
||||
[nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.fields), nameof<DescriptionField>(x => x.externalIdentifier), nameof<DescriptionExternalIdentifier>(x => x.type)].join('.'),
|
||||
[nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.fields), nameof<DescriptionField>(x => x.references), nameof<Reference>(x => x.id)].join('.'),
|
||||
|
@ -128,6 +129,7 @@ export class DescriptionEditorResolver extends BaseEditorResolver {
|
|||
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.visibilityRules), nameof<DescriptionTemplateRule>(x => x.textValue)].join('.'),
|
||||
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.visibilityRules), nameof<DescriptionTemplateRule>(x => x.textListValue)].join('.'),
|
||||
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.visibilityRules), nameof<DescriptionTemplateRule>(x => x.dateValue)].join('.'),
|
||||
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.visibilityRules), nameof<DescriptionTemplateRule>(x => x.booleanValue)].join('.'),
|
||||
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.data), nameof<DescriptionTemplateBaseFieldData>(x => x.label)].join('.'),
|
||||
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.data), nameof<DescriptionTemplateBaseFieldData>(x => x.fieldType)].join('.'),
|
||||
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.data), nameof<DescriptionTemplateSelectData>(x => x.options), nameof<DescriptionTemplateSelectOption>(x => x.label)].join('.'),
|
||||
|
|
|
@ -82,9 +82,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div *ngSwitchCase="descriptionTemplateFieldTypeEnum.CHECK_BOX" class="col-12">
|
||||
<mat-checkbox [checked]="propertiesFormGroup?.get(field.id).get('textValue').value == 'true'" [disabled]="propertiesFormGroup?.get(field.id).get('textValue').disabled"(change)="checkBoxChanged($event)">
|
||||
<mat-checkbox [formControl]="propertiesFormGroup?.get(field.id).get('booleanValue')">
|
||||
{{field.data.label}}</mat-checkbox>
|
||||
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('textValue').hasError('backendError')">{{propertiesFormGroup?.get(field.id).get('textValue').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('booleanValue').hasError('backendError')">{{propertiesFormGroup?.get(field.id).get('booleanValue').getError('backendError').message}}</mat-error>
|
||||
</div>
|
||||
<mat-form-field *ngSwitchCase="descriptionTemplateFieldTypeEnum.TEXT_AREA" class="col-12">
|
||||
<textarea matInput class="text-area" [formControl]="propertiesFormGroup?.get(field.id).get('textValue')" matTextareaAutosize matAutosizeMinRows="3" matAutosizeMaxRows="15" [required]="isRequired" placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}"></textarea>
|
||||
|
@ -126,14 +126,14 @@
|
|||
</div>
|
||||
</ng-container>
|
||||
<div *ngSwitchCase="descriptionTemplateFieldTypeEnum.BOOLEAN_DECISION" class="col-12">
|
||||
<mat-radio-group [formControl]="propertiesFormGroup?.get(field.id).get('textValue')" [required]="isRequired">
|
||||
<mat-radio-button class="radio-button-item" value="true">{{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.ACTIONS.YES" | translate }}</mat-radio-button>
|
||||
<mat-radio-button class="radio-button-item" value="false">{{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.ACTIONS.NO" | translate }}</mat-radio-button>
|
||||
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('textValue').hasError('backendError')">{{propertiesFormGroup?.get(field.id).get('textValue').getError('backendError').message}}</mat-error>
|
||||
<mat-radio-group [formControl]="propertiesFormGroup?.get(field.id).get('booleanValue')" [required]="isRequired">
|
||||
<mat-radio-button class="radio-button-item" [value]="true">{{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.ACTIONS.YES" | translate }}</mat-radio-button>
|
||||
<mat-radio-button class="radio-button-item" [value]="false">{{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.ACTIONS.NO" | translate }}</mat-radio-button>
|
||||
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('booleanValue').hasError('backendError')">{{propertiesFormGroup?.get(field.id).get('booleanValue').getError('backendError').message}}</mat-error>
|
||||
</mat-radio-group>
|
||||
<small class="text-danger d-block" *ngIf="propertiesFormGroup?.get(field.id).get('textValue').hasError('required') && propertiesFormGroup?.get(field.id).get('textValue').touched">{{'GENERAL.VALIDATION.REQUIRED' | translate}}
|
||||
<small class="text-danger d-block" *ngIf="propertiesFormGroup?.get(field.id).get('booleanValue').hasError('required') && propertiesFormGroup?.get(field.id).get('booleanValue').touched">{{'GENERAL.VALIDATION.REQUIRED' | translate}}
|
||||
</small>
|
||||
<small class="text-muted d-inline-block" *ngIf="(isRequired) && !propertiesFormGroup?.get(field.id).get('textValue').touched">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</small>
|
||||
<small class="text-muted d-inline-block" *ngIf="(isRequired) && !propertiesFormGroup?.get(field.id).get('booleanValue').touched">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</small>
|
||||
</div>
|
||||
|
||||
<div *ngSwitchCase="descriptionTemplateFieldTypeEnum.RADIO_BOX" class="col-12">
|
||||
|
|
|
@ -162,10 +162,7 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn
|
|||
// this.form.disable();
|
||||
// }
|
||||
break;
|
||||
case DescriptionTemplateFieldType.CHECK_BOX:
|
||||
if (this.propertiesFormGroup?.get(this.field.id).get('textValue').value == undefined) this.propertiesFormGroup?.get(this.field.id).get('textValue').setValue("false");
|
||||
this.visibilityRulesService.reloadVisibility();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// this.form = this.visibilityRulesService.getFormGroup(this.field.id);
|
||||
|
|
|
@ -6,6 +6,7 @@ export class RuleWithTarget {
|
|||
textValue: string;
|
||||
textListValue: string[];
|
||||
dateValue: Date;
|
||||
booleanValue: boolean;
|
||||
field: DescriptionTemplateField;
|
||||
|
||||
public constructor(source: string, rule: DescriptionTemplateRule , fieldEntity: DescriptionTemplateField) {
|
||||
|
@ -15,5 +16,6 @@ export class RuleWithTarget {
|
|||
this.textValue = rule.textValue;
|
||||
this.textListValue = rule.textListValue;
|
||||
this.dateValue = rule.dateValue;
|
||||
this.booleanValue = rule.booleanValue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -270,9 +270,8 @@ export class VisibilityRulesService {
|
|||
private ruleIsTrue(rule: RuleWithTarget, field: DescriptionFieldPersist) :boolean{
|
||||
if (field != null){
|
||||
const fieldType: DescriptionTemplateFieldType = rule.field != null && rule.field.data != null ? rule.field.data.fieldType : DescriptionTemplateFieldType.FREE_TEXT;
|
||||
if ([DescriptionTemplateFieldType.FREE_TEXT, DescriptionTemplateFieldType.CHECK_BOX, DescriptionTemplateFieldType.TEXT_AREA,
|
||||
DescriptionTemplateFieldType.RICH_TEXT_AREA, DescriptionTemplateFieldType.UPLOAD, DescriptionTemplateFieldType.BOOLEAN_DECISION,
|
||||
DescriptionTemplateFieldType.RADIO_BOX].includes(fieldType) && field.textValue != null && field.textValue.length > 0) {
|
||||
if ([DescriptionTemplateFieldType.FREE_TEXT, DescriptionTemplateFieldType.RADIO_BOX, DescriptionTemplateFieldType.TEXT_AREA,
|
||||
DescriptionTemplateFieldType.RICH_TEXT_AREA, DescriptionTemplateFieldType.UPLOAD].includes(fieldType) && field.textValue != null && field.textValue.length > 0) {
|
||||
if (DescriptionTemplateFieldType.UPLOAD == fieldType){
|
||||
return false; //not apply visibility logic
|
||||
} else {
|
||||
|
@ -287,6 +286,9 @@ export class VisibilityRulesService {
|
|||
else if (DescriptionTemplateFieldType.REFERENCE_TYPES == fieldType) {
|
||||
return false; //not implemented visibility logic
|
||||
}
|
||||
else if ([DescriptionTemplateFieldType.CHECK_BOX, DescriptionTemplateFieldType.BOOLEAN_DECISION].includes(fieldType)) {
|
||||
return field.booleanValue == rule.booleanValue;
|
||||
}
|
||||
else if (DescriptionTemplateFieldType.DATE_PICKER == fieldType && field.dateValue != null) return field.dateValue == rule.dateValue;
|
||||
else if ([DescriptionTemplateFieldType.VALIDATION, DescriptionTemplateFieldType.DATASET_IDENTIFIER].includes(fieldType) && field.externalIdentifier != null) {
|
||||
return false; //not implemented visibility logic
|
||||
|
|
|
@ -17,7 +17,7 @@ export class FormProgressIndicationComponent extends BaseComponent implements On
|
|||
progressSoFar: number;
|
||||
total: number;
|
||||
percent: number;
|
||||
fieldTypes: string[] = ['dateValue', 'externalIdentifier.identifier', 'externalIdentifier.type', 'reference', 'references', 'textListValue', 'textValue'];
|
||||
fieldTypes: string[] = ['dateValue', 'booleanValue', 'externalIdentifier.identifier', 'externalIdentifier.type', 'reference', 'references', 'textListValue', 'textValue'];
|
||||
|
||||
constructor(private visibilityRulesService: VisibilityRulesService) { super(); }
|
||||
|
||||
|
@ -66,7 +66,7 @@ export class FormProgressIndicationComponent extends BaseComponent implements On
|
|||
return valueCurrent;
|
||||
}
|
||||
|
||||
countRequiredFieldsByFieldset(ordinal: number, fieldsFormGroup: UntypedFormGroup, filterValid: boolean = false): number {
|
||||
countRequiredFieldsByFieldset(ordinal: number, fieldsFormGroup: UntypedFormGroup, filterValid: boolean = false): number {
|
||||
let fieldsCount: number = 0;
|
||||
const fieldNames = Object.keys(fieldsFormGroup.controls);
|
||||
for(let item of fieldNames) {
|
||||
|
@ -207,8 +207,8 @@ export class FormProgressIndicationComponent extends BaseComponent implements On
|
|||
if (validator && validator.required) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -375,7 +375,11 @@ public class DatasetMigrationService {
|
|||
if (textValue == null || textValue.isEmpty()) return fieldEntity;
|
||||
switch (currentField.getData().getFieldType()){
|
||||
case FREE_TEXT, TEXT_AREA, RICH_TEXT_AREA, RADIO_BOX -> fieldEntity.setTextValue(textValue.trim());
|
||||
case CHECK_BOX, BOOLEAN_DECISION -> fieldEntity.setTextValue(textValue.trim().toLowerCase(Locale.ROOT));
|
||||
case CHECK_BOX, BOOLEAN_DECISION -> {
|
||||
if (!this.conventionService.isNullOrEmpty(textValue)) {
|
||||
fieldEntity.setBooleanValue("true".equals(textValue.trim().toLowerCase(Locale.ROOT)));
|
||||
}
|
||||
}
|
||||
case DATE_PICKER -> {
|
||||
Instant instant = null;
|
||||
if(!this.conventionService.isNullOrEmpty(textValue)) {
|
||||
|
|
|
@ -416,7 +416,11 @@ public class DescriptionTemplateXmlMigrationService {
|
|||
data.setTarget(persist.getTarget());
|
||||
switch (fieldType){
|
||||
case FREE_TEXT, TEXT_AREA, RICH_TEXT_AREA, RADIO_BOX -> data.setTextValue(textValue.trim());
|
||||
case CHECK_BOX, BOOLEAN_DECISION -> data.setTextValue(textValue.trim().toLowerCase(Locale.ROOT));
|
||||
case CHECK_BOX, BOOLEAN_DECISION -> {
|
||||
if (!this.conventionService.isNullOrEmpty(textValue)) {
|
||||
data.setBooleanValue("true".equals(textValue.trim().toLowerCase(Locale.ROOT)));
|
||||
}
|
||||
}
|
||||
case DATE_PICKER -> {
|
||||
Instant instant = null;
|
||||
if(!this.conventionService.isNullOrEmpty(textValue)) {
|
||||
|
|
Loading…
Reference in New Issue