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, boolean hasValue, boolean hasColumnName, boolean hasContextIds) {
AuditEventBean eb = new AuditEventBean();
// AUDIT_ID AUDIT_DATE AUDIT_TABLE USER_ID ENTITY_ID
// REASON_FOR_CHANGE ACTION_MESSAGE
eb.setId(((Integer) hm.get("audit_id")).intValue());
eb.setAuditDate((java.util.Date) hm.get("audit_date"));
// used as a test, ignore and remove, tbh
// java.text.SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy
// hh:mm:ss");
// logger.warn("** timestamp found: "+sdf.format(eb.getAuditDate()));
// 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"));
eb.setActionMessage((String) hm.get("action_message"));
if (hasValue) {
// logger.warn("*** has value");
//
eb.setOldValue((String) hm.get("old_value"));
eb.setNewValue((String) hm.get("new_value"));
}
if (hasColumnName) {
// logger.warn("*** has value");
eb.setColumnName((String) hm.get("column_name"));
}
if (hasContextIds) {
// logger.warn("*** has context ids");
eb.setStudyId(((Integer) hm.get("study_id")).intValue());
eb.setSubjectId(((Integer) hm.get("subject_id")).intValue());
// logger.warn("*** set context ids: " +
// eb.getStudyId() + " " +
// eb.getSubjectId());
}
return eb;
}
use of org.akaza.openclinica.bean.admin.AuditEventBean in project OpenClinica by OpenClinica.
the class AuditEventDAO method findAllByEntityName.
public ArrayList findAllByEntityName(int entityId, String digesterName) {
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);
// study_id
this.setTypeExpected(11, TypeNames.INT);
// subject_id
this.setTypeExpected(12, TypeNames.INT);
HashMap variables = new HashMap();
variables.put(new Integer(1), new Integer(entityId));
String sql = digester.getQuery(digesterName);
ArrayList alist = this.select(sql, variables);
ArrayList al = new ArrayList();
Iterator it = alist.iterator();
AuditEventBean ebCheck = new AuditEventBean();
HashMap AuditEventHashMap = new HashMap();
AuditEventBean eb = new AuditEventBean();
while (it.hasNext()) {
HashMap nextEb = (HashMap) it.next();
eb = (AuditEventBean) this.getEntityFromHashMap(nextEb, true, true, true);
ebCheck = (AuditEventBean) AuditEventHashMap.get(new Integer(eb.getId()));
if (ebCheck == null) {
AuditEventHashMap.put(new Integer(eb.getId()), eb);
// logger.warn("Put into hashmap: "+eb.getId());
} else {
HashMap changes = ebCheck.getChanges();
changes.put(eb.getColumnName(), eb.getNewValue());
ebCheck.setChanges(changes);
AuditEventHashMap.put(new Integer(eb.getId()), ebCheck);
}
}
// end of first iterator loop
Set s = AuditEventHashMap.entrySet();
Iterator sit = s.iterator();
while (sit.hasNext()) {
Map.Entry mentry = (Map.Entry) sit.next();
AuditEventBean newAEBean = (AuditEventBean) mentry.getValue();
newAEBean = this.setStudyAndSubjectInfo(newAEBean);
// al.add(mentry.getValue());
al.add(newAEBean);
}
return al;
}
use of org.akaza.openclinica.bean.admin.AuditEventBean in project OpenClinica by OpenClinica.
the class AuditEventDAO method createRowForJobConclusion.
public void createRowForJobConclusion(TriggerBean trigger, int eventTypeId) {
AuditEventBean auditEvent = new AuditEventBean();
auditEvent.setUserId(trigger.getUserAccount().getId());
auditEvent.setEntityId(trigger.getDataset().getId());
auditEvent.setAuditTable("datasets");
auditEvent.setName(trigger.getFullName());
auditEvent.setActionMessage("");
auditEvent.setOldValue("");
auditEvent.setNewValue("");
auditEvent.setReasonForChange("");
// need to set type_id either (success) or (failure), tbh
// use custom SQL here?
AuditEventBean new_aeb = (AuditEventBean) create(auditEvent);
}
use of org.akaza.openclinica.bean.admin.AuditEventBean in project OpenClinica by OpenClinica.
the class AuditEventDAO method findAggregatesByTableName.
public Collection findAggregatesByTableName(String tableName) {
this.unsetTypeExpected();
this.setTypeExpected(1, TypeNames.INT);
this.setTypeExpected(2, TypeNames.STRING);
HashMap variables = new HashMap();
variables.put(new Integer(1), tableName);
String sql = digester.getQuery("findAggregatesByTableName");
logger.debug("sql is: " + sql);
ArrayList alist = this.select(sql, variables);
logger.debug("size is: " + alist.size());
ArrayList al = new ArrayList();
Iterator it = alist.iterator();
while (it.hasNext()) {
logger.debug("has next..");
AuditEventBean eb = (AuditEventBean) this.getColumnNameFromHashMap((HashMap) it.next());
logger.debug("got bean");
al.add(eb);
}
return al;
}
use of org.akaza.openclinica.bean.admin.AuditEventBean in project OpenClinica by OpenClinica.
the class AuditEventDAO method findByPK.
public EntityBean findByPK(int id) {
AuditEventBean eb = new AuditEventBean();
this.setTypesExpected();
HashMap variables = new HashMap();
variables.put(new Integer(1), new Integer(id));
String sql = digester.getQuery("findByPK");
ArrayList alist = this.select(sql, variables);
Iterator it = alist.iterator();
if (it.hasNext()) {
eb = (AuditEventBean) this.getEntityFromHashMap((HashMap) it.next());
}
return eb;
}
Aggregations