Adds Dataset Profile versioning functionality (Ticket #59)
This commit is contained in:
parent
05a75090e9
commit
aed9d831e9
|
@ -81,13 +81,11 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
||||||
@Column(name = "\"Label\"")
|
@Column(name = "\"Label\"")
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
// @Cascade(value=org.hibernate.annotations.CascadeType.ALL)
|
// @Cascade(value=org.hibernate.annotations.CascadeType.ALL)
|
||||||
@JoinColumn(name = "\"DMP\"", nullable = false)
|
@JoinColumn(name = "\"DMP\"", nullable = false)
|
||||||
private DMP dmp;
|
private DMP dmp;
|
||||||
|
|
||||||
|
|
||||||
@Column(name = "\"Uri\"")
|
@Column(name = "\"Uri\"")
|
||||||
private String uri;
|
private String uri;
|
||||||
|
|
||||||
|
@ -95,7 +93,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
||||||
@Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true)
|
@Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true)
|
||||||
private String properties;
|
private String properties;
|
||||||
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
//@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
|
//@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
|
||||||
@JoinColumn(name = "\"Profile\"", nullable = true)
|
@JoinColumn(name = "\"Profile\"", nullable = true)
|
||||||
|
@ -112,18 +109,15 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
||||||
)
|
)
|
||||||
private Set<Registry> registries;
|
private Set<Registry> registries;
|
||||||
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
|
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||||
private Set<DatasetDataRepository> datasetDataRepositories;
|
private Set<DatasetDataRepository> datasetDataRepositories;
|
||||||
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
|
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||||
private Set<DatasetService> services;
|
private Set<DatasetService> services;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
|
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||||
private Set<DatasetExternalDataset> datasetExternalDatasets;
|
private Set<DatasetExternalDataset> datasetExternalDatasets;
|
||||||
|
|
||||||
|
|
||||||
@Column(name = "\"Status\"", nullable = false)
|
@Column(name = "\"Status\"", nullable = false)
|
||||||
private Short status;
|
private Short status;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ import java.util.UUID;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "\"DatasetProfile\"")
|
@Table(name = "\"DatasetProfile\"")
|
||||||
public class DatasetProfile implements DataEntity<DatasetProfile,UUID> {
|
public class DatasetProfile implements DataEntity<DatasetProfile,UUID>{
|
||||||
|
|
||||||
public enum Status {
|
public enum Status {
|
||||||
SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99);
|
SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99);
|
||||||
|
@ -142,7 +142,7 @@ public class DatasetProfile implements DataEntity<DatasetProfile,UUID> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "DatasetProfileListingModel [id=" + id + ", label=" + label + ", dataset=" + dataset + ", definition=" + definition + "]";
|
return "DatasetProfileListingModel [id=" + id + ", label=" + label + ", dataset=" + dataset + ", definition=" + definition + ", version=" + version + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -194,4 +194,11 @@ public class DatasetWizardController extends BaseController {
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message("Import was unsuccessful."));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message("Import was unsuccessful."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.GET, value = {"profile/{id}"}, produces = "application/json")
|
||||||
|
public @ResponseBody
|
||||||
|
ResponseEntity getSingleProfileUpdate(@PathVariable String id, @ClaimedAuthorities(claims = {ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException {
|
||||||
|
DatasetWizardModel dataset = this.datasetManager.datasetUpdateProfile(id);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package eu.eudat.logic.managers;
|
package eu.eudat.logic.managers;
|
||||||
|
|
||||||
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
import eu.eudat.data.dao.criteria.*;
|
||||||
import eu.eudat.data.dao.criteria.ExternalDatasetCriteria;
|
|
||||||
import eu.eudat.data.dao.criteria.RegistryCriteria;
|
|
||||||
import eu.eudat.data.dao.criteria.ServiceCriteria;
|
|
||||||
import eu.eudat.data.dao.entities.*;
|
import eu.eudat.data.dao.entities.*;
|
||||||
import eu.eudat.data.entities.*;
|
import eu.eudat.data.entities.*;
|
||||||
import eu.eudat.data.query.items.table.dataset.DatasetPublicTableRequest;
|
import eu.eudat.data.query.items.table.dataset.DatasetPublicTableRequest;
|
||||||
|
@ -22,6 +19,7 @@ import eu.eudat.logic.utilities.documents.xml.ExportXmlBuilder;
|
||||||
import eu.eudat.models.HintedModelFactory;
|
import eu.eudat.models.HintedModelFactory;
|
||||||
import eu.eudat.models.data.datasetImport.*;
|
import eu.eudat.models.data.datasetImport.*;
|
||||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||||
|
import eu.eudat.models.data.dmp.AssociatedProfile;
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
||||||
import eu.eudat.models.data.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
|
@ -168,6 +166,44 @@ public class DatasetManager {
|
||||||
}
|
}
|
||||||
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity));
|
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity));
|
||||||
dataset.fromDataModel(datasetEntity);
|
dataset.fromDataModel(datasetEntity);
|
||||||
|
|
||||||
|
// Creates the Criteria to get all version of DatasetProfile in question.
|
||||||
|
DatasetProfileCriteria profileCriteria = new DatasetProfileCriteria();
|
||||||
|
UUID profileId = datasetEntity.getProfile().getGroupId();
|
||||||
|
List<UUID> uuidList = new LinkedList<>();
|
||||||
|
uuidList.add(profileId);
|
||||||
|
profileCriteria.setGroupIds(uuidList);
|
||||||
|
profileCriteria.setAllVersions(true);
|
||||||
|
List<eu.eudat.data.entities.DatasetProfile> items = databaseRepository.getDatasetProfileDao().getWithCriteria(profileCriteria)
|
||||||
|
.orderBy(((builder, root) -> builder.asc(root.get("version"))))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
// Search if the Dataset needs dataset Profile update depending on his DMP associated profiles.
|
||||||
|
AssociatedProfile associatedProfile = new AssociatedProfile();
|
||||||
|
boolean y = true;
|
||||||
|
// Start the Dataset Profile List from the latest to the earliest.
|
||||||
|
for (int x=(items.size()-1); x>=0; x--) {
|
||||||
|
associatedProfile.setId(items.get(x).getId());
|
||||||
|
// Check if Dmp contains this profile.
|
||||||
|
for(AssociatedProfile p : dataset.getDmp().getProfiles() ) {
|
||||||
|
if (p.getId().toString().equals(associatedProfile.getId().toString())) {
|
||||||
|
Short latestVersion = items.get(x).getVersion();
|
||||||
|
if (latestVersion.equals(datasetEntity.getProfile().getVersion())) {
|
||||||
|
dataset.setIsProfileLatestVersion(true);
|
||||||
|
y = false;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
dataset.setIsProfileLatestVersion(false);
|
||||||
|
y = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!y){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dataset.setTags(datasetElastic.getTags());
|
dataset.setTags(datasetElastic.getTags());
|
||||||
return dataset;
|
return dataset;
|
||||||
}
|
}
|
||||||
|
@ -255,7 +291,7 @@ public class DatasetManager {
|
||||||
HttpEntity<LinkedMultiValueMap<String, Object>> requestEntity = new HttpEntity<LinkedMultiValueMap<String, Object>>(
|
HttpEntity<LinkedMultiValueMap<String, Object>> requestEntity = new HttpEntity<LinkedMultiValueMap<String, Object>>(
|
||||||
map, headers);
|
map, headers);
|
||||||
|
|
||||||
byte[] queueResult = new RestTemplate().postForObject("http://localhost:3000/convert/office"
|
byte[] queueResult = new RestTemplate().postForObject(environment.getProperty("pdf.converter.url") + "convert/office"
|
||||||
, requestEntity, byte[].class);
|
, requestEntity, byte[].class);
|
||||||
|
|
||||||
File resultPdf = new File(environment.getProperty("configuration.exportUrl") + label + ".pdf");
|
File resultPdf = new File(environment.getProperty("configuration.exportUrl") + label + ".pdf");
|
||||||
|
@ -496,4 +532,51 @@ public class DatasetManager {
|
||||||
// TODO: When tags functionality return.
|
// TODO: When tags functionality return.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DatasetWizardModel datasetUpdateProfile(String id) {
|
||||||
|
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||||
|
eu.eudat.data.entities.Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||||
|
eu.eudat.elastic.entities.Dataset datasetElastic;
|
||||||
|
try{
|
||||||
|
datasetElastic = datasetRepository.exists() ?
|
||||||
|
datasetRepository.findDocument(id) : new eu.eudat.elastic.entities.Dataset();
|
||||||
|
}
|
||||||
|
catch (Exception ex){
|
||||||
|
datasetElastic = new eu.eudat.elastic.entities.Dataset();
|
||||||
|
}
|
||||||
|
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity));
|
||||||
|
dataset.fromDataModel(datasetEntity);
|
||||||
|
|
||||||
|
// Creates the Criteria to get all version of DatasetProfile in question.
|
||||||
|
DatasetProfileCriteria profileCriteria = new DatasetProfileCriteria();
|
||||||
|
UUID profileId = datasetEntity.getProfile().getGroupId();
|
||||||
|
List<UUID> uuidList = new LinkedList<>();
|
||||||
|
uuidList.add(profileId);
|
||||||
|
profileCriteria.setGroupIds(uuidList);
|
||||||
|
|
||||||
|
// Gets the latest version of the datasetProfile.
|
||||||
|
eu.eudat.data.entities.DatasetProfile item = databaseRepository.getDatasetProfileDao().getWithCriteria(profileCriteria).getSingle();
|
||||||
|
|
||||||
|
// Sets the latest version of dataet Profile to the Dataset in question.
|
||||||
|
dataset.setDatasetProfileDefinition(getLatestDatasetProfile(datasetEntity, item));
|
||||||
|
dataset.setProfile(item.getId());
|
||||||
|
|
||||||
|
// Now at latest version.
|
||||||
|
dataset.setIsProfileLatestVersion(true);
|
||||||
|
|
||||||
|
dataset.setTags(datasetElastic.getTags());
|
||||||
|
return dataset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PagedDatasetProfile getLatestDatasetProfile(Dataset datasetEntity, DatasetProfile profile) {
|
||||||
|
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(profile);
|
||||||
|
datasetprofile.setStatus(datasetEntity.getStatus());
|
||||||
|
if (datasetEntity.getProperties() != null) {
|
||||||
|
JSONObject jobject = new JSONObject(datasetEntity.getProperties());
|
||||||
|
Map<String, Object> properties = jobject.toMap();
|
||||||
|
datasetprofile.fromJsonObject(properties);
|
||||||
|
}
|
||||||
|
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
|
||||||
|
pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile);
|
||||||
|
return pagedDatasetProfile;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,11 +33,11 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
||||||
private List<Tag> tags;
|
private List<Tag> tags;
|
||||||
private List<ExternalDatasetListingModel> externalDatasets;
|
private List<ExternalDatasetListingModel> externalDatasets;
|
||||||
private UUID profile;
|
private UUID profile;
|
||||||
|
private Boolean isProfileLatestVersion;
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(UUID id) {
|
public void setId(UUID id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,6 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLabel(String label) {
|
public void setLabel(String label) {
|
||||||
this.label = label;
|
this.label = label;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +52,6 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
||||||
public String getReference() {
|
public String getReference() {
|
||||||
return reference;
|
return reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReference(String reference) {
|
public void setReference(String reference) {
|
||||||
this.reference = reference;
|
this.reference = reference;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +59,6 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
||||||
public String getUri() {
|
public String getUri() {
|
||||||
return uri;
|
return uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUri(String uri) {
|
public void setUri(String uri) {
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +66,6 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(String description) {
|
public void setDescription(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +73,6 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
||||||
public short getStatus() {
|
public short getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatus(short status) {
|
public void setStatus(short status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +80,6 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
||||||
public Date getCreated() {
|
public Date getCreated() {
|
||||||
return created;
|
return created;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreated(Date created) {
|
public void setCreated(Date created) {
|
||||||
this.created = created;
|
this.created = created;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +87,6 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
||||||
public DataManagementPlan getDmp() {
|
public DataManagementPlan getDmp() {
|
||||||
return dmp;
|
return dmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDmp(DataManagementPlan dmp) {
|
public void setDmp(DataManagementPlan dmp) {
|
||||||
this.dmp = dmp;
|
this.dmp = dmp;
|
||||||
}
|
}
|
||||||
|
@ -101,7 +94,6 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
||||||
public PagedDatasetProfile getDatasetProfileDefinition() {
|
public PagedDatasetProfile getDatasetProfileDefinition() {
|
||||||
return datasetProfileDefinition;
|
return datasetProfileDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDatasetProfileDefinition(PagedDatasetProfile datasetProfileDefinition) {
|
public void setDatasetProfileDefinition(PagedDatasetProfile datasetProfileDefinition) {
|
||||||
this.datasetProfileDefinition = datasetProfileDefinition;
|
this.datasetProfileDefinition = datasetProfileDefinition;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +101,6 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
||||||
public List<Registry> getRegistries() {
|
public List<Registry> getRegistries() {
|
||||||
return registries;
|
return registries;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRegistries(List<Registry> registries) {
|
public void setRegistries(List<Registry> registries) {
|
||||||
this.registries = registries;
|
this.registries = registries;
|
||||||
}
|
}
|
||||||
|
@ -117,7 +108,6 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
||||||
public List<Service> getServices() {
|
public List<Service> getServices() {
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setServices(List<Service> services) {
|
public void setServices(List<Service> services) {
|
||||||
this.services = services;
|
this.services = services;
|
||||||
}
|
}
|
||||||
|
@ -125,7 +115,6 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
||||||
public List<DataRepository> getDataRepositories() {
|
public List<DataRepository> getDataRepositories() {
|
||||||
return dataRepositories;
|
return dataRepositories;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDataRepositories(List<DataRepository> dataRepositories) {
|
public void setDataRepositories(List<DataRepository> dataRepositories) {
|
||||||
this.dataRepositories = dataRepositories;
|
this.dataRepositories = dataRepositories;
|
||||||
}
|
}
|
||||||
|
@ -133,7 +122,6 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
||||||
public UUID getProfile() {
|
public UUID getProfile() {
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProfile(UUID profile) {
|
public void setProfile(UUID profile) {
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +129,6 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
||||||
public List<ExternalDatasetListingModel> getExternalDatasets() {
|
public List<ExternalDatasetListingModel> getExternalDatasets() {
|
||||||
return externalDatasets;
|
return externalDatasets;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExternalDatasets(List<ExternalDatasetListingModel> externalDatasets) {
|
public void setExternalDatasets(List<ExternalDatasetListingModel> externalDatasets) {
|
||||||
this.externalDatasets = externalDatasets;
|
this.externalDatasets = externalDatasets;
|
||||||
}
|
}
|
||||||
|
@ -149,11 +136,17 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
||||||
public List<Tag> getTags() {
|
public List<Tag> getTags() {
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTags(List<Tag> tags) {
|
public void setTags(List<Tag> tags) {
|
||||||
this.tags = tags;
|
this.tags = tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getIsProfileLatestVersion() {
|
||||||
|
return isProfileLatestVersion;
|
||||||
|
}
|
||||||
|
public void setIsProfileLatestVersion(Boolean profileLatestVersion) {
|
||||||
|
isProfileLatestVersion = profileLatestVersion;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatasetWizardModel fromDataModel(Dataset entity) {
|
public DatasetWizardModel fromDataModel(Dataset entity) {
|
||||||
this.id = entity.getId();
|
this.id = entity.getId();
|
||||||
|
@ -178,7 +171,7 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
||||||
this.dmp = new DataManagementPlan().fromDataModel(entity.getDmp());
|
this.dmp = new DataManagementPlan().fromDataModel(entity.getDmp());
|
||||||
this.externalDatasets = entity.getDatasetExternalDatasets().stream().map(item -> {
|
this.externalDatasets = entity.getDatasetExternalDatasets().stream().map(item -> {
|
||||||
ExternalDatasetListingModel externalDatasetListingModel = new ExternalDatasetListingModel().fromDataModel(item.getExternalDataset());
|
ExternalDatasetListingModel externalDatasetListingModel = new ExternalDatasetListingModel().fromDataModel(item.getExternalDataset());
|
||||||
if(item.getData()!=null) {
|
if(item.getData()!= null) {
|
||||||
Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
||||||
Map<String, String> values = data.get("data");
|
Map<String, String> values = data.get("data");
|
||||||
externalDatasetListingModel.setInfo(values.get("info"));
|
externalDatasetListingModel.setInfo(values.get("info"));
|
||||||
|
|
|
@ -21,4 +21,5 @@ export interface DatasetWizardModel {
|
||||||
tags?: TagModel[];
|
tags?: TagModel[];
|
||||||
externalDatasets?: ExternalDatasetModel[];
|
externalDatasets?: ExternalDatasetModel[];
|
||||||
profile?: DatasetProfileModel;
|
profile?: DatasetProfileModel;
|
||||||
|
isProfileLatestVersion?: Boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,4 +88,8 @@ export class DatasetWizardService {
|
||||||
};
|
};
|
||||||
return this.http.post(this.actionUrl + 'upload', formData, { params: params });
|
return this.http.post(this.actionUrl + 'upload', formData, { params: params });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public updateDatasetProfile(id: String): Observable<DatasetWizardModel> {
|
||||||
|
return this.http.get<DatasetWizardModel>(this.actionUrl + "profile/"+ id, { headers: this.headers });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ export class DatasetWizardEditorModel {
|
||||||
public dmp: DmpModel;
|
public dmp: DmpModel;
|
||||||
public datasetProfileDefinition: DatasetDescriptionFormEditorModel;
|
public datasetProfileDefinition: DatasetDescriptionFormEditorModel;
|
||||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
|
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
|
||||||
|
public isProfileLatestVersion: Boolean;
|
||||||
|
|
||||||
fromModel(item: DatasetWizardModel): DatasetWizardEditorModel {
|
fromModel(item: DatasetWizardModel): DatasetWizardEditorModel {
|
||||||
this.id = item.id;
|
this.id = item.id;
|
||||||
|
@ -41,9 +42,9 @@ export class DatasetWizardEditorModel {
|
||||||
if (item.dataRepositories) { this.dataRepositories = item.dataRepositories.map(x => new ExternalDataRepositoryEditorModel().fromModel(x)); }
|
if (item.dataRepositories) { this.dataRepositories = item.dataRepositories.map(x => new ExternalDataRepositoryEditorModel().fromModel(x)); }
|
||||||
if (item.externalDatasets) { this.externalDatasets = item.externalDatasets.map(x => new ExternalDatasetEditorModel().fromModel(x)); }
|
if (item.externalDatasets) { this.externalDatasets = item.externalDatasets.map(x => new ExternalDatasetEditorModel().fromModel(x)); }
|
||||||
this.dmp = item.dmp;
|
this.dmp = item.dmp;
|
||||||
this.profile = item.profile;
|
|
||||||
if (item.datasetProfileDefinition) { this.datasetProfileDefinition = new DatasetDescriptionFormEditorModel().fromModel(item.datasetProfileDefinition); }
|
if (item.datasetProfileDefinition) { this.datasetProfileDefinition = new DatasetDescriptionFormEditorModel().fromModel(item.datasetProfileDefinition); }
|
||||||
this.tags = item.tags;
|
this.tags = item.tags;
|
||||||
|
this.isProfileLatestVersion = item.isProfileLatestVersion;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,4 +322,4 @@ export class ExternalDataRepositoryEditorModel {
|
||||||
// name: [this.name]
|
// name: [this.name]
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -41,7 +41,10 @@
|
||||||
(click)="downloadDOCX();" type="button">{{ 'DATASET-WIZARD.ACTIONS.DOWNLOAD-DOCX' | translate }}</button>
|
(click)="downloadDOCX();" type="button">{{ 'DATASET-WIZARD.ACTIONS.DOWNLOAD-DOCX' | translate }}</button>
|
||||||
<button mat-raised-button color="primary" *ngIf="datasetWizardModel&&datasetWizardModel?.status == 1" class="downloadXML"
|
<button mat-raised-button color="primary" *ngIf="datasetWizardModel&&datasetWizardModel?.status == 1" class="downloadXML"
|
||||||
(click)="downloadXML();" type="button">{{ 'DATASET-WIZARD.ACTIONS.DOWNLOAD-XML' | translate }}</button>
|
(click)="downloadXML();" type="button">{{ 'DATASET-WIZARD.ACTIONS.DOWNLOAD-XML' | translate }}</button>
|
||||||
|
<button mat-raised-button color="primary" *ngIf="needsUpdate()" class="updateDatasetProfile" (click)="openUpdateDatasetProfileDialogue();"
|
||||||
|
type="button">{{ 'DATASET-WIZARD.ACTIONS.UPDATE-DATASET-PROFILE' | translate }}</button>
|
||||||
<div class="fill-space"></div>
|
<div class="fill-space"></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<mat-horizontal-stepper [linear]="isLinear" class="col-12" #stepper>
|
<mat-horizontal-stepper [linear]="isLinear" class="col-12" #stepper>
|
||||||
|
|
|
@ -39,4 +39,9 @@
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
margin-right: 15px;
|
margin-right: 15px;
|
||||||
}
|
}
|
||||||
|
.updateDatasetProfile {
|
||||||
|
margin-top: 15px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
margin-right: 15px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
||||||
availableProfiles: DatasetProfileModel[] = [];
|
availableProfiles: DatasetProfileModel[] = [];
|
||||||
itemId: string;
|
itemId: string;
|
||||||
publicId: string;
|
publicId: string;
|
||||||
|
profileUpdateId: string;
|
||||||
downloadDocumentId: string;
|
downloadDocumentId: string;
|
||||||
isLinear = false;
|
isLinear = false;
|
||||||
|
|
||||||
|
@ -121,6 +122,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
||||||
const dmpId = params['dmpId'];
|
const dmpId = params['dmpId'];
|
||||||
const newDmpId = queryParams['newDmpId'];
|
const newDmpId = queryParams['newDmpId'];
|
||||||
this.publicId = params['publicId'];
|
this.publicId = params['publicId'];
|
||||||
|
this.profileUpdateId = params['updateId'];
|
||||||
|
|
||||||
this.itemId ? this.downloadDocumentId = this.itemId : this.downloadDocumentId = this.publicId
|
this.itemId ? this.downloadDocumentId = this.itemId : this.downloadDocumentId = this.publicId
|
||||||
|
|
||||||
|
@ -130,6 +132,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(data => {
|
.subscribe(data => {
|
||||||
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
|
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
|
||||||
|
this.needsUpdate();
|
||||||
this.breadCrumbs = Observable.of([
|
this.breadCrumbs = Observable.of([
|
||||||
{
|
{
|
||||||
parentComponentName: null,
|
parentComponentName: null,
|
||||||
|
@ -274,8 +277,40 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.publicMode = true;
|
this.publicMode = true;
|
||||||
}
|
} else if (this.profileUpdateId != null) {
|
||||||
else {
|
this.datasetWizardService.updateDatasetProfile(this.profileUpdateId)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(data => {
|
||||||
|
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
|
||||||
|
this.needsUpdate();
|
||||||
|
this.breadCrumbs = Observable.of([
|
||||||
|
{
|
||||||
|
parentComponentName: null,
|
||||||
|
label: 'Datasets',
|
||||||
|
url: '/datasets',
|
||||||
|
notFoundResolver: [
|
||||||
|
{
|
||||||
|
parentComponentName: null,
|
||||||
|
label: this.datasetWizardModel.dmp.project.label,
|
||||||
|
url: '/projects/edit/' + this.datasetWizardModel.dmp.project.id
|
||||||
|
},
|
||||||
|
{
|
||||||
|
parentComponentName: null,
|
||||||
|
label: this.datasetWizardModel.dmp.label,
|
||||||
|
url: '/plans/edit/' + this.datasetWizardModel.dmp.id,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}]);
|
||||||
|
this.formGroup = this.datasetWizardModel.buildForm();
|
||||||
|
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
|
||||||
|
if (this.datasetWizardModel.status === 1) {
|
||||||
|
this.formGroup.disable();
|
||||||
|
this.viewOnly = true;
|
||||||
|
}
|
||||||
|
// if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP.
|
||||||
|
this.loadDatasetProfiles();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
this.datasetWizardModel = new DatasetWizardEditorModel();
|
this.datasetWizardModel = new DatasetWizardEditorModel();
|
||||||
this.formGroup = this.datasetWizardModel.buildForm();
|
this.formGroup = this.datasetWizardModel.buildForm();
|
||||||
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
|
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
|
||||||
|
@ -535,4 +570,30 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
needsUpdate() {
|
||||||
|
if (this.datasetWizardModel.isProfileLatestVersion) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
openUpdateDatasetProfileDialogue() {
|
||||||
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||||
|
data: {
|
||||||
|
message: this.language.instant('DATASET-EDITOR.VERSION-DIALOG.QUESTION'),
|
||||||
|
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'),
|
||||||
|
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||||
|
if (result) {
|
||||||
|
this.profileUpdateId = this.itemId;
|
||||||
|
this.uiNotificationService.snackBarNotification("Profile changed, WOW!", SnackBarNotificationLevel.Success);
|
||||||
|
this.router.navigate(['/datasets/profileupdate/' + this.profileUpdateId]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,6 @@ const routes: Routes = [
|
||||||
breadcrumb: true
|
breadcrumb: true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
path: 'copy/:id',
|
path: 'copy/:id',
|
||||||
component: DatasetWizardComponent,
|
component: DatasetWizardComponent,
|
||||||
|
@ -62,6 +61,14 @@ const routes: Routes = [
|
||||||
data: {
|
data: {
|
||||||
breadcrumb: true
|
breadcrumb: true
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'profileupdate/:updateId',
|
||||||
|
component: DatasetWizardComponent,
|
||||||
|
canActivate: [AuthGuard],
|
||||||
|
data: {
|
||||||
|
breadcrumb: true
|
||||||
|
},
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -121,8 +121,8 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O
|
||||||
this.datasetWizardService.uploadXml(result.fileList, result.datasetTitle, result.dmpId, result.datasetProfileId)
|
this.datasetWizardService.uploadXml(result.fileList, result.datasetTitle, result.dmpId, result.datasetProfileId)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
complete => this.onCallbackSuccess(),
|
complete => this.onCallbackSuccess(),
|
||||||
error => this.onCallbackError(error)
|
error => this.onCallbackError(error)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -258,7 +258,8 @@
|
||||||
"DOWNLOAD-PDF": "Download PDF",
|
"DOWNLOAD-PDF": "Download PDF",
|
||||||
"DOWNLOAD-XML": "Download XML",
|
"DOWNLOAD-XML": "Download XML",
|
||||||
"DOWNLOAD-DOCX": "Download DOCX",
|
"DOWNLOAD-DOCX": "Download DOCX",
|
||||||
"COPY-DATASET": "Copy Dataset"
|
"COPY-DATASET": "Copy Dataset",
|
||||||
|
"UPDATE-DATASET-PROFILE": "Update Profile"
|
||||||
},
|
},
|
||||||
"UPLOAD": {
|
"UPLOAD": {
|
||||||
"UPLOAD-XML": "Import",
|
"UPLOAD-XML": "Import",
|
||||||
|
@ -493,6 +494,9 @@
|
||||||
"SAVE": "Save",
|
"SAVE": "Save",
|
||||||
"CANCEL": "Cancel",
|
"CANCEL": "Cancel",
|
||||||
"DELETE": "Delete"
|
"DELETE": "Delete"
|
||||||
|
},
|
||||||
|
"VERSION-DIALOG": {
|
||||||
|
"QUESTION": "It seems your Dataset Profile is outdated. Do you want to update it to the latest version?"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"DATASET-CREATE-WIZARD": {
|
"DATASET-CREATE-WIZARD": {
|
||||||
|
|
Loading…
Reference in New Issue