prefilling source changes
This commit is contained in:
parent
0530373c83
commit
4ebabd68ab
|
@ -145,8 +145,7 @@ public class AuditableAction {
|
||||||
public static final EventId PrefillingSource_Lookup = new EventId(260001, "PrefillingSource_Lookup");
|
public static final EventId PrefillingSource_Lookup = new EventId(260001, "PrefillingSource_Lookup");
|
||||||
public static final EventId PrefillingSource_Persist = new EventId(260002, "PrefillingSource_Persist");
|
public static final EventId PrefillingSource_Persist = new EventId(260002, "PrefillingSource_Persist");
|
||||||
public static final EventId PrefillingSource_Delete = new EventId(260003, "PrefillingSource_Delete");
|
public static final EventId PrefillingSource_Delete = new EventId(260003, "PrefillingSource_Delete");
|
||||||
public static final EventId PrefillingSource_Generate = new EventId(260005, "PrefillingSource_Generate");
|
public static final EventId PrefillingSource_Generate = new EventId(260004, "PrefillingSource_Generate");
|
||||||
public static final EventId PrefillingSource_GenerateWithData = new EventId(260006, "PrefillingSource_GenerateWithData");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
package eu.eudat.commons.types.prefillingsource;
|
|
||||||
|
|
||||||
import eu.eudat.commons.JsonHandlingService;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class PrefillingEntity {
|
|
||||||
private String pid;
|
|
||||||
private String name;
|
|
||||||
private Map<String, Object> data;
|
|
||||||
private String key;
|
|
||||||
private String tag;
|
|
||||||
|
|
||||||
public String getPid() {
|
|
||||||
return pid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPid(String pid) {
|
|
||||||
this.pid = pid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Object> getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setData(Map<String, Object> data) {
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKey() {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKey(String key) {
|
|
||||||
this.key = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTag() {
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTag(String tag) {
|
|
||||||
this.tag = tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PrefillingEntity build(Map<String, String> fetchedData, JsonHandlingService jsonHandlingService){
|
|
||||||
PrefillingEntity m = new PrefillingEntity();
|
|
||||||
|
|
||||||
m.setPid(fetchedData.getOrDefault("pid", null));
|
|
||||||
m.setName(fetchedData.getOrDefault("name", null));
|
|
||||||
m.setKey(fetchedData.getOrDefault("key", null));
|
|
||||||
m.setTag(fetchedData.getOrDefault("tag", null));
|
|
||||||
m.setData(jsonHandlingService.fromJsonSafe(Map.class,fetchedData.getOrDefault("data", null)));
|
|
||||||
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,10 +4,12 @@ import java.util.Map;
|
||||||
|
|
||||||
public class Prefilling {
|
public class Prefilling {
|
||||||
|
|
||||||
private String pid;
|
private String id;
|
||||||
public static final String _pid = "pid";
|
public static final String _id = "reference_id";
|
||||||
private String name;
|
|
||||||
public static final String _name = "name";
|
private String label;
|
||||||
|
public static final String _label = "label";
|
||||||
|
|
||||||
private Map<String, Object> data;
|
private Map<String, Object> data;
|
||||||
public static final String _data = "data";
|
public static final String _data = "data";
|
||||||
private String key;
|
private String key;
|
||||||
|
@ -15,20 +17,20 @@ public class Prefilling {
|
||||||
private String tag;
|
private String tag;
|
||||||
public static final String _tag = "tag";
|
public static final String _tag = "tag";
|
||||||
|
|
||||||
public String getPid() {
|
public String getId() {
|
||||||
return pid;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPid(String pid) {
|
public void setId(String id) {
|
||||||
this.pid = pid;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getLabel() {
|
||||||
return name;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setLabel(String label) {
|
||||||
this.name = name;
|
this.label = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> getData() {
|
public Map<String, Object> getData() {
|
||||||
|
|
|
@ -1,92 +0,0 @@
|
||||||
package eu.eudat.model.builder;
|
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
|
||||||
import eu.eudat.commons.types.prefillingsource.PrefillingEntity;
|
|
||||||
import eu.eudat.convention.ConventionService;
|
|
||||||
import eu.eudat.data.UserEntity;
|
|
||||||
import eu.eudat.model.Prefilling;
|
|
||||||
import eu.eudat.model.User;
|
|
||||||
import eu.eudat.model.UserContactInfo;
|
|
||||||
import eu.eudat.query.UserContactInfoQuery;
|
|
||||||
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 PrefillingBuilder extends BaseBuilder<Prefilling, PrefillingEntity> {
|
|
||||||
|
|
||||||
private final QueryFactory queryFactory;
|
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
|
||||||
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public PrefillingBuilder(ConventionService conventionService,
|
|
||||||
QueryFactory queryFactory,
|
|
||||||
BuilderFactory builderFactory) {
|
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(PrefillingBuilder.class)));
|
|
||||||
this.queryFactory = queryFactory;
|
|
||||||
this.builderFactory = builderFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PrefillingBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
|
||||||
this.authorize = values;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Prefilling> build(FieldSet fields, List<PrefillingEntity> data) throws MyApplicationException {
|
|
||||||
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
|
|
||||||
this.logger.trace(new DataLogEntry("requested fields", fields));
|
|
||||||
if (fields == null || data == null || fields.isEmpty())
|
|
||||||
return new ArrayList<>();
|
|
||||||
|
|
||||||
List<Prefilling> models = new ArrayList<>();
|
|
||||||
|
|
||||||
for (PrefillingEntity d : data) {
|
|
||||||
Prefilling m = new Prefilling();
|
|
||||||
if (fields.hasField(this.asIndexer(Prefilling._pid))) m.setPid(d.getPid());
|
|
||||||
if (fields.hasField(this.asIndexer(Prefilling._name))) m.setName(d.getName());
|
|
||||||
if (fields.hasField(this.asIndexer(Prefilling._key))) m.setKey(d.getKey());
|
|
||||||
if (fields.hasField(this.asIndexer(Prefilling._tag))) m.setTag(d.getTag());
|
|
||||||
if (fields.hasField(this.asIndexer(Prefilling._data))) m.setData(d.getData());
|
|
||||||
models.add(m);
|
|
||||||
}
|
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
|
||||||
|
|
||||||
return models;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<UUID, List<UserContactInfo>> collectUserContactInfos(FieldSet fields, List<UserEntity> data) throws MyApplicationException {
|
|
||||||
if (fields.isEmpty() || data.isEmpty()) return null;
|
|
||||||
this.logger.debug("checking related - {}", UserContactInfo.class.getSimpleName());
|
|
||||||
|
|
||||||
Map<UUID, List<UserContactInfo>> itemMap;
|
|
||||||
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(UserContactInfo._user, User._id));
|
|
||||||
UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).authorize(this.authorize).userIds(data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList()));
|
|
||||||
itemMap = this.builderFactory.builder(UserContactInfoBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getUser().getId());
|
|
||||||
|
|
||||||
if (!fields.hasField(this.asIndexer(UserContactInfo._user, User._id))) {
|
|
||||||
itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getUser() != null).peek(x -> {
|
|
||||||
x.getUser().setId(null);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return itemMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -13,10 +13,17 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DescriptionProfilingRequest {
|
public class DescriptionProfilingRequest {
|
||||||
|
|
||||||
|
private Map<String, String> data;
|
||||||
|
public static final String _data = "data";
|
||||||
|
|
||||||
|
private String prefillId;
|
||||||
|
public static final String _prefillId = "prefillId";
|
||||||
|
|
||||||
private UUID prefillingSourceId;
|
private UUID prefillingSourceId;
|
||||||
|
|
||||||
public static final String _prefillingSourceId = "prefillingSourceId";
|
public static final String _prefillingSourceId = "prefillingSourceId";
|
||||||
|
@ -28,6 +35,21 @@ public class DescriptionProfilingRequest {
|
||||||
private BaseFieldSet project;
|
private BaseFieldSet project;
|
||||||
public static final String _project = "project";
|
public static final String _project = "project";
|
||||||
|
|
||||||
|
public Map<String, String> getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(Map<String, String> data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrefillId() {
|
||||||
|
return prefillId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrefillId(String prefillId) {
|
||||||
|
this.prefillId = prefillId;
|
||||||
|
}
|
||||||
|
|
||||||
public UUID getPrefillingSourceId() {
|
public UUID getPrefillingSourceId() {
|
||||||
return prefillingSourceId;
|
return prefillingSourceId;
|
||||||
|
@ -80,10 +102,16 @@ public class DescriptionProfilingRequest {
|
||||||
.failOn(DescriptionProfilingRequest._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._descriptionTemplateId}, LocaleContextHolder.getLocale())),
|
.failOn(DescriptionProfilingRequest._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._descriptionTemplateId}, LocaleContextHolder.getLocale())),
|
||||||
this.spec()
|
this.spec()
|
||||||
.must(() -> this.isValidGuid(item.getPrefillingSourceId()))
|
.must(() -> this.isValidGuid(item.getPrefillingSourceId()))
|
||||||
.failOn(DescriptionProfilingRequest._prefillingSourceId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._prefillingSourceId}, LocaleContextHolder.getLocale()))
|
.failOn(DescriptionProfilingRequest._prefillingSourceId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._prefillingSourceId}, LocaleContextHolder.getLocale())),
|
||||||
// this.spec() TODO
|
this.spec()
|
||||||
|
.must(() -> !this.isEmpty(item.getPrefillId()))
|
||||||
|
.failOn(DescriptionProfilingRequest._prefillId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._prefillId}, LocaleContextHolder.getLocale()))
|
||||||
|
// this.spec()
|
||||||
|
// .must(() -> item.getData() != null)
|
||||||
|
// .failOn(DescriptionProfilingWithDataRequest._data).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._data}, LocaleContextHolder.getLocale()))
|
||||||
|
// this.spec()
|
||||||
// .must(() -> item.getProject() != null)
|
// .must(() -> item.getProject() != null)
|
||||||
// .failOn(DescriptionProfilingRequest._project).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._project}, LocaleContextHolder.getLocale()))
|
// .failOn(DescriptionProfilingWithDataRequest._project).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._project}, LocaleContextHolder.getLocale()))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,106 +0,0 @@
|
||||||
package eu.eudat.model.persist;
|
|
||||||
|
|
||||||
import eu.eudat.commons.validation.BaseValidator;
|
|
||||||
import gr.cite.tools.validation.specification.Specification;
|
|
||||||
import eu.eudat.convention.ConventionService;
|
|
||||||
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
|
||||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
|
||||||
import org.springframework.context.MessageSource;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class DescriptionProfilingWithDataRequest {
|
|
||||||
|
|
||||||
private Map<String, Object> data;
|
|
||||||
public static final String _data = "data";
|
|
||||||
|
|
||||||
private UUID prefillingSourceId;
|
|
||||||
|
|
||||||
public static final String _prefillingSourceId = "prefillingSourceId";
|
|
||||||
|
|
||||||
private UUID descriptionTemplateId;
|
|
||||||
|
|
||||||
public static final String _descriptionTemplateId = "descriptionTemplateId";
|
|
||||||
|
|
||||||
private BaseFieldSet project;
|
|
||||||
public static final String _project = "project";
|
|
||||||
|
|
||||||
public Map<String, Object> getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setData(Map<String, Object> data) {
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getPrefillingSourceId() {
|
|
||||||
return prefillingSourceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPrefillingSourceId(UUID prefillingSourceId) {
|
|
||||||
this.prefillingSourceId = prefillingSourceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getDescriptionTemplateId() {
|
|
||||||
return descriptionTemplateId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescriptionTemplateId(UUID descriptionTemplateId) {
|
|
||||||
this.descriptionTemplateId = descriptionTemplateId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BaseFieldSet getProject() {
|
|
||||||
return project;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProject(BaseFieldSet project) {
|
|
||||||
this.project = project;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Component(DescriptionProfilingWithDataRequestValidator.ValidatorName)
|
|
||||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
|
||||||
public static class DescriptionProfilingWithDataRequestValidator extends BaseValidator<DescriptionProfilingWithDataRequest> {
|
|
||||||
|
|
||||||
public static final String ValidatorName = "DescriptionProfilingWithDataRequestValidator";
|
|
||||||
|
|
||||||
private final MessageSource messageSource;
|
|
||||||
|
|
||||||
|
|
||||||
protected DescriptionProfilingWithDataRequestValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
|
|
||||||
super(conventionService, errors);
|
|
||||||
this.messageSource = messageSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Class<DescriptionProfilingWithDataRequest> modelClass() {
|
|
||||||
return DescriptionProfilingWithDataRequest.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<Specification> specifications(DescriptionProfilingWithDataRequest item) {
|
|
||||||
return Arrays.asList(
|
|
||||||
this.spec()
|
|
||||||
.must(() -> this.isValidGuid(item.getDescriptionTemplateId()))
|
|
||||||
.failOn(DescriptionProfilingWithDataRequest._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._descriptionTemplateId}, LocaleContextHolder.getLocale())),
|
|
||||||
this.spec()
|
|
||||||
.must(() -> this.isValidGuid(item.getPrefillingSourceId()))
|
|
||||||
.failOn(DescriptionProfilingWithDataRequest._prefillingSourceId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._prefillingSourceId}, LocaleContextHolder.getLocale()))
|
|
||||||
// this.spec() TODO
|
|
||||||
// .must(() -> item.getData() != null)
|
|
||||||
// .failOn(DescriptionProfilingWithDataRequest._data).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._data}, LocaleContextHolder.getLocale()))
|
|
||||||
// this.spec()
|
|
||||||
// .must(() -> item.getProject() != null)
|
|
||||||
// .failOn(DescriptionProfilingWithDataRequest._project).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._project}, LocaleContextHolder.getLocale()))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
package eu.eudat.model.persist;
|
||||||
|
|
||||||
|
import eu.eudat.commons.validation.BaseValidator;
|
||||||
|
import gr.cite.tools.validation.specification.Specification;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
||||||
|
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.MessageSource;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class PrefillingSearchRequest {
|
||||||
|
|
||||||
|
private String like;
|
||||||
|
public static final String _like = "like";
|
||||||
|
|
||||||
|
private UUID prefillingSourceId;
|
||||||
|
|
||||||
|
public static final String _prefillingSourceId = "prefillingSourceId";
|
||||||
|
|
||||||
|
public String getLike() {
|
||||||
|
return like;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLike(String like) {
|
||||||
|
this.like = like;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getPrefillingSourceId() {
|
||||||
|
return prefillingSourceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrefillingSourceId(UUID prefillingSourceId) {
|
||||||
|
this.prefillingSourceId = prefillingSourceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component(PrefillingSearchRequestValidator.ValidatorName)
|
||||||
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public static class PrefillingSearchRequestValidator extends BaseValidator<PrefillingSearchRequest> {
|
||||||
|
|
||||||
|
public static final String ValidatorName = "PrefillingSearchRequestValidator";
|
||||||
|
|
||||||
|
private final MessageSource messageSource;
|
||||||
|
|
||||||
|
|
||||||
|
protected PrefillingSearchRequestValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
|
||||||
|
super(conventionService, errors);
|
||||||
|
this.messageSource = messageSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<PrefillingSearchRequest> modelClass() {
|
||||||
|
return PrefillingSearchRequest.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Specification> specifications(PrefillingSearchRequest item) {
|
||||||
|
return Arrays.asList(
|
||||||
|
this.spec()
|
||||||
|
.must(() -> this.isValidGuid(item.getPrefillingSourceId()))
|
||||||
|
.failOn(PrefillingSearchRequest._prefillingSourceId).failWith(messageSource.getMessage("Validation_Required", new Object[]{PrefillingSearchRequest._prefillingSourceId}, LocaleContextHolder.getLocale()))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -271,15 +271,19 @@ public class ExternalFetcherServiceImpl implements ExternalFetcherService {
|
||||||
private ExternalDataResult jsonToExternalDataResult(DocumentContext jsonContext, ResultsConfiguration<ResultFieldsMappingConfiguration> resultsConfigurationEntity) {
|
private ExternalDataResult jsonToExternalDataResult(DocumentContext jsonContext, ResultsConfiguration<ResultFieldsMappingConfiguration> resultsConfigurationEntity) {
|
||||||
ExternalDataResult result = new ExternalDataResult();
|
ExternalDataResult result = new ExternalDataResult();
|
||||||
if (this.conventionService.isNullOrEmpty(resultsConfigurationEntity.getResultsArrayPath())) return new ExternalDataResult();
|
if (this.conventionService.isNullOrEmpty(resultsConfigurationEntity.getResultsArrayPath())) return new ExternalDataResult();
|
||||||
List<Map<String, Object>> rawData = jsonContext.read(resultsConfigurationEntity.getResultsArrayPath());
|
Object jsonData = jsonContext.read(resultsConfigurationEntity.getResultsArrayPath());
|
||||||
|
List<Map<String, Object>> rawData = new ArrayList<>();
|
||||||
|
if (jsonData instanceof List) {
|
||||||
|
rawData = (List<Map<String, Object>>) jsonData;
|
||||||
|
}else{
|
||||||
|
rawData.add((Map<String, Object>)jsonData);
|
||||||
|
}
|
||||||
result.setRawData(rawData);
|
result.setRawData(rawData);
|
||||||
|
|
||||||
if (this.conventionService.isListNullOrEmpty(rawData) || this.conventionService.isListNullOrEmpty(resultsConfigurationEntity.getFieldsMapping())) return new ExternalDataResult();
|
if (this.conventionService.isListNullOrEmpty(rawData) || this.conventionService.isListNullOrEmpty(resultsConfigurationEntity.getFieldsMapping())) return new ExternalDataResult();
|
||||||
|
|
||||||
List<Object> results = jsonContext.read(resultsConfigurationEntity.getResultsArrayPath());
|
|
||||||
|
|
||||||
List<Map<String, String>> parsedData = new ArrayList<>();
|
List<Map<String, String>> parsedData = new ArrayList<>();
|
||||||
for(Object resultItem : results){
|
for(Object resultItem : result.getRawData()){
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
boolean isValid = true;
|
boolean isValid = true;
|
||||||
for(ResultFieldsMappingConfiguration field : resultsConfigurationEntity.getFieldsMapping()) {
|
for(ResultFieldsMappingConfiguration field : resultsConfigurationEntity.getFieldsMapping()) {
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package eu.eudat.service.prefillingsource;
|
package eu.eudat.service.prefillingsource;
|
||||||
|
|
||||||
import eu.eudat.model.Description;
|
import eu.eudat.model.Description;
|
||||||
|
import eu.eudat.model.Prefilling;
|
||||||
import eu.eudat.model.PrefillingSource;
|
import eu.eudat.model.PrefillingSource;
|
||||||
|
import eu.eudat.model.persist.PrefillingSearchRequest;
|
||||||
import eu.eudat.model.persist.DescriptionProfilingRequest;
|
import eu.eudat.model.persist.DescriptionProfilingRequest;
|
||||||
import eu.eudat.model.persist.DescriptionProfilingWithDataRequest;
|
|
||||||
import eu.eudat.model.persist.PrefillingSourcePersist;
|
import eu.eudat.model.persist.PrefillingSourcePersist;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.exception.MyForbiddenException;
|
import gr.cite.tools.exception.MyForbiddenException;
|
||||||
|
@ -16,6 +17,7 @@ import org.xml.sax.SAXException;
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface PrefillingSourceService {
|
public interface PrefillingSourceService {
|
||||||
|
@ -24,8 +26,8 @@ public interface PrefillingSourceService {
|
||||||
|
|
||||||
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
|
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
|
||||||
|
|
||||||
Description getPrefilledDescription(DescriptionProfilingRequest model) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
List<Prefilling> searchPrefillings(PrefillingSearchRequest model);
|
||||||
|
|
||||||
Description getPrefilledDescriptionUsingData(DescriptionProfilingWithDataRequest model) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
Description getPrefilledDescription(DescriptionProfilingRequest model, FieldSet fields) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,8 @@ import eu.eudat.model.builder.DescriptionTemplateBuilder;
|
||||||
import eu.eudat.model.builder.PrefillingSourceBuilder;
|
import eu.eudat.model.builder.PrefillingSourceBuilder;
|
||||||
import eu.eudat.model.deleter.PrefillingSourceDeleter;
|
import eu.eudat.model.deleter.PrefillingSourceDeleter;
|
||||||
import eu.eudat.model.descriptionproperties.*;
|
import eu.eudat.model.descriptionproperties.*;
|
||||||
|
import eu.eudat.model.persist.PrefillingSearchRequest;
|
||||||
import eu.eudat.model.persist.DescriptionProfilingRequest;
|
import eu.eudat.model.persist.DescriptionProfilingRequest;
|
||||||
import eu.eudat.model.persist.DescriptionProfilingWithDataRequest;
|
|
||||||
import eu.eudat.model.persist.PrefillingSourcePersist;
|
import eu.eudat.model.persist.PrefillingSourcePersist;
|
||||||
import eu.eudat.model.persist.externalfetcher.*;
|
import eu.eudat.model.persist.externalfetcher.*;
|
||||||
import eu.eudat.model.persist.prefillingsourcedefinition.PrefillingSourceDefinitionFieldPersist;
|
import eu.eudat.model.persist.prefillingsourcedefinition.PrefillingSourceDefinitionFieldPersist;
|
||||||
|
@ -309,19 +309,38 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
|
||||||
this.deleterFactory.deleter(PrefillingSourceDeleter.class).deleteAndSaveByIds(List.of(id));
|
this.deleterFactory.deleter(PrefillingSourceDeleter.class).deleteAndSaveByIds(List.of(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Description getPrefilledDescription(DescriptionProfilingRequest model) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
|
public List<Prefilling> searchPrefillings(PrefillingSearchRequest model) {
|
||||||
PrefillingSourceEntity prefillingSourceEntity = this.queryFactory.query(PrefillingSourceQuery.class).ids(model.getPrefillingSourceId()).isActive(IsActive.Active).first();
|
PrefillingSourceEntity prefillingSourceEntity = this.queryFactory.query(PrefillingSourceQuery.class).ids(model.getPrefillingSourceId()).isActive(IsActive.Active).first();
|
||||||
if (prefillingSourceEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (prefillingSourceEntity == null)
|
||||||
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
DescriptionProfilingWithDataRequest descriptionProfilingWithDataRequest = new DescriptionProfilingWithDataRequest();
|
PrefillingSourceDefinitionEntity prefillingSourceDefinition = this.xmlHandlingService.fromXmlSafe(PrefillingSourceDefinitionEntity.class, prefillingSourceEntity.getDefinition());
|
||||||
descriptionProfilingWithDataRequest.setPrefillingSourceId(model.getPrefillingSourceId());
|
if (prefillingSourceDefinition == null)
|
||||||
descriptionProfilingWithDataRequest.setProject(model.getProject());
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSourceDefinition.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
descriptionProfilingWithDataRequest.setDescriptionTemplateId(model.getDescriptionTemplateId());
|
|
||||||
validatorFactory.validator(DescriptionProfilingWithDataRequest.DescriptionProfilingWithDataRequestValidator.ValidatorName).validateForce(descriptionProfilingWithDataRequest);
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria();
|
||||||
return this.getPrefilledDescriptionUsingData(descriptionProfilingWithDataRequest);
|
externalReferenceCriteria.setLike(model.getLike());
|
||||||
|
|
||||||
|
ExternalDataResult externalData = this.externalFetcherService.getExternalData(Stream.of(prefillingSourceDefinition.getSearchConfiguration()).collect(Collectors.toList()), externalReferenceCriteria, null);
|
||||||
|
if (externalData == null || this.conventionService.isListNullOrEmpty(externalData.getResults())) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Description getPrefilledDescriptionUsingData(DescriptionProfilingWithDataRequest model) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
|
List<Prefilling> prefillings = new ArrayList<>();
|
||||||
|
for (Map<String, String> result : externalData.getResults()) {
|
||||||
|
Prefilling prefilling = new Prefilling();
|
||||||
|
prefilling.setId(result.getOrDefault(Prefilling._id, null));
|
||||||
|
prefilling.setLabel(result.getOrDefault(Prefilling._label, null));
|
||||||
|
prefilling.setKey(result.getOrDefault(Prefilling._key, null));
|
||||||
|
prefilling.setTag(result.getOrDefault(Prefilling._tag, null));
|
||||||
|
|
||||||
|
prefillings.add(prefilling);
|
||||||
|
}
|
||||||
|
|
||||||
|
return prefillings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Description getPrefilledDescription(DescriptionProfilingRequest model, FieldSet fieldSet) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
|
||||||
|
|
||||||
PrefillingSourceEntity prefillingSourceEntity = this.queryFactory.query(PrefillingSourceQuery.class).ids(model.getPrefillingSourceId()).first();
|
PrefillingSourceEntity prefillingSourceEntity = this.queryFactory.query(PrefillingSourceQuery.class).ids(model.getPrefillingSourceId()).first();
|
||||||
if (prefillingSourceEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (prefillingSourceEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
@ -329,7 +348,10 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
|
||||||
PrefillingSourceDefinitionEntity prefillingSourceDefinition = this.xmlHandlingService.fromXmlSafe(PrefillingSourceDefinitionEntity.class, prefillingSourceEntity.getDefinition());
|
PrefillingSourceDefinitionEntity prefillingSourceDefinition = this.xmlHandlingService.fromXmlSafe(PrefillingSourceDefinitionEntity.class, prefillingSourceEntity.getDefinition());
|
||||||
if (prefillingSourceDefinition == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSourceDefinition.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (prefillingSourceDefinition == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSourceDefinition.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
ExternalDataResult externalData = this.externalFetcherService.getExternalData(Stream.of(prefillingSourceDefinition.getGetConfiguration()).collect(Collectors.toList()), new ExternalReferenceCriteria(), null);
|
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria();
|
||||||
|
externalReferenceCriteria.setLike(model.getPrefillId());
|
||||||
|
|
||||||
|
ExternalDataResult externalData = this.externalFetcherService.getExternalData(Stream.of(prefillingSourceDefinition.getGetConfiguration()).collect(Collectors.toList()), externalReferenceCriteria, null);
|
||||||
if (externalData == null || this.conventionService.isListNullOrEmpty(externalData.getResults())) {
|
if (externalData == null || this.conventionService.isListNullOrEmpty(externalData.getResults())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -339,7 +361,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
|
||||||
eu.eudat.commons.types.descriptiontemplate.DefinitionEntity descriptionTemplateDefinition = this.xmlHandlingService.fromXml(eu.eudat.commons.types.descriptiontemplate.DefinitionEntity.class, descriptionTemplateEntity.getDefinition());
|
eu.eudat.commons.types.descriptiontemplate.DefinitionEntity descriptionTemplateDefinition = this.xmlHandlingService.fromXml(eu.eudat.commons.types.descriptiontemplate.DefinitionEntity.class, descriptionTemplateEntity.getDefinition());
|
||||||
|
|
||||||
Description description = new Description();
|
Description description = new Description();
|
||||||
description.setDescriptionTemplate(this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(model.getProject(), descriptionTemplateEntity));
|
description.setDescriptionTemplate(this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, descriptionTemplateEntity));
|
||||||
return mapPrefilledEntityToDescription(description, descriptionTemplateDefinition, prefillingSourceDefinition, prefillingSourceEntity.getLabel(), externalData.getResults().getFirst());//TODO
|
return mapPrefilledEntityToDescription(description, descriptionTemplateDefinition, prefillingSourceDefinition, prefillingSourceEntity.getLabel(), externalData.getResults().getFirst());//TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,10 @@ import eu.eudat.model.Prefilling;
|
||||||
import eu.eudat.model.PrefillingSource;
|
import eu.eudat.model.PrefillingSource;
|
||||||
import eu.eudat.model.builder.PrefillingSourceBuilder;
|
import eu.eudat.model.builder.PrefillingSourceBuilder;
|
||||||
import eu.eudat.model.censorship.DescriptionCensor;
|
import eu.eudat.model.censorship.DescriptionCensor;
|
||||||
|
import eu.eudat.model.censorship.PrefillingCensor;
|
||||||
import eu.eudat.model.censorship.PrefillingSourceCensor;
|
import eu.eudat.model.censorship.PrefillingSourceCensor;
|
||||||
|
import eu.eudat.model.persist.PrefillingSearchRequest;
|
||||||
import eu.eudat.model.persist.DescriptionProfilingRequest;
|
import eu.eudat.model.persist.DescriptionProfilingRequest;
|
||||||
import eu.eudat.model.persist.DescriptionProfilingWithDataRequest;
|
|
||||||
import eu.eudat.model.persist.PrefillingSourcePersist;
|
import eu.eudat.model.persist.PrefillingSourcePersist;
|
||||||
import eu.eudat.model.result.QueryResult;
|
import eu.eudat.model.result.QueryResult;
|
||||||
import eu.eudat.query.PrefillingSourceQuery;
|
import eu.eudat.query.PrefillingSourceQuery;
|
||||||
|
@ -144,14 +145,14 @@ public class PrefillingSourceController {
|
||||||
this.auditService.track(AuditableAction.PrefillingSource_Delete, "id", id);
|
this.auditService.track(AuditableAction.PrefillingSource_Delete, "id", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("generate")
|
@PostMapping("search")
|
||||||
@ValidationFilterAnnotation(validator = DescriptionProfilingRequest.DescriptionProfilingRequestValidator.ValidatorName, argumentName = "model")
|
@ValidationFilterAnnotation(validator = PrefillingSearchRequest.PrefillingSearchRequestValidator.ValidatorName, argumentName = "model")
|
||||||
public Description generate(@RequestBody DescriptionProfilingRequest model) throws MyApplicationException, MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
|
public List<Prefilling> search(@RequestBody PrefillingSearchRequest model) throws MyApplicationException, MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
|
||||||
logger.debug(new MapLogEntry("persisting" + Prefilling.class.getSimpleName()).And("model", model));
|
logger.debug(new MapLogEntry("searching" + Prefilling.class.getSimpleName()).And("model", model));
|
||||||
|
|
||||||
this.censorFactory.censor(DescriptionCensor.class).censor(model.getProject(), null);
|
this.censorFactory.censor(PrefillingCensor.class).censor(null, null);
|
||||||
|
|
||||||
Description item = this.prefillingSourceService.getPrefilledDescription(model);
|
List<Prefilling> item = this.prefillingSourceService.searchPrefillings(model);
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.PrefillingSource_Generate, Map.ofEntries(
|
this.auditService.track(AuditableAction.PrefillingSource_Generate, Map.ofEntries(
|
||||||
new AbstractMap.SimpleEntry<String, Object>("model", model)
|
new AbstractMap.SimpleEntry<String, Object>("model", model)
|
||||||
|
@ -160,16 +161,16 @@ public class PrefillingSourceController {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("generate-with-data")
|
@PostMapping("generate")
|
||||||
@ValidationFilterAnnotation(validator = DescriptionProfilingWithDataRequest.DescriptionProfilingWithDataRequestValidator.ValidatorName, argumentName = "model")
|
@ValidationFilterAnnotation(validator = DescriptionProfilingRequest.DescriptionProfilingRequestValidator.ValidatorName, argumentName = "model")
|
||||||
public Description generateWithData(@RequestBody DescriptionProfilingWithDataRequest model) throws MyApplicationException, MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
|
public Description generate(@RequestBody DescriptionProfilingRequest model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
|
||||||
logger.debug(new MapLogEntry("persisting" + Prefilling.class.getSimpleName()).And("model", model));
|
logger.debug(new MapLogEntry("persisting" + Prefilling.class.getSimpleName()).And("model", model));
|
||||||
|
|
||||||
this.censorFactory.censor(DescriptionCensor.class).censor(model.getProject(), null);
|
this.censorFactory.censor(DescriptionCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
Description item = this.prefillingSourceService.getPrefilledDescriptionUsingData(model);
|
Description item = this.prefillingSourceService.getPrefilledDescription(model, fieldSet);
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.PrefillingSource_GenerateWithData, Map.ofEntries(
|
this.auditService.track(AuditableAction.PrefillingSource_Generate, Map.ofEntries(
|
||||||
new AbstractMap.SimpleEntry<String, Object>("model", model)
|
new AbstractMap.SimpleEntry<String, Object>("model", model)
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';
|
import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';
|
||||||
import { PrefillingService } from "@app/core/services/prefilling.service";
|
|
||||||
import { CookieService } from 'ngx-cookie-service';
|
import { CookieService } from 'ngx-cookie-service';
|
||||||
import { AdminAuthGuard } from './admin-auth-guard.service';
|
import { AdminAuthGuard } from './admin-auth-guard.service';
|
||||||
import { AuthGuard } from './auth-guard.service';
|
import { AuthGuard } from './auth-guard.service';
|
||||||
|
@ -89,7 +88,6 @@ export class CoreServiceModule {
|
||||||
PrincipalService,
|
PrincipalService,
|
||||||
SupportiveMaterialService,
|
SupportiveMaterialService,
|
||||||
LanguageInfoService,
|
LanguageInfoService,
|
||||||
PrefillingService,
|
|
||||||
DescriptionTemplateTypeService,
|
DescriptionTemplateTypeService,
|
||||||
HttpErrorHandlingService,
|
HttpErrorHandlingService,
|
||||||
QueryParamsService,
|
QueryParamsService,
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
import { Guid } from "@common/types/guid";
|
import { Guid } from "@common/types/guid";
|
||||||
|
|
||||||
|
export interface PrefillingSearchRequest {
|
||||||
|
like: string;
|
||||||
|
prefillingSourceId: Guid;
|
||||||
|
}
|
||||||
|
|
||||||
export interface DescriptionProfilingRequest {
|
export interface DescriptionProfilingRequest {
|
||||||
prefillingSourceId: Guid;
|
prefillingSourceId: Guid;
|
||||||
descriptionTemplateId: Guid;
|
descriptionTemplateId: Guid;
|
||||||
}
|
|
||||||
|
|
||||||
export interface DescriptionProfilingWithDataRequest {
|
|
||||||
prefillingSourceId: Guid;
|
|
||||||
descriptionTemplateId: Guid;
|
|
||||||
data: Map<String, Object>;
|
data: Map<String, Object>;
|
||||||
|
prefillId: string;
|
||||||
|
project: string[];
|
||||||
}
|
}
|
|
@ -27,6 +27,13 @@ export interface PrefillingSourceDefinitionFixedValueField {
|
||||||
fixedValue: string;
|
fixedValue: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Prefilling {
|
||||||
|
id: string,
|
||||||
|
label: string,
|
||||||
|
key: string,
|
||||||
|
tag: string
|
||||||
|
}
|
||||||
|
|
||||||
// Persist
|
// Persist
|
||||||
|
|
||||||
export interface PrefillingSourcePersist extends BaseEntityPersist{
|
export interface PrefillingSourcePersist extends BaseEntityPersist{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
||||||
import { PrefillingSource, PrefillingSourcePersist } from '@app/core/model/prefilling-source/prefilling-source';
|
import { Prefilling, PrefillingSource, PrefillingSourcePersist } from '@app/core/model/prefilling-source/prefilling-source';
|
||||||
import { PrefillingSourceLookup } from '@app/core/query/prefilling-source.lookup';
|
import { PrefillingSourceLookup } from '@app/core/query/prefilling-source.lookup';
|
||||||
import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration';
|
import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration';
|
||||||
import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration';
|
import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration';
|
||||||
|
@ -12,7 +12,7 @@ import { catchError, map } from 'rxjs/operators';
|
||||||
import { nameof } from 'ts-simple-nameof';
|
import { nameof } from 'ts-simple-nameof';
|
||||||
import { ConfigurationService } from '../configuration/configuration.service';
|
import { ConfigurationService } from '../configuration/configuration.service';
|
||||||
import { BaseHttpV2Service } from '../http/base-http-v2.service';
|
import { BaseHttpV2Service } from '../http/base-http-v2.service';
|
||||||
import { DescriptionProfilingRequest, DescriptionProfilingWithDataRequest } from '@app/core/model/description-profiling-request/description-profiling-request';
|
import { PrefillingSearchRequest, DescriptionProfilingRequest } from '@app/core/model/description-profiling-request/description-profiling-request';
|
||||||
import { Description } from '@app/core/model/description/description';
|
import { Description } from '@app/core/model/description/description';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -57,19 +57,20 @@ export class PrefillingSourceService {
|
||||||
catchError((error: any) => throwError(error)));
|
catchError((error: any) => throwError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
generate(item: DescriptionProfilingRequest): Observable<Description> {
|
search(item: PrefillingSearchRequest): Observable<Prefilling[]> {
|
||||||
const url = `${this.apiBase}/generate`;
|
const url = `${this.apiBase}/search`;
|
||||||
|
|
||||||
return this.http
|
return this.http
|
||||||
.post<Description>(url, item).pipe(
|
.post<Prefilling[]>(url, item).pipe(
|
||||||
catchError((error: any) => throwError(error)));
|
catchError((error: any) => throwError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
generateWithData(item: DescriptionProfilingWithDataRequest): Observable<Description> {
|
generate(item: DescriptionProfilingRequest, reqFields: string[] = []): Observable<Description> {
|
||||||
const url = `${this.apiBase}/generate-with-data`;
|
const url = `${this.apiBase}/generate`;
|
||||||
|
const options = { params: { f: reqFields } };
|
||||||
|
|
||||||
return this.http
|
return this.http
|
||||||
.post<Description>(url, item).pipe(
|
.post<Description>(url, item, options).pipe(
|
||||||
catchError((error: any) => throwError(error)));
|
catchError((error: any) => throwError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
import { HttpClient, HttpHeaders } from "@angular/common/http";
|
|
||||||
import { Injectable } from "@angular/core";
|
|
||||||
import { ConfigurationService } from "@app/core/services/configuration/configuration.service";
|
|
||||||
import { BaseHttpV2Service } from "./http/base-http-v2.service";
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class PrefillingService {
|
|
||||||
private readonly actionUrl: string;
|
|
||||||
private headers = new HttpHeaders();
|
|
||||||
|
|
||||||
constructor(private http: BaseHttpV2Service, private httpClient: HttpClient, private configurationService: ConfigurationService) {
|
|
||||||
this.actionUrl = configurationService.server + 'prefilling/';
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: refactor
|
|
||||||
// public getPrefillingList(like: string): Observable<Prefilling[]> {
|
|
||||||
// return this.http.get<Prefilling[]>(this.actionUrl + 'list?like=' + encodeURIComponent(like), { headers: this.headers });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public getPrefillingDataset(pid: string, profileId: string, configId: string): Observable<DatasetWizardModel> {
|
|
||||||
// return this.http.get<DatasetWizardModel>(this.actionUrl + '/generate/' + encodeURIComponent(pid) + '?configId=' + encodeURIComponent(configId) + '&profileId=' + encodeURIComponent(profileId), { headers: this.headers });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public getPrefillingDatasetUsingData(data: any, profileId: string, configId: string): Observable<DatasetWizardModel> {
|
|
||||||
// return this.http.post<DatasetWizardModel>(this.actionUrl + '/generateUsingData' + '?configId=' + encodeURIComponent(configId) + '&profileId=' + encodeURIComponent(profileId), data, { headers: this.headers });
|
|
||||||
// }
|
|
||||||
}
|
|
|
@ -105,7 +105,7 @@ export class PrefillingSourceEditorComponent extends BaseEditor<PrefillingSource
|
||||||
buildForm() {
|
buildForm() {
|
||||||
this.formGroup = this.editorModel.buildForm(null, this.isDeleted || !this.authService.hasPermission(AppPermission.EditPrefillingSource));
|
this.formGroup = this.editorModel.buildForm(null, this.isDeleted || !this.authService.hasPermission(AppPermission.EditPrefillingSource));
|
||||||
this.prefillingSourceEditorService.setValidationErrorModel(this.editorModel.validationErrorModel);
|
this.prefillingSourceEditorService.setValidationErrorModel(this.editorModel.validationErrorModel);
|
||||||
this.addFieldMapping("prefilling_id", "searchConfiguration");
|
this.addFieldMapping("reference_id", "searchConfiguration");
|
||||||
this.addFieldMapping("label", "searchConfiguration");
|
this.addFieldMapping("label", "searchConfiguration");
|
||||||
this.addFieldMapping("description", "searchConfiguration");
|
this.addFieldMapping("description", "searchConfiguration");
|
||||||
|
|
||||||
|
|
|
@ -255,6 +255,9 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
|
||||||
});
|
});
|
||||||
dialogRef.afterClosed().subscribe(result => {
|
dialogRef.afterClosed().subscribe(result => {
|
||||||
if (result) {
|
if (result) {
|
||||||
|
result.dmp = this.item.dmp;
|
||||||
|
result.dmpDescriptionTemplate = this.item.dmpDescriptionTemplate;
|
||||||
|
this.prepareForm(result);
|
||||||
// this.descriptionModel = this.descriptionModel.fromModel(result);
|
// this.descriptionModel = this.descriptionModel.fromModel(result);
|
||||||
// this.descriptionModel.dmp = data;
|
// this.descriptionModel.dmp = data;
|
||||||
// this.descriptionModel.dmpSectionIndex = this.dmpSectionIndex;
|
// this.descriptionModel.dmpSectionIndex = this.dmpSectionIndex;
|
||||||
|
|
|
@ -45,17 +45,17 @@
|
||||||
<mat-error *ngIf="prefillForm.get('prefillingSourceId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="prefillForm.get('prefillingSourceId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div *ngIf="prefillSelected" class="row">
|
<div *ngIf="prefillForm.get('prefillingSourceId').value != null" class="row">
|
||||||
<div class="col-12 pl-0 pr-0 pb-2 d-flex flex-row">
|
<div class="col-12 pl-0 pr-0 pb-2 d-flex flex-row">
|
||||||
<h4 class="col-auto heading">{{'PREFILL-DESCRIPTION-DIALOG.SEARCH-HEADER' | translate}}</h4>
|
<h4 class="col-auto heading">{{'PREFILL-DESCRIPTION-DIALOG.SEARCH-HEADER' | translate}}</h4>
|
||||||
</div>
|
</div>
|
||||||
<mat-form-field class="col-md-12">
|
<mat-form-field class="col-md-12">
|
||||||
<app-single-auto-complete [required]="true" [formControl]="prefillForm.get('prefill')"
|
<app-single-auto-complete [required]="true" [formControl]="prefillForm.get('prefillId')"
|
||||||
placeholder="{{'PREFILL-DESCRIPTION-DIALOG.SEARCH' | translate}}"
|
placeholder="{{'PREFILL-DESCRIPTION-DIALOG.SEARCH' | translate}}"
|
||||||
[configuration]="prefillAutoCompleteConfiguration">
|
[configuration]="prefillAutoCompleteConfiguration">
|
||||||
</app-single-auto-complete>
|
</app-single-auto-complete>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div> -->
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="prefillSelected">
|
<div *ngIf="prefillSelected">
|
||||||
|
|
|
@ -1,18 +1,22 @@
|
||||||
import { Component, Inject, OnInit } from "@angular/core";
|
import { Component, Inject, OnInit } from "@angular/core";
|
||||||
import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
|
import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
|
||||||
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from "@angular/material/dialog";
|
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from "@angular/material/dialog";
|
||||||
import { DescriptionProfilingRequest } from "@app/core/model/description-profiling-request/description-profiling-request";
|
import { PrefillingSearchRequest, DescriptionProfilingRequest } from "@app/core/model/description-profiling-request/description-profiling-request";
|
||||||
import { DescriptionTemplate } from "@app/core/model/description-template/description-template";
|
import { DescriptionTemplate } from "@app/core/model/description-template/description-template";
|
||||||
import { Dmp } from "@app/core/model/dmp/dmp";
|
import { Dmp } from "@app/core/model/dmp/dmp";
|
||||||
|
import { Prefilling } from "@app/core/model/prefilling-source/prefilling-source";
|
||||||
import { DmpBlueprintService } from "@app/core/services/dmp/dmp-blueprint.service";
|
import { DmpBlueprintService } from "@app/core/services/dmp/dmp-blueprint.service";
|
||||||
import { PrefillingSourceService } from "@app/core/services/prefilling-source/prefilling-source.service";
|
import { PrefillingSourceService } from "@app/core/services/prefilling-source/prefilling-source.service";
|
||||||
import { ProgressIndicationService } from "@app/core/services/progress-indication/progress-indication-service";
|
import { ProgressIndicationService } from "@app/core/services/progress-indication/progress-indication-service";
|
||||||
|
import { SingleAutoCompleteConfiguration } from "@app/library/auto-complete/single/single-auto-complete-configuration";
|
||||||
|
import { DescriptionTemplateEditorResolver } from "@app/ui/admin/description-template/editor/description-template-editor.resolver";
|
||||||
import { BaseComponent } from "@common/base/base.component";
|
import { BaseComponent } from "@common/base/base.component";
|
||||||
import { FormService } from "@common/forms/form-service";
|
import { FormService } from "@common/forms/form-service";
|
||||||
import { Guid } from "@common/types/guid";
|
import { Guid } from "@common/types/guid";
|
||||||
import { TranslateService } from "@ngx-translate/core";
|
import { TranslateService } from "@ngx-translate/core";
|
||||||
import { UUID } from "crypto";
|
import { UUID } from "crypto";
|
||||||
import { takeUntil } from "rxjs/operators";
|
import { Observable } from "rxjs";
|
||||||
|
import { map, takeUntil } from "rxjs/operators";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'prefill-description-component',
|
selector: 'prefill-description-component',
|
||||||
|
@ -22,7 +26,7 @@ import { takeUntil } from "rxjs/operators";
|
||||||
export class PrefillDescriptionDialogComponent extends BaseComponent implements OnInit {
|
export class PrefillDescriptionDialogComponent extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
progressIndication = false;
|
progressIndication = false;
|
||||||
// prefillAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
prefillAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
||||||
prefillSelected: boolean = false;
|
prefillSelected: boolean = false;
|
||||||
prefillForm: UntypedFormGroup;
|
prefillForm: UntypedFormGroup;
|
||||||
|
|
||||||
|
@ -53,18 +57,20 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements
|
||||||
this.prefillForm = this.fb.group({
|
this.prefillForm = this.fb.group({
|
||||||
type: this.fb.control(false),
|
type: this.fb.control(false),
|
||||||
descriptionTemplateId: this.fb.control(null, Validators.required),
|
descriptionTemplateId: this.fb.control(null, Validators.required),
|
||||||
prefillingSourceId: this.fb.control(null, Validators.required)
|
prefillingSourceId: this.fb.control(null, Validators.required),
|
||||||
|
prefillId: this.fb.control(null, Validators.required),
|
||||||
})
|
})
|
||||||
// if (this.data.availableProfiles && this.data.availableProfiles.length === 1) {
|
// if (this.data.availableProfiles && this.data.availableProfiles.length === 1) {
|
||||||
// this.addProfileIfUsedLessThanMax(this.data.availableProfiles[0]);
|
// this.addProfileIfUsedLessThanMax(this.data.availableProfiles[0]);
|
||||||
// }
|
// }
|
||||||
// this.prefillAutoCompleteConfiguration = {
|
this.prefillAutoCompleteConfiguration = {
|
||||||
// filterFn: this.searchDescriptions.bind(this),
|
filterFn: this.searchDescriptions.bind(this),
|
||||||
// loadDataOnStart: false,
|
loadDataOnStart: false,
|
||||||
// displayFn: (item) => (item['name'].length > 60) ? (item['name'].substr(0, 60) + "...") : item['name'],
|
displayFn: (item) => (item['label'].length > 60) ? (item['label'].substr(0, 60) + "...") : item['label'],
|
||||||
// titleFn: (item) => item['name'],
|
titleFn: (item) => item['label'],
|
||||||
// subtitleFn: (item) => item['pid']
|
subtitleFn: (item) => item['id'],
|
||||||
// };
|
valueAssign: (item) => item['id'],
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// addProfileIfUsedLessThanMax(profile: DescriptionProfileModel) {
|
// addProfileIfUsedLessThanMax(profile: DescriptionProfileModel) {
|
||||||
|
@ -170,17 +176,22 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements
|
||||||
return object1 && object2 && object1.id === object2.id;
|
return object1 && object2 && object1.id === object2.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// searchDescriptions(query: string): Observable<Prefilling[]> {
|
searchDescriptions(query: string): Observable<Prefilling[]> {
|
||||||
// return this.prefillingService.getPrefillingList(query).pipe(map(prefilling => prefilling.sort((a, b) => {
|
const request: PrefillingSearchRequest= {
|
||||||
// if (a.name > b.name) {
|
like: query,
|
||||||
// return 1;
|
prefillingSourceId: this.prefillForm.get('prefillingSourceId').value
|
||||||
// } else if (a.name < b.name) {
|
};
|
||||||
// return -1;
|
|
||||||
// } else {
|
return this.prefillingSourceService.search(request).pipe(map(prefilling => prefilling.sort((a, b) => {
|
||||||
// return 0;
|
if (a.label > b.label) {
|
||||||
// }
|
return 1;
|
||||||
// })));
|
} else if (a.label < b.label) {
|
||||||
// }
|
return -1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
|
||||||
next() {
|
next() {
|
||||||
// if (this.isPrefilled) {
|
// if (this.isPrefilled) {
|
||||||
|
@ -201,11 +212,16 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements
|
||||||
// }
|
// }
|
||||||
const formData = this.formService.getValue(this.prefillForm.value) as DescriptionProfilingRequest;
|
const formData = this.formService.getValue(this.prefillForm.value) as DescriptionProfilingRequest;
|
||||||
|
|
||||||
this.prefillingSourceService.generate(formData)
|
this.prefillingSourceService.generate(formData, DescriptionTemplateEditorResolver.lookupFields())
|
||||||
.pipe(takeUntil(this._destroyed)).subscribe(
|
.pipe(takeUntil(this._destroyed)).subscribe(description => {
|
||||||
);
|
if (description) {
|
||||||
|
this.closeDialog(description);
|
||||||
|
} else {
|
||||||
this.closeDialog();
|
this.closeDialog();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
closeDialog(result = null): void {
|
closeDialog(result = null): void {
|
||||||
this.dialogRef.close(result);
|
this.dialogRef.close(result);
|
||||||
|
|
Loading…
Reference in New Issue