You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@streampipes.apache.org by "JHoelli (via GitHub)" <gi...@apache.org> on 2025/10/01 11:49:06 UTC

[PR] Add related assets to adapter during adapter generation process

JHoelli opened a new pull request, #3804:
URL: https://github.com/apache/streampipes/pull/3804

   ### Purpose
   Adds the ability to associate adapters with assets during the adapter creation process.
   
   ### Remarks
   
   1. New Component: adapter-asset-configuration - A component for managing the adapter-asset configuration.
   2. New Service: adapter-asset-configuration.service - A service for adding adapters to assets.
   3. UI Update: Minor changes to start-adapter-configuration to include the new checkbox element (adapter-asset-configuration). Added new success message in adapter-started-success.
   4. Backend: new Endpoint to map the generated measure to the data-lake id 
   
   PR introduces (a) breaking change(s): <no>
   
   PR introduces (a) deprecation(s): <no>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add related assets to adapter during adapter generation process

Posted by "tenthe (via GitHub)" <gi...@apache.org>.
tenthe commented on code in PR #3804:
URL: https://github.com/apache/streampipes/pull/3804#discussion_r2399088729


##########
ui/src/app/connect/dialog/adapter-started/adapter-started-dialog.component.ts:
##########
@@ -214,6 +242,92 @@ export class AdapterStartedDialog implements OnInit {
         this.shepherdService.trigger('confirm_adapter_started_button');
     }
 
+    async addToAsset(): Promise<void> {
+        this.pollingActive = false;

Review Comment:
   It seems this is a legacy variable, can we remove it form this class?



##########
ui/projects/streampipes/platform-services/src/lib/model/assets/asset.model.ts:
##########
@@ -43,6 +43,13 @@ export interface AssetLink {
     navigationActive: boolean;
 }
 
+export interface LinkageData {

Review Comment:
   Can you please add a small comment what this class is used for?



##########
ui/src/app/connect/dialog/adapter-started/adapter-started-dialog.component.ts:
##########
@@ -214,6 +242,92 @@ export class AdapterStartedDialog implements OnInit {
         this.shepherdService.trigger('confirm_adapter_started_button');
     }
 
+    async addToAsset(): Promise<void> {
+        this.pollingActive = false;
+
+        try {
+            const adapter = await this.getAdapter();
+            const linkageData: LinkageData[] = this.createLinkageData(adapter);
+
+            if (this.saveInDataLake) {
+                await this.addDataLakeLinkageData(adapter, linkageData);
+            }
+
+            await this.saveAssets(linkageData);
+            this.setSuccessMessage(linkageData);
+        } catch (err) {
+            console.error('Error in addToAsset:', err);
+        }
+    }
+
+    private async getAdapter(): Promise<AdapterDescription> {
+        return await this.adapterService
+            .getAdapter(this.adapterElementId)
+            .toPromise();
+    }
+
+    private createLinkageData(adapter: AdapterDescription): LinkageData[] {
+        return [
+            {
+                type: 'adapter',
+                id: this.adapterElementId,
+                name: adapter.name,
+            },
+            {
+                type: 'data-source',
+                id: adapter.correspondingDataStreamElementId,
+                name: adapter.name,
+            },
+        ];
+    }
+
+    private async addDataLakeLinkageData(
+        adapter: AdapterDescription,
+        linkageData: LinkageData[],
+    ): Promise<void> {
+        const pipelineId = `persist-${this.adapter.name.replaceAll(' ', '-')}`;
+        linkageData.push({
+            type: 'pipeline',
+            id: pipelineId,
+            name: pipelineId,
+        });
+
+        const res = await this.dataLakeService
+            .getMeasurementByName(adapter.name)
+            .toPromise();
+
+        linkageData.push({
+            type: 'measurement',
+            id: res.elementId,
+            name: adapter.name,
+        });
+    }
+
+    private async saveAssets(linkageData: LinkageData[]): Promise<void> {
+        await this.assetSaveService.saveSelectedAssets(
+            this.selectedAssets,
+            linkageData,
+        );
+    }
+
+    private setSuccessMessage(linkageData: LinkageData[]): void {
+        const assetTypesList = this.formatWithAnd(
+            linkageData.map(data => data.type),
+        );
+
+        const assetIdsList = this.formatWithAnd(
+            this.selectedAssets.map(asset => asset.assetName),
+        );
+
+        this.addToAssetText = `Your ${assetTypesList} were successfully added to ${assetIdsList}.`;

Review Comment:
   Can you please add support for multiple languages here.



##########
ui/src/app/connect/dialog/adapter-started/adapter-started-dialog.component.ts:
##########
@@ -214,6 +242,92 @@ export class AdapterStartedDialog implements OnInit {
         this.shepherdService.trigger('confirm_adapter_started_button');
     }
 
+    async addToAsset(): Promise<void> {
+        this.pollingActive = false;
+
+        try {
+            const adapter = await this.getAdapter();
+            const linkageData: LinkageData[] = this.createLinkageData(adapter);
+
+            if (this.saveInDataLake) {
+                await this.addDataLakeLinkageData(adapter, linkageData);
+            }
+
+            await this.saveAssets(linkageData);
+            this.setSuccessMessage(linkageData);
+        } catch (err) {
+            console.error('Error in addToAsset:', err);
+        }
+    }
+
+    private async getAdapter(): Promise<AdapterDescription> {
+        return await this.adapterService
+            .getAdapter(this.adapterElementId)
+            .toPromise();

Review Comment:
   Looks like `.toPromise()` is deprecated — you might want to use `firstValueFrom(...)` here instead:
   
   ```
   return await firstValueFrom(this.adapterService.getAdapter(this.adapterElementId));
   ```
   
   



##########
ui/src/app/connect/dialog/adapter-started/adapter-started-dialog.component.ts:
##########
@@ -214,6 +242,92 @@ export class AdapterStartedDialog implements OnInit {
         this.shepherdService.trigger('confirm_adapter_started_button');
     }
 
+    async addToAsset(): Promise<void> {
+        this.pollingActive = false;
+
+        try {
+            const adapter = await this.getAdapter();
+            const linkageData: LinkageData[] = this.createLinkageData(adapter);
+
+            if (this.saveInDataLake) {
+                await this.addDataLakeLinkageData(adapter, linkageData);
+            }
+
+            await this.saveAssets(linkageData);

Review Comment:
   ```suggestion
              this.saveAssets(linkageData);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add related assets to adapter during adapter generation process

Posted by "tenthe (via GitHub)" <gi...@apache.org>.
tenthe merged PR #3804:
URL: https://github.com/apache/streampipes/pull/3804


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org