Search in sources :

Example 16 with AuditEventBean

use of org.akaza.openclinica.bean.admin.AuditEventBean in project OpenClinica by OpenClinica.

the class AuditEventDAO method getColumnNameFromHashMap.

/**
 * getFinalEntityFromCollection, code created to place many of the functions
 * originally in findAllByUser here, so that it can be used efficiently by
 * findEventStatusLogByStudySubject.
 *
 * @return an AuditEventBean, containing all the preset values
 */
// public AuditEventBean getFinalEntityFromCollection() {
// AuditEventBean eb = new AuditEventBean();
// 
// return eb;
// }
/**
 * <p>
 * getEntityFromHashMap, the method that gets the object from the database
 * query.
 */
public Object getColumnNameFromHashMap(HashMap hm) {
    AuditEventBean eb = new AuditEventBean();
    eb.setUpdateCount(((Integer) hm.get("count")).intValue());
    eb.setColumnName((String) hm.get("column_name"));
    return eb;
}
Also used : AuditEventBean(org.akaza.openclinica.bean.admin.AuditEventBean)

Example 17 with AuditEventBean

use of org.akaza.openclinica.bean.admin.AuditEventBean in project OpenClinica by OpenClinica.

the class AuditEventDAO method findAllByAuditTable.

public ArrayList findAllByAuditTable(String tableName) {
    ArrayList<AuditEventBean> al = new ArrayList<AuditEventBean>();
    this.setTypesExpected();
    HashMap variables = new HashMap();
    variables.put(new Integer(1), tableName);
    String sql = digester.getQuery("findAllByAuditTable");
    ArrayList alist = this.select(sql, variables);
    Iterator it = alist.iterator();
    while (it.hasNext()) {
        AuditEventBean eb = new AuditEventBean();
        eb = (AuditEventBean) this.getEntityFromHashMap((HashMap) it.next());
        al.add(eb);
    }
    return al;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) AuditEventBean(org.akaza.openclinica.bean.admin.AuditEventBean)

Example 18 with AuditEventBean

use of org.akaza.openclinica.bean.admin.AuditEventBean in project OpenClinica by OpenClinica.

the class AuditEventDAO method findAllByUserId.

public ArrayList findAllByUserId(int userId) {
    /*
         * select ae. , aev.old_value, aev.new_value, aev.column_name from
         * audit_event ae, audit_event_values aev where ae.audit_id=aev.audit_id
         * and ae.user_id=? order by ae.audit_date; NEWER QUERY : select ae. ,
         * aev.old_value, aev.new_value, aev.column_name, aec.study_id,
         * aec.subject_id from audit_event ae, audit_event_values aev,
         * audit_event_context aec where ae.audit_id=aev.audit_id and
         * ae.audit_id = aec.audit_id and ae.user_id=? order by ae.audit_date
         */
    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(userId));
    String sql = digester.getQuery("findAllByUserId");
    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);
        // currently added here, but is there repeated work?
        // create a method instead to just add the names to the ids
        // found in the context, tbh
        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);
        }
    // go ahead and check to see if they match
    /*
             * if (eb.getAuditTable().equals(ebCheck.getAuditTable()) &&
             * eb.getEntityId()==ebCheck.getEntityId()) { //get the other
             * column, new value, old value information and //keep on iterating
             * HashMap changes = ebCheck.getChanges();
             * changes.put(eb.getColumnName(),eb.getNewValue());
             * ebCheck.setChanges(changes); } else { //go ahead and add the
             * ebCheck to the list, //reset the ebCheck to review next changes
             * if (ebCheck.getEntityId()!=0) { al.add(ebCheck); } //else {
             * ebCheck = (AuditEventBean) this.getEntityFromHashMap(nextEb,
             * true, true); //}
             * logger.warn("*** Switched entity info: "+eb.getEntityId()+" "+
             * ebCheck.getEntityId()); }
             */
    }
    // 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;
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) AuditEventBean(org.akaza.openclinica.bean.admin.AuditEventBean) HashMap(java.util.HashMap) Map(java.util.Map)

Example 19 with AuditEventBean

use of org.akaza.openclinica.bean.admin.AuditEventBean in project OpenClinica by OpenClinica.

the class AuditEventDAO method createRowForUserAccount.

public void createRowForUserAccount(UserAccountBean uab, String reasonForChange, String actionMessage) {
    // creator method for making a row in the audit table
    // for a user account, tbh
    // TODO doesn't work -- set it up by adding rows to context and values
    AuditEventBean aeb = new AuditEventBean();
    aeb.setUserId(uab.getId());
    aeb.setEntityId(uab.getId());
    aeb.setAuditTable("__user_account");
    aeb.setReasonForChange(reasonForChange);
    aeb.setActionMessage(actionMessage);
    AuditEventBean new_aeb = (AuditEventBean) create(aeb);
}
Also used : AuditEventBean(org.akaza.openclinica.bean.admin.AuditEventBean)

Aggregations

AuditEventBean (org.akaza.openclinica.bean.admin.AuditEventBean)19 HashMap (java.util.HashMap)11 ArrayList (java.util.ArrayList)10 Iterator (java.util.Iterator)7 Map (java.util.Map)3 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)3 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)3 AuditEventDAO (org.akaza.openclinica.dao.admin.AuditEventDAO)3 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)3 EntityBeanTable (org.akaza.openclinica.web.bean.EntityBeanTable)3 Calendar (java.util.Calendar)2 Date (java.util.Date)2 Set (java.util.Set)2 StudyEventAuditBean (org.akaza.openclinica.bean.admin.StudyEventAuditBean)2 SubjectEventStatus (org.akaza.openclinica.bean.core.SubjectEventStatus)2 DisplayStudyEventBean (org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean)2 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)2 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)2 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)2 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)2