-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: match intent with wildcard qualifier key/value(s)
When querying for capability providers, it was not possible to have wildcards in the intent's qualifier entry key or value. This prevented the platform to match intents like e.g. `{entity: '*'}` with more specific capabilities like e.g. `{entity: 'user'}`. fixes: #172
- Loading branch information
1 parent
10c2b45
commit 5ea3981
Showing
12 changed files
with
274 additions
and
22 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...ev-tools-app/src/app/dev-tools/intent-accordion-item/intent-accordion-item.component.html
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<app-qualifier-chip-list [type]="intent.type" [qualifier]="intent.qualifier"></app-qualifier-chip-list> | ||
<div class="hints"> | ||
<span class="implicit" *ngIf="intent.metadata.implicit" title="This is an implicit intent because the application provides the capability itself.">IMPLICIT</span> | ||
<span class="not-handled" *ngIf="!anyQualifier && unhandled$ | async" title="No application found to handle this intent.">NOT HANDLED</span> | ||
<span class="not-handled" *ngIf="unhandled$ | async" title="No application found to handle this intent.">NOT HANDLED</span> | ||
</div> |
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
26 changes: 14 additions & 12 deletions
26
...-tools-app/src/app/dev-tools/intent-accordion-panel/intent-accordion-panel.component.html
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 |
---|---|---|
@@ -1,12 +1,14 @@ | ||
<section *ngIf="!anyQualifier"> | ||
<h2>Handled by following applications</h2> | ||
<ul> | ||
<li *ngFor="let provider of providers$ | async"> | ||
<a class="app-name" [wbRouterLink]="{entity: 'application', symbolicName: provider.symbolicName}" | ||
[wbRouterLinkExtras]="{target: 'blank'}" | ||
[class.self]="provider.symbolicName === intent.metadata.symbolicAppName"> | ||
{{provider.name}} | ||
</a> | ||
</li> | ||
</ul> | ||
</section> | ||
<ng-container *ngIf="providers$ | async as providers"> | ||
<section *ngIf="providers.length"> | ||
<h2>Handled by following applications</h2> | ||
<ul> | ||
<li *ngFor="let provider of providers"> | ||
<a class="app-name" [wbRouterLink]="{entity: 'application', symbolicName: provider.symbolicName}" | ||
[wbRouterLinkExtras]="{target: 'blank'}" | ||
[class.self]="provider.symbolicName === intent.metadata.symbolicAppName"> | ||
{{provider.name}} | ||
</a> | ||
</li> | ||
</ul> | ||
</section> | ||
</ng-container> |
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
45 changes: 45 additions & 0 deletions
45
projects/scion/workbench-application-platform/src/lib/core/qualifier-patcher.ts
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,45 @@ | ||
/* | ||
* Copyright (c) 2018-2019 Swiss Federal Railways | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
|
||
import { NilQualifier, Qualifier } from '@scion/workbench-application-platform.api'; | ||
|
||
/** | ||
* Returns a copy of the given intent qualifier with all its wildcard qualifier values | ||
* replaced with values of the given capability qualifier, if any. | ||
* Also, if the intent qualifier specifies a wildcard key, it is merged with the capability qualifier. | ||
* | ||
* @param intentQualifier | ||
* qualifier for an intent as specified in the manifest, may contain wildcards as qualifier key (*) | ||
* and/or qualifier value (* or ?). | ||
* @param capabilityQualifier | ||
* qualifier for a capability as specified in the manifest, may contain wildcards (* or ?) as qualifier value; | ||
* if `null`, {NilQualifier} is used. | ||
*/ | ||
export function patchQualifier(intentQualifier: Qualifier, capabilityQualifier: Qualifier): Qualifier { | ||
if (!intentQualifier || !capabilityQualifier) { | ||
return intentQualifier || NilQualifier; | ||
} | ||
|
||
// Create a working copy of the intent qualifier | ||
const _intentQualifier: Qualifier = {...intentQualifier}; | ||
delete _intentQualifier['*']; | ||
|
||
Object.keys(capabilityQualifier) | ||
.forEach(key => { | ||
if (intentQualifier[key] === '*' || intentQualifier[key] === '?') { | ||
_intentQualifier[key] = capabilityQualifier[key]; | ||
} | ||
else if (intentQualifier.hasOwnProperty('*') && !intentQualifier.hasOwnProperty(key)) { | ||
_intentQualifier[key] = capabilityQualifier[key]; | ||
} | ||
}); | ||
|
||
return _intentQualifier; | ||
} |
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
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