diff --git a/waltz-ng/client/applications/components/overview/app-overview.html b/waltz-ng/client/applications/components/overview/app-overview.html index c1be159044..400f263d55 100644 --- a/waltz-ng/client/applications/components/overview/app-overview.html +++ b/waltz-ng/client/applications/components/overview/app-overview.html @@ -277,6 +277,12 @@ + +
+ + + diff --git a/waltz-ng/client/applications/components/overview/app-overview.js b/waltz-ng/client/applications/components/overview/app-overview.js index 88c210648b..49a6891720 100644 --- a/waltz-ng/client/applications/components/overview/app-overview.js +++ b/waltz-ng/client/applications/components/overview/app-overview.js @@ -25,6 +25,7 @@ import template from "./app-overview.html"; import {displayError} from "../../../common/error-utils"; import {enrichComplexitiesWithKind, findDefaultComplexityKind} from "../../../complexity/services/complexity-utilities"; import {mkSelectionOptions} from "../../../common/selector-utils"; +import PrimaryRatingOverviewSubSection from "../../../measurable-rating/svelte/PrimaryRatingOverviewSubSection.svelte"; const bindings = { parentEntityRef: "<" @@ -43,7 +44,8 @@ const initialState = { aliasEditor: false, tagEditor: false }, - showAllAppGroups: false + showAllAppGroups: false, + PrimaryRatingOverviewSubSection }; diff --git a/waltz-ng/client/measurable-rating/svelte/PrimaryRatingOverviewSubSection.svelte b/waltz-ng/client/measurable-rating/svelte/PrimaryRatingOverviewSubSection.svelte new file mode 100644 index 0000000000..d5cee4aeaf --- /dev/null +++ b/waltz-ng/client/measurable-rating/svelte/PrimaryRatingOverviewSubSection.svelte @@ -0,0 +1,107 @@ + + + +
+ Primary Viewpoint Ratings +
+
+ {#if !_.isEmpty(primaryRatingsView?.measurableRatings)} + + + {#each ratingsRows as rating} + + + + + {/each} + +
+ {_.get(rating, ["category", "name"], "Unknown Category")} + + + + + {_.get(rating, ["measurable", "name"], "Unknown Measurable")} + + +
+ {:else} +
+ No primary ratings have been set for this application +
+ {/if} +
+
+ + + +
+
\ No newline at end of file diff --git a/waltz-ng/client/measurable-rating/svelte/PrimaryRatingTooltipContent.svelte b/waltz-ng/client/measurable-rating/svelte/PrimaryRatingTooltipContent.svelte new file mode 100644 index 0000000000..e6a817eb50 --- /dev/null +++ b/waltz-ng/client/measurable-rating/svelte/PrimaryRatingTooltipContent.svelte @@ -0,0 +1,40 @@ + + + +{#if measurable} +
+

{measurable.name}

+ {measurable.externalId} + +
+
+{/if} + +
+ +
+ {ratingSchemeItem.description} +
+
+ +{#if rating.description} +
+
+
+ Rating Comment: +
+ +
+{:else } +
+{/if} \ No newline at end of file diff --git a/waltz-ng/client/svelte-stores/measurable-rating-store.js b/waltz-ng/client/svelte-stores/measurable-rating-store.js index c83e0bf20c..821a97527e 100644 --- a/waltz-ng/client/svelte-stores/measurable-rating-store.js +++ b/waltz-ng/client/svelte-stores/measurable-rating-store.js @@ -33,11 +33,20 @@ export function mkMeasurableRelationshipStore() { null, {force}); + const getPrimaryRatingsViewBySelector = (options, force = false) => remote + .fetchViewData( + "POST", + "api/measurable-rating/primary-ratings/view", + options, + null, + {force}); + return { findByApplicationSelector, getById, getViewById, - getViewByCategoryAndSelector + getViewByCategoryAndSelector, + getPrimaryRatingsViewBySelector }; } diff --git a/waltz-service/src/main/java/org/finos/waltz/service/measurable_rating/MeasurableRatingViewService.java b/waltz-service/src/main/java/org/finos/waltz/service/measurable_rating/MeasurableRatingViewService.java index 5f74695641..5d8554e46b 100644 --- a/waltz-service/src/main/java/org/finos/waltz/service/measurable_rating/MeasurableRatingViewService.java +++ b/waltz-service/src/main/java/org/finos/waltz/service/measurable_rating/MeasurableRatingViewService.java @@ -52,7 +52,6 @@ import static java.lang.String.format; import static java.util.Collections.emptyList; -import static org.finos.waltz.common.CollectionUtilities.find; import static org.finos.waltz.common.MapUtilities.indexBy; import static org.finos.waltz.common.SetUtilities.asSet; import static org.finos.waltz.common.SetUtilities.filter; @@ -168,10 +167,12 @@ public MeasurableRatingCategoryView getViewForCategoryAndSelector(IdSelectionOpt GenericSelector appSelector = GENERIC_SELECTOR_FACTORY.applyForKind(EntityKind.APPLICATION, idSelectionOptions); List applications = applicationService.findByAppIdSelector(idSelectionOptions); - Collection allCategories = measurableCategoryService.findAll(); - MeasurableCategory category = find(allCategories, d -> d.id().get() == categoryId) - .orElseThrow(() -> new IllegalArgumentException(format("Cannot find category with id: %s", categoryId))); + MeasurableCategory category = measurableCategoryService.getById(categoryId); + + if(category == null) { + throw new IllegalArgumentException(format("Cannot find category with id: %s", categoryId)); + } List ratings = measurableRatingService.findForCategoryAndSelector(appSelector.selector(), categoryId); List measurables = measurableService.findByCategoryId(categoryId); @@ -195,21 +196,7 @@ public MeasurableRatingCategoryView getViewForCategoryAndSelector(IdSelectionOpt Set hierarchyForCategory = measurableService.findHierarchyForCategory(categoryId); - Set primaryCategories = allCategories - .stream() - .filter(MeasurableCategory::allowPrimaryRatings) - .collect(Collectors.toSet()); - - Set primaryMeasurableRatings = measurableRatingService.findPrimaryRatingsForGenericSelector(appSelector); - List primaryMeasurables = measurableDao.findByMeasurableIdSelector(mkMeasurableIdSelector(primaryMeasurableRatings)); - Set primaryRatingSchemeItems = ratingSchemeDAO.findRatingSchemeItemsForSchemeIds(map(primaryCategories, MeasurableCategory::ratingSchemeId)); - - ImmutableMeasurableRatingsView primaryRatingsView = ImmutableMeasurableRatingsView.builder() - .measurableRatings(primaryMeasurableRatings) - .measurables(primaryMeasurables) - .measurableCategories(primaryCategories) - .ratingSchemeItems(primaryRatingSchemeItems) - .build(); + ImmutableMeasurableRatingsView primaryRatingsView = getPrimaryRatingsView(appSelector); ImmutableMeasurableRatingsView ratingsView = ImmutableMeasurableRatingsView .builder() @@ -250,6 +237,26 @@ public MeasurableRatingCategoryView getViewForCategoryAndSelector(IdSelectionOpt .build(); } + public ImmutableMeasurableRatingsView getPrimaryRatingsView(GenericSelector appSelector) { + + Set primaryCategories = measurableCategoryService.findAll() + .stream() + .filter(MeasurableCategory::allowPrimaryRatings) + .collect(Collectors.toSet()); + + Set primaryMeasurableRatings = measurableRatingService.findPrimaryRatingsForGenericSelector(appSelector); + List primaryMeasurables = measurableDao.findByMeasurableIdSelector(mkMeasurableIdSelector(primaryMeasurableRatings)); + Set primaryRatingSchemeItems = ratingSchemeDAO.findRatingSchemeItemsForSchemeIds(map(primaryCategories, MeasurableCategory::ratingSchemeId)); + + return ImmutableMeasurableRatingsView.builder() + .measurableRatings(primaryMeasurableRatings) + .measurables(primaryMeasurables) + .measurableCategories(primaryCategories) + .ratingSchemeItems(primaryRatingSchemeItems) + .build(); + } + + private SelectConditionStep> mkMeasurableIdSelector(Set primaryMeasurableRatings) { return DSL .select(MEASURABLE.ID) diff --git a/waltz-web/src/main/java/org/finos/waltz/web/endpoints/api/MeasurableRatingEndpoint.java b/waltz-web/src/main/java/org/finos/waltz/web/endpoints/api/MeasurableRatingEndpoint.java index 7255973f16..abf6eee2ab 100644 --- a/waltz-web/src/main/java/org/finos/waltz/web/endpoints/api/MeasurableRatingEndpoint.java +++ b/waltz-web/src/main/java/org/finos/waltz/web/endpoints/api/MeasurableRatingEndpoint.java @@ -19,11 +19,14 @@ package org.finos.waltz.web.endpoints.api; import org.finos.waltz.common.exception.InsufficientPrivelegeException; +import org.finos.waltz.data.GenericSelector; +import org.finos.waltz.data.GenericSelectorFactory; import org.finos.waltz.model.EntityKind; import org.finos.waltz.model.EntityReference; import org.finos.waltz.model.IdSelectionOptions; import org.finos.waltz.model.Operation; import org.finos.waltz.model.UserTimestamp; +import org.finos.waltz.model.application.MeasurableRatingsView; import org.finos.waltz.model.measurable_rating.ImmutableRemoveMeasurableRatingCommand; import org.finos.waltz.model.measurable_rating.MeasurableRating; import org.finos.waltz.model.measurable_rating.MeasurableRatingCategoryView; @@ -104,6 +107,7 @@ public void register() { String getViewByIdPath = mkPath(BASE_URL, "id", ":id", "view"); String findForEntityPath = mkPath(BASE_URL, "entity", ":kind", ":id"); String getViewForCategoryAndAppSelectorPath = mkPath(BASE_URL, "category", ":id", "view"); + String getPrimaryRatingsViewForAppSelectorPath = mkPath(BASE_URL, "primary-ratings", "view"); String modifyMeasurableForEntityPath = mkPath(BASE_URL, "entity", ":kind", ":id", "measurable", ":measurableId"); String modifyCategoryForEntityPath = mkPath(BASE_URL, "entity", ":kind", ":id", "category", ":categoryId"); String findByMeasurableSelectorPath = mkPath(BASE_URL, "measurable-selector"); @@ -138,6 +142,13 @@ public void register() { return time("viewForCatAndSelector", () -> measurableRatingViewService.getViewForCategoryAndSelector(idSelectionOptions, categoryId)); }; + DatumRoute getPrimaryRatingsViewForAppSelectorRoute = (request, response) -> { + IdSelectionOptions idSelectionOptions = readIdSelectionOptionsFromBody(request); + GenericSelectorFactory selectorFactory = new GenericSelectorFactory(); + GenericSelector genericSelector = selectorFactory.apply(idSelectionOptions); + return measurableRatingViewService.getPrimaryRatingsView(genericSelector); + }; + ListRoute findByCategoryRoute = (request, response) -> measurableRatingService.findByCategory(getId(request)); @@ -168,6 +179,7 @@ public void register() { postForList(saveRatingDescriptionPath, this::saveRatingDescriptionRoute); postForList(saveRatingIsPrimaryPath, this::saveRatingIsPrimaryRoute); postForDatum(getViewForCategoryAndAppSelectorPath, getViewByCategoryAndAppSelectorRoute); + postForDatum(getPrimaryRatingsViewForAppSelectorPath, getPrimaryRatingsViewForAppSelectorRoute); }