From: Sungmin Kim Date: Mon, 3 Feb 2014 07:06:10 +0000 (+0900) Subject: fixed remove distribution that has dependency. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a883db97f9e58e9204bb1acdae7affe042a6851b;p=sdk%2Ftools%2Fsdk-build.git fixed remove distribution that has dependency. Signed-off-by: Sungmin Kim Change-Id: Iac995325124e8300c1e275f1080837c24099d824 --- diff --git a/dibs-web/app/controllers/admin_distribution_controller.rb b/dibs-web/app/controllers/admin_distribution_controller.rb index 10d51ed..eb1b354 100644 --- a/dibs-web/app/controllers/admin_distribution_controller.rb +++ b/dibs-web/app/controllers/admin_distribution_controller.rb @@ -157,12 +157,9 @@ class AdminDistributionController < ApplicationController jobs = Job.find(:all, :conditions => ["distribution_id = ?", dist.id]) if not jobs.nil? then - # remove job_timestamps table jobs.each do |job| - jobTimestamp = JobTimestamp.delete_all(["job_id=?", job.id]) - job.destroy + AdminProjectController.removeJob(job.id) end - end # remove distribution diff --git a/dibs-web/app/controllers/admin_project_controller.rb b/dibs-web/app/controllers/admin_project_controller.rb index 17a49ca..214a0b9 100644 --- a/dibs-web/app/controllers/admin_project_controller.rb +++ b/dibs-web/app/controllers/admin_project_controller.rb @@ -193,7 +193,7 @@ class AdminProjectController < ApplicationController project_id = change_item[:ProjectId] - err = remove_project(project_id) + err = AdminProjectController.remove_project(project_id) if err then render :json => { :error => err}, :status => 406 else @@ -213,27 +213,34 @@ class AdminProjectController < ApplicationController jobs = Job.find(:all, :conditions => ["project_id =?", project_id]) if not jobs.nil? then - # remove job_timestamps table jobs.each do |job| - jobTimestamp = JobTimestamp.delete_all(["job_id=?", job.id]) - job.destroy + AdminProjectController.removeJob(job.id) end - end - case project.ptype - when "GIT" - # remove source info - sources = Source.find(:all, :conditions => ["project_id = ?", project_id]) - - if not sources.nil? then + # remove source info + sources = Source.find(:all, :conditions => ["project_id = ?", project_id]) + if not sources.nil? then + sources.each do |source| # remove package - sources.each do |source| - Package.delete_all(["source_id = ?", source.id]) - source.destroy + Package.delete_all(["source_id = ?", source.id]) + + # remove job info (If sync job ,project_id is empty in jobs) + jobs = Job.find(:all, :conditions => ["source_id =?", source.id]) + if not jobs.nil? then + jobs.each do |job| + AdminProjectController.removeJob(job.id) + end end + + source.destroy end + + end + # remove sub-project table + case project.ptype + when "GIT" ProjectGit.delete_all(["project_id = ?", project_id]) ProjectOs.delete_all(["project_id = ?", project_id]) GroupProjectAccess.delete_all(["project_id = ?", project_id]) @@ -255,6 +262,19 @@ class AdminProjectController < ApplicationController return end + def AdminProjectController.removeJob(id) + job = Job.find(id) + + # remove child job + children_job = Job.find(:all, :conditions => ["parent_job_id = ?", job.id]) + children_job.each do |child_job| + AdminProjectController.removeJob(child_job.id) + end + + JobTimestamp.delete_all(["job_id=?", job.id]) + job.destroy + end + def modifyProject change_group_list = params[:ChangeInfoList] change_item = change_group_list[0] diff --git a/dibs-web/app/controllers/admin_server_controller.rb b/dibs-web/app/controllers/admin_server_controller.rb index aa55578..5136382 100644 --- a/dibs-web/app/controllers/admin_server_controller.rb +++ b/dibs-web/app/controllers/admin_server_controller.rb @@ -244,13 +244,27 @@ class AdminServerController < ApplicationController server = RemoteBuildServer.find(:first, :conditions => ["id = ?", id]) - if server.nil? + if server.nil? then errmsg = "Server does not exist" render :json => { :error => errmsg }, :status => 406 - else - server.destroy - render :json => { :success => "OK!" } - end + return + end + + # remove job info + jobs = Job.find(:all, :conditions => ["remote_build_server_id=?", id]) + + if not jobs.nil? then + # remove job_timestamps table + jobs.each do |job| + jobTimestamp = JobTimestamp.delete_all(["job_id=?", job.id]) + job.destroy + end + + end + + server.destroy + render :json => { :success => "OK!" } + end def addOSCategory diff --git a/dibs-web/public/javascripts/dibs-api.js b/dibs-web/public/javascripts/dibs-api.js index fd324b7..70d601e 100644 --- a/dibs-web/public/javascripts/dibs-api.js +++ b/dibs-web/public/javascripts/dibs-api.js @@ -332,7 +332,7 @@ function getInfoFromServerData(url, data, successFunction) { dataType: 'xml', text: 'JSONP', data: data, - timeout: 10000, + timeout: 300000, success: function(xml) { setSessionInfo(xml); successFunction(xml); @@ -350,9 +350,9 @@ function postForServer(url, changeInfoList, successFunction) { data: JSON.stringify({ ChangeInfoList: changeInfoList }), dataType: 'json', contentType: "application/json; charset=utf-8", - timeout: 10000, + timeout: 3600000, beforeSend: function() { $.mobile.showPageLoadingMsg(); }, //Show spinner - complete: function() { $.mobile.hidePageLoadingMsg() }, //Hide spinner + complete: function() { $.mobile.hidePageLoadingMsg(); }, //Hide spinner success: function(xml) { successFunction(xml); }, @@ -371,7 +371,7 @@ function deleteForServer(url, successFunction) { dataType: 'xml', timeout: 1000, beforeSend: function() { $.mobile.showPageLoadingMsg(); }, //Show spinner - complete: function() { $.mobile.hidePageLoadingMsg() }, //Hide spinner + complete: function() { $.mobile.hidePageLoadingMsg(); }, //Hide spinner success: function(xml) { expireSession(); dibsWebClear();