Skip to content

Commit

Permalink
Report incoherences for capabilities mapping
Browse files Browse the repository at this point in the history
 Close #134
  • Loading branch information
mauvaisetroupe committed Oct 11, 2023
1 parent 3bb7815 commit d4717b2
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mauvaisetroupe.eadesignit.web.rest;

import com.mauvaisetroupe.eadesignit.domain.Application;
import com.mauvaisetroupe.eadesignit.domain.LandscapeView;
import com.mauvaisetroupe.eadesignit.repository.LandscapeViewRepository;
import com.mauvaisetroupe.eadesignit.repository.view.LandscapeLight;
Expand All @@ -13,9 +14,11 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathExpressionException;
Expand Down Expand Up @@ -189,10 +192,32 @@ public ResponseEntity<LandscapeDTO> getLandscapeView(@PathVariable Long id) {
CapabilityUtil capabilityUtil = new CapabilityUtil();

if (landscapeView.isPresent()) {
Collection<CapabilityDTO> result = capabilityUtil.getRoot(

// Capabilities

Collection<CapabilityDTO> capabilitiesRoots = capabilityUtil.getRoot(
landscapeView.get().getCapabilityApplicationMappings().stream().map(cp -> cp.getCapability()).collect(Collectors.toList())
);

// All applications from capabilities

Set<Application> applicationsFromCapabilities = landscapeView.get().getCapabilityApplicationMappings().stream().map(cm -> cm.getApplication()).collect(Collectors.toSet());

// All applications from flows

Set<Application> applicationsFromFlows = new HashSet<>();
landscapeView.get().getFlows().stream().flatMap(f -> f.getInterfaces().stream()).forEach( i -> {
applicationsFromFlows.add(i.getSource());
applicationsFromFlows.add(i.getTarget());
});

// Find difference between applications in flows and in capabilities
Set<Application> applicationOnlyInCapabilities = applicationsFromCapabilities.stream().filter(a -> !applicationsFromFlows.contains(a)).collect(Collectors.toSet());
Set<Application> applicationOnlyInFlows = applicationsFromFlows.stream().filter(a -> !applicationsFromCapabilities.contains(a)).collect(Collectors.toSet());


// DrawIO

try {
MXFileSerializer fileSerializer = new MXFileSerializer(landscapeView.get());
if (StringUtils.hasText(landscapeView.get().getCompressedDrawXML())) {
Expand All @@ -208,7 +233,9 @@ public ResponseEntity<LandscapeDTO> getLandscapeView(@PathVariable Long id) {
e.printStackTrace();
}
landscapeDTO.setLandscape(landscapeView.get());
landscapeDTO.setConsolidatedCapability(result);
landscapeDTO.setConsolidatedCapability(capabilitiesRoots);
landscapeDTO.setApplicationsOnlyInCapabilities(applicationOnlyInCapabilities);
landscapeDTO.setApplicationsOnlyInFlows(applicationOnlyInFlows);
}
Optional<LandscapeDTO> landscapeDtoOptional;
if (landscapeView.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package com.mauvaisetroupe.eadesignit.web.rest.dto;

import com.mauvaisetroupe.eadesignit.domain.Application;
import com.mauvaisetroupe.eadesignit.domain.LandscapeView;
import com.mauvaisetroupe.eadesignit.service.dto.CapabilityDTO;
import java.util.Collection;
import java.util.Set;

public class LandscapeDTO {

LandscapeView landscape;
Collection<CapabilityDTO> consolidatedCapability;
Set<Application> applicationsOnlyInCapabilities;
Set<Application> applicationsOnlyInFlows;

public Collection<CapabilityDTO> getConsolidatedCapability() {
return consolidatedCapability;
Expand All @@ -24,4 +28,20 @@ public LandscapeView getLandscape() {
public void setLandscape(LandscapeView landscape) {
this.landscape = landscape;
}

public Set<Application> getApplicationsOnlyInCapabilities() {
return applicationsOnlyInCapabilities;
}

public void setApplicationsOnlyInCapabilities(Set<Application> applicationsOnlyInCapabilities) {
this.applicationsOnlyInCapabilities = applicationsOnlyInCapabilities;
}

public Set<Application> getApplicationsOnlyInFlows() {
return applicationsOnlyInFlows;
}

public void setApplicationsOnlyInFlows(Set<Application> applicationsOnlyInFlows) {
this.applicationsOnlyInFlows = applicationsOnlyInFlows;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ export default class LandscapeViewDetails extends mixins(JhiDataUtils) {
public landscapeViewId = -1;
public filter = '';
public showLabelIfNumberapplicationsLessThan = 20;
public applicationsOnlyInCapabilities: IApplication[] = [];
public applicationsOnlyInFlows: IApplication[] = [];
public get reportToDisplay() {
return (this.applicationsOnlyInCapabilities.length > 0 || this.applicationsOnlyInFlows.length > 0);

Check warning on line 60 in src/main/webapp/app/entities/landscape-view/landscape-view-details.component.ts

View workflow job for this annotation

GitHub Actions / EADesignIt pipeline

Replace `(this.applicationsOnlyInCapabilities.length·>·0·||·this.applicationsOnlyInFlows.length·>·0)` with `this.applicationsOnlyInCapabilities.length·>·0·||·this.applicationsOnlyInFlows.length·>·0`
}
public capabilitiesByApplicationID = new Object();
public flowsByApplicationID = new Object();

//for description update
public reorderAliasflowToSave: IFunctionalFlow[] = [];
Expand All @@ -64,6 +71,23 @@ export default class LandscapeViewDetails extends mixins(JhiDataUtils) {
return this.landscapeView.flows.map(f => f.alias);
}

public get allApplications() {
if (!this.landscapeView || !this.landscapeView.flows) return [];
return this.landscapeView.flows.flatMap(f => f.allApplications).filter((value, index, self) =>

Check warning on line 76 in src/main/webapp/app/entities/landscape-view/landscape-view-details.component.ts

View workflow job for this annotation

GitHub Actions / EADesignIt pipeline

Replace `.flatMap(f·=>·f.allApplications).filter((value,·index,·self)·=>⏎····index·===·self.findIndex((a)·=>·(⏎······a.id·===·value.id⏎····)))` with `⏎······.flatMap(f·=>·f.allApplications)⏎······.filter((value,·index,·self)·=>·index·===·self.findIndex(a·=>·a.id·===·value.id));`
index === self.findIndex((a) => (
a.id === value.id
)))
}

public get onlyCapabilitiesPercent() {
return (100 * this.applicationsOnlyInCapabilities.length / this.allApplications.length).toFixed(0)

Check warning on line 83 in src/main/webapp/app/entities/landscape-view/landscape-view-details.component.ts

View workflow job for this annotation

GitHub Actions / EADesignIt pipeline

Replace `100·*·this.applicationsOnlyInCapabilities.length·/·this.allApplications.length).toFixed(0)` with `(100·*·this.applicationsOnlyInCapabilities.length)·/·this.allApplications.length).toFixed(0);`
}

public get onlyFlowsPercent() {
return (100 * this.applicationsOnlyInFlows.length / this.allApplications.length).toFixed(0)

Check warning on line 87 in src/main/webapp/app/entities/landscape-view/landscape-view-details.component.ts

View workflow job for this annotation

GitHub Actions / EADesignIt pipeline

Replace `100·*·this.applicationsOnlyInFlows.length·/·this.allApplications.length).toFixed(0)` with `(100·*·this.applicationsOnlyInFlows.length)·/·this.allApplications.length).toFixed(0);`
}

Check warning on line 88 in src/main/webapp/app/entities/landscape-view/landscape-view-details.component.ts

View workflow job for this annotation

GitHub Actions / EADesignIt pipeline

Delete `⏎`


@Watch('tabIndex')
public onTabChange(newtab) {
this.tabIndex = newtab;
Expand Down Expand Up @@ -129,7 +153,29 @@ export default class LandscapeViewDetails extends mixins(JhiDataUtils) {
});
flow.allApplications = Object.values(distinctApplications);
});
if (this.landscapeView && this.landscapeView.flows) {
// flowsByApplicationID
this.landscapeView.flows.forEach(f => {
f.steps.map(s => s.flowInterface).forEach(i => {

Check warning on line 159 in src/main/webapp/app/entities/landscape-view/landscape-view-details.component.ts

View workflow job for this annotation

GitHub Actions / EADesignIt pipeline

Replace `.map(s·=>·s.flowInterface)` with `⏎··············.map(s·=>·s.flowInterface)⏎··············`
if (!this.flowsByApplicationID[i.source.id]) this.flowsByApplicationID[i.source.id] = [];

Check warning on line 160 in src/main/webapp/app/entities/landscape-view/landscape-view-details.component.ts

View workflow job for this annotation

GitHub Actions / EADesignIt pipeline

Insert `··`
this.flowsByApplicationID[i.source.id] = [f];

Check warning on line 161 in src/main/webapp/app/entities/landscape-view/landscape-view-details.component.ts

View workflow job for this annotation

GitHub Actions / EADesignIt pipeline

Replace `··············` with `················`
if (!this.flowsByApplicationID[i.target.id]) this.flowsByApplicationID[i.target.id] = [];

Check warning on line 162 in src/main/webapp/app/entities/landscape-view/landscape-view-details.component.ts

View workflow job for this annotation

GitHub Actions / EADesignIt pipeline

Insert `··`
this.flowsByApplicationID[i.target.id] = [f];

Check warning on line 163 in src/main/webapp/app/entities/landscape-view/landscape-view-details.component.ts

View workflow job for this annotation

GitHub Actions / EADesignIt pipeline

Insert `··`
})
});
}
this.consolidatedCapability = res.consolidatedCapability;

if (this.landscapeView && this.landscapeView.capabilityApplicationMappings) {
// capabilitiesByApplicationID
this.landscapeView.capabilityApplicationMappings.forEach(cm => {
if (!this.capabilitiesByApplicationID[cm.application.id]) this.capabilitiesByApplicationID[cm.application.id] = [];
this.capabilitiesByApplicationID[cm.application.id].push(cm.capability);
})
}

this.applicationsOnlyInCapabilities = res.applicationsOnlyInCapabilities;
this.applicationsOnlyInFlows = res.applicationsOnlyInFlows
if (this.landscapeView.compressedDrawSVG) {
this.drawIoSVG = decodeURIComponent(escape(window.atob(this.landscapeView.compressedDrawSVG)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,60 @@
</div>
</div>
</b-tab>
<b-tab title="Report" id="tab-report">
<div>
<div v-if="applicationsOnlyInCapabilities.length">
<h4>[Capability Mapping] Applications with no Functional Flow
({{ onlyCapabilitiesPercent }} %)
</h4>
<b-table
:items="applicationsOnlyInCapabilities"
:fields="['id','alias','name', 'flows', 'capabilities']"
striped
fixed
class="mx-5"
>
<template #cell(flows)="data">
<span v-for="(f, i) in flowsByApplicationID[data.item.id]" :key="f.id">
{{ i == 0 ? '' : ', ' }} <router-link :to="{ name: 'FunctionalFlowView', params: { functionalFlowId: f.id } }">{{ f.alias }}</router-link>
</span>
</template>

<template #cell(capabilities)="data">
<span v-for="(c, i) in capabilitiesByApplicationID[data.item.id]" :key="c.id">
{{ i == 0 ? '' : ', ' }} <router-link :to="{ name: 'CapabilityView', params: { capabilityId: c.id } }">L{{ c.level }} - {{ c.name }}</router-link>
</span>
</template>

</b-table>
</div>
<div v-if="applicationsOnlyInFlows">
<h4>[Capability Mapping] Applications with no Capability
({{ onlyFlowsPercent }} %)
</h4>
<b-table
:items="applicationsOnlyInFlows"
:fields="['id','alias','name', 'flows', 'capabilities']"
striped
fixed
class="ml-5"
>
<template #cell(flows)="data">
<span v-for="(f, i) in flowsByApplicationID[data.item.id]" :key="f.id">
{{ i == 0 ? '' : ', ' }}<router-link :to="{ name: 'FunctionalFlowView', params: { functionalFlowId: f.id } }">{{ f.alias }}</router-link>
</span>
</template>

<template #cell(capabilities)="data">
<span v-for="(c, i) in capabilitiesByApplicationID[data.item.id]" :key="c.id">
{{ i == 0 ? '' : ', ' }} <router-link :to="{ name: 'CapabilityView', params: { capabilityId: c.id } }">L{{ c.level }} - {{ c.name }}</router-link>
</span>
</template>

</b-table>
</div>
</div>
</b-tab>
</b-tabs>
</div>
<div class="col-12">
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/app/shared/model/functional-flow.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface IFunctionalFlow {
owner?: IOwner | null;
landscapes?: ILandscapeView[] | null;
dataFlows?: IDataFlow[] | null;
allApplications?: IApplication[];
allApplications?: IApplication[]; // not given by backend, computed in typescript
}

export class FunctionalFlow implements IFunctionalFlow {
Expand Down
3 changes: 3 additions & 0 deletions src/main/webapp/app/shared/model/landscape-view.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ICapabilityApplicationMapping } from '@/shared/model/capability-applica

import { ViewPoint } from '@/shared/model/enumerations/view-point.model';
import { ICapability } from './capability.model';
import { IApplication } from './application.model';
export interface ILandscapeView {
id?: number;
viewpoint?: ViewPoint | null;
Expand All @@ -18,6 +19,8 @@ export interface ILandscapeView {
export interface ILandscapeDTO {
landscape: ILandscapeView;
consolidatedCapability: ICapability[];
applicationsOnlyInCapabilities: IApplication[];
applicationsOnlyInFlows: IApplication[];
}

export class LandscapeView implements ILandscapeView {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ describe('Component Tests', () => {
const lanscapeDTO: ILandscapeDTO = {
landscape: { id: 123, flows: [] },
consolidatedCapability: [],
applicationsOnlyInCapabilities: [],
applicationsOnlyInFlows: [],
};
landscapeViewServiceStub.find.resolves(lanscapeDTO);

Expand Down Expand Up @@ -100,6 +102,8 @@ describe('Component Tests', () => {
const lanscapeDTO: ILandscapeDTO = {
landscape: { id: 123, flows: [] },
consolidatedCapability: [],
applicationsOnlyInCapabilities: [],
applicationsOnlyInFlows: [],
};

landscapeViewServiceStub.find.resolves(lanscapeDTO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ describe('Component Tests', () => {
const lanscapeDTO: ILandscapeDTO = {
landscape: { id: 123 },
consolidatedCapability: [],
applicationsOnlyInCapabilities: [],
applicationsOnlyInFlows: [],
};
landscapeViewServiceStub.find.resolves(lanscapeDTO);
landscapeViewServiceStub.retrieve.resolves([lanscapeDTO]);
Expand Down

0 comments on commit d4717b2

Please sign in to comment.