List of usage examples for org.hibernate.envers RevisionType MOD
RevisionType MOD
To view the source code for org.hibernate.envers RevisionType MOD.
Click Source Link
From source file:ch.puzzle.itc.mobiliar.business.auditview.control.AuditServiceTest.java
License:Open Source License
@Test public void shouldAuditViewEntryIsRelevantBecauseOldAndNewValueAreNotEqual() { // given// w w w .j a va2 s . c o m String oldValue = "Technical Key: appLogLevel-tmp"; String newValue = "Technical Key: appLogLevel"; MyRevisionEntity revisionEntity = new MyRevisionEntity(); AuditViewEntry entry = AuditViewEntry.builder(revisionEntity, RevisionType.MOD).oldValue(oldValue) .value(newValue).type(EMPTY).build(); // when boolean relevant = auditService.isAuditViewEntryRelevant(entry, Collections.<Integer, AuditViewEntry>emptyMap()); // then assertThat(relevant, is(true)); }
From source file:ch.puzzle.itc.mobiliar.business.auditview.control.AuditServiceTest.java
License:Open Source License
@Test public void shouldAuditViewEntryIsNotRelevantBecauseOldAndNewValueAreEqual() { // given/*from w w w. j ava 2 s. co m*/ String oldValue = "Technical Key: appLogLevel"; String newValue = "Technical Key: appLogLevel"; MyRevisionEntity revisionEntity = new MyRevisionEntity(); AuditViewEntry entry = AuditViewEntry.builder(revisionEntity, RevisionType.MOD).oldValue(oldValue) .value(newValue).type(EMPTY).build(); // when boolean relevant = auditService.isAuditViewEntryRelevant(entry, Collections.<Integer, AuditViewEntry>emptyMap()); // then assertThat(relevant, is(false)); }
From source file:ch.puzzle.itc.mobiliar.business.auditview.control.AuditServiceTest.java
License:Open Source License
@Test public void shouldReturnTrueIfEntryIsNotAlreadyInList() { // given//from w ww . j a va 2s. c om String oldValue = "Technical Key: appLogLevel-tmp"; String newValue = "Technical Key: appLogLevel"; MyRevisionEntity revisionEntity = new MyRevisionEntity(); AuditViewEntry entryInList = AuditViewEntry.builder(revisionEntity, RevisionType.MOD).oldValue(oldValue) .value(newValue).type(EMPTY).build(); AuditViewEntry newEntry = AuditViewEntry.builder(revisionEntity, RevisionType.MOD).oldValue(oldValue + ".") .value(newValue).type(EMPTY).build(); Map<Integer, AuditViewEntry> allAuditViewEntries = new HashMap<>(1); allAuditViewEntries.put(entryInList.hashCode(), entryInList); // when boolean relevant = auditService.isAuditViewEntryRelevant(newEntry, allAuditViewEntries); // then assertThat(relevant, is(true)); }
From source file:ch.puzzle.itc.mobiliar.business.auditview.control.AuditServiceTest.java
License:Open Source License
@Test public void shouldReturnFalseIfEntryIsAlreadyInList() { // given//from w w w .ja va2 s . c o m String oldValue = "Technical Key: appLogLevel-tmp"; String newValue = "Technical Key: appLogLevel"; MyRevisionEntity revisionEntity = new MyRevisionEntity(); AuditViewEntry entryInList = AuditViewEntry.builder(revisionEntity, RevisionType.MOD).oldValue(oldValue) .value(newValue).type(EMPTY).build(); Map<Integer, AuditViewEntry> allAuditViewEntries = new HashMap<>(1); allAuditViewEntries.put(entryInList.hashCode(), entryInList); // when boolean relevant = auditService.isAuditViewEntryRelevant(entryInList, allAuditViewEntries); // then assertThat(relevant, is(false)); }
From source file:ch.puzzle.itc.mobiliar.business.auditview.control.AuditServiceTest.java
License:Open Source License
@Test public void shouldReturnTrueIfTypeIsTemplateDescriptor_valuesEqual() { // given//from ww w . j av a 2s . c o m String value = EMPTY; MyRevisionEntity revisionEntity = new MyRevisionEntity(); AuditViewEntry entryInList = AuditViewEntry.builder(revisionEntity, RevisionType.MOD).oldValue(value) .value(value).type(Auditable.TYPE_TEMPLATE_DESCRIPTOR).build(); Map<Integer, AuditViewEntry> allAuditViewEntries = new HashMap<>(1); // when boolean relevant = auditService.isAuditViewEntryRelevant(entryInList, allAuditViewEntries); // then assertThat(relevant, is(true)); }
From source file:ch.puzzle.itc.mobiliar.business.auditview.control.AuditServiceTest.java
License:Open Source License
@Test public void shouldReturnTrueIfTypeIsTemplateDescriptor_valuesNotEqual() { // given/*from w w w. j a v a 2 s. c o m*/ String value = EMPTY; MyRevisionEntity revisionEntity = new MyRevisionEntity(); AuditViewEntry entryInList = AuditViewEntry.builder(revisionEntity, RevisionType.MOD).oldValue(value) .value("abcd").type(Auditable.TYPE_TEMPLATE_DESCRIPTOR).build(); Map<Integer, AuditViewEntry> allAuditViewEntries = new HashMap<>(1); // when boolean relevant = auditService.isAuditViewEntryRelevant(entryInList, allAuditViewEntries); // then assertThat(relevant, is(true)); }
From source file:ch.puzzle.itc.mobiliar.business.auditview.control.AuditServiceTest.java
License:Open Source License
@Test public void shouldReturnTrueForObfuscatedValuesWhenValuesAreEqual() { // given/*from w w w . j av a2 s.c o m*/ MyRevisionEntity revisionEntity = new MyRevisionEntity(); AuditViewEntry entryInList = AuditViewEntry.builder(revisionEntity, RevisionType.MOD).oldValue("abcd") .value("abcd").type(Auditable.TYPE_TEMPLATE_DESCRIPTOR).isObfuscatedValue(true).build(); Map<Integer, AuditViewEntry> allAuditViewEntries = new HashMap<>(1); // when boolean relevant = auditService.isAuditViewEntryRelevant(entryInList, allAuditViewEntries); // then assertThat(relevant, is(true)); }
From source file:ch.puzzle.itc.mobiliar.business.auditview.control.AuditServiceTest.java
License:Open Source License
@Test public void shouldReturnTrueForObfuscatedValuesWhenValuesAreNotEqual() { // given/*from ww w . ja va2s .c o m*/ String value = EMPTY; MyRevisionEntity revisionEntity = new MyRevisionEntity(); AuditViewEntry entryInList = AuditViewEntry.builder(revisionEntity, RevisionType.MOD).oldValue(value) .value("abcd").type(Auditable.TYPE_TEMPLATE_DESCRIPTOR).isObfuscatedValue(true).build(); Map<Integer, AuditViewEntry> allAuditViewEntries = new HashMap<>(1); // when boolean relevant = auditService.isAuditViewEntryRelevant(entryInList, allAuditViewEntries); // then assertThat(relevant, is(true)); }
From source file:fr.mcc.ginco.audit.utils.AuditQueryBuilder.java
License:CeCILL license
/** * Builds a query returning objects property updates revisions * /*from w w w .j a va2 s . c o m*/ * @param reader * @param thesaurus * the thesaurus on which searched should be performed * @param startDate * the start date for the search * @param clazz * the object class * @param propertyName * the audited property * @return */ public AuditQuery getPropertyChangedQueryOnUpdate(Thesaurus thesaurus, Date startDate, Class<?> clazz, String propertyName) { AuditQuery auditQuery = readerService.getAuditReader().createQuery().forRevisionsOfEntity(clazz, false, true); filterOnDateAndThesaurusId(auditQuery, thesaurus, startDate); auditQuery.add(AuditEntity.property(propertyName).hasChanged()); auditQuery.add(AuditEntity.revisionType().eq(RevisionType.MOD)); return auditQuery; }
From source file:org.azafiu.hibernatetest.rest.ProductRESTService.java
License:Apache License
/** * Retrieve the active products that need to be checked * /* www . ja v a2s . c om*/ * @return a list of {@link ProductDTO} objects */ @RequestMapping(value = "/checker", method = RequestMethod.GET, produces = "application/json") public List<ProductDTO> getAllActiveProductsForChecker() { /** Retrieve a list of products which need checker approval */ final List<Object[]> productChanges = this.productDao.getAllProductsWaitingForApproval(); final List<ProductDTO> results = new ArrayList<ProductDTO>(); for (final Object[] revision : productChanges) { final ProductDTO dto = new ProductDTO(); if (revision.length > 2 && ProductEntity.class.isInstance(revision[0])) { /** get the current value for the {@link ProductDetailsEntity} */ final ProductEntity currentValue = (ProductEntity) revision[0]; if (RevisionType.class.isInstance(revision[2])) { // get the {@link RevisionType} of the current change final RevisionType rt = (RevisionType) revision[2]; dto.setOperation(rt.name()); // get the {@link DefaultRevisionEntity} and retrieve the // revision date final DefaultRevisionEntity revEntity = (DefaultRevisionEntity) revision[1]; final Date revDate = revEntity.getRevisionDate(); dto.setRevision(revDate.getTime()); // get all product details associated with the current // product at the given revision dto.setProductDetails( this.getAllProductDetailsForProductAtRevision(currentValue.getId(), revDate.getTime())); // if the revision type was 'MOD', search for the previous // value of the product to construct the product dto if (rt == RevisionType.MOD) { final ProductEntity previousValue = this.productDao .getPreviousStateForProduct(currentValue.getId(), revEntity.getId()); dto.setInitial(previousValue); dto.setChanges(currentValue); } else { dto.setChanges(currentValue); } } results.add(dto); } } return results; }