diff options
author | mr <mr@mrautenberg.de> | 2011-01-18 17:12:54 +0100 |
---|---|---|
committer | mr <mr@mrautenberg.de> | 2011-01-18 17:12:54 +0100 |
commit | 8da8b742db45faeff56afc5b70d1ca263e4c0bb0 (patch) | |
tree | 7be1bcc6dbe6efcb61a55f03187c8306feeea6c6 /application.rb | |
parent | 318fb6deb86e326c3e6676c493fd8d327f38c1e1 (diff) |
fix javascript
Diffstat (limited to 'application.rb')
-rw-r--r-- | application.rb | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/application.rb b/application.rb index fbd29a9..31bab62 100644 --- a/application.rb +++ b/application.rb @@ -26,6 +26,25 @@ helpers do redirect url_for('/create') end + private + def delete_model(model, subjectid=nil) + begin RestClient.put(File.join(model.task_uri, 'Cancelled'),subjectid) if model.task_uri rescue LOGGER.warn "Can not cancel task #{model.task_uri}" end + delete_dependent(model.uri, subjectid) if model.uri + delete_dependent(model.validation_uri, subjectid) if model.validation_uri + delete_dependent(model.validation_report_uri, subjectid) if model.validation_report_uri + delete_dependent(model.validation_qmrf_uri, subjectid) if model.validation_qmrf_uri + delete_dependent(model.training_dataset, subjectid) if model.training_dataset + delete_dependent(model.feature_dataset, subjectid) if model.feature_dataset + end + + def delete_dependent(uri, subjectid=nil) + begin + RestClient.delete(uri, :subjectid => subjectid) if subjectid + RestClient.delete(uri) if !subjectid + rescue + LOGGER.warn "Can not delete uri: #{uri}" + end + end end before do @@ -234,6 +253,7 @@ post '/models' do # create a new model end post '/predict/?' do # post chemical name to model + subjectid = session[:subjectid] ? session[:subjectid] : nil @identifier = params[:identifier] unless params[:selection] and params[:identifier] != '' flash[:notice] = "Please enter a compound identifier and select an endpoint from the list." @@ -376,8 +396,8 @@ end delete '/model/:id/?' do model = ToxCreateModel.get(params[:id]) begin - RestClient.delete(model.uri, :subjectid => session[:subjectid]) if model.uri - RestClient.delete model.task_uri if model.task_uri + + delete_model(model, session[:subjectid]) model.destroy unless ToxCreateModel.get(params[:id]) begin |