diff --git a/mqtt-mapping-ui/mqtt-mapping/package.json b/mqtt-mapping-ui/mqtt-mapping/package.json index a56505e9..223e0fd0 100644 --- a/mqtt-mapping-ui/mqtt-mapping/package.json +++ b/mqtt-mapping-ui/mqtt-mapping/package.json @@ -1,7 +1,7 @@ { "name": "mqtt-mapping", "version": "3.3.3", - "description": "Cumulocity plugin to map custom JSON payloads to C8Y payloads.The lugin support both directions: inbound/outbound.", + "description": "Cumulocity plugin to map custom JSON payloads to C8Y payloads.The plugin support both directions: inbound/outbound.", "repository": { "type": "git", "url": "git@github.com:SoftwareAG/cumulocity-dynamic-mqtt-mapper.git" diff --git a/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/core/c8y-agent.service.ts b/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/core/c8y-agent.service.ts index c5183c36..28f5dffa 100644 --- a/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/core/c8y-agent.service.ts +++ b/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/core/c8y-agent.service.ts @@ -50,6 +50,12 @@ export class C8YAgent { private alert: AlertService ) {} + + public initializeCache(): void { + this.inventory.initializeCache(); + this.identity.initializeCache(); + } + async createMEAO(context: ProcessingContext) { let result: any; let error: string = ""; diff --git a/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/core/facade-identity.service.ts b/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/core/facade-identity.service.ts index 590d6308..d8f368d4 100644 --- a/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/core/facade-identity.service.ts +++ b/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/core/facade-identity.service.ts @@ -24,7 +24,6 @@ import { IExternalIdentity, IIdentified, IResult, - IResultList, } from "@c8y/client"; import * as _ from "lodash"; import { ProcessingContext } from "../processor/prosessor.model"; @@ -39,6 +38,10 @@ export class FacadeIdentityService { private identity: IdentityService ) {} + public initializeCache(): void { + this.mockIdentity.initializeCache(); + } + public async resolveGlobalId2ExternalId( managedObjectId: string, externalIdType: string, diff --git a/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/core/facade-inventory.service.ts b/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/core/facade-inventory.service.ts index 9e737654..e9f05447 100644 --- a/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/core/facade-inventory.service.ts +++ b/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/core/facade-inventory.service.ts @@ -32,6 +32,10 @@ export class FacadeInventoryService { private inventory: InventoryService ) {} + public initializeCache(): void { + this.mockInventory.initializeCache(); + } + public update( managedObject: Partial, context: ProcessingContext diff --git a/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/core/mapping.service.ts b/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/core/mapping.service.ts index 5b6a7fc1..bc47351d 100644 --- a/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/core/mapping.service.ts +++ b/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/core/mapping.service.ts @@ -118,6 +118,12 @@ export class MappingService { return this.reload$; } + initializeCache(dir: Direction): void{ + if (dir == Direction.INBOUND) { + this.jsonProcessorInbound.initializeCache(); + } + } + async updateSubscriptions(sub: C8YAPISubscription): Promise { let response = this.client.fetch( `${BASE_URL}/${PATH_SUBSCRIPTION_ENDPOINT}`, diff --git a/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/processor/payload-processor-inbound.service.ts b/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/processor/payload-processor-inbound.service.ts index f6313dba..1769c0c5 100644 --- a/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/processor/payload-processor-inbound.service.ts +++ b/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/processor/payload-processor-inbound.service.ts @@ -47,6 +47,10 @@ export abstract class PayloadProcessorInbound { public abstract extractFromSource(context: ProcessingContext): void; + public initializeCache(): void { + this.c8yClient.initializeCache(); + } + protected JSONATA = require("jsonata"); public async substituteInTargetAndSend(context: ProcessingContext) { @@ -114,7 +118,10 @@ export abstract class PayloadProcessorInbound { } if (mapping.targetAPI != API.INVENTORY.name) { - if (pathTarget == findDeviceIdentifier(mapping).pathTarget && mapping.mapDeviceIdentifier) { + if ( + pathTarget == findDeviceIdentifier(mapping).pathTarget && + mapping.mapDeviceIdentifier + ) { let sourceId: string; const identity = { externalId: substituteValue.value.toString(), diff --git a/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/step-main/mapping-stepper.component.html b/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/step-main/mapping-stepper.component.html index ba3ebf4f..e816fdad 100644 --- a/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/step-main/mapping-stepper.component.html +++ b/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/step-main/mapping-stepper.component.html @@ -387,8 +387,8 @@ (); + editorTestingPayloadTemplateEmitter = new EventEmitter(); schemaUpdateSource: EventEmitter = new EventEmitter(); schemaUpdateTarget: EventEmitter = new EventEmitter(); @@ -705,7 +705,7 @@ export class MappingStepperComponent implements OnInit { const testSourceTemplate = this.editorSource ? this.editorSource.get() : {}; - this.editorTestingRequestTemplateEmitter.emit(testSourceTemplate); + this.editorTestingPayloadTemplateEmitter.emit(testSourceTemplate); this.onSelectSubstitution(0); event.stepper.next(); } diff --git a/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/step-three/mapping-testing.component.html b/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/step-three/mapping-testing.component.html index 26747537..181d77bd 100644 --- a/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/step-three/mapping-testing.component.html +++ b/mqtt-mapping-ui/mqtt-mapping/src/mqtt-mapping/step-three/mapping-testing.component.html @@ -31,11 +31,32 @@

Test mapping

-
+
{{ sourceSystem }} Payload  +
+ + + + {{ testingModel.errorMsg }} + + +
+
+
+
+
+
{{ @@ -59,13 +80,19 @@
-
-
+
+
+ +
+
- +
{{ selectedResult$ | async @@ -86,7 +113,7 @@
-
+
+