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
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])
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]
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
dataType: 'xml',
text: 'JSONP',
data: data,
- timeout: 10000,
+ timeout: 300000,
success: function(xml) {
setSessionInfo(xml);
successFunction(xml);
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);
},
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();