change to common models for Deposit
This commit is contained in:
parent
5fc7241dc2
commit
0530373c83
|
@ -45,7 +45,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>gr.cite.opendmp</groupId>
|
<groupId>gr.cite.opendmp</groupId>
|
||||||
<artifactId>repositorydepositbase</artifactId>
|
<artifactId>repositorydepositbase</artifactId>
|
||||||
<version>2.0.0</version>
|
<version>2.0.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>gr.cite.opendmp</groupId>
|
||||||
|
<artifactId>common-models</artifactId>
|
||||||
|
<version>0.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>gr.cite.opendmp</groupId>
|
<groupId>gr.cite.opendmp</groupId>
|
||||||
|
|
|
@ -1,21 +1,20 @@
|
||||||
package eu.eudat.model.builder.deposit;
|
package eu.eudat.model.builder.commonmodels;
|
||||||
|
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import gr.cite.tools.data.builder.Builder;
|
import gr.cite.tools.data.builder.Builder;
|
||||||
import gr.cite.tools.data.query.QueryBase;
|
import gr.cite.tools.data.query.QueryBase;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public abstract class BaseDepositBuilder<M, D> implements Builder {
|
public abstract class BaseCommonModelBuilder<M, D> implements Builder {
|
||||||
protected final LoggerService logger;
|
protected final LoggerService logger;
|
||||||
protected final ConventionService conventionService;
|
protected final ConventionService conventionService;
|
||||||
|
|
||||||
public BaseDepositBuilder(
|
public BaseCommonModelBuilder(
|
||||||
ConventionService conventionService,
|
ConventionService conventionService,
|
||||||
LoggerService logger
|
LoggerService logger
|
||||||
) {
|
) {
|
||||||
|
@ -30,16 +29,16 @@ public abstract class BaseDepositBuilder<M, D> implements Builder {
|
||||||
M model = null;
|
M model = null;
|
||||||
return null; //TODO
|
return null; //TODO
|
||||||
}
|
}
|
||||||
List<DepositBuilderItemResponse<M, D>> models = this.buildInternal(List.of(data));
|
List<CommonModelBuilderItemResponse<M, D>> models = this.buildInternal(List.of(data));
|
||||||
return models.stream().map(DepositBuilderItemResponse::getModel).findFirst().orElse(null); //TODO
|
return models.stream().map(CommonModelBuilderItemResponse::getModel).findFirst().orElse(null); //TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<M> build(List<D> data) throws MyApplicationException{
|
public List<M> build(List<D> data) throws MyApplicationException{
|
||||||
List<DepositBuilderItemResponse<M, D>> models = this.buildInternal(data);
|
List<CommonModelBuilderItemResponse<M, D>> models = this.buildInternal(data);
|
||||||
return models == null ? null : models.stream().map(DepositBuilderItemResponse::getModel).collect(Collectors.toList());
|
return models == null ? null : models.stream().map(CommonModelBuilderItemResponse::getModel).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract List<DepositBuilderItemResponse<M, D>> buildInternal(List<D> data) throws MyApplicationException;
|
protected abstract List<CommonModelBuilderItemResponse<M, D>> buildInternal(List<D> data) throws MyApplicationException;
|
||||||
|
|
||||||
public <K> Map<K, M> asForeignKey(QueryBase<D> query, Function<D, K> keySelector) throws MyApplicationException {
|
public <K> Map<K, M> asForeignKey(QueryBase<D> query, Function<D, K> keySelector) throws MyApplicationException {
|
||||||
this.logger.trace("Building references from query");
|
this.logger.trace("Building references from query");
|
||||||
|
@ -50,9 +49,9 @@ public abstract class BaseDepositBuilder<M, D> implements Builder {
|
||||||
|
|
||||||
public <K> Map<K, M> asForeignKey(List<D> data, Function<D, K> keySelector) throws MyApplicationException {
|
public <K> Map<K, M> asForeignKey(List<D> data, Function<D, K> keySelector) throws MyApplicationException {
|
||||||
this.logger.trace("building references");
|
this.logger.trace("building references");
|
||||||
List<DepositBuilderItemResponse<M, D>> models = this.buildInternal(data);
|
List<CommonModelBuilderItemResponse<M, D>> models = this.buildInternal(data);
|
||||||
this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0));
|
this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
return models == null ? new HashMap<>() : models.stream().collect(Collectors.toMap(x-> keySelector.apply(x.getData()), DepositBuilderItemResponse::getModel));
|
return models == null ? new HashMap<>() : models.stream().collect(Collectors.toMap(x-> keySelector.apply(x.getData()), CommonModelBuilderItemResponse::getModel));
|
||||||
}
|
}
|
||||||
public <K> Map<K, List<M>> asMasterKey(QueryBase<D> query,Function<D, K> keySelector) throws MyApplicationException {
|
public <K> Map<K, List<M>> asMasterKey(QueryBase<D> query,Function<D, K> keySelector) throws MyApplicationException {
|
||||||
this.logger.trace("Building details from query");
|
this.logger.trace("Building details from query");
|
||||||
|
@ -63,11 +62,11 @@ public abstract class BaseDepositBuilder<M, D> implements Builder {
|
||||||
|
|
||||||
public <K> Map<K, List<M>> asMasterKey(List<D> data, Function<D, K> keySelector) throws MyApplicationException {
|
public <K> Map<K, List<M>> asMasterKey(List<D> data, Function<D, K> keySelector) throws MyApplicationException {
|
||||||
this.logger.trace("building details");
|
this.logger.trace("building details");
|
||||||
List<DepositBuilderItemResponse<M, D>> models = this.buildInternal(data);
|
List<CommonModelBuilderItemResponse<M, D>> models = this.buildInternal(data);
|
||||||
this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0));
|
this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
Map<K, List<M>> map = new HashMap<>();
|
Map<K, List<M>> map = new HashMap<>();
|
||||||
if (models == null) return map;
|
if (models == null) return map;
|
||||||
for (DepositBuilderItemResponse<M, D> model : models) {
|
for (CommonModelBuilderItemResponse<M, D> model : models) {
|
||||||
K key = keySelector.apply(model.getData());
|
K key = keySelector.apply(model.getData());
|
||||||
if (!map.containsKey(key)) map.put(key, new ArrayList<M>());
|
if (!map.containsKey(key)) map.put(key, new ArrayList<M>());
|
||||||
map.get(key).add(model.getModel());
|
map.get(key).add(model.getModel());
|
|
@ -1,10 +1,10 @@
|
||||||
package eu.eudat.model.builder.deposit;
|
package eu.eudat.model.builder.commonmodels;
|
||||||
|
|
||||||
public class DepositBuilderItemResponse<M, D>{
|
public class CommonModelBuilderItemResponse<M, D>{
|
||||||
private final M model;
|
private final M model;
|
||||||
private final D data;
|
private final D data;
|
||||||
|
|
||||||
public DepositBuilderItemResponse(M model, D data) {
|
public CommonModelBuilderItemResponse(M model, D data) {
|
||||||
this.model = model;
|
this.model = model;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
|
@ -1,18 +1,10 @@
|
||||||
package eu.eudat.model.builder.deposit;
|
package eu.eudat.model.builder.commonmodels;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.TagEntity;
|
|
||||||
import eu.eudat.model.Tag;
|
|
||||||
import eu.eudat.model.User;
|
|
||||||
import eu.eudat.model.builder.BaseBuilder;
|
import eu.eudat.model.builder.BaseBuilder;
|
||||||
import eu.eudat.model.builder.UserBuilder;
|
|
||||||
import eu.eudat.model.deposit.DepositConfiguration;
|
import eu.eudat.model.deposit.DepositConfiguration;
|
||||||
import eu.eudat.query.UserQuery;
|
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
import gr.cite.tools.logging.DataLogEntry;
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
@ -23,7 +15,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
|
@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
|
@ -1,12 +1,18 @@
|
||||||
package eu.eudat.model.builder.deposit;
|
package eu.eudat.model.builder.commonmodels;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.enums.DmpAccessType;
|
||||||
|
import eu.eudat.commonmodels.models.DmpModel;
|
||||||
|
import eu.eudat.commonmodels.models.DmpUserModel;
|
||||||
|
import eu.eudat.commonmodels.models.FileEnvelopeModel;
|
||||||
|
import eu.eudat.commonmodels.models.description.DescriptionModel;
|
||||||
|
import eu.eudat.commonmodels.models.reference.ReferenceModel;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.*;
|
import eu.eudat.data.*;
|
||||||
import eu.eudat.depositinterface.enums.DmpAccessType;
|
|
||||||
import eu.eudat.depositinterface.models.*;
|
|
||||||
import eu.eudat.model.*;
|
import eu.eudat.model.*;
|
||||||
|
import eu.eudat.model.builder.commonmodels.description.DescriptionCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.reference.ReferenceCommonModelBuilder;
|
||||||
import eu.eudat.query.*;
|
import eu.eudat.query.*;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.query.Ordering;
|
import gr.cite.tools.data.query.Ordering;
|
||||||
|
@ -25,66 +31,66 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class DmpDepositBuilder extends BaseDepositBuilder<DmpDepositModel, DmpEntity> {
|
public class DmpCommonModelBuilder extends BaseCommonModelBuilder<DmpModel, DmpEntity> {
|
||||||
|
|
||||||
private final QueryFactory queryFactory;
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
private FileEnvelope pdfFile;
|
private FileEnvelopeModel pdfFile;
|
||||||
private FileEnvelope rdaJsonFile;
|
private FileEnvelopeModel rdaJsonFile;
|
||||||
private FileEnvelope supportingFilesZip;
|
private FileEnvelopeModel supportingFilesZip;
|
||||||
private String repositoryId;
|
private String repositoryId;
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DmpDepositBuilder(ConventionService conventionService,
|
public DmpCommonModelBuilder(ConventionService conventionService,
|
||||||
QueryFactory queryFactory,
|
QueryFactory queryFactory,
|
||||||
BuilderFactory builderFactory) {
|
BuilderFactory builderFactory) {
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpDepositBuilder.class)));
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpCommonModelBuilder.class)));
|
||||||
this.queryFactory = queryFactory;
|
this.queryFactory = queryFactory;
|
||||||
this.builderFactory = builderFactory;
|
this.builderFactory = builderFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DmpDepositBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
public DmpCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
this.authorize = values;
|
this.authorize = values;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DmpDepositBuilder setPdfFile(FileEnvelope pdfFile) {
|
public DmpCommonModelBuilder setPdfFile(FileEnvelopeModel pdfFile) {
|
||||||
this.pdfFile = pdfFile;
|
this.pdfFile = pdfFile;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DmpDepositBuilder setRdaJsonFile(FileEnvelope rdaJsonFile) {
|
public DmpCommonModelBuilder setRdaJsonFile(FileEnvelopeModel rdaJsonFile) {
|
||||||
this.rdaJsonFile = rdaJsonFile;
|
this.rdaJsonFile = rdaJsonFile;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DmpDepositBuilder setSupportingFilesZip(FileEnvelope supportingFilesZip) {
|
public DmpCommonModelBuilder setSupportingFilesZip(FileEnvelopeModel supportingFilesZip) {
|
||||||
this.supportingFilesZip = supportingFilesZip;
|
this.supportingFilesZip = supportingFilesZip;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DmpDepositBuilder setRepositoryId(String repositoryId) {
|
public DmpCommonModelBuilder setRepositoryId(String repositoryId) {
|
||||||
this.repositoryId = repositoryId;
|
this.repositoryId = repositoryId;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<DepositBuilderItemResponse<DmpDepositModel, DmpEntity>> buildInternal(List<DmpEntity> data) throws MyApplicationException {
|
protected List<CommonModelBuilderItemResponse<DmpModel, DmpEntity>> buildInternal(List<DmpEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
List<DepositBuilderItemResponse<DmpDepositModel, DmpEntity>> models = new ArrayList<>();
|
List<CommonModelBuilderItemResponse<DmpModel, DmpEntity>> models = new ArrayList<>();
|
||||||
|
|
||||||
Map<UUID, List<ReferenceDepositModel>> dmpReferencesMap = this.collectReferences(data);
|
Map<UUID, List<ReferenceModel>> dmpReferencesMap = this.collectReferences(data);
|
||||||
|
|
||||||
Map<UUID, List<DmpUserDepositModel>> dmpUsersMap = this.collectDmpUsers(data);
|
Map<UUID, List<DmpUserModel>> dmpUsersMap = this.collectDmpUsers(data);
|
||||||
|
|
||||||
Map<UUID, List<DescriptionDepositModel>> descriptionsMap = this.collectDmpDescriptions(data);
|
Map<UUID, List<DescriptionModel>> descriptionsMap = this.collectDmpDescriptions(data);
|
||||||
|
|
||||||
for (DmpEntity d : data) {
|
for (DmpEntity d : data) {
|
||||||
DmpDepositModel m = new DmpDepositModel();
|
DmpModel m = new DmpModel();
|
||||||
m.setId(d.getId());
|
m.setId(d.getId());
|
||||||
m.setLabel(d.getLabel());
|
m.setLabel(d.getLabel());
|
||||||
m.setVersion(d.getVersion());
|
m.setVersion(d.getVersion());
|
||||||
|
@ -104,7 +110,7 @@ public class DmpDepositBuilder extends BaseDepositBuilder<DmpDepositModel, DmpEn
|
||||||
if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId())) m.setUsers(dmpUsersMap.get(d.getId()));
|
if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId())) m.setUsers(dmpUsersMap.get(d.getId()));
|
||||||
if (descriptionsMap != null && !descriptionsMap.isEmpty() && descriptionsMap.containsKey(d.getId())) m.setDescriptions(descriptionsMap.get(d.getId()));
|
if (descriptionsMap != null && !descriptionsMap.isEmpty() && descriptionsMap.containsKey(d.getId())) m.setDescriptions(descriptionsMap.get(d.getId()));
|
||||||
|
|
||||||
models.add(new DepositBuilderItemResponse<>(m, d));
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
}
|
}
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
@ -128,18 +134,18 @@ public class DmpDepositBuilder extends BaseDepositBuilder<DmpDepositModel, DmpEn
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<UUID, List<ReferenceDepositModel>> collectReferences(List<DmpEntity> data) throws MyApplicationException {
|
private Map<UUID, List<ReferenceModel>> collectReferences(List<DmpEntity> data) throws MyApplicationException {
|
||||||
if (data.isEmpty()) return null;
|
if (data.isEmpty()) return null;
|
||||||
this.logger.debug("checking related - {}", DmpReference.class.getSimpleName());
|
this.logger.debug("checking related - {}", DmpReference.class.getSimpleName());
|
||||||
|
|
||||||
List<DmpReferenceEntity> dmpReferences = this.queryFactory.query(DmpReferenceQuery.class).isActives(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(DmpReference._dmp).ensure(DmpReference._reference));
|
List<DmpReferenceEntity> dmpReferences = this.queryFactory.query(DmpReferenceQuery.class).isActives(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(DmpReference._dmp).ensure(DmpReference._reference));
|
||||||
|
|
||||||
Map<UUID, List<ReferenceDepositModel>> itemMap = new HashMap<>();
|
Map<UUID, List<ReferenceModel>> itemMap = new HashMap<>();
|
||||||
ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).isActive(IsActive.Active).ids(dmpReferences.stream().map(DmpReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()));
|
ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).isActive(IsActive.Active).ids(dmpReferences.stream().map(DmpReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()));
|
||||||
Map<UUID, ReferenceDepositModel> referenceDepositModelMap = this.builderFactory.builder(ReferenceDepositBuilder.class).authorize(this.authorize).asForeignKey(query, ReferenceEntity::getId);
|
Map<UUID, ReferenceModel> referenceModelMap = this.builderFactory.builder(ReferenceCommonModelBuilder.class).authorize(this.authorize).asForeignKey(query, ReferenceEntity::getId);
|
||||||
if (referenceDepositModelMap == null) return null;
|
if (referenceModelMap == null) return null;
|
||||||
for (DmpReferenceEntity dmpReference : dmpReferences) {
|
for (DmpReferenceEntity dmpReference : dmpReferences) {
|
||||||
ReferenceDepositModel model =referenceDepositModelMap.getOrDefault(dmpReference.getReferenceId(), null);
|
ReferenceModel model =referenceModelMap.getOrDefault(dmpReference.getReferenceId(), null);
|
||||||
if (model == null) continue;;
|
if (model == null) continue;;
|
||||||
UUID key = dmpReference.getDmpId();
|
UUID key = dmpReference.getDmpId();
|
||||||
if (!itemMap.containsKey(key)) itemMap.put(key, new ArrayList<>());
|
if (!itemMap.containsKey(key)) itemMap.put(key, new ArrayList<>());
|
||||||
|
@ -149,23 +155,23 @@ public class DmpDepositBuilder extends BaseDepositBuilder<DmpDepositModel, DmpEn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Map<UUID, List<DmpUserDepositModel>> collectDmpUsers(List<DmpEntity> data) throws MyApplicationException {
|
private Map<UUID, List<DmpUserModel>> collectDmpUsers(List<DmpEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("checking related - {}", DmpUser.class.getSimpleName());
|
this.logger.debug("checking related - {}", DmpUser.class.getSimpleName());
|
||||||
|
|
||||||
Map<UUID, List<DmpUserDepositModel>> itemMap;
|
Map<UUID, List<DmpUserModel>> itemMap;
|
||||||
DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).isActives(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
|
DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).isActives(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
|
||||||
itemMap = this.builderFactory.builder(DmpUserDepositBuilder.class).authorize(this.authorize).asMasterKey(query, DmpUserEntity::getDmpId);
|
itemMap = this.builderFactory.builder(DmpUserCommonModelBuilder.class).authorize(this.authorize).asMasterKey(query, DmpUserEntity::getDmpId);
|
||||||
|
|
||||||
return itemMap;
|
return itemMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<UUID, List<DescriptionDepositModel>> collectDmpDescriptions(List<DmpEntity> data) throws MyApplicationException {
|
private Map<UUID, List<DescriptionModel>> collectDmpDescriptions(List<DmpEntity> data) throws MyApplicationException {
|
||||||
if (data.isEmpty()) return null;
|
if (data.isEmpty()) return null;
|
||||||
this.logger.debug("checking related - {}", Description.class.getSimpleName());
|
this.logger.debug("checking related - {}", Description.class.getSimpleName());
|
||||||
|
|
||||||
Map<UUID, List<DescriptionDepositModel>> itemMap;
|
Map<UUID, List<DescriptionModel>> itemMap;
|
||||||
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).isActive(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
|
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).isActive(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
|
||||||
itemMap = this.builderFactory.builder(DescriptionDepositBuilder.class).authorize(this.authorize).asMasterKey(query, DescriptionEntity::getDmpId);
|
itemMap = this.builderFactory.builder(DescriptionCommonModelBuilder.class).authorize(this.authorize).asMasterKey(query, DescriptionEntity::getDmpId);
|
||||||
|
|
||||||
return itemMap;
|
return itemMap;
|
||||||
}
|
}
|
|
@ -1,13 +1,13 @@
|
||||||
package eu.eudat.model.builder.deposit;
|
package eu.eudat.model.builder.commonmodels;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.enums.DmpUserRole;
|
||||||
|
import eu.eudat.commonmodels.models.DmpUserModel;
|
||||||
|
import eu.eudat.commonmodels.models.UserModel;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.DmpUserEntity;
|
import eu.eudat.data.DmpUserEntity;
|
||||||
import eu.eudat.data.UserEntity;
|
import eu.eudat.data.UserEntity;
|
||||||
import eu.eudat.depositinterface.enums.DmpUserRole;
|
|
||||||
import eu.eudat.depositinterface.models.DmpUserDepositModel;
|
|
||||||
import eu.eudat.depositinterface.models.UserDepositModel;
|
|
||||||
import eu.eudat.query.UserQuery;
|
import eu.eudat.query.UserQuery;
|
||||||
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;
|
||||||
|
@ -24,7 +24,7 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class DmpUserDepositBuilder extends BaseDepositBuilder<DmpUserDepositModel, DmpUserEntity> {
|
public class DmpUserCommonModelBuilder extends BaseCommonModelBuilder<DmpUserModel, DmpUserEntity> {
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
|
|
||||||
|
@ -33,51 +33,51 @@ public class DmpUserDepositBuilder extends BaseDepositBuilder<DmpUserDepositMode
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DmpUserDepositBuilder(
|
public DmpUserCommonModelBuilder(
|
||||||
ConventionService conventionService,
|
ConventionService conventionService,
|
||||||
BuilderFactory builderFactory, QueryFactory queryFactory) {
|
BuilderFactory builderFactory, QueryFactory queryFactory) {
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpUserDepositBuilder.class)));
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpUserCommonModelBuilder.class)));
|
||||||
this.builderFactory = builderFactory;
|
this.builderFactory = builderFactory;
|
||||||
this.queryFactory = queryFactory;
|
this.queryFactory = queryFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DmpUserDepositBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
public DmpUserCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
this.authorize = values;
|
this.authorize = values;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<DepositBuilderItemResponse<DmpUserDepositModel, DmpUserEntity>> buildInternal(List<DmpUserEntity> data) throws MyApplicationException {
|
protected List<CommonModelBuilderItemResponse<DmpUserModel, DmpUserEntity>> buildInternal(List<DmpUserEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {} items ", Optional.ofNullable(data).map(List::size).orElse(0));
|
this.logger.debug("building for {} items ", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
if (data == null)
|
if (data == null)
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
Map<UUID, UserDepositModel> userItemsMap = this.collectUsers(data);
|
Map<UUID, UserModel> userItemsMap = this.collectUsers(data);
|
||||||
|
|
||||||
List<DepositBuilderItemResponse<DmpUserDepositModel, DmpUserEntity>> models = new ArrayList<>();
|
List<CommonModelBuilderItemResponse<DmpUserModel, DmpUserEntity>> models = new ArrayList<>();
|
||||||
for (DmpUserEntity d : data) {
|
for (DmpUserEntity d : data) {
|
||||||
DmpUserDepositModel m = new DmpUserDepositModel();
|
DmpUserModel m = new DmpUserModel();
|
||||||
switch (d.getRole()){
|
switch (d.getRole()){
|
||||||
case User -> m.setRole(DmpUserRole.User);
|
case User -> m.setRole(DmpUserRole.User);
|
||||||
case Owner -> m.setRole(DmpUserRole.Owner);
|
case Owner -> m.setRole(DmpUserRole.Owner);
|
||||||
default -> throw new MyApplicationException("unrecognized type " + d.getRole().getValue());
|
default -> throw new MyApplicationException("unrecognized type " + d.getRole().getValue());
|
||||||
}
|
}
|
||||||
if (userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId()));
|
if (userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId()));
|
||||||
models.add(new DepositBuilderItemResponse<>(m, d));
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
}
|
}
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<UUID, UserDepositModel> collectUsers(List<DmpUserEntity> data) throws MyApplicationException {
|
private Map<UUID, UserModel> collectUsers(List<DmpUserEntity> data) throws MyApplicationException {
|
||||||
if (data.isEmpty())
|
if (data.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
this.logger.debug("checking related - {}", UserDepositModel.class.getSimpleName());
|
this.logger.debug("checking related - {}", UserModel.class.getSimpleName());
|
||||||
|
|
||||||
Map<UUID, UserDepositModel> itemMap;
|
Map<UUID, UserModel> itemMap;
|
||||||
UserQuery q = this.queryFactory.query(UserQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().map(DmpUserEntity::getUserId).distinct().collect(Collectors.toList()));
|
UserQuery q = this.queryFactory.query(UserQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().map(DmpUserEntity::getUserId).distinct().collect(Collectors.toList()));
|
||||||
itemMap = this.builderFactory.builder(UserDepositBuilder.class).authorize(this.authorize).asForeignKey(q, UserEntity::getId);
|
itemMap = this.builderFactory.builder(UserCommonModelBuilder.class).authorize(this.authorize).asForeignKey(q, UserEntity::getId);
|
||||||
return itemMap;
|
return itemMap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.reference.ReferenceTypeModel;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.data.ReferenceTypeEntity;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class ReferenceTypeCommonModelBuilder extends BaseCommonModelBuilder<ReferenceTypeModel, ReferenceTypeEntity> {
|
||||||
|
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ReferenceTypeCommonModelBuilder(
|
||||||
|
ConventionService conventionService) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeCommonModelBuilder.class)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceTypeCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<CommonModelBuilderItemResponse<ReferenceTypeModel, ReferenceTypeEntity>> buildInternal(List<ReferenceTypeEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<CommonModelBuilderItemResponse<ReferenceTypeModel, ReferenceTypeEntity>> models = new ArrayList<>();
|
||||||
|
for (ReferenceTypeEntity d : data) {
|
||||||
|
ReferenceTypeModel m = new ReferenceTypeModel();
|
||||||
|
m.setId(d.getId());
|
||||||
|
m.setCode(d.getCode());
|
||||||
|
m.setName(d.getName());
|
||||||
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
package eu.eudat.model.builder.deposit;
|
package eu.eudat.model.builder.commonmodels;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.UserModel;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.UserEntity;
|
import eu.eudat.data.UserEntity;
|
||||||
import eu.eudat.depositinterface.models.UserDepositModel;
|
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -19,32 +19,32 @@ import java.util.Optional;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class UserDepositBuilder extends BaseDepositBuilder<UserDepositModel, UserEntity> {
|
public class UserCommonModelBuilder extends BaseCommonModelBuilder<UserModel, UserEntity> {
|
||||||
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public UserDepositBuilder(ConventionService conventionService) {
|
public UserCommonModelBuilder(ConventionService conventionService) {
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(UserDepositBuilder.class)));
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(UserCommonModelBuilder.class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserDepositBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
public UserCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
this.authorize = values;
|
this.authorize = values;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<DepositBuilderItemResponse<UserDepositModel, UserEntity>> buildInternal(List<UserEntity> data) throws MyApplicationException {
|
protected List<CommonModelBuilderItemResponse<UserModel, UserEntity>> buildInternal(List<UserEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {} items ", Optional.ofNullable(data).map(List::size).orElse(0));
|
this.logger.debug("building for {} items ", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
if (data == null)
|
if (data == null)
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
|
||||||
List<DepositBuilderItemResponse<UserDepositModel, UserEntity>> models = new ArrayList<>();
|
List<CommonModelBuilderItemResponse<UserModel, UserEntity>> models = new ArrayList<>();
|
||||||
|
|
||||||
for (UserEntity d : data) {
|
for (UserEntity d : data) {
|
||||||
UserDepositModel m = new UserDepositModel();
|
UserModel m = new UserModel();
|
||||||
m.setName(d.getName());
|
m.setName(d.getName());
|
||||||
models.add(new DepositBuilderItemResponse<>(m, d));
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
}
|
}
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
|
@ -0,0 +1,117 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.description;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.description.DescriptionModel;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.DescriptionTemplateModel;
|
||||||
|
import eu.eudat.commons.JsonHandlingService;
|
||||||
|
import eu.eudat.commons.XmlHandlingService;
|
||||||
|
import eu.eudat.commons.types.description.PropertyDefinitionEntity;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
|
import eu.eudat.model.DescriptionTemplate;
|
||||||
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
|
import eu.eudat.model.builder.commonmodels.descriptiontemplate.DescriptionTemplateCommonModelBuilder;
|
||||||
|
import eu.eudat.query.*;
|
||||||
|
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 org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class DescriptionCommonModelBuilder extends BaseCommonModelBuilder<DescriptionModel, DescriptionEntity> {
|
||||||
|
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private final JsonHandlingService jsonHandlingService;
|
||||||
|
private final XmlHandlingService xmlHandlingService;
|
||||||
|
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DescriptionCommonModelBuilder(
|
||||||
|
ConventionService conventionService,
|
||||||
|
QueryFactory queryFactory,
|
||||||
|
BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionCommonModelBuilder.class)));
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
this.jsonHandlingService = jsonHandlingService;
|
||||||
|
this.xmlHandlingService = xmlHandlingService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<CommonModelBuilderItemResponse<DescriptionModel, DescriptionEntity>> buildInternal(List<DescriptionEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
Map<UUID, DescriptionTemplateModel> descriptionTemplates = this.collectDescriptionTemplates(data);
|
||||||
|
|
||||||
|
Map<UUID, DefinitionEntity> definitionEntityMap = this.collectDescriptionTemplateDefinitions(data);
|
||||||
|
|
||||||
|
List<CommonModelBuilderItemResponse<DescriptionModel, DescriptionEntity>> models = new ArrayList<>();
|
||||||
|
for (DescriptionEntity d : data) {
|
||||||
|
DescriptionModel m = new DescriptionModel();
|
||||||
|
m.setLabel(d.getLabel());
|
||||||
|
m.setDescription(d.getDescription());
|
||||||
|
if (descriptionTemplates != null && d.getDescriptionTemplateId() != null && descriptionTemplates.containsKey(d.getDescriptionTemplateId())) m.setDescriptionTemplate(descriptionTemplates.get(d.getDescriptionTemplateId()));
|
||||||
|
if (d.getProperties() != null){
|
||||||
|
//TODO Update with the new logic of property definition
|
||||||
|
PropertyDefinitionEntity propertyDefinition = this.jsonHandlingService.fromJsonSafe(PropertyDefinitionEntity.class, d.getProperties());
|
||||||
|
m.setProperties(this.builderFactory.builder(PropertyDefinitionCommonModelBuilder.class).withDefinition(definitionEntityMap != null ? definitionEntityMap.getOrDefault(d.getDescriptionTemplateId(), null) : null).authorize(this.authorize).build(propertyDefinition));
|
||||||
|
}
|
||||||
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<UUID, DefinitionEntity> collectDescriptionTemplateDefinitions(List<DescriptionEntity> data) throws MyApplicationException {
|
||||||
|
if (data.isEmpty())
|
||||||
|
return null;
|
||||||
|
this.logger.debug("checking related - {}", DefinitionEntity.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<java.util.UUID, DefinitionEntity> itemMap = new HashMap<>();
|
||||||
|
DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList()));
|
||||||
|
List<DescriptionTemplateEntity> items = q.collectAs(new BaseFieldSet().ensure(eu.eudat.model.DescriptionTemplate._id).ensure(DescriptionTemplate._definition));
|
||||||
|
for (DescriptionTemplateEntity item : items){
|
||||||
|
DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, item.getDefinition());
|
||||||
|
itemMap.put(item.getId(), definition);
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<UUID, DescriptionTemplateModel> collectDescriptionTemplates(List<DescriptionEntity> data) throws MyApplicationException {
|
||||||
|
if (data.isEmpty())
|
||||||
|
return null;
|
||||||
|
this.logger.debug("checking related - {}", DescriptionTemplateModel.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<UUID, DescriptionTemplateModel> itemMap;
|
||||||
|
DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList()));
|
||||||
|
itemMap = this.builderFactory.builder(DescriptionTemplateCommonModelBuilder.class).authorize(this.authorize).asForeignKey(q, DescriptionTemplateEntity::getId);
|
||||||
|
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.description;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.description.ExternalIdentifierModel;
|
||||||
|
import eu.eudat.commons.types.description.ExternalIdentifierEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class ExternalIdentifierCommonModelBuilder extends BaseCommonModelBuilder<ExternalIdentifierModel, ExternalIdentifierEntity> {
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
@Autowired
|
||||||
|
public ExternalIdentifierCommonModelBuilder(
|
||||||
|
ConventionService conventionService
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(ExternalIdentifierCommonModelBuilder.class)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExternalIdentifierCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<CommonModelBuilderItemResponse<ExternalIdentifierModel, ExternalIdentifierEntity>> buildInternal(List<ExternalIdentifierEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<CommonModelBuilderItemResponse<ExternalIdentifierModel, ExternalIdentifierEntity>> models = new ArrayList<>();
|
||||||
|
for (ExternalIdentifierEntity d : data) {
|
||||||
|
ExternalIdentifierModel m = new ExternalIdentifierModel();
|
||||||
|
m.setIdentifier(d.getIdentifier());
|
||||||
|
m.setType(d.getType());
|
||||||
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.description;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.description.FieldModel;
|
||||||
|
import eu.eudat.commonmodels.models.reference.ReferenceModel;
|
||||||
|
import eu.eudat.commons.enums.FieldType;
|
||||||
|
import eu.eudat.commons.types.description.FieldEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.data.ReferenceEntity;
|
||||||
|
import eu.eudat.model.Reference;
|
||||||
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
|
import eu.eudat.model.builder.commonmodels.reference.ReferenceCommonModelBuilder;
|
||||||
|
import eu.eudat.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.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class FieldCommonModelBuilder extends BaseCommonModelBuilder<FieldModel, FieldEntity> {
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
private eu.eudat.commons.types.descriptiontemplate.FieldEntity fieldEntity;
|
||||||
|
@Autowired
|
||||||
|
public FieldCommonModelBuilder(
|
||||||
|
ConventionService conventionService, BuilderFactory builderFactory, QueryFactory queryFactory
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(FieldCommonModelBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldCommonModelBuilder withFieldEntity(eu.eudat.commons.types.descriptiontemplate.FieldEntity fieldEntity) {
|
||||||
|
this.fieldEntity = fieldEntity;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected List<CommonModelBuilderItemResponse<FieldModel, FieldEntity>> buildInternal(List<FieldEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
FieldType fieldType = this.fieldEntity != null && this.fieldEntity.getData() != null ? this.fieldEntity.getData().getFieldType() : FieldType.FREE_TEXT;
|
||||||
|
|
||||||
|
Map<UUID, ReferenceModel> referenceItemsMap = FieldType.isReferenceType(fieldType) ? this.collectReferences(data) : null;
|
||||||
|
|
||||||
|
List<CommonModelBuilderItemResponse<FieldModel, FieldEntity>> models = new ArrayList<>();
|
||||||
|
for (FieldEntity d : data) {
|
||||||
|
FieldModel m = new FieldModel();
|
||||||
|
if (FieldType.isDateType(fieldType)) m.setDateValue(d.getDateValue());
|
||||||
|
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()) {
|
||||||
|
m.setReferences(new ArrayList<>());
|
||||||
|
for (UUID referenceId : d.getTextListValue().stream().map(UUID::fromString).toList()){
|
||||||
|
if (referenceItemsMap.containsKey(referenceId)) m.getReferences().add(referenceItemsMap.get(referenceId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (d.getExternalIdentifier() != null && FieldType.isExternalIdentifierType(fieldType)) m.setExternalIdentifier(this.builderFactory.builder(ExternalIdentifierCommonModelBuilder.class).authorize(this.authorize).build(d.getExternalIdentifier()));
|
||||||
|
|
||||||
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<UUID, ReferenceModel> collectReferences(List<FieldEntity> data) throws MyApplicationException {
|
||||||
|
if (data.isEmpty())
|
||||||
|
return null;
|
||||||
|
this.logger.debug("checking related - {}", Reference.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<UUID, ReferenceModel> itemMap;
|
||||||
|
|
||||||
|
ReferenceQuery q = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).ids(data.stream().map(FieldEntity::getTextListValue).flatMap(List::stream).map(UUID::fromString).distinct().collect(Collectors.toList()));
|
||||||
|
itemMap = this.builderFactory.builder(ReferenceCommonModelBuilder.class).authorize(this.authorize).asForeignKey(q, ReferenceEntity::getId);
|
||||||
|
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.description;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.description.PropertyDefinitionModel;
|
||||||
|
import eu.eudat.commons.types.description.PropertyDefinitionEntity;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.FieldSetEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class PropertyDefinitionCommonModelBuilder extends BaseCommonModelBuilder<PropertyDefinitionModel, PropertyDefinitionEntity> {
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
private DefinitionEntity definition;
|
||||||
|
@Autowired
|
||||||
|
public PropertyDefinitionCommonModelBuilder(
|
||||||
|
ConventionService conventionService, BuilderFactory builderFactory
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(PropertyDefinitionCommonModelBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertyDefinitionCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertyDefinitionCommonModelBuilder withDefinition(DefinitionEntity definition) {
|
||||||
|
this.definition = definition;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected List<CommonModelBuilderItemResponse<PropertyDefinitionModel, PropertyDefinitionEntity>> buildInternal(List<PropertyDefinitionEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<CommonModelBuilderItemResponse<PropertyDefinitionModel, PropertyDefinitionEntity>> models = new ArrayList<>();
|
||||||
|
for (PropertyDefinitionEntity d : data) {
|
||||||
|
PropertyDefinitionModel m = new PropertyDefinitionModel();
|
||||||
|
m.setFieldSets(new HashMap<>());
|
||||||
|
for (String key : d.getFieldSets().keySet()){
|
||||||
|
FieldSetEntity fieldSetEntity = definition != null ? definition.getFieldSetById(key).stream().findFirst().orElse(null) : null;
|
||||||
|
m.getFieldSets().put(key, this.builderFactory.builder(PropertyDefinitionFieldSetCommonModelBuilder.class).authorize(this.authorize).withFieldSetEntity(fieldSetEntity).build(d.getFieldSets().get(key)));
|
||||||
|
}
|
||||||
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.description;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.description.PropertyDefinitionFieldSetModel;
|
||||||
|
import eu.eudat.commons.types.description.PropertyDefinitionFieldSetEntity;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.FieldSetEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class PropertyDefinitionFieldSetCommonModelBuilder extends BaseCommonModelBuilder<PropertyDefinitionFieldSetModel, PropertyDefinitionFieldSetEntity> {
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
private FieldSetEntity fieldSetEntity;
|
||||||
|
@Autowired
|
||||||
|
public PropertyDefinitionFieldSetCommonModelBuilder(
|
||||||
|
ConventionService conventionService, BuilderFactory builderFactory
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(PropertyDefinitionFieldSetCommonModelBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertyDefinitionFieldSetCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public PropertyDefinitionFieldSetCommonModelBuilder withFieldSetEntity(FieldSetEntity fieldSetEntity) {
|
||||||
|
this.fieldSetEntity = fieldSetEntity;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected List<CommonModelBuilderItemResponse<PropertyDefinitionFieldSetModel, PropertyDefinitionFieldSetEntity>> buildInternal(List<PropertyDefinitionFieldSetEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<CommonModelBuilderItemResponse<PropertyDefinitionFieldSetModel, PropertyDefinitionFieldSetEntity>> models = new ArrayList<>();
|
||||||
|
for (PropertyDefinitionFieldSetEntity d : data) {
|
||||||
|
PropertyDefinitionFieldSetModel m = new PropertyDefinitionFieldSetModel();
|
||||||
|
if (d.getItems() != null) m.setItems(this.builderFactory.builder(PropertyDefinitionFieldSetItemModelCommonModelBuilder.class).withFieldSetEntity(this.fieldSetEntity).authorize(this.authorize).build(d.getItems()));
|
||||||
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.description;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.description.PropertyDefinitionFieldSetItemModel;
|
||||||
|
import eu.eudat.commons.types.description.PropertyDefinitionFieldSetItemEntity;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.FieldSetEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class PropertyDefinitionFieldSetItemModelCommonModelBuilder extends BaseCommonModelBuilder<PropertyDefinitionFieldSetItemModel, PropertyDefinitionFieldSetItemEntity> {
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
private FieldSetEntity fieldSetEntity;
|
||||||
|
@Autowired
|
||||||
|
public PropertyDefinitionFieldSetItemModelCommonModelBuilder(
|
||||||
|
ConventionService conventionService, BuilderFactory builderFactory
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(PropertyDefinitionFieldSetItemModelCommonModelBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertyDefinitionFieldSetItemModelCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public PropertyDefinitionFieldSetItemModelCommonModelBuilder withFieldSetEntity(FieldSetEntity fieldSetEntity) {
|
||||||
|
this.fieldSetEntity = fieldSetEntity;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<CommonModelBuilderItemResponse<PropertyDefinitionFieldSetItemModel, PropertyDefinitionFieldSetItemEntity>> buildInternal(List<PropertyDefinitionFieldSetItemEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<CommonModelBuilderItemResponse<PropertyDefinitionFieldSetItemModel, PropertyDefinitionFieldSetItemEntity>> models = new ArrayList<>();
|
||||||
|
for (PropertyDefinitionFieldSetItemEntity d : data) {
|
||||||
|
PropertyDefinitionFieldSetItemModel m = new PropertyDefinitionFieldSetItemModel();
|
||||||
|
|
||||||
|
m.setComment(d.getComment());
|
||||||
|
m.setOrdinal(d.getOrdinal());
|
||||||
|
if (d.getFields() != null && !d.getFields().isEmpty()) {
|
||||||
|
m.setFields(new HashMap<>());
|
||||||
|
for (String key : d.getFields().keySet()){
|
||||||
|
FieldEntity fieldEntity = fieldSetEntity != null ? fieldSetEntity.getAllField().stream().findFirst().orElse(null) : null;
|
||||||
|
m.getFields().put(key, this.builderFactory.builder(FieldCommonModelBuilder.class).authorize(this.authorize).withFieldEntity(fieldEntity).build(d.getFields().get(key)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.descriptiontemplate;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.DefinitionModel;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
|
import eu.eudat.model.builder.descriptiontemplatedefinition.PageBuilder;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class DefinitionCommonModelBuilder extends BaseCommonModelBuilder<DefinitionModel, DefinitionEntity> {
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
@Autowired
|
||||||
|
public DefinitionCommonModelBuilder(
|
||||||
|
ConventionService conventionService, BuilderFactory builderFactory
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(DefinitionCommonModelBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DefinitionCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<CommonModelBuilderItemResponse<DefinitionModel, DefinitionEntity>> buildInternal(List<DefinitionEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<CommonModelBuilderItemResponse<DefinitionModel, DefinitionEntity>> models = new ArrayList<>();
|
||||||
|
for (DefinitionEntity d : data) {
|
||||||
|
DefinitionModel m = new DefinitionModel();
|
||||||
|
if (d.getPages() != null) m.setPages(this.builderFactory.builder(PageCommonModelBuilder.class).authorize(this.authorize).build(d.getPages()));
|
||||||
|
|
||||||
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.descriptiontemplate;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.DescriptionTemplateModel;
|
||||||
|
import eu.eudat.commons.JsonHandlingService;
|
||||||
|
import eu.eudat.commons.XmlHandlingService;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class DescriptionTemplateCommonModelBuilder extends BaseCommonModelBuilder<DescriptionTemplateModel, DescriptionTemplateEntity> {
|
||||||
|
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private final JsonHandlingService jsonHandlingService;
|
||||||
|
|
||||||
|
private final XmlHandlingService xmlHandlingService;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DescriptionTemplateCommonModelBuilder(
|
||||||
|
ConventionService conventionService,
|
||||||
|
QueryFactory queryFactory,
|
||||||
|
BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionTemplateCommonModelBuilder.class)));
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
this.jsonHandlingService = jsonHandlingService;
|
||||||
|
this.xmlHandlingService = xmlHandlingService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionTemplateCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<CommonModelBuilderItemResponse<DescriptionTemplateModel, DescriptionTemplateEntity>> buildInternal(List<DescriptionTemplateEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<CommonModelBuilderItemResponse<DescriptionTemplateModel, DescriptionTemplateEntity>> models = new ArrayList<>();
|
||||||
|
for (DescriptionTemplateEntity d : data) {
|
||||||
|
DescriptionTemplateModel m = new DescriptionTemplateModel();
|
||||||
|
m.setId(d.getId());
|
||||||
|
m.setLabel(d.getLabel());
|
||||||
|
m.setDescription(d.getDescription());
|
||||||
|
m.setGroupId(d.getGroupId());
|
||||||
|
m.setVersion(d.getVersion());
|
||||||
|
m.setLanguage(d.getLanguage());
|
||||||
|
|
||||||
|
|
||||||
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.descriptiontemplate;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.FieldModel;
|
||||||
|
import eu.eudat.commons.enums.FieldValidationType;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
|
import eu.eudat.service.fielddatahelper.FieldDataHelperService;
|
||||||
|
import eu.eudat.service.fielddatahelper.FieldDataHelperServiceProvider;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class FieldCommonModelBuilder extends BaseCommonModelBuilder<FieldModel, FieldEntity> {
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
private final FieldDataHelperServiceProvider fieldDataHelperServiceProvider;
|
||||||
|
@Autowired
|
||||||
|
public FieldCommonModelBuilder(
|
||||||
|
ConventionService conventionService, BuilderFactory builderFactory, FieldDataHelperServiceProvider fieldDataHelperServiceProvider
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(FieldCommonModelBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
this.fieldDataHelperServiceProvider = fieldDataHelperServiceProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<CommonModelBuilderItemResponse<FieldModel, FieldEntity>> buildInternal(List<FieldEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<CommonModelBuilderItemResponse<FieldModel, FieldEntity>> models = new ArrayList<>();
|
||||||
|
for (FieldEntity d : data) {
|
||||||
|
FieldModel m = new FieldModel();
|
||||||
|
m.setId(d.getId());
|
||||||
|
m.setOrdinal(d.getOrdinal());
|
||||||
|
m.setNumbering(d.getNumbering());
|
||||||
|
m.setSchematics(d.getSchematics());
|
||||||
|
m.setDefaultValue(d.getDefaultValue());
|
||||||
|
m.setIncludeInExport(d.getIncludeInExport());
|
||||||
|
if (!this.conventionService.isListNullOrEmpty(d.getValidations())){
|
||||||
|
m.setValidations(new ArrayList<>());
|
||||||
|
for (FieldValidationType fieldValidationType : d.getValidations()) {
|
||||||
|
switch (fieldValidationType){
|
||||||
|
case Url -> m.getValidations().add(eu.eudat.commonmodels.enums.FieldValidationType.Url);
|
||||||
|
case None -> m.getValidations().add(eu.eudat.commonmodels.enums.FieldValidationType.None);
|
||||||
|
case Required -> m.getValidations().add(eu.eudat.commonmodels.enums.FieldValidationType.Required);
|
||||||
|
default -> throw new MyApplicationException("unrecognized type " + fieldValidationType);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m.setNumbering(d.getNumbering());
|
||||||
|
m.setNumbering(d.getNumbering());
|
||||||
|
if (d.getVisibilityRules() != null) m.setVisibilityRules(this.builderFactory.builder(RuleCommonModelBuilder.class).authorize(this.authorize).build(d.getVisibilityRules()));
|
||||||
|
if (d.getData() != null){
|
||||||
|
FieldDataHelperService fieldDataHelperService = this.fieldDataHelperServiceProvider.get(d.getData().getFieldType());
|
||||||
|
m.setData(fieldDataHelperService.buildCommonModelOne(d.getData(), this.authorize));
|
||||||
|
}
|
||||||
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.descriptiontemplate;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.FieldSetModel;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.FieldSetEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
|
import eu.eudat.model.builder.descriptiontemplatedefinition.FieldBuilder;
|
||||||
|
import eu.eudat.model.builder.descriptiontemplatedefinition.MultiplicityBuilder;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class FieldSetCommonModelBuilder extends BaseCommonModelBuilder<FieldSetModel, FieldSetEntity> {
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
@Autowired
|
||||||
|
public FieldSetCommonModelBuilder(
|
||||||
|
ConventionService conventionService, BuilderFactory builderFactory
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(FieldSetCommonModelBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldSetCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<CommonModelBuilderItemResponse<FieldSetModel, FieldSetEntity>> buildInternal(List<FieldSetEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<CommonModelBuilderItemResponse<FieldSetModel, FieldSetEntity>> models = new ArrayList<>();
|
||||||
|
for (FieldSetEntity d : data) {
|
||||||
|
FieldSetModel m = new FieldSetModel();
|
||||||
|
m.setId(d.getId());
|
||||||
|
m.setOrdinal(d.getOrdinal());
|
||||||
|
m.setTitle(d.getTitle());
|
||||||
|
m.setNumbering(d.getNumbering());
|
||||||
|
m.setDescription(d.getDescription());
|
||||||
|
m.setExtendedDescription(d.getExtendedDescription());
|
||||||
|
m.setAdditionalInformation(d.getAdditionalInformation());
|
||||||
|
m.setHasCommentField(d.getHasCommentField());
|
||||||
|
if (d.getMultiplicity() != null) m.setMultiplicity(this.builderFactory.builder(MultiplicityCommonModelBuilder.class).authorize(this.authorize).build(d.getMultiplicity()));
|
||||||
|
if (d.getFields() != null) m.setFields(this.builderFactory.builder(FieldCommonModelBuilder.class).authorize(this.authorize).build(d.getFields()));
|
||||||
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.descriptiontemplate;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.MultiplicityModel;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.MultiplicityEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
|
import eu.eudat.model.descriptiontemplatedefinition.Multiplicity;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class MultiplicityCommonModelBuilder extends BaseCommonModelBuilder<MultiplicityModel, MultiplicityEntity> {
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
@Autowired
|
||||||
|
public MultiplicityCommonModelBuilder(
|
||||||
|
ConventionService conventionService, BuilderFactory builderFactory
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(MultiplicityCommonModelBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MultiplicityCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<CommonModelBuilderItemResponse<MultiplicityModel, MultiplicityEntity>> buildInternal(List<MultiplicityEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<CommonModelBuilderItemResponse<MultiplicityModel, MultiplicityEntity>> models = new ArrayList<>();
|
||||||
|
for (MultiplicityEntity d : data) {
|
||||||
|
MultiplicityModel m = new MultiplicityModel();
|
||||||
|
m.setMin(d.getMin());
|
||||||
|
m.setMax(d.getMax());
|
||||||
|
m.setPlaceholder(d.getPlaceholder());
|
||||||
|
m.setTableView(d.getTableView());
|
||||||
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.descriptiontemplate;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.PageModel;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.PageEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
|
import eu.eudat.model.builder.descriptiontemplatedefinition.SectionBuilder;
|
||||||
|
import eu.eudat.model.descriptiontemplatedefinition.Page;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class PageCommonModelBuilder extends BaseCommonModelBuilder<PageModel, PageEntity> {
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
@Autowired
|
||||||
|
public PageCommonModelBuilder(
|
||||||
|
ConventionService conventionService, BuilderFactory builderFactory
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(PageCommonModelBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<CommonModelBuilderItemResponse<PageModel, PageEntity>> buildInternal(List<PageEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<CommonModelBuilderItemResponse<PageModel, PageEntity>> models = new ArrayList<>();
|
||||||
|
for (PageEntity d : data) {
|
||||||
|
PageModel m = new PageModel();
|
||||||
|
m.setId(d.getId());
|
||||||
|
m.setOrdinal(d.getOrdinal());
|
||||||
|
m.setTitle(d.getTitle());
|
||||||
|
m.setSections(this.builderFactory.builder(SectionCommonModelBuilder.class).authorize(this.authorize).build(d.getSections()));
|
||||||
|
|
||||||
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.descriptiontemplate;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.RuleModel;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.RuleEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class RuleCommonModelBuilder extends BaseCommonModelBuilder<RuleModel, RuleEntity> {
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
@Autowired
|
||||||
|
public RuleCommonModelBuilder(
|
||||||
|
ConventionService conventionService
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(RuleCommonModelBuilder.class)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public RuleCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<CommonModelBuilderItemResponse<RuleModel, RuleEntity>> buildInternal(List<RuleEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<CommonModelBuilderItemResponse<RuleModel, RuleEntity>> models = new ArrayList<>();
|
||||||
|
for (RuleEntity d : data) {
|
||||||
|
RuleModel m = new RuleModel();
|
||||||
|
m.setTarget(d.getTarget());
|
||||||
|
m.setValue(d.getValue());
|
||||||
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.descriptiontemplate;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.SectionModel;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.SectionEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
|
import eu.eudat.model.builder.descriptiontemplatedefinition.FieldSetBuilder;
|
||||||
|
import eu.eudat.model.builder.descriptiontemplatedefinition.SectionBuilder;
|
||||||
|
import eu.eudat.model.descriptiontemplatedefinition.Section;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class SectionCommonModelBuilder extends BaseCommonModelBuilder<SectionModel, SectionEntity> {
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
@Autowired
|
||||||
|
public SectionCommonModelBuilder(
|
||||||
|
ConventionService conventionService, BuilderFactory builderFactory
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(SectionCommonModelBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SectionCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<CommonModelBuilderItemResponse<SectionModel, SectionEntity>> buildInternal(List<SectionEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<CommonModelBuilderItemResponse<SectionModel, SectionEntity>> models = new ArrayList<>();
|
||||||
|
for (SectionEntity d : data) {
|
||||||
|
SectionModel m = new SectionModel();
|
||||||
|
m.setId(d.getId());
|
||||||
|
m.setDescription(d.getDescription());
|
||||||
|
m.setOrdinal(d.getOrdinal());
|
||||||
|
m.setDefaultVisibility(d.isDefaultVisibility());
|
||||||
|
m.setMultiplicity(d.getMultiplicity());
|
||||||
|
m.setNumbering(d.getNumbering());
|
||||||
|
m.setTitle(d.getTitle());
|
||||||
|
m.setExtendedDescription(d.getExtendedDescription());
|
||||||
|
if (d.getSections() != null) m.setSections(this.builderFactory.builder(SectionCommonModelBuilder.class).authorize(this.authorize).build(d.getSections()));
|
||||||
|
if (d.getFieldSets() != null) m.setFieldSets(this.builderFactory.builder(FieldSetCommonModelBuilder.class).authorize(this.authorize).build(d.getFieldSets()));
|
||||||
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.descriptiontemplate.fielddata;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.enums.FieldType;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.fielddata.BaseFieldDataModel;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.BaseFieldDataEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public abstract class BaseFieldDataCommonModelBuilder<Model extends BaseFieldDataModel, Entity extends BaseFieldDataEntity> extends BaseCommonModelBuilder<Model, Entity> {
|
||||||
|
protected EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
@Autowired
|
||||||
|
public BaseFieldDataCommonModelBuilder(
|
||||||
|
ConventionService conventionService,
|
||||||
|
LoggerService logger) {
|
||||||
|
super(conventionService, logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseFieldDataCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract Model getInstance();
|
||||||
|
|
||||||
|
protected abstract void buildChild(Entity d, Model m);
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<CommonModelBuilderItemResponse<Model, Entity>> buildInternal(List<Entity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<CommonModelBuilderItemResponse<Model, Entity>> models = new ArrayList<>();
|
||||||
|
for (Entity d : data) {
|
||||||
|
Model m = this.getInstance();
|
||||||
|
m.setLabel(d.getLabel());
|
||||||
|
switch (d.getFieldType()){
|
||||||
|
case SELECT -> m.setFieldType(FieldType.SELECT);
|
||||||
|
case BOOLEAN_DECISION -> m.setFieldType(FieldType.BOOLEAN_DECISION);
|
||||||
|
case RADIO_BOX -> m.setFieldType(FieldType.RADIO_BOX);
|
||||||
|
case INTERNAL_ENTRIES_DMPS -> m.setFieldType(FieldType.INTERNAL_ENTRIES_DMPS);
|
||||||
|
case INTERNAL_ENTRIES_DESCRIPTIONS -> m.setFieldType(FieldType.INTERNAL_ENTRIES_DESCRIPTIONS);
|
||||||
|
case CHECK_BOX -> m.setFieldType(FieldType.CHECK_BOX);
|
||||||
|
case FREE_TEXT -> m.setFieldType(FieldType.FREE_TEXT);
|
||||||
|
case TEXT_AREA -> m.setFieldType(FieldType.TEXT_AREA);
|
||||||
|
case RICH_TEXT_AREA -> m.setFieldType(FieldType.RICH_TEXT_AREA);
|
||||||
|
case UPLOAD -> m.setFieldType(FieldType.UPLOAD);
|
||||||
|
case DATE_PICKER -> m.setFieldType(FieldType.DATE_PICKER);
|
||||||
|
case TAGS -> m.setFieldType(FieldType.TAGS);
|
||||||
|
case REFERENCE_TYPES -> m.setFieldType(FieldType.REFERENCE_TYPES);
|
||||||
|
case DATASET_IDENTIFIER -> m.setFieldType(FieldType.DATASET_IDENTIFIER);
|
||||||
|
case CURRENCY -> m.setFieldType(FieldType.CURRENCY);
|
||||||
|
case VALIDATION -> m.setFieldType(FieldType.VALIDATION);
|
||||||
|
default -> throw new MyApplicationException("unrecognized type " + d.getFieldType());
|
||||||
|
}
|
||||||
|
this.buildChild(d, m);
|
||||||
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.descriptiontemplate.fielddata;
|
||||||
|
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.fielddata.LabelAndMultiplicityDataModel;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.LabelAndMultiplicityDataEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class LabelAndMultiplicityDataCommonModelBuilder extends BaseFieldDataCommonModelBuilder<LabelAndMultiplicityDataModel, LabelAndMultiplicityDataEntity> {
|
||||||
|
@Autowired
|
||||||
|
public LabelAndMultiplicityDataCommonModelBuilder(
|
||||||
|
ConventionService conventionService
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(LabelAndMultiplicityDataCommonModelBuilder.class)));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected LabelAndMultiplicityDataModel getInstance() {
|
||||||
|
return new LabelAndMultiplicityDataModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void buildChild(LabelAndMultiplicityDataEntity d, LabelAndMultiplicityDataModel m) {
|
||||||
|
m.setMultipleSelect(d.getMultipleSelect());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.descriptiontemplate.fielddata;
|
||||||
|
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.fielddata.LabelDataModel;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.LabelDataEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class LabelDataCommonModelBuilder extends BaseFieldDataCommonModelBuilder<LabelDataModel, LabelDataEntity> {
|
||||||
|
@Autowired
|
||||||
|
public LabelDataCommonModelBuilder(
|
||||||
|
ConventionService conventionService
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(LabelDataCommonModelBuilder.class)));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected LabelDataModel getInstance() {
|
||||||
|
return new LabelDataModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void buildChild(LabelDataEntity d, LabelDataModel m) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.descriptiontemplate.fielddata;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.fielddata.RadioBoxDataModel;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.RadioBoxDataEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class RadioBoxDataCommonModelBuilder extends BaseFieldDataCommonModelBuilder<RadioBoxDataModel, RadioBoxDataEntity> {
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
@Autowired
|
||||||
|
public RadioBoxDataCommonModelBuilder(
|
||||||
|
ConventionService conventionService, BuilderFactory builderFactory
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(RadioBoxDataCommonModelBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected RadioBoxDataModel getInstance() {
|
||||||
|
return new RadioBoxDataModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void buildChild(RadioBoxDataEntity d, RadioBoxDataModel m) {
|
||||||
|
m.setOptions(this.builderFactory.builder(RadioBoxOptionCommonModelBuilder.class).authorize(this.authorize).build(d.getOptions()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public static class RadioBoxOptionCommonModelBuilder extends BaseCommonModelBuilder<RadioBoxDataModel.RadioBoxOptionModel, RadioBoxDataEntity.RadioBoxDataOptionEntity> {
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
@Autowired
|
||||||
|
public RadioBoxOptionCommonModelBuilder(
|
||||||
|
ConventionService conventionService
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(RadioBoxOptionCommonModelBuilder.class)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public RadioBoxOptionCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<CommonModelBuilderItemResponse<RadioBoxDataModel.RadioBoxOptionModel, RadioBoxDataEntity.RadioBoxDataOptionEntity>> buildInternal(List<RadioBoxDataEntity.RadioBoxDataOptionEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<CommonModelBuilderItemResponse<RadioBoxDataModel.RadioBoxOptionModel, RadioBoxDataEntity.RadioBoxDataOptionEntity>> models = new ArrayList<>();
|
||||||
|
for (RadioBoxDataEntity.RadioBoxDataOptionEntity d : data) {
|
||||||
|
RadioBoxDataModel.RadioBoxOptionModel m = new RadioBoxDataModel.RadioBoxOptionModel();
|
||||||
|
m.setLabel(d.getLabel());
|
||||||
|
m.setValue(d.getValue());
|
||||||
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.descriptiontemplate.fielddata;
|
||||||
|
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.fielddata.ReferenceTypeDataModel;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.ReferenceTypeDataEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.ReferenceTypeBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.ReferenceTypeCommonModelBuilder;
|
||||||
|
import eu.eudat.query.ReferenceTypeQuery;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class ReferenceTypeDataCommonModelBuilder extends BaseFieldDataCommonModelBuilder<ReferenceTypeDataModel, ReferenceTypeDataEntity> {
|
||||||
|
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
@Autowired
|
||||||
|
public ReferenceTypeDataCommonModelBuilder(
|
||||||
|
ConventionService conventionService, QueryFactory queryFactory, BuilderFactory builderFactory
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeDataCommonModelBuilder.class)));
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ReferenceTypeDataModel getInstance() {
|
||||||
|
return new ReferenceTypeDataModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void buildChild(ReferenceTypeDataEntity d, ReferenceTypeDataModel m) {
|
||||||
|
if (d.getReferenceTypeId() != null) m.setReferenceType(this.builderFactory.builder(ReferenceTypeCommonModelBuilder.class).build(this.queryFactory.query(ReferenceTypeQuery.class).ids(d.getReferenceTypeId()).first())); //TODO: Optimize
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.descriptiontemplate.fielddata;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.fielddata.SelectDataModel;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.SelectDataEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class SelectDataCommonModelBuilder extends BaseFieldDataCommonModelBuilder<SelectDataModel, SelectDataEntity> {
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
@Autowired
|
||||||
|
public SelectDataCommonModelBuilder(
|
||||||
|
ConventionService conventionService, BuilderFactory builderFactory
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(SelectDataCommonModelBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SelectDataModel getInstance() {
|
||||||
|
return new SelectDataModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void buildChild(SelectDataEntity d, SelectDataModel m) {
|
||||||
|
m.setOptions(this.builderFactory.builder(SelectOptionCommonModelBuilder.class).authorize(this.authorize).build(d.getOptions()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public static class SelectOptionCommonModelBuilder extends BaseCommonModelBuilder<SelectDataModel.OptionModel, SelectDataEntity.OptionEntity> {
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
@Autowired
|
||||||
|
public SelectOptionCommonModelBuilder(
|
||||||
|
ConventionService conventionService
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(SelectOptionCommonModelBuilder.class)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public SelectOptionCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<CommonModelBuilderItemResponse<SelectDataModel.OptionModel, SelectDataEntity.OptionEntity>> buildInternal(List<SelectDataEntity.OptionEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<CommonModelBuilderItemResponse<SelectDataModel.OptionModel, SelectDataEntity.OptionEntity>> models = new ArrayList<>();
|
||||||
|
for (SelectDataEntity.OptionEntity d : data) {
|
||||||
|
SelectDataModel.OptionModel m = new SelectDataModel.OptionModel();
|
||||||
|
m.setLabel(d.getLabel());
|
||||||
|
m.setValue(d.getValue());
|
||||||
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.descriptiontemplate.fielddata;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.fielddata.UploadDataModel;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.UploadDataEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class UploadDataCommonModelBuilder extends BaseFieldDataCommonModelBuilder<UploadDataModel, UploadDataEntity> {
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
@Autowired
|
||||||
|
public UploadDataCommonModelBuilder(
|
||||||
|
ConventionService conventionService, BuilderFactory builderFactory
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(UploadDataCommonModelBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected UploadDataModel getInstance() {
|
||||||
|
return new UploadDataModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void buildChild(UploadDataEntity d, UploadDataModel m) {
|
||||||
|
m.setTypes(this.builderFactory.builder(UploadOptionCommonModelBuilder.class).authorize(this.authorize).build(d.getTypes()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public static class UploadOptionCommonModelBuilder extends BaseCommonModelBuilder<UploadDataModel.UploadOptionModel, UploadDataEntity.UploadDataOptionEntity> {
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
@Autowired
|
||||||
|
public UploadOptionCommonModelBuilder(
|
||||||
|
ConventionService conventionService
|
||||||
|
) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(UploadOptionCommonModelBuilder.class)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public UploadOptionCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<CommonModelBuilderItemResponse<UploadDataModel.UploadOptionModel, UploadDataEntity.UploadDataOptionEntity>> buildInternal(List<UploadDataEntity.UploadDataOptionEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
List<CommonModelBuilderItemResponse<UploadDataModel.UploadOptionModel, UploadDataEntity.UploadDataOptionEntity>> models = new ArrayList<>();
|
||||||
|
for (UploadDataEntity.UploadDataOptionEntity d : data) {
|
||||||
|
UploadDataModel.UploadOptionModel m = new UploadDataModel.UploadOptionModel();
|
||||||
|
m.setLabel(d.getLabel());
|
||||||
|
m.setValue(d.getValue());
|
||||||
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
package eu.eudat.model.builder.commonmodels.reference;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.enums.ReferenceSourceType;
|
||||||
|
import eu.eudat.commonmodels.models.reference.ReferenceModel;
|
||||||
|
import eu.eudat.commonmodels.models.reference.ReferenceTypeModel;
|
||||||
|
import eu.eudat.commons.XmlHandlingService;
|
||||||
|
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.data.ReferenceTypeEntity;
|
||||||
|
import eu.eudat.data.ReferenceEntity;
|
||||||
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
|
import eu.eudat.model.builder.commonmodels.ReferenceTypeCommonModelBuilder;
|
||||||
|
import eu.eudat.query.ReferenceTypeQuery;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class ReferenceCommonModelBuilder extends BaseCommonModelBuilder<ReferenceModel, ReferenceEntity> {
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
private final XmlHandlingService xmlHandlingService;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ReferenceCommonModelBuilder(
|
||||||
|
ConventionService conventionService,
|
||||||
|
BuilderFactory builderFactory, QueryFactory queryFactory, XmlHandlingService xmlHandlingService) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceCommonModelBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.xmlHandlingService = xmlHandlingService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<CommonModelBuilderItemResponse<ReferenceModel, ReferenceEntity>> buildInternal(List<ReferenceEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
|
Map<UUID, ReferenceTypeModel> typeMap = this.collectReferenceTypes(data);
|
||||||
|
List<CommonModelBuilderItemResponse<ReferenceModel, ReferenceEntity>> models = new ArrayList<>();
|
||||||
|
for (ReferenceEntity d : data) {
|
||||||
|
ReferenceModel m = new ReferenceModel();
|
||||||
|
m.setId(d.getId());
|
||||||
|
m.setLabel(d.getLabel());
|
||||||
|
if (d.getDefinition() != null){
|
||||||
|
DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, d.getDefinition());
|
||||||
|
m.setDefinition(this.builderFactory.builder(ReferenceDefinitionCommonModelBuilder.class).authorize(this.authorize).build(definition));
|
||||||
|
}
|
||||||
|
m.setReference(d.getReference());
|
||||||
|
m.setAbbreviation(d.getAbbreviation());
|
||||||
|
m.setDescription(d.getDescription());
|
||||||
|
m.setSource(d.getSource());
|
||||||
|
switch (d.getSourceType()){
|
||||||
|
case Internal -> m.setSourceType(ReferenceSourceType.Internal);
|
||||||
|
case External -> m.setSourceType(ReferenceSourceType.External);
|
||||||
|
default -> throw new MyApplicationException("unrecognized type " + d.getSourceType().getValue());
|
||||||
|
}
|
||||||
|
if (typeMap != null && d.getTypeId() != null && typeMap.containsKey(d.getTypeId())) m.setType(typeMap.get(d.getTypeId()));
|
||||||
|
|
||||||
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
}
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Map<UUID, ReferenceTypeModel> collectReferenceTypes(List<ReferenceEntity> data) throws MyApplicationException {
|
||||||
|
if (data.isEmpty())
|
||||||
|
return null;
|
||||||
|
this.logger.debug("checking related - {}", ReferenceTypeModel.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<UUID, ReferenceTypeModel> itemMap;
|
||||||
|
ReferenceTypeQuery q = this.queryFactory.query(ReferenceTypeQuery.class).authorize(this.authorize).ids(data.stream().map(ReferenceEntity::getTypeId).distinct().collect(Collectors.toList()));
|
||||||
|
itemMap = this.builderFactory.builder(ReferenceTypeCommonModelBuilder.class).authorize(this.authorize).asForeignKey(q, ReferenceTypeEntity::getId);
|
||||||
|
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,11 @@
|
||||||
package eu.eudat.model.builder.deposit;
|
package eu.eudat.model.builder.commonmodels.reference;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.reference.ReferenceDefinitionModel;
|
||||||
import eu.eudat.commons.types.reference.DefinitionEntity;
|
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.depositinterface.models.reference.DefinitionDepositModel;
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
@ -15,33 +17,33 @@ import org.springframework.context.annotation.Scope;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class ReferenceDefinitionDepositBuilder extends BaseDepositBuilder<DefinitionDepositModel, DefinitionEntity> {
|
public class ReferenceDefinitionCommonModelBuilder extends BaseCommonModelBuilder<ReferenceDefinitionModel, DefinitionEntity> {
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public ReferenceDefinitionDepositBuilder(
|
public ReferenceDefinitionCommonModelBuilder(
|
||||||
ConventionService conventionService, BuilderFactory builderFactory) {
|
ConventionService conventionService, BuilderFactory builderFactory) {
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceDefinitionDepositBuilder.class)));
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceDefinitionCommonModelBuilder.class)));
|
||||||
this.builderFactory = builderFactory;
|
this.builderFactory = builderFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReferenceDefinitionDepositBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
public ReferenceDefinitionCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
this.authorize = values;
|
this.authorize = values;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<DepositBuilderItemResponse<DefinitionDepositModel, DefinitionEntity>> buildInternal(List<DefinitionEntity> data) throws MyApplicationException {
|
protected List<CommonModelBuilderItemResponse<ReferenceDefinitionModel, DefinitionEntity>> buildInternal(List<DefinitionEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
List<DepositBuilderItemResponse<DefinitionDepositModel, DefinitionEntity>> models = new ArrayList<>();
|
List<CommonModelBuilderItemResponse<ReferenceDefinitionModel, DefinitionEntity>> models = new ArrayList<>();
|
||||||
for (DefinitionEntity d : data) {
|
for (DefinitionEntity d : data) {
|
||||||
DefinitionDepositModel m = new DefinitionDepositModel();
|
ReferenceDefinitionModel m = new ReferenceDefinitionModel();
|
||||||
if (d.getFields() != null) m.setFields(this.builderFactory.builder(ReferenceFieldDepositBuilder.class).authorize(this.authorize).build(d.getFields()));
|
if (d.getFields() != null) m.setFields(this.builderFactory.builder(ReferenceFieldCommonModelBuilder.class).authorize(this.authorize).build(d.getFields()));
|
||||||
models.add(new DepositBuilderItemResponse<>(m, d));
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
}
|
}
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
return models;
|
return models;
|
|
@ -1,9 +1,11 @@
|
||||||
package eu.eudat.model.builder.deposit;
|
package eu.eudat.model.builder.commonmodels.reference;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.reference.ReferenceFieldModel;
|
||||||
import eu.eudat.commons.types.reference.FieldEntity;
|
import eu.eudat.commons.types.reference.FieldEntity;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.depositinterface.models.reference.FieldDepositModel;
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -17,33 +19,33 @@ import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class ReferenceFieldDepositBuilder extends BaseDepositBuilder<FieldDepositModel, FieldEntity> {
|
public class ReferenceFieldCommonModelBuilder extends BaseCommonModelBuilder<ReferenceFieldModel, FieldEntity> {
|
||||||
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public ReferenceFieldDepositBuilder(
|
public ReferenceFieldCommonModelBuilder(
|
||||||
ConventionService conventionService) {
|
ConventionService conventionService) {
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceFieldDepositBuilder.class)));
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceFieldCommonModelBuilder.class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReferenceFieldDepositBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
public ReferenceFieldCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
this.authorize = values;
|
this.authorize = values;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<DepositBuilderItemResponse<FieldDepositModel, FieldEntity>> buildInternal(List<FieldEntity> data) throws MyApplicationException {
|
protected List<CommonModelBuilderItemResponse<ReferenceFieldModel, FieldEntity>> buildInternal(List<FieldEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
|
||||||
List<DepositBuilderItemResponse<FieldDepositModel, FieldEntity>> models = new ArrayList<>();
|
List<CommonModelBuilderItemResponse<ReferenceFieldModel, FieldEntity>> models = new ArrayList<>();
|
||||||
for (FieldEntity d : data) {
|
for (FieldEntity d : data) {
|
||||||
FieldDepositModel m = new FieldDepositModel();
|
ReferenceFieldModel m = new ReferenceFieldModel();
|
||||||
m.setCode(d.getCode());
|
m.setCode(d.getCode());
|
||||||
m.setValue(d.getValue());
|
m.setValue(d.getValue());
|
||||||
|
|
||||||
models.add(new DepositBuilderItemResponse<>(m, d));
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
}
|
}
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
return models;
|
return models;
|
|
@ -1,101 +0,0 @@
|
||||||
package eu.eudat.model.builder.deposit;
|
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
|
||||||
import eu.eudat.commons.JsonHandlingService;
|
|
||||||
import eu.eudat.commons.XmlHandlingService;
|
|
||||||
import eu.eudat.commons.enums.IsActive;
|
|
||||||
import eu.eudat.commons.types.description.PropertyDefinitionEntity;
|
|
||||||
import eu.eudat.convention.ConventionService;
|
|
||||||
import eu.eudat.data.DescriptionEntity;
|
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
|
||||||
import eu.eudat.depositinterface.models.DescriptionDepositModel;
|
|
||||||
import eu.eudat.model.*;
|
|
||||||
import eu.eudat.model.builder.*;
|
|
||||||
import eu.eudat.model.builder.descriptionpropertiesdefinition.PropertyDefinitionBuilder;
|
|
||||||
import eu.eudat.query.*;
|
|
||||||
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;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
|
||||||
public class DescriptionDepositBuilder extends BaseDepositBuilder<DescriptionDepositModel, DescriptionEntity> {
|
|
||||||
|
|
||||||
private final QueryFactory queryFactory;
|
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
|
||||||
private final JsonHandlingService jsonHandlingService;
|
|
||||||
|
|
||||||
private final XmlHandlingService xmlHandlingService;
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public DescriptionDepositBuilder(
|
|
||||||
ConventionService conventionService,
|
|
||||||
QueryFactory queryFactory,
|
|
||||||
BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService) {
|
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionDepositBuilder.class)));
|
|
||||||
this.queryFactory = queryFactory;
|
|
||||||
this.builderFactory = builderFactory;
|
|
||||||
this.jsonHandlingService = jsonHandlingService;
|
|
||||||
this.xmlHandlingService = xmlHandlingService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DescriptionDepositBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
|
||||||
this.authorize = values;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<DepositBuilderItemResponse<DescriptionDepositModel, DescriptionEntity>> buildInternal(List<DescriptionEntity> data) throws MyApplicationException {
|
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
|
||||||
|
|
||||||
Map<UUID, eu.eudat.commons.types.descriptiontemplate.DefinitionEntity> definitionMap = this.collectDescriptionTemplates(data);
|
|
||||||
|
|
||||||
List<DepositBuilderItemResponse<DescriptionDepositModel, DescriptionEntity>> models = new ArrayList<>();
|
|
||||||
for (DescriptionEntity d : data) {
|
|
||||||
DescriptionDepositModel m = new DescriptionDepositModel();
|
|
||||||
m.setLabel(d.getLabel());
|
|
||||||
m.setDescription(d.getDescription());
|
|
||||||
if (d.getProperties() != null){
|
|
||||||
//TODO Update with the new logic of property definition
|
|
||||||
// PropertyDefinitionEntity propertyDefinition = this.jsonHandlingService.fromJsonSafe(PropertyDefinitionEntity.class, d.getProperties());
|
|
||||||
// if (definitionMap != null && definitionMap.containsKey(d.getDescriptionTemplateId()) && propertyDefinition != null && !this.conventionService.isListNullOrEmpty(propertyDefinition.getFields())) m.setFields(this.builderFactory.builder(DescriptionFieldDepositBuilder.class).authorize(this.authorize).setDefinition(definitionMap.get(d.getDescriptionTemplateId())).build(propertyDefinition.getFields()));
|
|
||||||
}
|
|
||||||
models.add(new DepositBuilderItemResponse<>(m, d));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
|
||||||
|
|
||||||
return models;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<UUID, eu.eudat.commons.types.descriptiontemplate.DefinitionEntity> collectDescriptionTemplates(List<DescriptionEntity> data) throws MyApplicationException {
|
|
||||||
if (data.isEmpty())
|
|
||||||
return null;
|
|
||||||
this.logger.debug("checking related - {}", DescriptionTemplate.class.getSimpleName());
|
|
||||||
|
|
||||||
List<DescriptionTemplateEntity> descriptionTemplateEntities = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(DescriptionTemplate._id).ensure(DescriptionTemplate._definition));
|
|
||||||
Map<UUID, eu.eudat.commons.types.descriptiontemplate.DefinitionEntity>itemMap = new HashMap<>();
|
|
||||||
|
|
||||||
for (DescriptionTemplateEntity descriptionTemplateEntity : descriptionTemplateEntities){
|
|
||||||
eu.eudat.commons.types.descriptiontemplate.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(eu.eudat.commons.types.descriptiontemplate.DefinitionEntity.class, descriptionTemplateEntity.getDefinition());
|
|
||||||
itemMap.put(descriptionTemplateEntity.getId(), definition);
|
|
||||||
}
|
|
||||||
return itemMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,112 +0,0 @@
|
||||||
package eu.eudat.model.builder.deposit;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
|
||||||
import eu.eudat.commons.types.description.FieldEntity;
|
|
||||||
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
|
||||||
import eu.eudat.convention.ConventionService;
|
|
||||||
import eu.eudat.depositinterface.enums.FieldType;
|
|
||||||
import eu.eudat.depositinterface.models.DescriptionFieldDepositModel;
|
|
||||||
import eu.eudat.service.fielddatahelper.FieldDataHelperServiceProvider;
|
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
|
||||||
import gr.cite.tools.logging.LoggerService;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
|
||||||
public class DescriptionFieldDepositBuilder extends BaseDepositBuilder<DescriptionFieldDepositModel, FieldEntity> {
|
|
||||||
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
|
||||||
private eu.eudat.commons.types.descriptiontemplate.DefinitionEntity definition;
|
|
||||||
private final FieldDataHelperServiceProvider fieldDataHelperServiceProvider;
|
|
||||||
@Autowired
|
|
||||||
public DescriptionFieldDepositBuilder(
|
|
||||||
ConventionService conventionService, FieldDataHelperServiceProvider fieldDataHelperServiceProvider
|
|
||||||
) {
|
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionFieldDepositBuilder.class)));
|
|
||||||
this.fieldDataHelperServiceProvider = fieldDataHelperServiceProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DescriptionFieldDepositBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
|
||||||
this.authorize = values;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DescriptionFieldDepositBuilder setDefinition(DefinitionEntity definition) {
|
|
||||||
this.definition = definition;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<DepositBuilderItemResponse<DescriptionFieldDepositModel, FieldEntity>> buildInternal(List<FieldEntity> data) throws MyApplicationException {
|
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
|
||||||
|
|
||||||
List<DepositBuilderItemResponse<DescriptionFieldDepositModel, FieldEntity>> models = new ArrayList<>();
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
|
||||||
for (FieldEntity d : data) {
|
|
||||||
DescriptionFieldDepositModel m = new DescriptionFieldDepositModel();
|
|
||||||
if (definition != null){
|
|
||||||
|
|
||||||
//TODO Update with the new logic of property definition
|
|
||||||
//List<eu.eudat.commons.types.descriptiontemplate.FieldEntity> fieldEntities = definition.getFieldById(d.getKey());
|
|
||||||
List<eu.eudat.commons.types.descriptiontemplate.FieldEntity> fieldEntities = new ArrayList<>();
|
|
||||||
if (!this.conventionService.isListNullOrEmpty(fieldEntities)){
|
|
||||||
eu.eudat.commons.types.descriptiontemplate.FieldEntity field = fieldEntities.getFirst();
|
|
||||||
m.setSchematics(field.getSchematics());
|
|
||||||
if (field.getData() != null) {
|
|
||||||
boolean isMultiValue = fieldDataHelperServiceProvider.get(field.getData().getFieldType()).isMultiValue(field.getData());
|
|
||||||
if (!isMultiValue) m.setValues(List.of(d.getTextValue()));
|
|
||||||
else {
|
|
||||||
try {
|
|
||||||
//TODO: Find better Solution
|
|
||||||
List<Object> values = objectMapper.readValue(d.getTextValue(), new TypeReference<List<Object>>() {});
|
|
||||||
m.setValues(values);
|
|
||||||
} catch (JsonProcessingException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (field.getData().getFieldType()) {
|
|
||||||
case SELECT -> m.setFieldType(FieldType.WORD_LIST);
|
|
||||||
case BOOLEAN_DECISION -> m.setFieldType(FieldType.BOOLEAN_DECISION);
|
|
||||||
case RADIO_BOX -> m.setFieldType(FieldType.RADIO_BOX);
|
|
||||||
case INTERNAL_ENTRIES_DMPS -> m.setFieldType(FieldType.INTERNAL_DMP_ENTRIES_DMPS);
|
|
||||||
case INTERNAL_ENTRIES_DESCRIPTIONS -> m.setFieldType(FieldType.INTERNAL_DMP_ENTRIES_DATASETS);
|
|
||||||
case CHECK_BOX -> m.setFieldType(FieldType.CHECK_BOX);
|
|
||||||
case FREE_TEXT -> m.setFieldType(FieldType.FREE_TEXT);
|
|
||||||
case TEXT_AREA -> m.setFieldType(FieldType.TEXT_AREA);
|
|
||||||
case RICH_TEXT_AREA -> m.setFieldType(FieldType.RICH_TEXT_AREA);
|
|
||||||
case UPLOAD -> m.setFieldType(FieldType.UPLOAD);
|
|
||||||
case DATE_PICKER -> m.setFieldType(FieldType.DATE_PICKER);
|
|
||||||
// case REFERENCE_TYPES -> m.setFieldType(FieldType.REFERENCE_TYPES); //TODO new reference logic
|
|
||||||
case TAGS -> m.setFieldType(FieldType.TAGS);
|
|
||||||
case DATASET_IDENTIFIER -> m.setFieldType(FieldType.DATASET_IDENTIFIER);
|
|
||||||
case CURRENCY -> m.setFieldType(FieldType.CURRENCY);
|
|
||||||
case VALIDATION -> m.setFieldType(FieldType.VALIDATION);
|
|
||||||
default -> throw new MyApplicationException("unrecognized type " + field.getData().getFieldType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
models.add(new DepositBuilderItemResponse<>(m, d));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
|
||||||
|
|
||||||
return models;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,75 +0,0 @@
|
||||||
package eu.eudat.model.builder.deposit;
|
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
|
||||||
import eu.eudat.commons.XmlHandlingService;
|
|
||||||
import eu.eudat.commons.types.reference.DefinitionEntity;
|
|
||||||
import eu.eudat.convention.ConventionService;
|
|
||||||
import eu.eudat.data.ReferenceEntity;
|
|
||||||
import eu.eudat.depositinterface.enums.ReferenceSourceType;
|
|
||||||
import eu.eudat.depositinterface.models.ReferenceDepositModel;
|
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
|
||||||
import gr.cite.tools.logging.LoggerService;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
|
||||||
public class ReferenceDepositBuilder extends BaseDepositBuilder<ReferenceDepositModel, ReferenceEntity> {
|
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
|
||||||
private final XmlHandlingService xmlHandlingService;
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public ReferenceDepositBuilder(
|
|
||||||
ConventionService conventionService,
|
|
||||||
BuilderFactory builderFactory, XmlHandlingService xmlHandlingService) {
|
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceDepositBuilder.class)));
|
|
||||||
this.builderFactory = builderFactory;
|
|
||||||
this.xmlHandlingService = xmlHandlingService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReferenceDepositBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
|
||||||
this.authorize = values;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<DepositBuilderItemResponse<ReferenceDepositModel, ReferenceEntity>> buildInternal(List<ReferenceEntity> data) throws MyApplicationException {
|
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
|
||||||
|
|
||||||
List<DepositBuilderItemResponse<ReferenceDepositModel, ReferenceEntity>> models = new ArrayList<>();
|
|
||||||
for (ReferenceEntity d : data) {
|
|
||||||
ReferenceDepositModel m = new ReferenceDepositModel();
|
|
||||||
m.setId(d.getId());
|
|
||||||
m.setLabel(d.getLabel());
|
|
||||||
if (d.getDefinition() != null){
|
|
||||||
DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, d.getDefinition());
|
|
||||||
m.setDefinition(this.builderFactory.builder(ReferenceDefinitionDepositBuilder.class).authorize(this.authorize).build(definition));
|
|
||||||
}
|
|
||||||
m.setReference(d.getReference());
|
|
||||||
m.setAbbreviation(d.getAbbreviation());
|
|
||||||
m.setDescription(d.getDescription());
|
|
||||||
m.setSource(d.getSource());
|
|
||||||
switch (d.getSourceType()){
|
|
||||||
case Internal -> m.setSourceType(ReferenceSourceType.Internal);
|
|
||||||
case External -> m.setSourceType(ReferenceSourceType.External);
|
|
||||||
default -> throw new MyApplicationException("unrecognized type " + d.getSourceType().getValue());
|
|
||||||
}
|
|
||||||
// m.setType(d.getTypeId()); //TODO new reference logic
|
|
||||||
models.add(new DepositBuilderItemResponse<>(m, d));
|
|
||||||
}
|
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
|
||||||
return models;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -65,13 +65,8 @@ public class FieldBuilder extends BaseBuilder<Field, FieldEntity> {
|
||||||
if (fields.hasField(this.asIndexer(Field._numbering))) m.setNumbering(d.getNumbering());
|
if (fields.hasField(this.asIndexer(Field._numbering))) m.setNumbering(d.getNumbering());
|
||||||
if (!visibilityRulesFields.isEmpty() && d.getVisibilityRules() != null) m.setVisibilityRules(this.builderFactory.builder(RuleBuilder.class).authorize(this.authorize).build(visibilityRulesFields, d.getVisibilityRules()));
|
if (!visibilityRulesFields.isEmpty() && d.getVisibilityRules() != null) m.setVisibilityRules(this.builderFactory.builder(RuleBuilder.class).authorize(this.authorize).build(visibilityRulesFields, d.getVisibilityRules()));
|
||||||
if (!dataFields.isEmpty() && d.getData() != null){
|
if (!dataFields.isEmpty() && d.getData() != null){
|
||||||
try {
|
|
||||||
FieldDataHelperService fieldDataHelperService = this.fieldDataHelperServiceProvider.get(d.getData().getFieldType());
|
FieldDataHelperService fieldDataHelperService = this.fieldDataHelperServiceProvider.get(d.getData().getFieldType());
|
||||||
m.setData(fieldDataHelperService.buildOne(dataFields, d.getData(), this.authorize));
|
m.setData(fieldDataHelperService.buildOne(dataFields, d.getData(), this.authorize));
|
||||||
|
|
||||||
} catch (Exception e){
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
models.add(m);
|
models.add(m);
|
||||||
|
|
|
@ -10,9 +10,6 @@ import gr.cite.tools.fieldset.FieldSet;
|
||||||
import gr.cite.tools.logging.DataLogEntry;
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
|
@ -1,77 +1,77 @@
|
||||||
package eu.eudat.model.builder.filetransformer;
|
//package eu.eudat.model.builder.filetransformer;
|
||||||
|
//
|
||||||
import eu.eudat.convention.ConventionService;
|
//import eu.eudat.convention.ConventionService;
|
||||||
import gr.cite.tools.data.builder.Builder;
|
//import gr.cite.tools.data.builder.Builder;
|
||||||
import gr.cite.tools.data.query.QueryBase;
|
//import gr.cite.tools.data.query.QueryBase;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
//import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
//import gr.cite.tools.logging.LoggerService;
|
||||||
|
//
|
||||||
import java.util.*;
|
//import java.util.*;
|
||||||
import java.util.function.Function;
|
//import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
//import java.util.stream.Collectors;
|
||||||
|
//
|
||||||
public abstract class BaseFileTransformerBuilder<M, D> implements Builder {
|
//public abstract class BaseFileTransformerBuilder<M, D> implements Builder {
|
||||||
protected final LoggerService logger;
|
// protected final LoggerService logger;
|
||||||
protected final ConventionService conventionService;
|
// protected final ConventionService conventionService;
|
||||||
|
//
|
||||||
public BaseFileTransformerBuilder(
|
// public BaseFileTransformerBuilder(
|
||||||
ConventionService conventionService,
|
// ConventionService conventionService,
|
||||||
LoggerService logger
|
// LoggerService logger
|
||||||
) {
|
// ) {
|
||||||
this.conventionService = conventionService;
|
// this.conventionService = conventionService;
|
||||||
this.logger = logger;
|
// this.logger = logger;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public M build(D data) throws MyApplicationException {
|
// public M build(D data) throws MyApplicationException {
|
||||||
if (data == null) {
|
// if (data == null) {
|
||||||
//this.logger.Debug(new MapLogEntry("requested build for null item requesting fields").And("fields", directives));
|
// //this.logger.Debug(new MapLogEntry("requested build for null item requesting fields").And("fields", directives));
|
||||||
// return default(M);
|
//// return default(M);
|
||||||
M model = null;
|
// M model = null;
|
||||||
return null; //TODO
|
// return null; //TODO
|
||||||
}
|
// }
|
||||||
List<FileTransformerBuilderItemResponse<M, D>> models = this.buildInternal(List.of(data));
|
// List<FileTransformerBuilderItemResponse<M, D>> models = this.buildInternal(List.of(data));
|
||||||
return models.stream().map(FileTransformerBuilderItemResponse::getModel).findFirst().orElse(null); //TODO
|
// return models.stream().map(FileTransformerBuilderItemResponse::getModel).findFirst().orElse(null); //TODO
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public List<M> build(List<D> data) throws MyApplicationException{
|
// public List<M> build(List<D> data) throws MyApplicationException{
|
||||||
List<FileTransformerBuilderItemResponse<M, D>> models = this.buildInternal(data);
|
// List<FileTransformerBuilderItemResponse<M, D>> models = this.buildInternal(data);
|
||||||
return models == null ? null : models.stream().map(FileTransformerBuilderItemResponse::getModel).collect(Collectors.toList());
|
// return models == null ? null : models.stream().map(FileTransformerBuilderItemResponse::getModel).collect(Collectors.toList());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
protected abstract List<FileTransformerBuilderItemResponse<M, D>> buildInternal(List<D> data) throws MyApplicationException;
|
// protected abstract List<FileTransformerBuilderItemResponse<M, D>> buildInternal(List<D> data) throws MyApplicationException;
|
||||||
|
//
|
||||||
public <K> Map<K, M> asForeignKey(QueryBase<D> query, Function<D, K> keySelector) throws MyApplicationException {
|
// public <K> Map<K, M> asForeignKey(QueryBase<D> query, Function<D, K> keySelector) throws MyApplicationException {
|
||||||
this.logger.trace("Building references from query");
|
// this.logger.trace("Building references from query");
|
||||||
List<D> data = query.collect();
|
// List<D> data = query.collect();
|
||||||
this.logger.debug("collected {} items to build", Optional.ofNullable(data).map(List::size).orElse(0));
|
// this.logger.debug("collected {} items to build", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
return this.asForeignKey(data, keySelector);
|
// return this.asForeignKey(data, keySelector);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public <K> Map<K, M> asForeignKey(List<D> data, Function<D, K> keySelector) throws MyApplicationException {
|
// public <K> Map<K, M> asForeignKey(List<D> data, Function<D, K> keySelector) throws MyApplicationException {
|
||||||
this.logger.trace("building references");
|
// this.logger.trace("building references");
|
||||||
List<FileTransformerBuilderItemResponse<M, D>> models = this.buildInternal(data);
|
// List<FileTransformerBuilderItemResponse<M, D>> models = this.buildInternal(data);
|
||||||
this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0));
|
// this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
return models == null ? new HashMap<>() : models.stream().collect(Collectors.toMap(x-> keySelector.apply(x.getData()), FileTransformerBuilderItemResponse::getModel));
|
// return models == null ? new HashMap<>() : models.stream().collect(Collectors.toMap(x-> keySelector.apply(x.getData()), FileTransformerBuilderItemResponse::getModel));
|
||||||
}
|
// }
|
||||||
public <K> Map<K, List<M>> asMasterKey(QueryBase<D> query,Function<D, K> keySelector) throws MyApplicationException {
|
// public <K> Map<K, List<M>> asMasterKey(QueryBase<D> query,Function<D, K> keySelector) throws MyApplicationException {
|
||||||
this.logger.trace("Building details from query");
|
// this.logger.trace("Building details from query");
|
||||||
List<D> data = query.collect();
|
// List<D> data = query.collect();
|
||||||
this.logger.debug("collected {} items to build", Optional.ofNullable(data).map(List::size).orElse(0));
|
// this.logger.debug("collected {} items to build", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
return this.asMasterKey(data, keySelector);
|
// return this.asMasterKey(data, keySelector);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public <K> Map<K, List<M>> asMasterKey(List<D> data, Function<D, K> keySelector) throws MyApplicationException {
|
// public <K> Map<K, List<M>> asMasterKey(List<D> data, Function<D, K> keySelector) throws MyApplicationException {
|
||||||
this.logger.trace("building details");
|
// this.logger.trace("building details");
|
||||||
List<FileTransformerBuilderItemResponse<M, D>> models = this.buildInternal(data);
|
// List<FileTransformerBuilderItemResponse<M, D>> models = this.buildInternal(data);
|
||||||
this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0));
|
// this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
Map<K, List<M>> map = new HashMap<>();
|
// Map<K, List<M>> map = new HashMap<>();
|
||||||
if (models == null) return map;
|
// if (models == null) return map;
|
||||||
for (FileTransformerBuilderItemResponse<M, D> model : models) {
|
// for (FileTransformerBuilderItemResponse<M, D> model : models) {
|
||||||
K key = keySelector.apply(model.getData());
|
// K key = keySelector.apply(model.getData());
|
||||||
if (!map.containsKey(key)) map.put(key, new ArrayList<M>());
|
// if (!map.containsKey(key)) map.put(key, new ArrayList<M>());
|
||||||
map.get(key).add(model.getModel());
|
// map.get(key).add(model.getModel());
|
||||||
}
|
// }
|
||||||
return map;
|
// return map;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
|
|
@ -1,270 +1,265 @@
|
||||||
package eu.eudat.model.builder.filetransformer;
|
//package eu.eudat.model.builder.filetransformer;
|
||||||
|
//
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
//import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
//import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
//import eu.eudat.commons.types.description.FieldEntity;
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
//import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.commons.types.description.FieldEntity;
|
//import eu.eudat.file.transformer.models.descriptiontemplate.DescriptionTemplateFileTransformerModel;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
//import eu.eudat.file.transformer.models.descriptiontemplate.definition.*;
|
||||||
import eu.eudat.convention.ConventionService;
|
//import eu.eudat.service.fielddatahelper.FieldDataHelperServiceProvider;
|
||||||
import eu.eudat.depositinterface.enums.FieldType;
|
//import gr.cite.tools.exception.MyApplicationException;
|
||||||
import eu.eudat.depositinterface.models.DescriptionFieldDepositModel;
|
//import gr.cite.tools.logging.LoggerService;
|
||||||
import eu.eudat.file.transformer.models.descriptiontemplate.DescriptionTemplateFileTransformerModel;
|
//import org.slf4j.LoggerFactory;
|
||||||
import eu.eudat.file.transformer.models.descriptiontemplate.definition.*;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import eu.eudat.service.fielddatahelper.FieldDataHelperServiceProvider;
|
//import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
//import org.springframework.context.annotation.Scope;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
//import org.springframework.stereotype.Component;
|
||||||
import org.slf4j.LoggerFactory;
|
//
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import java.util.*;
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
//
|
||||||
import org.springframework.context.annotation.Scope;
|
//@Component
|
||||||
import org.springframework.stereotype.Component;
|
//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
//public class DescriptionFieldFileTransformerBuilder extends BaseFileTransformerBuilder<DescriptionTemplateFileTransformerModel, FieldEntity> {
|
||||||
import java.util.*;
|
//
|
||||||
|
// private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
@Component
|
// private DescriptionTemplateFileTransformerModel definition;
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
// private final FieldDataHelperServiceProvider fieldDataHelperServiceProvider;
|
||||||
public class DescriptionFieldFileTransformerBuilder extends BaseFileTransformerBuilder<DescriptionTemplateFileTransformerModel, FieldEntity> {
|
//
|
||||||
|
// @Autowired
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
// public DescriptionFieldFileTransformerBuilder(
|
||||||
private DescriptionTemplateFileTransformerModel definition;
|
// ConventionService conventionService, FieldDataHelperServiceProvider fieldDataHelperServiceProvider
|
||||||
private final FieldDataHelperServiceProvider fieldDataHelperServiceProvider;
|
// ) {
|
||||||
|
// super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionFieldFileTransformerBuilder.class)));
|
||||||
@Autowired
|
// this.fieldDataHelperServiceProvider = fieldDataHelperServiceProvider;
|
||||||
public DescriptionFieldFileTransformerBuilder(
|
// }
|
||||||
ConventionService conventionService, FieldDataHelperServiceProvider fieldDataHelperServiceProvider
|
//
|
||||||
) {
|
// public DescriptionFieldFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionFieldFileTransformerBuilder.class)));
|
// this.authorize = values;
|
||||||
this.fieldDataHelperServiceProvider = fieldDataHelperServiceProvider;
|
// return this;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public DescriptionFieldFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
// public DescriptionFieldFileTransformerBuilder setDefinition(DescriptionTemplateFileTransformerModel definition) {
|
||||||
this.authorize = values;
|
// this.definition = definition;
|
||||||
return this;
|
// return this;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public DescriptionFieldFileTransformerBuilder setDefinition(DescriptionTemplateFileTransformerModel definition) {
|
// @Override
|
||||||
this.definition = definition;
|
// protected List<FileTransformerBuilderItemResponse<DescriptionTemplateFileTransformerModel, FieldEntity>> buildInternal(List<FieldEntity> data) throws MyApplicationException {
|
||||||
return this;
|
// this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
}
|
// if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
//
|
||||||
@Override
|
// // List<FileTransformerBuilderItemResponse<DescriptionFieldDepositModel, FieldEntity>> models = new ArrayList<>();
|
||||||
protected List<FileTransformerBuilderItemResponse<DescriptionTemplateFileTransformerModel, FieldEntity>> buildInternal(List<FieldEntity> data) throws MyApplicationException {
|
// ObjectMapper objectMapper = new ObjectMapper();
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
// for (FieldEntity d : data) {
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
// // DescriptionFieldDepositModel m = new DescriptionFieldDepositModel();
|
||||||
|
// if (definition != null){
|
||||||
List<FileTransformerBuilderItemResponse<DescriptionFieldDepositModel, FieldEntity>> models = new ArrayList<>();
|
// //TODO Update with the new logic of property definition
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
//// FieldFileTransformerModel fieldEntity = findFieldById(d.getKey());
|
||||||
for (FieldEntity d : data) {
|
// FieldFileTransformerModel fieldEntity = new FieldFileTransformerModel();
|
||||||
// DescriptionFieldDepositModel m = new DescriptionFieldDepositModel();
|
// if (fieldEntity != null){
|
||||||
if (definition != null){
|
// //m.setSchematics(fieldEntity.getSchematics());
|
||||||
//TODO Update with the new logic of property definition
|
// if (fieldEntity.getData() != null) {
|
||||||
// FieldFileTransformerModel fieldEntity = findFieldById(d.getKey());
|
// /*boolean isMultiValue = fieldDataHelperServiceProvider.get(eu.eudat.commons.enums.FieldType.of(fieldEntity.getData().getFieldType().getValue())).isMultiValue(fieldEntity.getData());
|
||||||
FieldFileTransformerModel fieldEntity = new FieldFileTransformerModel();
|
// if (!isMultiValue) fieldEntity.getData().setValue(List.of(d.getValue());
|
||||||
if (fieldEntity != null){
|
// else {
|
||||||
//m.setSchematics(fieldEntity.getSchematics());
|
// fieldEntity.getData().setValue(d.getValue());
|
||||||
if (fieldEntity.getData() != null) {
|
// }
|
||||||
/*boolean isMultiValue = fieldDataHelperServiceProvider.get(eu.eudat.commons.enums.FieldType.of(fieldEntity.getData().getFieldType().getValue())).isMultiValue(fieldEntity.getData());
|
// */
|
||||||
if (!isMultiValue) fieldEntity.getData().setValue(List.of(d.getValue());
|
// /*switch (field.getData().getFieldType()) {
|
||||||
else {
|
// case AUTO_COMPLETE -> m.setFieldType(FieldType.AUTO_COMPLETE);
|
||||||
fieldEntity.getData().setValue(d.getValue());
|
// case WORD_LIST -> m.setFieldType(FieldType.WORD_LIST);
|
||||||
}
|
// case BOOLEAN_DECISION -> m.setFieldType(FieldType.BOOLEAN_DECISION);
|
||||||
*/
|
// case RADIO_BOX -> m.setFieldType(FieldType.RADIO_BOX);
|
||||||
/*switch (field.getData().getFieldType()) {
|
// case INTERNAL_DMP_ENTRIES_RESEARCHERS -> m.setFieldType(FieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS);
|
||||||
case AUTO_COMPLETE -> m.setFieldType(FieldType.AUTO_COMPLETE);
|
// case INTERNAL_DMP_ENTRIES_DMPS -> m.setFieldType(FieldType.INTERNAL_DMP_ENTRIES_DMPS);
|
||||||
case WORD_LIST -> m.setFieldType(FieldType.WORD_LIST);
|
// case INTERNAL_DMP_ENTRIES_DATASETS -> m.setFieldType(FieldType.INTERNAL_DMP_ENTRIES_DATASETS);
|
||||||
case BOOLEAN_DECISION -> m.setFieldType(FieldType.BOOLEAN_DECISION);
|
// case CHECK_BOX -> m.setFieldType(FieldType.CHECK_BOX);
|
||||||
case RADIO_BOX -> m.setFieldType(FieldType.RADIO_BOX);
|
// case FREE_TEXT -> m.setFieldType(FieldType.FREE_TEXT);
|
||||||
case INTERNAL_DMP_ENTRIES_RESEARCHERS -> m.setFieldType(FieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS);
|
// case TEXT_AREA -> m.setFieldType(FieldType.TEXT_AREA);
|
||||||
case INTERNAL_DMP_ENTRIES_DMPS -> m.setFieldType(FieldType.INTERNAL_DMP_ENTRIES_DMPS);
|
// case RICH_TEXT_AREA -> m.setFieldType(FieldType.RICH_TEXT_AREA);
|
||||||
case INTERNAL_DMP_ENTRIES_DATASETS -> m.setFieldType(FieldType.INTERNAL_DMP_ENTRIES_DATASETS);
|
// case UPLOAD -> m.setFieldType(FieldType.UPLOAD);
|
||||||
case CHECK_BOX -> m.setFieldType(FieldType.CHECK_BOX);
|
// case DATE_PICKER -> m.setFieldType(FieldType.DATE_PICKER);
|
||||||
case FREE_TEXT -> m.setFieldType(FieldType.FREE_TEXT);
|
// case EXTERNAL_DATASETS -> m.setFieldType(FieldType.EXTERNAL_DATASETS);
|
||||||
case TEXT_AREA -> m.setFieldType(FieldType.TEXT_AREA);
|
// case DATA_REPOSITORIES -> m.setFieldType(FieldType.DATA_REPOSITORIES);
|
||||||
case RICH_TEXT_AREA -> m.setFieldType(FieldType.RICH_TEXT_AREA);
|
// case JOURNAL_REPOSITORIES -> m.setFieldType(FieldType.JOURNAL_REPOSITORIES);
|
||||||
case UPLOAD -> m.setFieldType(FieldType.UPLOAD);
|
// case PUB_REPOSITORIES -> m.setFieldType(FieldType.PUB_REPOSITORIES);
|
||||||
case DATE_PICKER -> m.setFieldType(FieldType.DATE_PICKER);
|
// case LICENSES -> m.setFieldType(FieldType.LICENSES);
|
||||||
case EXTERNAL_DATASETS -> m.setFieldType(FieldType.EXTERNAL_DATASETS);
|
// case PUBLICATIONS -> m.setFieldType(FieldType.PUBLICATIONS);
|
||||||
case DATA_REPOSITORIES -> m.setFieldType(FieldType.DATA_REPOSITORIES);
|
// case REGISTRIES -> m.setFieldType(FieldType.REGISTRIES);
|
||||||
case JOURNAL_REPOSITORIES -> m.setFieldType(FieldType.JOURNAL_REPOSITORIES);
|
// case SERVICES -> m.setFieldType(FieldType.SERVICES);
|
||||||
case PUB_REPOSITORIES -> m.setFieldType(FieldType.PUB_REPOSITORIES);
|
// case TAGS -> m.setFieldType(FieldType.TAGS);
|
||||||
case LICENSES -> m.setFieldType(FieldType.LICENSES);
|
// case RESEARCHERS -> m.setFieldType(FieldType.RESEARCHERS);
|
||||||
case PUBLICATIONS -> m.setFieldType(FieldType.PUBLICATIONS);
|
// case ORGANIZATIONS -> m.setFieldType(FieldType.ORGANIZATIONS);
|
||||||
case REGISTRIES -> m.setFieldType(FieldType.REGISTRIES);
|
// case DATASET_IDENTIFIER -> m.setFieldType(FieldType.DATASET_IDENTIFIER);
|
||||||
case SERVICES -> m.setFieldType(FieldType.SERVICES);
|
// case CURRENCY -> m.setFieldType(FieldType.CURRENCY);
|
||||||
case TAGS -> m.setFieldType(FieldType.TAGS);
|
// case VALIDATION -> m.setFieldType(FieldType.VALIDATION);
|
||||||
case RESEARCHERS -> m.setFieldType(FieldType.RESEARCHERS);
|
// case TAXONOMIES -> m.setFieldType(FieldType.TAXONOMIES);
|
||||||
case ORGANIZATIONS -> m.setFieldType(FieldType.ORGANIZATIONS);
|
// default -> throw new MyApplicationException("unrecognized type " + field.getData().getFieldType());
|
||||||
case DATASET_IDENTIFIER -> m.setFieldType(FieldType.DATASET_IDENTIFIER);
|
// }*/
|
||||||
case CURRENCY -> m.setFieldType(FieldType.CURRENCY);
|
// }
|
||||||
case VALIDATION -> m.setFieldType(FieldType.VALIDATION);
|
// }
|
||||||
case TAXONOMIES -> m.setFieldType(FieldType.TAXONOMIES);
|
// }
|
||||||
default -> throw new MyApplicationException("unrecognized type " + field.getData().getFieldType());
|
// //models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
||||||
}*/
|
// }
|
||||||
}
|
//
|
||||||
}
|
// for (PageFileTransformerModel page : definition.getDefinition().getPages()) {
|
||||||
}
|
// page.setSections(calculateSectionVisibility(page.getSections()));
|
||||||
//models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
// }
|
||||||
}
|
//
|
||||||
|
// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
for (PageFileTransformerModel page : definition.getDefinition().getPages()) {
|
//
|
||||||
page.setSections(calculateSectionVisibility(page.getSections()));
|
// return List.of(new FileTransformerBuilderItemResponse<>(definition, data.get(0)));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
// private FieldFileTransformerModel findFieldById(String id) {
|
||||||
|
// FieldFileTransformerModel result = null;
|
||||||
return List.of(new FileTransformerBuilderItemResponse<>(definition, data.get(0)));
|
// List<PageFileTransformerModel> pages = definition.getDefinition().getPages();
|
||||||
}
|
// for (PageFileTransformerModel page: pages) {
|
||||||
|
// if (page.getSections() != null && !page.getSections().isEmpty()) {
|
||||||
private FieldFileTransformerModel findFieldById(String id) {
|
// result = findSectionFieldById(id, page.getSections());
|
||||||
FieldFileTransformerModel result = null;
|
// if (result != null) {
|
||||||
List<PageFileTransformerModel> pages = definition.getDefinition().getPages();
|
// break;
|
||||||
for (PageFileTransformerModel page: pages) {
|
// }
|
||||||
if (page.getSections() != null && !page.getSections().isEmpty()) {
|
// }
|
||||||
result = findSectionFieldById(id, page.getSections());
|
// }
|
||||||
if (result != null) {
|
// return result;
|
||||||
break;
|
// }
|
||||||
}
|
//
|
||||||
}
|
// private FieldFileTransformerModel findSectionFieldById(String id, List<SectionFileTransformerModel> sections) {
|
||||||
}
|
// FieldFileTransformerModel result = null;
|
||||||
return result;
|
// for (SectionFileTransformerModel section: sections) {
|
||||||
}
|
// if (section.getSections() != null && !section.getSections().isEmpty()) {
|
||||||
|
// result = findSectionFieldById(id, section.getSections());
|
||||||
private FieldFileTransformerModel findSectionFieldById(String id, List<SectionFileTransformerModel> sections) {
|
// }
|
||||||
FieldFileTransformerModel result = null;
|
// if (result == null) {
|
||||||
for (SectionFileTransformerModel section: sections) {
|
// List<FieldSetFileTransformerModel> fieldSets = section.getFieldSets();
|
||||||
if (section.getSections() != null && !section.getSections().isEmpty()) {
|
// if (fieldSets != null && !fieldSets.isEmpty()) {
|
||||||
result = findSectionFieldById(id, section.getSections());
|
// for (FieldSetFileTransformerModel fieldSet : fieldSets) {
|
||||||
}
|
// List<FieldFileTransformerModel> fields = fieldSet.getFields();
|
||||||
if (result == null) {
|
// if (fields != null && !fields.isEmpty()) {
|
||||||
List<FieldSetFileTransformerModel> fieldSets = section.getFieldSets();
|
// for (FieldFileTransformerModel field : fields) {
|
||||||
if (fieldSets != null && !fieldSets.isEmpty()) {
|
// if (field.getId().equals(id)) {
|
||||||
for (FieldSetFileTransformerModel fieldSet : fieldSets) {
|
// result = field;
|
||||||
List<FieldFileTransformerModel> fields = fieldSet.getFields();
|
// break;
|
||||||
if (fields != null && !fields.isEmpty()) {
|
// }
|
||||||
for (FieldFileTransformerModel field : fields) {
|
// }
|
||||||
if (field.getId().equals(id)) {
|
// }
|
||||||
result = field;
|
// if (result != null) {
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (result != null) {
|
// }
|
||||||
break;
|
// }
|
||||||
}
|
// return result;
|
||||||
}
|
// }
|
||||||
}
|
//
|
||||||
}
|
// private List<SectionFileTransformerModel> calculateSectionVisibility(List<SectionFileTransformerModel> sections) {
|
||||||
}
|
// List<SectionFileTransformerModel> result = new ArrayList<>();
|
||||||
return result;
|
//
|
||||||
}
|
// for (SectionFileTransformerModel section : sections) {
|
||||||
|
// if (section.getSections() != null && !section.getSections().isEmpty()) {
|
||||||
private List<SectionFileTransformerModel> calculateSectionVisibility(List<SectionFileTransformerModel> sections) {
|
// section.setSections(calculateSectionVisibility(section.getSections()));
|
||||||
List<SectionFileTransformerModel> result = new ArrayList<>();
|
// }
|
||||||
|
//
|
||||||
for (SectionFileTransformerModel section : sections) {
|
// if (section.getFieldSets() != null && !section.getFieldSets().isEmpty()) {
|
||||||
if (section.getSections() != null && !section.getSections().isEmpty()) {
|
// section.setFieldSets(calculateFieldSetVisibility(section.getFieldSets()));
|
||||||
section.setSections(calculateSectionVisibility(section.getSections()));
|
// }
|
||||||
}
|
//
|
||||||
|
// if ((section.getSections() != null && !section.getSections().isEmpty()) || (section.getFieldSets() != null && !section.getFieldSets().isEmpty())) {
|
||||||
if (section.getFieldSets() != null && !section.getFieldSets().isEmpty()) {
|
// result.add(section);
|
||||||
section.setFieldSets(calculateFieldSetVisibility(section.getFieldSets()));
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if ((section.getSections() != null && !section.getSections().isEmpty()) || (section.getFieldSets() != null && !section.getFieldSets().isEmpty())) {
|
// return result;
|
||||||
result.add(section);
|
// }
|
||||||
}
|
//
|
||||||
}
|
// private List<FieldSetFileTransformerModel> calculateFieldSetVisibility(List<FieldSetFileTransformerModel> fieldSets) {
|
||||||
|
// List<FieldSetFileTransformerModel> result = new ArrayList<>();
|
||||||
return result;
|
// for (FieldSetFileTransformerModel fieldSet : fieldSets) {
|
||||||
}
|
// if (fieldSet.getFields() != null && !fieldSet.getFields().isEmpty()) {
|
||||||
|
// fieldSet.setFields(calculateFieldVisibility(fieldSet.getFields()));
|
||||||
private List<FieldSetFileTransformerModel> calculateFieldSetVisibility(List<FieldSetFileTransformerModel> fieldSets) {
|
// if (fieldSet.getFields() != null && !fieldSet.getFields().isEmpty()) {
|
||||||
List<FieldSetFileTransformerModel> result = new ArrayList<>();
|
// result.add(fieldSet);
|
||||||
for (FieldSetFileTransformerModel fieldSet : fieldSets) {
|
// }
|
||||||
if (fieldSet.getFields() != null && !fieldSet.getFields().isEmpty()) {
|
// }
|
||||||
fieldSet.setFields(calculateFieldVisibility(fieldSet.getFields()));
|
// }
|
||||||
if (fieldSet.getFields() != null && !fieldSet.getFields().isEmpty()) {
|
// return result;
|
||||||
result.add(fieldSet);
|
// }
|
||||||
}
|
//
|
||||||
}
|
// private List<FieldFileTransformerModel> calculateFieldVisibility(List<FieldFileTransformerModel> fields) {
|
||||||
}
|
// List<FieldFileTransformerModel> result = new ArrayList<>();
|
||||||
return result;
|
// for (FieldFileTransformerModel field : fields) {
|
||||||
}
|
// if (field.getVisibilityRules() != null && !field.getVisibilityRules().isEmpty()) {
|
||||||
|
// Integer maxChecks = field.getVisibilityRules().size();
|
||||||
private List<FieldFileTransformerModel> calculateFieldVisibility(List<FieldFileTransformerModel> fields) {
|
// Integer successfulChecks = 0;
|
||||||
List<FieldFileTransformerModel> result = new ArrayList<>();
|
// for (RuleFileTransformerModel rule : field.getVisibilityRules()) {
|
||||||
for (FieldFileTransformerModel field : fields) {
|
// FieldFileTransformerModel targetField = findFieldByPages(definition.getDefinition().getPages(), rule.getTarget());
|
||||||
if (field.getVisibilityRules() != null && !field.getVisibilityRules().isEmpty()) {
|
// if (targetField.getData() != null ) {
|
||||||
Integer maxChecks = field.getVisibilityRules().size();
|
// successfulChecks = targetField.getData().getValue().equals(rule.getValue()) ? successfulChecks + 1 : successfulChecks;
|
||||||
Integer successfulChecks = 0;
|
// }
|
||||||
for (RuleFileTransformerModel rule : field.getVisibilityRules()) {
|
// }
|
||||||
FieldFileTransformerModel targetField = findFieldByPages(definition.getDefinition().getPages(), rule.getTarget());
|
// if (successfulChecks.equals(maxChecks)) {
|
||||||
if (targetField.getData() != null ) {
|
// result.add(field);
|
||||||
successfulChecks = targetField.getData().getValue().equals(rule.getValue()) ? successfulChecks + 1 : successfulChecks;
|
// }
|
||||||
}
|
// } else {
|
||||||
}
|
// result.add(field);
|
||||||
if (successfulChecks.equals(maxChecks)) {
|
// }
|
||||||
result.add(field);
|
// }
|
||||||
}
|
// return result;
|
||||||
} else {
|
// }
|
||||||
result.add(field);
|
//
|
||||||
}
|
// private FieldFileTransformerModel findFieldByPages(List<PageFileTransformerModel> pages, String fieldId) {
|
||||||
}
|
// FieldFileTransformerModel result = null;
|
||||||
return result;
|
// for (PageFileTransformerModel page : pages) {
|
||||||
}
|
// result = findFieldBySections(page.getSections(), fieldId);
|
||||||
|
// if (result != null) {
|
||||||
private FieldFileTransformerModel findFieldByPages(List<PageFileTransformerModel> pages, String fieldId) {
|
// break;
|
||||||
FieldFileTransformerModel result = null;
|
// }
|
||||||
for (PageFileTransformerModel page : pages) {
|
// }
|
||||||
result = findFieldBySections(page.getSections(), fieldId);
|
// return result;
|
||||||
if (result != null) {
|
// }
|
||||||
break;
|
//
|
||||||
}
|
// private FieldFileTransformerModel findFieldBySections(List<SectionFileTransformerModel> sections, String fieldId) {
|
||||||
}
|
// FieldFileTransformerModel result = null;
|
||||||
return result;
|
// for (SectionFileTransformerModel section : sections) {
|
||||||
}
|
// if (section.getSections() != null && !section.getSections().isEmpty()) {
|
||||||
|
// result = findFieldBySections(section.getSections(), fieldId);
|
||||||
private FieldFileTransformerModel findFieldBySections(List<SectionFileTransformerModel> sections, String fieldId) {
|
// if (result != null) {
|
||||||
FieldFileTransformerModel result = null;
|
// break;
|
||||||
for (SectionFileTransformerModel section : sections) {
|
// }
|
||||||
if (section.getSections() != null && !section.getSections().isEmpty()) {
|
// }
|
||||||
result = findFieldBySections(section.getSections(), fieldId);
|
//
|
||||||
if (result != null) {
|
// if (section.getFieldSets() != null && !section.getFieldSets().isEmpty()) {
|
||||||
break;
|
// result = findFieldByFieldSets(section.getFieldSets(), fieldId);
|
||||||
}
|
// if (result != null) {
|
||||||
}
|
// break;
|
||||||
|
// }
|
||||||
if (section.getFieldSets() != null && !section.getFieldSets().isEmpty()) {
|
// }
|
||||||
result = findFieldByFieldSets(section.getFieldSets(), fieldId);
|
// }
|
||||||
if (result != null) {
|
// return result;
|
||||||
break;
|
// }
|
||||||
}
|
//
|
||||||
}
|
// private FieldFileTransformerModel findFieldByFieldSets(List<FieldSetFileTransformerModel> fieldSets, String fieldId) {
|
||||||
}
|
// FieldFileTransformerModel result = null;
|
||||||
return result;
|
// for (FieldSetFileTransformerModel fieldSet: fieldSets) {
|
||||||
}
|
// result = findField(fieldSet.getFields(), fieldId);
|
||||||
|
// if (result != null) {
|
||||||
private FieldFileTransformerModel findFieldByFieldSets(List<FieldSetFileTransformerModel> fieldSets, String fieldId) {
|
// break;
|
||||||
FieldFileTransformerModel result = null;
|
// }
|
||||||
for (FieldSetFileTransformerModel fieldSet: fieldSets) {
|
// }
|
||||||
result = findField(fieldSet.getFields(), fieldId);
|
// return result;
|
||||||
if (result != null) {
|
// }
|
||||||
break;
|
//
|
||||||
}
|
// private FieldFileTransformerModel findField(List<FieldFileTransformerModel> fields, String fieldId) {
|
||||||
}
|
// FieldFileTransformerModel result = null;
|
||||||
return result;
|
// for (FieldFileTransformerModel field: fields) {
|
||||||
}
|
// if (field.getId().equals(fieldId)) {
|
||||||
|
// result = field;
|
||||||
private FieldFileTransformerModel findField(List<FieldFileTransformerModel> fields, String fieldId) {
|
// break;
|
||||||
FieldFileTransformerModel result = null;
|
// }
|
||||||
for (FieldFileTransformerModel field: fields) {
|
// }
|
||||||
if (field.getId().equals(fieldId)) {
|
// return result;
|
||||||
result = field;
|
// }
|
||||||
break;
|
//
|
||||||
}
|
//}
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,171 +1,167 @@
|
||||||
package eu.eudat.model.builder.filetransformer;
|
//package eu.eudat.model.builder.filetransformer;
|
||||||
|
//
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
//import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.commons.JsonHandlingService;
|
//import eu.eudat.commons.JsonHandlingService;
|
||||||
import eu.eudat.commons.XmlHandlingService;
|
//import eu.eudat.commons.XmlHandlingService;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
//import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.types.description.PropertyDefinitionEntity;
|
//import eu.eudat.commons.types.description.PropertyDefinitionEntity;
|
||||||
import eu.eudat.convention.ConventionService;
|
//import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.*;
|
//import eu.eudat.data.*;
|
||||||
import eu.eudat.depositinterface.models.DescriptionDepositModel;
|
//import eu.eudat.file.transformer.enums.DescriptionStatus;
|
||||||
import eu.eudat.file.transformer.enums.DescriptionStatus;
|
//import eu.eudat.file.transformer.models.description.DescriptionFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.description.DescriptionFileTransformerModel;
|
//import eu.eudat.file.transformer.models.description.DescriptionReferenceFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.description.DescriptionReferenceFileTransformerModel;
|
//import eu.eudat.file.transformer.models.description.DescriptionTagFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.description.DescriptionTagFileTransformerModel;
|
//import eu.eudat.file.transformer.models.descriptiontemplate.DescriptionTemplateFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.descriptiontemplate.DescriptionTemplateFileTransformerModel;
|
//import eu.eudat.file.transformer.models.dmp.DmpFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.dmp.DmpFileTransformerModel;
|
//import eu.eudat.file.transformer.models.reference.ReferenceFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.dmp.DmpReferenceFileTransformerModel;
|
//import eu.eudat.file.transformer.models.tag.TagFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.reference.ReferenceFileTransformerModel;
|
//import eu.eudat.model.DescriptionReference;
|
||||||
import eu.eudat.file.transformer.models.tag.TagFileTransformerModel;
|
//import eu.eudat.model.DescriptionTemplate;
|
||||||
import eu.eudat.file.transformer.models.user.UserFileTransformerModel;
|
//import eu.eudat.model.DmpReference;
|
||||||
import eu.eudat.model.DescriptionReference;
|
//import eu.eudat.query.*;
|
||||||
import eu.eudat.model.DescriptionTemplate;
|
//import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import eu.eudat.model.DmpReference;
|
//import gr.cite.tools.data.query.QueryFactory;
|
||||||
import eu.eudat.model.Tag;
|
//import gr.cite.tools.exception.MyApplicationException;
|
||||||
import eu.eudat.model.builder.TagBuilder;
|
//import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
import eu.eudat.query.*;
|
//import gr.cite.tools.logging.LoggerService;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
//import org.slf4j.LoggerFactory;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
//import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
//import org.springframework.context.annotation.Scope;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
//import org.springframework.stereotype.Component;
|
||||||
import org.slf4j.LoggerFactory;
|
//
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import java.util.*;
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
//import java.util.stream.Collectors;
|
||||||
import org.springframework.context.annotation.Scope;
|
//
|
||||||
import org.springframework.stereotype.Component;
|
//@Component
|
||||||
|
//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
import java.util.*;
|
//public class DescriptionFileTransformerBuilder extends BaseFileTransformerBuilder<DescriptionFileTransformerModel, DescriptionEntity> {
|
||||||
import java.util.stream.Collectors;
|
//
|
||||||
|
// private final QueryFactory queryFactory;
|
||||||
@Component
|
//
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
// private final BuilderFactory builderFactory;
|
||||||
public class DescriptionFileTransformerBuilder extends BaseFileTransformerBuilder<DescriptionFileTransformerModel, DescriptionEntity> {
|
// private final JsonHandlingService jsonHandlingService;
|
||||||
|
//
|
||||||
private final QueryFactory queryFactory;
|
// private final XmlHandlingService xmlHandlingService;
|
||||||
|
// private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
private final BuilderFactory builderFactory;
|
//
|
||||||
private final JsonHandlingService jsonHandlingService;
|
// @Autowired
|
||||||
|
// public DescriptionFileTransformerBuilder(
|
||||||
private final XmlHandlingService xmlHandlingService;
|
// ConventionService conventionService,
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
// QueryFactory queryFactory,
|
||||||
|
// BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService) {
|
||||||
@Autowired
|
// super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionFileTransformerBuilder.class)));
|
||||||
public DescriptionFileTransformerBuilder(
|
// this.queryFactory = queryFactory;
|
||||||
ConventionService conventionService,
|
// this.builderFactory = builderFactory;
|
||||||
QueryFactory queryFactory,
|
// this.jsonHandlingService = jsonHandlingService;
|
||||||
BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService) {
|
// this.xmlHandlingService = xmlHandlingService;
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionFileTransformerBuilder.class)));
|
// }
|
||||||
this.queryFactory = queryFactory;
|
//
|
||||||
this.builderFactory = builderFactory;
|
// public DescriptionFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
this.jsonHandlingService = jsonHandlingService;
|
// this.authorize = values;
|
||||||
this.xmlHandlingService = xmlHandlingService;
|
// return this;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public DescriptionFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
// @Override
|
||||||
this.authorize = values;
|
// protected List<FileTransformerBuilderItemResponse<DescriptionFileTransformerModel, DescriptionEntity>> buildInternal(List<DescriptionEntity> data) throws MyApplicationException {
|
||||||
return this;
|
// this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
}
|
// if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
//
|
||||||
@Override
|
// List<DescriptionTemplateFileTransformerModel> definitionMap = this.collectDescriptionTemplates(data);
|
||||||
protected List<FileTransformerBuilderItemResponse<DescriptionFileTransformerModel, DescriptionEntity>> buildInternal(List<DescriptionEntity> data) throws MyApplicationException {
|
// Map<UUID, List<DescriptionReferenceFileTransformerModel>> referenceMap = collectReferences(data);
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
// Map<UUID, List<DescriptionTagFileTransformerModel>> tagMap = collectTags(data);
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
//
|
||||||
|
//
|
||||||
List<DescriptionTemplateFileTransformerModel> definitionMap = this.collectDescriptionTemplates(data);
|
// DmpFileTransformerModel dmp = this.getDmp(data.get(0).getDmpId());
|
||||||
Map<UUID, List<DescriptionReferenceFileTransformerModel>> referenceMap = collectReferences(data);
|
//
|
||||||
Map<UUID, List<DescriptionTagFileTransformerModel>> tagMap = collectTags(data);
|
//
|
||||||
|
// List<FileTransformerBuilderItemResponse<DescriptionFileTransformerModel, DescriptionEntity>> models = new ArrayList<>();
|
||||||
|
// for (DescriptionEntity d : data) {
|
||||||
DmpFileTransformerModel dmp = this.getDmp(data.get(0).getDmpId());
|
// DescriptionFileTransformerModel m = new DescriptionFileTransformerModel();
|
||||||
|
// m.setId(d.getId());
|
||||||
|
// m.setLabel(d.getLabel());
|
||||||
List<FileTransformerBuilderItemResponse<DescriptionFileTransformerModel, DescriptionEntity>> models = new ArrayList<>();
|
// m.setLabel(d.getLabel());
|
||||||
for (DescriptionEntity d : data) {
|
// m.setDescription(d.getDescription());
|
||||||
DescriptionFileTransformerModel m = new DescriptionFileTransformerModel();
|
// m.setCreatedAt(d.getCreatedAt());
|
||||||
m.setId(d.getId());
|
// m.setFinalizedAt(d.getFinalizedAt());
|
||||||
m.setLabel(d.getLabel());
|
// m.setUpdatedAt(d.getUpdatedAt());
|
||||||
m.setDescription(d.getDescription());
|
// m.setStatus(DescriptionStatus.of(d.getStatus().getValue()));
|
||||||
m.setCreatedAt(d.getCreatedAt());
|
// if (d.getProperties() != null){
|
||||||
m.setFinalizedAt(d.getFinalizedAt());
|
// PropertyDefinitionEntity propertyDefinition = this.jsonHandlingService.fromJsonSafe(PropertyDefinitionEntity.class, d.getProperties());
|
||||||
m.setUpdatedAt(d.getUpdatedAt());
|
//
|
||||||
m.setStatus(DescriptionStatus.of(d.getStatus().getValue()));
|
// //TODO Update with the new logic of property definition
|
||||||
if (d.getProperties() != null){
|
//// if (definitionMap != null && definitionMap.stream().anyMatch(dt -> dt.getId().equals(d.getDescriptionTemplateId())) && propertyDefinition != null && !this.conventionService.isListNullOrEmpty(propertyDefinition.getFields())) m.setDescriptionTemplate(this.builderFactory.builder(DescriptionFieldFileTransformerBuilder.class).authorize(this.authorize).setDefinition(definitionMap.stream().filter(dm -> dm.getId().equals(d.getDescriptionTemplateId())).findFirst().get()).build(propertyDefinition.getFields()).get(0));
|
||||||
PropertyDefinitionEntity propertyDefinition = this.jsonHandlingService.fromJsonSafe(PropertyDefinitionEntity.class, d.getProperties());
|
// }
|
||||||
|
// if (referenceMap != null && !referenceMap.isEmpty() && referenceMap.containsKey(d.getId())) m.setDescriptionReferenceFileTransformerModels(referenceMap.get(d.getId()));
|
||||||
//TODO Update with the new logic of property definition
|
// if (tagMap != null && !tagMap.isEmpty() && tagMap.containsKey(d.getId())) m.setDescriptionTagFileTransformerModels(tagMap.get(d.getId()));
|
||||||
// if (definitionMap != null && definitionMap.stream().anyMatch(dt -> dt.getId().equals(d.getDescriptionTemplateId())) && propertyDefinition != null && !this.conventionService.isListNullOrEmpty(propertyDefinition.getFields())) m.setDescriptionTemplate(this.builderFactory.builder(DescriptionFieldFileTransformerBuilder.class).authorize(this.authorize).setDefinition(definitionMap.stream().filter(dm -> dm.getId().equals(d.getDescriptionTemplateId())).findFirst().get()).build(propertyDefinition.getFields()).get(0));
|
//
|
||||||
}
|
// m.setDmp(dmp);
|
||||||
if (referenceMap != null && !referenceMap.isEmpty() && referenceMap.containsKey(d.getId())) m.setDescriptionReferenceFileTransformerModels(referenceMap.get(d.getId()));
|
// models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
||||||
if (tagMap != null && !tagMap.isEmpty() && tagMap.containsKey(d.getId())) m.setDescriptionTagFileTransformerModels(tagMap.get(d.getId()));
|
// }
|
||||||
|
//
|
||||||
m.setDmp(dmp);
|
// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
//
|
||||||
}
|
// return models;
|
||||||
|
// }
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
//
|
||||||
|
// private DmpFileTransformerModel getDmp(UUID id) {
|
||||||
return models;
|
// DmpQuery query = queryFactory.query(DmpQuery.class).authorize(authorize).isActive(IsActive.Active).ids(id);
|
||||||
}
|
// return builderFactory.builder(DmpFileTransformerBuilder.class).ignoreDescriptions(true).authorize(authorize).build(query.first());
|
||||||
|
// }
|
||||||
private DmpFileTransformerModel getDmp(UUID id) {
|
//
|
||||||
DmpQuery query = queryFactory.query(DmpQuery.class).authorize(authorize).isActive(IsActive.Active).ids(id);
|
// private List<DescriptionTemplateFileTransformerModel> collectDescriptionTemplates(List<DescriptionEntity> data) throws MyApplicationException {
|
||||||
return builderFactory.builder(DmpFileTransformerBuilder.class).ignoreDescriptions(true).authorize(authorize).build(query.first());
|
// if (data.isEmpty())
|
||||||
}
|
// return null;
|
||||||
|
// this.logger.debug("checking related - {}", DescriptionTemplate.class.getSimpleName());
|
||||||
private List<DescriptionTemplateFileTransformerModel> collectDescriptionTemplates(List<DescriptionEntity> data) throws MyApplicationException {
|
//
|
||||||
if (data.isEmpty())
|
// List<DescriptionTemplateEntity> descriptionTemplateEntities = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(DescriptionTemplate._id).ensure(DescriptionTemplate._definition));
|
||||||
return null;
|
//
|
||||||
this.logger.debug("checking related - {}", DescriptionTemplate.class.getSimpleName());
|
// return this.builderFactory.builder(DescriptionTemplateFileTransformerBuilder.class).authorize(authorize).build(descriptionTemplateEntities);
|
||||||
|
// }
|
||||||
List<DescriptionTemplateEntity> descriptionTemplateEntities = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(DescriptionTemplate._id).ensure(DescriptionTemplate._definition));
|
//
|
||||||
|
// private Map<UUID, List<DescriptionReferenceFileTransformerModel>> collectReferences(List<DescriptionEntity> data) throws MyApplicationException {
|
||||||
return this.builderFactory.builder(DescriptionTemplateFileTransformerBuilder.class).authorize(authorize).build(descriptionTemplateEntities);
|
// if (data.isEmpty()) return null;
|
||||||
}
|
// this.logger.debug("checking related - {}", DmpReference.class.getSimpleName());
|
||||||
|
//
|
||||||
private Map<UUID, List<DescriptionReferenceFileTransformerModel>> collectReferences(List<DescriptionEntity> data) throws MyApplicationException {
|
// List<DescriptionReferenceEntity> descriptionReferences = this.queryFactory.query(DescriptionReferenceQuery.class).authorize(this.authorize).descriptionIds(data.stream().map(DescriptionEntity::getId).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(DescriptionReference._description).ensure(DescriptionReference._reference));
|
||||||
if (data.isEmpty()) return null;
|
//
|
||||||
this.logger.debug("checking related - {}", DmpReference.class.getSimpleName());
|
// Map<UUID, List<DescriptionReferenceFileTransformerModel>> itemMap = new HashMap<>();
|
||||||
|
// ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).isActive(IsActive.Active).ids(descriptionReferences.stream().map(DescriptionReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()));
|
||||||
List<DescriptionReferenceEntity> descriptionReferences = this.queryFactory.query(DescriptionReferenceQuery.class).authorize(this.authorize).descriptionIds(data.stream().map(DescriptionEntity::getId).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(DescriptionReference._description).ensure(DescriptionReference._reference));
|
// Map<UUID, ReferenceFileTransformerModel> referenceDepositModelMap = this.builderFactory.builder(ReferenceFileTransformerBuilder.class).authorize(this.authorize).asForeignKey(query, ReferenceEntity::getId);
|
||||||
|
// if (referenceDepositModelMap == null) return null;
|
||||||
Map<UUID, List<DescriptionReferenceFileTransformerModel>> itemMap = new HashMap<>();
|
// for (DescriptionReferenceEntity descriptionReference : descriptionReferences) {
|
||||||
ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).isActive(IsActive.Active).ids(descriptionReferences.stream().map(DescriptionReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()));
|
// DescriptionReferenceFileTransformerModel descriptionReferenceFileTransformerModel = new DescriptionReferenceFileTransformerModel();
|
||||||
Map<UUID, ReferenceFileTransformerModel> referenceDepositModelMap = this.builderFactory.builder(ReferenceFileTransformerBuilder.class).authorize(this.authorize).asForeignKey(query, ReferenceEntity::getId);
|
// descriptionReferenceFileTransformerModel.setId(descriptionReference.getId());
|
||||||
if (referenceDepositModelMap == null) return null;
|
// descriptionReferenceFileTransformerModel.setReference(referenceDepositModelMap.getOrDefault(descriptionReference.getReferenceId(), null));
|
||||||
for (DescriptionReferenceEntity descriptionReference : descriptionReferences) {
|
// DescriptionReferenceFileTransformerModel model = descriptionReferenceFileTransformerModel;
|
||||||
DescriptionReferenceFileTransformerModel descriptionReferenceFileTransformerModel = new DescriptionReferenceFileTransformerModel();
|
// if (model == null) continue;
|
||||||
descriptionReferenceFileTransformerModel.setId(descriptionReference.getId());
|
// UUID key = descriptionReference.getDescriptionId();
|
||||||
descriptionReferenceFileTransformerModel.setReference(referenceDepositModelMap.getOrDefault(descriptionReference.getReferenceId(), null));
|
// if (!itemMap.containsKey(key)) itemMap.put(key, new ArrayList<>());
|
||||||
DescriptionReferenceFileTransformerModel model = descriptionReferenceFileTransformerModel;
|
// itemMap.get(key).add(model);
|
||||||
if (model == null) continue;
|
// }
|
||||||
UUID key = descriptionReference.getDescriptionId();
|
// return itemMap;
|
||||||
if (!itemMap.containsKey(key)) itemMap.put(key, new ArrayList<>());
|
// }
|
||||||
itemMap.get(key).add(model);
|
//
|
||||||
}
|
// private Map<UUID, List<DescriptionTagFileTransformerModel>> collectTags(List<DescriptionEntity> data) {
|
||||||
return itemMap;
|
// if (data.isEmpty()) return null;
|
||||||
}
|
//
|
||||||
|
// List<DescriptionTagEntity> descriptionTags = this.queryFactory.query(DescriptionTagQuery.class).authorize(this.authorize).descriptionIds(data.stream().map(DescriptionEntity::getId).distinct().toList()).collect();
|
||||||
private Map<UUID, List<DescriptionTagFileTransformerModel>> collectTags(List<DescriptionEntity> data) {
|
//
|
||||||
if (data.isEmpty()) return null;
|
// Map<UUID, List<DescriptionTagFileTransformerModel>> itemMap = new HashMap<>();
|
||||||
|
// TagQuery query = this.queryFactory.query(TagQuery.class).authorize(this.authorize).isActive(IsActive.Active).ids(descriptionTags.stream().map(DescriptionTagEntity::getTagId).distinct().toList());
|
||||||
List<DescriptionTagEntity> descriptionTags = this.queryFactory.query(DescriptionTagQuery.class).authorize(this.authorize).descriptionIds(data.stream().map(DescriptionEntity::getId).distinct().toList()).collect();
|
// Map<UUID, TagFileTransformerModel> tagMap = this.builderFactory.builder(TagFileTransformerBuilder.class).asForeignKey(query, TagEntity::getId);
|
||||||
|
// for (DescriptionTagEntity descriptionTag : descriptionTags) {
|
||||||
Map<UUID, List<DescriptionTagFileTransformerModel>> itemMap = new HashMap<>();
|
// DescriptionTagFileTransformerModel descriptionTagFileTransformerModel = new DescriptionTagFileTransformerModel();
|
||||||
TagQuery query = this.queryFactory.query(TagQuery.class).authorize(this.authorize).isActive(IsActive.Active).ids(descriptionTags.stream().map(DescriptionTagEntity::getTagId).distinct().toList());
|
// descriptionTagFileTransformerModel.setId(descriptionTag.getId());
|
||||||
Map<UUID, TagFileTransformerModel> tagMap = this.builderFactory.builder(TagFileTransformerBuilder.class).asForeignKey(query, TagEntity::getId);
|
// descriptionTagFileTransformerModel.setTagFileTransformerModel(tagMap.getOrDefault(descriptionTag.getTagId(), null));
|
||||||
for (DescriptionTagEntity descriptionTag : descriptionTags) {
|
// DescriptionTagFileTransformerModel model = descriptionTagFileTransformerModel;
|
||||||
DescriptionTagFileTransformerModel descriptionTagFileTransformerModel = new DescriptionTagFileTransformerModel();
|
// if (model == null) continue;
|
||||||
descriptionTagFileTransformerModel.setId(descriptionTag.getId());
|
// UUID key = descriptionTag.getDescriptionId();
|
||||||
descriptionTagFileTransformerModel.setTagFileTransformerModel(tagMap.getOrDefault(descriptionTag.getTagId(), null));
|
// if (!itemMap.containsKey(key)) itemMap.put(key, new ArrayList<>());
|
||||||
DescriptionTagFileTransformerModel model = descriptionTagFileTransformerModel;
|
// itemMap.get(key).add(model);
|
||||||
if (model == null) continue;
|
// }
|
||||||
UUID key = descriptionTag.getDescriptionId();
|
//
|
||||||
if (!itemMap.containsKey(key)) itemMap.put(key, new ArrayList<>());
|
// return itemMap;
|
||||||
itemMap.get(key).add(model);
|
// }
|
||||||
}
|
//
|
||||||
|
//}
|
||||||
return itemMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,243 +1,243 @@
|
||||||
package eu.eudat.model.builder.filetransformer;
|
//package eu.eudat.model.builder.filetransformer;
|
||||||
|
//
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
//import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.commons.JsonHandlingService;
|
//import eu.eudat.commons.JsonHandlingService;
|
||||||
import eu.eudat.commons.XmlHandlingService;
|
//import eu.eudat.commons.XmlHandlingService;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.*;
|
//import eu.eudat.commons.types.descriptiontemplate.*;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.*;
|
//import eu.eudat.commons.types.descriptiontemplate.fielddata.*;
|
||||||
import eu.eudat.convention.ConventionService;
|
//import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.file.transformer.enums.FieldDataExternalDatasetType;
|
//import eu.eudat.file.transformer.enums.FieldDataExternalDatasetType;
|
||||||
import eu.eudat.file.transformer.enums.FieldType;
|
//import eu.eudat.file.transformer.enums.FieldType;
|
||||||
import eu.eudat.file.transformer.enums.FieldValidationType;
|
//import eu.eudat.file.transformer.enums.FieldValidationType;
|
||||||
import eu.eudat.file.transformer.models.descriptiontemplate.definition.*;
|
//import eu.eudat.file.transformer.models.descriptiontemplate.definition.*;
|
||||||
import eu.eudat.file.transformer.models.descriptiontemplate.definition.fielddata.*;
|
//import eu.eudat.file.transformer.models.descriptiontemplate.definition.fielddata.*;
|
||||||
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;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
//import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
//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 java.util.ArrayList;
|
//import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
//import java.util.EnumSet;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import java.util.Optional;
|
//import java.util.Optional;
|
||||||
|
//
|
||||||
@Component
|
//@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class DescriptionTemplateDefinitionFileTransformerBuilder extends BaseFileTransformerBuilder<DefinitionFileTransformerModel, DefinitionEntity> {
|
//public class DescriptionTemplateDefinitionFileTransformerBuilder extends BaseFileTransformerBuilder<DefinitionFileTransformerModel, DefinitionEntity> {
|
||||||
|
//
|
||||||
private final QueryFactory queryFactory;
|
// private final QueryFactory queryFactory;
|
||||||
|
//
|
||||||
private final BuilderFactory builderFactory;
|
// private final BuilderFactory builderFactory;
|
||||||
private final JsonHandlingService jsonHandlingService;
|
// private final JsonHandlingService jsonHandlingService;
|
||||||
|
//
|
||||||
private final XmlHandlingService xmlHandlingService;
|
// private final XmlHandlingService xmlHandlingService;
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
// private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
public DescriptionTemplateDefinitionFileTransformerBuilder(
|
// public DescriptionTemplateDefinitionFileTransformerBuilder(
|
||||||
ConventionService conventionService,
|
// ConventionService conventionService,
|
||||||
QueryFactory queryFactory,
|
// QueryFactory queryFactory,
|
||||||
BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService) {
|
// BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService) {
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionTemplateDefinitionFileTransformerBuilder.class)));
|
// super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionTemplateDefinitionFileTransformerBuilder.class)));
|
||||||
this.queryFactory = queryFactory;
|
// this.queryFactory = queryFactory;
|
||||||
this.builderFactory = builderFactory;
|
// this.builderFactory = builderFactory;
|
||||||
this.jsonHandlingService = jsonHandlingService;
|
// this.jsonHandlingService = jsonHandlingService;
|
||||||
this.xmlHandlingService = xmlHandlingService;
|
// this.xmlHandlingService = xmlHandlingService;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public DescriptionTemplateDefinitionFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
// public DescriptionTemplateDefinitionFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
this.authorize = values;
|
// this.authorize = values;
|
||||||
return this;
|
// return this;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
protected List<FileTransformerBuilderItemResponse<DefinitionFileTransformerModel, DefinitionEntity>> buildInternal(List<DefinitionEntity> data) throws MyApplicationException {
|
// protected List<FileTransformerBuilderItemResponse<DefinitionFileTransformerModel, DefinitionEntity>> buildInternal(List<DefinitionEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
// this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
// if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
//
|
||||||
List<FileTransformerBuilderItemResponse<DefinitionFileTransformerModel, DefinitionEntity>> models = new ArrayList<>();
|
// List<FileTransformerBuilderItemResponse<DefinitionFileTransformerModel, DefinitionEntity>> models = new ArrayList<>();
|
||||||
for (DefinitionEntity d : data) {
|
// for (DefinitionEntity d : data) {
|
||||||
DefinitionFileTransformerModel m = new DefinitionFileTransformerModel();
|
// DefinitionFileTransformerModel m = new DefinitionFileTransformerModel();
|
||||||
m.setPages(collectPages(d.getPages()));
|
// m.setPages(collectPages(d.getPages()));
|
||||||
models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
// models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
//
|
||||||
return models;
|
// return models;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private List<PageFileTransformerModel> collectPages(List<PageEntity> data) {
|
// private List<PageFileTransformerModel> collectPages(List<PageEntity> data) {
|
||||||
List<PageFileTransformerModel> result = new ArrayList<>();
|
// List<PageFileTransformerModel> result = new ArrayList<>();
|
||||||
for (PageEntity d: data) {
|
// for (PageEntity d: data) {
|
||||||
PageFileTransformerModel m = new PageFileTransformerModel();
|
// PageFileTransformerModel m = new PageFileTransformerModel();
|
||||||
m.setId(d.getId());
|
// m.setId(d.getId());
|
||||||
m.setOrdinal(d.getOrdinal());
|
// m.setOrdinal(d.getOrdinal());
|
||||||
m.setTitle(d.getTitle());
|
// m.setTitle(d.getTitle());
|
||||||
if (d.getSections() != null) m.setSections(collectSections(d.getSections()));
|
// if (d.getSections() != null) m.setSections(collectSections(d.getSections()));
|
||||||
result.add(m);
|
// result.add(m);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private List<SectionFileTransformerModel> collectSections(List<SectionEntity> data) {
|
// private List<SectionFileTransformerModel> collectSections(List<SectionEntity> data) {
|
||||||
List<SectionFileTransformerModel> result = new ArrayList<>();
|
// List<SectionFileTransformerModel> result = new ArrayList<>();
|
||||||
for (SectionEntity d : data) {
|
// for (SectionEntity d : data) {
|
||||||
SectionFileTransformerModel m = new SectionFileTransformerModel();
|
// SectionFileTransformerModel m = new SectionFileTransformerModel();
|
||||||
m.setId(d.getId());
|
// m.setId(d.getId());
|
||||||
m.setDescription(d.getDescription());
|
// m.setDescription(d.getDescription());
|
||||||
m.setTitle(d.getTitle());
|
// m.setTitle(d.getTitle());
|
||||||
m.setOrdinal(d.getOrdinal());
|
// m.setOrdinal(d.getOrdinal());
|
||||||
m.setDefaultVisibility(d.isDefaultVisibility());
|
// m.setDefaultVisibility(d.isDefaultVisibility());
|
||||||
m.setExtendedDescription(d.getExtendedDescription());
|
// m.setExtendedDescription(d.getExtendedDescription());
|
||||||
m.setMultiplicity(d.getMultiplicity());
|
// m.setMultiplicity(d.getMultiplicity());
|
||||||
m.setNumbering(d.getNumbering());
|
// m.setNumbering(d.getNumbering());
|
||||||
if (d.getSections() != null && !d.getSections().isEmpty()) {
|
// if (d.getSections() != null && !d.getSections().isEmpty()) {
|
||||||
m.setSections(collectSections(d.getSections()));
|
// m.setSections(collectSections(d.getSections()));
|
||||||
}
|
// }
|
||||||
if (d.getFieldSets() != null && !d.getFieldSets().isEmpty()) {
|
// if (d.getFieldSets() != null && !d.getFieldSets().isEmpty()) {
|
||||||
m.setFieldSets(collectFieldSet(d.getFieldSets()));
|
// m.setFieldSets(collectFieldSet(d.getFieldSets()));
|
||||||
}
|
// }
|
||||||
result.add(m);
|
// result.add(m);
|
||||||
}
|
// }
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private List<FieldSetFileTransformerModel> collectFieldSet(List<FieldSetEntity> data) {
|
// private List<FieldSetFileTransformerModel> collectFieldSet(List<FieldSetEntity> data) {
|
||||||
List<FieldSetFileTransformerModel> result = new ArrayList<>();
|
// List<FieldSetFileTransformerModel> result = new ArrayList<>();
|
||||||
for (FieldSetEntity d : data) {
|
// for (FieldSetEntity d : data) {
|
||||||
FieldSetFileTransformerModel m = new FieldSetFileTransformerModel();
|
// FieldSetFileTransformerModel m = new FieldSetFileTransformerModel();
|
||||||
m.setId(d.getId());
|
// m.setId(d.getId());
|
||||||
m.setDescription(d.getDescription());
|
// m.setDescription(d.getDescription());
|
||||||
m.setExtendedDescription(d.getExtendedDescription());
|
// m.setExtendedDescription(d.getExtendedDescription());
|
||||||
m.setAdditionalInformation(d.getAdditionalInformation());
|
// m.setAdditionalInformation(d.getAdditionalInformation());
|
||||||
m.setHasCommentField(d.getHasCommentField());
|
// m.setHasCommentField(d.getHasCommentField());
|
||||||
m.setNumbering(d.getNumbering());
|
// m.setNumbering(d.getNumbering());
|
||||||
m.setOrdinal(d.getOrdinal());
|
// m.setOrdinal(d.getOrdinal());
|
||||||
m.setTitle(d.getTitle());
|
// m.setTitle(d.getTitle());
|
||||||
//m.setMultiplicity(); //TODO: No multiplicity in this code (yet)
|
// //m.setMultiplicity(); //TODO: No multiplicity in this code (yet)
|
||||||
m.setFields(convertFields(d.getFields()));
|
// m.setFields(convertFields(d.getFields()));
|
||||||
result.add(m);
|
// result.add(m);
|
||||||
}
|
// }
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private List<FieldFileTransformerModel> convertFields(List<FieldEntity> data) {
|
// private List<FieldFileTransformerModel> convertFields(List<FieldEntity> data) {
|
||||||
List<FieldFileTransformerModel> result = new ArrayList<>();
|
// List<FieldFileTransformerModel> result = new ArrayList<>();
|
||||||
for (FieldEntity d : data) {
|
// for (FieldEntity d : data) {
|
||||||
FieldFileTransformerModel m = new FieldFileTransformerModel();
|
// FieldFileTransformerModel m = new FieldFileTransformerModel();
|
||||||
m.setId(d.getId());
|
// m.setId(d.getId());
|
||||||
m.setSchematics(d.getSchematics());
|
// m.setSchematics(d.getSchematics());
|
||||||
m.setNumbering(d.getNumbering());
|
// m.setNumbering(d.getNumbering());
|
||||||
m.setOrdinal(d.getOrdinal());
|
// m.setOrdinal(d.getOrdinal());
|
||||||
m.setDefaultValue(d.getDefaultValue());
|
// m.setDefaultValue(d.getDefaultValue());
|
||||||
m.setIncludeInExport(d.getIncludeInExport());
|
// m.setIncludeInExport(d.getIncludeInExport());
|
||||||
m.setValidations(d.getValidations().stream().map(fieldValidationType -> FieldValidationType.of(fieldValidationType.getValue())).toList());
|
// m.setValidations(d.getValidations().stream().map(fieldValidationType -> FieldValidationType.of(fieldValidationType.getValue())).toList());
|
||||||
if (d.getVisibilityRules() != null && !d.getVisibilityRules().isEmpty()) {
|
// if (d.getVisibilityRules() != null && !d.getVisibilityRules().isEmpty()) {
|
||||||
m.setVisibilityRules(convertVisibilityRules(d.getVisibilityRules()));
|
// m.setVisibilityRules(convertVisibilityRules(d.getVisibilityRules()));
|
||||||
}
|
// }
|
||||||
m.setData(convertData(d.getData()));
|
// m.setData(convertData(d.getData()));
|
||||||
result.add(m);
|
// result.add(m);
|
||||||
}
|
// }
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public List<RuleFileTransformerModel> convertVisibilityRules(List<RuleEntity> data) {
|
// public List<RuleFileTransformerModel> convertVisibilityRules(List<RuleEntity> data) {
|
||||||
List<RuleFileTransformerModel> result = new ArrayList<>();
|
// List<RuleFileTransformerModel> result = new ArrayList<>();
|
||||||
for (RuleEntity d : data) {
|
// for (RuleEntity d : data) {
|
||||||
RuleFileTransformerModel m = new RuleFileTransformerModel();
|
// RuleFileTransformerModel m = new RuleFileTransformerModel();
|
||||||
m.setTarget(d.getTarget());
|
// m.setTarget(d.getTarget());
|
||||||
m.setValue(d.getValue());
|
// m.setValue(d.getValue());
|
||||||
result.add(m);
|
// result.add(m);
|
||||||
}
|
// }
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public BaseFieldDataFileTransformerModel convertData (BaseFieldDataEntity data) {
|
// public BaseFieldDataFileTransformerModel convertData (BaseFieldDataEntity data) {
|
||||||
BaseFieldDataFileTransformerModel m;
|
// BaseFieldDataFileTransformerModel m;
|
||||||
switch (data) { //TODO new reference logic
|
// switch (data) { //TODO new reference logic
|
||||||
// case ExternalSelectDataEntity d -> {
|
//// case ExternalSelectDataEntity d -> {
|
||||||
// m = new ExternalSelectDataFileTransformerModel();
|
//// m = new ExternalSelectDataFileTransformerModel();
|
||||||
|
//// m.setLabel(d.getLabel());
|
||||||
|
//// m.setFieldType(FieldType.of(d.getFieldType().getValue()));
|
||||||
|
//// ((ExternalSelectDataFileTransformerModel)m).setMultipleSelect(d.getMultipleSelect());
|
||||||
|
//// ((ExternalSelectDataFileTransformerModel) m).setSources(convertAutoCompleteSingleData(d.getSources()));
|
||||||
|
//// }
|
||||||
|
//// case ExternalDatasetDataEntity d -> {
|
||||||
|
//// m = new ExternalDatasetDataFileTransformerModel();
|
||||||
|
//// m.setLabel(d.getLabel());
|
||||||
|
//// m.setFieldType(FieldType.of(d.getFieldType().getValue()));
|
||||||
|
//// ((ExternalDatasetDataFileTransformerModel)m).setType(FieldDataExternalDatasetType.of(d.getType().getValue()));
|
||||||
|
//// }
|
||||||
|
// case RadioBoxDataEntity d -> {
|
||||||
|
// m = new RadioBoxDataFileTransformerModel();
|
||||||
// m.setLabel(d.getLabel());
|
// m.setLabel(d.getLabel());
|
||||||
// m.setFieldType(FieldType.of(d.getFieldType().getValue()));
|
// m.setFieldType(FieldType.of(d.getFieldType().getValue()));
|
||||||
// ((ExternalSelectDataFileTransformerModel)m).setMultipleSelect(d.getMultipleSelect());
|
// ((RadioBoxDataFileTransformerModel) m).setOptions(convertRadioBoxOptions(d.getOptions()));
|
||||||
// ((ExternalSelectDataFileTransformerModel) m).setSources(convertAutoCompleteSingleData(d.getSources()));
|
|
||||||
// }
|
// }
|
||||||
// case ExternalDatasetDataEntity d -> {
|
// case UploadDataEntity d -> {
|
||||||
// m = new ExternalDatasetDataFileTransformerModel();
|
// m = new UploadDataFileTransformerModel();
|
||||||
// m.setLabel(d.getLabel());
|
// m.setLabel(d.getLabel());
|
||||||
// m.setFieldType(FieldType.of(d.getFieldType().getValue()));
|
// m.setFieldType(FieldType.of(d.getFieldType().getValue()));
|
||||||
// ((ExternalDatasetDataFileTransformerModel)m).setType(FieldDataExternalDatasetType.of(d.getType().getValue()));
|
// ((UploadDataFileTransformerModel) m).setMaxFileSizeInMB(d.getMaxFileSizeInMB());
|
||||||
|
// ((UploadDataFileTransformerModel) m).setTypes(convertUploadDataOptions(d.getTypes()));
|
||||||
// }
|
// }
|
||||||
case RadioBoxDataEntity d -> {
|
// case SelectDataEntity d -> {
|
||||||
m = new RadioBoxDataFileTransformerModel();
|
// m = new SelectDataFileTransformerModel();
|
||||||
m.setLabel(d.getLabel());
|
// m.setLabel(d.getLabel());
|
||||||
m.setFieldType(FieldType.of(d.getFieldType().getValue()));
|
// m.setFieldType(FieldType.of(d.getFieldType().getValue()));
|
||||||
((RadioBoxDataFileTransformerModel) m).setOptions(convertRadioBoxOptions(d.getOptions()));
|
// ((SelectDataFileTransformerModel) m).setMultipleSelect(d.getMultipleSelect());
|
||||||
}
|
// ((SelectDataFileTransformerModel) m).setOptions(d.getOptions().stream().map(this::convertComboBoxOption).toList());
|
||||||
case UploadDataEntity d -> {
|
// }
|
||||||
m = new UploadDataFileTransformerModel();
|
// case LabelAndMultiplicityDataEntity d -> {
|
||||||
m.setLabel(d.getLabel());
|
// m = new LabelAndMultiplicityDataFileTransformerModel();
|
||||||
m.setFieldType(FieldType.of(d.getFieldType().getValue()));
|
// m.setLabel(d.getLabel());
|
||||||
((UploadDataFileTransformerModel) m).setMaxFileSizeInMB(d.getMaxFileSizeInMB());
|
// m.setFieldType(FieldType.of(d.getFieldType().getValue()));
|
||||||
((UploadDataFileTransformerModel) m).setTypes(convertUploadDataOptions(d.getTypes()));
|
// ((LabelAndMultiplicityDataFileTransformerModel)m).setMultipleSelect(d.getMultipleSelect());
|
||||||
}
|
// }
|
||||||
case SelectDataEntity d -> {
|
// default -> {
|
||||||
m = new SelectDataFileTransformerModel();
|
// m = new LabelDataFileTransformerModel();
|
||||||
m.setLabel(d.getLabel());
|
// m.setLabel(data.getLabel());
|
||||||
m.setFieldType(FieldType.of(d.getFieldType().getValue()));
|
// m.setFieldType(FieldType.of(data.getFieldType().getValue()));
|
||||||
((SelectDataFileTransformerModel) m).setMultipleSelect(d.getMultipleSelect());
|
// }
|
||||||
((SelectDataFileTransformerModel) m).setOptions(d.getOptions().stream().map(this::convertComboBoxOption).toList());
|
// }
|
||||||
}
|
// return m;
|
||||||
case LabelAndMultiplicityDataEntity d -> {
|
// }
|
||||||
m = new LabelAndMultiplicityDataFileTransformerModel();
|
//
|
||||||
m.setLabel(d.getLabel());
|
// private List<RadioBoxDataFileTransformerModel.RadioBoxDataOptionFileTransformerModel> convertRadioBoxOptions(List<RadioBoxDataEntity.RadioBoxDataOptionEntity> data) {
|
||||||
m.setFieldType(FieldType.of(d.getFieldType().getValue()));
|
// List<RadioBoxDataFileTransformerModel.RadioBoxDataOptionFileTransformerModel> result = new ArrayList<>();
|
||||||
((LabelAndMultiplicityDataFileTransformerModel)m).setMultipleSelect(d.getMultipleSelect());
|
// for (RadioBoxDataEntity.RadioBoxDataOptionEntity d : data) {
|
||||||
}
|
// RadioBoxDataFileTransformerModel.RadioBoxDataOptionFileTransformerModel m = new RadioBoxDataFileTransformerModel.RadioBoxDataOptionFileTransformerModel();
|
||||||
default -> {
|
// m.setLabel(d.getLabel());
|
||||||
m = new LabelDataFileTransformerModel();
|
// m.setValue(d.getValue());
|
||||||
m.setLabel(data.getLabel());
|
// result.add(m);
|
||||||
m.setFieldType(FieldType.of(data.getFieldType().getValue()));
|
// }
|
||||||
}
|
// return result;
|
||||||
}
|
// }
|
||||||
return m;
|
//
|
||||||
}
|
// private SelectDataFileTransformerModel.OptionFileTransformerModel convertComboBoxOption(SelectDataEntity.OptionEntity data) {
|
||||||
|
// SelectDataFileTransformerModel.OptionFileTransformerModel m = new SelectDataFileTransformerModel.OptionFileTransformerModel();
|
||||||
private List<RadioBoxDataFileTransformerModel.RadioBoxDataOptionFileTransformerModel> convertRadioBoxOptions(List<RadioBoxDataEntity.RadioBoxDataOptionEntity> data) {
|
// m.setLabel(data.getLabel());
|
||||||
List<RadioBoxDataFileTransformerModel.RadioBoxDataOptionFileTransformerModel> result = new ArrayList<>();
|
// m.setValue(data.getValue());
|
||||||
for (RadioBoxDataEntity.RadioBoxDataOptionEntity d : data) {
|
// return m;
|
||||||
RadioBoxDataFileTransformerModel.RadioBoxDataOptionFileTransformerModel m = new RadioBoxDataFileTransformerModel.RadioBoxDataOptionFileTransformerModel();
|
// }
|
||||||
m.setLabel(d.getLabel());
|
//
|
||||||
m.setValue(d.getValue());
|
// private List<UploadDataFileTransformerModel.UploadDataOptionFileTransformerModel> convertUploadDataOptions(List<UploadDataEntity.UploadDataOptionEntity> data) {
|
||||||
result.add(m);
|
// List<UploadDataFileTransformerModel.UploadDataOptionFileTransformerModel> result = new ArrayList<>();
|
||||||
}
|
// for (UploadDataEntity.UploadDataOptionEntity d : data) {
|
||||||
return result;
|
// UploadDataFileTransformerModel.UploadDataOptionFileTransformerModel m = new UploadDataFileTransformerModel.UploadDataOptionFileTransformerModel();
|
||||||
}
|
// m.setLabel(d.getLabel());
|
||||||
|
// m.setValue(d.getValue());
|
||||||
private SelectDataFileTransformerModel.OptionFileTransformerModel convertComboBoxOption(SelectDataEntity.OptionEntity data) {
|
// result.add(m);
|
||||||
SelectDataFileTransformerModel.OptionFileTransformerModel m = new SelectDataFileTransformerModel.OptionFileTransformerModel();
|
// }
|
||||||
m.setLabel(data.getLabel());
|
// return result;
|
||||||
m.setValue(data.getValue());
|
// }
|
||||||
return m;
|
//
|
||||||
}
|
//
|
||||||
|
//}
|
||||||
private List<UploadDataFileTransformerModel.UploadDataOptionFileTransformerModel> convertUploadDataOptions(List<UploadDataEntity.UploadDataOptionEntity> data) {
|
|
||||||
List<UploadDataFileTransformerModel.UploadDataOptionFileTransformerModel> result = new ArrayList<>();
|
|
||||||
for (UploadDataEntity.UploadDataOptionEntity d : data) {
|
|
||||||
UploadDataFileTransformerModel.UploadDataOptionFileTransformerModel m = new UploadDataFileTransformerModel.UploadDataOptionFileTransformerModel();
|
|
||||||
m.setLabel(d.getLabel());
|
|
||||||
m.setValue(d.getValue());
|
|
||||||
result.add(m);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,83 +1,83 @@
|
||||||
package eu.eudat.model.builder.filetransformer;
|
//package eu.eudat.model.builder.filetransformer;
|
||||||
|
//
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
//import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.commons.JsonHandlingService;
|
//import eu.eudat.commons.JsonHandlingService;
|
||||||
import eu.eudat.commons.XmlHandlingService;
|
//import eu.eudat.commons.XmlHandlingService;
|
||||||
import eu.eudat.convention.ConventionService;
|
//import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
//import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.file.transformer.models.descriptiontemplate.DescriptionTemplateFileTransformerModel;
|
//import eu.eudat.file.transformer.models.descriptiontemplate.DescriptionTemplateFileTransformerModel;
|
||||||
import eu.eudat.query.DescriptionTemplateQuery;
|
//import eu.eudat.query.DescriptionTemplateQuery;
|
||||||
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;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
//import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
//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 java.util.ArrayList;
|
//import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
//import java.util.EnumSet;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import java.util.Optional;
|
//import java.util.Optional;
|
||||||
|
//
|
||||||
@Component
|
//@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class DescriptionTemplateFileTransformerBuilder extends BaseFileTransformerBuilder<DescriptionTemplateFileTransformerModel, DescriptionTemplateEntity> {
|
//public class DescriptionTemplateFileTransformerBuilder extends BaseFileTransformerBuilder<DescriptionTemplateFileTransformerModel, DescriptionTemplateEntity> {
|
||||||
|
//
|
||||||
private final QueryFactory queryFactory;
|
// private final QueryFactory queryFactory;
|
||||||
|
//
|
||||||
private final BuilderFactory builderFactory;
|
// private final BuilderFactory builderFactory;
|
||||||
private final JsonHandlingService jsonHandlingService;
|
// private final JsonHandlingService jsonHandlingService;
|
||||||
|
//
|
||||||
private final XmlHandlingService xmlHandlingService;
|
// private final XmlHandlingService xmlHandlingService;
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
// private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
public DescriptionTemplateFileTransformerBuilder(
|
// public DescriptionTemplateFileTransformerBuilder(
|
||||||
ConventionService conventionService,
|
// ConventionService conventionService,
|
||||||
QueryFactory queryFactory,
|
// QueryFactory queryFactory,
|
||||||
BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService) {
|
// BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService) {
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionTemplateFileTransformerBuilder.class)));
|
// super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionTemplateFileTransformerBuilder.class)));
|
||||||
this.queryFactory = queryFactory;
|
// this.queryFactory = queryFactory;
|
||||||
this.builderFactory = builderFactory;
|
// this.builderFactory = builderFactory;
|
||||||
this.jsonHandlingService = jsonHandlingService;
|
// this.jsonHandlingService = jsonHandlingService;
|
||||||
this.xmlHandlingService = xmlHandlingService;
|
// this.xmlHandlingService = xmlHandlingService;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public DescriptionTemplateFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
// public DescriptionTemplateFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
this.authorize = values;
|
// this.authorize = values;
|
||||||
return this;
|
// return this;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
protected List<FileTransformerBuilderItemResponse<DescriptionTemplateFileTransformerModel, DescriptionTemplateEntity>> buildInternal(List<DescriptionTemplateEntity> data) throws MyApplicationException {
|
// protected List<FileTransformerBuilderItemResponse<DescriptionTemplateFileTransformerModel, DescriptionTemplateEntity>> buildInternal(List<DescriptionTemplateEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
// this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
// if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
//
|
||||||
data = queryFactory.query(DescriptionTemplateQuery.class).ids(data.stream().map(DescriptionTemplateEntity::getId).toList()).collect();
|
// data = queryFactory.query(DescriptionTemplateQuery.class).ids(data.stream().map(DescriptionTemplateEntity::getId).toList()).collect();
|
||||||
List<FileTransformerBuilderItemResponse<DescriptionTemplateFileTransformerModel, DescriptionTemplateEntity>> models = new ArrayList<>();
|
// List<FileTransformerBuilderItemResponse<DescriptionTemplateFileTransformerModel, DescriptionTemplateEntity>> models = new ArrayList<>();
|
||||||
for (DescriptionTemplateEntity d : data) {
|
// for (DescriptionTemplateEntity d : data) {
|
||||||
|
//
|
||||||
DescriptionTemplateFileTransformerModel m = new DescriptionTemplateFileTransformerModel();
|
// DescriptionTemplateFileTransformerModel m = new DescriptionTemplateFileTransformerModel();
|
||||||
m.setId(d.getId());
|
// m.setId(d.getId());
|
||||||
m.setLabel(d.getLabel());
|
// m.setLabel(d.getLabel());
|
||||||
m.setDescription(d.getDescription());
|
// m.setDescription(d.getDescription());
|
||||||
m.setLanguage(d.getLanguage());
|
// m.setLanguage(d.getLanguage());
|
||||||
m.setVersion(d.getVersion());
|
// m.setVersion(d.getVersion());
|
||||||
m.setDefinition(this.builderFactory.builder(DescriptionTemplateDefinitionFileTransformerBuilder.class).authorize(authorize).build(collectDescriptionTemplates(d)));
|
// m.setDefinition(this.builderFactory.builder(DescriptionTemplateDefinitionFileTransformerBuilder.class).authorize(authorize).build(collectDescriptionTemplates(d)));
|
||||||
|
//
|
||||||
models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
// models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
//
|
||||||
return models;
|
// return models;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private eu.eudat.commons.types.descriptiontemplate.DefinitionEntity collectDescriptionTemplates(DescriptionTemplateEntity data) throws MyApplicationException {
|
// private eu.eudat.commons.types.descriptiontemplate.DefinitionEntity collectDescriptionTemplates(DescriptionTemplateEntity data) throws MyApplicationException {
|
||||||
return this.xmlHandlingService.fromXmlSafe(eu.eudat.commons.types.descriptiontemplate.DefinitionEntity.class, data.getDefinition());
|
// return this.xmlHandlingService.fromXmlSafe(eu.eudat.commons.types.descriptiontemplate.DefinitionEntity.class, data.getDefinition());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,129 +1,129 @@
|
||||||
package eu.eudat.model.builder.filetransformer;
|
//package eu.eudat.model.builder.filetransformer;
|
||||||
|
//
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
//import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
//import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.commons.JsonHandlingService;
|
//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.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.DmpBlueprintSystemFieldType;
|
//import eu.eudat.file.transformer.enums.DmpBlueprintSystemFieldType;
|
||||||
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.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;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
//import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
//import gr.cite.tools.logging.LoggerService;
|
||||||
import org.apache.commons.lang3.NotImplementedException;
|
//import org.apache.commons.lang3.NotImplementedException;
|
||||||
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 java.util.*;
|
//import java.util.*;
|
||||||
|
//
|
||||||
@Component
|
//@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class DmpBlueprintFileTransformerBuilder extends BaseFileTransformerBuilder<DmpBlueprintFileTransformerModel, DmpBlueprintEntity> {
|
//public class DmpBlueprintFileTransformerBuilder extends BaseFileTransformerBuilder<DmpBlueprintFileTransformerModel, DmpBlueprintEntity> {
|
||||||
|
//
|
||||||
private final QueryFactory queryFactory;
|
// private final QueryFactory queryFactory;
|
||||||
|
//
|
||||||
private final BuilderFactory builderFactory;
|
// private final BuilderFactory builderFactory;
|
||||||
private final JsonHandlingService jsonHandlingService;
|
// private final JsonHandlingService jsonHandlingService;
|
||||||
|
//
|
||||||
private final XmlHandlingService xmlHandlingService;
|
// private final XmlHandlingService xmlHandlingService;
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
// private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
public DmpBlueprintFileTransformerBuilder(
|
// public DmpBlueprintFileTransformerBuilder(
|
||||||
ConventionService conventionService,
|
// ConventionService conventionService,
|
||||||
QueryFactory queryFactory,
|
// QueryFactory queryFactory,
|
||||||
BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService) {
|
// BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService) {
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpBlueprintFileTransformerBuilder.class)));
|
// super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpBlueprintFileTransformerBuilder.class)));
|
||||||
this.queryFactory = queryFactory;
|
// this.queryFactory = queryFactory;
|
||||||
this.builderFactory = builderFactory;
|
// this.builderFactory = builderFactory;
|
||||||
this.jsonHandlingService = jsonHandlingService;
|
// this.jsonHandlingService = jsonHandlingService;
|
||||||
this.xmlHandlingService = xmlHandlingService;
|
// this.xmlHandlingService = xmlHandlingService;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public DmpBlueprintFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
// public DmpBlueprintFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
this.authorize = values;
|
// this.authorize = values;
|
||||||
return this;
|
// return this;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
protected List<FileTransformerBuilderItemResponse<DmpBlueprintFileTransformerModel, DmpBlueprintEntity>> buildInternal(List<DmpBlueprintEntity> data) throws MyApplicationException {
|
// protected List<FileTransformerBuilderItemResponse<DmpBlueprintFileTransformerModel, DmpBlueprintEntity>> buildInternal(List<DmpBlueprintEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
// this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
// if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
//
|
||||||
data = queryFactory.query(DmpBlueprintQuery.class).ids(data.stream().map(DmpBlueprintEntity::getId).toList()).collect();
|
// data = queryFactory.query(DmpBlueprintQuery.class).ids(data.stream().map(DmpBlueprintEntity::getId).toList()).collect();
|
||||||
List<FileTransformerBuilderItemResponse<DmpBlueprintFileTransformerModel, DmpBlueprintEntity>> models = new ArrayList<>();
|
// List<FileTransformerBuilderItemResponse<DmpBlueprintFileTransformerModel, DmpBlueprintEntity>> models = new ArrayList<>();
|
||||||
for (DmpBlueprintEntity d : data) {
|
// for (DmpBlueprintEntity d : data) {
|
||||||
|
//
|
||||||
DmpBlueprintFileTransformerModel m = new DmpBlueprintFileTransformerModel();
|
// DmpBlueprintFileTransformerModel m = new DmpBlueprintFileTransformerModel();
|
||||||
m.setId(d.getId());
|
// m.setId(d.getId());
|
||||||
m.setLabel(d.getLabel());
|
// m.setLabel(d.getLabel());
|
||||||
try {
|
// try {
|
||||||
m.setDefinitionFileTransformerModel(getDefinition(d.getDefinition()));
|
// m.setDefinitionFileTransformerModel(getDefinition(d.getDefinition()));
|
||||||
} catch (JsonProcessingException e) {
|
// } catch (JsonProcessingException e) {
|
||||||
logger.error(e.getMessage(), e);
|
// logger.error(e.getMessage(), e);
|
||||||
}
|
// }
|
||||||
models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
// models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
//
|
||||||
return models;
|
// return models;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private DefinitionFileTransformerModel getDefinition(String source) throws JsonProcessingException {
|
// private DefinitionFileTransformerModel getDefinition(String source) throws JsonProcessingException {
|
||||||
DefinitionFileTransformerModel result = new DefinitionFileTransformerModel();
|
// DefinitionFileTransformerModel result = new DefinitionFileTransformerModel();
|
||||||
result.setSections(new ArrayList<>());
|
// result.setSections(new ArrayList<>());
|
||||||
DefinitionEntity parsedDefinition = xmlHandlingService.fromXmlSafe(DefinitionEntity.class, source);
|
// DefinitionEntity parsedDefinition = xmlHandlingService.fromXmlSafe(DefinitionEntity.class, source);
|
||||||
List<SectionEntity> sections = parsedDefinition.getSections();
|
// List<SectionEntity> sections = parsedDefinition.getSections();
|
||||||
sections.forEach(section -> {
|
// sections.forEach(section -> {
|
||||||
SectionFileTransformerModel m = new SectionFileTransformerModel();
|
// SectionFileTransformerModel m = new SectionFileTransformerModel();
|
||||||
m.setId(section.getId());
|
// m.setId(section.getId());
|
||||||
m.setLabel(section.getLabel());
|
// m.setLabel(section.getLabel());
|
||||||
m.setOrdinal(section.getOrdinal());
|
// m.setOrdinal(section.getOrdinal());
|
||||||
m.setDescription(section.getDescription());
|
// m.setDescription(section.getDescription());
|
||||||
if (section.getFields() != null && !section.getFields().isEmpty()) {
|
// if (section.getFields() != null && !section.getFields().isEmpty()) {
|
||||||
m.setFields(mapFields(section.getFields()));
|
// m.setFields(mapFields(section.getFields()));
|
||||||
}
|
// }
|
||||||
m.setHasTemplates(section.getHasTemplates());
|
// m.setHasTemplates(section.getHasTemplates());
|
||||||
result.getSections().add(m);
|
// result.getSections().add(m);
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private List<FieldFileTransformerModel> mapFields(List<FieldEntity> fieldEntities) {
|
// private List<FieldFileTransformerModel> mapFields(List<FieldEntity> fieldEntities) {
|
||||||
List<FieldFileTransformerModel> result = new ArrayList<>();
|
// List<FieldFileTransformerModel> result = new ArrayList<>();
|
||||||
fieldEntities.forEach(fieldEntity -> {
|
// fieldEntities.forEach(fieldEntity -> {
|
||||||
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 ReferenceType -> 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());
|
||||||
m.setLabel(fieldEntity.getLabel());
|
// m.setLabel(fieldEntity.getLabel());
|
||||||
m.setDescription(fieldEntity.getDescription());
|
// m.setDescription(fieldEntity.getDescription());
|
||||||
m.setOrdinal(fieldEntity.getOrdinal());
|
// m.setOrdinal(fieldEntity.getOrdinal());
|
||||||
m.setPlaceholder(fieldEntity.getPlaceholder());
|
// m.setPlaceholder(fieldEntity.getPlaceholder());
|
||||||
m.setRequired(fieldEntity.isRequired());
|
// m.setRequired(fieldEntity.isRequired());
|
||||||
switch (m) {
|
// switch (m) {
|
||||||
case SystemFieldFileTransformerModel sm -> sm.setSystemFieldType(DmpBlueprintSystemFieldType.of(((SystemFieldEntity)fieldEntity).getType().getValue()));
|
// case SystemFieldFileTransformerModel sm -> sm.setSystemFieldType(DmpBlueprintSystemFieldType.of(((SystemFieldEntity)fieldEntity).getType().getValue()));
|
||||||
case ExtraFieldFileTransformerModelFileTransformerModel sm -> sm.setDataType(DmpBlueprintExtraFieldDataType.of(((ExtraFieldEntity)fieldEntity).getType().getValue()));
|
// case ExtraFieldFileTransformerModelFileTransformerModel sm -> sm.setDataType(DmpBlueprintExtraFieldDataType.of(((ExtraFieldEntity)fieldEntity).getType().getValue()));
|
||||||
// case ReferenceFieldFileTransformerModelFileTransformerModel sm -> sm.setReferenceTypeId(((ReferenceFieldEntity)fieldEntity).getReferenceTypeId());
|
//// case ReferenceFieldFileTransformerModelFileTransformerModel sm -> sm.setReferenceTypeId(((ReferenceFieldEntity)fieldEntity).getReferenceTypeId());
|
||||||
default -> throw new MyApplicationException("unrecognized type " + fieldEntity.getCategory());
|
// default -> throw new MyApplicationException("unrecognized type " + fieldEntity.getCategory());
|
||||||
}
|
// }
|
||||||
result.add(m);
|
// result.add(m);
|
||||||
});
|
// });
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,200 +1,200 @@
|
||||||
package eu.eudat.model.builder.filetransformer;
|
//package eu.eudat.model.builder.filetransformer;
|
||||||
|
//
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
//import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
//import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.convention.ConventionService;
|
//import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.*;
|
//import eu.eudat.data.*;
|
||||||
import eu.eudat.file.transformer.enums.DmpAccessType;
|
//import eu.eudat.file.transformer.enums.DmpAccessType;
|
||||||
import eu.eudat.file.transformer.enums.DmpStatus;
|
//import eu.eudat.file.transformer.enums.DmpStatus;
|
||||||
import eu.eudat.file.transformer.enums.DmpVersionStatus;
|
//import eu.eudat.file.transformer.enums.DmpVersionStatus;
|
||||||
import eu.eudat.file.transformer.models.description.DescriptionFileTransformerModel;
|
//import eu.eudat.file.transformer.models.description.DescriptionFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.dmp.DmpFileTransformerModel;
|
//import eu.eudat.file.transformer.models.dmp.DmpFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.dmp.DmpReferenceFileTransformerModel;
|
//import eu.eudat.file.transformer.models.dmp.DmpReferenceFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.dmp.DmpUserFileTransformerModel;
|
//import eu.eudat.file.transformer.models.dmp.DmpUserFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.dmpblueprint.DmpBlueprintFileTransformerModel;
|
//import eu.eudat.file.transformer.models.dmpblueprint.DmpBlueprintFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.dmpblueprint.definition.SectionFileTransformerModel;
|
//import eu.eudat.file.transformer.models.dmpblueprint.definition.SectionFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.entitydoi.EntityDoiFileTransformerModel;
|
//import eu.eudat.file.transformer.models.entitydoi.EntityDoiFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.reference.ReferenceFileTransformerModel;
|
//import eu.eudat.file.transformer.models.reference.ReferenceFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.user.UserFileTransformerModel;
|
//import eu.eudat.file.transformer.models.user.UserFileTransformerModel;
|
||||||
import eu.eudat.model.*;
|
//import eu.eudat.model.*;
|
||||||
import eu.eudat.model.builder.DmpReferenceBuilder;
|
//import eu.eudat.model.builder.DmpReferenceBuilder;
|
||||||
import eu.eudat.query.*;
|
//import eu.eudat.query.*;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
//import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.query.Ordering;
|
//import gr.cite.tools.data.query.Ordering;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
//import gr.cite.tools.data.query.QueryFactory;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
//import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
//import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
//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 java.time.Instant;
|
//import java.time.Instant;
|
||||||
import java.util.*;
|
//import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
//import java.util.stream.Collectors;
|
||||||
|
//
|
||||||
@Component
|
//@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class DmpFileTransformerBuilder extends BaseFileTransformerBuilder<DmpFileTransformerModel, DmpEntity> {
|
//public class DmpFileTransformerBuilder extends BaseFileTransformerBuilder<DmpFileTransformerModel, DmpEntity> {
|
||||||
|
//
|
||||||
private final QueryFactory queryFactory;
|
// private final QueryFactory queryFactory;
|
||||||
private final BuilderFactory builderFactory;
|
// private final BuilderFactory builderFactory;
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
// private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
//
|
||||||
private Boolean ignoreDescriptions = false;
|
// private Boolean ignoreDescriptions = false;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
public DmpFileTransformerBuilder(ConventionService conventionService,
|
// public DmpFileTransformerBuilder(ConventionService conventionService,
|
||||||
QueryFactory queryFactory,
|
// QueryFactory queryFactory,
|
||||||
BuilderFactory builderFactory) {
|
// BuilderFactory builderFactory) {
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpFileTransformerBuilder.class)));
|
// super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpFileTransformerBuilder.class)));
|
||||||
this.queryFactory = queryFactory;
|
// this.queryFactory = queryFactory;
|
||||||
this.builderFactory = builderFactory;
|
// this.builderFactory = builderFactory;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public DmpFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
// public DmpFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
this.authorize = values;
|
// this.authorize = values;
|
||||||
return this;
|
// return this;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public DmpFileTransformerBuilder ignoreDescriptions(Boolean ignoreDescriptions) {
|
// public DmpFileTransformerBuilder ignoreDescriptions(Boolean ignoreDescriptions) {
|
||||||
this.ignoreDescriptions = ignoreDescriptions;
|
// this.ignoreDescriptions = ignoreDescriptions;
|
||||||
return this;
|
// return this;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
protected List<FileTransformerBuilderItemResponse<DmpFileTransformerModel, DmpEntity>> buildInternal(List<DmpEntity> data) throws MyApplicationException {
|
// protected List<FileTransformerBuilderItemResponse<DmpFileTransformerModel, DmpEntity>> buildInternal(List<DmpEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
// this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
// if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
//
|
||||||
List<FileTransformerBuilderItemResponse<DmpFileTransformerModel, DmpEntity>> models = new ArrayList<>();
|
// List<FileTransformerBuilderItemResponse<DmpFileTransformerModel, DmpEntity>> models = new ArrayList<>();
|
||||||
|
//
|
||||||
Map<UUID, List<DmpReferenceFileTransformerModel>> dmpReferencesMap = this.collectReferences(data);
|
// Map<UUID, List<DmpReferenceFileTransformerModel>> dmpReferencesMap = this.collectReferences(data);
|
||||||
|
//
|
||||||
Map<UUID, List<DmpUserFileTransformerModel>> dmpUsersMap = this.collectDmpUsers(data);
|
// Map<UUID, List<DmpUserFileTransformerModel>> dmpUsersMap = this.collectDmpUsers(data);
|
||||||
|
//
|
||||||
Map<UUID, List<DescriptionFileTransformerModel>> descriptionsMap = null;
|
// Map<UUID, List<DescriptionFileTransformerModel>> descriptionsMap = null;
|
||||||
if (!ignoreDescriptions) {
|
// if (!ignoreDescriptions) {
|
||||||
descriptionsMap = this.collectDmpDescriptions(data);
|
// descriptionsMap = this.collectDmpDescriptions(data);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Map<UUID, List<EntityDoiFileTransformerModel>> doiMap = this.collectEntityDois(data);
|
// Map<UUID, List<EntityDoiFileTransformerModel>> doiMap = this.collectEntityDois(data);
|
||||||
Map<UUID, UserFileTransformerModel> creatorMap = this.collectCreators(data);
|
// Map<UUID, UserFileTransformerModel> creatorMap = this.collectCreators(data);
|
||||||
Map<UUID, DmpBlueprintFileTransformerModel> blueprintMap = this.collectBlueprints(data);
|
// Map<UUID, DmpBlueprintFileTransformerModel> blueprintMap = this.collectBlueprints(data);
|
||||||
|
//
|
||||||
for (DmpEntity d : data) {
|
// for (DmpEntity d : data) {
|
||||||
DmpFileTransformerModel m = new DmpFileTransformerModel();
|
// DmpFileTransformerModel m = new DmpFileTransformerModel();
|
||||||
m.setId(d.getId());
|
// m.setId(d.getId());
|
||||||
m.setLabel(d.getLabel());
|
// m.setLabel(d.getLabel());
|
||||||
m.setVersion(d.getVersion());
|
// m.setVersion(d.getVersion());
|
||||||
m.setDescription(d.getDescription());
|
// m.setDescription(d.getDescription());
|
||||||
m.setFinalizedAt(d.getFinalizedAt());
|
// m.setFinalizedAt(d.getFinalizedAt());
|
||||||
m.setCreatedAt(d.getCreatedAt());
|
// m.setCreatedAt(d.getCreatedAt());
|
||||||
if (d.getPublicAfter() != null && d.getPublicAfter().isAfter(Instant.now())) {
|
// if (d.getPublicAfter() != null && d.getPublicAfter().isAfter(Instant.now())) {
|
||||||
m.setPublishedAt(d.getPublicAfter());
|
// m.setPublishedAt(d.getPublicAfter());
|
||||||
}
|
// }
|
||||||
switch (d.getAccessType()){
|
// switch (d.getAccessType()){
|
||||||
case Public -> m.setAccessType(DmpAccessType.Public);
|
// case Public -> m.setAccessType(DmpAccessType.Public);
|
||||||
case Restricted -> m.setAccessType(DmpAccessType.Restricted);
|
// case Restricted -> m.setAccessType(DmpAccessType.Restricted);
|
||||||
case null -> m.setAccessType(null);
|
// case null -> m.setAccessType(null);
|
||||||
default -> throw new MyApplicationException("unrecognized type " + d.getAccessType().getValue());
|
// default -> throw new MyApplicationException("unrecognized type " + d.getAccessType().getValue());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
m.setProperties(d.getProperties());
|
// m.setProperties(d.getProperties());
|
||||||
m.setUpdatedAt(d.getUpdatedAt());
|
// m.setUpdatedAt(d.getUpdatedAt());
|
||||||
m.setLanguage(d.getLanguage());
|
// m.setLanguage(d.getLanguage());
|
||||||
m.setStatus(DmpStatus.of(d.getStatus().getValue()));
|
// m.setStatus(DmpStatus.of(d.getStatus().getValue()));
|
||||||
m.setVersionStatus(DmpVersionStatus.of(d.getVersionStatus().getValue()));
|
// m.setVersionStatus(DmpVersionStatus.of(d.getVersionStatus().getValue()));
|
||||||
if (dmpReferencesMap != null && !dmpReferencesMap.isEmpty() && dmpReferencesMap.containsKey(d.getId())) m.setDmpReferences(dmpReferencesMap.get(d.getId()));
|
// if (dmpReferencesMap != null && !dmpReferencesMap.isEmpty() && dmpReferencesMap.containsKey(d.getId())) m.setDmpReferences(dmpReferencesMap.get(d.getId()));
|
||||||
if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId())) m.setDmpUsers(dmpUsersMap.get(d.getId()));
|
// if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId())) m.setDmpUsers(dmpUsersMap.get(d.getId()));
|
||||||
if (descriptionsMap != null && !descriptionsMap.isEmpty() && descriptionsMap.containsKey(d.getId())) m.setDescriptions(descriptionsMap.get(d.getId()));
|
// if (descriptionsMap != null && !descriptionsMap.isEmpty() && descriptionsMap.containsKey(d.getId())) m.setDescriptions(descriptionsMap.get(d.getId()));
|
||||||
if (doiMap != null && !doiMap.isEmpty() && doiMap.containsKey(d.getId())) m.setEntityDois(doiMap.get(d.getId()));
|
// if (doiMap != null && !doiMap.isEmpty() && doiMap.containsKey(d.getId())) m.setEntityDois(doiMap.get(d.getId()));
|
||||||
if (creatorMap != null && !creatorMap.isEmpty() && creatorMap.containsKey(d.getId())) m.setCreator(creatorMap.get(d.getId()));
|
// if (creatorMap != null && !creatorMap.isEmpty() && creatorMap.containsKey(d.getId())) m.setCreator(creatorMap.get(d.getId()));
|
||||||
if (blueprintMap != null && !blueprintMap.isEmpty() && blueprintMap.containsKey(d.getBlueprintId())) m.setBlueprint(blueprintMap.get(d.getBlueprintId()));
|
// if (blueprintMap != null && !blueprintMap.isEmpty() && blueprintMap.containsKey(d.getBlueprintId())) m.setBlueprint(blueprintMap.get(d.getBlueprintId()));
|
||||||
|
//
|
||||||
SectionFileTransformerModel templateSection = m.getBlueprint().getDefinitionFileTransformerModel().getSections().stream().filter(SectionFileTransformerModel::getHasTemplates).findFirst().orElse(null);
|
// SectionFileTransformerModel templateSection = m.getBlueprint().getDefinitionFileTransformerModel().getSections().stream().filter(SectionFileTransformerModel::getHasTemplates).findFirst().orElse(null);
|
||||||
if (templateSection != null && m.getDescriptions() != null && !m.getDescriptions().isEmpty()) {
|
// if (templateSection != null && m.getDescriptions() != null && !m.getDescriptions().isEmpty()) {
|
||||||
m.getDescriptions().forEach(description -> {
|
// m.getDescriptions().forEach(description -> {
|
||||||
description.setSectionId(templateSection.getId());
|
// description.setSectionId(templateSection.getId());
|
||||||
description.setCreatedBy(m.getCreator());
|
// description.setCreatedBy(m.getCreator());
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
// models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
||||||
}
|
// }
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
//
|
||||||
return models;
|
// return models;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private Map<UUID, List<DmpReferenceFileTransformerModel>> collectReferences(List<DmpEntity> data) throws MyApplicationException {
|
// private Map<UUID, List<DmpReferenceFileTransformerModel>> collectReferences(List<DmpEntity> data) throws MyApplicationException {
|
||||||
if (data.isEmpty()) return null;
|
// if (data.isEmpty()) return null;
|
||||||
this.logger.debug("checking related - {}", DmpReference.class.getSimpleName());
|
// this.logger.debug("checking related - {}", DmpReference.class.getSimpleName());
|
||||||
|
//
|
||||||
List<DmpReferenceEntity> dmpReferences = this.queryFactory.query(DmpReferenceQuery.class).isActives(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(DmpReference._dmp).ensure(DmpReference._reference));
|
// List<DmpReferenceEntity> dmpReferences = this.queryFactory.query(DmpReferenceQuery.class).isActives(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(DmpReference._dmp).ensure(DmpReference._reference));
|
||||||
|
//
|
||||||
Map<UUID, List<DmpReferenceFileTransformerModel>> itemMap = new HashMap<>();
|
// Map<UUID, List<DmpReferenceFileTransformerModel>> itemMap = new HashMap<>();
|
||||||
ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).isActive(IsActive.Active).ids(dmpReferences.stream().map(DmpReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()));
|
// ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).isActive(IsActive.Active).ids(dmpReferences.stream().map(DmpReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()));
|
||||||
Map<UUID, ReferenceFileTransformerModel> referenceDepositModelMap = this.builderFactory.builder(ReferenceFileTransformerBuilder.class).authorize(this.authorize).asForeignKey(query, ReferenceEntity::getId);
|
// Map<UUID, ReferenceFileTransformerModel> referenceDepositModelMap = this.builderFactory.builder(ReferenceFileTransformerBuilder.class).authorize(this.authorize).asForeignKey(query, ReferenceEntity::getId);
|
||||||
if (referenceDepositModelMap == null) return null;
|
// if (referenceDepositModelMap == null) return null;
|
||||||
for (DmpReferenceEntity dmpReference : dmpReferences) {
|
// for (DmpReferenceEntity dmpReference : dmpReferences) {
|
||||||
DmpReferenceFileTransformerModel dmpReferenceFileTransformerModel = new DmpReferenceFileTransformerModel();
|
// DmpReferenceFileTransformerModel dmpReferenceFileTransformerModel = new DmpReferenceFileTransformerModel();
|
||||||
dmpReferenceFileTransformerModel.setId(dmpReference.getId());
|
// dmpReferenceFileTransformerModel.setId(dmpReference.getId());
|
||||||
dmpReferenceFileTransformerModel.setData(dmpReference.getData());
|
// dmpReferenceFileTransformerModel.setData(dmpReference.getData());
|
||||||
dmpReferenceFileTransformerModel.setReference(referenceDepositModelMap.getOrDefault(dmpReference.getReferenceId(), null));
|
// dmpReferenceFileTransformerModel.setReference(referenceDepositModelMap.getOrDefault(dmpReference.getReferenceId(), null));
|
||||||
DmpReferenceFileTransformerModel model = dmpReferenceFileTransformerModel;
|
// DmpReferenceFileTransformerModel model = dmpReferenceFileTransformerModel;
|
||||||
if (model == null) continue;
|
// if (model == null) continue;
|
||||||
UUID key = dmpReference.getDmpId();
|
// UUID key = dmpReference.getDmpId();
|
||||||
if (!itemMap.containsKey(key)) itemMap.put(key, new ArrayList<>());
|
// if (!itemMap.containsKey(key)) itemMap.put(key, new ArrayList<>());
|
||||||
itemMap.get(key).add(model);
|
// itemMap.get(key).add(model);
|
||||||
}
|
// }
|
||||||
return itemMap;
|
// return itemMap;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
private Map<UUID, List<DmpUserFileTransformerModel>> collectDmpUsers(List<DmpEntity> data) throws MyApplicationException {
|
// private Map<UUID, List<DmpUserFileTransformerModel>> collectDmpUsers(List<DmpEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("checking related - {}", DmpUser.class.getSimpleName());
|
// this.logger.debug("checking related - {}", DmpUser.class.getSimpleName());
|
||||||
|
//
|
||||||
Map<UUID, List<DmpUserFileTransformerModel>> itemMap;
|
// Map<UUID, List<DmpUserFileTransformerModel>> itemMap;
|
||||||
DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).isActives(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
|
// DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).isActives(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
|
||||||
itemMap = this.builderFactory.builder(DmpUserFileTransformerBuilder.class).authorize(this.authorize).asMasterKey(query, DmpUserEntity::getDmpId);
|
// itemMap = this.builderFactory.builder(DmpUserFileTransformerBuilder.class).authorize(this.authorize).asMasterKey(query, DmpUserEntity::getDmpId);
|
||||||
|
//
|
||||||
return itemMap;
|
// return itemMap;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private Map<UUID, List<DescriptionFileTransformerModel>> collectDmpDescriptions(List<DmpEntity> data) throws MyApplicationException {
|
// private Map<UUID, List<DescriptionFileTransformerModel>> collectDmpDescriptions(List<DmpEntity> data) throws MyApplicationException {
|
||||||
if (data.isEmpty()) return null;
|
// if (data.isEmpty()) return null;
|
||||||
this.logger.debug("checking related - {}", Description.class.getSimpleName());
|
// this.logger.debug("checking related - {}", Description.class.getSimpleName());
|
||||||
|
//
|
||||||
Map<UUID, List<DescriptionFileTransformerModel>> itemMap;
|
// Map<UUID, List<DescriptionFileTransformerModel>> itemMap;
|
||||||
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).isActive(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
|
// DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).isActive(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
|
||||||
itemMap = this.builderFactory.builder(DescriptionFileTransformerBuilder.class).authorize(this.authorize).asMasterKey(query, DescriptionEntity::getDmpId);
|
// itemMap = this.builderFactory.builder(DescriptionFileTransformerBuilder.class).authorize(this.authorize).asMasterKey(query, DescriptionEntity::getDmpId);
|
||||||
|
//
|
||||||
return itemMap;
|
// return itemMap;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private Map<UUID, UserFileTransformerModel> collectCreators(List<DmpEntity> data) {
|
// private Map<UUID, UserFileTransformerModel> collectCreators(List<DmpEntity> data) {
|
||||||
DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).isActives(IsActive.Active).authorize(this.authorize).userIds(data.stream().map(DmpEntity::getCreatorId).toList());
|
// DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).isActives(IsActive.Active).authorize(this.authorize).userIds(data.stream().map(DmpEntity::getCreatorId).toList());
|
||||||
return this.builderFactory.builder(DmpUserFileTransformerBuilder.class).authorize(this.authorize).asMasterKey(query, DmpUserEntity::getDmpId)
|
// return this.builderFactory.builder(DmpUserFileTransformerBuilder.class).authorize(this.authorize).asMasterKey(query, DmpUserEntity::getDmpId)
|
||||||
.entrySet().stream().map(uuidListEntry -> Map.entry(uuidListEntry.getKey(), uuidListEntry.getValue().get(0).getUser()))
|
// .entrySet().stream().map(uuidListEntry -> Map.entry(uuidListEntry.getKey(), uuidListEntry.getValue().get(0).getUser()))
|
||||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
// .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private Map<UUID, DmpBlueprintFileTransformerModel> collectBlueprints(List<DmpEntity> data) {
|
// private Map<UUID, DmpBlueprintFileTransformerModel> collectBlueprints(List<DmpEntity> data) {
|
||||||
DmpBlueprintQuery query = this.queryFactory.query(DmpBlueprintQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().map(DmpEntity::getBlueprintId).toList());
|
// DmpBlueprintQuery query = this.queryFactory.query(DmpBlueprintQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().map(DmpEntity::getBlueprintId).toList());
|
||||||
return this.builderFactory.builder(DmpBlueprintFileTransformerBuilder.class).authorize(this.authorize).asMasterKey(query, DmpBlueprintEntity::getId)
|
// return this.builderFactory.builder(DmpBlueprintFileTransformerBuilder.class).authorize(this.authorize).asMasterKey(query, DmpBlueprintEntity::getId)
|
||||||
.entrySet().stream().map(uuidListEntry -> Map.entry(uuidListEntry.getKey(), uuidListEntry.getValue().get(0)))
|
// .entrySet().stream().map(uuidListEntry -> Map.entry(uuidListEntry.getKey(), uuidListEntry.getValue().get(0)))
|
||||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
// .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private Map<UUID, List<EntityDoiFileTransformerModel>> collectEntityDois(List<DmpEntity> data) {
|
// private Map<UUID, List<EntityDoiFileTransformerModel>> collectEntityDois(List<DmpEntity> data) {
|
||||||
if (data.isEmpty()) return null;
|
// if (data.isEmpty()) return null;
|
||||||
Map<UUID, List<EntityDoiFileTransformerModel>> result;
|
// Map<UUID, List<EntityDoiFileTransformerModel>> result;
|
||||||
EntityDoiQuery query = this.queryFactory.query(EntityDoiQuery.class).isActive(IsActive.Active).authorize(authorize).entityIds(data.stream().map(DmpEntity::getId).distinct().toList());
|
// EntityDoiQuery query = this.queryFactory.query(EntityDoiQuery.class).isActive(IsActive.Active).authorize(authorize).entityIds(data.stream().map(DmpEntity::getId).distinct().toList());
|
||||||
result = builderFactory.builder(EntityDoiFileTransformerBuilder.class).asMasterKey(query, EntityDoiEntity::getEntityId);
|
// result = builderFactory.builder(EntityDoiFileTransformerBuilder.class).asMasterKey(query, EntityDoiEntity::getEntityId);
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,85 +1,85 @@
|
||||||
package eu.eudat.model.builder.filetransformer;
|
//package eu.eudat.model.builder.filetransformer;
|
||||||
|
//
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
//import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
//import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.convention.ConventionService;
|
//import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.DmpUserEntity;
|
//import eu.eudat.data.DmpUserEntity;
|
||||||
import eu.eudat.data.UserEntity;
|
//import eu.eudat.data.UserEntity;
|
||||||
import eu.eudat.file.transformer.enums.DmpUserRole;
|
//import eu.eudat.file.transformer.enums.DmpUserRole;
|
||||||
import eu.eudat.file.transformer.models.dmp.DmpUserFileTransformerModel;
|
//import eu.eudat.file.transformer.models.dmp.DmpUserFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.user.UserFileTransformerModel;
|
//import eu.eudat.file.transformer.models.user.UserFileTransformerModel;
|
||||||
import eu.eudat.query.UserQuery;
|
//import eu.eudat.query.UserQuery;
|
||||||
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;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
//import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
//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 java.util.*;
|
//import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
//import java.util.stream.Collectors;
|
||||||
|
//
|
||||||
@Component
|
//@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class DmpUserFileTransformerBuilder extends BaseFileTransformerBuilder<DmpUserFileTransformerModel, DmpUserEntity> {
|
//public class DmpUserFileTransformerBuilder extends BaseFileTransformerBuilder<DmpUserFileTransformerModel, DmpUserEntity> {
|
||||||
|
//
|
||||||
private final BuilderFactory builderFactory;
|
// private final BuilderFactory builderFactory;
|
||||||
|
//
|
||||||
private final QueryFactory queryFactory;
|
// private final QueryFactory queryFactory;
|
||||||
|
//
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
// private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
public DmpUserFileTransformerBuilder(
|
// public DmpUserFileTransformerBuilder(
|
||||||
ConventionService conventionService,
|
// ConventionService conventionService,
|
||||||
BuilderFactory builderFactory, QueryFactory queryFactory) {
|
// BuilderFactory builderFactory, QueryFactory queryFactory) {
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpUserFileTransformerBuilder.class)));
|
// super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpUserFileTransformerBuilder.class)));
|
||||||
this.builderFactory = builderFactory;
|
// this.builderFactory = builderFactory;
|
||||||
this.queryFactory = queryFactory;
|
// this.queryFactory = queryFactory;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public DmpUserFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
// public DmpUserFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
this.authorize = values;
|
// this.authorize = values;
|
||||||
return this;
|
// return this;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
protected List<FileTransformerBuilderItemResponse<DmpUserFileTransformerModel, DmpUserEntity>> buildInternal(List<DmpUserEntity> data) throws MyApplicationException {
|
// protected List<FileTransformerBuilderItemResponse<DmpUserFileTransformerModel, DmpUserEntity>> buildInternal(List<DmpUserEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {} items ", Optional.ofNullable(data).map(List::size).orElse(0));
|
// this.logger.debug("building for {} items ", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
if (data == null)
|
// if (data == null)
|
||||||
return new ArrayList<>();
|
// return new ArrayList<>();
|
||||||
|
//
|
||||||
|
//
|
||||||
Map<UUID, UserFileTransformerModel> userItemsMap = this.collectUsers(data);
|
// Map<UUID, UserFileTransformerModel> userItemsMap = this.collectUsers(data);
|
||||||
|
//
|
||||||
List<FileTransformerBuilderItemResponse<DmpUserFileTransformerModel, DmpUserEntity>> models = new ArrayList<>();
|
// List<FileTransformerBuilderItemResponse<DmpUserFileTransformerModel, DmpUserEntity>> models = new ArrayList<>();
|
||||||
for (DmpUserEntity d : data) {
|
// for (DmpUserEntity d : data) {
|
||||||
DmpUserFileTransformerModel m = new DmpUserFileTransformerModel();
|
// DmpUserFileTransformerModel m = new DmpUserFileTransformerModel();
|
||||||
m.setId(d.getId());
|
// m.setId(d.getId());
|
||||||
switch (d.getRole()){
|
// switch (d.getRole()){
|
||||||
case User -> m.setRole(DmpUserRole.User);
|
// case User -> m.setRole(DmpUserRole.User);
|
||||||
case Owner -> m.setRole(DmpUserRole.Owner);
|
// case Owner -> m.setRole(DmpUserRole.Owner);
|
||||||
default -> throw new MyApplicationException("unrecognized type " + d.getRole().getValue());
|
// default -> throw new MyApplicationException("unrecognized type " + d.getRole().getValue());
|
||||||
}
|
// }
|
||||||
if (userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId()));
|
// if (userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId()));
|
||||||
models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
// models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
||||||
}
|
// }
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
return models;
|
// return models;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private Map<UUID, UserFileTransformerModel> collectUsers(List<DmpUserEntity> data) throws MyApplicationException {
|
// private Map<UUID, UserFileTransformerModel> collectUsers(List<DmpUserEntity> data) throws MyApplicationException {
|
||||||
if (data.isEmpty())
|
// if (data.isEmpty())
|
||||||
return null;
|
// return null;
|
||||||
this.logger.debug("checking related - {}", UserFileTransformerModel.class.getSimpleName());
|
// this.logger.debug("checking related - {}", UserFileTransformerModel.class.getSimpleName());
|
||||||
|
//
|
||||||
Map<UUID, UserFileTransformerModel> itemMap;
|
// Map<UUID, UserFileTransformerModel> itemMap;
|
||||||
UserQuery q = this.queryFactory.query(UserQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().map(DmpUserEntity::getUserId).distinct().collect(Collectors.toList()));
|
// UserQuery q = this.queryFactory.query(UserQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().map(DmpUserEntity::getUserId).distinct().collect(Collectors.toList()));
|
||||||
itemMap = this.builderFactory.builder(UserFileTransformerBuilder.class).authorize(this.authorize).asForeignKey(q, UserEntity::getId);
|
// itemMap = this.builderFactory.builder(UserFileTransformerBuilder.class).authorize(this.authorize).asForeignKey(q, UserEntity::getId);
|
||||||
return itemMap;
|
// return itemMap;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,34 +1,34 @@
|
||||||
package eu.eudat.model.builder.filetransformer;
|
//package eu.eudat.model.builder.filetransformer;
|
||||||
|
//
|
||||||
import eu.eudat.convention.ConventionService;
|
//import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.EntityDoiEntity;
|
//import eu.eudat.data.EntityDoiEntity;
|
||||||
import eu.eudat.file.transformer.models.entitydoi.EntityDoiFileTransformerModel;
|
//import eu.eudat.file.transformer.models.entitydoi.EntityDoiFileTransformerModel;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
//import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
//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.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
|
//
|
||||||
import java.util.ArrayList;
|
//import java.util.ArrayList;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
|
//
|
||||||
@Component
|
//@Component
|
||||||
public class EntityDoiFileTransformerBuilder extends BaseFileTransformerBuilder<EntityDoiFileTransformerModel, EntityDoiEntity>{
|
//public class EntityDoiFileTransformerBuilder extends BaseFileTransformerBuilder<EntityDoiFileTransformerModel, EntityDoiEntity>{
|
||||||
@Autowired
|
// @Autowired
|
||||||
public EntityDoiFileTransformerBuilder(ConventionService conventionService) {
|
// public EntityDoiFileTransformerBuilder(ConventionService conventionService) {
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpFileTransformerBuilder.class)));
|
// super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpFileTransformerBuilder.class)));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
protected List<FileTransformerBuilderItemResponse<EntityDoiFileTransformerModel, EntityDoiEntity>> buildInternal(List<EntityDoiEntity> data) throws MyApplicationException {
|
// protected List<FileTransformerBuilderItemResponse<EntityDoiFileTransformerModel, EntityDoiEntity>> buildInternal(List<EntityDoiEntity> data) throws MyApplicationException {
|
||||||
List<FileTransformerBuilderItemResponse<EntityDoiFileTransformerModel, EntityDoiEntity>> result = new ArrayList<>();
|
// List<FileTransformerBuilderItemResponse<EntityDoiFileTransformerModel, EntityDoiEntity>> result = new ArrayList<>();
|
||||||
for (EntityDoiEntity d : data) {
|
// for (EntityDoiEntity d : data) {
|
||||||
EntityDoiFileTransformerModel m = new EntityDoiFileTransformerModel();
|
// EntityDoiFileTransformerModel m = new EntityDoiFileTransformerModel();
|
||||||
m.setId(d.getId());
|
// m.setId(d.getId());
|
||||||
m.setDoi(d.getDoi());
|
// m.setDoi(d.getDoi());
|
||||||
m.setRepositoryId(d.getRepositoryId());
|
// m.setRepositoryId(d.getRepositoryId());
|
||||||
result.add(new FileTransformerBuilderItemResponse<>(m, d));
|
// result.add(new FileTransformerBuilderItemResponse<>(m, d));
|
||||||
}
|
// }
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
package eu.eudat.model.builder.filetransformer;
|
//package eu.eudat.model.builder.filetransformer;
|
||||||
|
//
|
||||||
public class FileTransformerBuilderItemResponse<M, D>{
|
//public class FileTransformerBuilderItemResponse<M, D>{
|
||||||
private final M model;
|
// private final M model;
|
||||||
private final D data;
|
// private final D data;
|
||||||
|
//
|
||||||
public FileTransformerBuilderItemResponse(M model, D data) {
|
// public FileTransformerBuilderItemResponse(M model, D data) {
|
||||||
this.model = model;
|
// this.model = model;
|
||||||
this.data = data;
|
// this.data = data;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public D getData() {
|
// public D getData() {
|
||||||
return data;
|
// return data;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public M getModel() {
|
// public M getModel() {
|
||||||
return model;
|
// return model;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,55 +1,54 @@
|
||||||
package eu.eudat.model.builder.filetransformer;
|
//package eu.eudat.model.builder.filetransformer;
|
||||||
|
//
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
//import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.commons.types.reference.DefinitionEntity;
|
//import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||||
import eu.eudat.convention.ConventionService;
|
//import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.depositinterface.models.reference.DefinitionDepositModel;
|
//import eu.eudat.file.transformer.models.reference.DefinitionFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.reference.DefinitionFileTransformerModel;
|
//import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
//import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
//import gr.cite.tools.logging.LoggerService;
|
||||||
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 java.util.ArrayList;
|
||||||
import java.util.ArrayList;
|
//import java.util.EnumSet;
|
||||||
import java.util.EnumSet;
|
//import java.util.List;
|
||||||
import java.util.List;
|
//import java.util.Optional;
|
||||||
import java.util.Optional;
|
//
|
||||||
|
//@Component
|
||||||
@Component
|
//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
//public class ReferenceDefinitionFileTransformerBuilder extends BaseFileTransformerBuilder<DefinitionFileTransformerModel, DefinitionEntity> {
|
||||||
public class ReferenceDefinitionFileTransformerBuilder extends BaseFileTransformerBuilder<DefinitionFileTransformerModel, DefinitionEntity> {
|
//
|
||||||
|
// private final BuilderFactory builderFactory;
|
||||||
private final BuilderFactory builderFactory;
|
// private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
//
|
||||||
|
// @Autowired
|
||||||
@Autowired
|
// public ReferenceDefinitionFileTransformerBuilder(
|
||||||
public ReferenceDefinitionFileTransformerBuilder(
|
// ConventionService conventionService, BuilderFactory builderFactory) {
|
||||||
ConventionService conventionService, BuilderFactory builderFactory) {
|
// super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceDefinitionFileTransformerBuilder.class)));
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceDefinitionFileTransformerBuilder.class)));
|
// this.builderFactory = builderFactory;
|
||||||
this.builderFactory = builderFactory;
|
// }
|
||||||
}
|
//
|
||||||
|
// public ReferenceDefinitionFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
public ReferenceDefinitionFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
// this.authorize = values;
|
||||||
this.authorize = values;
|
// return this;
|
||||||
return this;
|
// }
|
||||||
}
|
//
|
||||||
|
// @Override
|
||||||
@Override
|
// protected List<FileTransformerBuilderItemResponse<DefinitionFileTransformerModel, DefinitionEntity>> buildInternal(List<DefinitionEntity> data) throws MyApplicationException {
|
||||||
protected List<FileTransformerBuilderItemResponse<DefinitionFileTransformerModel, DefinitionEntity>> buildInternal(List<DefinitionEntity> data) throws MyApplicationException {
|
// this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
// if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
//
|
||||||
|
// List<FileTransformerBuilderItemResponse<DefinitionFileTransformerModel, DefinitionEntity>> models = new ArrayList<>();
|
||||||
List<FileTransformerBuilderItemResponse<DefinitionFileTransformerModel, DefinitionEntity>> models = new ArrayList<>();
|
// for (DefinitionEntity d : data) {
|
||||||
for (DefinitionEntity d : data) {
|
// DefinitionFileTransformerModel m = new DefinitionFileTransformerModel();
|
||||||
DefinitionFileTransformerModel m = new DefinitionFileTransformerModel();
|
// if (d.getFields() != null) m.setFields(this.builderFactory.builder(ReferenceFieldFileTransformerBuilder.class).authorize(this.authorize).build(d.getFields()));
|
||||||
if (d.getFields() != null) m.setFields(this.builderFactory.builder(ReferenceFieldFileTransformerBuilder.class).authorize(this.authorize).build(d.getFields()));
|
// models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
||||||
models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
// }
|
||||||
}
|
// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
// return models;
|
||||||
return models;
|
// }
|
||||||
}
|
//}
|
||||||
}
|
|
||||||
|
|
|
@ -1,54 +1,53 @@
|
||||||
package eu.eudat.model.builder.filetransformer;
|
//package eu.eudat.model.builder.filetransformer;
|
||||||
|
//
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
//import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.commons.types.reference.FieldEntity;
|
//import eu.eudat.commons.types.reference.FieldEntity;
|
||||||
import eu.eudat.convention.ConventionService;
|
//import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.depositinterface.models.reference.FieldDepositModel;
|
//import eu.eudat.file.transformer.models.reference.FieldFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.reference.FieldFileTransformerModel;
|
//import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
//import gr.cite.tools.logging.LoggerService;
|
||||||
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 java.util.ArrayList;
|
||||||
import java.util.ArrayList;
|
//import java.util.EnumSet;
|
||||||
import java.util.EnumSet;
|
//import java.util.List;
|
||||||
import java.util.List;
|
//import java.util.Optional;
|
||||||
import java.util.Optional;
|
//
|
||||||
|
//@Component
|
||||||
@Component
|
//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
//public class ReferenceFieldFileTransformerBuilder extends BaseFileTransformerBuilder<FieldFileTransformerModel, FieldEntity> {
|
||||||
public class ReferenceFieldFileTransformerBuilder extends BaseFileTransformerBuilder<FieldFileTransformerModel, FieldEntity> {
|
//
|
||||||
|
// private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
//
|
||||||
|
// @Autowired
|
||||||
@Autowired
|
// public ReferenceFieldFileTransformerBuilder(
|
||||||
public ReferenceFieldFileTransformerBuilder(
|
// ConventionService conventionService) {
|
||||||
ConventionService conventionService) {
|
// super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceFieldFileTransformerBuilder.class)));
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceFieldFileTransformerBuilder.class)));
|
// }
|
||||||
}
|
//
|
||||||
|
// public ReferenceFieldFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
public ReferenceFieldFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
// this.authorize = values;
|
||||||
this.authorize = values;
|
// return this;
|
||||||
return this;
|
// }
|
||||||
}
|
//
|
||||||
|
// @Override
|
||||||
@Override
|
// protected List<FileTransformerBuilderItemResponse<FieldFileTransformerModel, FieldEntity>> buildInternal(List<FieldEntity> data) throws MyApplicationException {
|
||||||
protected List<FileTransformerBuilderItemResponse<FieldFileTransformerModel, FieldEntity>> buildInternal(List<FieldEntity> data) throws MyApplicationException {
|
// this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
// if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
//
|
||||||
|
// List<FileTransformerBuilderItemResponse<FieldFileTransformerModel, FieldEntity>> models = new ArrayList<>();
|
||||||
List<FileTransformerBuilderItemResponse<FieldFileTransformerModel, FieldEntity>> models = new ArrayList<>();
|
// for (FieldEntity d : data) {
|
||||||
for (FieldEntity d : data) {
|
// FieldFileTransformerModel m = new FieldFileTransformerModel();
|
||||||
FieldFileTransformerModel m = new FieldFileTransformerModel();
|
// m.setCode(d.getCode());
|
||||||
m.setCode(d.getCode());
|
// m.setValue(d.getValue());
|
||||||
m.setValue(d.getValue());
|
//
|
||||||
|
// models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
||||||
models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
// }
|
||||||
}
|
// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
// return models;
|
||||||
return models;
|
// }
|
||||||
}
|
//}
|
||||||
}
|
|
||||||
|
|
|
@ -1,80 +1,80 @@
|
||||||
package eu.eudat.model.builder.filetransformer;
|
//package eu.eudat.model.builder.filetransformer;
|
||||||
|
//
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
//import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.commons.XmlHandlingService;
|
//import eu.eudat.commons.XmlHandlingService;
|
||||||
import eu.eudat.commons.types.reference.DefinitionEntity;
|
//import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||||
import eu.eudat.convention.ConventionService;
|
//import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.ReferenceEntity;
|
//import eu.eudat.data.ReferenceEntity;
|
||||||
import eu.eudat.file.transformer.enums.ReferenceSourceType;
|
//import eu.eudat.file.transformer.enums.ReferenceSourceType;
|
||||||
import eu.eudat.file.transformer.enums.ReferenceType;
|
//import eu.eudat.file.transformer.enums.ReferenceType;
|
||||||
import eu.eudat.file.transformer.models.description.DescriptionReferenceFileTransformerModel;
|
//import eu.eudat.file.transformer.models.description.DescriptionReferenceFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.dmp.DmpReferenceFileTransformerModel;
|
//import eu.eudat.file.transformer.models.dmp.DmpReferenceFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.reference.ReferenceFileTransformerModel;
|
//import eu.eudat.file.transformer.models.reference.ReferenceFileTransformerModel;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
//import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
//import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
//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 java.util.ArrayList;
|
//import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
//import java.util.EnumSet;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import java.util.Optional;
|
//import java.util.Optional;
|
||||||
|
//
|
||||||
@Component
|
//@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class ReferenceFileTransformerBuilder extends BaseFileTransformerBuilder<ReferenceFileTransformerModel, ReferenceEntity> {
|
//public class ReferenceFileTransformerBuilder extends BaseFileTransformerBuilder<ReferenceFileTransformerModel, ReferenceEntity> {
|
||||||
|
//
|
||||||
private final BuilderFactory builderFactory;
|
// private final BuilderFactory builderFactory;
|
||||||
private final XmlHandlingService xmlHandlingService;
|
// private final XmlHandlingService xmlHandlingService;
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
// private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
public ReferenceFileTransformerBuilder(
|
// public ReferenceFileTransformerBuilder(
|
||||||
ConventionService conventionService,
|
// ConventionService conventionService,
|
||||||
BuilderFactory builderFactory, XmlHandlingService xmlHandlingService) {
|
// BuilderFactory builderFactory, XmlHandlingService xmlHandlingService) {
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceFileTransformerBuilder.class)));
|
// super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceFileTransformerBuilder.class)));
|
||||||
this.builderFactory = builderFactory;
|
// this.builderFactory = builderFactory;
|
||||||
this.xmlHandlingService = xmlHandlingService;
|
// this.xmlHandlingService = xmlHandlingService;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public ReferenceFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
// public ReferenceFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
this.authorize = values;
|
// this.authorize = values;
|
||||||
return this;
|
// return this;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
protected List<FileTransformerBuilderItemResponse<ReferenceFileTransformerModel, ReferenceEntity>> buildInternal(List<ReferenceEntity> data) throws MyApplicationException {
|
// protected List<FileTransformerBuilderItemResponse<ReferenceFileTransformerModel, ReferenceEntity>> buildInternal(List<ReferenceEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
// this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
// if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
//
|
||||||
List<FileTransformerBuilderItemResponse<ReferenceFileTransformerModel, ReferenceEntity>> models = new ArrayList<>();
|
// List<FileTransformerBuilderItemResponse<ReferenceFileTransformerModel, ReferenceEntity>> models = new ArrayList<>();
|
||||||
for (ReferenceEntity d : data) {
|
// for (ReferenceEntity d : data) {
|
||||||
ReferenceFileTransformerModel m = new ReferenceFileTransformerModel();
|
// ReferenceFileTransformerModel m = new ReferenceFileTransformerModel();
|
||||||
m.setId(d.getId());
|
// m.setId(d.getId());
|
||||||
m.setLabel(d.getLabel());
|
// m.setLabel(d.getLabel());
|
||||||
if (d.getDefinition() != null){
|
// if (d.getDefinition() != null){
|
||||||
DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, d.getDefinition());
|
// DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, d.getDefinition());
|
||||||
m.setDefinition(this.builderFactory.builder(ReferenceDefinitionFileTransformerBuilder.class).authorize(this.authorize).build(definition));
|
// m.setDefinition(this.builderFactory.builder(ReferenceDefinitionFileTransformerBuilder.class).authorize(this.authorize).build(definition));
|
||||||
}
|
// }
|
||||||
m.setReference(d.getReference());
|
// m.setReference(d.getReference());
|
||||||
m.setAbbreviation(d.getAbbreviation());
|
// m.setAbbreviation(d.getAbbreviation());
|
||||||
m.setDescription(d.getDescription());
|
// m.setDescription(d.getDescription());
|
||||||
m.setSource(d.getSource());
|
// m.setSource(d.getSource());
|
||||||
switch (d.getSourceType()){
|
// switch (d.getSourceType()){
|
||||||
case Internal -> m.setSourceType(ReferenceSourceType.Internal);
|
// case Internal -> m.setSourceType(ReferenceSourceType.Internal);
|
||||||
case External -> m.setSourceType(ReferenceSourceType.External);
|
// case External -> m.setSourceType(ReferenceSourceType.External);
|
||||||
default -> throw new MyApplicationException("unrecognized type " + d.getSourceType().getValue());
|
// default -> throw new MyApplicationException("unrecognized type " + d.getSourceType().getValue());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
//m.setType(d.getTypeId()); //TODO new reference logic
|
// //m.setType(d.getTypeId()); //TODO new reference logic
|
||||||
|
//
|
||||||
models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
// models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
||||||
}
|
// }
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
return models;
|
// return models;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,59 +1,59 @@
|
||||||
package eu.eudat.model.builder.filetransformer;
|
//package eu.eudat.model.builder.filetransformer;
|
||||||
|
//
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
//import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.commons.XmlHandlingService;
|
//import eu.eudat.commons.XmlHandlingService;
|
||||||
import eu.eudat.convention.ConventionService;
|
//import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.TagEntity;
|
//import eu.eudat.data.TagEntity;
|
||||||
import eu.eudat.file.transformer.models.tag.TagFileTransformerModel;
|
//import eu.eudat.file.transformer.models.tag.TagFileTransformerModel;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
//import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
//import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
//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 java.util.ArrayList;
|
//import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
//import java.util.EnumSet;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import java.util.Optional;
|
//import java.util.Optional;
|
||||||
|
//
|
||||||
@Component
|
//@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class TagFileTransformerBuilder extends BaseFileTransformerBuilder<TagFileTransformerModel, TagEntity> {
|
//public class TagFileTransformerBuilder extends BaseFileTransformerBuilder<TagFileTransformerModel, TagEntity> {
|
||||||
|
//
|
||||||
private final BuilderFactory builderFactory;
|
// private final BuilderFactory builderFactory;
|
||||||
private final XmlHandlingService xmlHandlingService;
|
// private final XmlHandlingService xmlHandlingService;
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
// private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
public TagFileTransformerBuilder(
|
// public TagFileTransformerBuilder(
|
||||||
ConventionService conventionService,
|
// ConventionService conventionService,
|
||||||
BuilderFactory builderFactory, XmlHandlingService xmlHandlingService) {
|
// BuilderFactory builderFactory, XmlHandlingService xmlHandlingService) {
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(TagFileTransformerBuilder.class)));
|
// super(conventionService, new LoggerService(LoggerFactory.getLogger(TagFileTransformerBuilder.class)));
|
||||||
this.builderFactory = builderFactory;
|
// this.builderFactory = builderFactory;
|
||||||
this.xmlHandlingService = xmlHandlingService;
|
// this.xmlHandlingService = xmlHandlingService;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public TagFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
// public TagFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
this.authorize = values;
|
// this.authorize = values;
|
||||||
return this;
|
// return this;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
protected List<FileTransformerBuilderItemResponse<TagFileTransformerModel, TagEntity>> buildInternal(List<TagEntity> data) throws MyApplicationException {
|
// protected List<FileTransformerBuilderItemResponse<TagFileTransformerModel, TagEntity>> buildInternal(List<TagEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
// this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
if (data == null || data.isEmpty()) return new ArrayList<>();
|
// if (data == null || data.isEmpty()) return new ArrayList<>();
|
||||||
|
//
|
||||||
List<FileTransformerBuilderItemResponse<TagFileTransformerModel, TagEntity>> models = new ArrayList<>();
|
// List<FileTransformerBuilderItemResponse<TagFileTransformerModel, TagEntity>> models = new ArrayList<>();
|
||||||
for (TagEntity d : data) {
|
// for (TagEntity d : data) {
|
||||||
TagFileTransformerModel m = new TagFileTransformerModel();
|
// TagFileTransformerModel m = new TagFileTransformerModel();
|
||||||
m.setId(d.getId());
|
// m.setId(d.getId());
|
||||||
m.setLabel(d.getLabel());
|
// m.setLabel(d.getLabel());
|
||||||
models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
// models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
||||||
}
|
// }
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
return models;
|
// return models;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,76 +1,75 @@
|
||||||
package eu.eudat.model.builder.filetransformer;
|
//package eu.eudat.model.builder.filetransformer;
|
||||||
|
//
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
//import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.convention.ConventionService;
|
//import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.UserContactInfoEntity;
|
//import eu.eudat.data.UserContactInfoEntity;
|
||||||
import eu.eudat.data.UserEntity;
|
//import eu.eudat.data.UserEntity;
|
||||||
import eu.eudat.depositinterface.models.UserDepositModel;
|
//import eu.eudat.file.transformer.enums.ContactInfoType;
|
||||||
import eu.eudat.file.transformer.enums.ContactInfoType;
|
//import eu.eudat.file.transformer.models.user.UserContactInfoFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.user.UserContactInfoFileTransformerModel;
|
//import eu.eudat.file.transformer.models.user.UserFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.user.UserFileTransformerModel;
|
//import eu.eudat.query.UserContactInfoQuery;
|
||||||
import eu.eudat.query.UserContactInfoQuery;
|
//import gr.cite.tools.data.query.QueryFactory;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
//import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
//import gr.cite.tools.logging.LoggerService;
|
||||||
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 java.util.*;
|
||||||
import java.util.*;
|
//
|
||||||
|
//@Component
|
||||||
@Component
|
//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
//public class UserFileTransformerBuilder extends BaseFileTransformerBuilder<UserFileTransformerModel, UserEntity> {
|
||||||
public class UserFileTransformerBuilder extends BaseFileTransformerBuilder<UserFileTransformerModel, UserEntity> {
|
//
|
||||||
|
// private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
// private final QueryFactory queryFactory;
|
||||||
private final QueryFactory queryFactory;
|
//
|
||||||
|
// @Autowired
|
||||||
@Autowired
|
// public UserFileTransformerBuilder(ConventionService conventionService, QueryFactory queryFactory) {
|
||||||
public UserFileTransformerBuilder(ConventionService conventionService, QueryFactory queryFactory) {
|
// super(conventionService, new LoggerService(LoggerFactory.getLogger(UserFileTransformerBuilder.class)));
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(UserFileTransformerBuilder.class)));
|
// this.queryFactory = queryFactory;
|
||||||
this.queryFactory = queryFactory;
|
// }
|
||||||
}
|
//
|
||||||
|
// public UserFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
public UserFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
// this.authorize = values;
|
||||||
this.authorize = values;
|
// return this;
|
||||||
return this;
|
// }
|
||||||
}
|
//
|
||||||
|
// @Override
|
||||||
@Override
|
// protected List<FileTransformerBuilderItemResponse<UserFileTransformerModel, UserEntity>> buildInternal(List<UserEntity> data) throws MyApplicationException {
|
||||||
protected List<FileTransformerBuilderItemResponse<UserFileTransformerModel, UserEntity>> buildInternal(List<UserEntity> data) throws MyApplicationException {
|
// this.logger.debug("building for {} items ", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
this.logger.debug("building for {} items ", Optional.ofNullable(data).map(List::size).orElse(0));
|
// if (data == null)
|
||||||
if (data == null)
|
// return new ArrayList<>();
|
||||||
return new ArrayList<>();
|
//
|
||||||
|
// List<FileTransformerBuilderItemResponse<UserFileTransformerModel, UserEntity>> models = new ArrayList<>();
|
||||||
List<FileTransformerBuilderItemResponse<UserFileTransformerModel, UserEntity>> models = new ArrayList<>();
|
//
|
||||||
|
// for (UserEntity d : data) {
|
||||||
for (UserEntity d : data) {
|
// UserFileTransformerModel m = new UserFileTransformerModel();
|
||||||
UserFileTransformerModel m = new UserFileTransformerModel();
|
// m.setId(d.getId());
|
||||||
m.setId(d.getId());
|
// m.setName(d.getName());
|
||||||
m.setName(d.getName());
|
// m.setContacts(mapContactInfo(d.getId()));
|
||||||
m.setContacts(mapContactInfo(d.getId()));
|
// models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
||||||
models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
// }
|
||||||
}
|
// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
//
|
||||||
|
// return models;
|
||||||
return models;
|
// }
|
||||||
}
|
//
|
||||||
|
// private List<UserContactInfoFileTransformerModel> mapContactInfo(UUID userId) {
|
||||||
private List<UserContactInfoFileTransformerModel> mapContactInfo(UUID userId) {
|
// List<UserContactInfoFileTransformerModel> result = new ArrayList<>();
|
||||||
List<UserContactInfoFileTransformerModel> result = new ArrayList<>();
|
// UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(userId);
|
||||||
UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(userId);
|
// List<UserContactInfoEntity> contactInfos = query.collect();
|
||||||
List<UserContactInfoEntity> contactInfos = query.collect();
|
// contactInfos.forEach(contactInfo -> {
|
||||||
contactInfos.forEach(contactInfo -> {
|
// UserContactInfoFileTransformerModel m = new UserContactInfoFileTransformerModel();
|
||||||
UserContactInfoFileTransformerModel m = new UserContactInfoFileTransformerModel();
|
// m.setId(contactInfo.getId());
|
||||||
m.setId(contactInfo.getId());
|
// m.setOrdinal(contactInfo.getOrdinal());
|
||||||
m.setOrdinal(contactInfo.getOrdinal());
|
// m.setType(ContactInfoType.of(contactInfo.getType().getValue()));
|
||||||
m.setType(ContactInfoType.of(contactInfo.getType().getValue()));
|
// m.setValue(contactInfo.getValue());
|
||||||
m.setValue(contactInfo.getValue());
|
// result.add(m);
|
||||||
result.add(m);
|
// });
|
||||||
});
|
// return result;
|
||||||
return result;
|
// }
|
||||||
}
|
//
|
||||||
|
//}
|
||||||
}
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.service.deposit;
|
package eu.eudat.service.deposit;
|
||||||
|
|
||||||
import eu.eudat.depositinterface.models.DmpDepositModel;
|
import eu.eudat.commonmodels.models.DmpModel;
|
||||||
import eu.eudat.depositinterface.repository.DepositClient;
|
import eu.eudat.depositinterface.repository.DepositClient;
|
||||||
import eu.eudat.depositinterface.repository.DepositConfiguration;
|
import eu.eudat.depositinterface.repository.DepositConfiguration;
|
||||||
import org.springframework.core.ParameterizedTypeReference;
|
import org.springframework.core.ParameterizedTypeReference;
|
||||||
|
@ -16,7 +16,7 @@ public class DepositClientImpl implements DepositClient {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String deposit(DmpDepositModel dmpDepositModel, String repositoryAccessToken) throws Exception {
|
public String deposit(DmpModel dmpDepositModel, String repositoryAccessToken) throws Exception {
|
||||||
return depositClient.post().uri("/", uriBuilder -> uriBuilder.queryParam("authToken", repositoryAccessToken).build()).bodyValue(dmpDepositModel).exchangeToMono(mono -> mono.bodyToMono(String.class)).block();
|
return depositClient.post().uri("/", uriBuilder -> uriBuilder.queryParam("authToken", repositoryAccessToken).build()).bodyValue(dmpDepositModel).exchangeToMono(mono -> mono.bodyToMono(String.class)).block();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,22 +2,22 @@ package eu.eudat.service.deposit;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.commonmodels.models.DmpModel;
|
||||||
|
import eu.eudat.commonmodels.models.FileEnvelopeModel;
|
||||||
import eu.eudat.configurations.deposit.DepositProperties;
|
import eu.eudat.configurations.deposit.DepositProperties;
|
||||||
import eu.eudat.data.DmpEntity;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.depositinterface.models.DmpDepositModel;
|
|
||||||
import eu.eudat.depositinterface.models.FileEnvelope;
|
|
||||||
import eu.eudat.depositinterface.repository.DepositClient;
|
import eu.eudat.depositinterface.repository.DepositClient;
|
||||||
import eu.eudat.depositinterface.repository.DepositConfiguration;
|
import eu.eudat.depositinterface.repository.DepositConfiguration;
|
||||||
import eu.eudat.model.EntityDoi;
|
import eu.eudat.model.EntityDoi;
|
||||||
import eu.eudat.model.builder.deposit.DepositConfigurationBuilder;
|
import eu.eudat.model.builder.commonmodels.DepositConfigurationBuilder;
|
||||||
import eu.eudat.model.builder.deposit.DmpDepositBuilder;
|
import eu.eudat.model.builder.commonmodels.DmpCommonModelBuilder;
|
||||||
import eu.eudat.model.persist.deposit.DepositAuthenticateRequest;
|
import eu.eudat.model.persist.deposit.DepositAuthenticateRequest;
|
||||||
import eu.eudat.model.persist.deposit.DepositRequest;
|
import eu.eudat.model.persist.deposit.DepositRequest;
|
||||||
import eu.eudat.model.persist.EntityDoiPersist;
|
import eu.eudat.model.persist.EntityDoiPersist;
|
||||||
import eu.eudat.query.DmpQuery;
|
import eu.eudat.query.DmpQuery;
|
||||||
import eu.eudat.service.entitydoi.EntityDoiService;
|
import eu.eudat.service.entitydoi.EntityDoiService;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeCacheService;
|
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeCacheService;
|
||||||
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeFilterFunction;
|
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeFilterFunction;
|
||||||
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeModel;
|
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeModel;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
@ -130,10 +130,10 @@ public class DepositServiceImpl implements DepositService {
|
||||||
|
|
||||||
//GK: Forth make the required files to be uploaded with the deposit
|
//GK: Forth make the required files to be uploaded with the deposit
|
||||||
//TODO: Properly create required files
|
//TODO: Properly create required files
|
||||||
FileEnvelope docEnvelope = new FileEnvelope();
|
FileEnvelopeModel docEnvelope = new FileEnvelopeModel();
|
||||||
FileEnvelope pdfEnvelope = new FileEnvelope();
|
FileEnvelopeModel pdfEnvelope = new FileEnvelopeModel();
|
||||||
FileEnvelope jsonEnvelope = new FileEnvelope();
|
FileEnvelopeModel jsonEnvelope = new FileEnvelopeModel();
|
||||||
FileEnvelope zip = new FileEnvelope();
|
FileEnvelopeModel zip = new FileEnvelopeModel();
|
||||||
//TODO: Create Files
|
//TODO: Create Files
|
||||||
// File zip = new File(environment.getProperty("temp.temp") + UUID.randomUUID() + ".zip");
|
// File zip = new File(environment.getProperty("temp.temp") + UUID.randomUUID() + ".zip");
|
||||||
// try {
|
// try {
|
||||||
|
@ -151,7 +151,7 @@ public class DepositServiceImpl implements DepositService {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
//GK: Fifth Transform them to the DepositModel
|
//GK: Fifth Transform them to the DepositModel
|
||||||
DmpDepositModel depositModel = this.builderFactory.builder(DmpDepositBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic)
|
DmpModel depositModel = this.builderFactory.builder(DmpCommonModelBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic)
|
||||||
.setRepositoryId(dmpDepositModel.getRepositoryId()).setPdfFile(pdfEnvelope).setRdaJsonFile(jsonEnvelope).setSupportingFilesZip(zip).build(dmpEntity);
|
.setRepositoryId(dmpDepositModel.getRepositoryId()).setPdfFile(pdfEnvelope).setRdaJsonFile(jsonEnvelope).setSupportingFilesZip(zip).build(dmpEntity);
|
||||||
|
|
||||||
//GK: Sixth Perform the deposit
|
//GK: Sixth Perform the deposit
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.eudat.service.fielddatahelper;
|
package eu.eudat.service.fielddatahelper;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.fielddata.BaseFieldDataModel;
|
||||||
import eu.eudat.commons.enums.FieldType;
|
import eu.eudat.commons.enums.FieldType;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.BaseFieldDataEntity;
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.BaseFieldDataEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.BaseFieldDataImportExport;
|
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.BaseFieldDataImportExport;
|
||||||
|
@ -12,19 +13,21 @@ import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public abstract class BaseFieldDataHelperService<M extends BaseFieldData, PM extends BaseFieldDataPersist, D extends BaseFieldDataEntity, IE extends BaseFieldDataImportExport> implements FieldDataHelperService {
|
public abstract class BaseFieldDataHelperService<M extends BaseFieldData, PM extends BaseFieldDataPersist, D extends BaseFieldDataEntity, IE extends BaseFieldDataImportExport, CM extends BaseFieldDataModel> implements FieldDataHelperService {
|
||||||
protected FieldType fieldType;
|
protected FieldType fieldType;
|
||||||
|
|
||||||
protected abstract D newDataInstanceInternal();
|
protected abstract D newDataInstanceInternal();
|
||||||
protected abstract M newModelInstanceInternal();
|
protected abstract M newModelInstanceInternal();
|
||||||
protected abstract PM newPersistModelInstanceInternal();
|
protected abstract PM newPersistModelInstanceInternal();
|
||||||
protected abstract IE newImportExportInstanceInternal();
|
protected abstract IE newImportExportInstanceInternal();
|
||||||
|
protected abstract CM newCommonModelInstanceInternal();
|
||||||
|
|
||||||
protected abstract List<M> buildInternal(FieldSet fieldSet, List<D> data, EnumSet<AuthorizationFlags> authorizationFlags);
|
protected abstract List<M> buildInternal(FieldSet fieldSet, List<D> data, EnumSet<AuthorizationFlags> authorizationFlags);
|
||||||
protected abstract D applyPersistInternal(PM persist, D data);
|
protected abstract D applyPersistInternal(PM persist, D data);
|
||||||
protected abstract PM importExportMapDataToPersistInternal(IE data, PM persist);
|
protected abstract PM importExportMapDataToPersistInternal(IE data, PM persist);
|
||||||
protected abstract IE dataToImportExportXmlInternal(D data, IE xml);
|
protected abstract IE dataToImportExportXmlInternal(D data, IE xml);
|
||||||
protected abstract boolean isMultiValueInternal(D data);
|
protected abstract boolean isMultiValueInternal(D data);
|
||||||
|
protected abstract List<CM> buildCommonModelInternal(List<D> data, EnumSet<AuthorizationFlags> authorizationFlags);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FieldType getFieldType() {
|
public FieldType getFieldType() {
|
||||||
|
@ -45,6 +48,11 @@ public abstract class BaseFieldDataHelperService<M extends BaseFieldData, PM ext
|
||||||
return this.newModelInstanceInternal();
|
return this.newModelInstanceInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseFieldDataModel newCommonModelInstance() {
|
||||||
|
return this.newCommonModelInstanceInternal();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseFieldDataPersist newPersistModelInstance() {
|
public BaseFieldDataPersist newPersistModelInstance() {
|
||||||
return this.newPersistModelInstanceInternal();
|
return this.newPersistModelInstanceInternal();
|
||||||
|
@ -94,6 +102,13 @@ public abstract class BaseFieldDataHelperService<M extends BaseFieldData, PM ext
|
||||||
return models.get(0);
|
return models.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseFieldDataModel buildCommonModelOne(BaseFieldDataEntity data, EnumSet<AuthorizationFlags> authorizationFlags){
|
||||||
|
List<BaseFieldDataModel> models = this.buildCommonModelInternal(List.of((D) data), authorizationFlags).stream().map(x-> (CM)x).collect(Collectors.toList());
|
||||||
|
if (models == null || models.isEmpty()) return null;
|
||||||
|
return models.getFirst();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BaseFieldData> build(FieldSet fieldSet, List<BaseFieldDataEntity> data, EnumSet<AuthorizationFlags> authorizationFlags) {
|
public List<BaseFieldData> build(FieldSet fieldSet, List<BaseFieldDataEntity> data, EnumSet<AuthorizationFlags> authorizationFlags) {
|
||||||
return this.buildInternal(fieldSet, data.stream().map(x-> (D) x).collect(Collectors.toList()), authorizationFlags).stream().map(x-> (M)x).collect(Collectors.toList());
|
return this.buildInternal(fieldSet, data.stream().map(x-> (D) x).collect(Collectors.toList()), authorizationFlags).stream().map(x-> (M)x).collect(Collectors.toList());
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.eudat.service.fielddatahelper;
|
package eu.eudat.service.fielddatahelper;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.fielddata.BaseFieldDataModel;
|
||||||
import eu.eudat.commons.enums.FieldType;
|
import eu.eudat.commons.enums.FieldType;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.BaseFieldDataEntity;
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.BaseFieldDataEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.BaseFieldDataImportExport;
|
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.BaseFieldDataImportExport;
|
||||||
|
@ -16,15 +17,18 @@ public interface FieldDataHelperService {
|
||||||
FieldType getFieldType();
|
FieldType getFieldType();
|
||||||
BaseFieldDataEntity newDataInstance();
|
BaseFieldDataEntity newDataInstance();
|
||||||
BaseFieldData newModelInstance();
|
BaseFieldData newModelInstance();
|
||||||
|
BaseFieldDataModel newCommonModelInstance();
|
||||||
BaseFieldDataPersist newPersistModelInstance();
|
BaseFieldDataPersist newPersistModelInstance();
|
||||||
BaseFieldDataImportExport newImportExportInstance();
|
BaseFieldDataImportExport newImportExportInstance();
|
||||||
Class<?> getDataClass();
|
Class<?> getDataClass();
|
||||||
Class<?> getModelClass();
|
Class<?> getModelClass();
|
||||||
Class<?> getPersistModelClass();
|
Class<?> getPersistModelClass();
|
||||||
|
Class<?> getCommonModelClass();
|
||||||
Class<?> getImportExportClass();
|
Class<?> getImportExportClass();
|
||||||
Validator getPersistModelValidator();
|
Validator getPersistModelValidator();
|
||||||
List<BaseFieldData> build(gr.cite.tools.fieldset.FieldSet fieldSet, List<BaseFieldDataEntity> data, EnumSet<AuthorizationFlags> authorizationFlags);
|
List<BaseFieldData> build(gr.cite.tools.fieldset.FieldSet fieldSet, List<BaseFieldDataEntity> data, EnumSet<AuthorizationFlags> authorizationFlags);
|
||||||
BaseFieldData buildOne(FieldSet fieldSet, BaseFieldDataEntity data, EnumSet<AuthorizationFlags> authorizationFlags);
|
BaseFieldData buildOne(FieldSet fieldSet, BaseFieldDataEntity data, EnumSet<AuthorizationFlags> authorizationFlags);
|
||||||
|
BaseFieldDataModel buildCommonModelOne(BaseFieldDataEntity data, EnumSet<AuthorizationFlags> authorizationFlags);
|
||||||
BaseFieldDataEntity applyPersist(BaseFieldDataPersist persist);
|
BaseFieldDataEntity applyPersist(BaseFieldDataPersist persist);
|
||||||
BaseFieldDataEntity applyPersist(BaseFieldDataPersist persist, BaseFieldDataEntity data);
|
BaseFieldDataEntity applyPersist(BaseFieldDataPersist persist, BaseFieldDataEntity data);
|
||||||
BaseFieldDataPersist importExportMapDataToPersist(BaseFieldDataImportExport xml);
|
BaseFieldDataPersist importExportMapDataToPersist(BaseFieldDataImportExport xml);
|
||||||
|
|
|
@ -12,7 +12,7 @@ public class FieldDataHelperServiceProvider {
|
||||||
private ApplicationContext applicationContext;
|
private ApplicationContext applicationContext;
|
||||||
|
|
||||||
public FieldDataHelperService get(FieldType type){
|
public FieldDataHelperService get(FieldType type){
|
||||||
BaseFieldDataHelperService<?, ?, ?, ? > item = null;
|
BaseFieldDataHelperService<?, ?, ?, ?, ? > item = null;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case INTERNAL_ENTRIES_DESCRIPTIONS:
|
case INTERNAL_ENTRIES_DESCRIPTIONS:
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package eu.eudat.service.fielddatahelper;
|
package eu.eudat.service.fielddatahelper;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.fielddata.BaseFieldDataModel;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.fielddata.LabelAndMultiplicityDataModel;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.LabelAndMultiplicityDataEntity;
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.LabelAndMultiplicityDataEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.LabelAndMultiplicityDataImportExport;
|
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.LabelAndMultiplicityDataImportExport;
|
||||||
|
import eu.eudat.model.builder.commonmodels.descriptiontemplate.fielddata.LabelAndMultiplicityDataCommonModelBuilder;
|
||||||
import eu.eudat.model.builder.descriptiontemplatedefinition.fielddata.LabelAndMultiplicityDataBuilder;
|
import eu.eudat.model.builder.descriptiontemplatedefinition.fielddata.LabelAndMultiplicityDataBuilder;
|
||||||
import eu.eudat.model.descriptiontemplatedefinition.fielddata.LabelAndMultiplicityData;
|
import eu.eudat.model.descriptiontemplatedefinition.fielddata.LabelAndMultiplicityData;
|
||||||
import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.LabelAndMultiplicityDataPersist;
|
import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.LabelAndMultiplicityDataPersist;
|
||||||
|
@ -16,7 +19,7 @@ import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class LabelAndMultiplicityFieldDataHelperService extends BaseFieldDataHelperService<LabelAndMultiplicityData, LabelAndMultiplicityDataPersist, LabelAndMultiplicityDataEntity, LabelAndMultiplicityDataImportExport> {
|
public class LabelAndMultiplicityFieldDataHelperService extends BaseFieldDataHelperService<LabelAndMultiplicityData, LabelAndMultiplicityDataPersist, LabelAndMultiplicityDataEntity, LabelAndMultiplicityDataImportExport, LabelAndMultiplicityDataModel> {
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
|
|
||||||
|
@ -46,6 +49,11 @@ public class LabelAndMultiplicityFieldDataHelperService extends BaseFieldDataHel
|
||||||
return new LabelAndMultiplicityDataImportExport();
|
return new LabelAndMultiplicityDataImportExport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected LabelAndMultiplicityDataModel newCommonModelInstanceInternal() {
|
||||||
|
return new LabelAndMultiplicityDataModel();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getDataClass() {
|
public Class<?> getDataClass() {
|
||||||
return LabelAndMultiplicityDataEntity.class;
|
return LabelAndMultiplicityDataEntity.class;
|
||||||
|
@ -64,6 +72,11 @@ public class LabelAndMultiplicityFieldDataHelperService extends BaseFieldDataHel
|
||||||
return LabelAndMultiplicityDataImportExport.class;
|
return LabelAndMultiplicityDataImportExport.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getCommonModelClass() {
|
||||||
|
return LabelAndMultiplicityDataModel.class;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Validator getPersistModelValidator() {
|
public Validator getPersistModelValidator() {
|
||||||
return this.validatorFactory.validator(LabelAndMultiplicityDataPersist.LabelAndMultiplicityDataPersistValidator.class);
|
return this.validatorFactory.validator(LabelAndMultiplicityDataPersist.LabelAndMultiplicityDataPersistValidator.class);
|
||||||
|
@ -74,6 +87,11 @@ public class LabelAndMultiplicityFieldDataHelperService extends BaseFieldDataHel
|
||||||
return this.builderFactory.builder(LabelAndMultiplicityDataBuilder.class).authorize(authorizationFlags).build(fieldSet, data);
|
return this.builderFactory.builder(LabelAndMultiplicityDataBuilder.class).authorize(authorizationFlags).build(fieldSet, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<LabelAndMultiplicityDataModel> buildCommonModelInternal(List<LabelAndMultiplicityDataEntity> data, EnumSet<AuthorizationFlags> authorizationFlags) {
|
||||||
|
return this.builderFactory.builder(LabelAndMultiplicityDataCommonModelBuilder.class).authorize(authorizationFlags).build(data);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected LabelAndMultiplicityDataEntity applyPersistInternal(LabelAndMultiplicityDataPersist persist, LabelAndMultiplicityDataEntity data) {
|
protected LabelAndMultiplicityDataEntity applyPersistInternal(LabelAndMultiplicityDataPersist persist, LabelAndMultiplicityDataEntity data) {
|
||||||
data.setMultipleSelect(persist.getMultipleSelect());
|
data.setMultipleSelect(persist.getMultipleSelect());
|
||||||
|
@ -96,4 +114,6 @@ public class LabelAndMultiplicityFieldDataHelperService extends BaseFieldDataHel
|
||||||
protected boolean isMultiValueInternal(LabelAndMultiplicityDataEntity data) {
|
protected boolean isMultiValueInternal(LabelAndMultiplicityDataEntity data) {
|
||||||
return data.getMultipleSelect();
|
return data.getMultipleSelect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
package eu.eudat.service.fielddatahelper;
|
package eu.eudat.service.fielddatahelper;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.fielddata.LabelAndMultiplicityDataModel;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.fielddata.LabelDataModel;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.LabelAndMultiplicityDataEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.LabelDataEntity;
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.LabelDataEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.LabelDataImportExport;
|
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.LabelDataImportExport;
|
||||||
|
import eu.eudat.model.builder.commonmodels.descriptiontemplate.fielddata.LabelAndMultiplicityDataCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.descriptiontemplate.fielddata.LabelDataCommonModelBuilder;
|
||||||
import eu.eudat.model.builder.descriptiontemplatedefinition.fielddata.LabelDataBuilder;
|
import eu.eudat.model.builder.descriptiontemplatedefinition.fielddata.LabelDataBuilder;
|
||||||
import eu.eudat.model.descriptiontemplatedefinition.fielddata.LabelData;
|
import eu.eudat.model.descriptiontemplatedefinition.fielddata.LabelData;
|
||||||
import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.LabelDataPersist;
|
import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.LabelDataPersist;
|
||||||
|
@ -16,7 +21,7 @@ import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class LabelFieldDataHelperService extends BaseFieldDataHelperService<LabelData, LabelDataPersist, LabelDataEntity, LabelDataImportExport> {
|
public class LabelFieldDataHelperService extends BaseFieldDataHelperService<LabelData, LabelDataPersist, LabelDataEntity, LabelDataImportExport, LabelDataModel> {
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
|
|
||||||
private final ValidatorFactory validatorFactory;
|
private final ValidatorFactory validatorFactory;
|
||||||
|
@ -46,6 +51,11 @@ public class LabelFieldDataHelperService extends BaseFieldDataHelperService<Labe
|
||||||
return new LabelDataImportExport();
|
return new LabelDataImportExport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected LabelDataModel newCommonModelInstanceInternal() {
|
||||||
|
return new LabelDataModel();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getDataClass() {
|
public Class<?> getDataClass() {
|
||||||
return LabelDataEntity.class;
|
return LabelDataEntity.class;
|
||||||
|
@ -64,6 +74,11 @@ public class LabelFieldDataHelperService extends BaseFieldDataHelperService<Labe
|
||||||
return LabelDataImportExport.class;
|
return LabelDataImportExport.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getCommonModelClass() {
|
||||||
|
return LabelDataModel.class;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Validator getPersistModelValidator() {
|
public Validator getPersistModelValidator() {
|
||||||
return this.validatorFactory.validator(LabelDataPersist.LabelPersistValidator.class);
|
return this.validatorFactory.validator(LabelDataPersist.LabelPersistValidator.class);
|
||||||
|
@ -74,6 +89,11 @@ public class LabelFieldDataHelperService extends BaseFieldDataHelperService<Labe
|
||||||
return this.builderFactory.builder(LabelDataBuilder.class).authorize(authorizationFlags).build(fieldSet, data);
|
return this.builderFactory.builder(LabelDataBuilder.class).authorize(authorizationFlags).build(fieldSet, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<LabelDataModel> buildCommonModelInternal(List<LabelDataEntity> data, EnumSet<AuthorizationFlags> authorizationFlags) {
|
||||||
|
return this.builderFactory.builder(LabelDataCommonModelBuilder.class).authorize(authorizationFlags).build(data);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected LabelDataEntity applyPersistInternal(LabelDataPersist persist, LabelDataEntity data) {
|
protected LabelDataEntity applyPersistInternal(LabelDataPersist persist, LabelDataEntity data) {
|
||||||
return data;
|
return data;
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
package eu.eudat.service.fielddatahelper;
|
package eu.eudat.service.fielddatahelper;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.fielddata.LabelAndMultiplicityDataModel;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.fielddata.RadioBoxDataModel;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.LabelAndMultiplicityDataEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.RadioBoxDataEntity;
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.RadioBoxDataEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.RadioBoxDataImportExport;
|
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.RadioBoxDataImportExport;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.commonmodels.descriptiontemplate.fielddata.LabelAndMultiplicityDataCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.descriptiontemplate.fielddata.RadioBoxDataCommonModelBuilder;
|
||||||
import eu.eudat.model.builder.descriptiontemplatedefinition.fielddata.RadioBoxDataBuilder;
|
import eu.eudat.model.builder.descriptiontemplatedefinition.fielddata.RadioBoxDataBuilder;
|
||||||
import eu.eudat.model.descriptiontemplatedefinition.fielddata.RadioBoxData;
|
import eu.eudat.model.descriptiontemplatedefinition.fielddata.RadioBoxData;
|
||||||
import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.*;
|
import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.*;
|
||||||
|
@ -19,7 +24,7 @@ import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class RadioBoxFieldDataHelperService extends BaseFieldDataHelperService<RadioBoxData, RadioBoxDataPersist, RadioBoxDataEntity, RadioBoxDataImportExport> {
|
public class RadioBoxFieldDataHelperService extends BaseFieldDataHelperService<RadioBoxData, RadioBoxDataPersist, RadioBoxDataEntity, RadioBoxDataImportExport, RadioBoxDataModel> {
|
||||||
|
|
||||||
private final ConventionService conventionService;
|
private final ConventionService conventionService;
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
|
@ -52,6 +57,11 @@ public class RadioBoxFieldDataHelperService extends BaseFieldDataHelperService<R
|
||||||
return new RadioBoxDataImportExport();
|
return new RadioBoxDataImportExport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected RadioBoxDataModel newCommonModelInstanceInternal() {
|
||||||
|
return new RadioBoxDataModel();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getDataClass() {
|
public Class<?> getDataClass() {
|
||||||
return RadioBoxDataEntity.class;
|
return RadioBoxDataEntity.class;
|
||||||
|
@ -70,6 +80,11 @@ public class RadioBoxFieldDataHelperService extends BaseFieldDataHelperService<R
|
||||||
return RadioBoxDataImportExport.class;
|
return RadioBoxDataImportExport.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getCommonModelClass() {
|
||||||
|
return RadioBoxDataModel.class;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Validator getPersistModelValidator() {
|
public Validator getPersistModelValidator() {
|
||||||
return this.validatorFactory.validator(RadioBoxDataPersist.RadioBoxDataPersistValidator.class);
|
return this.validatorFactory.validator(RadioBoxDataPersist.RadioBoxDataPersistValidator.class);
|
||||||
|
@ -80,6 +95,11 @@ public class RadioBoxFieldDataHelperService extends BaseFieldDataHelperService<R
|
||||||
return this.builderFactory.builder(RadioBoxDataBuilder.class).authorize(authorizationFlags).build(fieldSet, data);
|
return this.builderFactory.builder(RadioBoxDataBuilder.class).authorize(authorizationFlags).build(fieldSet, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<RadioBoxDataModel> buildCommonModelInternal(List<RadioBoxDataEntity> data, EnumSet<AuthorizationFlags> authorizationFlags) {
|
||||||
|
return this.builderFactory.builder(RadioBoxDataCommonModelBuilder.class).authorize(authorizationFlags).build(data);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected RadioBoxDataEntity applyPersistInternal(RadioBoxDataPersist persist, RadioBoxDataEntity data) {
|
protected RadioBoxDataEntity applyPersistInternal(RadioBoxDataPersist persist, RadioBoxDataEntity data) {
|
||||||
if (!this.conventionService.isListNullOrEmpty(persist.getOptions())){
|
if (!this.conventionService.isListNullOrEmpty(persist.getOptions())){
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package eu.eudat.service.fielddatahelper;
|
package eu.eudat.service.fielddatahelper;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.fielddata.ReferenceTypeDataModel;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.ReferenceTypeDataEntity;
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.ReferenceTypeDataEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.ReferenceTypeDataImportExport;
|
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.ReferenceTypeDataImportExport;
|
||||||
|
import eu.eudat.model.builder.commonmodels.descriptiontemplate.fielddata.ReferenceTypeDataCommonModelBuilder;
|
||||||
import eu.eudat.model.builder.descriptiontemplatedefinition.fielddata.ReferenceTypeDataBuilder;
|
import eu.eudat.model.builder.descriptiontemplatedefinition.fielddata.ReferenceTypeDataBuilder;
|
||||||
import eu.eudat.model.descriptiontemplatedefinition.fielddata.ReferenceTypeData;
|
import eu.eudat.model.descriptiontemplatedefinition.fielddata.ReferenceTypeData;
|
||||||
import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.ReferenceTypeDataPersist;
|
import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.ReferenceTypeDataPersist;
|
||||||
|
@ -16,7 +18,7 @@ import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class ReferenceTypeFieldDataHelperService extends BaseFieldDataHelperService<ReferenceTypeData, ReferenceTypeDataPersist, ReferenceTypeDataEntity, ReferenceTypeDataImportExport> {
|
public class ReferenceTypeFieldDataHelperService extends BaseFieldDataHelperService<ReferenceTypeData, ReferenceTypeDataPersist, ReferenceTypeDataEntity, ReferenceTypeDataImportExport, ReferenceTypeDataModel> {
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
|
|
||||||
|
@ -46,6 +48,11 @@ public class ReferenceTypeFieldDataHelperService extends BaseFieldDataHelperServ
|
||||||
return new ReferenceTypeDataImportExport();
|
return new ReferenceTypeDataImportExport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ReferenceTypeDataModel newCommonModelInstanceInternal() {
|
||||||
|
return new ReferenceTypeDataModel();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getDataClass() {
|
public Class<?> getDataClass() {
|
||||||
return ReferenceTypeDataEntity.class;
|
return ReferenceTypeDataEntity.class;
|
||||||
|
@ -64,6 +71,11 @@ public class ReferenceTypeFieldDataHelperService extends BaseFieldDataHelperServ
|
||||||
return ReferenceTypeDataImportExport.class;
|
return ReferenceTypeDataImportExport.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getCommonModelClass() {
|
||||||
|
return ReferenceTypeDataModel.class;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Validator getPersistModelValidator() {
|
public Validator getPersistModelValidator() {
|
||||||
return this.validatorFactory.validator(ReferenceTypeDataPersist.ReferenceTypeDataPersistValidator.class);
|
return this.validatorFactory.validator(ReferenceTypeDataPersist.ReferenceTypeDataPersistValidator.class);
|
||||||
|
@ -74,6 +86,11 @@ public class ReferenceTypeFieldDataHelperService extends BaseFieldDataHelperServ
|
||||||
return this.builderFactory.builder(ReferenceTypeDataBuilder.class).authorize(authorizationFlags).build(fieldSet, data);
|
return this.builderFactory.builder(ReferenceTypeDataBuilder.class).authorize(authorizationFlags).build(fieldSet, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<ReferenceTypeDataModel> buildCommonModelInternal(List<ReferenceTypeDataEntity> data, EnumSet<AuthorizationFlags> authorizationFlags) {
|
||||||
|
return this.builderFactory.builder(ReferenceTypeDataCommonModelBuilder.class).authorize(authorizationFlags).build(data);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ReferenceTypeDataEntity applyPersistInternal(ReferenceTypeDataPersist persist, ReferenceTypeDataEntity data) {
|
protected ReferenceTypeDataEntity applyPersistInternal(ReferenceTypeDataPersist persist, ReferenceTypeDataEntity data) {
|
||||||
data.setMultipleSelect(persist.getMultipleSelect());
|
data.setMultipleSelect(persist.getMultipleSelect());
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
package eu.eudat.service.fielddatahelper;
|
package eu.eudat.service.fielddatahelper;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.fielddata.LabelAndMultiplicityDataModel;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.fielddata.SelectDataModel;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.LabelAndMultiplicityDataEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.SelectDataEntity;
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.SelectDataEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.SelectDataImportExport;
|
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.SelectDataImportExport;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.commonmodels.descriptiontemplate.fielddata.LabelAndMultiplicityDataCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.descriptiontemplate.fielddata.SelectDataCommonModelBuilder;
|
||||||
import eu.eudat.model.builder.descriptiontemplatedefinition.fielddata.SelectDataBuilder;
|
import eu.eudat.model.builder.descriptiontemplatedefinition.fielddata.SelectDataBuilder;
|
||||||
import eu.eudat.model.descriptiontemplatedefinition.fielddata.SelectData;
|
import eu.eudat.model.descriptiontemplatedefinition.fielddata.SelectData;
|
||||||
import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.*;
|
import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.*;
|
||||||
|
@ -19,7 +24,7 @@ import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class SelectFieldDataHelperService extends BaseFieldDataHelperService<SelectData, SelectDataPersist, SelectDataEntity, SelectDataImportExport> {
|
public class SelectFieldDataHelperService extends BaseFieldDataHelperService<SelectData, SelectDataPersist, SelectDataEntity, SelectDataImportExport, SelectDataModel> {
|
||||||
|
|
||||||
private final ConventionService conventionService;
|
private final ConventionService conventionService;
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
|
@ -52,6 +57,11 @@ public class SelectFieldDataHelperService extends BaseFieldDataHelperService<Sel
|
||||||
return new SelectDataImportExport();
|
return new SelectDataImportExport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SelectDataModel newCommonModelInstanceInternal() {
|
||||||
|
return new SelectDataModel();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getDataClass() {
|
public Class<?> getDataClass() {
|
||||||
return SelectDataEntity.class;
|
return SelectDataEntity.class;
|
||||||
|
@ -65,6 +75,11 @@ public class SelectFieldDataHelperService extends BaseFieldDataHelperService<Sel
|
||||||
return SelectDataPersist.class;
|
return SelectDataPersist.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getCommonModelClass() {
|
||||||
|
return SelectDataModel.class;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getImportExportClass() {
|
public Class<?> getImportExportClass() {
|
||||||
return SelectDataImportExport.class;
|
return SelectDataImportExport.class;
|
||||||
|
@ -80,6 +95,11 @@ public class SelectFieldDataHelperService extends BaseFieldDataHelperService<Sel
|
||||||
return this.builderFactory.builder(SelectDataBuilder.class).authorize(authorizationFlags).build(fieldSet, data);
|
return this.builderFactory.builder(SelectDataBuilder.class).authorize(authorizationFlags).build(fieldSet, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<SelectDataModel> buildCommonModelInternal(List<SelectDataEntity> data, EnumSet<AuthorizationFlags> authorizationFlags) {
|
||||||
|
return this.builderFactory.builder(SelectDataCommonModelBuilder.class).authorize(authorizationFlags).build(data);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SelectDataEntity applyPersistInternal(SelectDataPersist persist, SelectDataEntity data) {
|
protected SelectDataEntity applyPersistInternal(SelectDataPersist persist, SelectDataEntity data) {
|
||||||
data.setMultipleSelect(persist.getMultipleSelect());
|
data.setMultipleSelect(persist.getMultipleSelect());
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
package eu.eudat.service.fielddatahelper;
|
package eu.eudat.service.fielddatahelper;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.fielddata.LabelAndMultiplicityDataModel;
|
||||||
|
import eu.eudat.commonmodels.models.descriptiotemplate.fielddata.SelectDataModel;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.LabelAndMultiplicityDataEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.UploadDataEntity;
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.UploadDataEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.UploadDataImportExport;
|
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.UploadDataImportExport;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.commonmodels.descriptiontemplate.fielddata.LabelAndMultiplicityDataCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.descriptiontemplate.fielddata.UploadDataCommonModelBuilder;
|
||||||
import eu.eudat.model.builder.descriptiontemplatedefinition.fielddata.UploadDataBuilder;
|
import eu.eudat.model.builder.descriptiontemplatedefinition.fielddata.UploadDataBuilder;
|
||||||
import eu.eudat.model.descriptiontemplatedefinition.fielddata.UploadData;
|
import eu.eudat.model.descriptiontemplatedefinition.fielddata.UploadData;
|
||||||
import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.*;
|
import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.*;
|
||||||
|
@ -19,7 +24,7 @@ import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class UploadFieldDataHelperService extends BaseFieldDataHelperService<UploadData, UploadDataPersist, UploadDataEntity, UploadDataImportExport> {
|
public class UploadFieldDataHelperService extends BaseFieldDataHelperService<UploadData, UploadDataPersist, UploadDataEntity, UploadDataImportExport, SelectDataModel> {
|
||||||
|
|
||||||
private final ConventionService conventionService;
|
private final ConventionService conventionService;
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
|
@ -52,6 +57,11 @@ public class UploadFieldDataHelperService extends BaseFieldDataHelperService<Upl
|
||||||
return new UploadDataImportExport();
|
return new UploadDataImportExport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SelectDataModel newCommonModelInstanceInternal() {
|
||||||
|
return new SelectDataModel();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getDataClass() {
|
public Class<?> getDataClass() {
|
||||||
return UploadDataEntity.class;
|
return UploadDataEntity.class;
|
||||||
|
@ -70,6 +80,11 @@ public class UploadFieldDataHelperService extends BaseFieldDataHelperService<Upl
|
||||||
return UploadDataImportExport.class;
|
return UploadDataImportExport.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getCommonModelClass() {
|
||||||
|
return SelectDataModel.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Validator getPersistModelValidator() {
|
public Validator getPersistModelValidator() {
|
||||||
|
@ -81,6 +96,11 @@ public class UploadFieldDataHelperService extends BaseFieldDataHelperService<Upl
|
||||||
return this.builderFactory.builder(UploadDataBuilder.class).authorize(authorizationFlags).build(fieldSet, data);
|
return this.builderFactory.builder(UploadDataBuilder.class).authorize(authorizationFlags).build(fieldSet, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<SelectDataModel> buildCommonModelInternal(List<UploadDataEntity> data, EnumSet<AuthorizationFlags> authorizationFlags) {
|
||||||
|
return this.builderFactory.builder(UploadDataCommonModelBuilder.class).authorize(authorizationFlags).build(data);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected UploadDataEntity applyPersistInternal(UploadDataPersist persist, UploadDataEntity data) {
|
protected UploadDataEntity applyPersistInternal(UploadDataPersist persist, UploadDataEntity data) {
|
||||||
if (!this.conventionService.isListNullOrEmpty(persist.getTypes())){
|
if (!this.conventionService.isListNullOrEmpty(persist.getTypes())){
|
||||||
|
|
|
@ -12,8 +12,6 @@ import eu.eudat.file.transformer.models.description.DescriptionFileTransformerMo
|
||||||
import eu.eudat.file.transformer.models.dmp.DmpFileTransformerModel;
|
import eu.eudat.file.transformer.models.dmp.DmpFileTransformerModel;
|
||||||
import eu.eudat.file.transformer.models.misc.FileEnvelope;
|
import eu.eudat.file.transformer.models.misc.FileEnvelope;
|
||||||
import eu.eudat.file.transformer.models.misc.FileFormat;
|
import eu.eudat.file.transformer.models.misc.FileFormat;
|
||||||
import eu.eudat.model.builder.filetransformer.DescriptionFileTransformerBuilder;
|
|
||||||
import eu.eudat.model.builder.filetransformer.DmpFileTransformerBuilder;
|
|
||||||
import eu.eudat.model.file.TransformerCacheModel;
|
import eu.eudat.model.file.TransformerCacheModel;
|
||||||
import eu.eudat.query.DescriptionQuery;
|
import eu.eudat.query.DescriptionQuery;
|
||||||
import eu.eudat.query.DmpQuery;
|
import eu.eudat.query.DmpQuery;
|
||||||
|
@ -134,9 +132,9 @@ public class FileTransformerService {
|
||||||
TransformerRepository repository = getRepository(format);
|
TransformerRepository repository = getRepository(format);
|
||||||
//GK: Second get the Target Data Management Plan
|
//GK: Second get the Target Data Management Plan
|
||||||
DmpQuery query = this.queryFactory.query(DmpQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(dmpId);
|
DmpQuery query = this.queryFactory.query(DmpQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(dmpId);
|
||||||
DmpFileTransformerModel dmpFileTransformerModel = this.builderFactory.builder(DmpFileTransformerBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(query.first());
|
// DmpFileTransformerModel dmpFileTransformerModel = this.builderFactory.builder(DmpFileTransformerBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(query.first());
|
||||||
dmpFileTransformerModel.setVariant(format);
|
// dmpFileTransformerModel.setVariant(format);
|
||||||
FileEnvelope fileEnvelope = repository.exportDmp(dmpFileTransformerModel);
|
FileEnvelope fileEnvelope = repository.exportDmp(null); //TODO
|
||||||
eu.eudat.model.file.FileEnvelope result = new eu.eudat.model.file.FileEnvelope();
|
eu.eudat.model.file.FileEnvelope result = new eu.eudat.model.file.FileEnvelope();
|
||||||
byte[] data = storageFileService.readByFileRefAsBytesSafe(fileEnvelope.getFile(), StorageType.Transformer);
|
byte[] data = storageFileService.readByFileRefAsBytesSafe(fileEnvelope.getFile(), StorageType.Transformer);
|
||||||
result.setFile(data);
|
result.setFile(data);
|
||||||
|
@ -152,9 +150,9 @@ public class FileTransformerService {
|
||||||
TransformerRepository repository = getRepository(format);
|
TransformerRepository repository = getRepository(format);
|
||||||
//GK: Second get the Target Data Management Plan
|
//GK: Second get the Target Data Management Plan
|
||||||
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(descriptionId);
|
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(descriptionId);
|
||||||
DescriptionFileTransformerModel descriptionFileTransformerModel = this.builderFactory.builder(DescriptionFileTransformerBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(query.first());
|
// DescriptionFileTransformerModel descriptionFileTransformerModel = this.builderFactory.builder(DescriptionFileTransformerBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(query.first());
|
||||||
descriptionFileTransformerModel.setCreatedBy(descriptionFileTransformerModel.getDmp().getCreator());
|
// descriptionFileTransformerModel.setCreatedBy(descriptionFileTransformerModel.getDmp().getCreator());
|
||||||
FileEnvelope fileEnvelope = repository.exportDescription(descriptionFileTransformerModel, format);
|
FileEnvelope fileEnvelope = repository.exportDescription(null, format); //TODO
|
||||||
eu.eudat.model.file.FileEnvelope result = new eu.eudat.model.file.FileEnvelope();
|
eu.eudat.model.file.FileEnvelope result = new eu.eudat.model.file.FileEnvelope();
|
||||||
byte[] data = this.storageFileService.readByFileRefAsBytesSafe(fileEnvelope.getFile(), StorageType.Transformer);
|
byte[] data = this.storageFileService.readByFileRefAsBytesSafe(fileEnvelope.getFile(), StorageType.Transformer);
|
||||||
result.setFile(data);
|
result.setFile(data);
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>gr.cite.opendmp</groupId>
|
<groupId>gr.cite.opendmp</groupId>
|
||||||
<artifactId>repositorydepositbase</artifactId>
|
<artifactId>repositorydepositbase</artifactId>
|
||||||
<version>2.0.0</version>
|
<version>2.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue