Skip to content

Commit

Permalink
Merge pull request finos#4988 from deutschebank/db-contrib/waltz-4876…
Browse files Browse the repository at this point in the history
…-favourites-service-store

Db contrib/waltz 4876 favourites service store
  • Loading branch information
davidwatkins73 authored Jul 8, 2020
2 parents c50e52a + 0cc2c14 commit 16913b4
Show file tree
Hide file tree
Showing 84 changed files with 1,021 additions and 461 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@ public List<AppGroup> findPrivateGroupsByOwner(String userId) {
}


public AppGroup findFavouritesGroupByOwner(String userId) {
SelectConditionStep<Record1<Long>> groupIds = getPrivateGroupIdByOwner(userId);

return dsl.select(APPLICATION_GROUP.fields())
.from(APPLICATION_GROUP)
.where(APPLICATION_GROUP.ID.in(groupIds)
.and(APPLICATION_GROUP.KIND.eq(AppGroupKind.PRIVATE.name())
.and(notRemoved)
.and(APPLICATION_GROUP.IS_FAVOURITE_GROUP.isTrue())))
.fetchOne(TO_DOMAIN);
}


public List<AppGroup> findRelatedByApplicationId(long appId, String username) {

SelectConditionStep<Record1<Long>> groupsFromAppGroupEntry = dsl
Expand Down Expand Up @@ -229,6 +242,8 @@ public Long insert(AppGroup appGroup) {
.set(APPLICATION_GROUP.DESCRIPTION, appGroup.description())
.set(APPLICATION_GROUP.NAME, appGroup.name())
.set(APPLICATION_GROUP.KIND, appGroup.appGroupKind().name())
.set(APPLICATION_GROUP.IS_REMOVED, appGroup.isRemoved())
.set(APPLICATION_GROUP.IS_FAVOURITE_GROUP, appGroup.isFavouriteGroup())
.returning(APPLICATION_GROUP.ID)
.fetchOne()
.getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,17 @@ public int[] addApplications(long groupId, List<Long> applicationIds) {
public int removeApplication(long groupId, long applicationId) {
return dsl.delete(APPLICATION_GROUP_ENTRY)
.where(APPLICATION_GROUP_ENTRY.GROUP_ID.eq(groupId))
.and(APPLICATION_GROUP_ENTRY.APPLICATION_ID.eq(applicationId))
.and(APPLICATION_GROUP_ENTRY.APPLICATION_ID.eq(applicationId)
.and(APPLICATION_GROUP_ENTRY.IS_READONLY.isFalse()))
.execute();
}


public int removeApplications(long groupId, List<Long> applicationIds) {
return dsl.delete(APPLICATION_GROUP_ENTRY)
.where(APPLICATION_GROUP_ENTRY.GROUP_ID.eq(groupId))
.and(APPLICATION_GROUP_ENTRY.APPLICATION_ID.in(applicationIds))
.and(APPLICATION_GROUP_ENTRY.APPLICATION_ID.in(applicationIds)
.and(APPLICATION_GROUP_ENTRY.IS_READONLY.isFalse()))
.execute();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,30 @@

package com.khartec.waltz.jobs.harness;

import com.khartec.waltz.data.application.ApplicationDao;
import com.khartec.waltz.common.exception.InsufficientPrivelegeException;
import com.khartec.waltz.data.application.ApplicationIdSelectorFactory;
import com.khartec.waltz.model.EntityKind;
import com.khartec.waltz.model.EntityReference;
import com.khartec.waltz.model.application.Application;
import com.khartec.waltz.model.app_group.AppGroupEntry;
import com.khartec.waltz.service.DIConfiguration;
import com.khartec.waltz.service.app_group.FavouritesService;
import org.jooq.DSLContext;
import org.jooq.Record1;
import org.jooq.Select;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.List;

import static com.khartec.waltz.model.EntityReference.mkRef;
import static com.khartec.waltz.model.IdSelectionOptions.mkOpts;
import java.util.Collection;


public class AppGroupHarness {

public static void main(String[] args) {
public static void main(String[] args) throws InsufficientPrivelegeException {
System.out.println("--- start");

ApplicationIdSelectorFactory appSelectorFactory = new ApplicationIdSelectorFactory();

AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
ApplicationDao applicationDao = ctx.getBean(ApplicationDao.class);

EntityReference grp5 = mkRef(EntityKind.APP_GROUP, 5);
Select<Record1<Long>> selector = appSelectorFactory.apply(mkOpts(grp5));
FavouritesService service = ctx.getBean(FavouritesService.class);

System.out.println(dsl.render(selector));
List<Application> apps = applicationDao.findByAppIdSelector(selector);

System.out.println(apps.size());
Collection<AppGroupEntry> appGroupEntries = service.addApplication("jessica.woodland-scott@db.com", 15792);

System.out.println("--- done");



}

}
11 changes: 6 additions & 5 deletions waltz-ng/client/actor/pages/actor-view/actor-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
<waltz-page-header name="{{ ctrl.actor.name }}"
small="Actor"
icon="user-circle">
<ol class="waltz-breadcrumbs">
<li><a ui-sref="main">Home</a></li>
</li>
<li ng-bind="ctrl.actor.name"></li>
</ol>
<breadcrumbs>
<ol class="waltz-breadcrumbs">
<li><a ui-sref="main">Home</a></li>
<li ng-bind="ctrl.actor.name"></li>
</ol>
</breadcrumbs>
</waltz-page-header>


Expand Down
3 changes: 2 additions & 1 deletion waltz-ng/client/app-groups/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Routes from './routes';
import AppGroupList from './components/app-group-list/app-group-list';
import AppGroupListSection from './components/app-group-list-section/app-group-list-section';
import AppGroupAppSelectionList from './directives/app-group-app-selection-list';
import FavouritesStore from "./services/favourites-store";


export default () => {
Expand All @@ -44,7 +45,7 @@ export default () => {
SubscriptionButtons,
RelatedAppGroupsSection ]);

registerStores(module, [ AppGroupStore ]);
registerStores(module, [ AppGroupStore, FavouritesStore ]);

return module.name;

Expand Down
20 changes: 11 additions & 9 deletions waltz-ng/client/app-groups/pages/edit/app-group-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@
<waltz-page-header name="{{ ctrl.appGroup.name }}"
icon="edit"
small="Edit">
<ol class="waltz-breadcrumbs">
<li><a ui-sref="main">Home</a></li>
<li>
<a ui-sref="main.app-group.view ({ id:ctrl.appGroup.id })"
ng-bind="ctrl.appGroup.name">
</a>
</li>
<li>Edit</li>
</ol>
<breadcrumbs>
<ol class="waltz-breadcrumbs">
<li><a ui-sref="main">Home</a></li>
<li>
<a ui-sref="main.app-group.view ({ id:ctrl.appGroup.id })"
ng-bind="ctrl.appGroup.name">
</a>
</li>
<li>Edit</li>
</ol>
</breadcrumbs>
</waltz-page-header>


Expand Down
12 changes: 7 additions & 5 deletions waltz-ng/client/app-groups/pages/view/app-group-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
<waltz-page-header name="{{ ctrl.groupDetail.appGroup.name }}"
icon="object-group"
small="{{ ctrl.groupDetail.appGroup.appGroupKind }}">
<ol class="waltz-breadcrumbs">
<li><a ui-sref="main">Home</a></li>
<li>App Group</li>
<li><span ng-bind="ctrl.groupDetail.appGroup.name"></span></li>
</ol>
<breadcrumbs>
<ol class="waltz-breadcrumbs">
<li><a ui-sref="main">Home</a></li>
<li>App Group</li>
<li><span ng-bind="ctrl.groupDetail.appGroup.name"></span></li>
</ol>
</breadcrumbs>

</waltz-page-header>

Expand Down
73 changes: 73 additions & 0 deletions waltz-ng/client/app-groups/services/favourites-store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* 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
*
*/

export function store($http, BaseApiUrl) {

const BASE = `${BaseApiUrl}/favourites`;

const getFavouritesGroupEntries = () => $http
.get(`${BASE}/entries`)
.then(result => result.data);

const addApplication = (applicationId) => $http
.post(`${BASE}/application/${applicationId}`)
.then(result => result.data);

const removeApplication = (applicationId) => $http
.delete(`${BASE}/application/${applicationId}`)
.then(result => result.data);

return {
getFavouritesGroupEntries,
addApplication,
removeApplication
};
}


store.$inject = [
'$http',
'BaseApiUrl'
];


const serviceName = "FavouritesStore";


export const FavouritesStore_API = {
getFavouritesGroupEntries: {
serviceName,
serviceFnName: 'getFavouritesGroupEntries',
description: 'fetches application entries for favourites group'
},
addApplication: {
serviceName,
serviceFnName: 'addApplication',
description: 'executes addApplication'
},
removeApplication: {
serviceName,
serviceFnName: 'removeApplication',
description: 'executes removeApplication'
}
};

export default {
serviceName,
store
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
<waltz-page-header icon="desktop"
name="Matching Applications"
small="{{ ctrl.assetCode }}">
<ol class="waltz-breadcrumbs">
<li><a ui-sref="main">Home</a></li>
<li>Waltz</li>
</ol>
<breadcrumbs>
<ol class="waltz-breadcrumbs">
<li><a ui-sref="main">Home</a></li>
<li>Waltz</li>
</ol>
</breadcrumbs>
</waltz-page-header>
<div class="waltz-page-summary waltz-page-summary-attach">
<ul class="list-unstyled">
Expand Down
12 changes: 7 additions & 5 deletions waltz-ng/client/applications/pages/edit/app-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
<waltz-page-header icon="edit"
name="{{ ctrl.application.name }}"
small="Editor">
<ol class="waltz-breadcrumbs">
<li><a ui-sref="main">Home</a></li>
<li><a ui-sref="main.app.view ({ id: ctrl.application.id })">{{ ctrl.application.name }}</a></li>
<li>Edit</li>
</ol>
<breadcrumbs>
<ol class="waltz-breadcrumbs">
<li><a ui-sref="main">Home</a></li>
<li><a ui-sref="main.app.view ({ id: ctrl.application.id })">{{ ctrl.application.name }}</a></li>
<li>Edit</li>
</ol>
</breadcrumbs>
</waltz-page-header>


Expand Down
16 changes: 11 additions & 5 deletions waltz-ng/client/applications/pages/view/app-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@
<waltz-page-header icon="desktop"
name="{{ ctrl.app.name }}"
small="{{ ctrl.app.assetCode }}">
<ol class="waltz-breadcrumbs">
<li><a ui-sref="main">Home</a></li>
<li>Applications</li>
<li><span ng-bind="ctrl.app.name"></span></li>
</ol>
<breadcrumbs>
<ol class="waltz-breadcrumbs">
<li><a ui-sref="main">Home</a></li>
<li>Applications</li>
<li><span ng-bind="ctrl.app.name"></span></li>
</ol>
</breadcrumbs>
<actions>
<waltz-favourites-button parent-entity-ref="ctrl.parentEntityRef">
</waltz-favourites-button>
</actions>
</waltz-page-header>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
<waltz-page-header icon="check-square-o"
name="Attestations"
small="{{ctrl.user.userName}}">
<ol class="waltz-breadcrumbs">
<li><a ui-sref="main">Home</a></li>
<li>Attestations</li>
<li ng-bind="ctrl.user.userName"></li>
</ol>
<breadcrumbs>
<ol class="waltz-breadcrumbs">
<li><a ui-sref="main">Home</a></li>
<li>Attestations</li>
<li ng-bind="ctrl.user.userName"></li>
</ol>
</breadcrumbs>
</waltz-page-header>

<div class="waltz-page-summary waltz-page-summary-attach">
Expand Down
14 changes: 8 additions & 6 deletions waltz-ng/client/attestation/attestation-run-create.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
<waltz-page-header icon="check-square-o"
name="Attestation Run"
small="create">
<ol class="waltz-breadcrumbs">
<li><a ui-sref="main">Home</a></li>
<li><a ui-sref="main.attestation.instance.user">Attestations</a></li>
<li><a ui-sref="main.attestation.run.list">Attestation runs</a></li>
<li>Create</li>
</ol>
<breadcrumbs>
<ol class="waltz-breadcrumbs">
<li><a ui-sref="main">Home</a></li>
<li><a ui-sref="main.attestation.instance.user">Attestations</a></li>
<li><a ui-sref="main.attestation.run.list">Attestation runs</a></li>
<li>Create</li>
</ol>
</breadcrumbs>
</waltz-page-header>

<div class="waltz-page-summary waltz-page-summary-attach">
Expand Down
12 changes: 7 additions & 5 deletions waltz-ng/client/attestation/attestation-run-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
<waltz-page-header icon="check-square-o"
name="Attestation runs"
small="list">
<ol class="waltz-breadcrumbs">
<li><a ui-sref="main">Home</a></li>
<li><a ui-sref="main.attestation.instance.user">Attestations</a></li>
<li>runs</li>
</ol>
<breadcrumbs>
<ol class="waltz-breadcrumbs">
<li><a ui-sref="main">Home</a></li>
<li><a ui-sref="main.attestation.instance.user">Attestations</a></li>
<li>runs</li>
</ol>
</breadcrumbs>
</waltz-page-header>

<div class="waltz-page-summary waltz-page-summary-attach">
Expand Down
12 changes: 7 additions & 5 deletions waltz-ng/client/attestation/attestation-run-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
<waltz-page-header icon="check-square-o"
name="{{ctrl.run.name}}"
small="Attestation Run">
<ol class="waltz-breadcrumbs">
<li><a ui-sref="main">Home</a></li>
<li><a ui-sref="main.attestation.run.list">Attestation runs</a></li>
<li><span ng-bind="ctrl.run.name"></span></li>
</ol>
<breadcrumbs>
<ol class="waltz-breadcrumbs">
<li><a ui-sref="main">Home</a></li>
<li><a ui-sref="main.attestation.run.list">Attestation runs</a></li>
<li><span ng-bind="ctrl.run.name"></span></li>
</ol>
</breadcrumbs>
</waltz-page-header>

<div class="waltz-page-summary waltz-page-summary-attach">
Expand Down
Loading

0 comments on commit 16913b4

Please sign in to comment.