Skip to content
Snippets Groups Projects
Commit 9b683fae authored by parkera's avatar parkera
Browse files

SSDM-2161 Change the way the sample codes are automatically generated

SVN: 34360
parent bab7a396
No related branches found
No related tags found
No related merge requests found
...@@ -258,16 +258,38 @@ function ServerFacade(openbisServer) { ...@@ -258,16 +258,38 @@ function ServerFacade(openbisServer) {
// //
// Others //OLD METHOD
// /*this.generateCode = function(sampleType, action) {
this.generateCode = function(sampleType, action) {
this.openbisServer.countNumberOfSamplesForType(sampleType.code, function(response) { this.openbisServer.countNumberOfSamplesForType(sampleType.code, function(response) {
if(response.result || response.result === 0) { if(response.result || response.result === 0) {
action(sampleType.codePrefix + (parseInt(response.result) + 1)); action(sampleType.codePrefix + (parseInt(response.result) + 1));
} }
}); });
} }*/
this.generateCode = function(sampleType, action) {
var prefix = sampleType.codePrefix;
this.searchWithType(
sampleType.code,
"",
function(results) {
if(results.length == 0)
nextcode = prefix + "1";
else{
var codes = [];
for(var idx=0; idx<results.length; idx++){
numeric_code = results[idx].code.substring(3); //assuming all codes are 3 letters long!!!!
numeric_code = numeric_code.replace("_","");
codes[idx] = parseInt(numeric_code);
}
codes.sort();
var nextid = codes[codes.length-1] + 1;
var nextcode = prefix + nextid;
}
action(nextcode);
});
}
this.deleteDataSets = function(datasetIds, reason, callback) { this.deleteDataSets = function(datasetIds, reason, callback) {
this.openbisServer.deleteDataSets(datasetIds, reason, "TRASH", callback); this.openbisServer.deleteDataSets(datasetIds, reason, "TRASH", callback);
} }
......
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