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");
}
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());
}
Aggregations