<listener>\r
<listener-class>compbio.listeners.ContextListener</listener-class>\r
</listener>\r
+ <servlet-mapping>\r
+ <servlet-name>ServletDeleteRecord</servlet-name>\r
+ <url-pattern>/ServletDeleteRecord</url-pattern>\r
+ </servlet-mapping>\r
\r
\r
<!-- Session timeout in minutes -->\r
</init-param>\r
<load-on-startup>1</load-on-startup>\r
</servlet>\r
+ <servlet>\r
+ <description>\r
+ </description>\r
+ <display-name>ServletDeleteRecord</display-name>\r
+ <servlet-name>ServletDeleteRecord</servlet-name>\r
+ <servlet-class>compbio.listeners.ServletDeleteRecord</servlet-class>\r
+ </servlet>\r
\r
\r
<!-- ProteoCache servlets -->\r
--- /dev/null
+package compbio.cassandra;
+
+import org.apache.log4j.Logger;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.core.Session;
+
+public class CassandraRemover {
+ private Session session;
+ private static Logger log = Logger.getLogger(CassandraNativeConnector.class);
+
+ public CassandraRemover() {
+ Session inis = CassandraNativeConnector.getSession();
+ setSession (inis);
+ }
+
+ public void setSession(Session s) {
+ assert s != null;
+ session = s;
+ }
+
+ /*
+ * getting a record from CF for current jobId
+ */
+ public StructureJobLog ReadJobLog(String jobid) {
+ final long startTime = System.currentTimeMillis();
+ String com = "SELECT Protein, StartTime FROM ProteinLog WHERE JobID = '" + jobid + "';";
+ System.out.println("Command: " + com);
+ ResultSet results = session.execute(com);
+ if (results.isExhausted())
+ return null;
+ final long queryTime = System.currentTimeMillis();
+ Row row = results.one();
+ String com1 = "SELECT * FROM ProteinRow WHERE JobID = '" + jobid + "' ALLOW FILTERING;";
+ System.out.println("Command: " + com1);
+ ResultSet results1 = session.execute(com1);
+ if (results1.isExhausted())
+ return null;
+ Row row1 = results1.one();
+ StructureJobLog res = new StructureJobLog(row.getString("Protein"), row.getString("JobID"), row.getString("DataBegin"),
+ row.getString("DataEnd"), row.getString("ip"), row1.getMap("Predictions", String.class, String.class));
+ System.out.println("Query time is " + (queryTime - startTime) + " msec");
+ final long endTime = System.currentTimeMillis();
+ System.out.println(" rows analysed, execution time is " + (endTime - startTime) + " msec");
+ return res;
+ }
+
+
+
+}
--- /dev/null
+package compbio.listeners;
+
+import java.io.IOException;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import compbio.statistic.CassandraRequester;
+
+/**
+ * Servlet implementation class ServletDeleteRecord
+ */
+public class ServletDeleteRecord extends HttpServlet {
+ private static final long serialVersionUID = 1L;
+
+ /**request
+ * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ CassandraRequester cr = new CassandraRequester();
+ String flagId = request.getParameter("byId");
+ String jobId = request.getParameter("id");
+ String date1 = request.getParameter("date1");
+ String date2 = request.getParameter("date2");
+ if (flagId.equals("on"))
+ request.setAttribute("result", cr.countJobs(date1, date2));
+ System.out.println(flagId);
+// request.setAttribute("IdJob", id);
+// RequestDispatcher rd = request.getRequestDispatcher("/ReportLogInfo.jsp");
+// rd.forward(request, response);
+ }
+
+ /**
+ * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ doGet(request, response);
+ }
+
+}
--- /dev/null
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+<%@page import="java.util.*"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Update/delete data base</title>
+<script type="text/javascript">
+function show(el, id) {
+ document.getElementById(id).style.visibility = (el.checked)?"visible":"hidden";
+}
+</script>
+</head>
+<body>
+<form method="post" action="ServletDeleteRecord">
+ <h3>Delete:</h3>
+ <% Calendar cal = Calendar.getInstance();
+ String currentdate = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH);
+ %>
+ <input type="checkbox" name="byId" onclick="show(this, 'id');">records with job's id
+ <div id='id' class="row" style="visibility:hidden;">
+ job id: <input type="text" name="id" />
+ </div>
+ <input type="checkbox" name="byDate" onclick="show(this, 'date');">records for the period of dates
+ <div id='date' class="row" style="visibility:hidden;">
+ from <input type="text" name="data1" value = <%= currentdate%> style=" width : 145px;"/>
+ to <input type="text" name="data2" value = <%= currentdate%> />
+ </div>
+ <input type="checkbox" name="byIp" onclick="show(this, 'ip');">records with ip
+ <div id='ip' class="row" style="visibility:hidden;">
+ ip: <input type="text" name="ip" value = '127'/>
+ </div>
+ <input type="checkbox" name="bySequence" onclick="show(this, 'seq');">records for protein sequence<br/>
+ <div id='seq' class="row" style="visibility:hidden;">
+ Sequence: <input type="text" name="seq" value = "ATA"/>
+ </div>
+ <input type="submit" name="Delete" value="Delete"/>
+ </form>
+</body>
+</html>
\ No newline at end of file