/* * AddStatistics.java */ /** * @author jseible * * This is my test class */ package org.ngbw.utils; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import org.ngbw.sdk.database.ConnectionManager; import org.ngbw.sdk.database.DriverConnectionSource; import org.ngbw.sdk.database.Statistics; import org.ngbw.sdk.database.Task; import org.ngbw.sdk.database.TaskLogMessage; import org.ngbw.sdk.tool.BaseProcessWorker; public class AddStatistics { // private static long task_id = 0; // private static int statistic_id = 1; private static long task_id_insert = 1005; // private static long task_id_compare = 22; // private static long task_id_jobhandle = 955; // private static long task_id_email = 1000; // private static long task_id_date = 228800; // private static long task_id_userId = 2025; public static void main(String[] args) { try { ConnectionManager.setConnectionSource(new DriverConnectionSource()); /** * do stuff... */ System.out.println("test....." + new Date().toString()); System.out.println(" "); // Statistics statE = new Statistics(); // System.out.println(statE.hashCode()); /** * to update the row with the StatisticID 28 */ //A until now // Statistics stat2 = new Statistics(22); // stat2.setJobEndTime(new Date()); // stat2.save(); //B with findStatisticIdByTaskId-method // 1) find TaskId by Statistic_ID // Statistics stat = Statistics.findStatisticIdByTaskId(task_id); // long statisticIdFromTaskId = stat.getStatisticId(); // System.out.println(statisticIdFromTaskId); //just for testing //2) update the row // Statistics stat3 = new Statistics(statisticIdFromTaskId); // stat3.setJobEndTime(new Date()); // stat3.save(); //C with updateStatisticRecord-method // Statistics stat22 = new Statistics(); // stat22.updateStatisticRecord(task_id); /** * to insert a new TASK_ID; it inserts on under the last row which I deleted */ //OLD WAY // Statistics stat = new Statistics(); // stat.insertStatisticRecordOLD(task_id_insert); // System.out.println(stat.getStatisticId()); //how to catch the STATISTIC_ID after inserting the records //NEW WAY with the method insertStatisticRecord in the BaseProcessWorker-class //before trying look at BaseProcessWorker class what to comment and recomment!!! // BaseProcessWorker bpw = new BaseProcessWorker(){}; // bpw.insertStatisticRecord(task_id_insert); // System.out.println(task_id_insert); // /** * compare task_id with other task_id */ // Statistics stat = new Statistics(); // System.out.println(stat.equals(task_id_insert)); // Object compared = stat.equals(task_id_compare); // System.out.println(compared); /** * delete a TASK_ID */ // Statistics stat = new Statistics(3); // (1) means the number of the STATISTIC_ID-column in the example_table-TABLE // stat.delete(); // stat.save(); // /** * ************** important for my DB table ******************************************************************************************* */ /** * test my getters and setters */ /** * test getJobStartTime */ // Statistics stat = new Statistics(); // Date date = new Date(); // stat.setJobStartTime(date); // System.out.println("***************getJobStartTime**************************************************"); // System.out.println("here is just the date: - " + date); // System.out.println("here is stat.getJobStartTime() - " + stat.getJobStartTime()); // System.out.println("********************************************************************************"); // System.out.println(" "); /** * test getJobEndTime */ // Statistics stat2 = new Statistics(); // Date date2 = new Date(); // stat2.setJobEndTime(date2); // System.out.println("***************getJobEndTime***************************************************"); // System.out.println("here is just the date2: - " + date2); // System.out.println("here is stat2.getJobEndTime() - " + stat2.getJobEndTime()); // System.out.println("*******************************************************************************"); // System.out.println(" "); /** * test getProcessWorker */ // Statistics stat3 = new Statistics(); // String processWorker = stat3.getClass().getName(); // stat3.setProcessWorker(processWorker); // System.out.println("***************processWorker***************************************************"); // System.out.println("here is just the processWorker: - " + processWorker); // System.out.println("here is stat3.getProcessWorker() - " + stat3.getProcessWorker()); // System.out.println("*******************************************************************************"); // System.out.println(" "); /** * test getRemoteJobId */ // Statistics stat4 = new Statistics(); // String remoteJobId = "This is the remoteJobId"; // stat4.setRemoteJobId(remoteJobId); // System.out.println("***************remoteJobId***************************************************"); // System.out.println("here is just the remoteJobId: - " + remoteJobId); // System.out.println("here is stat4.getRemoteJobId() - " + stat4.getRemoteJobId()); // System.out.println("*******************************************************************************"); // System.out.println(" "); /** * test getProcessId - i didn't change that getMethod */ // Statistics stat5 = new Statistics(); // long processId = 2950; // stat5.setProcessId(processId); // System.out.println("***************getProcessId***************************************************"); // System.out.println("here is just the processId: - " + processId); // System.out.println("here is stat4.getRemoteJobId() - " + stat5.getProcessId()); // System.out.println("*******************************************************************************"); // System.out.println(" "); // /** WORKS * to get JOBHANDLE */ // Statistics stat = new Statistics(); // stat.setTaskId(task_id_jobhandle); // System.out.println("TASK_ID: " + task_id_jobhandle+ " | JOBHANDLE: " + stat.getTask().getJobHandle()); /** works * to get EMail */ // Statistics stat = new Statistics(); // stat.setTaskId(task_id_email); // System.out.println("TASK_ID: " + task_id_email + " | EMAIL: " + stat.getTask().getUser().getEmail()); /** works * to get USER_ID * to get USER_Name * to get STAGE (in table task_log_messages) for Terri */ // Statistics stat = new Statistics(); // stat.setTaskId(task_id_userId); // System.out.println("TASK_ID: " + task_id_userId + " | USER_ID: " + stat.getTask().getUserId()); // System.out.println("TASK_ID: " + task_id_userId + " | USER_Name: " + stat.getTask().getUser().getUsername()); // to get the last Stage, But I want all! see DB query SELECT * FROM ngbwtest.task_log_messages where TASK_ID = 2025 // System.out.println("TASK_ID: " + task_id_userId + " | STAGE: " + stat.getTask().getStage()); /** * terri * table task_log_messages * to get column STAGE, ERROR, MESSAGE * * i have to create a new TaskLogMessage Object instead of a * new Statistic object, because i can't get it from there */ //1.step // TaskLogMessage tlm = new TaskLogMessage(new Task(task_id_insert)); // tlm.getStage(); // tlm.isError(); // tlm.getMessage(); //2.step // Statistics stat44 = new Statistics(); // List messages = stat44.getTask().logMessages(); // // for (TaskLogMessage log : messages) { // log.getStage(); // log.isError(); // log.getMessage(); // } //get coulmn: ToolID from database table: task Statistics stat55 = new Statistics(); stat55.getTask().getToolId(); /** *-------------------GET ACTUAL_DATE_TIME--------------------- */ /** * get date from ExampleRow CLASS - date-methods */ // Statistics stat = new Statistics(); // System.out.println("This is the actual Date with 'java.util.Date': " + stat.actualDateWithJavaUtilDate()); /** * to store the Date in DB-column */ // Statistics stat = new Statistics(); // Date actualDateTime = new Date(); // stat.setActualDateTime(actualDateTime); // stat.setTaskId(task_id_date); // stat.save(); } catch (Exception err) { err.printStackTrace(System.err); System.exit(-1); } } }