Search in sources :

Example 11 with ProductMilestone

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

the class ProductReleaseProviderTest method createNewProductReleaseDTO.

private org.jboss.pnc.dto.ProductRelease createNewProductReleaseDTO(String version, Integer id) {
    // when
    ProductMilestone milestone = prepareNewProductMilestone();
    when(productRepository.queryById(milestone.getProductVersion().getProduct().getId())).thenReturn(milestone.getProductVersion().getProduct());
    when(productVersionRepository.queryById(milestone.getProductVersion().getId())).thenReturn(milestone.getProductVersion());
    when(productMilestoneRepository.queryById(milestone.getId())).thenReturn(milestone);
    ProductMilestoneRef ref = productMilestoneMapper.toRef(milestone);
    ProductVersionRef productVersionRef = productVersionMapper.toRef(milestone.getProductVersion());
    org.jboss.pnc.dto.ProductRelease.Builder releaseDTO = org.jboss.pnc.dto.ProductRelease.builder().version(version).productVersion(productVersionRef).productMilestone(ref);
    if (id != null) {
        return releaseDTO.id(id.toString()).build();
    } else {
        return releaseDTO.build();
    }
}
Also used : ProductMilestone(org.jboss.pnc.model.ProductMilestone) ProductRelease(org.jboss.pnc.model.ProductRelease) ProductMilestoneRef(org.jboss.pnc.dto.ProductMilestoneRef) ProductVersionRef(org.jboss.pnc.dto.ProductVersionRef)

Example 12 with ProductMilestone

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

the class ProductVersionProviderTest method testShouldThrowWhenCurrentMilestoneIsClosed.

@Test
public void testShouldThrowWhenCurrentMilestoneIsClosed() {
    String newVersion = "19.0";
    org.jboss.pnc.dto.ProductVersion withClosedMilestone = provider.getSpecific("2");
    ProductMilestoneRef closedMilestone = withClosedMilestone.getProductMilestones().values().iterator().next();
    org.jboss.pnc.dto.ProductVersion updated = withClosedMilestone.toBuilder().currentProductMilestone(closedMilestone).build();
    ProductMilestone closedReturn = new ProductMilestone();
    closedReturn.setId(Integer.parseInt(closedMilestone.getId()));
    closedReturn.setEndDate(new Date());
    when(milestoneRepository.queryById(anyInt())).thenReturn(closedReturn);
    assertThatThrownBy(() -> provider.update(withClosedMilestone.getId(), updated)).isInstanceOf(InvalidEntityException.class);
}
Also used : ProductMilestone(org.jboss.pnc.model.ProductMilestone) ProductMilestoneRef(org.jboss.pnc.dto.ProductMilestoneRef) Test(org.junit.Test)

Example 13 with ProductMilestone

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

the class ProductMilestoneReleaseManager method onPushResult.

private void onPushResult(Integer milestoneId, MilestoneReleaseResultRest result) {
    log.debug("Storing milestone release result: {}", result);
    ProductMilestone milestone = milestoneRepository.queryById(milestoneId);
    if (milestone == null) {
        log.error("No milestone found for milestone id {}", milestoneId);
        return;
    }
    storeResult(milestone, result);
    userLog.info("Milestone release result stored.");
}
Also used : ProductMilestone(org.jboss.pnc.model.ProductMilestone)

Example 14 with ProductMilestone

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

the class ProductMilestoneReleaseManager method cancel.

public void cancel(ProductMilestone milestoneInDb, String accessToken, boolean useRHPAM) {
    if (!useRHPAM) {
        Collection<BpmTask> activeTasks = bpmManager.getActiveTasks();
        Optional<MilestoneReleaseTask> milestoneReleaseTask = activeTasks.stream().map(task -> (MilestoneReleaseTask) task).filter(task -> task.getMilestone().getId().equals(milestoneInDb.getId())).findAny();
        if (milestoneReleaseTask.isPresent()) {
            bpmManager.cancelTask(milestoneReleaseTask.get());
        }
    } else {
        RestConnector restConnector = new RestConnector(bpmConfig);
        restConnector.cancelByCorrelation(Numbers.decimalToBase32(milestoneInDb.getId()), accessToken);
    }
    ProductMilestoneRelease milestoneRelease = productMilestoneReleaseRepository.findLatestByMilestone(milestoneInDb);
    milestoneRelease.setStatus(MilestoneCloseStatus.CANCELED);
    productMilestoneReleaseRepository.save(milestoneRelease);
}
Also used : GlobalModuleGroup(org.jboss.pnc.common.json.GlobalModuleGroup) BuildImportResultRest(org.jboss.pnc.bpm.model.causeway.BuildImportResultRest) Date(java.util.Date) CollectionUtils.ofNullableCollection(org.jboss.pnc.common.util.CollectionUtils.ofNullableCollection) LoggerFactory(org.slf4j.LoggerFactory) BpmTask(org.jboss.pnc.bpm.BpmTask) Function(java.util.function.Function) BuildMapper(org.jboss.pnc.mapper.api.BuildMapper) BuildRecordRepository(org.jboss.pnc.spi.datastore.repositories.BuildRecordRepository) Inject(javax.inject.Inject) ProductMilestoneRepository(org.jboss.pnc.spi.datastore.repositories.ProductMilestoneRepository) BuildRecordPushResult(org.jboss.pnc.model.BuildRecordPushResult) ProductMilestoneRelease(org.jboss.pnc.model.ProductMilestoneRelease) BuildPushStatus(org.jboss.pnc.enums.BuildPushStatus) BpmManager(org.jboss.pnc.bpm.BpmManager) ProductMilestone(org.jboss.pnc.model.ProductMilestone) ProductVersionRepository(org.jboss.pnc.spi.datastore.repositories.ProductVersionRepository) BpmEventType(org.jboss.pnc.bpm.BpmEventType) BuildImportStatus(org.jboss.pnc.bpm.model.causeway.BuildImportStatus) ProductVersion(org.jboss.pnc.model.ProductVersion) Event(javax.enterprise.event.Event) Stateless(javax.ejb.Stateless) MilestoneReleaseTask(org.jboss.pnc.bpm.task.MilestoneReleaseTask) Logger(org.slf4j.Logger) Collection(java.util.Collection) RestConnector(org.jboss.pnc.bpm.RestConnector) BuildRecord(org.jboss.pnc.model.BuildRecord) NoEntityException(org.jboss.pnc.bpm.NoEntityException) MilestoneReleaseResultRest(org.jboss.pnc.bpm.model.causeway.MilestoneReleaseResultRest) ProductMilestoneReleaseRepository(org.jboss.pnc.spi.datastore.repositories.ProductMilestoneReleaseRepository) CoreException(org.jboss.pnc.spi.exception.CoreException) BuildRecordPushResultRepository(org.jboss.pnc.spi.datastore.repositories.BuildRecordPushResultRepository) ProductMilestoneCloseResult(org.jboss.pnc.dto.ProductMilestoneCloseResult) Optional(java.util.Optional) ProcessManagerException(org.jboss.pnc.spi.exception.ProcessManagerException) ProductMilestoneCloseResultMapper(org.jboss.pnc.mapper.api.ProductMilestoneCloseResultMapper) BpmModuleConfig(org.jboss.pnc.common.json.moduleconfig.BpmModuleConfig) Sequence(org.jboss.pnc.common.concurrent.Sequence) Numbers(org.jboss.pnc.common.Numbers) MilestoneCloseStatus(org.jboss.pnc.enums.MilestoneCloseStatus) Base32LongID(org.jboss.pnc.model.Base32LongID) RestConnector(org.jboss.pnc.bpm.RestConnector) BpmTask(org.jboss.pnc.bpm.BpmTask) MilestoneReleaseTask(org.jboss.pnc.bpm.task.MilestoneReleaseTask) ProductMilestoneRelease(org.jboss.pnc.model.ProductMilestoneRelease)

Example 15 with ProductMilestone

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

the class OperationsManagerImpl method newDeliverableAnalyzerOperation.

@Override
public DeliverableAnalyzerOperation newDeliverableAnalyzerOperation(String milestoneId, Map<String, String> inputParams) {
    ProductMilestone milestone = productMilestoneRepository.queryById(ProductMilestoneMapper.idMapper.toEntity(milestoneId));
    if (milestone == null) {
        throw new EmptyEntityException("Milestone with id " + milestoneId + " doesn't exist");
    }
    String operationId = Sequence.nextBase32Id();
    MDCUtils.addProcessContext(operationId);
    org.jboss.pnc.model.DeliverableAnalyzerOperation operation = org.jboss.pnc.model.DeliverableAnalyzerOperation.Builder.newBuilder().progressStatus(ProgressStatus.NEW).submitTime(Date.from(Instant.now())).productMilestone(milestone).operationParameters(inputParams).user(userService.currentUser()).id(operationId).build();
    repository.save(operation);
    analysisStatusChangedEventNotifier.fire(new OperationChangedEvent(operation, null));
    return operation;
}
Also used : EmptyEntityException(org.jboss.pnc.facade.validation.EmptyEntityException) DeliverableAnalyzerOperation(org.jboss.pnc.model.DeliverableAnalyzerOperation) ProductMilestone(org.jboss.pnc.model.ProductMilestone)

Aggregations

ProductMilestone (org.jboss.pnc.model.ProductMilestone)15 Date (java.util.Date)4 Test (org.junit.Test)4 ProductMilestoneRelease (org.jboss.pnc.model.ProductMilestoneRelease)3 Optional (java.util.Optional)2 ProductMilestoneRef (org.jboss.pnc.dto.ProductMilestoneRef)2 BuildConfigSetRecord (org.jboss.pnc.model.BuildConfigSetRecord)2 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)2 BuildConfigurationSet (org.jboss.pnc.model.BuildConfigurationSet)2 BuildRecord (org.jboss.pnc.model.BuildRecord)2 ProductRelease (org.jboss.pnc.model.ProductRelease)2 ProductVersion (org.jboss.pnc.model.ProductVersion)2 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1