From: Natasha Sherstneva Date: Mon, 18 Nov 2013 21:31:47 +0000 (+0000) Subject: PROT-4 Initial code for remover servlet X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=d4eea7f5a8fea637ab742ce69c84a0f835266567;p=proteocache.git PROT-4 Initial code for remover servlet --- diff --git a/WEB-INF/web.xml b/WEB-INF/web.xml index 242a900..b8436c2 100644 --- a/WEB-INF/web.xml +++ b/WEB-INF/web.xml @@ -14,6 +14,10 @@ compbio.listeners.ContextListener + + ServletDeleteRecord + /ServletDeleteRecord + @@ -40,6 +44,13 @@ 1 + + + + ServletDeleteRecord + ServletDeleteRecord + compbio.listeners.ServletDeleteRecord + diff --git a/datadb/compbio/cassandra/CassandraRemover.java b/datadb/compbio/cassandra/CassandraRemover.java new file mode 100644 index 0000000..d066d82 --- /dev/null +++ b/datadb/compbio/cassandra/CassandraRemover.java @@ -0,0 +1,51 @@ +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; + } + + + +} diff --git a/server/compbio/listeners/ServletDeleteRecord.java b/server/compbio/listeners/ServletDeleteRecord.java new file mode 100644 index 0000000..8ec6a1f --- /dev/null +++ b/server/compbio/listeners/ServletDeleteRecord.java @@ -0,0 +1,43 @@ +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); + } + +} diff --git a/website/Update.jsp b/website/Update.jsp new file mode 100644 index 0000000..844079b --- /dev/null +++ b/website/Update.jsp @@ -0,0 +1,41 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@page import="java.util.*"%> + + + + +Update/delete data base + + + +
+

Delete:

+ <% Calendar cal = Calendar.getInstance(); + String currentdate = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH); + %> + records with job's id + + records for the period of dates + + records with ip + + records for protein sequence
+ + +
+ + \ No newline at end of file