Package de.micromata.hibernate.history

Examples of de.micromata.hibernate.history.HistoryEntry


   * @return id of the inserted objects if saved manually inside this method or null if the object has to be saved by save method (default).
   */
  public Serializable onBeforeSave(final Session session, final Object obj)
  {
    if (obj instanceof HistoryEntry) {
      final HistoryEntry entry = (HistoryEntry) obj;
      final Integer origEntityId = entry.getEntityId();
      final String entityClassname = entry.getClassName();
      final Serializable newId = getNewId(entityClassname, origEntityId);
      final List<PropertyDelta> delta = entry.getDelta();
      Serializable id = null;
      if (newId != null) {
        // No public access, so try this:
        invokeHistorySetter(entry, "setEntityId", Integer.class, newId);
      } else {
View Full Code Here


    Integer id = a1.getId();
    a1.setName("History 2");
    addressDao.update(a1);
    HistoryEntry[] historyEntries = addressDao.getHistoryEntries(a1);
    assertEquals(2, historyEntries.length);
    HistoryEntry entry = historyEntries[0];
    log.debug(entry);
    assertHistoryEntry(entry, id, user, HistoryEntryType.UPDATE, "name", String.class, "History test", "History 2");
    entry = historyEntries[1];
    log.debug(entry);
    assertHistoryEntry(entry, id, user, HistoryEntryType.INSERT, null, null, null, null);

    a1.setTask(getTask("1.2"));
    addressDao.update(a1);
    historyEntries = addressDao.getHistoryEntries(a1);
    assertEquals(3, historyEntries.length);
    entry = historyEntries[0];
    log.debug(entry);
    assertHistoryEntry(entry, id, user, HistoryEntryType.UPDATE, "task", TaskDO.class, getTask("1.1").getId(), getTask("1.2").getId());

    a1.setTask(getTask("1.1"));
    a1.setName("History test");
    addressDao.update(a1);
    historyEntries = addressDao.getHistoryEntries(a1);
    assertEquals(4, historyEntries.length);
    entry = historyEntries[0];
    log.debug(entry);
    assertHistoryEntry(entry, id, user, HistoryEntryType.UPDATE, null, null, null, null);
    List<PropertyDelta> delta = entry.getDelta();
    assertEquals(2, delta.size());
    for (int i = 0; i < 2; i++) {
      PropertyDelta prop = delta.get(0);
      if ("name".equals(prop.getPropertyName()) == true) {
        assertPropertyDelta(prop, "name", String.class, "History 2", "History test");
View Full Code Here

        group = groupDao.getById(id);
        assertEquals(2, group.getAssignedUsers().size());

        HistoryEntry[] historyEntries = groupDao.getHistoryEntries(group);
        assertEquals(3, historyEntries.length);
        HistoryEntry entry = historyEntries[2];
        assertHistoryEntry(entry, group.getId(), histUser, HistoryEntryType.INSERT);
        entry = historyEntries[1];
        assertHistoryEntry(entry, group.getId(), histUser, HistoryEntryType.UPDATE, "assignedUsers", PFUserDO.class, getUser(TEST_USER2)
            .getId().toString(), "");
        entry = historyEntries[0];
View Full Code Here

      public Object doInTransaction(final TransactionStatus status)
      {
        // Checking history entries of user for new group:
        HistoryEntry[] historyEntries = userDao.getHistoryEntries(getUser("UserTest.historyUser1a"));
        assertEquals(2, historyEntries.length); // insert and update assignedGroups
        final HistoryEntry entry = historyEntries[0]; // Update assignedGroups entry
        assertEquals(1, entry.getDelta().size());
        assertEquals("", entry.getDelta().get(0).getOldValue());
        assertGroupIds(new String[] { "UserTest.historyGroup1"}, entry.getDelta().get(0).getNewValue());

        // Checking history entries of new group:
        historyEntries = groupDao.getHistoryEntries(getGroup("UserTest.historyGroup1"));
        assertEquals(1, historyEntries.length); // insert
        return null;
View Full Code Here

    final Integer id = a1.getId();
    a1.setName("History 2");
    contactDao.update(a1);
    HistoryEntry[] historyEntries = contactDao.getHistoryEntries(a1);
    assertEquals(2, historyEntries.length);
    HistoryEntry entry = historyEntries[0];
    log.debug(entry);
    assertHistoryEntry(entry, id, user, HistoryEntryType.UPDATE, "name", String.class, "History test", "History 2");
    entry = historyEntries[1];
    log.debug(entry);
    assertHistoryEntry(entry, id, user, HistoryEntryType.INSERT, null, null, null, null);

    a1.setTask(getTask("1.2"));
    contactDao.update(a1);
    historyEntries = contactDao.getHistoryEntries(a1);
    assertEquals(3, historyEntries.length);
    entry = historyEntries[0];
    log.debug(entry);
    assertHistoryEntry(entry, id, user, HistoryEntryType.UPDATE, "task", TaskDO.class, getTask("1.1").getId(), getTask("1.2").getId());

    a1.setTask(getTask("1.1"));
    a1.setName("History test");
    contactDao.update(a1);
    historyEntries = contactDao.getHistoryEntries(a1);
    assertEquals(4, historyEntries.length);
    entry = historyEntries[0];
    log.debug(entry);
    assertHistoryEntry(entry, id, user, HistoryEntryType.UPDATE, null, null, null, null);
    final List<PropertyDelta> delta = entry.getDelta();
    assertEquals(2, delta.size());
    for (int i = 0; i < 2; i++) {
      final PropertyDelta prop = delta.get(0);
      if ("name".equals(prop.getPropertyName()) == true) {
        assertPropertyDelta(prop, "name", String.class, "History 2", "History test");
View Full Code Here

TOP

Related Classes of de.micromata.hibernate.history.HistoryEntry

Copyright © 2018 www.massapicom. 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.