use of org.finos.waltz.model.measurable.Measurable in project waltz by khartec.
the class MeasurableRatingService method save.
// -- WRITE
public Collection<MeasurableRating> save(SaveMeasurableRatingCommand command, boolean ignoreReadOnly) {
checkNotNull(command, "command cannot be null");
checkRatingIsAllowable(command);
Measurable measurable = measurableDao.getById(command.measurableId());
checkNotNull(measurable, format("Unknown measurable with id: %d", command.measurableId()));
checkTrue(measurable.concrete(), "Cannot rate against an abstract measurable");
Operation operationThatWasPerformed = measurableRatingDao.save(command, false);
String entityName = getEntityName(command);
String previousRatingMessage = command.previousRating().isPresent() ? "from " + command.previousRating().get() : "";
writeChangeLogEntry(command, format("Saved: %s with a rating of: %s %s for %s", measurable.name(), command.rating(), previousRatingMessage, entityName), format("Saved: %s has assigned %s with a rating of: %s %s", entityName, measurable.name(), command.rating(), previousRatingMessage), operationThatWasPerformed);
return findForEntity(command.entityReference());
}
use of org.finos.waltz.model.measurable.Measurable in project waltz by khartec.
the class FlowDiagramService method makeForMeasurable.
private Long makeForMeasurable(EntityReference ref, String userId, String providedTitle) {
Measurable measurable = measurableDao.getById(ref.id());
String title = isEmpty(providedTitle) ? measurable.name() + " flows" : providedTitle;
return mkNewFlowDiagram(title, userId, newArrayList(mkDiagramEntity(measurable)), emptyList());
}
use of org.finos.waltz.model.measurable.Measurable in project waltz by khartec.
the class MeasurableHarness method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
MeasurableIdSelectorFactory factory = new MeasurableIdSelectorFactory();
MeasurableService measurableService = ctx.getBean(MeasurableService.class);
EntityReference ref = mkRef(EntityKind.PERSON, 172272);
IdSelectionOptions options = mkOpts(ref, HierarchyQueryScope.CHILDREN);
Select<Record1<Long>> selector = factory.apply(options);
System.out.println("--selector");
System.out.println(selector);
System.out.println("---");
List<Measurable> measurables = measurableService.findByMeasurableIdSelector(options);
measurables.forEach(System.out::println);
System.out.println("-----");
measurables.stream().filter(m -> OptionalUtilities.contentsEqual(m.id(), 486L)).forEach(System.out::println);
System.out.println(measurables.size());
}
use of org.finos.waltz.model.measurable.Measurable in project waltz by khartec.
the class AllocationHarness method mkMeasurables.
private static List<Measurable> mkMeasurables(MeasurableService measurableService, MeasurableCategory category) {
Measurable m = ImmutableMeasurable.builder().name("z").categoryId(category.id().get()).concrete(true).provenance(PROVENANCE).lastUpdatedBy("admin").build();
measurableService.create(ImmutableMeasurable.copyOf(m).withName("A"), "admin");
measurableService.create(ImmutableMeasurable.copyOf(m).withName("B"), "admin");
measurableService.create(ImmutableMeasurable.copyOf(m).withName("C"), "admin");
return measurableService.findByCategoryId(category.id().get());
}
use of org.finos.waltz.model.measurable.Measurable in project waltz by khartec.
the class RoadmapGenerator method pickAxisItems.
private List<Measurable> pickAxisItems(ApplicationContext ctx, EntityReference type, int howMany) {
MeasurableDao measurableDao = getMeasurableDao(ctx);
List<Measurable> concreteChoices = filter(Measurable::concrete, measurableDao.findByCategoryId(type.id()));
return randomPick(concreteChoices, howMany);
}
Aggregations