Search in sources :

Example 1 with Measurable

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());
}
Also used : Measurable(org.finos.waltz.model.measurable.Measurable)

Example 2 with Measurable

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());
}
Also used : Measurable(org.finos.waltz.model.measurable.Measurable)

Example 3 with Measurable

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());
}
Also used : IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) OptionalUtilities(org.finos.waltz.common.OptionalUtilities) EntityKind(org.finos.waltz.model.EntityKind) IdSelectionOptions.mkOpts(org.finos.waltz.model.IdSelectionOptions.mkOpts) DIConfiguration(org.finos.waltz.service.DIConfiguration) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) List(java.util.List) Measurable(org.finos.waltz.model.measurable.Measurable) Record1(org.jooq.Record1) MeasurableService(org.finos.waltz.service.measurable.MeasurableService) EntityReference(org.finos.waltz.model.EntityReference) MeasurableIdSelectorFactory(org.finos.waltz.data.measurable.MeasurableIdSelectorFactory) Select(org.jooq.Select) HierarchyQueryScope(org.finos.waltz.model.HierarchyQueryScope) Measurable(org.finos.waltz.model.measurable.Measurable) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MeasurableIdSelectorFactory(org.finos.waltz.data.measurable.MeasurableIdSelectorFactory) EntityReference(org.finos.waltz.model.EntityReference) MeasurableService(org.finos.waltz.service.measurable.MeasurableService) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Example 4 with Measurable

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());
}
Also used : Measurable(org.finos.waltz.model.measurable.Measurable) ImmutableMeasurable(org.finos.waltz.model.measurable.ImmutableMeasurable)

Example 5 with Measurable

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);
}
Also used : Measurable(org.finos.waltz.model.measurable.Measurable) MeasurableDao(org.finos.waltz.data.measurable.MeasurableDao)

Aggregations

Measurable (org.finos.waltz.model.measurable.Measurable)26 MeasurableDao (org.finos.waltz.data.measurable.MeasurableDao)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 EntityKind (org.finos.waltz.model.EntityKind)6 Collectors (java.util.stream.Collectors)5 Checks.checkNotNull (org.finos.waltz.common.Checks.checkNotNull)5 DateTimeUtilities (org.finos.waltz.common.DateTimeUtilities)5 DIConfiguration (org.finos.waltz.service.DIConfiguration)5 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)5 IOException (java.io.IOException)4 InputStreamReader (java.io.InputStreamReader)4 Collection (java.util.Collection)4 Map (java.util.Map)4 Checks.checkTrue (org.finos.waltz.common.Checks.checkTrue)4 MapUtilities.indexBy (org.finos.waltz.common.MapUtilities.indexBy)4 StringUtilities.lower (org.finos.waltz.common.StringUtilities.lower)4 ApplicationDao (org.finos.waltz.data.application.ApplicationDao)4 RatingSchemeDAO (org.finos.waltz.data.rating_scheme.RatingSchemeDAO)4 RoadmapDao (org.finos.waltz.data.roadmap.RoadmapDao)4