Search in sources :

Example 11 with Product

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

the class ProductVersionProviderImpl method store.

@Override
public ProductVersion store(ProductVersion restEntity) {
    validateBeforeSaving(restEntity);
    org.jboss.pnc.model.ProductVersion productVersionRestDb = mapper.toEntity(restEntity);
    Product product = productRepository.queryById(Integer.valueOf(restEntity.getProduct().getId()));
    productVersionRestDb.generateBrewTagPrefix(product.getAbbreviation(), restEntity.getVersion(), systemConfig.getBrewTagPattern());
    org.jboss.pnc.model.ProductVersion productVersion = repository.save(productVersionRestDb);
    for (BuildConfiguration bc : productVersionRestDb.getBuildConfigurations()) {
        bc.setProductVersion(productVersion);
    }
    repository.flushAndRefresh(productVersion);
    return mapper.toDTO(productVersion);
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) Product(org.jboss.pnc.model.Product)

Aggregations

Product (org.jboss.pnc.model.Product)11 ProductVersion (org.jboss.pnc.model.ProductVersion)6 Test (org.junit.Test)4 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)2 BuildConfigurationSet (org.jboss.pnc.model.BuildConfigurationSet)2 ContainerTest (org.jboss.pnc.test.category.ContainerTest)2 Instant (java.time.Instant)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 TransactionAttribute (javax.ejb.TransactionAttribute)1 Transactional (org.jboss.arquillian.transaction.api.annotation.Transactional)1 ProductRef (org.jboss.pnc.dto.ProductRef)1 ProductVersion (org.jboss.pnc.dto.ProductVersion)1 ConflictedEntryException (org.jboss.pnc.facade.validation.ConflictedEntryException)1 InvalidEntityException (org.jboss.pnc.facade.validation.InvalidEntityException)1 BuildEnvironment (org.jboss.pnc.model.BuildEnvironment)1 ProductMilestone (org.jboss.pnc.model.ProductMilestone)1 ProductMilestoneRelease (org.jboss.pnc.model.ProductMilestoneRelease)1 ProductRelease (org.jboss.pnc.model.ProductRelease)1 Project (org.jboss.pnc.model.Project)1