use of org.akaza.openclinica.bean.admin.AuditEventBean in project OpenClinica by OpenClinica.
the class ViewSingleJobServlet method processRequest.
@Override
protected void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
// changes to this servlet, we now look at group name too, tbh 05/2009
String triggerName = fp.getString("tname");
String gName = fp.getString("gname");
String groupName = "";
if (gName.equals("") || gName.equals("0")) {
groupName = XsltTriggerService.TRIGGER_GROUP_NAME;
} else {
// if (gName.equals("1")) {
groupName = TRIGGER_IMPORT_GROUP;
}
// << tbh 09/03/2009 #4143
scheduler = getScheduler();
Trigger trigger = scheduler.getTrigger(triggerName, groupName);
if (trigger == null) {
groupName = XsltTriggerService.TRIGGER_GROUP_NAME;
trigger = scheduler.getTrigger(triggerName.trim(), groupName);
}
// << tbh 09/03/2009 #4143
// above is a hack, if we add more trigger groups this will have
// to be redone
logger.debug("found trigger name: " + triggerName);
logger.debug("found group name: " + groupName);
TriggerBean triggerBean = new TriggerBean();
JobDataMap dataMap = new JobDataMap();
AuditEventDAO auditEventDAO = new AuditEventDAO(sm.getDataSource());
try {
triggerBean.setFullName(trigger.getName());
triggerBean.setPreviousDate(trigger.getPreviousFireTime());
triggerBean.setNextDate(trigger.getNextFireTime());
// >> set active here, tbh 10/08/2009
if (scheduler.getTriggerState(triggerName, groupName) == Trigger.STATE_PAUSED) {
triggerBean.setActive(false);
logger.debug("setting active to false for trigger: " + trigger.getName());
} else {
triggerBean.setActive(true);
logger.debug("setting active to TRUE for trigger: " + trigger.getName());
}
// <<
if (trigger.getDescription() != null) {
triggerBean.setDescription(trigger.getDescription());
}
if (trigger.getJobDataMap().size() > 0) {
dataMap = trigger.getJobDataMap();
String contactEmail = dataMap.getString(XsltTriggerService.EMAIL);
logger.debug("found email: " + contactEmail);
// int dsId = new Integer(datasetId).intValue();
if (gName.equals("") || gName.equals("0")) {
String exportFormat = dataMap.getString(XsltTriggerService.EXPORT_FORMAT);
String periodToRun = dataMap.getString(ExampleSpringJob.PERIOD);
// int userId = new Integer(userAcctId).intValue();
int dsId = dataMap.getInt(ExampleSpringJob.DATASET_ID);
triggerBean.setExportFormat(exportFormat);
triggerBean.setPeriodToRun(periodToRun);
DatasetDAO datasetDAO = new DatasetDAO(sm.getDataSource());
DatasetBean dataset = (DatasetBean) datasetDAO.findByPK(dsId);
triggerBean.setDataset(dataset);
}
int userId = dataMap.getInt(ExampleSpringJob.USER_ID);
// need to set information, extract bean, user account bean
UserAccountDAO userAccountDAO = new UserAccountDAO(sm.getDataSource());
triggerBean.setContactEmail(contactEmail);
UserAccountBean userAccount = (UserAccountBean) userAccountDAO.findByPK(userId);
triggerBean.setUserAccount(userAccount);
ArrayList<AuditEventBean> triggerLogs = auditEventDAO.findAllByAuditTable(trigger.getName());
// set the table for the audit event beans here
ArrayList allRows = AuditEventRow.generateRowsFromBeans(triggerLogs);
EntityBeanTable table = fp.getEntityBeanTable();
String[] columns = { resword.getString("date_and_time"), resword.getString("action_message"), resword.getString("entity_operation"), // resword.getString("study_subject_ID"),
resword.getString("changes_and_additions"), resword.getString("actions") };
table.setColumns(new ArrayList(Arrays.asList(columns)));
table.setAscendingSort(false);
table.hideColumnLink(1);
table.hideColumnLink(3);
table.hideColumnLink(4);
table.setQuery("ViewSingleJob?tname=" + triggerName + "&gname=" + gName, new HashMap());
table.setRows(allRows);
table.computeDisplay();
request.setAttribute("table", table);
}
} catch (NullPointerException e) {
// TODO Auto-generated catch block
logger.debug(" found NPE " + e.getMessage());
e.printStackTrace();
}
// need to show the extract for which this runs, which files, etc
// in other words the job data map
request.setAttribute("triggerBean", triggerBean);
request.setAttribute("groupName", groupName);
forwardPage(Page.VIEW_SINGLE_JOB);
}
use of org.akaza.openclinica.bean.admin.AuditEventBean in project OpenClinica by OpenClinica.
the class AuditEventDAO method create.
// public Collection findAllByAuditTable(String tableName) {
// ArrayList al = new ArrayList();
// AuditEventBean eb = new AuditEventBean();
// this.setTypesExpected();
//
// HashMap variables = new HashMap();
// variables.put(new Integer(1), tableName);
//
// String sql = digester.getQuery("findByPK");
// ArrayList alist = this.select(sql, variables);
// Iterator it = alist.iterator();
//
// while (it.hasNext()) {
// AuditEventBean auditEventBean = new AuditEventBean();
// auditEventBean = (AuditEventBean) this.getEntityFromHashMap((HashMap)
// it.next());
// al.add(auditEventBean);
// }
// return al;
// }
/**
* Creates a new row in the audit_log_event table
*/
public EntityBean create(EntityBean eb) {
AuditEventBean sb = (AuditEventBean) eb;
HashMap<Integer, Object> variables = new HashMap<Integer, Object>();
// INSERT INTO audit_event
// (AUDIT_DATE,AUDIT_TABLE,USER_ID,ENTITY_ID,REASON_FOR_CHANGE,
// ACTION_MESSAGE)
// VALUES (NOW(),?,?,?,?,?)
// needs to change, tbh 02/2009
// new query needs to be
// INSERT INTO audit_log_event(audit_id, audit_log_event_type_id,
// audit_date, user_id, audit_table, entity_id, entity_name, old_value,
// new_value)
// VALUES (pk, ?, now(), NEW.update_id, ?, ?, ?, ?, ?);
variables.put(new Integer(1), sb.getAuditTable());
variables.put(new Integer(2), new Integer(sb.getUserId()));
variables.put(new Integer(3), new Integer(sb.getEntityId()));
variables.put(new Integer(4), sb.getReasonForChangeKey());
variables.put(new Integer(5), sb.getActionMessageKey());
this.execute(digester.getQuery("create"), variables);
return sb;
}
use of org.akaza.openclinica.bean.admin.AuditEventBean in project OpenClinica by OpenClinica.
the class AuditEventDAO method findEventStatusLogByStudySubject.
public ArrayList findEventStatusLogByStudySubject(int studySubjectId) {
/*
* select ae. , aev.old_value, aev.new_value from audit_event ae,
* audit_event_values aev, study_event se where
* ae.audit_table='STUDY_EVENT' and ae.audit_id=aev.audit_id and
* aev.column_name='Subject Event Status ID' and
* ae.entity_id=study_event.study_event_id and
* study_event.study_subject_id=?
*/
this.unsetTypeExpected();
this.setTypeExpected(1, TypeNames.INT);
this.setTypeExpected(2, TypeNames.TIMESTAMP);
this.setTypeExpected(3, TypeNames.STRING);
this.setTypeExpected(4, TypeNames.INT);
this.setTypeExpected(5, TypeNames.INT);
this.setTypeExpected(6, TypeNames.STRING);
// action_message
this.setTypeExpected(7, TypeNames.STRING);
// old_value
this.setTypeExpected(8, TypeNames.STRING);
// new_value
this.setTypeExpected(9, TypeNames.STRING);
// column name
this.setTypeExpected(10, TypeNames.STRING);
HashMap variables = new HashMap();
variables.put(new Integer(1), new Integer(studySubjectId));
logger.debug("&&& querying study log...");
String sql = digester.getQuery("findEventStatusLogByStudySubject");
ArrayList alist = this.select(sql, variables);
ArrayList al = new ArrayList();
Iterator it = alist.iterator();
logger.debug("&&& about to get entities from HM...");
while (it.hasNext()) {
AuditEventBean eb = (AuditEventBean) this.getEntityFromHashMap((HashMap) it.next(), true, true, false);
al.add(eb);
}
logger.debug("&&& returning array list...");
return al;
}
use of org.akaza.openclinica.bean.admin.AuditEventBean in project OpenClinica by OpenClinica.
the class AuditEventDAO method findAll.
public Collection findAll() {
this.setTypesExpected();
ArrayList alist = this.select(digester.getQuery("findAll"));
ArrayList al = new ArrayList();
Iterator it = alist.iterator();
while (it.hasNext()) {
AuditEventBean eb = (AuditEventBean) this.getEntityFromHashMap((HashMap) it.next());
al.add(eb);
}
return al;
}
use of org.akaza.openclinica.bean.admin.AuditEventBean in project OpenClinica by OpenClinica.
the class AuditEventDAO method getEntityFromHashMap.
/**
* <p>
* getEntityFromHashMap, the method that gets the object from the database
* query.
*/
public Object getEntityFromHashMap(HashMap hm) {
AuditEventBean eb = new AuditEventBean();
// AUDIT_ID AUDIT_DATE AUDIT_TABLE USER_ID ENTITY_ID
// REASON_FOR_CHANGE
eb.setId(((Integer) hm.get("audit_id")).intValue());
eb.setAuditDate((java.util.Date) hm.get("audit_date"));
// eb.setAuditDate(new
// Date(((java.sql.Timestamp)hm.get("audit_date")).getTime()));
eb.setAuditTable((String) hm.get("audit_table"));
eb.setUserId(((Integer) hm.get("user_id")).intValue());
eb.setEntityId(((Integer) hm.get("entity_id")).intValue());
eb.setReasonForChange(((String) hm.get("reason_for_change")).trim());
eb.setActionMessage(((String) hm.get("action_message")).trim());
return eb;
}
Aggregations