Skip to content

Commit

Permalink
Pull request #388: CTCTOWALTZ-3268 permissions2 7088
Browse files Browse the repository at this point in the history
Merge in WALTZ/waltz from WALTZ/waltz-dw:CTCTOWALTZ-3268-permissions2-7088 to db-feature/waltz-7088-permissions-view

* commit 'f048fac87677fd5e2b6bd3eb3c155f1bdfac5de0':
  Permissions: Visualise the permission groups
  Permissions: Visualise the permission groups
  Permissions: Visualise the permission groups
  Model, dao and endpoint for Permissions viewer
  • Loading branch information
db-waltz committed Jul 19, 2024
2 parents 6ca681a + f048fac commit ac979ee
Show file tree
Hide file tree
Showing 12 changed files with 461 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package org.finos.waltz.data.permission;

import org.finos.waltz.model.EntityKind;
import org.finos.waltz.model.Operation;
import org.finos.waltz.model.permission.ImmutablePermissionViewItem;
import org.finos.waltz.model.permission.PermissionViewItem;
import org.finos.waltz.schema.Tables;
import org.finos.waltz.schema.tables.AssessmentDefinition;
import org.finos.waltz.schema.tables.InvolvementGroup;
import org.finos.waltz.schema.tables.InvolvementGroupEntry;
import org.finos.waltz.schema.tables.InvolvementKind;
import org.finos.waltz.schema.tables.MeasurableCategory;
import org.finos.waltz.schema.tables.PermissionGroup;
import org.finos.waltz.schema.tables.PermissionGroupInvolvement;
import org.jooq.DSLContext;
import org.jooq.Field;
import org.jooq.impl.DSL;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.Set;

import static org.finos.waltz.data.JooqUtilities.maybeReadRef;
import static org.finos.waltz.model.EntityReference.mkRef;

@Repository
public class PermissionViewDao {

private static final InvolvementGroup ig = Tables.INVOLVEMENT_GROUP.as("ig");
private static final InvolvementGroupEntry ige = Tables.INVOLVEMENT_GROUP_ENTRY.as("ige");
private static final InvolvementKind ik = Tables.INVOLVEMENT_KIND.as("ik");
private static final PermissionGroup pg = Tables.PERMISSION_GROUP.as("pg");
private static final PermissionGroupInvolvement pgi = Tables.PERMISSION_GROUP_INVOLVEMENT.as("pgi");
private static final MeasurableCategory mc = Tables.MEASURABLE_CATEGORY.as("mc");
private static final AssessmentDefinition ad = Tables.ASSESSMENT_DEFINITION.as("ad");

private final DSLContext dsl;

@Autowired
public PermissionViewDao(DSLContext dsl) {
this.dsl = dsl;
}

public Set<PermissionViewItem> findAll() {
Field<String> qualifierName = DSL
.coalesce(mc.NAME, ad.NAME, null)
.as("qualifier_name");

return dsl
.select(pg.NAME, pg.ID, pg.EXTERNAL_ID, pg.DESCRIPTION,
pgi.PARENT_KIND, pgi.SUBJECT_KIND, pgi.QUALIFIER_KIND, pgi.QUALIFIER_ID, qualifierName, pgi.OPERATION,
ig.NAME, ig.ID, ig.EXTERNAL_ID,
ik.NAME, ik.DESCRIPTION, ik.EXTERNAL_ID, ik.ID)
.from(ig)
.innerJoin(pgi).on(pgi.INVOLVEMENT_GROUP_ID.eq(ig.ID))
.innerJoin(ige).on(ig.ID.eq(ige.INVOLVEMENT_GROUP_ID))
.innerJoin(ik).on(ik.ID.eq(ige.INVOLVEMENT_KIND_ID))
.innerJoin(pg).on(pg.ID.eq(pgi.PERMISSION_GROUP_ID))
.leftJoin(mc).on(pgi.QUALIFIER_KIND.eq(EntityKind.MEASURABLE_CATEGORY.name()).and(mc.ID.eq(pgi.QUALIFIER_ID)))
.leftJoin(ad).on(pgi.QUALIFIER_KIND.eq(EntityKind.ASSESSMENT_DEFINITION.name()).and(ad.ID.eq(pgi.QUALIFIER_ID)))
.fetchSet(r -> ImmutablePermissionViewItem
.builder()
.parentKind(EntityKind.valueOf(r.get(pgi.PARENT_KIND)))
.subjectKind(EntityKind.valueOf(r.get(pgi.SUBJECT_KIND)))
.qualifier(maybeReadRef(r, pgi.QUALIFIER_KIND, pgi.QUALIFIER_ID, qualifierName).orElse(null))
.operation(Operation.valueOf(r.get(pgi.OPERATION)))
.permissionGroup(mkRef(EntityKind.PERMISSION_GROUP, r.get(pg.ID), r.get(pg.NAME), r.get(pg.DESCRIPTION), r.get(pg.EXTERNAL_ID)))
.involvementGroup(mkRef(EntityKind.INVOLVEMENT_GROUP, r.get(ig.ID), r.get(ig.NAME), null, r.get(ig.EXTERNAL_ID)))
.involvementKind(mkRef(EntityKind.INVOLVEMENT_KIND, r.get(ik.ID), r.get(ik.NAME), r.get(ik.DESCRIPTION), r.get(ik.EXTERNAL_ID)))
.build());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public enum EntityKind {
FLOW_CLASSIFICATION("Flow classification"),
FLOW_DIAGRAM("Flow diagram"),
INVOLVEMENT("Involvement"),
INVOLVEMENT_GROUP("Involvement Group"),
INVOLVEMENT_KIND("Involvement kind"),
LICENCE("Licence"),
LEGAL_ENTITY("Legal Entity"),
Expand All @@ -75,6 +76,7 @@ public enum EntityKind {
MEASURABLE_RATING_REPLACEMENT("Measurable rating replacement"),
ORG_UNIT("Organisational unit"),
PERFORMANCE_METRIC_PACK("Performance metric pack"),
PERMISSION_GROUP("Permission Group"),
PERSON("Person"),
PHYSICAL_SPECIFICATION("Physical specification"),
PHYSICAL_SPEC_DATA_TYPE_DECORATOR("Physical specification data type decorator"),
Expand Down Expand Up @@ -107,7 +109,7 @@ public enum EntityKind {
CAPABILITY("Capability"), // TO BE REMOVED IN 1.5

@Deprecated
AUTHORITATIVE_SOURCE("Authoritative source"); // TO BE REMOVED IN 1.36
AUTHORITATIVE_SOURCE("Authoritative source"); // TO BE REMOVED IN 1.36


private final String prettyName;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.finos.waltz.model.permission;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.finos.waltz.model.EntityKind;
import org.finos.waltz.model.EntityReference;
import org.finos.waltz.model.Nullable;
import org.finos.waltz.model.Operation;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as=ImmutablePermissionViewItem.class)
public interface PermissionViewItem {
EntityKind parentKind();

EntityKind subjectKind();

@Nullable
EntityReference qualifier();

Operation operation();

EntityReference involvementGroup();

EntityReference permissionGroup();

EntityReference involvementKind();
}
14 changes: 14 additions & 0 deletions waltz-ng/client/common/services/enums/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ export const entity = {
description: null,
position: 1500
},
INVOLVEMENT_GROUP: {
key: "INVOLVEMENT_GROUP",
name: "Involvement Group",
icon: "people-group",
description: null,
position: 1510
},
INVOLVEMENT_KIND: {
key: "INVOLVEMENT_KIND",
name: "Involvement Kind",
Expand Down Expand Up @@ -318,6 +325,13 @@ export const entity = {
description: null,
position: 1960
},
PERMISSION_GROUP: {
key: "PERMISSION_GROUP",
name: "Permission Group",
icon: "layer-group",
description: null,
position: 1970
},
PERSON: {
key: "PERSON",
name: "Person",
Expand Down
11 changes: 7 additions & 4 deletions waltz-ng/client/common/svelte/EntityIcon.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
import Icon from "./Icon.svelte";
export let kind;
export let showName = false;
$: name = _.get(entity, [kind, "icon"], "circle-o");
$: iconName = _.get(entity, [kind, "icon"], "circle-o");
$: label = _.get(entity, [kind, "name"], "");
</script>

<style>
</style>

<Icon {name}/>
<Icon name={iconName}/>
{#if showName}
<span>{label}</span>
{/if}
40 changes: 40 additions & 0 deletions waltz-ng/client/svelte-stores/permission-view-store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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 {remote} from "./remote";
import {checkIsEntityRef} from "../common/checks";

export function mkPermissionViewStore() {

const findAll = (ref, force) => {
return remote
.fetchViewList(
"GET",
`api/permission-view`,
null,
force);
};


return {
findAll
};
}

export const permissionViewStore = mkPermissionViewStore();
20 changes: 20 additions & 0 deletions waltz-ng/client/system/permissions-view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {initialiseData} from "../common";
import PermissionsView from "./svelte/permissions/PermissionsView.svelte";

const initialState = {
PermissionsView
};


function controller() {
initialiseData(this, initialState);
}

const page = {
controller,
template: `<waltz-svelte-component component="$ctrl.PermissionsView"></waltz-svelte-component>`,
controllerAs: "$ctrl"
};


export default page;
7 changes: 7 additions & 0 deletions waltz-ng/client/system/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import EudaListView from "./euda-list-view";
import RelationshipKindsView from "./relationship-kinds-view";
import ReassignRecipientsView from "./reassign-recipients-view";
import ColorGradientView from "./color-gradient-view";
import PermissionsView from "./permissions-view";
import NavAidBuilderView from "./nav-aid-builder-view";
import VersionInfoView from "./version-info-view";
import LicencesAdminView from "./licences-view";
Expand Down Expand Up @@ -162,6 +163,11 @@ const diagramBuilderState = {
views: {"content@": DiagramBuilderView}
};

const permissionsState = {
url: "/permissions",
views: {"content@": PermissionsView}
};


function setupRoutes($stateProvider) {
$stateProvider
Expand All @@ -179,6 +185,7 @@ function setupRoutes($stateProvider) {
.state("main.system.nav-aids", navAidAdminState)
.state("main.system.nav-aid-builder", navAidBuilderState)
.state("main.system.orphans", orphansState)
.state("main.system.permissions", permissionsState)
.state("main.system.rating-schemes", ratingSchemesState)
.state("main.system.reassign-recipients", reassignRecipientsState)
.state("main.system.recalculate", recalculateState)
Expand Down
Loading

0 comments on commit ac979ee

Please sign in to comment.