Fixing issues in public API mappers
This commit is contained in:
parent
5825aa642a
commit
9ba8751564
|
@ -6,6 +6,7 @@ import eu.eudat.model.DmpDescriptionTemplate;
|
|||
import eu.eudat.model.publicapi.associatedprofile.AssociatedProfilePublicModel;
|
||||
import eu.eudat.model.publicapi.doi.DoiPublicModel;
|
||||
import eu.eudat.model.publicapi.grant.GrantPublicOverviewModel;
|
||||
import eu.eudat.model.publicapi.listingmodels.DataManagementPlanPublicListingModel;
|
||||
import eu.eudat.model.publicapi.organisation.OrganizationPublicModel;
|
||||
import eu.eudat.model.publicapi.overviewmodels.DataManagementPlanPublicModel;
|
||||
import eu.eudat.model.publicapi.researcher.ResearcherPublicModel;
|
||||
|
@ -13,13 +14,18 @@ import eu.eudat.model.publicapi.user.UserInfoPublicModel;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Component
|
||||
public class DmpToPublicApiDmpMapper {
|
||||
|
||||
private final DescriptionToPublicApiDatasetMapper descriptionToPublicApiDatasetMapper;
|
||||
|
||||
public DmpToPublicApiDmpMapper(DescriptionToPublicApiDatasetMapper descriptionToPublicApiDatasetMapper) {
|
||||
this.descriptionToPublicApiDatasetMapper = descriptionToPublicApiDatasetMapper;
|
||||
}
|
||||
|
||||
public DataManagementPlanPublicModel toPublicModel(Dmp dmp, List<EntityDoiEntity> doiEntities, List<DmpDescriptionTemplate> descriptionTemplates) {
|
||||
DataManagementPlanPublicModel model = new DataManagementPlanPublicModel();
|
||||
model.setId(dmp.getId().toString());
|
||||
|
@ -27,9 +33,13 @@ public class DmpToPublicApiDmpMapper {
|
|||
model.setDescription(dmp.getDescription());
|
||||
model.setVersion(dmp.getVersion());
|
||||
model.setGroupId(dmp.getGroupId());
|
||||
model.setProfile(dmp.getBlueprint().getLabel());
|
||||
if (dmp.getBlueprint() != null) model.setProfile(dmp.getBlueprint().getLabel());
|
||||
|
||||
model.setDatasets(new ArrayList<>()); //TODO
|
||||
if (dmp.getDescriptions() != null) {
|
||||
DataManagementPlanPublicListingModel publicListingModel = new DataManagementPlanPublicListingModel();
|
||||
publicListingModel.setId(model.getId());
|
||||
model.setDatasets(dmp.getDescriptions().stream().map(x -> descriptionToPublicApiDatasetMapper.toPublicModel(x, publicListingModel)).toList());
|
||||
}
|
||||
|
||||
model.setUsers(dmp.getDmpUsers().stream().map(UserInfoPublicModel::fromDmpUser).toList());
|
||||
model.setResearchers(dmp.getDmpReferences().stream().map(ResearcherPublicModel::fromDmpReference).filter(Objects::nonNull).toList());
|
||||
|
|
|
@ -102,6 +102,7 @@ public class DataRepositoryPublicModel {
|
|||
model.setReference(reference.getReference());
|
||||
model.setSource(reference.getSource());
|
||||
model.setPid(reference.getReference());
|
||||
if (reference.getDefinition() == null) return model;
|
||||
Field uri = reference.getDefinition().getFields().stream().filter(x -> x.getCode().equals("uri")).toList().get(0);
|
||||
if (uri != null) model.setUri(uri.getValue());
|
||||
|
||||
|
|
|
@ -118,6 +118,7 @@ public class ExternalDatasetPublicListingModel {
|
|||
model.setReference(reference.getReference());
|
||||
model.setSource(reference.getSource());
|
||||
model.setPid(reference.getReference());
|
||||
if (reference.getDefinition() == null) return model;
|
||||
Field uri = reference.getDefinition().getFields().stream().filter(x -> x.getCode().equals("uri")).toList().get(0);
|
||||
if (uri != null) model.setUri(uri.getValue());
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ public class RegistryPublicModel {
|
|||
model.setReference(reference.getReference());
|
||||
model.setSource(reference.getSource());
|
||||
model.setDefinition(reference.getDefinition().toString());
|
||||
if (reference.getDefinition() == null) return model;
|
||||
Field uri = reference.getDefinition().getFields().stream().filter(x -> x.getCode().equals("uri")).toList().get(0);
|
||||
if (uri != null) model.setUri(uri.getValue());
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ public class ServicePublicModel {
|
|||
model.setAbbreviation(reference.getAbbreviation());
|
||||
model.setReference(reference.getReference());
|
||||
model.setSource(reference.getSource());
|
||||
if (reference.getDefinition() == null) return model;
|
||||
model.setDefinition(reference.getDefinition().toString());
|
||||
Field uri = reference.getDefinition().getFields().stream().filter(x -> x.getCode().equals("uri")).toList().get(0);
|
||||
if (uri != null) model.setUri(uri.getValue());
|
||||
|
|
|
@ -98,6 +98,7 @@ public class GrantPublicOverviewModel {
|
|||
model.setAbbreviation(reference.getAbbreviation());
|
||||
model.setLabel(reference.getLabel());
|
||||
model.setFunder(funder);
|
||||
if (reference.getDefinition() == null) return model;
|
||||
Field startDate = reference.getDefinition().getFields().stream().filter(x -> x.getCode().equals("startDate")).toList().get(0);
|
||||
if (startDate != null) model.setStartDate(Date.from(Instant.parse(startDate.getValue())));
|
||||
Field endDate = reference.getDefinition().getFields().stream().filter(x -> x.getCode().equals("endDate")).toList().get(0);
|
||||
|
@ -129,6 +130,7 @@ public class GrantPublicOverviewModel {
|
|||
model.setAbbreviation(reference.getAbbreviation());
|
||||
model.setLabel(reference.getLabel());
|
||||
model.setFunder(funder);
|
||||
if (reference.getDefinition() == null) return model;
|
||||
Field startDate = reference.getDefinition().getFields().stream().filter(x -> x.getCode().equals("startDate")).toList().get(0);
|
||||
if (startDate != null) model.setStartDate(Date.from(Instant.parse(startDate.getValue())));
|
||||
Field endDate = reference.getDefinition().getFields().stream().filter(x -> x.getCode().equals("endDate")).toList().get(0);
|
||||
|
|
|
@ -149,6 +149,7 @@ public class PublicDatasetsDescriptionDocumentation extends BaseController {
|
|||
String.join(".", Description._createdBy, User._id),
|
||||
String.join(".", Description._createdBy, User._name),
|
||||
String.join(".", Description._descriptionReferences, DescriptionReference._reference, Reference._id),
|
||||
String.join(".", Description._descriptionReferences, DescriptionReference._reference, Reference._type),
|
||||
String.join(".", Description._descriptionReferences, DescriptionReference._reference, Reference._reference),
|
||||
String.join(".", Description._descriptionReferences, DescriptionReference._reference, Reference._label),
|
||||
String.join(".", Description._descriptionReferences, DescriptionReference._reference, Reference._abbreviation),
|
||||
|
|
|
@ -14,6 +14,8 @@ import eu.eudat.model.mapper.publicapi.DmpToPublicApiDmpListingMapper;
|
|||
import eu.eudat.model.mapper.publicapi.DmpToPublicApiDmpMapper;
|
||||
import eu.eudat.model.publicapi.listingmodels.DataManagementPlanPublicListingModel;
|
||||
import eu.eudat.model.publicapi.overviewmodels.DataManagementPlanPublicModel;
|
||||
import eu.eudat.model.referencedefinition.Definition;
|
||||
import eu.eudat.model.referencedefinition.Field;
|
||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||
import eu.eudat.query.DmpDescriptionTemplateQuery;
|
||||
import eu.eudat.query.DmpQuery;
|
||||
|
@ -121,12 +123,16 @@ public class PublicDmpsDocumentation extends BaseController {
|
|||
Dmp._description,
|
||||
Dmp._version,
|
||||
Dmp._groupId,
|
||||
String.join(".", Dmp._dmpUsers, String.join(".", DmpUser._user, User._id)),
|
||||
String.join(".", Dmp._dmpUsers, String.join(".", DmpUser._user, User._name)),
|
||||
String.join(".", Dmp._dmpUsers, DmpUser._user, User._id),
|
||||
String.join(".", Dmp._dmpUsers, DmpUser._user, User._name),
|
||||
String.join(".", Dmp._dmpUsers, DmpUser._role),
|
||||
String.join(".", Dmp._dmpReferences, String.join(".", DmpReference._reference, Reference._id)),
|
||||
String.join(".", Dmp._dmpReferences, String.join(".", DmpReference._reference, Reference._reference)),
|
||||
String.join(".", Dmp._dmpReferences, String.join(".", DmpReference._reference, Reference._label)),
|
||||
String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._id),
|
||||
String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._type),
|
||||
String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._reference),
|
||||
String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._label),
|
||||
String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._definition, Definition._fields, Field._code),
|
||||
String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._definition, Definition._fields, Field._dataType),
|
||||
String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._definition, Definition._fields, Field._value),
|
||||
Dmp._dmpReferences,
|
||||
Dmp._createdAt,
|
||||
Dmp._updatedAt,
|
||||
|
@ -165,15 +171,16 @@ public class PublicDmpsDocumentation extends BaseController {
|
|||
Dmp._description,
|
||||
Dmp._version,
|
||||
Dmp._groupId,
|
||||
String.join(".", Dmp._dmpUsers, String.join(".", DmpUser._user, User._id)),
|
||||
String.join(".", Dmp._dmpUsers, String.join(".", DmpUser._user, User._name)),
|
||||
String.join(".", Dmp._dmpUsers, DmpUser._user, User._id),
|
||||
String.join(".", Dmp._dmpUsers, DmpUser._user, User._name),
|
||||
String.join(".", Dmp._dmpUsers, DmpUser._role),
|
||||
String.join(".", Dmp._dmpReferences, String.join(".", DmpReference._reference, Reference._id)),
|
||||
String.join(".", Dmp._dmpReferences, String.join(".", DmpReference._reference, Reference._reference)),
|
||||
String.join(".", Dmp._dmpReferences, String.join(".", DmpReference._reference, Reference._label)),
|
||||
String.join(".", Dmp._dmpReferences, String.join(".", DmpReference._reference, Reference._abbreviation)),
|
||||
String.join(".", Dmp._dmpReferences, String.join(".", DmpReference._reference, Reference._description)),
|
||||
String.join(".", Dmp._dmpReferences, String.join(".", DmpReference._reference, Reference._definition)),
|
||||
String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._id),
|
||||
String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._type),
|
||||
String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._reference),
|
||||
String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._label),
|
||||
String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._abbreviation),
|
||||
String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._description),
|
||||
String.join(".", Dmp._dmpReferences, DmpReference._reference, Reference._definition),
|
||||
Dmp._createdAt,
|
||||
Dmp._updatedAt,
|
||||
Dmp._finalizedAt
|
||||
|
|
Loading…
Reference in New Issue