org.hibernate.envers.DefaultRevisionEntity Java Examples
The following examples show how to use
org.hibernate.envers.DefaultRevisionEntity.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BuildConfigurationAuditedRepositoryImpl.java From pnc with Apache License 2.0 | 6 votes |
@Override public List<IdRev> searchIdRevForBuildConfigurationNameOrProjectName( List<Project> projectsMatchingName, String name) { AuditDisjunction disjunction = AuditEntity.disjunction(); projectsMatchingName.forEach(project -> { disjunction.add(AuditEntity.relatedId("project").eq(project.getId())); }); disjunction.add(AuditEntity.property("name").like(name)); List<Object[]> result = AuditReaderFactory.get(entityManager) .createQuery() .forRevisionsOfEntity(BuildConfiguration.class, false, false) .add(disjunction) .addOrder(AuditEntity.revisionNumber().desc()) .getResultList(); return result.stream().map(o -> { BuildConfiguration buildConfiguration = (BuildConfiguration) o[0]; DefaultRevisionEntity revisionEntity = (DefaultRevisionEntity) o[1]; return new IdRev(buildConfiguration.getId(), revisionEntity.getId()); }).collect(Collectors.toList()); }
Example #2
Source File: EnversDemo.java From HibernateDemos with The Unlicense | 5 votes |
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(); } }
Example #3
Source File: BuildConfigurationAuditedRepositoryImpl.java From pnc with Apache License 2.0 | 5 votes |
private BuildConfigurationAudited createAudited(Object entity, Object revision) { BuildConfiguration buildConfiguration = (BuildConfiguration) entity; DefaultRevisionEntity revisionEntity = (DefaultRevisionEntity) revision; // preload generic parameters buildConfiguration.getGenericParameters().forEach((k, v) -> k.equals(null)); return BuildConfigurationAudited.fromBuildConfiguration(buildConfiguration, revisionEntity.getId()); }
Example #4
Source File: BuildConfigurationAuditedRepositoryImpl.java From pnc with Apache License 2.0 | 5 votes |
@Override public List<IdRev> searchIdRevForBuildConfigurationName(String buildConfigurationName) { List<Object[]> result = AuditReaderFactory.get(entityManager) .createQuery() .forRevisionsOfEntity(BuildConfiguration.class, false, false) .add(AuditEntity.property("name").like(buildConfigurationName)) .addOrder(AuditEntity.revisionNumber().desc()) .getResultList(); return result.stream().map(o -> { BuildConfiguration buildConfiguration = (BuildConfiguration) o[0]; DefaultRevisionEntity revisionEntity = (DefaultRevisionEntity) o[1]; return new IdRev(buildConfiguration.getId(), revisionEntity.getId()); }).collect(Collectors.toList()); }
Example #5
Source File: BuildConfigurationAuditedRepositoryImpl.java From pnc with Apache License 2.0 | 5 votes |
@Override public List<IdRev> searchIdRevForProjectId(Integer projectId) { List<Object[]> result = AuditReaderFactory.get(entityManager) .createQuery() .forRevisionsOfEntity(BuildConfiguration.class, false, false) .add(AuditEntity.relatedId("project").eq(projectId)) .addOrder(AuditEntity.revisionNumber().desc()) .getResultList(); return result.stream().map(o -> { BuildConfiguration buildConfiguration = (BuildConfiguration) o[0]; DefaultRevisionEntity revisionEntity = (DefaultRevisionEntity) o[1]; return new IdRev(buildConfiguration.getId(), revisionEntity.getId()); }).collect(Collectors.toList()); }
Example #6
Source File: BasicModelTest.java From pnc with Apache License 2.0 | 5 votes |
private BuildConfigurationAudited findBuildConfigurationAudited(EntityManager em) { List<Object[]> result = AuditReaderFactory.get(em) .createQuery() .forRevisionsOfEntity(BuildConfiguration.class, false, false) .addOrder(AuditEntity.revisionNumber().desc()) .getResultList(); Object[] second = result.get(1); BuildConfiguration buildConfiguration = (BuildConfiguration) second[0]; return BuildConfigurationAudited .fromBuildConfiguration(buildConfiguration, ((DefaultRevisionEntity) second[1]).getId()); }
Example #7
Source File: ConfigurationManager.java From ankush with GNU Lesser General Public License v3.0 | 5 votes |
/** * 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; }
Example #8
Source File: GetRevisionsCommand.java From hibernate-demos with Apache License 2.0 | 5 votes |
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; }
Example #9
Source File: EnversDemo.java From hibernate-demos with Apache License 2.0 | 5 votes |
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(); } }
Example #10
Source File: ArtifactAuditedRepositoryImpl.java From pnc with Apache License 2.0 | 4 votes |
private ArtifactAudited createAudited(Object entity, Object revision) { Artifact artifact = (Artifact) entity; DefaultRevisionEntity revisionEntity = (DefaultRevisionEntity) revision; return ArtifactAudited.fromArtifact(artifact, revisionEntity.getId()); }
Example #11
Source File: DataPointServiceImpl.java From hibernate-demos with Apache License 2.0 | 4 votes |
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) ); }
Example #12
Source File: DataPointService.java From hibernate-demos with Apache License 2.0 | votes |
public Map<Number, DefaultRevisionEntity> getRevisions(long id);