Refactors the the connection between DMP and Dataset Template (Profile) and adds Dataset Template criteria on DMP listing.
This commit is contained in:
parent
10e76e6d2b
commit
f9b12f99a4
|
@ -18,6 +18,7 @@ public class DataManagementPlanCriteria extends Criteria<DMP> {
|
|||
private List<String> organisations;
|
||||
private Integer role;
|
||||
private List<UUID> collaborators;
|
||||
private List<UUID> datasetTemplates;
|
||||
|
||||
public Date getPeriodStart() {
|
||||
return periodStart;
|
||||
|
@ -81,4 +82,11 @@ public class DataManagementPlanCriteria extends Criteria<DMP> {
|
|||
public void setCollaborators(List<UUID> collaborators) {
|
||||
this.collaborators = collaborators;
|
||||
}
|
||||
|
||||
public List<UUID> getDatasetTemplates() {
|
||||
return datasetTemplates;
|
||||
}
|
||||
public void setDatasetTemplates(List<UUID> datasetTemplates) {
|
||||
this.datasetTemplates = datasetTemplates;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,12 +6,50 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
|
||||
public class DatasetProfileCriteria extends Criteria<DatasetProfile> {
|
||||
|
||||
public enum DatasetProfileFilter {
|
||||
DMPs((short) 0), Datasets((short) 1);
|
||||
|
||||
private short value;
|
||||
private DatasetProfileFilter(short value) {
|
||||
this.value = value;
|
||||
}
|
||||
public short getValue() { return value; }
|
||||
|
||||
public static DatasetProfileFilter fromInteger(short value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return DMPs;
|
||||
case 1:
|
||||
return Datasets;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported DatasetProfile filter");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean allVersions;
|
||||
private List<UUID> groupIds;
|
||||
private Short filter;
|
||||
private UUID userId;
|
||||
|
||||
public boolean getAllVersions() { return allVersions; }
|
||||
public void setAllVersions(boolean allVersions) { this.allVersions = allVersions; }
|
||||
|
||||
public List<UUID> getGroupIds() { return groupIds; }
|
||||
public void setGroupIds(List<UUID> groupIds) { this.groupIds = groupIds; }
|
||||
|
||||
public Short getFilter() {
|
||||
return filter;
|
||||
}
|
||||
public void setFilter(Short filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
public UUID getUserId() {
|
||||
return userId;
|
||||
}
|
||||
public void setUserId(UUID userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,9 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
|||
if (criteria.getCollaborators() != null && !criteria.getCollaborators().isEmpty()) {
|
||||
query.where((builder, root) -> root.join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id").in(criteria.getCollaborators()));
|
||||
}
|
||||
if (criteria.getDatasetTemplates() != null && !criteria.getDatasetTemplates().isEmpty()) {
|
||||
query.where(((builder, root) -> root.join("associatedDmps", JoinType.LEFT).get("id").in(criteria.getDatasetTemplates())));
|
||||
}
|
||||
query.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()));
|
||||
return query;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.persistence.criteria.JoinType;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
@ -34,6 +35,16 @@ public class DatasetProfileDaoImpl extends DatabaseAccess<DatasetProfile> implem
|
|||
nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
|
||||
if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty())
|
||||
query.where((builder, root) -> root.get("groupId").in(criteria.getGroupIds()));
|
||||
if (criteria.getFilter() != null && criteria.getUserId() != null) {
|
||||
if (criteria.getFilter().equals(DatasetProfileCriteria.DatasetProfileFilter.DMPs.getValue())) {
|
||||
query.initSubQuery(UUID.class).where((builder, root) ->
|
||||
builder.and(root.get("id").in(
|
||||
query.subQuery((builder1, root1) -> builder1.equal(root1.join("dmps", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), criteria.getUserId()),
|
||||
Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")))),
|
||||
builder.notEqual(root.get("id"), criteria.getUserId())));
|
||||
//query.where(((builder, root) -> builder.equal(root.join("dmps", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), criteria.getUserId())));
|
||||
}
|
||||
}
|
||||
query.where(((builder, root) -> builder.notEqual(root.get("status"), DatasetProfile.Status.DELETED.getValue())));
|
||||
return query;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ package eu.eudat.data.entities;
|
|||
import eu.eudat.data.converters.DateToUTCConverter;
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.ManyToAny;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
@ -91,9 +92,16 @@ public class DMP implements DataEntity<DMP, UUID> {
|
|||
private Project project;
|
||||
|
||||
|
||||
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||
/*@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||
@Column(name = "\"AssociatedDmps\"", columnDefinition = "xml", nullable = true)
|
||||
private String associatedDmps;
|
||||
private String associatedDmps;*/
|
||||
@OneToMany(fetch = FetchType.EAGER)
|
||||
@JoinTable(name = "\"DMPDatasetProfile\"",
|
||||
joinColumns = {@JoinColumn(name = "\"dmp\"", referencedColumnName = "\"ID\"")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "\"datasetprofile\"", referencedColumnName = "\"ID\"")}
|
||||
)
|
||||
private List<DatasetProfile> associatedDmps;
|
||||
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "\"Profile\"")
|
||||
|
@ -229,10 +237,10 @@ public class DMP implements DataEntity<DMP, UUID> {
|
|||
this.project = project;
|
||||
}
|
||||
|
||||
public String getAssociatedDmps() {
|
||||
public List<DatasetProfile> getAssociatedDmps() {
|
||||
return associatedDmps;
|
||||
}
|
||||
public void setAssociatedDmps(String associatedDmps) {
|
||||
public void setAssociatedDmps(List<DatasetProfile> associatedDmps) {
|
||||
this.associatedDmps = associatedDmps;
|
||||
}
|
||||
|
||||
|
|
|
@ -79,6 +79,13 @@ public class DatasetProfile implements DataEntity<DatasetProfile,UUID>{
|
|||
@Column(name = "\"Version\"", nullable = false)
|
||||
private Short version;
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "\"DMPDatasetProfile\"",
|
||||
joinColumns = {@JoinColumn(name = "\"datasetprofile\"", referencedColumnName = "\"ID\"")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "\"dmp\"", referencedColumnName = "\"ID\"")}
|
||||
)
|
||||
private List<DMP> dmps;
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
|
|
|
@ -94,6 +94,13 @@ public class Admin extends BaseController {
|
|||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/datasetprofiles/using/paged"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<DatasetProfileListingModel>>> getUsingDatasetProfilesPaged(@RequestBody DatasetProfileTableRequestItem datasetProfileTableRequestItem, Principal principal) throws Exception {
|
||||
DataTableData<DatasetProfileListingModel> datasetProfileTableData = this.datasetProfileManager.getDatasetProfilesUsedByDMP(datasetProfileTableRequestItem, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/preview"}, consumes = "application/json", produces = "application/json")
|
||||
public ResponseEntity<ResponseItem<PagedDatasetProfile>> getPreview(@RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext());
|
||||
|
|
|
@ -133,7 +133,6 @@ public class DataManagementPlanManager {
|
|||
|
||||
CompletableFuture itemsFuture;
|
||||
if(fieldsGroup.equals("listing")){
|
||||
|
||||
itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class))
|
||||
.selectAsync(item -> {
|
||||
item.setDataset(
|
||||
|
@ -145,7 +144,7 @@ public class DataManagementPlanManager {
|
|||
}
|
||||
else{
|
||||
itemsFuture = pagedItems
|
||||
.selectAsync(item -> new DataManagementPlanListingModel().fromDataModel(item))
|
||||
.selectAsync(item -> new DataManagementPlanListingModel().fromDataModel(item))
|
||||
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));
|
||||
}
|
||||
|
||||
|
@ -670,28 +669,18 @@ public class DataManagementPlanManager {
|
|||
datasetsElement.appendChild(datasetElement);
|
||||
}
|
||||
Element profiles = xmlDoc.createElement("profiles");
|
||||
// Get DatasetProfiles from dmp to add to XML.
|
||||
if (dmp.getAssociatedDmps() != null && !dmp.getAssociatedDmps().isEmpty()) {
|
||||
Document viewStyleDoc = XmlBuilder.fromXml(dmp.getAssociatedDmps());
|
||||
Element item = (Element) viewStyleDoc.getElementsByTagName("profiles").item(0);
|
||||
if (item != null) {
|
||||
NodeList associatedProfilesElement = item.getChildNodes();
|
||||
for (int temp = 0; temp < associatedProfilesElement.getLength(); temp++) {
|
||||
Node associatedProfileElement = associatedProfilesElement.item(temp);
|
||||
if (associatedProfileElement.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element profile = xmlDoc.createElement("profile");
|
||||
Element profileLabel = xmlDoc.createElement("profilelabel");
|
||||
Node labelNode = associatedProfileElement.getAttributes().item(0);
|
||||
profileLabel.setTextContent(labelNode.getNodeValue());
|
||||
profile.appendChild(profileLabel);
|
||||
Element profileId = xmlDoc.createElement("profileId");
|
||||
Node idNode = associatedProfileElement.getAttributes().item(1);
|
||||
profileId.setTextContent(idNode.getNodeValue());
|
||||
profile.appendChild(profileId);
|
||||
profiles.appendChild(profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get DatasetProfiles from DMP to add to XML.
|
||||
for (DatasetProfile datasetProfile : dmp.getAssociatedDmps()) {
|
||||
Element researcherElement = xmlDoc.createElement("researcher");
|
||||
Element profile = xmlDoc.createElement("profile");
|
||||
Element profileLabel = xmlDoc.createElement("profilelabel");
|
||||
profileLabel.setTextContent(datasetProfile.getLabel());
|
||||
profile.appendChild(profileLabel);
|
||||
Element profileId = xmlDoc.createElement("profileId");
|
||||
profileId.setTextContent(datasetProfile.getId().toString());
|
||||
profile.appendChild(profileId);
|
||||
profiles.appendChild(profile);
|
||||
}
|
||||
dmpElement.appendChild(profiles);
|
||||
dmpElement.appendChild(datasetsElement);
|
||||
|
|
|
@ -3,7 +3,6 @@ package eu.eudat.logic.managers;
|
|||
import com.jayway.jsonpath.DocumentContext;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
||||
import eu.eudat.data.dao.entities.DatasetProfileDao;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileAutocompleteRequest;
|
||||
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
||||
|
@ -15,12 +14,14 @@ import eu.eudat.logic.utilities.builders.XmlBuilder;
|
|||
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
||||
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ExportXmlBuilderDatasetProfile;
|
||||
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ImportXmlBuilderDatasetProfile;
|
||||
import eu.eudat.logic.utilities.helpers.StreamHelper;
|
||||
import eu.eudat.models.data.components.commons.datafield.AutoCompleteData;
|
||||
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
|
||||
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
||||
import eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field;
|
||||
import eu.eudat.models.data.helpermodels.Tuple;
|
||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||
import eu.eudat.models.data.security.Principal;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.*;
|
||||
|
@ -31,12 +32,14 @@ import org.w3c.dom.Document;
|
|||
import org.w3c.dom.Element;
|
||||
|
||||
import javax.activation.MimetypesFileTypeMap;
|
||||
import javax.persistence.criteria.Root;
|
||||
import javax.xml.xpath.*;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Component
|
||||
|
@ -188,4 +191,20 @@ public class DatasetProfileManager {
|
|||
throw new DatasetProfileNewVersionException("Version to update not the latest.");
|
||||
}
|
||||
}
|
||||
|
||||
public DataTableData<DatasetProfileListingModel> getDatasetProfilesUsedByDMP(DatasetProfileTableRequestItem datasetProfileTableRequestItem, Principal principal) {
|
||||
|
||||
datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.DMPs.getValue());
|
||||
datasetProfileTableRequestItem.getCriteria().setUserId(principal.getId());
|
||||
|
||||
QueryableList<DatasetProfile> items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria());
|
||||
List<DatasetProfileListingModel> listingModels = items.select(item -> new DatasetProfileListingModel().fromDataModel(item));
|
||||
//listingModels = listingModels.stream().filter(StreamHelper.distinctByKey(DatasetProfileListingModel::getId)).collect(Collectors.toList());
|
||||
|
||||
DataTableData<DatasetProfileListingModel> data = new DataTableData<>();
|
||||
data.setData(listingModels);
|
||||
data.setTotalCount((long) listingModels.size());
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import eu.eudat.models.DataModel;
|
|||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
public class DatasetProfileListingModel implements DataModel<DatasetProfile, DatasetProfileListingModel> {
|
||||
|
||||
private UUID id;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.eudat.models.data.dmp;
|
||||
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.logic.utilities.interfaces.XmlSerializable;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
@ -41,4 +42,17 @@ public class AssociatedProfile implements XmlSerializable<AssociatedProfile> {
|
|||
this.label = item.getAttribute("label");
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public DatasetProfile toData() {
|
||||
DatasetProfile profile = new DatasetProfile();
|
||||
profile.setId(this.id);
|
||||
profile.setLabel(this.label);
|
||||
return profile;
|
||||
}
|
||||
|
||||
public AssociatedProfile fromData(DatasetProfile entity) {
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -206,7 +206,13 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
|||
if (entity.getCreator() != null) this.creator.fromDataModel(entity.getCreator());
|
||||
|
||||
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
||||
Document viewStyleDoc = XmlBuilder.fromXml(entity.getAssociatedDmps());
|
||||
this.profiles = new LinkedList<>();
|
||||
for (DatasetProfile datasetProfile: entity.getAssociatedDmps()) {
|
||||
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(datasetProfile);
|
||||
this.profiles.add(associatedProfile);
|
||||
}
|
||||
|
||||
/*Document viewStyleDoc = XmlBuilder.fromXml(entity.getAssociatedDmps());
|
||||
Element item = (Element) viewStyleDoc.getElementsByTagName("profiles").item(0);
|
||||
this.profiles = new LinkedList<>();
|
||||
if (item != null) {
|
||||
|
@ -248,13 +254,19 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
|||
dataManagementPlanEntity.setStatus((short) this.status);
|
||||
dataManagementPlanEntity.setDescription(this.description);
|
||||
if (this.profiles != null) {
|
||||
Document associatedProfileDoc = XmlBuilder.getDocument();
|
||||
/* Document associatedProfileDoc = XmlBuilder.getDocument();
|
||||
Element associatedProfilesElement = associatedProfileDoc.createElement("profiles");
|
||||
for (AssociatedProfile associatedProfile : this.profiles) {
|
||||
associatedProfilesElement.appendChild(associatedProfile.toXml(associatedProfileDoc));
|
||||
}
|
||||
associatedProfileDoc.appendChild(associatedProfilesElement);
|
||||
dataManagementPlanEntity.setAssociatedDmps(XmlBuilder.generateXml(associatedProfileDoc));
|
||||
dataManagementPlanEntity.setAssociatedDmps(XmlBuilder.generateXml(associatedProfileDoc));*/
|
||||
|
||||
List<DatasetProfile> datasetProfiles = new LinkedList<>();
|
||||
for (AssociatedProfile profile : this.profiles) {
|
||||
datasetProfiles.add(profile.toData());
|
||||
}
|
||||
dataManagementPlanEntity.setAssociatedDmps(datasetProfiles);
|
||||
}
|
||||
dataManagementPlanEntity.setProperties(this.properties != null ? JSONObject.toJSONString(this.properties) : null);
|
||||
dataManagementPlanEntity.setGroupId(this.groupId != null ? this.groupId : UUID.randomUUID());
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.eudat.models.data.dmp;
|
||||
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.data.entities.UserDMP;
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.data.dataset.Dataset;
|
||||
|
@ -175,13 +176,19 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
|
|||
entity.setResearchers(new HashSet<>(this.researchers.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
||||
if (this.project != null) entity.setProject(this.project.toDataModel());
|
||||
if (this.profiles != null) {
|
||||
Document associatedProfileDoc = XmlBuilder.getDocument();
|
||||
/*Document associatedProfileDoc = XmlBuilder.getDocument();
|
||||
Element associatedProfilesElement = associatedProfileDoc.createElement("profiles");
|
||||
for (AssociatedProfile associatedProfile : this.profiles) {
|
||||
associatedProfilesElement.appendChild(associatedProfile.toXml(associatedProfileDoc));
|
||||
}
|
||||
associatedProfileDoc.appendChild(associatedProfilesElement);
|
||||
entity.setAssociatedDmps(XmlBuilder.generateXml(associatedProfileDoc));
|
||||
entity.setAssociatedDmps(XmlBuilder.generateXml(associatedProfileDoc));*/
|
||||
|
||||
List<DatasetProfile> datasetProfiles = new LinkedList<>();
|
||||
for (AssociatedProfile profile : this.profiles) {
|
||||
datasetProfiles.add(profile.toData());
|
||||
}
|
||||
entity.setAssociatedDmps(datasetProfiles);
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.eudat.models.data.listingmodels;
|
||||
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.data.dmp.AssociatedProfile;
|
||||
|
@ -174,7 +175,13 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
|||
this.projectId = entity.getProject().getId().toString();
|
||||
|
||||
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
||||
Document viewStyleDoc = XmlBuilder.fromXml(entity.getAssociatedDmps());
|
||||
this.associatedProfiles = new LinkedList<>();
|
||||
for (DatasetProfile datasetProfile: entity.getAssociatedDmps()) {
|
||||
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(datasetProfile);
|
||||
this.associatedProfiles.add(associatedProfile);
|
||||
}
|
||||
|
||||
/*Document viewStyleDoc = XmlBuilder.fromXml(entity.getAssociatedDmps());
|
||||
Element item = (Element) viewStyleDoc.getElementsByTagName("profiles").item(0);
|
||||
this.associatedProfiles = new LinkedList<>();
|
||||
if (item != null) {
|
||||
|
@ -185,7 +192,7 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
|||
this.associatedProfiles.add(new AssociatedProfile().fromXml((Element) associatedProfileElement));
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
return this;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.eudat.models.data.listingmodels;
|
||||
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.data.dataset.DatasetOverviewModel;
|
||||
|
@ -166,6 +167,13 @@ public class DataManagementPlanOverviewModel implements DataModel<DMP, DataManag
|
|||
this.researchers = entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList());
|
||||
|
||||
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
||||
this.associatedProfiles = new LinkedList<>();
|
||||
for (DatasetProfile datasetProfile : entity.getAssociatedDmps()) {
|
||||
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(datasetProfile);
|
||||
this.associatedProfiles.add(associatedProfile);
|
||||
}
|
||||
}
|
||||
/*if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
||||
Document viewStyleDoc = XmlBuilder.fromXml(entity.getAssociatedDmps());
|
||||
Element item = (Element) viewStyleDoc.getElementsByTagName("profiles").item(0);
|
||||
this.associatedProfiles = new LinkedList<>();
|
||||
|
@ -178,7 +186,7 @@ public class DataManagementPlanOverviewModel implements DataModel<DMP, DataManag
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -10,4 +10,5 @@ export class DmpCriteria extends BaseCriteria {
|
|||
public status?: number;
|
||||
public role?: number;
|
||||
public collaborators?: string[] = [];
|
||||
public datasetTemplates?: string[] = [];
|
||||
}
|
||||
|
|
|
@ -39,6 +39,10 @@ export class DatasetProfileService {
|
|||
return this.http.post<DataTableData<DatasetListingModel>>(this.actionUrl + 'datasetprofiles/getPaged', dataTableRequest);
|
||||
}
|
||||
|
||||
getDatasetProfilesUsedPaged(dataTableRequest: DataTableRequest<DatasetProfileCriteria>) {
|
||||
return this.http.post<DataTableData<DatasetListingModel>>(this.actionUrl + 'datasetprofiles/using/paged', dataTableRequest);
|
||||
}
|
||||
|
||||
preview(data: DatasetProfile): Observable<DatasetProfileDefinitionModel> {
|
||||
return this.http.post<DatasetProfileDefinitionModel>(this.actionUrl + 'preview', data);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,19 @@
|
|||
</div>
|
||||
<!-- End of Visibility Filter-->
|
||||
|
||||
<!-- Related Dataset Templates Filter -->
|
||||
<div *ngIf="showProject" class="col-10 gray-container">
|
||||
<h6 class="category-title">{{ 'CRITERIA.DMP.RELATED-DATASET-TEMPLATES' | translate}}</h6>
|
||||
<mat-form-field>
|
||||
<app-multiple-auto-complete [formControl]="formGroup.get('datasetTemplates')"
|
||||
placeholder="{{ 'CRITERIA.DMP.SELECT-DATASET-TEMPLATES' | translate }}"
|
||||
[configuration]="datasetTemplateAutoCompleteConfiguration">
|
||||
</app-multiple-auto-complete>
|
||||
<mat-icon matSuffix class="style-icon">arrow_drop_down</mat-icon>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<!-- End of Related Dataset Templates Filter -->
|
||||
|
||||
<!-- Related Project Filters -->
|
||||
<div *ngIf="showProject" class="col-10 gray-container">
|
||||
<h6 class="category-title">{{ 'DMP-RELATED-PROJECT.RELATED-PROJECT' | translate}}</h6>
|
||||
|
|
|
@ -17,6 +17,8 @@ import { UserService } from '../../../../core/services/user/user.service';
|
|||
import { MultipleAutoCompleteConfiguration } from '../../../../library/auto-complete/multiple/multiple-auto-complete-configuration';
|
||||
import { BaseCriteriaComponent } from '../../../misc/criteria/base-criteria.component';
|
||||
import { DmpUploadDialogue } from './upload-dialogue/dmp-upload-dialogue.component';
|
||||
import { DatasetProfileCriteria } from '../../../../core/query/dataset-profile/dataset-profile-criteria';
|
||||
import { DatasetProfileService } from '../../../../core/services/dataset-profile/dataset-profile.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dmp-criteria-component',
|
||||
|
@ -39,6 +41,7 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
|
|||
role: new FormControl,
|
||||
organisations: new FormControl(),
|
||||
collaborators: new FormControl(),
|
||||
datasetTemplates: new FormControl()
|
||||
});
|
||||
|
||||
collaboratorsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
||||
|
@ -48,6 +51,13 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
|
|||
titleFn: (item) => item['name']
|
||||
};
|
||||
|
||||
datasetTemplateAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
||||
filterFn: this.filterDatasetTemplate.bind(this),
|
||||
initialItems: (excludedItems: any[]) => this.filterDatasetTemplate('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)),
|
||||
displayFn: (item) => item['label'],
|
||||
titleFn: (item) => item['label']
|
||||
};
|
||||
|
||||
projectAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
||||
filterFn: this.filterProject.bind(this),
|
||||
initialItems: (excludedItems: any[]) => this.filterProject('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)),
|
||||
|
@ -70,6 +80,7 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
|
|||
private dialog: MatDialog,
|
||||
private organisationService: OrganisationService,
|
||||
private userService: UserService,
|
||||
private datasetProfileService: DatasetProfileService
|
||||
) {
|
||||
super(new ValidationErrorModel());
|
||||
}
|
||||
|
@ -94,6 +105,9 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
|
|||
this.formGroup.get('collaborators').valueChanges
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(x => this.controlModified());
|
||||
this.formGroup.get('datasetTemplates').valueChanges
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(x => this.controlModified());
|
||||
//if (this.criteria == null) { this.criteria = new DataManagementPlanCriteria(); }
|
||||
}
|
||||
|
||||
|
@ -103,6 +117,7 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
|
|||
this.formGroup.get('status').patchValue(criteria.status);
|
||||
this.formGroup.get('role').patchValue(criteria.role);
|
||||
this.formGroup.get('collaborators').patchValue(criteria.collaborators);
|
||||
this.formGroup.get('datasetTemplates').patchValue(criteria.datasetTemplates);
|
||||
}
|
||||
|
||||
onCallbackError(error: any) {
|
||||
|
@ -147,6 +162,15 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
|
|||
return this.userService.getCollaboratorsPaged(collaboratorsRequestItem).map(x => x.data);
|
||||
}
|
||||
|
||||
filterDatasetTemplate(query: string) {
|
||||
const fields: Array<string> = new Array<string>();
|
||||
fields.push('asc');
|
||||
const datasetTemplateRequestItem: DataTableRequest<DatasetProfileCriteria> = new DataTableRequest(0, null, { fields: fields });
|
||||
datasetTemplateRequestItem.criteria = new DatasetProfileCriteria();
|
||||
datasetTemplateRequestItem.criteria.like = query;
|
||||
return this.datasetProfileService.getDatasetProfilesUsedPaged(datasetTemplateRequestItem).map(x => x.data);
|
||||
}
|
||||
|
||||
fileSave(event) {
|
||||
const dialogRef = this.dialog.open(DmpUploadDialogue, {
|
||||
data: {
|
||||
|
|
|
@ -109,12 +109,12 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread
|
|||
status: value.status,
|
||||
role: value.role
|
||||
}
|
||||
if (value.collaborators) {
|
||||
request.criteria.collaborators = value.collaborators.map(x => x.id)
|
||||
}
|
||||
if (value.organisations) {
|
||||
request.criteria.organisations = value.organisations.map(x => x.id)
|
||||
}
|
||||
if (value.datasetTemplates)
|
||||
request.criteria.datasetTemplates = value.datasetTemplates.map(x => x.id);
|
||||
if (value.collaborators)
|
||||
request.criteria.collaborators = value.collaborators.map(x => x.id);
|
||||
if (value.organisations)
|
||||
request.criteria.organisations = value.organisations.map(x => x.id);
|
||||
if (this.itemId) {
|
||||
request.criteria.groupIds = [this.itemId];
|
||||
request.criteria.allVersions = true;
|
||||
|
|
|
@ -528,7 +528,9 @@
|
|||
"PROJECTS": "Projects",
|
||||
"SELECT-PROJECTS": "Select Projects",
|
||||
"SELECT-COLLABORATORS": "Select Collaborators",
|
||||
"RELATED-COLLABORATORS": "Related Collaborators"
|
||||
"RELATED-COLLABORATORS": "Related Collaborators",
|
||||
"SELECT-DATASET-TEMPLATES": "Select Dataset Templates",
|
||||
"RELATED-DATASET-TEMPLATES": "Related Dataset Templates"
|
||||
},
|
||||
"USERS": {
|
||||
"LABEL": "Search",
|
||||
|
|
Loading…
Reference in New Issue