Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring
This commit is contained in:
commit
472eacc50a
|
@ -39,8 +39,8 @@ public class NestedCollaboratorElasticBuilder extends BaseElasticBuilder<NestedC
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
|
||||||
List<NestedCollaboratorElasticEntity> models = new ArrayList<>();
|
List<NestedCollaboratorElasticEntity> models = new ArrayList<>();
|
||||||
Map<UUID, String> userNameMap = this.queryFactory.query(UserQuery.class).disableTracking().isActive(IsActive.Active).ids(data.stream().map(DmpUserEntity::getUserId).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(User._id).ensure(User._name))
|
List<UserEntity> users = this.queryFactory.query(UserQuery.class).disableTracking().isActive(IsActive.Active).ids(data.stream().map(DmpUserEntity::getUserId).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(User._id).ensure(User._name));
|
||||||
.stream().collect(Collectors.toMap(UserEntity::getId, UserEntity::getName));
|
Map<UUID, String> userNameMap = users == null ? new HashMap<>() : users.stream().collect(Collectors.toMap(UserEntity::getId, UserEntity::getName));
|
||||||
for (DmpUserEntity d : data) {
|
for (DmpUserEntity d : data) {
|
||||||
NestedCollaboratorElasticEntity m = new NestedCollaboratorElasticEntity();
|
NestedCollaboratorElasticEntity m = new NestedCollaboratorElasticEntity();
|
||||||
m.setId(d.getId());
|
m.setId(d.getId());
|
||||||
|
|
|
@ -13,7 +13,7 @@ import org.opencdmp.convention.ConventionService;
|
||||||
import org.opencdmp.data.DescriptionTagEntity;
|
import org.opencdmp.data.DescriptionTagEntity;
|
||||||
import org.opencdmp.model.DescriptionTag;
|
import org.opencdmp.model.DescriptionTag;
|
||||||
import org.opencdmp.model.Tag;
|
import org.opencdmp.model.Tag;
|
||||||
import org.opencdmp.model.builder.descriptionproperties.DescriptionBuilder;
|
import org.opencdmp.model.builder.description.DescriptionBuilder;
|
||||||
import org.opencdmp.model.description.Description;
|
import org.opencdmp.model.description.Description;
|
||||||
import org.opencdmp.query.DescriptionQuery;
|
import org.opencdmp.query.DescriptionQuery;
|
||||||
import org.opencdmp.query.TagQuery;
|
import org.opencdmp.query.TagQuery;
|
||||||
|
|
|
@ -12,7 +12,7 @@ import org.opencdmp.commons.enums.RecentActivityItemType;
|
||||||
import org.opencdmp.commons.types.dashborad.RecentActivityItemEntity;
|
import org.opencdmp.commons.types.dashborad.RecentActivityItemEntity;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
import org.opencdmp.model.RecentActivityItem;
|
import org.opencdmp.model.RecentActivityItem;
|
||||||
import org.opencdmp.model.builder.descriptionproperties.DescriptionBuilder;
|
import org.opencdmp.model.builder.description.DescriptionBuilder;
|
||||||
import org.opencdmp.model.builder.dmp.DmpBuilder;
|
import org.opencdmp.model.builder.dmp.DmpBuilder;
|
||||||
import org.opencdmp.model.description.Description;
|
import org.opencdmp.model.description.Description;
|
||||||
import org.opencdmp.model.dmp.Dmp;
|
import org.opencdmp.model.dmp.Dmp;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.opencdmp.model.builder.descriptionproperties;
|
package org.opencdmp.model.builder.description;
|
||||||
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
|
@ -1,16 +1,16 @@
|
||||||
package org.opencdmp.model.builder.descriptionproperties;
|
package org.opencdmp.model.builder.description;
|
||||||
|
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import org.opencdmp.authorization.AuthorizationFlags;
|
import org.opencdmp.authorization.AuthorizationFlags;
|
||||||
import org.opencdmp.commons.types.description.ExternalIdentifierEntity;
|
import org.opencdmp.commons.types.description.ExternalIdentifierEntity;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
import org.opencdmp.model.builder.BaseBuilder;
|
import org.opencdmp.model.builder.BaseBuilder;
|
||||||
import org.opencdmp.model.description.ExternalIdentifier;
|
import org.opencdmp.model.description.ExternalIdentifier;
|
||||||
import org.opencdmp.service.fielddatahelper.FieldDataHelperServiceProvider;
|
import org.opencdmp.service.fielddatahelper.FieldDataHelperServiceProvider;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
|
||||||
import gr.cite.tools.logging.DataLogEntry;
|
|
||||||
import gr.cite.tools.logging.LoggerService;
|
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
@ -20,7 +20,7 @@ import org.springframework.stereotype.Component;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Component("description.ExternalIdentifierBuilder")
|
@Component("description.ExternalIdentifierBuilder")
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class ExternalIdentifierBuilder extends BaseBuilder<ExternalIdentifier, ExternalIdentifierEntity> {
|
public class ExternalIdentifierBuilder extends BaseBuilder<ExternalIdentifier, ExternalIdentifierEntity> {
|
||||||
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
|
@ -1,4 +1,4 @@
|
||||||
package org.opencdmp.model.builder.descriptionproperties;
|
package org.opencdmp.model.builder.description;
|
||||||
|
|
||||||
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;
|
|
@ -1,27 +1,27 @@
|
||||||
package org.opencdmp.model.builder.descriptionproperties;
|
package org.opencdmp.model.builder.description;
|
||||||
|
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import org.opencdmp.authorization.AuthorizationFlags;
|
import org.opencdmp.authorization.AuthorizationFlags;
|
||||||
import org.opencdmp.commons.types.description.PropertyDefinitionEntity;
|
import org.opencdmp.commons.types.description.PropertyDefinitionEntity;
|
||||||
import org.opencdmp.commons.types.descriptiontemplate.DefinitionEntity;
|
import org.opencdmp.commons.types.descriptiontemplate.DefinitionEntity;
|
||||||
import org.opencdmp.commons.types.descriptiontemplate.FieldSetEntity;
|
import org.opencdmp.commons.types.descriptiontemplate.FieldSetEntity;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
import org.opencdmp.model.builder.BaseBuilder;
|
import org.opencdmp.model.builder.BaseBuilder;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import org.opencdmp.model.description.PropertyDefinition;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
|
||||||
import gr.cite.tools.logging.DataLogEntry;
|
|
||||||
import gr.cite.tools.logging.LoggerService;
|
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.opencdmp.model.description.PropertyDefinition;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Component("descriptionpropertiesdefinitionbuilder")
|
@Component("descriptionpropertiesdefinitionbuilder")
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class PropertyDefinitionBuilder extends BaseBuilder<PropertyDefinition, PropertyDefinitionEntity> {
|
public class PropertyDefinitionBuilder extends BaseBuilder<PropertyDefinition, PropertyDefinitionEntity> {
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
|
@ -61,7 +61,7 @@ public class PropertyDefinitionBuilder extends BaseBuilder<PropertyDefinition, P
|
||||||
if (!fieldsFields.isEmpty() && d.getFieldSets() != null && !d.getFieldSets().isEmpty()) {
|
if (!fieldsFields.isEmpty() && d.getFieldSets() != null && !d.getFieldSets().isEmpty()) {
|
||||||
m.setFieldSets(new HashMap<>());
|
m.setFieldSets(new HashMap<>());
|
||||||
for (String key : d.getFieldSets().keySet()){
|
for (String key : d.getFieldSets().keySet()){
|
||||||
FieldSetEntity fieldSetEntity = definition != null ? definition.getFieldSetById(key).stream().findFirst().orElse(null) : null;
|
FieldSetEntity fieldSetEntity = this.definition != null ? this.definition.getFieldSetById(key).stream().findFirst().orElse(null) : null;
|
||||||
m.getFieldSets().put(key, this.builderFactory.builder(PropertyDefinitionFieldSetBuilder.class).authorize(this.authorize).withFieldSetEntity(fieldSetEntity).build(fieldsFields, d.getFieldSets().get(key)));
|
m.getFieldSets().put(key, this.builderFactory.builder(PropertyDefinitionFieldSetBuilder.class).authorize(this.authorize).withFieldSetEntity(fieldSetEntity).build(fieldsFields, d.getFieldSets().get(key)));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,16 +1,16 @@
|
||||||
package org.opencdmp.model.builder.descriptionproperties;
|
package org.opencdmp.model.builder.description;
|
||||||
|
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import org.opencdmp.authorization.AuthorizationFlags;
|
import org.opencdmp.authorization.AuthorizationFlags;
|
||||||
import org.opencdmp.commons.types.description.PropertyDefinitionFieldSetEntity;
|
import org.opencdmp.commons.types.description.PropertyDefinitionFieldSetEntity;
|
||||||
import org.opencdmp.commons.types.descriptiontemplate.FieldSetEntity;
|
import org.opencdmp.commons.types.descriptiontemplate.FieldSetEntity;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
import org.opencdmp.model.builder.BaseBuilder;
|
import org.opencdmp.model.builder.BaseBuilder;
|
||||||
import org.opencdmp.model.description.PropertyDefinitionFieldSet;
|
import org.opencdmp.model.description.PropertyDefinitionFieldSet;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
|
||||||
import gr.cite.tools.logging.DataLogEntry;
|
|
||||||
import gr.cite.tools.logging.LoggerService;
|
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
@ -20,7 +20,7 @@ import org.springframework.stereotype.Component;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Component("description.PropertyDefinitionFieldSet")
|
@Component("description.PropertyDefinitionFieldSet")
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class PropertyDefinitionFieldSetBuilder extends BaseBuilder<PropertyDefinitionFieldSet, PropertyDefinitionFieldSetEntity> {
|
public class PropertyDefinitionFieldSetBuilder extends BaseBuilder<PropertyDefinitionFieldSet, PropertyDefinitionFieldSetEntity> {
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
|
@ -1,5 +1,10 @@
|
||||||
package org.opencdmp.model.builder.descriptionproperties;
|
package org.opencdmp.model.builder.description;
|
||||||
|
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import org.opencdmp.authorization.AuthorizationFlags;
|
import org.opencdmp.authorization.AuthorizationFlags;
|
||||||
import org.opencdmp.commons.types.description.PropertyDefinitionFieldSetItemEntity;
|
import org.opencdmp.commons.types.description.PropertyDefinitionFieldSetItemEntity;
|
||||||
import org.opencdmp.commons.types.descriptiontemplate.FieldEntity;
|
import org.opencdmp.commons.types.descriptiontemplate.FieldEntity;
|
||||||
|
@ -7,11 +12,6 @@ import org.opencdmp.commons.types.descriptiontemplate.FieldSetEntity;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
import org.opencdmp.model.builder.BaseBuilder;
|
import org.opencdmp.model.builder.BaseBuilder;
|
||||||
import org.opencdmp.model.description.PropertyDefinitionFieldSetItem;
|
import org.opencdmp.model.description.PropertyDefinitionFieldSetItem;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
|
||||||
import gr.cite.tools.logging.DataLogEntry;
|
|
||||||
import gr.cite.tools.logging.LoggerService;
|
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
@ -21,7 +21,7 @@ import org.springframework.stereotype.Component;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Component("description.PropertyDefinitionFieldSetItemBuilder")
|
@Component("description.PropertyDefinitionFieldSetItemBuilder")
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class PropertyDefinitionFieldSetItemBuilder extends BaseBuilder<PropertyDefinitionFieldSetItem, PropertyDefinitionFieldSetItemEntity> {
|
public class PropertyDefinitionFieldSetItemBuilder extends BaseBuilder<PropertyDefinitionFieldSetItem, PropertyDefinitionFieldSetItemEntity> {
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
|
@ -63,7 +63,7 @@ public class PropertyDefinitionFieldSetItemBuilder extends BaseBuilder<PropertyD
|
||||||
if (!fieldsFields.isEmpty() && d.getFields() != null && !d.getFields().isEmpty()) {
|
if (!fieldsFields.isEmpty() && d.getFields() != null && !d.getFields().isEmpty()) {
|
||||||
m.setFields(new HashMap<>());
|
m.setFields(new HashMap<>());
|
||||||
for (String key : d.getFields().keySet()){
|
for (String key : d.getFields().keySet()){
|
||||||
FieldEntity fieldEntity = fieldSetEntity != null ? fieldSetEntity.getFieldById(key).stream().findFirst().orElse(null) : null;
|
FieldEntity fieldEntity = this.fieldSetEntity != null ? this.fieldSetEntity.getFieldById(key).stream().findFirst().orElse(null) : null;
|
||||||
m.getFields().put(key, this.builderFactory.builder(FieldBuilder.class).authorize(this.authorize).withFieldEntity(fieldEntity).build(fieldsFields, d.getFields().get(key)));
|
m.getFields().put(key, this.builderFactory.builder(FieldBuilder.class).authorize(this.authorize).withFieldEntity(fieldEntity).build(fieldsFields, d.getFields().get(key)));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@ import org.opencdmp.commons.types.descriptionreference.DescriptionReferenceDataE
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
import org.opencdmp.data.DescriptionReferenceEntity;
|
import org.opencdmp.data.DescriptionReferenceEntity;
|
||||||
import org.opencdmp.model.builder.BaseBuilder;
|
import org.opencdmp.model.builder.BaseBuilder;
|
||||||
import org.opencdmp.model.builder.descriptionproperties.DescriptionBuilder;
|
import org.opencdmp.model.builder.description.DescriptionBuilder;
|
||||||
import org.opencdmp.model.builder.reference.ReferenceBuilder;
|
import org.opencdmp.model.builder.reference.ReferenceBuilder;
|
||||||
import org.opencdmp.model.description.Description;
|
import org.opencdmp.model.description.Description;
|
||||||
import org.opencdmp.model.descriptionreference.DescriptionReference;
|
import org.opencdmp.model.descriptionreference.DescriptionReference;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.opencdmp.model.DmpDescriptionTemplate;
|
||||||
import org.opencdmp.model.DmpUser;
|
import org.opencdmp.model.DmpUser;
|
||||||
import org.opencdmp.model.EntityDoi;
|
import org.opencdmp.model.EntityDoi;
|
||||||
import org.opencdmp.model.builder.*;
|
import org.opencdmp.model.builder.*;
|
||||||
import org.opencdmp.model.builder.descriptionproperties.DescriptionBuilder;
|
import org.opencdmp.model.builder.description.DescriptionBuilder;
|
||||||
import org.opencdmp.model.builder.dmpblueprint.DmpBlueprintBuilder;
|
import org.opencdmp.model.builder.dmpblueprint.DmpBlueprintBuilder;
|
||||||
import org.opencdmp.model.builder.dmpreference.DmpReferenceBuilder;
|
import org.opencdmp.model.builder.dmpreference.DmpReferenceBuilder;
|
||||||
import org.opencdmp.model.description.Description;
|
import org.opencdmp.model.description.Description;
|
||||||
|
|
|
@ -45,7 +45,7 @@ import org.opencdmp.model.DescriptionValidationResult;
|
||||||
import org.opencdmp.model.DmpDescriptionTemplate;
|
import org.opencdmp.model.DmpDescriptionTemplate;
|
||||||
import org.opencdmp.model.StorageFile;
|
import org.opencdmp.model.StorageFile;
|
||||||
import org.opencdmp.model.UserContactInfo;
|
import org.opencdmp.model.UserContactInfo;
|
||||||
import org.opencdmp.model.builder.descriptionproperties.DescriptionBuilder;
|
import org.opencdmp.model.builder.description.DescriptionBuilder;
|
||||||
import org.opencdmp.model.deleter.DescriptionDeleter;
|
import org.opencdmp.model.deleter.DescriptionDeleter;
|
||||||
import org.opencdmp.model.deleter.DescriptionReferenceDeleter;
|
import org.opencdmp.model.deleter.DescriptionReferenceDeleter;
|
||||||
import org.opencdmp.model.deleter.DescriptionTagDeleter;
|
import org.opencdmp.model.deleter.DescriptionTagDeleter;
|
||||||
|
|
|
@ -13,7 +13,7 @@ import org.opencdmp.model.PublicDescription;
|
||||||
import org.opencdmp.model.PublicDmp;
|
import org.opencdmp.model.PublicDmp;
|
||||||
import org.opencdmp.model.builder.PublicDescriptionBuilder;
|
import org.opencdmp.model.builder.PublicDescriptionBuilder;
|
||||||
import org.opencdmp.model.builder.PublicDmpBuilder;
|
import org.opencdmp.model.builder.PublicDmpBuilder;
|
||||||
import org.opencdmp.model.builder.descriptionproperties.DescriptionBuilder;
|
import org.opencdmp.model.builder.description.DescriptionBuilder;
|
||||||
import org.opencdmp.model.builder.dmp.DmpBuilder;
|
import org.opencdmp.model.builder.dmp.DmpBuilder;
|
||||||
import org.opencdmp.model.description.Description;
|
import org.opencdmp.model.description.Description;
|
||||||
import org.opencdmp.model.dmp.Dmp;
|
import org.opencdmp.model.dmp.Dmp;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.opencdmp.model.DescriptionValidationResult;
|
||||||
import org.opencdmp.model.PublicDescription;
|
import org.opencdmp.model.PublicDescription;
|
||||||
import org.opencdmp.model.StorageFile;
|
import org.opencdmp.model.StorageFile;
|
||||||
import org.opencdmp.model.builder.PublicDescriptionBuilder;
|
import org.opencdmp.model.builder.PublicDescriptionBuilder;
|
||||||
import org.opencdmp.model.builder.descriptionproperties.DescriptionBuilder;
|
import org.opencdmp.model.builder.description.DescriptionBuilder;
|
||||||
import org.opencdmp.model.censorship.PublicDescriptionCensor;
|
import org.opencdmp.model.censorship.PublicDescriptionCensor;
|
||||||
import org.opencdmp.model.censorship.description.DescriptionCensor;
|
import org.opencdmp.model.censorship.description.DescriptionCensor;
|
||||||
import org.opencdmp.model.description.Description;
|
import org.opencdmp.model.description.Description;
|
||||||
|
|
|
@ -20,7 +20,7 @@ import org.opencdmp.controllers.publicapi.types.ApiMessageCode;
|
||||||
import org.opencdmp.controllers.publicapi.types.ResponseItem;
|
import org.opencdmp.controllers.publicapi.types.ResponseItem;
|
||||||
import org.opencdmp.data.DescriptionEntity;
|
import org.opencdmp.data.DescriptionEntity;
|
||||||
import org.opencdmp.model.DmpUser;
|
import org.opencdmp.model.DmpUser;
|
||||||
import org.opencdmp.model.builder.descriptionproperties.DescriptionBuilder;
|
import org.opencdmp.model.builder.description.DescriptionBuilder;
|
||||||
import org.opencdmp.model.builder.dmp.DmpBuilder;
|
import org.opencdmp.model.builder.dmp.DmpBuilder;
|
||||||
import org.opencdmp.model.description.Description;
|
import org.opencdmp.model.description.Description;
|
||||||
import org.opencdmp.model.descriptionreference.DescriptionReference;
|
import org.opencdmp.model.descriptionreference.DescriptionReference;
|
||||||
|
|
|
@ -63,4 +63,4 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -278,8 +278,11 @@ export class VisibilityRulesService {
|
||||||
return field.textValue == rule.textValue;
|
return field.textValue == rule.textValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ([DescriptionTemplateFieldType.SELECT].includes(fieldType) && field.textValue != null && field.textValue.length > 0) {
|
||||||
|
return rule.textValue != null && rule.textValue.length > 0 && field.textValue == rule.textValue;
|
||||||
|
}
|
||||||
else if ([DescriptionTemplateFieldType.SELECT].includes(fieldType) && field.textListValue != null && field.textListValue.length > 0) {
|
else if ([DescriptionTemplateFieldType.SELECT].includes(fieldType) && field.textListValue != null && field.textListValue.length > 0) {
|
||||||
return rule.textValue != null && rule.textValue.length > 0 && field.textListValue.includes(rule.textValue);
|
return field.textListValue.includes(rule.textValue);
|
||||||
}
|
}
|
||||||
else if ([DescriptionTemplateFieldType.REFERENCE_TYPES, DescriptionTemplateFieldType.UPLOAD, DescriptionTemplateFieldType.TAGS, DescriptionTemplateFieldType.INTERNAL_ENTRIES_DMPS,
|
else if ([DescriptionTemplateFieldType.REFERENCE_TYPES, DescriptionTemplateFieldType.UPLOAD, DescriptionTemplateFieldType.TAGS, DescriptionTemplateFieldType.INTERNAL_ENTRIES_DMPS,
|
||||||
DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS, DescriptionTemplateFieldType.VALIDATION, DescriptionTemplateFieldType.DATASET_IDENTIFIER].includes(fieldType)) {
|
DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS, DescriptionTemplateFieldType.VALIDATION, DescriptionTemplateFieldType.DATASET_IDENTIFIER].includes(fieldType)) {
|
||||||
|
|
|
@ -13,7 +13,6 @@ import org.opencdmp.commons.types.referencetype.ReferenceTypeDefinitionEntity;
|
||||||
import org.opencdmp.convention.ConventionService;
|
import org.opencdmp.convention.ConventionService;
|
||||||
import org.opencdmp.data.*;
|
import org.opencdmp.data.*;
|
||||||
import org.opencdmp.model.dmp.Dmp;
|
import org.opencdmp.model.dmp.Dmp;
|
||||||
import org.opencdmp.model.persist.descriptionreference.DescriptionReferenceDataPersist;
|
|
||||||
import org.opencdmp.model.reference.Reference;
|
import org.opencdmp.model.reference.Reference;
|
||||||
import org.opencdmp.model.referencetype.ReferenceType;
|
import org.opencdmp.model.referencetype.ReferenceType;
|
||||||
import org.opencdmp.query.*;
|
import org.opencdmp.query.*;
|
||||||
|
@ -53,6 +52,7 @@ public class DatasetMigrationService {
|
||||||
private final XmlHandlingService xmlHandlingService;
|
private final XmlHandlingService xmlHandlingService;
|
||||||
private static final int PageSize = 500;
|
private static final int PageSize = 500;
|
||||||
private static final boolean TestMode = false;
|
private static final boolean TestMode = false;
|
||||||
|
private static final int SimpleFieldSetOrdinal = -512;
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
private final ConventionService conventionService;
|
private final ConventionService conventionService;
|
||||||
private final MigrationTools migrationTools;
|
private final MigrationTools migrationTools;
|
||||||
|
@ -197,22 +197,23 @@ public class DatasetMigrationService {
|
||||||
List<FieldSetEntity> fieldSetEntities = descriptionTemplateDefinitionEntity.getAllFieldSets();
|
List<FieldSetEntity> fieldSetEntities = descriptionTemplateDefinitionEntity.getAllFieldSets();
|
||||||
|
|
||||||
for (String key : properties.keySet()) {
|
for (String key : properties.keySet()) {
|
||||||
if (key.toLowerCase(Locale.ROOT).trim().startsWith("commentfieldvalue")){
|
String finalKey = key.trim();
|
||||||
if (properties.get(key) != null && this.conventionService.isNullOrEmpty(properties.get(key).toString())) { continue; }
|
if (finalKey.toLowerCase(Locale.ROOT).trim().startsWith("commentfieldvalue")){
|
||||||
FieldSetEntity currentFieldSet = fieldSetEntities.stream().filter(x-> x.getId().equals(key.trim().substring("commentfieldvalue".length()))).findFirst().orElse(null);
|
if (properties.get(finalKey) != null && this.conventionService.isNullOrEmpty(properties.get(finalKey).toString())) { continue; }
|
||||||
|
FieldSetEntity currentFieldSet = fieldSetEntities.stream().filter(x-> x.getId().trim().equals(finalKey.trim().substring("commentfieldvalue".length()))).findFirst().orElse(null);
|
||||||
|
|
||||||
if (currentFieldSet == null) {
|
if (currentFieldSet == null) {
|
||||||
logger.error("Migrate Dataset " + item.getId() + " " + item.getLabel() + " Field set " + key + " not found for comment " + properties.get(key).toString());
|
logger.error("Migrate Dataset " + item.getId() + " " + item.getLabel() + " Field set " + finalKey + " not found for comment " + properties.get(finalKey).toString());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addSimpleCommentField(propertyDefinitionEntity, currentFieldSet, properties.get(key).toString());
|
this.addSimpleCommentField(propertyDefinitionEntity, currentFieldSet, properties.get(finalKey).toString());
|
||||||
} else {
|
} else {
|
||||||
if (!key.toLowerCase(Locale.ROOT).trim().startsWith("multiple_")) {
|
if (!finalKey.toLowerCase(Locale.ROOT).trim().startsWith("multiple_")) {
|
||||||
FieldSetEntity currentFieldSet = null;
|
FieldSetEntity currentFieldSet = null;
|
||||||
org.opencdmp.commons.types.descriptiontemplate.FieldEntity currentField = null;
|
org.opencdmp.commons.types.descriptiontemplate.FieldEntity currentField = null;
|
||||||
for (FieldSetEntity fieldSetEntity : fieldSetEntities) {
|
for (FieldSetEntity fieldSetEntity : fieldSetEntities) {
|
||||||
List<org.opencdmp.commons.types.descriptiontemplate.FieldEntity> fieldEntities = fieldSetEntity.getFieldById(key.trim());
|
List<org.opencdmp.commons.types.descriptiontemplate.FieldEntity> fieldEntities = fieldSetEntity.getFieldById(finalKey.trim());
|
||||||
if (!fieldEntities.isEmpty()) {
|
if (!fieldEntities.isEmpty()) {
|
||||||
currentFieldSet = fieldSetEntity;
|
currentFieldSet = fieldSetEntity;
|
||||||
currentField = fieldEntities.getFirst();
|
currentField = fieldEntities.getFirst();
|
||||||
|
@ -220,7 +221,7 @@ public class DatasetMigrationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentField == null) {
|
if (currentField == null) {
|
||||||
logger.error("Migrate Dataset " + item.getId() + " " + item.getLabel() + " Field set not found for field " + key + " " + properties.get(key).toString());
|
logger.error("Migrate Dataset " + item.getId() + " " + item.getLabel() + " Field set not found for field " + finalKey + " " + properties.get(finalKey).toString());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,11 +234,16 @@ public class DatasetMigrationService {
|
||||||
|
|
||||||
for (PropertyDefinitionFieldSetEntity fieldSetEntity : propertyDefinitionEntity.getFieldSets().values()){
|
for (PropertyDefinitionFieldSetEntity fieldSetEntity : propertyDefinitionEntity.getFieldSets().values()){
|
||||||
int newOrdinal = 0;
|
int newOrdinal = 0;
|
||||||
for (PropertyDefinitionFieldSetItemEntity propertyDefinitionFieldSetItemEntity : fieldSetEntity.getItems().stream().filter(x-> x.getOrdinal() >= 0).sorted(Comparator.comparingInt(PropertyDefinitionFieldSetItemEntity::getOrdinal)).toList()){
|
PropertyDefinitionFieldSetItemEntity firstFieldSet = fieldSetEntity.getItems().stream().findFirst().filter(x-> x.getOrdinal() == SimpleFieldSetOrdinal).orElse(null);
|
||||||
|
if (firstFieldSet != null){
|
||||||
|
firstFieldSet.setOrdinal(newOrdinal);
|
||||||
|
newOrdinal++;
|
||||||
|
}
|
||||||
|
for (PropertyDefinitionFieldSetItemEntity propertyDefinitionFieldSetItemEntity : fieldSetEntity.getItems().stream().filter(x-> x.getOrdinal() >= 0 && x.getOrdinal() != SimpleFieldSetOrdinal).sorted(Comparator.comparingInt(PropertyDefinitionFieldSetItemEntity::getOrdinal)).toList()){
|
||||||
propertyDefinitionFieldSetItemEntity.setOrdinal(newOrdinal);
|
propertyDefinitionFieldSetItemEntity.setOrdinal(newOrdinal);
|
||||||
newOrdinal++;
|
newOrdinal++;
|
||||||
}
|
}
|
||||||
for (PropertyDefinitionFieldSetItemEntity propertyDefinitionFieldSetItemEntity : fieldSetEntity.getItems().stream().filter(x-> x.getOrdinal() < 0).sorted(Comparator.comparingInt(PropertyDefinitionFieldSetItemEntity::getOrdinal)).toList()){
|
for (PropertyDefinitionFieldSetItemEntity propertyDefinitionFieldSetItemEntity : fieldSetEntity.getItems().stream().filter(x-> x.getOrdinal() < 0 && x.getOrdinal() != SimpleFieldSetOrdinal).sorted(Comparator.comparingInt(PropertyDefinitionFieldSetItemEntity::getOrdinal)).toList()){
|
||||||
propertyDefinitionFieldSetItemEntity.setOrdinal(newOrdinal);
|
propertyDefinitionFieldSetItemEntity.setOrdinal(newOrdinal);
|
||||||
newOrdinal++;
|
newOrdinal++;
|
||||||
}
|
}
|
||||||
|
@ -306,6 +312,8 @@ public class DatasetMigrationService {
|
||||||
} else {
|
} else {
|
||||||
if (groupOrdinalMapping.get(new MultipleFieldKey(fieldSetId, groupId)) != ordinal) throw new MyApplicationException("Invalid multiple key ordinal " + key);
|
if (groupOrdinalMapping.get(new MultipleFieldKey(fieldSetId, groupId)) != ordinal) throw new MyApplicationException("Invalid multiple key ordinal " + key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ordinal == SimpleFieldSetOrdinal) throw new MyApplicationException("Fieldset has migration simple fieldset ordinal " + SimpleFieldSetOrdinal);
|
||||||
|
|
||||||
this.addMultipleField(item, propertyDefinitionFieldSetEntity, ordinal, currentField, properties, referenceTypeDefinitionEntityMap, referenceMap);
|
this.addMultipleField(item, propertyDefinitionFieldSetEntity, ordinal, currentField, properties, referenceTypeDefinitionEntityMap, referenceMap);
|
||||||
|
|
||||||
|
@ -323,44 +331,44 @@ public class DatasetMigrationService {
|
||||||
propertyDefinitionFieldSetEntity.getItems().add(propertyDefinitionFieldSetItemEntity);
|
propertyDefinitionFieldSetEntity.getItems().add(propertyDefinitionFieldSetItemEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
propertyDefinitionFieldSetItemEntity.getFields().put(currentField.getId(), this.buildField(item, currentField, properties, referenceTypeDefinitionEntityMap, referenceMap));
|
propertyDefinitionFieldSetItemEntity.getFields().put(currentField.getId().trim(), this.buildField(item, currentField, properties, referenceTypeDefinitionEntityMap, referenceMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSimpleField(Dataset item, PropertyDefinitionEntity propertyDefinitionEntity, FieldSetEntity currentFieldSet, org.opencdmp.commons.types.descriptiontemplate.FieldEntity currentField, Map<String, Object> properties, Map<UUID, ReferenceTypeDefinitionEntity> referenceTypeDefinitionEntityMap, Map<ReferenceKey, ReferenceEntity> referenceMap){
|
private void addSimpleField(Dataset item, PropertyDefinitionEntity propertyDefinitionEntity, FieldSetEntity currentFieldSet, org.opencdmp.commons.types.descriptiontemplate.FieldEntity currentField, Map<String, Object> properties, Map<UUID, ReferenceTypeDefinitionEntity> referenceTypeDefinitionEntityMap, Map<ReferenceKey, ReferenceEntity> referenceMap){
|
||||||
PropertyDefinitionFieldSetEntity propertyDefinitionFieldSetEntity = propertyDefinitionEntity.getFieldSets().getOrDefault(currentFieldSet.getId(), null);
|
PropertyDefinitionFieldSetEntity propertyDefinitionFieldSetEntity = propertyDefinitionEntity.getFieldSets().getOrDefault(currentFieldSet.getId().trim(), null);
|
||||||
if (propertyDefinitionFieldSetEntity == null) {
|
if (propertyDefinitionFieldSetEntity == null) {
|
||||||
propertyDefinitionFieldSetEntity = new PropertyDefinitionFieldSetEntity();
|
propertyDefinitionFieldSetEntity = new PropertyDefinitionFieldSetEntity();
|
||||||
propertyDefinitionFieldSetEntity.setItems(new ArrayList<>());
|
propertyDefinitionFieldSetEntity.setItems(new ArrayList<>());
|
||||||
propertyDefinitionEntity.getFieldSets().put(currentFieldSet.getId(), propertyDefinitionFieldSetEntity);
|
propertyDefinitionEntity.getFieldSets().put(currentFieldSet.getId().trim(), propertyDefinitionFieldSetEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyDefinitionFieldSetItemEntity propertyDefinitionFieldSetItemEntity = null;
|
PropertyDefinitionFieldSetItemEntity propertyDefinitionFieldSetItemEntity = null;
|
||||||
if (this.conventionService.isListNullOrEmpty(propertyDefinitionFieldSetEntity.getItems())){
|
if (this.conventionService.isListNullOrEmpty(propertyDefinitionFieldSetEntity.getItems())){
|
||||||
propertyDefinitionFieldSetItemEntity = new PropertyDefinitionFieldSetItemEntity();
|
propertyDefinitionFieldSetItemEntity = new PropertyDefinitionFieldSetItemEntity();
|
||||||
propertyDefinitionFieldSetItemEntity.setFields(new HashMap<>());
|
propertyDefinitionFieldSetItemEntity.setFields(new HashMap<>());
|
||||||
propertyDefinitionFieldSetItemEntity.setOrdinal(0);
|
propertyDefinitionFieldSetItemEntity.setOrdinal(SimpleFieldSetOrdinal);
|
||||||
propertyDefinitionFieldSetEntity.getItems().add(propertyDefinitionFieldSetItemEntity);
|
propertyDefinitionFieldSetEntity.getItems().add(propertyDefinitionFieldSetItemEntity);
|
||||||
} else {
|
} else {
|
||||||
propertyDefinitionFieldSetItemEntity = propertyDefinitionFieldSetEntity.getItems().getFirst();
|
propertyDefinitionFieldSetItemEntity = propertyDefinitionFieldSetEntity.getItems().getFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
propertyDefinitionFieldSetItemEntity.getFields().put(currentField.getId(), this.buildField(item, currentField, properties, referenceTypeDefinitionEntityMap, referenceMap));
|
propertyDefinitionFieldSetItemEntity.getFields().put(currentField.getId().trim(), this.buildField(item, currentField, properties, referenceTypeDefinitionEntityMap, referenceMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void addSimpleCommentField(PropertyDefinitionEntity propertyDefinitionEntity, FieldSetEntity currentFieldSet, String comment){
|
private void addSimpleCommentField(PropertyDefinitionEntity propertyDefinitionEntity, FieldSetEntity currentFieldSet, String comment){
|
||||||
PropertyDefinitionFieldSetEntity propertyDefinitionFieldSetEntity = propertyDefinitionEntity.getFieldSets().getOrDefault(currentFieldSet.getId(), null);
|
PropertyDefinitionFieldSetEntity propertyDefinitionFieldSetEntity = propertyDefinitionEntity.getFieldSets().getOrDefault(currentFieldSet.getId().trim(), null);
|
||||||
if (propertyDefinitionFieldSetEntity == null) {
|
if (propertyDefinitionFieldSetEntity == null) {
|
||||||
propertyDefinitionFieldSetEntity = new PropertyDefinitionFieldSetEntity();
|
propertyDefinitionFieldSetEntity = new PropertyDefinitionFieldSetEntity();
|
||||||
propertyDefinitionFieldSetEntity.setItems(new ArrayList<>());
|
propertyDefinitionFieldSetEntity.setItems(new ArrayList<>());
|
||||||
propertyDefinitionEntity.getFieldSets().put(currentFieldSet.getId(), propertyDefinitionFieldSetEntity);
|
propertyDefinitionEntity.getFieldSets().put(currentFieldSet.getId().trim(), propertyDefinitionFieldSetEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyDefinitionFieldSetItemEntity propertyDefinitionFieldSetItemEntity = null;
|
PropertyDefinitionFieldSetItemEntity propertyDefinitionFieldSetItemEntity = null;
|
||||||
if (this.conventionService.isListNullOrEmpty(propertyDefinitionFieldSetEntity.getItems())){
|
if (this.conventionService.isListNullOrEmpty(propertyDefinitionFieldSetEntity.getItems())){
|
||||||
propertyDefinitionFieldSetItemEntity = new PropertyDefinitionFieldSetItemEntity();
|
propertyDefinitionFieldSetItemEntity = new PropertyDefinitionFieldSetItemEntity();
|
||||||
propertyDefinitionFieldSetItemEntity.setFields(new HashMap<>());
|
propertyDefinitionFieldSetItemEntity.setFields(new HashMap<>());
|
||||||
propertyDefinitionFieldSetItemEntity.setOrdinal(0);
|
propertyDefinitionFieldSetItemEntity.setOrdinal(SimpleFieldSetOrdinal);
|
||||||
propertyDefinitionFieldSetEntity.getItems().add(propertyDefinitionFieldSetItemEntity);
|
propertyDefinitionFieldSetEntity.getItems().add(propertyDefinitionFieldSetItemEntity);
|
||||||
} else {
|
} else {
|
||||||
propertyDefinitionFieldSetItemEntity = propertyDefinitionFieldSetEntity.getItems().getFirst();
|
propertyDefinitionFieldSetItemEntity = propertyDefinitionFieldSetEntity.getItems().getFirst();
|
||||||
|
@ -1021,7 +1029,7 @@ public class DatasetMigrationService {
|
||||||
|
|
||||||
private @NotNull DescriptionReferenceDataEntity buildDescriptionReferenceDataEntity(org.opencdmp.commons.types.descriptiontemplate.FieldEntity currentField){
|
private @NotNull DescriptionReferenceDataEntity buildDescriptionReferenceDataEntity(org.opencdmp.commons.types.descriptiontemplate.FieldEntity currentField){
|
||||||
DescriptionReferenceDataEntity data = new DescriptionReferenceDataEntity();
|
DescriptionReferenceDataEntity data = new DescriptionReferenceDataEntity();
|
||||||
data.setFieldId(currentField.getId());
|
data.setFieldId(currentField.getId().trim());
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,8 @@
|
||||||
package eu.old.eudat.migration;
|
package eu.old.eudat.migration;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonValue;
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
import eu.old.eudat.models.data.components.commons.DefaultValue;
|
|
||||||
import org.opencdmp.commons.XmlHandlingService;
|
|
||||||
import org.opencdmp.commons.enums.*;
|
|
||||||
import org.opencdmp.commons.types.descriptiontemplate.*;
|
|
||||||
import org.opencdmp.commons.types.descriptiontemplate.fielddata.*;
|
|
||||||
import org.opencdmp.commons.types.externalfetcher.*;
|
|
||||||
import org.opencdmp.commons.types.referencetype.*;
|
|
||||||
import org.opencdmp.convention.ConventionService;
|
|
||||||
import org.opencdmp.data.DescriptionTemplateEntity;
|
|
||||||
import org.opencdmp.data.ReferenceEntity;
|
|
||||||
import org.opencdmp.data.ReferenceTypeEntity;
|
|
||||||
import org.opencdmp.data.converters.enums.DatabaseEnum;
|
|
||||||
import org.opencdmp.model.descriptiontemplate.DescriptionTemplate;
|
|
||||||
import org.opencdmp.query.DescriptionTemplateQuery;
|
|
||||||
import org.opencdmp.query.ReferenceTypeQuery;
|
|
||||||
import eu.old.eudat.logic.services.helpers.HelpersService;
|
|
||||||
import eu.old.eudat.logic.utilities.builders.XmlBuilder;
|
import eu.old.eudat.logic.utilities.builders.XmlBuilder;
|
||||||
|
import eu.old.eudat.models.data.components.commons.DefaultValue;
|
||||||
import eu.old.eudat.models.data.components.commons.Multiplicity;
|
import eu.old.eudat.models.data.components.commons.Multiplicity;
|
||||||
import eu.old.eudat.models.data.components.commons.Rule;
|
import eu.old.eudat.models.data.components.commons.Rule;
|
||||||
import eu.old.eudat.models.data.components.commons.datafield.*;
|
import eu.old.eudat.models.data.components.commons.datafield.*;
|
||||||
|
@ -31,8 +16,21 @@ import jakarta.persistence.EntityManager;
|
||||||
import jakarta.ws.rs.NotSupportedException;
|
import jakarta.ws.rs.NotSupportedException;
|
||||||
import jakarta.xml.bind.JAXBException;
|
import jakarta.xml.bind.JAXBException;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.elasticsearch.common.inject.Guice;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.opencdmp.commons.XmlHandlingService;
|
||||||
|
import org.opencdmp.commons.enums.*;
|
||||||
|
import org.opencdmp.commons.types.descriptiontemplate.*;
|
||||||
|
import org.opencdmp.commons.types.descriptiontemplate.fielddata.*;
|
||||||
|
import org.opencdmp.commons.types.externalfetcher.*;
|
||||||
|
import org.opencdmp.commons.types.referencetype.ReferenceTypeDefinitionEntity;
|
||||||
|
import org.opencdmp.convention.ConventionService;
|
||||||
|
import org.opencdmp.data.DescriptionTemplateEntity;
|
||||||
|
import org.opencdmp.data.ReferenceEntity;
|
||||||
|
import org.opencdmp.data.ReferenceTypeEntity;
|
||||||
|
import org.opencdmp.data.converters.enums.DatabaseEnum;
|
||||||
|
import org.opencdmp.model.descriptiontemplate.DescriptionTemplate;
|
||||||
|
import org.opencdmp.query.DescriptionTemplateQuery;
|
||||||
|
import org.opencdmp.query.ReferenceTypeQuery;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -128,7 +126,7 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
Map<String, List<Section>> sectionPerPage = mapSectionsToPage(persist);
|
Map<String, List<Section>> sectionPerPage = mapSectionsToPage(persist);
|
||||||
data.setPages(new ArrayList<>());
|
data.setPages(new ArrayList<>());
|
||||||
for (Page pagePersist : persist.getPages()) {
|
for (Page pagePersist : persist.getPages()) {
|
||||||
data.getPages().add(this.buildPageEntity(pagePersist, sectionPerPage.get(pagePersist.getId()), referenceTypeEntityMap, knownReferenceEntities));
|
data.getPages().add(this.buildPageEntity(pagePersist, sectionPerPage.get(pagePersist.getId().trim()), referenceTypeEntityMap, knownReferenceEntities));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +138,7 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
if (persist == null)
|
if (persist == null)
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
data.setId(persist.getId());
|
data.setId(persist.getId().trim());
|
||||||
data.setDescription(persist.getDescription());
|
data.setDescription(persist.getDescription());
|
||||||
data.setExtendedDescription(persist.getExtendedDescription());
|
data.setExtendedDescription(persist.getExtendedDescription());
|
||||||
data.setOrdinal(persist.getOrdinal());
|
data.setOrdinal(persist.getOrdinal());
|
||||||
|
@ -168,7 +166,7 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
if (persist == null)
|
if (persist == null)
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
data.setId(persist.getId());
|
data.setId(persist.getId().trim());
|
||||||
data.setOrdinal(persist.getOrdinal());
|
data.setOrdinal(persist.getOrdinal());
|
||||||
data.setTitle(persist.getTitle());
|
data.setTitle(persist.getTitle());
|
||||||
data.setDescription(persist.getDescription());
|
data.setDescription(persist.getDescription());
|
||||||
|
@ -193,7 +191,7 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
if (persist == null)
|
if (persist == null)
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
data.setId(persist.getId());
|
data.setId(persist.getId().trim());
|
||||||
data.setOrdinal(persist.getOrdinal());
|
data.setOrdinal(persist.getOrdinal());
|
||||||
data.setSchematics(persist.getSchematics());
|
data.setSchematics(persist.getSchematics());
|
||||||
if (persist.getValidations() != null) data.setValidations(persist.getValidations().stream().map(x-> {
|
if (persist.getValidations() != null) data.setValidations(persist.getValidations().stream().map(x-> {
|
||||||
|
@ -455,7 +453,7 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
String textValue = persist.getValue();
|
String textValue = persist.getValue();
|
||||||
if (textValue == null || textValue.isEmpty()) return data;
|
if (textValue == null || textValue.isEmpty()) return data;
|
||||||
|
|
||||||
data.setTarget(persist.getTarget());
|
data.setTarget(persist.getTarget().trim());
|
||||||
switch (fieldType){
|
switch (fieldType){
|
||||||
case FREE_TEXT, TEXT_AREA, RICH_TEXT_AREA, RADIO_BOX -> data.setTextValue(textValue.trim());
|
case FREE_TEXT, TEXT_AREA, RICH_TEXT_AREA, RADIO_BOX -> data.setTextValue(textValue.trim());
|
||||||
case CHECK_BOX, BOOLEAN_DECISION -> {
|
case CHECK_BOX, BOOLEAN_DECISION -> {
|
||||||
|
@ -477,7 +475,7 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
case SELECT -> {
|
case SELECT -> {
|
||||||
if(!this.conventionService.isNullOrEmpty(textValue)) {
|
if(!this.conventionService.isNullOrEmpty(textValue)) {
|
||||||
String[] valuesParsed = migrationTools.tryParseJsonAsObjectString(String[].class, textValue);
|
String[] valuesParsed = migrationTools.tryParseJsonAsObjectString(String[].class, textValue);
|
||||||
data.setTextValue(valuesParsed != null && valuesParsed.length > 0 ? valuesParsed[0] : null);
|
data.setTextValue(valuesParsed != null && valuesParsed.length > 0 ? valuesParsed[0] : textValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case DATASET_IDENTIFIER -> {
|
case DATASET_IDENTIFIER -> {
|
||||||
|
@ -519,7 +517,7 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
if (persist == null)
|
if (persist == null)
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
data.setId(persist.getId());
|
data.setId(persist.getId().trim());
|
||||||
data.setOrdinal(persist.getOrdinal());
|
data.setOrdinal(persist.getOrdinal());
|
||||||
data.setTitle(persist.getTitle());
|
data.setTitle(persist.getTitle());
|
||||||
|
|
||||||
|
@ -539,18 +537,18 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
if (persist == null || persist.getPages() == null || persist.getSections() == null) return sectionPerPage;
|
if (persist == null || persist.getPages() == null || persist.getSections() == null) return sectionPerPage;
|
||||||
|
|
||||||
for (Page page :persist.getPages()){
|
for (Page page :persist.getPages()){
|
||||||
sectionPerPage.put(page.getId(), new ArrayList<>());
|
sectionPerPage.put(page.getId().trim(), new ArrayList<>());
|
||||||
for (Section section : persist.getSections()){
|
for (Section section : persist.getSections()){
|
||||||
if (this.isInPage(section, page)){
|
if (this.isInPage(section, page)){
|
||||||
if (mappedSectionsIds.contains(section.getId())) throw new MyApplicationException("Multiple page section found for page " + page.getId() + " section " + section.getId());
|
if (mappedSectionsIds.contains(section.getId().trim())) throw new MyApplicationException("Multiple page section found for page " + page.getId().trim() + " section " + section.getId().trim());
|
||||||
mappedSectionsIds.add(section.getId());
|
mappedSectionsIds.add(section.getId().trim());
|
||||||
sectionPerPage.get(page.getId()).add(section);
|
sectionPerPage.get(page.getId().trim()).add(section);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Section section : persist.getSections()){
|
for (Section section : persist.getSections()){
|
||||||
if (!mappedSectionsIds.contains(section.getId())) throw new MyApplicationException("Orphan section found " + section.getId());
|
if (!mappedSectionsIds.contains(section.getId().trim())) throw new MyApplicationException("Orphan section found " + section.getId().trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
return sectionPerPage;
|
return sectionPerPage;
|
||||||
|
@ -558,9 +556,9 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
|
|
||||||
private boolean isInPage(Section section, Page page){
|
private boolean isInPage(Section section, Page page){
|
||||||
try {
|
try {
|
||||||
return UUID.fromString(section.getPage()).equals(UUID.fromString(page.getId()));
|
return UUID.fromString(section.getPage()).equals(UUID.fromString(page.getId().trim()));
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
return section.getPage().toLowerCase(Locale.ROOT).equals(page.getId().toLowerCase(Locale.ROOT));
|
return section.getPage().toLowerCase(Locale.ROOT).equals(page.getId().trim().toLowerCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue