本文整理汇总了Java中org.hibernate.envers.DefaultRevisionEntity类的典型用法代码示例。如果您正苦于以下问题:Java DefaultRevisionEntity类的具体用法?Java DefaultRevisionEntity怎么用?Java DefaultRevisionEntity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultRevisionEntity类属于org.hibernate.envers包,在下文中一共展示了DefaultRevisionEntity类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertProperObjectsReturned
import org.hibernate.envers.DefaultRevisionEntity; //导入依赖的package包/类
private void assertProperObjectsReturned(final Object[] revisionObject, final ProductDetailsEntity pde) {
Assert.assertEquals(3, revisionObject.length);
Assert.assertTrue(ProductDetailsEntity.class.isInstance(revisionObject[0]));
Assert.assertTrue(DefaultRevisionEntity.class.isInstance(revisionObject[1]));
Assert.assertTrue(RevisionType.class.isInstance(revisionObject[2]));
final ProductDetailsEntity pd = (ProductDetailsEntity) revisionObject[0];
final RevisionType rt = (RevisionType) revisionObject[2];
Assert.assertEquals(RevisionType.ADD, rt);
Assert.assertEquals(pde.getStoreName(), pd.getStoreName());
Assert.assertEquals(pde.getExpirationDate(), pd.getExpirationDate());
Assert.assertEquals(pde.getActive(), pd.getActive());
Assert.assertEquals(pde.getWasChecked(), pd.getWasChecked());
}
示例2: getPreviousStateForProductDetails_WhenProductDetailsAdded_ThenReturnNULL
import org.hibernate.envers.DefaultRevisionEntity; //导入依赖的package包/类
@Test
public void getPreviousStateForProductDetails_WhenProductDetailsAdded_ThenReturnNULL() {
ProductDetailsEntity pe = new ProductDetailsEntity();
pe.setActive(true);
pe.setStoreName("Product 1");
pe.setExpirationDate(new Date());
pe.setWasChecked(Boolean.TRUE);
pe = this.productDetailsRepo.save(pe);
final Object[] latestProductDetails = this.productDetailsDao.getLatestChangeForItemWithID(pe.getId(),
ProductDetailsEntity.class);
Assert.assertNotNull(latestProductDetails);
Assert.assertEquals(3, latestProductDetails.length);
Assert.assertTrue(DefaultRevisionEntity.class.isInstance(latestProductDetails[1]));
final DefaultRevisionEntity revEnt = (DefaultRevisionEntity) latestProductDetails[1];
final ProductDetailsEntity prodEnt = this.productDetailsDao.getPreviousStateForProductDetails(pe.getId(),
revEnt.getId());
Assert.assertNull(prodEnt);
}
示例3: ProductDetailsEntity
import org.hibernate.envers.DefaultRevisionEntity; //导入依赖的package包/类
@Test
public void getPreviousStateForProductDetails_WhenProductDetailsAddedAndThenModified_ThenReturnsTheInitialStateOfTheProductDetails() {
ProductDetailsEntity pe = new ProductDetailsEntity();
pe.setActive(true);
pe.setStoreName("Product 1");
pe.setExpirationDate(new Date());
pe.setWasChecked(Boolean.TRUE);
pe = this.productDetailsRepo.save(pe);
pe.setActive(true);
pe.setStoreName("Product 2");
pe.setWasChecked(Boolean.FALSE);
this.productDetailsRepo.save(pe);
final Object[] latestProductDetails = this.productDetailsDao.getLatestChangeForItemWithID(pe.getId(),
ProductDetailsEntity.class);
Assert.assertNotNull(latestProductDetails);
Assert.assertEquals(3, latestProductDetails.length);
Assert.assertTrue(DefaultRevisionEntity.class.isInstance(latestProductDetails[1]));
final DefaultRevisionEntity revEnt = (DefaultRevisionEntity) latestProductDetails[1];
final ProductDetailsEntity prodEnt = this.productDetailsDao.getPreviousStateForProductDetails(pe.getId(),
revEnt.getId());
Assert.assertNotNull(prodEnt);
Assert.assertEquals("Product 1", prodEnt.getStoreName());
Assert.assertEquals(Boolean.TRUE, prodEnt.getActive());
Assert.assertEquals(Boolean.TRUE, prodEnt.getWasChecked());
}
示例4: initialize
import org.hibernate.envers.DefaultRevisionEntity; //导入依赖的package包/类
@Transactional
public void initialize() {
this.pe = new ProductEntity();
this.pe.setActive(true);
this.pe.setName("Product 1");
this.pe.setPrice(Double.valueOf(2.4));
this.pe.setWasChecked(Boolean.FALSE);
this.detail1.setStoreName("STORE_NAME");
this.detail1.setExpirationDate(new Date());
this.detail1.setWasChecked(Boolean.FALSE);
this.detail1.setActive(true);
this.detail2.setStoreName("STORE_NAME2");
this.detail2.setExpirationDate(new Date());
this.detail2.setWasChecked(Boolean.FALSE);
this.detail2.setActive(true);
this.pe = this.productRepo.save(this.pe);
this.detail1.setProduct(this.pe);
this.detail2.setProduct(this.pe);
this.productDetailsRepo.save(this.detail1);
this.productDetailsRepo.save(this.detail2);
final List<Object[]> products = this.productDao.getAllProductsWaitingForApproval();
Assert.assertNotNull(products);
Assert.assertEquals(1, products.size());
final Object[] productRevision = products.get(0);
Assert.assertEquals(3, productRevision.length);
Assert.assertTrue(DefaultRevisionEntity.class.isInstance(productRevision[1]));
final DefaultRevisionEntity revEnt = (DefaultRevisionEntity) productRevision[1];
this.insertDate = revEnt.getRevisionDate();
}
示例5: getPreviousStateForProduct_WhenProductAddedAndThenModified_ThenReturnsTheInitialStateOfTheProduct
import org.hibernate.envers.DefaultRevisionEntity; //导入依赖的package包/类
@Test
public void getPreviousStateForProduct_WhenProductAddedAndThenModified_ThenReturnsTheInitialStateOfTheProduct() {
ProductEntity pe = new ProductEntity();
pe.setActive(true);
pe.setName("Product 1");
pe.setPrice(Double.valueOf(2.4));
pe.setWasChecked(Boolean.TRUE);
pe = this.productRepo.save(pe);
pe.setActive(true);
pe.setName("Product 2");
pe.setPrice(Double.valueOf(2.4));
pe.setWasChecked(Boolean.FALSE);
this.productRepo.save(pe);
final Object[] productRevision = this.productDao.getLatestChangeForItemWithID(pe.getId(), ProductEntity.class);
Assert.assertEquals(3, productRevision.length);
Assert.assertTrue(DefaultRevisionEntity.class.isInstance(productRevision[1]));
final DefaultRevisionEntity revEnt = (DefaultRevisionEntity) productRevision[1];
final ProductEntity prodEnt = this.productDao.getPreviousStateForProduct(pe.getId(), revEnt.getId());
Assert.assertEquals("Product 1", prodEnt.getName());
Assert.assertEquals(Boolean.TRUE, prodEnt.getActive());
Assert.assertEquals(Boolean.TRUE, prodEnt.getWasChecked());
Assert.assertEquals(Double.valueOf(2.4), prodEnt.getPrice());
}
示例6: printRevisions
import org.hibernate.envers.DefaultRevisionEntity; //导入依赖的package包/类
public void printRevisions(List<Object[]> revisions) {
for (Object[] revision : revisions) {
final Project project = (Project) revision[0];
final DefaultRevisionEntity revisionEntity = (DefaultRevisionEntity) revision[1];
final RevisionType revisionType = (RevisionType) revision[2];
System.out.println();
System.out.println(project.toString());
System.out.println(revisionEntity.toString());
System.out.println("REVISION TYPE: " + revisionType.name());
System.out.println();
}
}
示例7: getLongId
import org.hibernate.envers.DefaultRevisionEntity; //导入依赖的package包/类
protected long getLongId(Object o) {
if (o instanceof KarakuRevisionEntity) {
return ((KarakuRevisionEntity) o).getId();
}
return ((DefaultRevisionEntity) o).getId();
}
示例8: getRevisionMetadata
import org.hibernate.envers.DefaultRevisionEntity; //导入依赖的package包/类
private RevisionMetadata<?> getRevisionMetadata(Object object) {
if (object instanceof DefaultRevisionEntity) {
return new DefaultRevisionMetadata((RevisionInfoEntity) object);
} else {
return new AnnotationRevisionMetadata<N>(object, RevisionNumber.class, RevisionTimestamp.class);
}
}
示例9: execute
import org.hibernate.envers.DefaultRevisionEntity; //导入依赖的package包/类
public Object execute(CommandSession session) throws Exception {
Map<Number, DefaultRevisionEntity> revisions = dpService.getRevisions(Long.valueOf( id ));
for (Number revisionNum : revisions.keySet()) {
DefaultRevisionEntity dre = revisions.get( revisionNum );
System.out.println(revisionNum + ": " + dre.getId() + ", " + dre.getTimestamp());
}
return null;
}
示例10: getAllActiveProductsForChecker
import org.hibernate.envers.DefaultRevisionEntity; //导入依赖的package包/类
/**
* Retrieve the active products that need to be checked
*
* @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;
}
示例11: getAllProductDetailsForProductAtRevision
import org.hibernate.envers.DefaultRevisionEntity; //导入依赖的package包/类
/**
* Retrieve all {@link ProductDetailsDTO} related to the given product at
* the given revision
*
* @param prodId
* the id of the {@link ProductEntity}
* @param revisionDateAsLong
* the timestamp of the revision as long
* @return a list of {@link ProductDetailsDTO}
*/
private List<ProductDetailsDTO>
getAllProductDetailsForProductAtRevision(final Long prodId,
final Long revisionDateAsLong) {
/**
* retrieve the information about related product details from the
* {@link ProductDetailsDAO}
*/
final List<Object[]> changes = this.productDetailsDao.getAllProductDetailsForProductAtRevision(prodId,
new Date(revisionDateAsLong));
final List<ProductDetailsDTO> results = new ArrayList<ProductDetailsDTO>();
for (final Object[] revision : changes) {
final ProductDetailsDTO dto = new ProductDetailsDTO();
if (revision.length > 2
&& ProductDetailsEntity.class.isInstance(revision[0])) {
/** get the current value for the {@link ProductDetailsEntity} */
final ProductDetailsEntity currentValue = (ProductDetailsEntity) revision[0];
if (currentValue != null) {
currentValue.setFkProduct(prodId);
}
if (RevisionType.class.isInstance(revision[2])) {
// get the {@link RevisionType} of the current change
final RevisionType rt = (RevisionType) revision[2];
dto.setOperation(rt.name());
// if the revision type was 'MOD' get the previous value of
// the entity to be able to construct the DTO
if (rt == RevisionType.MOD) {
final DefaultRevisionEntity dre = (DefaultRevisionEntity) revision[1];
final ProductDetailsEntity previousValue = this.productDetailsDao.getPreviousStateForProductDetails(currentValue.getId(),
dre.getId());
if (previousValue != null) {
previousValue.setFkProduct(prodId);
}
dto.setInitial(previousValue);
dto.setChanges(currentValue);
}
else {
dto.setChanges(currentValue);
}
}
results.add(dto);
}
}
return results;
}
示例12: getConfiguration
import org.hibernate.envers.DefaultRevisionEntity; //导入依赖的package包/类
/**
* Gets the configuration.
*
* @param clusterId
* the cluster id
* @return the configuration
*/
public List getConfiguration(Long clusterId) {
try {
AuditReader reader = AuditReaderFactory.get(HibernateUtils
.getEntityManager());
AuditQuery query = reader.createQuery().forRevisionsOfEntity(
Configuration.class, false, true);
// filter results besed on cluster id.
query.add(AuditEntity.property(
com.impetus.ankush2.constant.Constant.Keys.CLUSTERID).eq(
clusterId));
query.addOrder(AuditEntity.revisionProperty(
com.impetus.ankush2.constant.Constant.Keys.TIMESTAMP)
.desc());
// Getting Result list.
List list = query.getResultList();
// Creating List Object.
List result = new ArrayList();
for (Object object : list) {
Object[] obj = (Object[]) object;
Map map = new HashMap();
// Mapping Revision Entity.
DefaultRevisionEntity ri = (DefaultRevisionEntity) obj[1];
map.putAll(JsonMapperUtil.mapFromObject(obj[0]));
map.put(com.impetus.ankush2.constant.Constant.Keys.DATE,
ri.getRevisionDate());
map.put(com.impetus.ankush2.constant.Constant.Keys.REVISIONID,
ri.getId());
map.put(com.impetus.ankush2.constant.Constant.Keys.TYPE, obj[2]);
result.add(map);
}
return result;
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
return null;
}
示例13: getRevisions
import org.hibernate.envers.DefaultRevisionEntity; //导入依赖的package包/类
public Map<Number, DefaultRevisionEntity> getRevisions(long id) {
Session s = hibernateUtil.getSession();
AuditReader reader = AuditReaderFactory.get(s);
List<Number> revisionNums = reader.getRevisions( DataPoint.class, id );
return reader.findRevisions( DefaultRevisionEntity.class, new HashSet<Number>(revisionNums) );
}
示例14: getRevisions
import org.hibernate.envers.DefaultRevisionEntity; //导入依赖的package包/类
public Map<Number, DefaultRevisionEntity> getRevisions(long id);