Skip to content
Snippets Groups Projects
Commit ebf0091c authored by juanf's avatar juanf
Browse files

SSDM-6099 : Show only last version of a dataset belonging to a

repository_id or history_id
parent 5b6cdd14
No related branches found
No related tags found
No related merge requests found
......@@ -75,12 +75,8 @@ function DataSetViewerController(containerId, profile, entity, serverFacade, dat
var _this = this;
var datasetPermIds = [];
_this._datasetViewerModel.datasets = datasets; //In case they are loaded after the model is already created.
for(var i = 0; i < datasets.length; i++) { //DataSets for entity
var dataset = datasets[i];
this._datasetViewerModel.entityDataSets[dataset.code] = dataset;
datasetPermIds.push(dataset.code);
datasetPermIds.push(datasets[i].code);
}
require([ "as/dto/dataset/id/DataSetPermId", "as/dto/dataset/fetchoptions/DataSetFetchOptions" ],
......@@ -92,11 +88,71 @@ function DataSetViewerController(containerId, profile, entity, serverFacade, dat
}
var fetchOptions = new DataSetFetchOptions();
fetchOptions.withLinkedData().withExternalDms();
mainController.openbisV3.getDataSets(ids, fetchOptions).done(function(map) {
for(var dIdx = 0; dIdx < datasetPermIds.length; dIdx++) {
_this._datasetViewerModel.v3Datasets.push(map[datasetPermIds[dIdx]]);
fetchOptions.withProperties();
var parentFetchOptions = fetchOptions.withParents();
parentFetchOptions.withLinkedData().withExternalDms();
parentFetchOptions.withProperties();
mainController.openbisV3.getDataSets(ids, fetchOptions).done(function(map) {
var toShow = {
standard : {},
lastVersionOfLinked : {},
lastVersionOfHistory: {}
}
for(var dIdx = 0; dIdx < datasetPermIds.length; dIdx++) {
var dataset = map[datasetPermIds[dIdx]];
if(dataset.linkedData && dataset.linkedData.contentCopies && dataset.linkedData.contentCopies[0]) {
var repositoryId = dataset.linkedData.contentCopies[0].gitRepositoryId;
//console.log("dataset: " + dataset.permId.permId + " repository: " + repositoryId);
var lastInToShow = toShow.lastVersionOfLinked[repositoryId];
if(!lastInToShow || dataset.registrationDate > lastInToShow.registrationDate) {
toShow.lastVersionOfLinked[repositoryId] = dataset;
}
} else if(dataset.properties && dataset.properties["HISTORY_ID"]) {
var historyId = dataset.properties["HISTORY_ID"];
//console.log("dataset: " + dataset.permId.permId + " history: " + historyId);
var lastInToShow = toShow.lastVersionOfHistory[historyId];
if(!lastInToShow || dataset.registrationDate > lastInToShow.registrationDate) {
toShow.lastVersionOfHistory[historyId] = dataset;
}
} else {
//console.log("dataset: " + dataset.permId.permId);
toShow.standard[dataset.permId.permId] = dataset;
}
}
// Rebuild other lists
for(repositoryId in toShow.lastVersionOfLinked) {
var dataset = toShow.lastVersionOfLinked[repositoryId];
toShow.standard[dataset.permId.permId] = dataset;
}
for(historyId in toShow.lastVersionOfHistory) {
var dataset = toShow.lastVersionOfHistory[historyId];
toShow.standard[dataset.permId.permId] = dataset;
}
_this._datasetViewerView.repaintDatasets();
// V3 List
for(datasetId in toShow.standard) {
_this._datasetViewerModel.v3Datasets.push(toShow.standard[datasetId]);
}
// TODO : Legacy list to be removed
var v1Standard = [];
for(var i = 0; i < datasets.length; i++) { //DataSets for entity
var dataset = datasets[i];
if(toShow.standard[dataset.code]) {
_this._datasetViewerModel.entityDataSets[dataset.code] = dataset;
v1Standard.push(dataset);
}
}
// TODO : Legacy list to be removed
_this._datasetViewerModel.datasets = v1Standard; //In case they are loaded after the model is already created.
_this._datasetViewerView.repaintDatasets();
});
});
......
......@@ -100,8 +100,17 @@ function DataSetViewerModel(containerId, profile, entity, serverFacade, datastor
}
this.isLinkDataset = function(datasetCode) {
for(var idx = 0; idx < this.datasets.length; idx++) {
if(this.datasets[idx].code === datasetCode && this.datasets[idx].linkDataSet) {
for(var idx = 0; idx < this.v3Datasets.length; idx++) {
if(this.v3Datasets[idx].code === datasetCode && this.v3Datasets[idx].linkedData) {
return true;
}
}
return false;
}
this.isHistoryDataset = function(datasetCode) {
for(var idx = 0; idx < this.v3Datasets.length; idx++) {
if(this.v3Datasets[idx].code === datasetCode && this.v3Datasets[idx].properties["HISTORY_ID"]) {
return true;
}
}
......@@ -125,10 +134,19 @@ function DataSetViewerModel(containerId, profile, entity, serverFacade, datastor
}
this.getDirectDirectoryLink = function(datasetCode, pathInDataSet) {
var directLinkComponent = null;
var directLinkComponent = "";
var isLinked = false;
if(this.isLinkDataset(datasetCode)) {
directLinkComponent = "<span class='glyphicon glyphicon-link'></span>";
} else if(profile.directLinkEnabled && (profile.cifsFileServer || profile.sftpFileServer)) {
isLinked = true;
}
if(this.isHistoryDataset(datasetCode)) {
directLinkComponent = "<span class='glyphicon glyphicon-time'></span>";
}
if(!isLinked && profile.directLinkEnabled && (profile.cifsFileServer || profile.sftpFileServer)) {
var path = null;
if(this.isExperiment()) {
......@@ -136,8 +154,8 @@ function DataSetViewerModel(containerId, profile, entity, serverFacade, datastor
} else {
path = this.entity.experimentIdentifierOrNull.substring(1) + "/" + datasetCode + "/" + pathInDataSet + "/";
}
directLinkComponent = "<span onclick=\"" + "Util.showDirectLink('" + path + "')" + "\" class='glyphicon glyphicon-hdd'></span>";
directLinkComponent += "<span onclick=\"" + "Util.showDirectLink('" + path + "')" + "\" class='glyphicon glyphicon-hdd'></span>";
}
return directLinkComponent;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment