当前位置: 首页>>代码示例>>Java>>正文


Java AuditReader.getRevisions方法代码示例

本文整理汇总了Java中org.hibernate.envers.AuditReader.getRevisions方法的典型用法代码示例。如果您正苦于以下问题:Java AuditReader.getRevisions方法的具体用法?Java AuditReader.getRevisions怎么用?Java AuditReader.getRevisions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.envers.AuditReader的用法示例。


在下文中一共展示了AuditReader.getRevisions方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRevisions

import org.hibernate.envers.AuditReader; //导入方法依赖的package包/类
public List<Revision> getRevisions(String id, Params params) {

        AuditReader reader = getAuditReader();

        List<Number> revisionNumbers = reader.getRevisions(type, id);
        Map<Number, Revision> revisionMap = reader.findRevisions(Revision.class, asSet(revisionNumbers));
        Collection<Revision> revisions = revisionMap.values();

        Comparator<Revision> timestampComparator = Comparator.comparingLong(Revision::getTimestamp);
        Comparator<Revision> authorComparator = Comparator.comparing(Revision::getAuthor);

        Comparator<Revision> comparator;
        if (AUTHOR.equals(params.getSort())) {
            comparator = authorComparator;
        } else {
            comparator = timestampComparator;
        }

        if (params.getOrder() == Order.DESC) {
            comparator = comparator.reversed();
        }

        return Ordering.from(comparator)
                       .sortedCopy(revisions);
    }
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:26,代码来源:HistoricStore.java

示例2: getHeadRevisionNumber

import org.hibernate.envers.AuditReader; //导入方法依赖的package包/类
/**
 * 
 * @param id
 * @return
 */
public int getHeadRevisionNumber(int id) {
    int result = 0;
    try {
        begin();
        AuditReader reader = AuditReaderFactory.get(getEntityManager());
        List<Number> revisions = reader.getRevisions(entityClass, id);
        if (!revisions.isEmpty()) {
            result = revisions.get(revisions.size() - 1).intValue();
        }
        commit();
    } catch (NoResultException e) {
    	rollback();
        LOG.warn("No result for revision with id of " + id);
    } finally {
        cleanup();
    }
    return result;
}
 
开发者ID:intuit,项目名称:Tank,代码行数:24,代码来源:BaseDao.java

示例3: findAllHistory

import org.hibernate.envers.AuditReader; //导入方法依赖的package包/类
public List<HistoryDto> findAllHistory(String username) {

		Patient patientA = patientRepository.findByUsername(username);
		Long patientId = patientA.getId();

		EntityManager em = entityManagerFactory.createEntityManager();
		AuditReader reader = AuditReaderFactory.get(em);
		List<Number> revisions = reader.getRevisions(Patient.class, patientId);
		List<HistoryDto> historyList = findHistoryDetails(revisions);
		List<HistoryDto> legalHistoryList = findLegalHistoryByPatient(patientId);
		historyList.addAll(legalHistoryList);
		Collections.sort(historyList);

		List<HistoryDto> historyListReverse = getReversed(historyList);
		em.close();
		return historyListReverse;
	}
 
开发者ID:tlin-fei,项目名称:ds4p,代码行数:18,代码来源:AuditServiceImpl.java

示例4: findLastChangeRevision

import org.hibernate.envers.AuditReader; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Revision<N, T> findLastChangeRevision(ID id) {
	Class<T> type = entityInformation.getJavaType();
	AuditReader reader = AuditReaderFactory.get(entityManager);

	List<Number> revisions = reader.getRevisions(type, id);

	if (revisions.isEmpty()) {
		return null;
	}

	N latestRevision = (N) revisions.get(revisions.size() - 1);

	Class<?> revisionEntityClass = revisionEntityInformation.getRevisionEntityClass();

	Object revisionEntity = reader.findRevision(revisionEntityClass, latestRevision);
	RevisionMetadata<N> metadata = (RevisionMetadata<N>) getRevisionMetadata(revisionEntity);
	return new Revision<N, T>(metadata, reader.find(type, id, latestRevision));
}
 
开发者ID:zakyalvan,项目名称:spring-envers-audit,代码行数:21,代码来源:DefaultRevisionAwareJpaRepository.java

示例5: findRevisions

import org.hibernate.envers.AuditReader; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Page<Revision<N, T>> findRevisions(ID id, Pageable pageable) {
	Class<T> type = entityInformation.getJavaType();
	AuditReader reader = AuditReaderFactory.get(entityManager);
	List<Number> revisionNumbers = reader.getRevisions(type, id);

	if (pageable.getOffset() > revisionNumbers.size()) {
		return new PageImpl<Revision<N, T>>(Collections.<Revision<N, T>> emptyList(), pageable, 0);
	}

	int upperBound = pageable.getOffset() + pageable.getPageSize();
	upperBound = upperBound > revisionNumbers.size() ? revisionNumbers.size() : upperBound;

	List<? extends Number> subList = revisionNumbers.subList(pageable.getOffset(), upperBound);
	Revisions<N, T> revisions = getEntitiesForRevisions((List<N>) subList, id, reader);

	return new PageImpl<Revision<N, T>>(revisions.getContent(), pageable, revisionNumbers.size());
}
 
开发者ID:zakyalvan,项目名称:spring-envers-audit,代码行数:20,代码来源:DefaultRevisionAwareJpaRepository.java

示例6: getHistoryChanges

import org.hibernate.envers.AuditReader; //导入方法依赖的package包/类
@Override
public List<DefiniteResult> getHistoryChanges(ProcessResult processResultImpl) {

    List<DefiniteResult> history = new ArrayList<>();
    AuditReader auditReader = AuditReaderFactory.get(this.entityManager);
    Long id = processResultImpl.getId();
    if (id == null) {
        return new ArrayList<>();
    }
    List<Number> revisions = auditReader.getRevisions(processResultImpl.getClass(), id);
    DefiniteResult find = null;
    for (int i = 0; i < revisions.size(); i++) {
        Number revision = revisions.get(i);
        find = auditReader.find(DefiniteResultImpl.class, id, revision);
        history.add(find);
    }

    return history;

}
 
开发者ID:Tanaguru,项目名称:Tanaguru,代码行数:21,代码来源:ProcessResultDAOImpl.java

示例7: getRevisionHistoryMetadata

import org.hibernate.envers.AuditReader; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public List<RevisionMetadata> getRevisionHistoryMetadata(Object id) {

  AuditReader auditReader = getAuditReader();
  List<Number> revisionList = auditReader.getRevisions(getEntityClass(), id);
  List<RevisionMetadata> result = new ArrayList<RevisionMetadata>();
  for (Number revision : revisionList) {
    Long revisionLong = Long.valueOf(revision.longValue());
    result.add(new LazyRevisionMetadata(this.persistenceManager, revisionLong));
  }
  return result;
}
 
开发者ID:m-m-m,项目名称:persistence,代码行数:16,代码来源:AbstractRevisionedDaoEnvers.java

示例8: findRevisions

import org.hibernate.envers.AuditReader; //导入方法依赖的package包/类
public List<RevisionInfo> findRevisions(String id) {
    List<RevisionInfo> list = new ArrayList<>();
    AuditReader reader = AuditReaderFactory.get(getEntityManager());
    List<Number> revisions = reader.getRevisions(getEntityClass(), id);
    for (Number n : revisions) {
        CustomRevisionEntity revEntity = reader.findRevision(CustomRevisionEntity.class, n);
        list.add(new RevisionInfo(n, revEntity));
    }
    return list;
}
 
开发者ID:oregami,项目名称:oregami-server,代码行数:11,代码来源:GenericDAOUUIDImpl.java

示例9: findRevision

import org.hibernate.envers.AuditReader; //导入方法依赖的package包/类
public E findRevision(String id, Number revision) {
    AuditReader reader = AuditReaderFactory.get(getEntityManager());
    List<Number> revisions = reader.getRevisions(getEntityClass(), id);
    if (!revisions.contains(revision)) {
        return null;
    }
    E entity = reader.find(getEntityClass(), id, revision);
    return entity;
}
 
开发者ID:oregami,项目名称:oregami-server,代码行数:10,代码来源:GenericDAOUUIDImpl.java

示例10: findLegalHistoryByPatient

import org.hibernate.envers.AuditReader; //导入方法依赖的package包/类
public List<HistoryDto> findLegalHistoryByPatient(long patientId) {

		EntityManager em2 = entityManagerFactory.createEntityManager();
		AuditReader reader2 = AuditReaderFactory.get(em2);

		Set<Number> legalList = new HashSet<Number>();

		List<ModifiedEntityTypeEntity> metes = modifiedEntityTypeEntityRepository
				.findAll();
		for (ModifiedEntityTypeEntity m : metes) {
			String entityname = m.getEntityClassName()
					.substring(m.getEntityClassName().lastIndexOf('.') + 1)
					.trim();
			if (entityname.equals("PatientLegalRepresentativeAssociation")) {
				long revisionId = m.getRevision().getId();
				Byte bt = m.getRevisionType();

				if (bt != 2) {
					AuditQuery query = reader2
							.createQuery()
							.forEntitiesAtRevision(
									PatientLegalRepresentativeAssociation.class,
									revisionId);
					
					List<PatientLegalRepresentativeAssociation> psList = (List<PatientLegalRepresentativeAssociation>) query.getResultList();
					for (PatientLegalRepresentativeAssociation ps : psList) {
						PatientLegalRepresentativeAssociationPk pks=ps.getPatientLegalRepresentativeAssociationPk();
						Patient pl=pks.getPatient();
						if(pl!=null)
						{
						if (patientId == pl.getId()) {

							Long LegalId = ps.getId();
							List<Number> revisionListLegal = reader2
									.getRevisions(
											PatientLegalRepresentativeAssociation.class,
											LegalId);
							legalList.addAll(revisionListLegal);

							Long LegalRepId = ps
									.getPatientLegalRepresentativeAssociationPk()
									.getLegalRepresentative().getId();
							List<Number> revisionListLegal2 = reader2
									.getRevisions(Patient.class, LegalRepId);

							legalList.addAll(revisionListLegal2);

						}
						}
					}

				}

			}

		}
		Set<Number> removeLegalList = new HashSet<Number>();
		for (Number a : legalList) {
			RevisionInfoEntity patientRevisionEntity = patientRevisionEntityRepository
					.findOneById(a);
			List<ModifiedEntityTypeEntity> meteLegalLists = modifiedEntityTypeEntityRepository
					.findAllByRevision(patientRevisionEntity);
			for (ModifiedEntityTypeEntity meteLegal : meteLegalLists) {
				if (meteLegal.getRevisionType() == 0) {
					String en = new String(meteLegal.getEntityClassName());
					if (en.substring(en.lastIndexOf('.') + 1).trim()
							.equals("Patient")) {
						removeLegalList.add(a);
					}
				}

			}
		}
		legalList.removeAll(removeLegalList);
		em2.close();
		List<Number> legalList2 = new ArrayList<Number>(legalList);
		List<HistoryDto> historyLegals = (List<HistoryDto>) findLegalHistoryDetails(legalList2);
		return historyLegals;
	}
 
开发者ID:tlin-fei,项目名称:ds4p,代码行数:80,代码来源:AuditServiceImpl.java

示例11: getRevisions

import org.hibernate.envers.AuditReader; //导入方法依赖的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) );
}
 
开发者ID:hibernate,项目名称:hibernate-demos,代码行数:7,代码来源:DataPointServiceImpl.java

示例12: testRegion

import org.hibernate.envers.AuditReader; //导入方法依赖的package包/类
@Test
	public void testRegion() {

		entityManager.getTransaction().begin();

		RegionDao regionDao = injector.getInstance(RegionDao.class);

		Region germany = new Region(Region.GERMANY);
		String id1 = regionDao.save(germany);
		Assert.assertNotNull("ID expected", id1);

		List<Region> all = regionDao.findAll();
		Assert.assertTrue("1 Region expected", all.size()==1);

		Region europe = new Region(Region.EUROPE);
		String id2 = regionDao.save(europe);

		all = regionDao.findAll();
		Assert.assertTrue("2 Regions expected", all.size()==2);

		entityManager.getTransaction().commit();



		entityManager.getTransaction().begin();
		Region loadedGermany = regionDao.findByExactName(Region.GERMANY);
		Assert.assertNotNull(loadedGermany);
		Assert.assertEquals(loadedGermany.getId(), id1);
		Assert.assertEquals(loadedGermany, germany);

		Region loadedEurope = regionDao.findByExactName(Region.EUROPE);
		Assert.assertNotNull(loadedEurope);
		Assert.assertEquals(loadedEurope.getId(), id2);
		Assert.assertEquals(loadedEurope, europe);

		loadedEurope.setDescription("this is changed europe");
		regionDao.save(loadedEurope);

		all = regionDao.findAll();
		Assert.assertTrue("2 Regions expected", all.size()==2);
		entityManager.getTransaction().commit();


		entityManager.getTransaction().begin();
		Region loadedEurope2 = regionDao.findByExactName(Region.EUROPE);
		loadedEurope2.setDescription("this is twice changed europe");
		regionDao.save(loadedEurope);
		entityManager.getTransaction().commit();


		entityManager.getTransaction().begin();
		AuditReader auditReader = AuditReaderFactory.get(entityManager);
		List<Number> revisionNumbers = auditReader.getRevisions(Region.class, loadedEurope.getId());
//		System.out.println(revisionNumbers + " revisions found.");
		for (Number number : revisionNumbers) {
//			System.out.println("RevisionNumber: " + number);
			Region regionWithRevision = auditReader.find(Region.class, loadedEurope.getId(), number);
//			try {
//				System.out.println("Region with revision " + number + "\n"
//						+ new ObjectMapper().writeValueAsString(regionWithRevision));
//			} catch (JsonProcessingException e) {
//				Assert.fail(e.getMessage());
//			}
            Assert.assertNotNull(regionWithRevision);
		}
		entityManager.getTransaction().commit();



        entityManager.getTransaction().begin();
        regionDao.delete(loadedEurope);
        regionDao.delete(loadedGermany);
        List<Region> regionList = regionDao.findAll();
        Assert.assertEquals(0, regionList.size());
        entityManager.getTransaction().commit();



	}
 
开发者ID:oregami,项目名称:oregami-server,代码行数:80,代码来源:RegionRevisionTest.java


注:本文中的org.hibernate.envers.AuditReader.getRevisions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。