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

SSDM-2597 : Delete works again for samples, now using v3 API.

SVN: 37292
parent 081589fd
No related branches found
No related tags found
No related merge requests found
...@@ -362,8 +362,33 @@ function ServerFacade(openbisServer) { ...@@ -362,8 +362,33 @@ function ServerFacade(openbisServer) {
this.openbisServer.deleteDataSets(datasetIds, reason, "TRASH", callback); this.openbisServer.deleteDataSets(datasetIds, reason, "TRASH", callback);
} }
this.deleteSamples = function(sampleIds, reason, callback) { this.deleteSamples = function(samplePermIds, reason, callback) {
this.openbisServer.deleteSamples(sampleIds, reason, "TRASH", callback); require([ 'openbis', "as/dto/sample/id/SamplePermId", "as/dto/sample/delete/SampleDeletionOptions" ],
function(openbis, SamplePermId, SampleDeletionOptions) {
//Boilerplate
var testProtocol = window.location.protocol;
var testHost = window.location.hostname;
var testPort = window.location.port;
var testUrl = testProtocol + "//" + testHost + ":" + testPort;
var testApiUrl = testUrl + "/openbis/openbis/rmi-application-server-v3.json";
var v3Api = new openbis(testApiUrl);
v3Api._private.sessionToken = mainController.serverFacade.getSession();
var samplePermIdsObj = [];
for(var sPIdx = 0; sPIdx < samplePermIds.length; sPIdx++) {
samplePermIdsObj.push(new SamplePermId(samplePermIds[sPIdx]));
}
var deletionOptions = new SampleDeletionOptions();
deletionOptions.setReason(reason);
// logical deletion (move objects to the trash can)
v3Api.deleteSamples(samplePermIdsObj, deletionOptions).done(function(deletionId) {
callback(deletionId);
});
});
} }
this.deleteExperiments = function(experimentIds, reason, callback) { this.deleteExperiments = function(experimentIds, reason, callback) {
......
...@@ -81,14 +81,14 @@ function SampleTableController(parentController, title, experimentIdentifier, pr ...@@ -81,14 +81,14 @@ function SampleTableController(parentController, title, experimentIdentifier, pr
Util.showError("Please select at least one sample to delete!"); Util.showError("Please select at least one sample to delete!");
} else { } else {
var warningText = "The next " + ELNDictionary.samples + " will be deleted: "; var warningText = "The next " + ELNDictionary.samples + " will be deleted: ";
var sampleTechIds = []; var samplePermIds = [];
for(var sIdx = 0; sIdx < selected.length; sIdx++) { for(var sIdx = 0; sIdx < selected.length; sIdx++) {
sampleTechIds.push(selected[sIdx].id); samplePermIds.push(selected[sIdx].permId);
warningText += selected[sIdx].identifier + " "; warningText += selected[sIdx].identifier + " ";
} }
var modalView = new DeleteEntityController(function(reason) { var modalView = new DeleteEntityController(function(reason) {
mainController.serverFacade.deleteSamples(sampleTechIds, reason, function(data) { mainController.serverFacade.deleteSamples(samplePermIds, reason, function(data) {
if(data.error) { if(data.error) {
Util.showError(data.error.message); Util.showError(data.error.message);
} else { } else {
......
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