Skip to content

Commit

Permalink
Pull request #291: Show changes to taxonomies on the list page
Browse files Browse the repository at this point in the history
Merge in WALTZ/waltz from WALTZ/waltz-dw:CTCTOWALTZ-2778-taxonomy-changes-6675 to db-feature/waltz-6675-taxonomy-changes

* commit 'e81b235eec55c69c3abd97abe9c1aa7e7fc849e7':
  Show changes to taxonomies on the list page
  • Loading branch information
db-waltz authored and jessica-woodland-scott-db committed Jul 17, 2023
2 parents 580633e + e81b235 commit a2e1522
Show file tree
Hide file tree
Showing 16 changed files with 460 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
import org.finos.waltz.model.taxonomy_management.TaxonomyChangeLifecycleStatus;
import org.finos.waltz.model.taxonomy_management.TaxonomyChangeType;
import org.finos.waltz.schema.tables.records.TaxonomyChangeRecord;
import org.jooq.Condition;
import org.jooq.DSLContext;
import org.jooq.Field;
import org.jooq.Record;
import org.jooq.RecordMapper;
import org.jooq.impl.DSL;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

Expand Down Expand Up @@ -159,21 +161,42 @@ public TaxonomyChangeCommand createCommand(TaxonomyChangeCommand cmd) {
.withId(r.getId());
}

public Collection<TaxonomyChangeCommand> findChangesByDomainAndStatus(EntityReference domain, TaxonomyChangeLifecycleStatus status) {

public Collection<TaxonomyChangeCommand> findChangesByDomain(EntityReference domain) {
return findChangesByDomainAndCondition(
domain,
DSL.trueCondition());
}


public Collection<TaxonomyChangeCommand> findChangesByDomainAndStatus(EntityReference domain,
TaxonomyChangeLifecycleStatus status) {
return findChangesByDomainAndCondition(
domain,
TAXONOMY_CHANGE.STATUS.eq(status.name()));
}


public TaxonomyChangeCommand update(TaxonomyChangeCommand cmd) {
TaxonomyChangeRecord r = TO_RECORD_MAPPER.apply(cmd, dsl);
r.update();
return cmd;
}


// -- helpers ----

private Collection<TaxonomyChangeCommand> findChangesByDomainAndCondition(EntityReference domain,
Condition condition) {
return dsl
.select(TAXONOMY_CHANGE.fields())
.select(PRIMARY_REF_NAME, CHANGE_DOMAIN_NAME)
.from(TAXONOMY_CHANGE)
.where(TAXONOMY_CHANGE.STATUS.eq(status.name()))
.and(TAXONOMY_CHANGE.DOMAIN_ID.eq(domain.id()))
.where(TAXONOMY_CHANGE.DOMAIN_ID.eq(domain.id()))
.and(TAXONOMY_CHANGE.DOMAIN_KIND.eq(domain.kind().name()))
.and(condition)
.fetch(TO_DOMAIN_MAPPER);
}


public TaxonomyChangeCommand update(TaxonomyChangeCommand cmd) {
TaxonomyChangeRecord r = TO_RECORD_MAPPER.apply(cmd, dsl);
r.update();
return cmd;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public Long paramAsLong(String key, Long dflt) {
return isEmpty(strVal) ? dflt : Long.valueOf(strVal);
}


public List<Long> paramAsLongList(String key) throws JsonProcessingException {
String strVal = params().get(key);
List<?> list = getJsonMapper().readValue(strVal, List.class);
Expand Down
4 changes: 3 additions & 1 deletion waltz-ng/client/common/services/enums/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { surveyQuestionFieldType } from "./survey-question-field-type";
import { surveyRunStatus } from "./survey-run-status";
import { fieldDataType } from "./field-data-type";
import { physicalSpecDefinitionType } from "./physical-spec-definition-type";
import { taxonomyChangeType } from "./taxonomy-change-type";

export const capabilityRating = investmentRating;

Expand Down Expand Up @@ -93,7 +94,8 @@ export const enums = {
releaseLifecycleStatus,
surveyRunStatus,
surveyQuestionFieldType,
issuance
issuance,
taxonomyChangeType
};


Expand Down
80 changes: 80 additions & 0 deletions waltz-ng/client/common/services/enums/taxonomy-change-type.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
export const taxonomyChangeType = {
ADD_PEER: {
key: "ADD_PEER",
name: "Add Peer",
icon: null,
description: null,
position: 10
},
ADD_CHILD: {
key: "ADD_CHILD",
name: "Add Child",
icon: null,
description: null,
position: 10
},
DEPRECATE: {
key: "DEPRECATE",
name: "Deprecate",
icon: null,
description: null,
position: 10
},
MOVE: {
key: "MOVE",
name: "Move",
icon: null,
description: null,
position: 20
},
MERGE: {
key: "MERGE",
name: "Merge",
icon: null,
description: null,
position: 20
},
REMOVE: {
key: "REMOVE",
name: "Remove",
icon: null,
description: null,
position: 30
},
REORDER_SIBLINGS: {
key: "REORDER_SIBLINGS",
name: "Reorder Siblings",
icon: null,
description: null,
position: 30
},
UPDATE_NAME: {
key: "UPDATE_NAME",
name: "Update Name",
icon: null,
description: null,
position: 30
},
UPDATE_DESCRIPTION: {
key: "UPDATE_DESCRIPTION",
name: "Update Description",
icon: null,
description: null,
position: 30
},
UPDATE_CONCRETENESS: {
key: "UPDATE_CONCRETENESS",
name: "Update Concreteness",
icon: null,
description: null,
position: 30
},
UPDATE_EXTERNAL_ID: {
key: "UPDATE_EXTERNAL_ID",
name: "Update External ID",
icon: null,
description: null,
position: 30
},
};

10 changes: 10 additions & 0 deletions waltz-ng/client/dynamic-section/dynamic-section-definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,15 @@ const legalEntityRelationshipKindSection = {
};


const taxonomyChangesSection = {
componentId: "taxonomy-changes-section",
name: "Taxonomy Changes",
icon: "cog",
description: " This section list any formal changes against this taxonomy. These changes are ones that have been defined and applied in Waltz.",
id: 10030,
};


export const dynamicSections = {
appCostsSection,
appCostsSummarySection,
Expand Down Expand Up @@ -497,6 +506,7 @@ export const dynamicSections = {
softwarePackageVersions,
specificationDefinitionSection,
surveySection,
taxonomyChangesSection,
technologySection,
technologySummarySection
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="ui-grid-cell-contents"
ng-switch="$ctrl.change.changeType">
<span ng-switch-when="ADD_CHILD"
ng-bind="$ctrl.change.params.name">
</span>
<span ng-switch-when="UPDATE_DESCRIPTION"
ng-bind="$ctrl.change.params.description">
</span>
<span ng-switch-when="MOVE">
To: <span ng-bind="$ctrl.change.params.destinationName"></span>
</span>
<span ng-switch-when="MERGE">
Into: <span ng-bind="$ctrl.change.params.targetName"></span>
</span>
<span ng-switch-default>
-
</span>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import template from "./taxonomy-change-summary-cell.html";
import {initialiseData} from "../../../common";


const initialState = {};

const bindings = {
change: "<"
};


function controller(serviceBroker) {
const vm = initialiseData(this, initialState);
}


controller.$inject = [
"ServiceBroker"
];


const component = {
bindings,
controller,
template
};

export default {
id: "waltzTaxonomyChangeSummaryCell",
component
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<waltz-no-data ng-if="$ctrl.items.length === 0">
<message>
There are no logged changes
</message>
</waltz-no-data>


<div class="help-block">
This section lists any formal changes against this taxonomy.
These changes are ones that have been defined and applied directly in Waltz.
</div>


<div ng-if="$ctrl.items.length > 0">
<waltz-grid-with-search column-defs="$ctrl.columnDefs"
style="min-height: 1600px"
entries="$ctrl.items">
</waltz-grid-with-search>
</div>


<div class="pull-right">
<waltz-data-extract-link name="Export"
styling="link"
extract="taxonomy-changes/all-applied/{{$ctrl.parentEntityRef.kind}}/{{$ctrl.parentEntityRef.id}}"
method="GET"
ng-if="$ctrl.items.length > 0">
</waltz-data-extract-link>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import template from "./taxonomy-changes-section.html";
import {initialiseData} from "../../../common";
import {CORE_API} from "../../../common/services/core-api-utils";
import _ from "lodash";
import {mkEntityLinkGridCell} from "../../../common/grid-utils";


const initialState = {
items: [],
columnDefs: [
{
field: "changeType",
cellFilter: "toDisplayName:'taxonomyChangeType'",
width: "10%"
},
mkEntityLinkGridCell("Entity", "primaryReference", "none", "right"),
{
field: "params",
displayName: "Parameters",
cellTemplate: `
<div class="ui-grid-cell-contents">
<waltz-taxonomy-change-summary-cell change="row.entity">
</waltz-taxonomy-change-summary-cell>
</div>`
}, {
field: "lastUpdatedBy",
displayName: "Updated By",
width: "10%",
}, {
field: "lastUpdatedAt",
displayName: "Updated At",
cellTemplate: "<div class=\"ui-grid-cell-contents\"><waltz-from-now timestamp=\"COL_FIELD\"></waltz-from-now></div>"
}
]
};


const bindings = {
parentEntityRef: "<"
};


function controller(serviceBroker) {
const vm = initialiseData(this, initialState);

vm.$onInit = (c) => {
if (vm.parentEntityRef) {
serviceBroker
.execute(
CORE_API.TaxonomyManagementStore.findAllChangesByDomain,
[vm.parentEntityRef])
.then(r => {
vm.items = _
.chain(r.data)
.filter(d => d.status === "EXECUTED")
.orderBy(
[d => d.lastUpdatedAt, d => d.createdAt],
["desc", "desc"])
.value();
console.log(vm.items)
});

}
};
}


controller.$inject = [
"ServiceBroker"
];


const component = {
bindings,
controller,
template
};

export default {
id: "waltzTaxonomyChangesSection",
component
};
11 changes: 10 additions & 1 deletion waltz-ng/client/measurable-category/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,23 @@

import angular from "angular";
import CategoryStore from "./services/measurable-category-store";
import TaxonomyChangesSection from "./components/taxonomy-changes/taxonomy-changes-section"
import TaxonomyChangeSummaryCell from "./components/taxonomy-change-summary-cell/taxonomy-change-summary-cell"
import Routes from "./routes";
import {registerStores} from "../common/module-utils";
import {registerComponents, registerStores} from "../common/module-utils";

export default () => {
const module = angular.module("waltz.measurable-category", []);

registerStores(module, [ CategoryStore ]);

registerComponents(
module,
[
TaxonomyChangesSection,
TaxonomyChangeSummaryCell
]);

module.config(Routes);

return module.name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,12 @@
<waltz-dynamic-section-wrapper section="$ctrl.peopleSection"
parent-entity-ref="$ctrl.categoryRef">
</waltz-dynamic-section-wrapper>

<waltz-dynamic-section-wrapper section="$ctrl.taxonomyChangesSection"
ng-if="$ctrl.category.editable"
parent-entity-ref="$ctrl.categoryRef">
</waltz-dynamic-section-wrapper>


</div>

Loading

0 comments on commit a2e1522

Please sign in to comment.