Examples of AuditLog


Examples of com.avaje.tests.idkeys.db.AuditLog

     */
    public void testPropertyChange() throws SQLException
    {
        resetEvent();

        AuditLog al = new AuditLog();

        assertTrue("is EntityBean check", al instanceof EntityBean);

        addListener(al, this);
       
        // test if we get property notification about simple property changes
        al.setDescription("ABC");

        assertNotNull(lastPce);
        assertEquals(1, nuofEvents);
        assertEquals("description", lastPce.getPropertyName());
        assertNull(lastPce.getOldValue());
        assertEquals("ABC", lastPce.getNewValue());

        al.setDescription("DEF");

        assertNotNull(lastPce);
        assertEquals(2, nuofEvents);
        assertEquals("description", lastPce.getPropertyName());
        assertEquals("ABC", lastPce.getOldValue());
        assertEquals("DEF", lastPce.getNewValue());

        resetEvent();

        // test if we get change notification if EBean assigns an id to the bean
        getServer().save(al);

        assertNotNull(lastPce);
        assertEquals("id", lastPce.getPropertyName());
        assertNull(lastPce.getOldValue());
        assertNotNull(lastPce.getNewValue());

        String prevLogDesc = al.getDescription();

        resetEvent();

        // simulate external change and test if we get change notification when we refresh the entity
        Transaction tx = getServer().beginTransaction();
        PreparedStatement pstm = tx.getConnection().prepareStatement("update audit_log set description = ? where id = ?");
        pstm.setString(1, "GHI");
        pstm.setLong(2, al.getId());
        int updated = pstm.executeUpdate();
        pstm.close();

        assertEquals(1, updated);

        tx.commit();

        assertNull(lastPce);
        assertEquals(0, nuofEvents);

        getServer().refresh(al);

        assertEquals("GHI", al.getDescription());

        assertNotNull(lastPce);
        assertEquals(1, nuofEvents);
        assertEquals("description", lastPce.getPropertyName());
        assertEquals(prevLogDesc, lastPce.getOldValue());
        assertNotNull("GHI", lastPce.getNewValue());

        // check if we fire with the real new value which might be a modified version of what we passed to the set method
        resetEvent();
        al.setModifiedDescription("MODIFIED_VALUE");

        assertNotNull(lastPce);
        assertEquals(1, nuofEvents);
        assertEquals("modifiedDescription", lastPce.getPropertyName());
        assertEquals(null, lastPce.getOldValue());
View Full Code Here

Examples of com.avaje.tests.idkeys.db.AuditLog

     * <li>updating a lazy loaded property fires two events</li>
     * </ul>
     */
    public void testPartialLoad() throws SQLException
    {
        AuditLog log = new AuditLog();
        log.setDescription("log");

        getServer().save(log);

        assertNotNull(log.getId());

        resetEvent();

        List<AuditLog> logs = getServer().find(AuditLog.class)
                .where().eq("id", log.getId())
                .select("id")
                .findList();

        assertNotNull(logs);
        assertEquals(1, logs.size());

        AuditLog logLazy = logs.get(0);

        addListener(logLazy, this);

        // this will lazy load and update the property
        logLazy.setDescription("updated log");

        // which should result in one PCE events
        assertEquals(1, pces.size());

        // test for the acutal update of the value
View Full Code Here

Examples of com.avaje.tests.idkeys.db.AuditLog

public class TestSqlUpdateInTxn extends BaseTestCase {

  @Test
  public void testBasic() {

    AuditLog otherLog = new AuditLog();
    otherLog.setDescription("foo");
    Ebean.save(otherLog);

    AuditLog log = new AuditLog();
    log.setDescription("foo");
   
    Ebean.save(log);
   
    AuditLog log2 = Ebean.find(AuditLog.class, log.getId());
    Assert.assertEquals("foo", log2.getDescription());
   
    final Long id = log2.getId();
    final String updateDml = "update audit_log set description = :desc where id = :id";
    final String updateModDml = "update audit_log set modified_description = :desc";
   
    SqlUpdate sqlUpdate = Ebean.createSqlUpdate(updateDml);
    sqlUpdate.setParameter("desc", "foo2");
    sqlUpdate.setParameter("id", id);
    sqlUpdate.execute();
   
    SqlUpdate updateMod = Ebean.createSqlUpdateupdateModDml ) ;
    updateMod.setParameter("desc", "mod0");
    updateMod.execute();
   
    AuditLog log3 = Ebean.find(AuditLog.class, log.getId());
    Assert.assertEquals("foo2", log3.getDescription());
    Assert.assertEquals("mod0", log3.getModifiedDescription());

    Ebean.execute(new TxRunnable() { 
      public void run() { 
        SqlUpdate update = Ebean.createSqlUpdateupdateDml ) ;
        update.setParameter("desc", "foo3");
        update.setParameter("id", id);
        update.execute();

        SqlUpdate updateMod = Ebean.createSqlUpdateupdateModDml ) ;
        updateMod.setParameter("desc", "mod1");
        updateMod.execute();
     
    });

    AuditLog log4 = Ebean.find(AuditLog.class, log.getId());
    Assert.assertEquals("foo3", log4.getDescription());
    Assert.assertEquals("mod1", log4.getModifiedDescription());

   
    Ebean.beginTransaction();
   
    SqlUpdate update = Ebean.createSqlUpdate( updateDml) ;
    update.setParameter("desc", "foo4");
    update.setParameter("id", id);
    update.execute();

    updateMod = Ebean.createSqlUpdateupdateModDml ) ;
    updateMod.setParameter("desc", "mod2");
    updateMod.execute();

    Ebean.commitTransaction();

    AuditLog log5 = Ebean.find(AuditLog.class, log.getId());
    Assert.assertEquals("foo4", log5.getDescription());
    Assert.assertEquals("mod2", log5.getModifiedDescription());

  }
View Full Code Here

Examples of com.iisigroup.cap.base.model.AuditLog

    }

    try {

      Class clazz = joinPoint.getTarget().getClass();
      AuditLog auditLog = loggedFunction(TITLE, targetName, clazz, params);
      if (auditLog != null) {
        // 暫時不知道要放什麼值
        auditLog.setRemark(CapConstants.EMPTY_STRING);
        commonSrv.save(auditLog);
      }

    } catch (Exception ex) {
      LOGGER.error(StrUtils.concat(TITLE, "DO_LOG_EXCEPTION_OCCURED!!"),
View Full Code Here

Examples of com.rupertjones.globalcron.common.domain.AuditLog

    }

    private void audit(Auditable entity, AuditLogType type) {
        try {
            String user = sessionContextProvider.getCurrentUser();
            AuditLog log = new AuditLog();
            log.setType(type);
            log.setCreatedAt(new Date());
            log.setUser(user);
            log.setMessage(format("[Entity: %s] [Summary: %s] [by: %s]", entity.getClass().getName(), entity.toAuditLog(), user));
            auditLogDAO.upsert(log);
        } catch (Throwable th) {
            LOG.error("Audit Log could not be saved - actions are not recorded", th);
        }
    }
View Full Code Here

Examples of edu.uga.galileo.voci.bo.AuditLog

          .getCommand(), collectionId)) {
        errors.add("You don't have permission to edit "
            + "the requested collection.");
        goToList = true;
      } else {
        AuditLog record = alm.getRecord(Integer.parseInt(vals[0]),
            ContentType.valueOf(Integer.parseInt(vals[1])),
            (collectionId = Integer.parseInt(vals[2])), Timestamp
                .valueOf(vals[3]));
        String data = record.getDataExport();
        collection = new Collection();
        collection.fromString(data);
      }
    } catch (NullPointerException e) {
      goToList = true;
View Full Code Here

Examples of net.webpasswordsafe.common.model.AuditLog

    @Override
    @Transactional(propagation=Propagation.REQUIRES_NEW)
    public void log(Date date, String user, String ip, String action, String target, boolean status, String message)
    {
        AuditLog auditLog = new AuditLog(date, user, ip, action, target, status, message);
        auditLogDAO.makePersistent(auditLog);
    }
View Full Code Here

Examples of org.apache.continuum.web.util.AuditLog

        {
            this.setProjectGroupId( this.getSelectedProjectGroup() );
            return "projectGroupSummary";
        }

        AuditLog event = new AuditLog( "Project id=" + project.getId(), AuditLogConstants.ADD_PROJECT );
        event.setCategory( AuditLogConstants.PROJECT );
        event.setCurrentUser( getPrincipal() );
        event.log();

        return SUCCESS;
    }
View Full Code Here

Examples of org.apache.continuum.web.util.AuditLog

            catch ( BuildManagerException e )
            {
                throw new ContinuumException( e.getMessage(), e );
            }

            AuditLog event = new AuditLog( "Build Result id=" + buildId, AuditLogConstants.REMOVE_BUILD_RESULT );
            event.setCategory( AuditLogConstants.BUILD_RESULT );
            event.setCurrentUser( getPrincipal() );
            event.log();
           
            return SUCCESS;
        }

        return CONFIRM;
View Full Code Here

Examples of org.apache.continuum.web.util.AuditLog

        {
            name = getProjectGroupName();
            return CONFIRM;
        }

        AuditLog event = new AuditLog( "Project Group id=" + projectGroupId, AuditLogConstants.REMOVE_PROJECT_GROUP );
        event.setCategory( AuditLogConstants.PROJECT );
        event.setCurrentUser( getPrincipal() );
        event.log();

        return SUCCESS;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.