Search in sources :

Example 1 with AssessmentRatingDetail

use of org.finos.waltz.model.assessment_rating.AssessmentRatingDetail in project waltz by khartec.

the class AssessmentHarness method main.

public static void main(String[] args) throws ParseException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    AssessmentRatingViewService viewSvc = ctx.getBean(AssessmentRatingViewService.class);
    Set<AssessmentRatingDetail> assessments = viewSvc.findFavouriteAssessmentsForEntityAndUser(mkRef(EntityKind.APPLICATION, 20506L), "jessica.woodland-scott@db.com");
    System.out.println("done");
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) AssessmentRatingViewService(org.finos.waltz.service.assessment_rating.AssessmentRatingViewService) AssessmentRatingDetail(org.finos.waltz.model.assessment_rating.AssessmentRatingDetail)

Example 2 with AssessmentRatingDetail

use of org.finos.waltz.model.assessment_rating.AssessmentRatingDetail in project waltz by khartec.

the class ChangeUnitViewService method findPhysicalFlowChangeUnitsByChangeSetId.

public Set<PhysicalFlowChangeUnitViewItem> findPhysicalFlowChangeUnitsByChangeSetId(long changeSetId) {
    IdSelectionOptions idSelectionOptions = mkOptsForAllLifecycleStates(mkRef(EntityKind.CHANGE_SET, changeSetId), HierarchyQueryScope.EXACT);
    Collection<PhysicalFlow> physicalFlows = physicalFlowService.findBySelector(idSelectionOptions);
    Collection<PhysicalSpecification> physicalSpecs = physicalSpecificationService.findByIds(map(physicalFlows, PhysicalFlow::specificationId));
    // TODO: Move to a logical flow selector based upon change set #5626
    Collection<LogicalFlow> logicalFlows = logicalFlowService.findAllByFlowIds(map(physicalFlows, PhysicalFlow::logicalFlowId));
    List<AssessmentRating> assessmentRatings = assessmentRatingService.findByTargetKindForRelatedSelector(EntityKind.CHANGE_UNIT, idSelectionOptions);
    Map<Long, RatingSchemeItem> ratingSchemeItemsById = indexBy(ratingSchemeService.getAllRatingSchemeItems(), item -> item.id().get());
    Map<Long, PhysicalFlow> physicalFlowsById = indexBy(physicalFlows, flow -> flow.id().get());
    Map<Long, LogicalFlow> logicalFlowsById = indexBy(logicalFlows, flow -> flow.id().get());
    Map<Long, PhysicalSpecification> specsById = indexBy(physicalSpecs, spec -> spec.id().get());
    Map<Long, Collection<AssessmentRating>> assessmentRatingsByEntityId = groupBy(rating -> rating.entityReference().id(), assessmentRatings);
    List<ChangeUnit> changeUnits = changeUnitService.findByChangeSetId(changeSetId);
    return changeUnits.stream().filter(cu -> cu.subjectEntity().kind().equals(EntityKind.PHYSICAL_FLOW)).map(cu -> {
        PhysicalFlow physicalFlow = physicalFlowsById.get(cu.subjectEntity().id());
        PhysicalSpecification spec = specsById.get(physicalFlow.specificationId());
        LogicalFlow logicalFlow = logicalFlowsById.get(physicalFlow.logicalFlowId());
        Long changeUnitId = cu.id().get();
        Collection<AssessmentRating> assessmentRatingsForChangeUnit = assessmentRatingsByEntityId.getOrDefault(changeUnitId, emptySet());
        Set<AssessmentRatingDetail> assessmentRatingDetailForChangeUnit = map(assessmentRatingsForChangeUnit, rating -> mkAssessmentDefinitionDetail(rating, ratingSchemeItemsById.get(rating.ratingId())));
        return ImmutablePhysicalFlowChangeUnitViewItem.builder().changeUnit(cu).physicalSpecification(spec).logicalFlow(logicalFlow).assessments(assessmentRatingDetailForChangeUnit).build();
    }).collect(toSet());
}
Also used : ChangeUnit(org.finos.waltz.model.change_unit.ChangeUnit) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) PhysicalSpecificationService(org.finos.waltz.service.physical_specification.PhysicalSpecificationService) EntityKind(org.finos.waltz.model.EntityKind) PhysicalFlowChangeUnitViewItem(org.finos.waltz.model.change_unit.PhysicalFlowChangeUnitViewItem) AssessmentRating(org.finos.waltz.model.assessment_rating.AssessmentRating) Autowired(org.springframework.beans.factory.annotation.Autowired) RatingSchemeService(org.finos.waltz.service.rating_scheme.RatingSchemeService) AssessmentRatingDetail(org.finos.waltz.model.assessment_rating.AssessmentRatingDetail) PhysicalFlow(org.finos.waltz.model.physical_flow.PhysicalFlow) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) SetUtilities.map(org.finos.waltz.common.SetUtilities.map) ImmutablePhysicalFlowChangeUnitViewItem(org.finos.waltz.model.change_unit.ImmutablePhysicalFlowChangeUnitViewItem) RatingSchemeItem(org.finos.waltz.model.rating.RatingSchemeItem) Service(org.springframework.stereotype.Service) MapUtilities.groupBy(org.finos.waltz.common.MapUtilities.groupBy) Map(java.util.Map) LogicalFlowService(org.finos.waltz.service.logical_flow.LogicalFlowService) Collectors.toSet(java.util.stream.Collectors.toSet) IdSelectionOptions.mkOptsForAllLifecycleStates(org.finos.waltz.model.IdSelectionOptions.mkOptsForAllLifecycleStates) PhysicalFlowService(org.finos.waltz.service.physical_flow.PhysicalFlowService) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) Collections.emptySet(java.util.Collections.emptySet) Collection(java.util.Collection) Set(java.util.Set) MapUtilities.indexBy(org.finos.waltz.common.MapUtilities.indexBy) List(java.util.List) Checks.checkNotNull(org.finos.waltz.common.Checks.checkNotNull) AssessmentRatingService(org.finos.waltz.service.assessment_rating.AssessmentRatingService) PhysicalSpecification(org.finos.waltz.model.physical_specification.PhysicalSpecification) ImmutableAssessmentRatingDetail(org.finos.waltz.model.assessment_rating.ImmutableAssessmentRatingDetail) HierarchyQueryScope(org.finos.waltz.model.HierarchyQueryScope) PhysicalSpecification(org.finos.waltz.model.physical_specification.PhysicalSpecification) Collectors.toSet(java.util.stream.Collectors.toSet) Collections.emptySet(java.util.Collections.emptySet) Set(java.util.Set) ChangeUnit(org.finos.waltz.model.change_unit.ChangeUnit) RatingSchemeItem(org.finos.waltz.model.rating.RatingSchemeItem) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) AssessmentRating(org.finos.waltz.model.assessment_rating.AssessmentRating) Collection(java.util.Collection) PhysicalFlow(org.finos.waltz.model.physical_flow.PhysicalFlow) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions)

Aggregations

AssessmentRatingDetail (org.finos.waltz.model.assessment_rating.AssessmentRatingDetail)2 Collection (java.util.Collection)1 Collections.emptySet (java.util.Collections.emptySet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 Checks.checkNotNull (org.finos.waltz.common.Checks.checkNotNull)1 MapUtilities.groupBy (org.finos.waltz.common.MapUtilities.groupBy)1 MapUtilities.indexBy (org.finos.waltz.common.MapUtilities.indexBy)1 SetUtilities.map (org.finos.waltz.common.SetUtilities.map)1 EntityKind (org.finos.waltz.model.EntityKind)1 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)1 HierarchyQueryScope (org.finos.waltz.model.HierarchyQueryScope)1 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)1 IdSelectionOptions.mkOptsForAllLifecycleStates (org.finos.waltz.model.IdSelectionOptions.mkOptsForAllLifecycleStates)1 AssessmentRating (org.finos.waltz.model.assessment_rating.AssessmentRating)1 ImmutableAssessmentRatingDetail (org.finos.waltz.model.assessment_rating.ImmutableAssessmentRatingDetail)1 ChangeUnit (org.finos.waltz.model.change_unit.ChangeUnit)1 ImmutablePhysicalFlowChangeUnitViewItem (org.finos.waltz.model.change_unit.ImmutablePhysicalFlowChangeUnitViewItem)1