Merge branch 'DAO'
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Fri, 10 Jan 2014 15:15:38 +0000 (15:15 +0000)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Fri, 10 Jan 2014 15:15:38 +0000 (15:15 +0000)
Conflicts:
server/compbio/controllers/DailyStatisticsController.java
server/compbio/controllers/SequenceController.java

1  2 
server/compbio/controllers/BasicController.java
server/compbio/controllers/DailyStatisticsController.java
server/compbio/controllers/IPDataController.java
server/compbio/controllers/JobController.java
server/compbio/controllers/SequenceController.java
server/compbio/statistic/CassandraRequester.java

@@@ -8,8 -8,8 +8,8 @@@ import org.springframework.security.cor
  import org.springframework.security.core.context.SecurityContextHolder;
  import org.springframework.security.core.userdetails.UserDetails;
  
- import compbio.cassandra.CassandraReader;
  import compbio.cassandra.DateFormatter;
+ import compbio.cassandra.readers.CassandraReader;
  
  public class BasicController {
        final protected SimpleDateFormat formaterDDMMYY = DateFormatter.getFormatDDMMYY();
@@@ -17,7 -17,7 +17,7 @@@
        protected Calendar cal = Calendar.getInstance();
        protected String theEaerlistDate = DateFormatter.DateLongToString(CassandraReader.earliestDate(), formaterYYMMDD);
        protected String theCurrentDate = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH);
 -      
 +
        protected String getPrincipalName() {
                Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
                if (principal instanceof UserDetails) {
                }
                return false;
        }
 -      
 +
        protected String DateChecking(String trimmeddate1, String trimmeddate2, long longDate1, long longDate2) {
                Calendar cal2 = Calendar.getInstance();
 -              if (trimmeddate1.equalsIgnoreCase("") || trimmeddate2.equalsIgnoreCase("")) 
 +              if (trimmeddate1.equalsIgnoreCase("") || trimmeddate2.equalsIgnoreCase(""))
                        return "The date cann't be empty";
 -              else if (!DateFormatter.isThisDateValid(trimmeddate1, formaterYYMMDD) || !DateFormatter.isThisDateValid(trimmeddate2, formaterYYMMDD)) 
 +              else if (!DateFormatter.isThisDateValid(trimmeddate1, formaterYYMMDD)
 +                              || !DateFormatter.isThisDateValid(trimmeddate2, formaterYYMMDD))
                        return "The date format in invalid. Try format yyyy/mm/dd";
 -              else if (longDate2 < CassandraReader.earliestDate()) 
 +              else if (longDate2 < CassandraReader.earliestDate())
                        return "The date2 is after the earlestDate " + theEaerlistDate;
                else if (longDate1 > cal2.getTimeInMillis())
                        return "The date1 is before the current date " + theCurrentDate;
 -              else if (longDate1 > longDate2)         
 +              else if (longDate1 > longDate2)
                        return "Wrong date's diaposon. The date1 is more than date2.";
 -              else                    
 +              else
                        return null;
        }
  }
@@@ -11,12 -11,12 +11,14 @@@ import org.springframework.web.bind.ann
  import org.springframework.web.bind.annotation.RequestParam;
  
  import compbio.engine.JobStatus;
- import compbio.cassandra.CassandraReader;
- import compbio.cassandra.DateBean;
+ import compbio.beans.DateBean;
+ import compbio.beans.TotalJobsStatisticBean;
  import compbio.cassandra.DateFormatter;
- import compbio.cassandra.Total;
- import compbio.cassandra.TotalJobsStatisticBean;
- import compbio.statistic.CassandraRequester;
++
++import compbio.beans.Total;
+ import compbio.cassandra.readers.CassandraReader;
+ import compbio.cassandra.readers.DailyStatisticsReader;
 -import compbio.cassandra.readers.ProteoDAO;
++
  
  /**
   * @author Alexander Sherstnev
@@@ -61,8 -61,8 +63,8 @@@ public class DailyStatisticsController 
         *            the final date for the report (if option is set, date2 =
         *            today)
         * @param option
 -       *            defined whether the whole time range of jobs is reported
 -       *            (null means date1 and date2 are used)
 +       *            defined whether the whole time range of jobs is reported (null
 +       *            means date1 and date2 are used)
         * @return link to the report JSP page
         */
        @RequestMapping(value = "/stat/jobsdaily/results", method = RequestMethod.GET)
@@@ -71,7 -71,7 +73,7 @@@
                model.put("username", getPrincipalName());
                Calendar loccal = Calendar.getInstance();
                final long startTime = System.currentTimeMillis();
-               CassandraRequester cr = new CassandraRequester();
+               DailyStatisticsReader reader = new DailyStatisticsReader();
                if (option.equals("AllDates,off")) {
                        date1 = theEaerlistDate;
                        date2 = theCurrentDate;
                date2 = DateFormatter.DateLongToString(longDate2, formaterYYMMDD);
                model.put("date1", date1);
                model.put("date2", date2);
-               TotalJobsStatisticBean res = cr.countJobs(date1, date2);
+               TotalJobsStatisticBean res = reader.query(longDate1, longDate2);
                model.put("result", res);
 +              Map<String, Total> results = res.getDateTotal();
 +              String csvline = "\'Date\',\'Total\',\'OK\',\'Stopped\',\'Error\',\'Timeout\'%0A";
 +              for (Map.Entry<String, Total> entry : results.entrySet()) {
 +                      csvline += "\'" + entry.getKey() + "\',\'" + entry.getValue().getTotal() + "\',\'" + entry.getValue().getTotalOK() + "\',\'"
 +                                      + entry.getValue().getTotalStopped() + "\',\'" + entry.getValue().getTotalError() + "\',\'"
 +                                      + entry.getValue().getTotalTimeOut() + "\'%0A";
 +              }
 +              model.put("csvfile", csvline);
                model.put("ndays", res.getDateTotal().size());
                final long endTime = System.currentTimeMillis();
                model.put("timeExecution", (endTime - startTime));
                final long startTime = System.currentTimeMillis();
  
                String realdate;
+               long thetime = 0;
                try {
-                       long thetime = formaterYYMMDD.parse(date).getTime();
+                       thetime = formaterYYMMDD.parse(date).getTime();
                        if (thetime < 0) {
                                realdate = date;
                        } else {
                        }
                } catch (ParseException e) {
                        realdate = date;
+                       thetime = formaterDDMMYY.parse(realdate).getTime();
                }
+               
                if (null == JobStatus.getJobStatus(status)) {
                        return "support/Notimplemented";
                }
  
-               CassandraRequester cr = new CassandraRequester();
+               DailyStatisticsReader reader = new DailyStatisticsReader();
                // IMPORTANT: input should be suppied in the format: DD/MM/YYYY
-               DateBean r = cr.readJobByDay(realdate, JobStatus.getJobStatus(status));
+               DateBean r = reader.readJobByDay(thetime, realdate, JobStatus.getJobStatus(status));
                model.put("results", r);
                if (r != null)
                        model.put("njobs", r.getJobidAndSeq().size());
@@@ -8,8 -8,10 +8,10 @@@ import org.springframework.web.bind.ann
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.RequestParam;
  
- import compbio.cassandra.TotalByCounterBean;
- import compbio.cassandra.UserBean;
+ import compbio.beans.TotalByCounterBean;
+ import compbio.beans.UserBean;
+ import compbio.cassandra.readers.IpReader;
+ import compbio.cassandra.readers.ReaderByCounter;
  import compbio.statistic.CassandraRequester;
  
  /**
@@@ -29,8 -31,7 +31,8 @@@ public class IPDataController extends B
        @RequestMapping(value = "/admin/ip/query", method = RequestMethod.GET)
        public String initOneIPForm(Map<String, Object> model) {
                model.put("username", getPrincipalName());
 -              model.put("value", "127.0.0.1");
 +              CassandraRequester cr = new CassandraRequester();
 +              model.put("value", cr.getExample("ip"));
                return "query/IP";
        }
  
                }
  
                final long startTime = System.currentTimeMillis();
-               CassandraRequester cr = new CassandraRequester();
-               List<TotalByCounterBean> r = cr.readIpByCounter(realcounter);
+               ReaderByCounter reader = new ReaderByCounter();
+               List<TotalByCounterBean> r = reader.readIpByCounter(realcounter);
                model.put("results", r);
                model.put("njobs", 0);
 +              String csvline = "";
                if (null != r) {
                        model.put("njobs", r.size());
 +                      csvline = "\'Job%20 count\', \'IP\'%0A";
                }
 +              // form line for CSV file
 +              for (TotalByCounterBean b : r) {
 +                      csvline += "\'" + b.getTotaljobs() + "\',\'" + b.getName() + "\'%0A";
 +              }
 +              model.put("csvfile", csvline);
                final long endTime = System.currentTimeMillis();
                model.put("timeExecution", (endTime - startTime));
                model.put("counter", realcounter);
@@@ -83,8 -77,8 +85,8 @@@
        public String findIP(@RequestParam("ip") String ip, Map<String, Object> model) {
                model.put("username", getPrincipalName());
                final long startTime = System.currentTimeMillis();
-               CassandraRequester cr = new CassandraRequester();
-               UserBean r = cr.readIp(ip);
+               IpReader reader = new IpReader();
+               UserBean r = reader.readIp(ip);
                model.put("results", r);
                model.put("njobs", 0);
                if (null != r) {
@@@ -7,7 -7,6 +7,7 @@@ import java.util.Date
  import java.util.List;
  import java.util.Map;
  
 +import org.apache.log4j.Logger;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
@@@ -15,6 -14,7 +15,7 @@@ import org.springframework.web.bind.ann
  
  import compbio.statistic.CassandraRequester;
  import compbio.cassandra.DataBase;
+ import compbio.cassandra.readers.JobReader;
  import compbio.engine.archive.ArchivedJob;
  
  /**
   */
  @Controller
  public class JobController extends BasicController {
 +      private static Logger log = Logger.getLogger(JobController.class);
  
        /**
 -       * form a query page for job execution time statistics. The servlet should be
 -       * available for users and admins only. By defaults the report time range is
 -       * from the earliest day with jobs to today ("Query for all dates" is
 +       * form a query page for job execution time statistics. The servlet should
 +       * be available for users and admins only. By defaults the report time range
 +       * is from the earliest day with jobs to today ("Query for all dates" is
         * ticked). If the user removes the tick the time range is from today - 3
         * days to today. Currently, the input model is empty.
         * 
@@@ -51,8 -50,7 +52,8 @@@
        }
  
        /**
 -       * form a query page for a job. The servlet should no be visible to users at all. 
 +       * form a query page for a job. The servlet should no be visible to users at
 +       * all.
         * 
         * @param model
         *            MVC model
        @RequestMapping(value = "/job/query", method = RequestMethod.GET)
        public String initFindForm(Map<String, Object> model) {
                model.put("username", getPrincipalName());
 -              model.put("value", "jp_NzBOJKo");
 +              CassandraRequester cr = new CassandraRequester();
 +              model.put("value", cr.getExample("jobid"));
                return "query/JobLog";
        }
  
 +      /**
 +       * form a report page for a job execution time statistics.
 +       * 
 +       * @param model
 +       *            MVC model
 +       * @return link to the JSP query page
 +       */
        @RequestMapping(value = "/stat/exectime/results", method = RequestMethod.GET)
        public String findExecTimeData(@RequestParam("date1") String date1, @RequestParam("date2") String date2,
                        @RequestParam(value = "option", required = false) String option, Map<String, Object> model) {
                model.put("option", option);
                List<DataBase> res = sp.extractExecutionTime(date1, date2);
                model.put("result", res);
 +              String csvline = "";
 +              if (0 < res.size()) {
 +                      csvline = "\'Date\',\'Total\',\'0-30 sec\',\'30-60 sec\',\'1-2 min\',\'2-10 min\',\'more 10 min\'%0A";
 +                      for (DataBase entry : res) {
 +                              List<Integer> counts = entry.getTimeRez();
 +                              int total = 0;
 +                              for (int i = 0; i < counts.size(); ++i) {
 +                                      total += counts.get(i);
 +                              }
 +                              csvline += "\'" + entry.getDate() + "\',\'" + total;
 +                              for (int i = 0; i < counts.size(); ++i) {
 +                                      csvline += "\',\'" + counts.get(i);
 +                              }
 +                              csvline += "\'%0A";
 +                      }
 +              }
 +              model.put("csvfile", csvline);
                model.put("ndays", res.size() - 1);
                final long endTime = System.currentTimeMillis();
                model.put("timeExecution", (endTime - startTime));
                return "/reportTimeExecution";
        }
  
 +      /**
 +       * form a query page for a job. The servlet should no be visible to users at
 +       * all.
 +       * 
 +       * @param model
 +       *            MVC model
 +       * @return link to the JSP query page
 +       */
        @RequestMapping(value = "/job/results", method = RequestMethod.GET)
        public String findJob(@RequestParam("IdJob") String jobid, Map<String, Object> model) {
                model.put("username", getPrincipalName());
                final long startTime = System.currentTimeMillis();
-               CassandraRequester cr = new CassandraRequester();
-               model.put("result", cr.readJobLog(jobid));
+               JobReader reader = new JobReader();
+               model.put("result", reader.readJobLog(jobid));
                final long endTime = System.currentTimeMillis();
                model.put("timeExecution", (endTime - startTime));
                model.put("IdJob", jobid);
                try {
                        model.put("jobarchive", aj.prepareJobArchiveToWeb());
                } catch (IOException e) {
 -                      //TODO. what should we do if job is not available???
 +                      log.error("JobController.prepareJobArchiveToWeb: IO exception with job archive file");
 +                      log.error(e.getLocalizedMessage(), e.getCause());
                }
                return "reportJobLog";
        }
  
 -      /*
 -       * convert ???
 +      /**
 +       * convert date from the standard long representation (milliseconds from 1
 +       * Jan 1970) to yyyy/mm/dd
 +       * 
 +       * @param indate
 +       *            date in milliseconds from 1 Jan 1970
 +       * @return date in the form of yyyy/mm/dd
         */
        private String DateFormatYYMMDD(long indate) {
                SimpleDateFormat datformat = new SimpleDateFormat("yyyy/MM/dd");
@@@ -1,6 -1,5 +1,6 @@@
  package compbio.controllers;
  
 +import java.util.LinkedHashMap;
  import java.util.List;
  import java.util.Map;
  import java.util.regex.Pattern;
@@@ -10,11 -9,11 +10,10 @@@ import org.springframework.web.bind.ann
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.RequestParam;
  
- import compbio.cassandra.DataBase;
- import compbio.cassandra.ProteinBean;
- import compbio.cassandra.Total;
- import compbio.cassandra.TotalByCounterBean;
- import compbio.statistic.CassandraRequester;
+ import compbio.beans.ProteinBean;
+ import compbio.beans.TotalByCounterBean;
+ import compbio.cassandra.readers.ReaderByCounter;
+ import compbio.cassandra.readers.SequenceReader;
 -import compbio.statistic.CassandraRequester;
  
  /**
   * Spring controller for sequence queries. This version works in the servlet
@@@ -35,6 -34,14 +34,14 @@@ public class SequenceController extend
         */
        private final Pattern NONPROTEIN = Pattern.compile("[^ARNDCQEGHILKMFPSTWYV]+", Pattern.CASE_INSENSITIVE);
  
+       /**
+        * form a query page for search protein sequence. The servlet should be
+        * available for users and admins only. 
+        * 
+        * @param model
+        *            MVC model
+        * @return link to the JSP query page
+        */
        @RequestMapping(value = "query", method = RequestMethod.GET)
        public String formSequenceQuery(Map<String, Object> model) {
                model.put("username", getPrincipalName());
                return "query/Sequence";
        }
  
+       /**
+        * form a query page for statistics: Protein by job count. The servlet should be
+        * available for users and admins only. 
+        * 
+        * @param model
+        *            MVC model
+        * @return link to the JSP query page
+        */
        @RequestMapping(value = "counts/query", method = RequestMethod.GET)
        public String formCounterQuery(Map<String, Object> model) {
                model.put("username", getPrincipalName());
                return "query/SequenceCounts";
        }
  
+       /**
+        * form a report page for search protein sequence.
+        * 
+        * @param model
+        *            MVC model object
+        * @param sequence
+        *            protein sequence or part of sequence
+        * @param searchtype
+        *            defined whether the whole sequence or part of sequence would be searched
+        * @return link to the report JSP page
+        */
        @RequestMapping(value = "sequence/results", method = RequestMethod.GET)
        public String findSequence(@RequestParam("sequence") String sequence, @RequestParam("searchtype") String searchtype,
                        Map<String, Object> model) {
                model.put("njobs", 0);
                model.put("prot", trimmedsequence);
                model.put("searchtype", searchtype);
 -
 +              String csvline = "";
                if (0 < trimmedsequence.length()) {
-                       CassandraRequester cr = new CassandraRequester();
-                       List<ProteinBean> r = cr.readProteins(trimmedsequence, searchtype);
-                       model.put("results", r);
-                       if (null != r) {
+                       SequenceReader reader = new SequenceReader();
+                       List<ProteinBean> result = reader.readProteins(trimmedsequence, searchtype);
+                       model.put("results", result);
+                       if (null != result) {
                                if (searchtype.equals("whole"))
-                                       model.put("njobs", r.get(0).getJobid().size());
+                                       model.put("njobs", result.get(0).getJobid().size());
                                else
-                                       model.put("njobs", r.size());
+                                       model.put("njobs", result.size());
 +                              csvline = "\'Job\',\'Annotation\',\'Sequence\'%0A";
 +                      }
 +                      // form CSV file string
-                       for (ProteinBean entry : r) {
++                      for (ProteinBean entry : result) {
 +                              List<String> jobs = entry.getJobid();
 +                              String protein = entry.getSequence();
 +                              LinkedHashMap<String, String> predictions = entry.getPredictions();
 +                              for (String job : jobs) {
 +                                      csvline += "\'" + job + "\',\'Sequence\',\'" + protein + "\',\'%0A";
 +                                      for (Map.Entry<String, String> pr : predictions.entrySet()) {
 +                                              csvline += "\'\',\'" + pr.getKey() + "\',\'" + pr.getValue() + "\'%0A";
 +                                      }
 +                              }
                        }
                }
 +              model.put("csvfile", csvline);
 +
                final long endTime = System.currentTimeMillis();
                model.put("timeExecution", (endTime - startTime));
                return "reportProteinSequences";
        }
  
+       /**
+        * form a report page for statistics: Protein by job count.
+        * 
+        * @param model
+        *            MVC model object
+        * @param counter
+        *           
+        * @return link to the report JSP page
+        */
        @RequestMapping(value = "counts/results", method = RequestMethod.GET)
        public String countSequences(@RequestParam("counterJob") String counter, Map<String, Object> model) {
                model.put("username", getPrincipalName());
                        return "query/SequenceCounts";
                }
  
-               CassandraRequester cr = new CassandraRequester();
-               List<TotalByCounterBean> r = cr.readProteinByCounter(realcounter);
 -              ReaderByCounter reader = new ReaderByCounter();
++              ReaderByCounter reader = new ReaderByCounter();
+               List<TotalByCounterBean> r = reader.readProteinByCounter(realcounter);
+               model.put("results", r);
                model.put("njobs", 0);
 +              String csvline = "";
                if (null != r) {
                        model.put("njobs", r.size());
 +                      csvline = "\'Job%20 count\', \'Protein%20Sequence\'%0A";
                }
 +              // form line for CSV file
 +
 +              for (TotalByCounterBean b : r) {
 +                      if (b.getName().equals("")) {
 +                              csvline += "\'" + b.getTotaljobs() + "\',\'Alignment%20job\'%0A";
 +                              // fix problem with records without protein sequence (alignment
 +                              // jobs)
 +                              b.setName("Alignment job");
 +                      } else {
 +                              csvline += "\'" + b.getTotaljobs() + "\',\'" + b.getName() + "\'%0A";
 +                      }
 +              }
 +              model.put("csvfile", csvline);
 +
 +              model.put("results", r);
                final long endTime = System.currentTimeMillis();
                model.put("timeExecution", (endTime - startTime));
                model.put("counter", realcounter);
@@@ -9,17 -9,17 +9,17 @@@ import java.util.HashMap
  import java.util.List;
  import java.util.Map;
  
- import compbio.cassandra.DateBean;
- import compbio.cassandra.ProteinBean;
+ import compbio.beans.DateBean;
+ import compbio.beans.JobBean;
+ import compbio.beans.ProteinBean;
+ import compbio.beans.Total;
+ import compbio.beans.TotalByCounterBean;
+ import compbio.beans.TotalJobsStatisticBean;
+ import compbio.beans.UserBean;
  import compbio.cassandra.CassandraNativeConnector;
  import compbio.cassandra.CassandraReaderOld;
  import compbio.cassandra.DataBase;
  import compbio.cassandra.Pair;
- import compbio.cassandra.JobBean;
- import compbio.cassandra.Total;
- import compbio.cassandra.TotalByCounterBean;
- import compbio.cassandra.TotalJobsStatisticBean;
- import compbio.cassandra.UserBean;
  import compbio.engine.JobStatus;
  
  public class CassandraRequester {
                        query.add(db);
                }
  
 +              /* ???? Very strange code...
                DataBase db = new DataBase();
                db.setTimeTotalExec(totalTime);
                query.add(db);
 +              */
                return query;
        }
  
        /*
         * query: total number of jobs for the period from date1 till date2
-        */
+       */ 
        public TotalJobsStatisticBean countJobs(String date1, String date2) {
 -      /*      if (null == date1) {
 -                      date1 = "1970/1/1";
 -              }
 -              if (null == date2) {
 -                      date1 = "2100/1/1";
 -              }
 -              if (!isThisDateValid(date1, formatYYMMDD) || !isThisDateValid(date2, formatYYMMDD)) {
 -                      System.out.println("CassandraRequester.countJobs: wrong format for date1 " + date1 + "or date2 " + date2);
 -                      return null;
 -              }*/
 +              /*
 +               * if (null == date1) { date1 = "1970/1/1"; } if (null == date2) { date1
 +               * = "2100/1/1"; } if (!isThisDateValid(date1, formatYYMMDD) ||
 +               * !isThisDateValid(date2, formatYYMMDD)) { System.out.println(
 +               * "CassandraRequester.countJobs: wrong format for date1 " + date1 +
 +               * "or date2 " + date2); return null; }
 +               */
                SetDateRange();
                long dateStart = DateParsing(date1, formatYYMMDD);
                long dateEnd = DateParsing(date2, formatYYMMDD);
 -/*            if (dateEnd < earlestDate || dateStart > currentDate || dateStart > dateEnd)
 -                      return null;
 -              if (dateStart < earlestDate)
 -                      dateStart = earlestDate;
 -              if (dateEnd > currentDate)
 -                      dateStart = currentDate;*/
 +              /*
 +               * if (dateEnd < earlestDate || dateStart > currentDate || dateStart >
 +               * dateEnd) return null; if (dateStart < earlestDate) dateStart =
 +               * earlestDate; if (dateEnd > currentDate) dateStart = currentDate;
 +               */
                Calendar start = Calendar.getInstance();
                start.setTime(new Date(dateStart));
                Calendar end = Calendar.getInstance();
                long day = DateParsing(date, formatDDMMYY);
                if (day < earlestDate || day > currentDate)
                        return null;
 -              
 +
                if (status == JobStatus.OK) {
                        return db.ReadProteinData(day, date);
                }
                }
                return result;
        }
 -      
 +
        /*
         * query: protein feature
         */
        public Map<String, String> readProteinsPrediction(String feature, int percent) {
 -              Map<String, String> result = db.ReadProtein();;
 +              Map<String, String> result = db.ReadProtein();
 +              ;
                if (result == null)
                        return null;
                Map<String, String> query = new HashMap<String, String>();
                for (Map.Entry<String, String> entry : result.entrySet()) {
 -                      String pred = entry.getValue();                 
 -                      if (pred.replaceAll("[^"+feature+"]", "").length() > pred.length() * percent / 100 && (!entry.getKey().equals(""))) {
 -                      //      if (!entry.getKey().equals(""))
 -                                      query.put(entry.getKey(), pred);
 -                      }       
 +                      String pred = entry.getValue();
 +                      if (pred.replaceAll("[^" + feature + "]", "").length() > pred.length() * percent / 100 && (!entry.getKey().equals(""))) {
 +                              // if (!entry.getKey().equals(""))
 +                              query.put(entry.getKey(), pred);
 +                      }
                }
                return query;
        }
                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 "";
 +      }
 +
  }