From 643b0827e8b60b07c274263b312f4a0ee682c404 Mon Sep 17 00:00:00 2001 From: mofogasy Date: Fri, 8 Nov 2019 12:52:48 +0100 Subject: [PATCH] fix: add wildcard support for querying capabilities in the host app fixes: #201 --- .../src/lib/core/manifest-registry.service.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/projects/scion/workbench-application-platform/src/lib/core/manifest-registry.service.ts b/projects/scion/workbench-application-platform/src/lib/core/manifest-registry.service.ts index 540accf6e..89351c65a 100644 --- a/projects/scion/workbench-application-platform/src/lib/core/manifest-registry.service.ts +++ b/projects/scion/workbench-application-platform/src/lib/core/manifest-registry.service.ts @@ -13,6 +13,7 @@ import { Capability, Intent, Qualifier } from '@scion/workbench-application-plat import { Defined } from './defined.util'; import { sha256 } from 'js-sha256'; import { matchesCapabilityQualifier, matchesIntentQualifier, qualifiersEqual } from './qualifier-tester'; +import { patchQualifier } from './qualifier-patcher'; /** * Registry with all registered application capabilities and intents. @@ -50,9 +51,13 @@ export class ManifestRegistry { /** * Returns capabilities which have the given required type and qualifier. */ - public getCapabilities(type: string, qualifier: Qualifier): T[] { + public getCapabilities(type: string, qualifier: Qualifier, options?: {wildcardQuery?: boolean}): T[] { + const wildcardQuery = Defined.orElse(options && options.wildcardQuery, false); return this.getCapabilitiesByType(type) - .filter(capability => matchesCapabilityQualifier(capability.qualifier, qualifier)) as T[]; + .filter(capability => { + const queryQualifier = wildcardQuery ? patchQualifier(qualifier, capability.qualifier) : qualifier; + return matchesCapabilityQualifier(capability.qualifier, queryQualifier); + }) as T[]; } /**