-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pull request #388: CTCTOWALTZ-3268 permissions2 7088
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
Showing
12 changed files
with
461 additions
and
5 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
waltz-data/src/main/java/org/finos/waltz/data/permission/PermissionViewDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
waltz-model/src/main/java/org/finos/waltz/model/permission/PermissionViewItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.