Exemplo n.º 1
0
 /**
  * Build a {@PListObject} from a string that matches one of the tags defined in {@link Constants}.
  *
  * @param tag
  * @param value can be null if tag equals {@link Constants#TAG_BOOL_FALSE} or {@link
  *     Constants#TAG_BOOL_TRUE}.
  * @throws Exception
  * @todo replace with factory for PListObject
  */
 public PListObject buildObject(java.lang.String tag, java.lang.String value) throws Exception {
   if (null == tag) {
     throw new Exception("Cannot add a child with a null tag to a PList.");
   }
   PListObject ret = null;
   if (tag.equalsIgnoreCase(Constants.TAG_INTEGER)) {
     ret = new Integer();
     ((Integer) ret).setValue(value);
   } else if (tag.equalsIgnoreCase(Constants.TAG_STRING)) {
     ret = new String();
     ((String) ret).setValue(value);
   } else if (tag.equalsIgnoreCase(Constants.TAG_REAL)) {
     ret = new Real();
     ((Real) ret).setValue(value);
   } else if (tag.equalsIgnoreCase(Constants.TAG_DATE)) {
     ret = new Date();
     ((Date) ret).setValue(value);
   } else if (tag.equalsIgnoreCase(Constants.TAG_BOOL_FALSE)) {
     ret = new False();
   } else if (tag.equalsIgnoreCase(Constants.TAG_BOOL_TRUE)) {
     ret = new True();
   } else if (tag.equalsIgnoreCase(Constants.TAG_DATA)) {
     ret = new Data();
     ((Data) ret).setValue(value.trim(), true);
   } else if (tag.equalsIgnoreCase(Constants.TAG_DICT)) {
     ret = new Dict();
   } else if (tag.equalsIgnoreCase(Constants.TAG_PLIST_ARRAY)) {
     ret = new Array();
   }
   return ret;
 }
  /*
   * Results must be in report sort order
   */
  @Override
  public List doQuery() {

    List<Object> rows = new ArrayList<Object>();

    // NOTE: List of List<DATA> must be in report sort order

    try {

      Connection conn = dataSource.getConnection();
      Statement statement = conn.createStatement();
      // Query batch job tables
      statement.execute(
          "select * from batch_job_instance a,batch_job_execution b,batch_step_execution c where a.job_instance_id = b.job_instance_id and b.job_execution_id = c.job_execution_id order by a.job_name,b.start_time,c.step_name");

      ResultSet results = statement.getResultSet();

      while (!results.isLast()) {

        results.next();

        String name = results.getString("job_name");
        Timestamp startTime = results.getTimestamp("start_time");
        Timestamp endTime = results.getTimestamp("end_time");
        String step = results.getString("step_name");
        // endtime is null, then it should be this job, don't report
        if (endTime == null) {
          continue;
        }

        long time = endTime.getTime() - startTime.getTime();

        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(startTime.getTime());

        List<Data> cols = new ArrayList<Data>();

        Data d = new Data();
        d.setId(JOB);
        d.setValue(name);

        cols.add(d);

        d = new Data();
        d.setId(STEP);
        d.setValue(step);

        cols.add(d);

        d = new Data();
        d.setId(DATE);
        d.setValue(cal.getTime());

        cols.add(d);

        d = new Data();
        d.setId(EXECUTION_TIME);
        d.setValue(time);
        cols.add(d);

        rows.add(cols);
      }

      conn.close();

    } catch (SQLException e) {

      throw new RuntimeException(e);
    }

    return rows;
  }
Exemplo n.º 3
0
 public static void main(String[] args) {
   Data d = new Data<Integer>();
   d.setValue(new Integer(34));
   Integer value = (Integer) d.getValue();
   System.out.println(value);
 }