Permalink
Browse files

Added support for deletion of runs in the Results view. The selected …

…runs output directories will be deleted.
  • Loading branch information...
1 parent 1aea9bd commit 5434a57b4a9266ab5e0b52c5d9db7bd01049c8c2 @shanti shanti committed Mar 12, 2012
@@ -23,6 +23,7 @@
*/
package com.sun.faban.harness.webclient;
+import com.sun.faban.common.SortableTableModel;
import com.sun.faban.harness.ParamRepository;
import com.sun.faban.harness.common.BenchmarkDescription;
import com.sun.faban.harness.common.Config;
@@ -38,6 +39,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
import java.io.*;
import java.net.URL;
import java.text.ParseException;
@@ -77,6 +79,8 @@ public String takeAction(HttpServletRequest request,
return editAnalysis(process, request, response);
if ("Archive".equals(process))
return editArchive(request, response);
+ if ("Delete".equals(process))
+ return deleteResults(request, response);
return null;
}
@@ -456,6 +460,29 @@ public String archive(HttpServletRequest request,
return "/archive_results.jsp";
}
+ public String deleteResults(HttpServletRequest request,
+ HttpServletResponse response) {
+ String[] runIds = request.getParameterValues("select");
+ if (runIds != null) {
+ for (String r : runIds) {
+ RunResult runResult = RunResult.getInstance(new RunId(r));
+ runResult.delete(r);
+ }
+ }
+ HttpSession session = request.getSession();
+ UserEnv usrEnv = (UserEnv) session.getAttribute("usrEnv");
+ if (usrEnv == null) {
+ usrEnv = new UserEnv();
+ session.setAttribute("usrEnv", usrEnv);
+ }
+ SortableTableModel resultTable = RunResult.getResultTable(usrEnv.getSubject(), 5, "DESCENDING");
+ String feedURL = "/controller/results/feed";
+ request.setAttribute("feedURL", feedURL );
+ request.setAttribute("table.model", resultTable);
+ return "/resultlist.jsp";
+
+ }
+
@SuppressWarnings("empty-statement")
private void prepareUpload(HttpServletRequest request, RunResult result,
HashSet<String> uploadedRuns, HashSet<File> uploadSet)
@@ -699,6 +699,20 @@ else if(result.status.equals("UNKNOWN"))
return table;
}
+ /*
+ * Deletes a certain run.
+ * @param RunId of run run to delete
+ * @return true if delete succeeds, false otherwise
+ */
+ public boolean delete(String runIdStr) {
+ RunId runId = new RunId(runIdStr);
+ File f = runId.getResultDir();
+ if (f.isDirectory()) {
+ return(FileHelper.recursiveDelete(f));
+ }
+ return(true);
+ }
+
private static HashMap<String, String> getAchievedMetricForTarget(String tags)
throws IOException {
HashMap<String, String> achievedMetricMap = new HashMap<String, String>();
@@ -64,6 +64,7 @@
<form name="processrun" method="post" action="/controller/result_action/take_action">
<center>
+ <input type="submit" name="process" value="Delete">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" name="process" value="Compare">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<!-- Commented out until FenXi supports averaging again.
<input type="submit" name="process" value="Average">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
@@ -152,6 +153,7 @@
<br/>
<br/>
<center>
+ <input type="submit" name="process" value="Delete">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" name="process" value="Compare">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<!-- Commented out until FenXi supports averaging again.
<input type="submit" name="action" value="edit_average>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

0 comments on commit 5434a57

Please sign in to comment.