Adds Templates (Dataset Profiles) on DMP listing.

This commit is contained in:
gkolokythas 2019-04-26 17:08:41 +03:00
parent e591e47736
commit e138b18dc1
3 changed files with 36 additions and 7 deletions

View File

@ -1,12 +1,19 @@
package eu.eudat.models.data.listingmodels;
import eu.eudat.data.entities.DMP;
import eu.eudat.logic.utilities.builders.XmlBuilder;
import eu.eudat.models.DataModel;
import eu.eudat.models.data.dmp.AssociatedProfile;
import eu.eudat.models.data.dmp.Organisation;
import eu.eudat.logic.utilities.helpers.LabelBuilder;
import eu.eudat.models.data.urls.DatasetUrlListing;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
@ -24,6 +31,7 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
private int status;
private UUID groupId;
private List<DatasetUrlListing> datasets;
private List<AssociatedProfile> associatedProfiles;
public String getId() {
return id;
@ -102,6 +110,13 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
this.status = status;
}
public List<AssociatedProfile> getAssociatedProfiles() {
return associatedProfiles;
}
public void setAssociatedProfiles(List<AssociatedProfile> associatedProfiles) {
this.associatedProfiles = associatedProfiles;
}
@Override
public DataManagementPlanListingModel fromDataModel(DMP entity) {
this.id = entity.getId().toString();
@ -120,6 +135,22 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
this.modifiedTime = entity.getModified();
this.organisations = LabelBuilder.getLabel(entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()));
this.datasets = entity.getDataset().stream().map(x-> new DatasetUrlListing().fromDataModel(x)).collect(Collectors.toList());
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<>();
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) {
this.associatedProfiles.add(new AssociatedProfile().fromXml((Element) associatedProfileElement));
}
}
}
}
return this;
}

View File

@ -12,4 +12,5 @@ export interface DmpListingModel {
groupId: string;
version: number;
datasets: any[];
associatedProfiles: any[];
}

View File

@ -9,13 +9,10 @@
</div>
<div class="row d-flex align-items-center my-1">
<mat-icon class="col-auto type-icon">storage</mat-icon>
<h4 class="col-auto m-0 p-0">4</h4>
<div class="col-auto dmp-chip ml-2">TEMPLATE</div>
<div class="col-auto dmp-chip ml-2">TEMPLATE</div>
<div class="col-auto dmp-chip ml-2">TEMPLATE</div>
<div class="col-auto dmp-chip ml-2">TEMPLATE</div>
<div class="col-auto dmp-chip ml-2">TEMPLATE</div>
<div class="col-auto dmp-chip ml-2">TEMPLATE</div>
<h4 class="col-auto m-0 p-0">{{dmp.associatedProfiles.length}}</h4>
<div class="row" *ngFor="let profile of dmp.associatedProfiles">
<div class="col-auto dmp-chip ml-2">{{profile.label}}</div>
</div>
</div>
<div class="row d-flex align-items-center my-1">
<mat-icon class="col-auto type-icon">settings</mat-icon>