Fetching dois for dmps for public API
This commit is contained in:
parent
d3d57e8838
commit
b3bc801cd4
|
@ -1,6 +1,8 @@
|
|||
package eu.eudat.model.mapper.publicapi;
|
||||
|
||||
import eu.eudat.data.EntityDoiEntity;
|
||||
import eu.eudat.model.Dmp;
|
||||
import eu.eudat.model.publicapi.doi.DoiPublicModel;
|
||||
import eu.eudat.model.publicapi.grant.GrantPublicOverviewModel;
|
||||
import eu.eudat.model.publicapi.organisation.OrganizationPublicModel;
|
||||
import eu.eudat.model.publicapi.overviewmodels.DataManagementPlanPublicModel;
|
||||
|
@ -9,12 +11,13 @@ import eu.eudat.model.publicapi.user.UserInfoPublicModel;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Component
|
||||
public class DmpToPublicApiDmpMapper {
|
||||
|
||||
public DataManagementPlanPublicModel toPublicModel(Dmp dmp) {
|
||||
public DataManagementPlanPublicModel toPublicModel(Dmp dmp, List<EntityDoiEntity> doiEntities) {
|
||||
DataManagementPlanPublicModel model = new DataManagementPlanPublicModel();
|
||||
model.setId(dmp.getId().toString());
|
||||
model.setLabel(dmp.getLabel());
|
||||
|
@ -26,6 +29,8 @@ public class DmpToPublicApiDmpMapper {
|
|||
model.setResearchers(dmp.getDmpReferences().stream().map(ResearcherPublicModel::fromDmpReference).filter(Objects::isNull).toList());
|
||||
model.setGrant(GrantPublicOverviewModel.fromDmpReferences(dmp.getDmpReferences()));
|
||||
model.setOrganisations(dmp.getDmpReferences().stream().map(OrganizationPublicModel::fromDmpReference).filter(Objects::isNull).toList());
|
||||
List<DoiPublicModel> dois = doiEntities.stream().map(DoiPublicModel::fromDataModel).toList();
|
||||
model.setDois(dois);
|
||||
|
||||
model.setCreatedAt(Date.from(dmp.getCreatedAt()));
|
||||
model.setModifiedAt(Date.from(dmp.getUpdatedAt()));
|
||||
|
|
|
@ -30,26 +30,11 @@ public class DoiPublicModel {
|
|||
this.doi = doi;
|
||||
}
|
||||
|
||||
public DoiPublicModel fromDataModel(EntityDoiEntity entity) {
|
||||
this.id = entity.getId();
|
||||
this.repositoryId = entity.getRepositoryId();
|
||||
this.doi = entity.getDoi();
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityDoiEntity toDataModel() throws Exception {
|
||||
EntityDoiEntity entity = new EntityDoiEntity();
|
||||
entity.setId(this.getId());
|
||||
entity.setRepositoryId(this.getRepositoryId());
|
||||
entity.setDoi(this.getDoi());
|
||||
return entity;
|
||||
}
|
||||
|
||||
public String generateLabel() {
|
||||
return this.getDoi();
|
||||
}
|
||||
|
||||
public String getHint() {
|
||||
return null;
|
||||
public static DoiPublicModel fromDataModel(EntityDoiEntity entity) {
|
||||
DoiPublicModel model = new DoiPublicModel();
|
||||
model.setId(entity.getId());
|
||||
model.setRepositoryId(entity.getRepositoryId());
|
||||
model.setDoi(entity.getDoi());
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,25 +109,4 @@ public class GrantPublicOverviewModel {
|
|||
return null;
|
||||
}
|
||||
|
||||
public GrantPublicOverviewModel fromDataModel(Grant entity) {
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
this.abbreviation = entity.getAbbreviation();
|
||||
this.description = entity.getDescription();
|
||||
this.startDate = entity.getStartdate();
|
||||
this.endDate = entity.getEnddate();
|
||||
this.uri = entity.getUri();
|
||||
this.funder = new FunderPublicOverviewModel();
|
||||
if (entity.getFunder() != null)
|
||||
this.funder.fromDataModel(entity.getFunder());
|
||||
return this;
|
||||
}
|
||||
|
||||
public Grant toDataModel() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getHint() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,10 +11,12 @@ import eu.eudat.model.*;
|
|||
import eu.eudat.model.builder.DmpBuilder;
|
||||
import eu.eudat.model.mapper.publicapi.DmpToPublicApiDmpListingMapper;
|
||||
import eu.eudat.model.mapper.publicapi.DmpToPublicApiDmpMapper;
|
||||
import eu.eudat.model.publicapi.doi.DoiPublicModel;
|
||||
import eu.eudat.model.publicapi.listingmodels.DataManagementPlanPublicListingModel;
|
||||
import eu.eudat.model.publicapi.overviewmodels.DataManagementPlanPublicModel;
|
||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||
import eu.eudat.query.DmpQuery;
|
||||
import eu.eudat.query.EntityDoiQuery;
|
||||
import eu.eudat.query.lookup.DmpLookup;
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
|
@ -173,7 +175,8 @@ public class PublicDmpsDocumentation extends BaseController {
|
|||
Dmp model = this.builderFactory.builder(DmpBuilder.class).build(fieldSet, query.firstAs(fieldSet));
|
||||
if (model == null)
|
||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
DataManagementPlanPublicModel dataManagementPlan = this.dmpToPublicApiDmpMapper.toPublicModel(model);
|
||||
EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).entityIds(UUID.fromString(id)).isActive(IsActive.Active);
|
||||
DataManagementPlanPublicModel dataManagementPlan = this.dmpToPublicApiDmpMapper.toPublicModel(model, entityDoiQuery.collect());
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanPublicModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue