X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=datadb%2Fcompbio%2Fcassandra%2Freaders%2FCassandraReader.java;h=a4561be889833600ef42cbbf2bfc194b538924df;hb=HEAD;hp=01dc12241dd1067c4e523a16ecc59a7a5202f2dc;hpb=cbdbc382e3dc3c0f3fc406d68945b618a137d766;p=proteocache.git diff --git a/datadb/compbio/cassandra/readers/CassandraReader.java b/datadb/compbio/cassandra/readers/CassandraReader.java index 01dc122..a4561be 100644 --- a/datadb/compbio/cassandra/readers/CassandraReader.java +++ b/datadb/compbio/cassandra/readers/CassandraReader.java @@ -6,13 +6,25 @@ import com.datastax.driver.core.ResultSet; import com.datastax.driver.core.Session; import com.datastax.driver.core.exceptions.QueryExecutionException; import com.datastax.driver.core.exceptions.QueryValidationException; + import compbio.cassandra.CassandraNativeConnector; +/** + * basic reader of the ProteoCache database. It depends on open + * CassandraNativeConnector, which should provide an open session to the + * ProteoCache DB (in the default constructor) + * + * @author as373024 + * + */ public class CassandraReader { protected static long earlestDate = 0; protected Session session; protected static Logger log = Logger.getLogger(CassandraNativeConnector.class); + /** + * default constructor. + */ public CassandraReader() { Session inis = CassandraNativeConnector.getSession(); setSession(inis); @@ -23,6 +35,13 @@ public class CassandraReader { session = s; } + /** + * Basic query to the DB. The method throws exception if the input command + * is not valid or if there is a problem with execution of the command + * + * @param command - reading CQL command + * @return resulting outout of the command + */ protected ResultSet CassandraQuery(String command) { try { ResultSet results = session.execute(command); @@ -43,12 +62,32 @@ public class CassandraReader { } - /* - * find the earliest date in the database + /** + * finds the earliest date in the database + * + * @return the earliest date (long) */ public static long earliestDate() { earlestDate = CassandraNativeConnector.getEarliestDateInDB(); return earlestDate; } + /** + * prepares an example of either job id or IP for the DB + * + * @param exampletype + * defines which example you need (an existing job from the DB - + * jobid, an IP - "ip") + * @return a string representation of the requested example, if the example + * type is not known empty string is returned + */ + public String getExample(String exampletype) { + if (exampletype.equals("jobid")) { + return "jp_NzBOJKo"; + } else if (exampletype.equals("ip")) { + return "127.0.0.1"; + } + return ""; + } + }