Skip to content

Commit

Permalink
Legal entity related entities section and exports
Browse files Browse the repository at this point in the history
#CTCTOWALTZ-2626
finos#6368
  • Loading branch information
jessica-woodland-scott-db committed Jan 18, 2023
1 parent 57a059c commit 7a53418
Show file tree
Hide file tree
Showing 9 changed files with 316 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@
@Repository
public class LegalEntityRelationshipDao {

private static final Field<String> ENTITY_NAME_FIELD = InlineSelectFieldFactory.mkNameField(
LEGAL_ENTITY_RELATIONSHIP.TARGET_ID,
LEGAL_ENTITY_RELATIONSHIP.TARGET_KIND,
newArrayList(EntityKind.APPLICATION))
.as("entity_name");
private final DSLContext dsl;
private static final RecordMapper<Record, LegalEntityRelationship> TO_DOMAIN_MAPPER = r -> {
LegalEntityRelationshipRecord record = r.into(LEGAL_ENTITY_RELATIONSHIP);

EntityReference targetEntityReference = mkRef(EntityKind.valueOf(record.getTargetKind()), record.getTargetId());
EntityReference targetEntityReference = mkRef(EntityKind.valueOf(record.getTargetKind()), record.getTargetId(), r.get(ENTITY_NAME_FIELD));
EntityReference legalEntityReference = mkRef(EntityKind.LEGAL_ENTITY, record.getLegalEntityId(), r.get(LEGAL_ENTITY.NAME));

return ImmutableLegalEntityRelationship.builder()
Expand Down Expand Up @@ -57,6 +62,7 @@ private Set<LegalEntityRelationship> findByCondition(Condition condition) {
return dsl
.select(LEGAL_ENTITY_RELATIONSHIP.fields())
.select(LEGAL_ENTITY.NAME)
.select(ENTITY_NAME_FIELD)
.from(LEGAL_ENTITY_RELATIONSHIP)
.innerJoin(LEGAL_ENTITY).on(LEGAL_ENTITY_RELATIONSHIP.LEGAL_ENTITY_ID.eq(LEGAL_ENTITY.ID))
.where(condition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
</script>
{#if _.isEmpty(favouriteAssessments)}
<NoData type="info">You have no favourite assessments, please open the assessments sectiont to add some</NoData>
<NoData type="info">You have no favourite assessments, please open the assessments section to add some</NoData>
{:else}
<table class="table table-hover table-condensed">
<colgroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
~ Waltz - Enterprise Architecture
~ Copyright (C) 2016, 2017, 2018, 2019 Waltz open source project
~ See README.md for more information
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific
~
-->
<waltz-section-actions>
<waltz-data-extract-link name="Export"
styling="button"
extract="legal-entity/id/{{$ctrl.parentEntityRef.id}}"
method="GET">
</waltz-data-extract-link>
<button class="btn btn-xs waltz-btn-transparent"
ng-click="$ctrl.visibility.overlay = ! $ctrl.visibility.overlay">
<waltz-icon name="map-signs"></waltz-icon>
</button>

</waltz-section-actions>

<waltz-source-data-overlay visible="$ctrl.visibility.overlay"
entities="['LEGAL_ENTITY']">
</waltz-source-data-overlay>

<div class="row">
<div class="col-sm-12">
<waltz-grid-with-search ng-if="$ctrl.relationships.length > 0"
entries="$ctrl.relationships"
column-defs="$ctrl.columnDefs">
</waltz-grid-with-search>
<waltz-no-data ng-if="$ctrl.relationships.length == 0">
<message>
No legal entities have been linked to this <span
ng-bind="$ctrl.parentEntityRef.kind | toDisplayName:'entity'"></span>
</message>
</waltz-no-data>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* Waltz - Enterprise Architecture
* Copyright (C) 2016, 2017, 2018, 2019 Waltz open source project
* See README.md for more information
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific
*
*/
import template from "./legal-entity-relationship-section.html";
import {initialiseData} from "../../../common";
import {CORE_API} from "../../../common/services/core-api-utils";
import _ from "lodash";

const bindings = {
parentEntityRef: "<"
};

const initialState = {
relationshipKinds: [],
relationships: [],
visibility: {
overlay: false
},
columnDefs: [
{
field: "targetEntityReference",
name: "Target Entity",
width: "30%",
cellTemplate: `<div style="padding-top: 0.5em">
<waltz-entity-link entity-ref="row.entity.targetEntityReference"></waltz-entity-link>
</div>`
},
{
field: "relationshipKind.name",
name: "Relationship",
width: "15%"
},
{field: "description", width: "30%"},
{
field: "lastUpdatedAt",
name: "Last Updated At",
width: "10%",
cellTemplate: `
<div class="ui-grid-cell-contents"
style="vertical-align: baseline;">
<waltz-from-now timestamp="COL_FIELD"
days-only="true">
</waltz-from-now>
</div>`
},
{
field: "lastUpdatedBy",
name: "Last Updated By",
width: "15%"
}
]
}


function controller($q, serviceBroker) {

const vm = initialiseData(this, initialState);

vm.$onChanges = () => {

const relKindsPromise = serviceBroker
.loadAppData(CORE_API.LegalEntityRelationshipKindStore.findAll, [])
.then(r => r.data);

const relationshipsPromise = serviceBroker
.loadViewData(CORE_API.LegalEntityRelationshipStore.findByLegalEntityId, [vm.parentEntityRef.id])
.then(r => r.data);

return $q
.all([relKindsPromise, relationshipsPromise])
.then(([relKinds, relationships]) => {
const relKindsById = _.keyBy(relKinds, d => d.id);

vm.relationships = _
.chain(relationships)
.map(d => Object.assign({}, d, {relationshipKind: relKindsById[d.relationshipKindId]}))
.sortBy(d => d.targetEntityReference.name, d => d.relationshipKind.name)
.value();
});
}
}

controller.$inject = [
"$q",
"ServiceBroker"
];


const component = {
template,
bindings,
controller
};


export default {
id: "waltzLegalEntityRelationshipSection",
component
};
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ function controller($q, serviceBroker) {
.then(([relKinds, relationships]) => {
const relKindsById = _.keyBy(relKinds, d => d.id);

vm.relationships = _.map(
relationships,
d => Object.assign({}, d, {relationshipKind: relKindsById[d.relationshipKindId]}));
vm.relationships = _
.chain(relationships)
.map(d => Object.assign({}, d, {relationshipKind: relKindsById[d.relationshipKindId]}))
.sortBy(d => d.legalEntityReference.name, d => d.relationshipKind.name)
.value();
});
}
}
Expand Down
5 changes: 4 additions & 1 deletion waltz-ng/client/legal-entity/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {registerComponents, registerStores} from "../common/module-utils";
import Routes from "./routes";
import LegalEntityView from "./pages/view/legal-entity-view";
import LegalEntitySection from "./components/legal-entity-section/legal-entity-section";
import LegalEntityRelationshipSection
from "./components/legal-entity-relationship-section/legal-entity-relationship-section";
import LegalEntityStore from "./services/legal-entity-store";
import LegalEntityRelationshipStore from "./services/legal-entity-relationship-store";
import LegalEntityRelationshipKindStore from "./services/legal-entity-relationship-kind-store";
Expand All @@ -34,7 +36,8 @@ export default () => {

registerComponents(module, [
LegalEntityView,
LegalEntitySection
LegalEntitySection,
LegalEntityRelationshipSection
]);

registerStores(module, [
Expand Down
116 changes: 78 additions & 38 deletions waltz-ng/client/legal-entity/pages/view/LegalEntityOverview.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
import {legalEntityStore} from "../../../svelte-stores/legal-entity-store";
import {entity} from "../../../common/services/enums/entity";
import NoData from "../../../common/svelte/NoData.svelte";
import AssessmentFavouritesList
from "../../../assessments/components/favourites-list/AssessmentFavouritesList.svelte";
import SubSection from "../../../common/svelte/SubSection.svelte";
import {activeSections, availableSections} from "../../../dynamic-section/section-store";
import _ from "lodash";
export let primaryEntityReference;
Expand All @@ -18,6 +23,21 @@
$: legalEntity = $legalEntityCall?.data;
function openAssessmentsSection() {
const closedAssessmentsSection = _.find($availableSections, d => d.componentId === "assessment-rating-section");
const openAssessmentsSection = _.find($activeSections?.sections, d => d.componentId === "assessment-rating-section");
if (closedAssessmentsSection) {
activeSections.add(closedAssessmentsSection);
}
if (openAssessmentsSection) {
activeSections.add(openAssessmentsSection);
}
window.scrollTo(0, 250);
}
</script>
Expand All @@ -42,45 +62,65 @@
<div class="waltz-page-summary waltz-page-summary-attach"
style="margin-bottom: 5em;">
<div class="waltz-display-section">
{#if legalEntity}
<div class="row">
<div class="col-sm-2">
Name
</div>
<div class="col-sm-10">
{legalEntity?.name}
</div>
</div>
<div class="row">
<div class="col-sm-2">
Description
</div>
<div class="col-sm-10">
{legalEntity?.description || "-"}
</div>
</div>
<div class="row">
<div class="col-sm-2">
External Id
</div>
<div class="col-sm-10">
{legalEntity?.externalId || "-"}
</div>
</div>
<div class="row">
<div class="col-sm-2">
Provenance
</div>
<div class="col-sm-10">
{legalEntity?.provenance}
</div>
<div class="row">
<div class="col-md-6">
{#if legalEntity}
<div class="row">
<div class="col-sm-2">
Name
</div>
<div class="col-sm-10">
{legalEntity?.name}
</div>
</div>
<div class="row">
<div class="col-sm-2">
Description
</div>
<div class="col-sm-10">
{legalEntity?.description || "-"}
</div>
</div>
<div class="row">
<div class="col-sm-2">
External Id
</div>
<div class="col-sm-10">
{legalEntity?.externalId || "-"}
</div>
</div>
<div class="row">
<div class="col-sm-2">
Provenance
</div>
<div class="col-sm-10">
{legalEntity?.provenance}
</div>
</div>
{:else}
<div class="row">
<div class="col-sm-12">
<NoData>No legal entity found</NoData>
</div>
</div>
{/if}
</div>
{:else}
<div class="row">
<div class="col-sm-12">
<NoData>No legal entity found</NoData>
</div>
<div class="col-md-6">
<SubSection>
<div slot="header">
<span>Assessments</span>
</div>
<div slot="content">
<AssessmentFavouritesList/>
</div>
<div slot="controls">
<button class="btn btn-skinny pull-right btn-xs"
on:click={openAssessmentsSection}>
More
</button>
</div>
</SubSection>
</div>
{/if}
</div>
</div>
</div>
Loading

0 comments on commit 7a53418

Please sign in to comment.