reference type refactor
This commit is contained in:
parent
4f1b05ab20
commit
87dd56ff2c
|
@ -8,12 +8,12 @@ import java.util.Map;
|
||||||
public enum DmpBlueprintFieldCategory implements DatabaseEnum<Short> {
|
public enum DmpBlueprintFieldCategory implements DatabaseEnum<Short> {
|
||||||
System((short) 0),
|
System((short) 0),
|
||||||
Extra((short) 1),
|
Extra((short) 1),
|
||||||
Reference((short) 1);
|
ReferenceType((short) 1);
|
||||||
|
|
||||||
public static class Names {
|
public static class Names {
|
||||||
public static final String System = "system";
|
public static final String System = "system";
|
||||||
public static final String Extra = "extra";
|
public static final String Extra = "extra";
|
||||||
public static final String Reference = "reference";
|
public static final String ReferenceType = "referenceType";
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Short value;
|
private final Short value;
|
||||||
|
|
|
@ -7,7 +7,7 @@ import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class ReferenceFieldEntity extends FieldEntity {
|
public class ReferenceTypeFieldEntity extends FieldEntity {
|
||||||
|
|
||||||
@XmlAttribute(name="referenceTypeId")
|
@XmlAttribute(name="referenceTypeId")
|
||||||
private UUID referenceTypeId;
|
private UUID referenceTypeId;
|
|
@ -26,7 +26,7 @@ public class SectionEntity {
|
||||||
@XmlElements({
|
@XmlElements({
|
||||||
@XmlElement(name = DmpBlueprintFieldCategory.Names.Extra, type = ExtraFieldEntity.class),
|
@XmlElement(name = DmpBlueprintFieldCategory.Names.Extra, type = ExtraFieldEntity.class),
|
||||||
@XmlElement(name = DmpBlueprintFieldCategory.Names.System, type = SystemFieldEntity.class),
|
@XmlElement(name = DmpBlueprintFieldCategory.Names.System, type = SystemFieldEntity.class),
|
||||||
@XmlElement(name = DmpBlueprintFieldCategory.Names.Reference, type = ReferenceFieldEntity.class),
|
@XmlElement(name = DmpBlueprintFieldCategory.Names.ReferenceType, type = ReferenceTypeFieldEntity.class),
|
||||||
})
|
})
|
||||||
private List<FieldEntity> fields;
|
private List<FieldEntity> fields;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class ReferenceFieldImportExport {
|
public class ReferenceTypeFieldImportExport {
|
||||||
|
|
||||||
@XmlAttribute(name = "id")
|
@XmlAttribute(name = "id")
|
||||||
private UUID id;
|
private UUID id;
|
|
@ -24,7 +24,7 @@ public class SectionImportExport {
|
||||||
private List<ExtraFieldImportExport> extraFields;
|
private List<ExtraFieldImportExport> extraFields;
|
||||||
@XmlElementWrapper(name = "referenceFields")
|
@XmlElementWrapper(name = "referenceFields")
|
||||||
@XmlElement(name = "referenceField")
|
@XmlElement(name = "referenceField")
|
||||||
private List<ReferenceFieldImportExport> referenceFields;
|
private List<ReferenceTypeFieldImportExport> referenceFields;
|
||||||
@XmlAttribute(name = "hasTemplates")
|
@XmlAttribute(name = "hasTemplates")
|
||||||
private boolean hasTemplates;
|
private boolean hasTemplates;
|
||||||
@XmlElementWrapper(name = "descriptionTemplates")
|
@XmlElementWrapper(name = "descriptionTemplates")
|
||||||
|
@ -79,11 +79,11 @@ public class SectionImportExport {
|
||||||
this.extraFields = extraFields;
|
this.extraFields = extraFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ReferenceFieldImportExport> getReferenceFields() {
|
public List<ReferenceTypeFieldImportExport> getReferenceFields() {
|
||||||
return referenceFields;
|
return referenceFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReferenceFields(List<ReferenceFieldImportExport> referenceFields) {
|
public void setReferenceFields(List<ReferenceTypeFieldImportExport> referenceFields) {
|
||||||
this.referenceFields = referenceFields;
|
this.referenceFields = referenceFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,16 @@
|
||||||
package eu.eudat.model.builder.dmpblueprintdefinition;
|
package eu.eudat.model.builder.dmpblueprintdefinition;
|
||||||
|
|
||||||
import eu.eudat.commons.types.dmpblueprint.ReferenceFieldEntity;
|
import eu.eudat.commons.types.dmpblueprint.ReferenceTypeFieldEntity;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.model.dmpblueprintdefinition.ReferenceField;
|
import eu.eudat.model.Dmp;
|
||||||
|
import eu.eudat.model.PublicReferenceType;
|
||||||
|
import eu.eudat.model.builder.PublicReferenceTypeBuilder;
|
||||||
|
import eu.eudat.model.builder.ReferenceTypeBuilder;
|
||||||
|
import eu.eudat.model.dmpblueprintdefinition.ReferenceTypeField;
|
||||||
|
import eu.eudat.query.ReferenceTypeQuery;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -13,20 +21,27 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class ReferenceFieldBuilder extends FieldBuilder<ReferenceField, ReferenceFieldEntity> {
|
public class ReferenceFieldBuilder extends FieldBuilder<ReferenceTypeField, ReferenceTypeFieldEntity> {
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public ReferenceFieldBuilder(
|
public ReferenceFieldBuilder(
|
||||||
ConventionService conventionService) {
|
ConventionService conventionService, QueryFactory queryFactory, BuilderFactory builderFactory) {
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceFieldBuilder.class)));
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceFieldBuilder.class)));
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ReferenceField getInstance() {
|
protected ReferenceTypeField getInstance() {
|
||||||
return new ReferenceField();
|
return new ReferenceTypeField();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ReferenceField buildChild(FieldSet fields, ReferenceFieldEntity data, ReferenceField model) {
|
protected ReferenceTypeField buildChild(FieldSet fields, ReferenceTypeFieldEntity data, ReferenceTypeField model) {
|
||||||
if (fields.hasField(this.asIndexer(ReferenceField._referenceTypeId))) model.setReferenceTypeId(data.getReferenceTypeId());
|
FieldSet referenceTypeFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeField._referenceType));
|
||||||
|
|
||||||
|
if (data.getReferenceTypeId() != null && !referenceTypeFields.isEmpty() ) model.setReferenceType(this.builderFactory.builder(ReferenceTypeBuilder.class).build(referenceTypeFields, this.queryFactory.query(ReferenceTypeQuery.class).ids(data.getReferenceTypeId()).first())); //TODO: Optimize
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Component("dmpblueprintdefinitionsectionbuilder")
|
@Component("dmpblueprintdefinitionsectionbuilder")
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
@ -65,7 +64,7 @@ public class SectionBuilder extends BaseBuilder<Section, SectionEntity> {
|
||||||
m.getFields().addAll(this.builderFactory.builder(SystemFieldBuilder.class).authorize(this.authorize).build(fieldsFields, systemFieldEntities));
|
m.getFields().addAll(this.builderFactory.builder(SystemFieldBuilder.class).authorize(this.authorize).build(fieldsFields, systemFieldEntities));
|
||||||
List<ExtraFieldEntity> extraFieldEntities = d.getFields().stream().filter(x-> DmpBlueprintFieldCategory.Extra.equals(x.getCategory())).map(x-> (ExtraFieldEntity)x).toList();
|
List<ExtraFieldEntity> extraFieldEntities = d.getFields().stream().filter(x-> DmpBlueprintFieldCategory.Extra.equals(x.getCategory())).map(x-> (ExtraFieldEntity)x).toList();
|
||||||
m.getFields().addAll(this.builderFactory.builder(ExtraFieldBuilder.class).authorize(this.authorize).build(fieldsFields, extraFieldEntities));
|
m.getFields().addAll(this.builderFactory.builder(ExtraFieldBuilder.class).authorize(this.authorize).build(fieldsFields, extraFieldEntities));
|
||||||
List<ReferenceFieldEntity> referenceFieldEntities = d.getFields().stream().filter(x-> DmpBlueprintFieldCategory.Reference.equals(x.getCategory())).map(x-> (ReferenceFieldEntity)x).toList();
|
List<ReferenceTypeFieldEntity> referenceFieldEntities = d.getFields().stream().filter(x-> DmpBlueprintFieldCategory.ReferenceType.equals(x.getCategory())).map(x-> (ReferenceTypeFieldEntity)x).toList();
|
||||||
m.getFields().addAll(this.builderFactory.builder(ReferenceFieldBuilder.class).authorize(this.authorize).build(fieldsFields, referenceFieldEntities));
|
m.getFields().addAll(this.builderFactory.builder(ReferenceFieldBuilder.class).authorize(this.authorize).build(fieldsFields, referenceFieldEntities));
|
||||||
}
|
}
|
||||||
models.add(m);
|
models.add(m);
|
||||||
|
|
|
@ -6,16 +6,11 @@ import eu.eudat.commons.JsonHandlingService;
|
||||||
import eu.eudat.commons.XmlHandlingService;
|
import eu.eudat.commons.XmlHandlingService;
|
||||||
import eu.eudat.commons.types.dmpblueprint.*;
|
import eu.eudat.commons.types.dmpblueprint.*;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
|
||||||
import eu.eudat.data.DmpBlueprintEntity;
|
import eu.eudat.data.DmpBlueprintEntity;
|
||||||
import eu.eudat.file.transformer.enums.DmpBlueprintExtraFieldDataType;
|
import eu.eudat.file.transformer.enums.DmpBlueprintExtraFieldDataType;
|
||||||
import eu.eudat.file.transformer.enums.DmpBlueprintFieldCategory;
|
|
||||||
import eu.eudat.file.transformer.enums.DmpBlueprintSystemFieldType;
|
import eu.eudat.file.transformer.enums.DmpBlueprintSystemFieldType;
|
||||||
import eu.eudat.file.transformer.models.descriptiontemplate.DescriptionTemplateFileTransformerModel;
|
|
||||||
import eu.eudat.file.transformer.models.dmpblueprint.DmpBlueprintFileTransformerModel;
|
import eu.eudat.file.transformer.models.dmpblueprint.DmpBlueprintFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.dmpblueprint.definition.*;
|
import eu.eudat.file.transformer.models.dmpblueprint.definition.*;
|
||||||
import eu.eudat.model.dmpblueprintdefinition.*;
|
|
||||||
import eu.eudat.query.DescriptionTemplateQuery;
|
|
||||||
import eu.eudat.query.DmpBlueprintQuery;
|
import eu.eudat.query.DmpBlueprintQuery;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
@ -111,7 +106,7 @@ public class DmpBlueprintFileTransformerBuilder extends BaseFileTransformerBuild
|
||||||
FieldFileTransformerModel m = switch (fieldEntity.getCategory()) {
|
FieldFileTransformerModel m = switch (fieldEntity.getCategory()) {
|
||||||
case System -> new SystemFieldFileTransformerModel();
|
case System -> new SystemFieldFileTransformerModel();
|
||||||
case Extra -> new ExtraFieldFileTransformerModelFileTransformerModel();
|
case Extra -> new ExtraFieldFileTransformerModelFileTransformerModel();
|
||||||
case Reference -> throw new NotImplementedException("ReferenceFieldFileTransformerModel");
|
case ReferenceType -> throw new NotImplementedException("ReferenceFieldFileTransformerModel");
|
||||||
default -> throw new MyApplicationException("unrecognized type " + fieldEntity.getCategory());
|
default -> throw new MyApplicationException("unrecognized type " + fieldEntity.getCategory());
|
||||||
};
|
};
|
||||||
m.setId(fieldEntity.getId());
|
m.setId(fieldEntity.getId());
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
package eu.eudat.model.dmpblueprintdefinition;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class ReferenceField extends Field {
|
|
||||||
|
|
||||||
public final static String _referenceTypeId = "referenceTypeId";
|
|
||||||
private UUID referenceTypeId;
|
|
||||||
|
|
||||||
public UUID getReferenceTypeId() {
|
|
||||||
return referenceTypeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReferenceTypeId(UUID referenceTypeId) {
|
|
||||||
this.referenceTypeId = referenceTypeId;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package eu.eudat.model.dmpblueprintdefinition;
|
||||||
|
|
||||||
|
import eu.eudat.model.ReferenceType;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class ReferenceTypeField extends Field {
|
||||||
|
|
||||||
|
public final static String _referenceType = "referenceTypeId";
|
||||||
|
private ReferenceType referenceType;
|
||||||
|
|
||||||
|
public ReferenceType getReferenceType() {
|
||||||
|
return referenceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReferenceType(ReferenceType referenceType) {
|
||||||
|
this.referenceType = referenceType;
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,7 +12,7 @@ import org.springframework.stereotype.Component;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ReferenceFieldPersist extends FieldPersist {
|
public class ReferenceTypeFieldPersist extends FieldPersist {
|
||||||
|
|
||||||
private UUID referenceTypeId;
|
private UUID referenceTypeId;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ public class ReferenceFieldPersist extends FieldPersist {
|
||||||
|
|
||||||
@Component(ReferenceFieldPersistPersistValidator.ValidatorName)
|
@Component(ReferenceFieldPersistPersistValidator.ValidatorName)
|
||||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public static class ReferenceFieldPersistPersistValidator extends BaseFieldPersistValidator<ReferenceFieldPersist> {
|
public static class ReferenceFieldPersistPersistValidator extends BaseFieldPersistValidator<ReferenceTypeFieldPersist> {
|
||||||
|
|
||||||
public static final String ValidatorName = "DmpBlueprint.ReferenceFieldPersistPersistValidator";
|
public static final String ValidatorName = "DmpBlueprint.ReferenceFieldPersistPersistValidator";
|
||||||
|
|
||||||
|
@ -37,17 +37,17 @@ public class ReferenceFieldPersist extends FieldPersist {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<ReferenceFieldPersist> modelClass() {
|
protected Class<ReferenceTypeFieldPersist> modelClass() {
|
||||||
return ReferenceFieldPersist.class;
|
return ReferenceTypeFieldPersist.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Specification> specifications(ReferenceFieldPersist item) {
|
protected List<Specification> specifications(ReferenceTypeFieldPersist item) {
|
||||||
List<Specification> specifications = getBaseSpecifications(item);
|
List<Specification> specifications = getBaseSpecifications(item);
|
||||||
specifications.add(
|
specifications.add(
|
||||||
this.spec()
|
this.spec()
|
||||||
.must(() -> !this.isNull(item.getReferenceTypeId()))
|
.must(() -> !this.isNull(item.getReferenceTypeId()))
|
||||||
.failOn(ReferenceFieldPersist._referenceTypeId).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceFieldPersist._referenceTypeId}, LocaleContextHolder.getLocale()))
|
.failOn(ReferenceTypeFieldPersist._referenceTypeId).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeFieldPersist._referenceTypeId}, LocaleContextHolder.getLocale()))
|
||||||
);
|
);
|
||||||
return specifications;
|
return specifications;
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package eu.eudat.model.persist.dmpblueprintdefinition;
|
package eu.eudat.model.persist.dmpblueprintdefinition;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.DmpBlueprintFieldCategory;
|
|
||||||
import eu.eudat.commons.validation.BaseValidator;
|
import eu.eudat.commons.validation.BaseValidator;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.validation.ValidatorFactory;
|
import gr.cite.tools.validation.ValidatorFactory;
|
||||||
|
@ -14,7 +13,6 @@ import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -154,8 +152,8 @@ public class SectionPersist {
|
||||||
case System -> {
|
case System -> {
|
||||||
return this.validatorFactory.validator(SystemFieldPersist.SystemFieldPersistValidator.class);
|
return this.validatorFactory.validator(SystemFieldPersist.SystemFieldPersistValidator.class);
|
||||||
}
|
}
|
||||||
case Reference -> {
|
case ReferenceType -> {
|
||||||
return this.validatorFactory.validator(ReferenceFieldPersist.ReferenceFieldPersistPersistValidator.class);
|
return this.validatorFactory.validator(ReferenceTypeFieldPersist.ReferenceFieldPersistPersistValidator.class);
|
||||||
}
|
}
|
||||||
default -> throw new MyApplicationException("unrecognized type " + ((FieldPersist) itm).getCategory());
|
default -> throw new MyApplicationException("unrecognized type " + ((FieldPersist) itm).getCategory());
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,6 @@ import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableConfigurationProperties(DashboardServiceProperties.class)
|
@EnableConfigurationProperties(DashboardServiceProperties.class)
|
||||||
public class PublicApiConfiguration {
|
public class DashboardServiceConfiguration {
|
||||||
|
|
||||||
}
|
}
|
|
@ -12,7 +12,7 @@ import eu.eudat.commons.types.actionconfirmation.DmpInvitationEntity;
|
||||||
import eu.eudat.commons.types.dmp.DmpBlueprintValueEntity;
|
import eu.eudat.commons.types.dmp.DmpBlueprintValueEntity;
|
||||||
import eu.eudat.commons.types.dmp.DmpContactEntity;
|
import eu.eudat.commons.types.dmp.DmpContactEntity;
|
||||||
import eu.eudat.commons.types.dmp.DmpPropertiesEntity;
|
import eu.eudat.commons.types.dmp.DmpPropertiesEntity;
|
||||||
import eu.eudat.commons.types.dmpblueprint.ReferenceFieldEntity;
|
import eu.eudat.commons.types.dmpblueprint.ReferenceTypeFieldEntity;
|
||||||
import eu.eudat.commons.types.dmpreference.DmpReferenceDataEntity;
|
import eu.eudat.commons.types.dmpreference.DmpReferenceDataEntity;
|
||||||
import eu.eudat.commons.types.notification.*;
|
import eu.eudat.commons.types.notification.*;
|
||||||
import eu.eudat.commons.types.reference.DefinitionEntity;
|
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||||
|
@ -650,8 +650,8 @@ public class DmpServiceImpl implements DmpService {
|
||||||
referenceEntity = this.entityManager.find(ReferenceEntity.class, referencePersist.getId());
|
referenceEntity = this.entityManager.find(ReferenceEntity.class, referencePersist.getId());
|
||||||
if (referenceEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{referencePersist.getId(), Reference.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (referenceEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{referencePersist.getId(), Reference.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
} else {
|
} else {
|
||||||
ReferenceFieldEntity fieldEntity = blueprintDefinition.getFieldById(model.getData().getBlueprintFieldId()).stream().filter(x-> x.getCategory().equals(DmpBlueprintFieldCategory.Reference)).map(x-> (ReferenceFieldEntity)x).findFirst().orElse(null);
|
ReferenceTypeFieldEntity fieldEntity = blueprintDefinition.getFieldById(model.getData().getBlueprintFieldId()).stream().filter(x-> x.getCategory().equals(DmpBlueprintFieldCategory.ReferenceType)).map(x-> (ReferenceTypeFieldEntity)x).findFirst().orElse(null);
|
||||||
if (fieldEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getData().getBlueprintFieldId(), ReferenceFieldEntity.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (fieldEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getData().getBlueprintFieldId(), ReferenceTypeFieldEntity.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
referenceEntity = this.queryFactory.query(ReferenceQuery.class).sourceTypes(referencePersist.getSourceType()).typeIds(fieldEntity.getReferenceTypeId()).sources(referencePersist.getSource()).isActive(IsActive.Active).references(referencePersist.getReference()).first();
|
referenceEntity = this.queryFactory.query(ReferenceQuery.class).sourceTypes(referencePersist.getSourceType()).typeIds(fieldEntity.getReferenceTypeId()).sources(referencePersist.getSource()).isActive(IsActive.Active).references(referencePersist.getReference()).first();
|
||||||
if (referenceEntity == null){
|
if (referenceEntity == null){
|
||||||
|
|
|
@ -262,9 +262,9 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
dataTyped.setType(((SystemFieldPersist) persist).getSystemFieldType());
|
dataTyped.setType(((SystemFieldPersist) persist).getSystemFieldType());
|
||||||
data = dataTyped;
|
data = dataTyped;
|
||||||
}
|
}
|
||||||
case Reference -> {
|
case ReferenceType -> {
|
||||||
ReferenceFieldEntity dataTyped = new ReferenceFieldEntity();
|
ReferenceTypeFieldEntity dataTyped = new ReferenceTypeFieldEntity();
|
||||||
dataTyped.setReferenceTypeId(((ReferenceFieldPersist) persist).getReferenceTypeId());
|
dataTyped.setReferenceTypeId(((ReferenceTypeFieldPersist) persist).getReferenceTypeId());
|
||||||
data = dataTyped;
|
data = dataTyped;
|
||||||
}
|
}
|
||||||
default -> throw new InternalError("unknown type: " + persist.getCategory());
|
default -> throw new InternalError("unknown type: " + persist.getCategory());
|
||||||
|
@ -490,10 +490,10 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
}
|
}
|
||||||
xml.setExtraFields(dmpBlueprintExtraFieldModels);
|
xml.setExtraFields(dmpBlueprintExtraFieldModels);
|
||||||
|
|
||||||
List<ReferenceFieldImportExport> dmpBlueprintReferenceFieldModels = new LinkedList<>();
|
List<ReferenceTypeFieldImportExport> dmpBlueprintReferenceFieldModels = new LinkedList<>();
|
||||||
if (!this.conventionService.isListNullOrEmpty(entity.getFields())) {
|
if (!this.conventionService.isListNullOrEmpty(entity.getFields())) {
|
||||||
for (ReferenceFieldEntity referenceFieldEntity : entity.getFields().stream().filter(x -> x.getCategory() == DmpBlueprintFieldCategory.Reference).map(x -> (ReferenceFieldEntity) x).toList()) {
|
for (ReferenceTypeFieldEntity referenceTypeFieldEntity : entity.getFields().stream().filter(x -> x.getCategory() == DmpBlueprintFieldCategory.ReferenceType).map(x -> (ReferenceTypeFieldEntity) x).toList()) {
|
||||||
dmpBlueprintReferenceFieldModels.add(this.referenceFieldXmlToExport(referenceFieldEntity));
|
dmpBlueprintReferenceFieldModels.add(this.referenceFieldXmlToExport(referenceTypeFieldEntity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xml.setReferenceFields(dmpBlueprintReferenceFieldModels);
|
xml.setReferenceFields(dmpBlueprintReferenceFieldModels);
|
||||||
|
@ -529,8 +529,8 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReferenceFieldImportExport referenceFieldXmlToExport(ReferenceFieldEntity entity) {
|
private ReferenceTypeFieldImportExport referenceFieldXmlToExport(ReferenceTypeFieldEntity entity) {
|
||||||
ReferenceFieldImportExport xml = new ReferenceFieldImportExport();
|
ReferenceTypeFieldImportExport xml = new ReferenceTypeFieldImportExport();
|
||||||
xml.setId(entity.getId());
|
xml.setId(entity.getId());
|
||||||
xml.setReferenceTypeId(entity.getReferenceTypeId());
|
xml.setReferenceTypeId(entity.getReferenceTypeId());
|
||||||
xml.setLabel(entity.getLabel());
|
xml.setLabel(entity.getLabel());
|
||||||
|
@ -603,7 +603,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!this.conventionService.isListNullOrEmpty(importXml.getReferenceFields())) {
|
if (!this.conventionService.isListNullOrEmpty(importXml.getReferenceFields())) {
|
||||||
for (ReferenceFieldImportExport referenceField : importXml.getReferenceFields()) {
|
for (ReferenceTypeFieldImportExport referenceField : importXml.getReferenceFields()) {
|
||||||
dmpBlueprintFieldModels.add(this.xmlReferenceFieldToPersist(referenceField));
|
dmpBlueprintFieldModels.add(this.xmlReferenceFieldToPersist(referenceField));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -658,10 +658,10 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
return persist;
|
return persist;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FieldPersist xmlReferenceFieldToPersist(ReferenceFieldImportExport importXml) {
|
private FieldPersist xmlReferenceFieldToPersist(ReferenceTypeFieldImportExport importXml) {
|
||||||
ReferenceFieldPersist persist = new ReferenceFieldPersist();
|
ReferenceTypeFieldPersist persist = new ReferenceTypeFieldPersist();
|
||||||
persist.setId(importXml.getId());
|
persist.setId(importXml.getId());
|
||||||
persist.setCategory(DmpBlueprintFieldCategory.Reference);
|
persist.setCategory(DmpBlueprintFieldCategory.ReferenceType);
|
||||||
persist.setReferenceTypeId(importXml.getReferenceTypeId());
|
persist.setReferenceTypeId(importXml.getReferenceTypeId());
|
||||||
persist.setLabel(importXml.getLabel());
|
persist.setLabel(importXml.getLabel());
|
||||||
persist.setPlaceholder(importXml.getPlaceholder());
|
persist.setPlaceholder(importXml.getPlaceholder());
|
||||||
|
|
Loading…
Reference in New Issue