Search in sources :

Example 6 with Project

use of org.jboss.pnc.model.Project in project pnc by project-ncl.

the class Producers method project.

Project project() {
    Project project = Project.Builder.newBuilder().name(randomAlphabetic(20)).build();
    projectRepository.save(project);
    return project;
}
Also used : Project(org.jboss.pnc.model.Project)

Example 7 with Project

use of org.jboss.pnc.model.Project in project pnc by project-ncl.

the class BuildConfigurationAuditedRepositoryImpl method searchIdRevForBuildConfigurationNameOrProjectName.

@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());
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) DefaultRevisionEntity(org.hibernate.envers.DefaultRevisionEntity) AuditDisjunction(org.hibernate.envers.query.criteria.AuditDisjunction) LoggerFactory(org.slf4j.LoggerFactory) BuildConfigurationAuditedRepository(org.jboss.pnc.spi.datastore.repositories.BuildConfigurationAuditedRepository) BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) BuildRecordRepository(org.jboss.pnc.spi.datastore.repositories.BuildRecordRepository) Inject(javax.inject.Inject) Map(java.util.Map) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) Root(javax.persistence.criteria.Root) Project(org.jboss.pnc.model.Project) Stateless(javax.ejb.Stateless) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Logger(org.slf4j.Logger) BuildRecord_(org.jboss.pnc.model.BuildRecord_) Set(java.util.Set) BuildRecord(org.jboss.pnc.model.BuildRecord) EntityManager(javax.persistence.EntityManager) Collectors(java.util.stream.Collectors) IdRev(org.jboss.pnc.model.IdRev) List(java.util.List) AuditReaderFactory(org.hibernate.envers.AuditReaderFactory) AuditEntity(org.hibernate.envers.query.AuditEntity) Base32LongID(org.jboss.pnc.model.Base32LongID) DefaultRevisionEntity(org.hibernate.envers.DefaultRevisionEntity) AuditDisjunction(org.hibernate.envers.query.criteria.AuditDisjunction) IdRev(org.jboss.pnc.model.IdRev)

Example 8 with Project

use of org.jboss.pnc.model.Project in project pnc by project-ncl.

the class DatastoreAdapter method loadBuildConfigurations.

/**
 * Fetch build configurations of project to be able access it outside transaction
 *
 * @param buildConfigAudited build config for which the build configurations are to be fetched
 */
private void loadBuildConfigurations(BuildConfigurationAudited buildConfigAudited) {
    Project project = buildConfigAudited.getProject();
    project.getBuildConfigurations().forEach(BuildConfiguration::getId);
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) Project(org.jboss.pnc.model.Project)

Aggregations

Project (org.jboss.pnc.model.Project)8 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)7 Date (java.util.Date)2 RepositoryConfiguration (org.jboss.pnc.model.RepositoryConfiguration)2 BuildOptions (org.jboss.pnc.spi.BuildOptions)2 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)2 Instant (java.time.Instant)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Stateless (javax.ejb.Stateless)1 TransactionAttribute (javax.ejb.TransactionAttribute)1 Inject (javax.inject.Inject)1 EntityManager (javax.persistence.EntityManager)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)1 Root (javax.persistence.criteria.Root)1 AuditReaderFactory (org.hibernate.envers.AuditReaderFactory)1