You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2021/09/30 09:04:26 UTC
[incubator-streampipes] branch STREAMPIPES-432 updated: Add builder
for pipeline invocations
This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch STREAMPIPES-432
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git
The following commit(s) were added to refs/heads/STREAMPIPES-432 by this push:
new 7a511aa Add builder for pipeline invocations
7a511aa is described below
commit 7a511aab9e5ba3c544b6838ac46936e2d2becd53
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Thu Sep 30 11:03:57 2021 +0200
Add builder for pipeline invocations
---
.../adapter-started-dialog.component.ts | 31 +++++-----
.../template/PipelineInvocationBuilder.ts | 68 ++++++++++++++++++++++
.../apis/pipeline-template.service.ts | 3 +-
3 files changed, 82 insertions(+), 20 deletions(-)
diff --git a/ui/src/app/connect/dialog/adapter-started/adapter-started-dialog.component.ts b/ui/src/app/connect/dialog/adapter-started/adapter-started-dialog.component.ts
index 6eb930a..18a6f8d 100644
--- a/ui/src/app/connect/dialog/adapter-started/adapter-started-dialog.component.ts
+++ b/ui/src/app/connect/dialog/adapter-started/adapter-started-dialog.component.ts
@@ -21,15 +21,14 @@ import { ShepherdService } from '../../../services/tour/shepherd.service';
import { RestService } from '../../services/rest.service';
import {
AdapterDescriptionUnion,
- FreeTextStaticProperty,
GenericAdapterSetDescription,
- MappingPropertyUnary,
Message,
SpDataStream,
SpecificAdapterSetDescription
} from '../../../core-model/gen/streampipes-model';
import { DialogRef } from '../../../core-ui/dialog/base-dialog/dialog-ref';
import { PipelineTemplateService } from '../../../platform-services/apis/pipeline-template.service';
+import { PipelineInvocationBuilder } from '../../../core-services/template/PipelineInvocationBuilder';
@Component({
selector: 'sp-dialog-adapter-started-dialog',
@@ -97,24 +96,20 @@ export class AdapterStartedDialog implements OnInit {
}
if (this.saveInDataLake) {
- const templateName = 'org.apache.streampipes.manager.template.instances.DataLakePipelineTemplate';
- // x.notifications[0].title
- this.pipelineTemplateService.getPipelineTemplateInvocation(this.adapter.adapterId, templateName)
+ const pipelineId = 'org.apache.streampipes.manager.template.instances.DataLakePipelineTemplate';
+ this.pipelineTemplateService.getPipelineTemplateInvocation(this.adapter.adapterId, pipelineId)
.subscribe(res => {
- let indexName;
- res.staticProperties.forEach(property => {
- if (property instanceof FreeTextStaticProperty && 'domId2db_measurement' === property.internalName) {
- indexName = this.adapter.name.toLowerCase().replace(' ', '_');
- property.value = indexName;
- } else if (property instanceof MappingPropertyUnary && 'domId2timestamp_mapping' === property.internalName) {
- property.selectedProperty = 's0::' + this.dataLakeTimestampField;
- }
- });
-
- res.pipelineTemplateId = templateName;
- // res.name = this.data.adapter.label;
- this.pipelineTemplateService.createPipelineTemplateInvocation(res, indexName);
+ const indexName = this.adapter.name.toLowerCase().replace(' ', '_');
+ const pipelineInvocation = PipelineInvocationBuilder
+ .create(res)
+ .setName(indexName)
+ .setTemplateId(pipelineId)
+ .setFreeTextStaticProperty('db_measurement', indexName)
+ .setMappingPropertyUnary('timestamp_mapping', 's0::' + this.dataLakeTimestampField)
+ .build();
+
+ this.pipelineTemplateService.createPipelineTemplateInvocation(pipelineInvocation);
});
}
}
diff --git a/ui/src/app/core-services/template/PipelineInvocationBuilder.ts b/ui/src/app/core-services/template/PipelineInvocationBuilder.ts
new file mode 100644
index 0000000..1cc7e41
--- /dev/null
+++ b/ui/src/app/core-services/template/PipelineInvocationBuilder.ts
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+import { FreeTextStaticProperty, MappingPropertyUnary, PipelineTemplateInvocation } from '../../core-model/gen/streampipes-model';
+
+export class PipelineInvocationBuilder {
+
+ private pipelineTemplateInvocation: PipelineTemplateInvocation;
+
+ constructor(pipelineTemplateInvocation: PipelineTemplateInvocation) {
+ this.pipelineTemplateInvocation = pipelineTemplateInvocation;
+ }
+
+ public static create(pipelineTemplateInvocation: PipelineTemplateInvocation) {
+ return new PipelineInvocationBuilder(pipelineTemplateInvocation);
+ }
+
+ public setTemplateId(id: string) {
+ this.pipelineTemplateInvocation.pipelineTemplateId = id;
+ return this;
+ }
+
+ public setName(name: string) {
+ this.pipelineTemplateInvocation.kviName = name;
+ return this;
+ }
+
+ public setFreeTextStaticProperty(name: string, value: string) {
+ this.pipelineTemplateInvocation.staticProperties.forEach(property => {
+ if (property instanceof FreeTextStaticProperty && 'domId2' + name === property.internalName) {
+ property.value = value;
+ }
+ });
+
+ return this;
+ }
+
+ public setMappingPropertyUnary(name: string, value: string) {
+ this.pipelineTemplateInvocation.staticProperties.forEach(property => {
+ if (property instanceof MappingPropertyUnary && 'domId2' + name === property.internalName) {
+ property.selectedProperty = value;
+ }
+ });
+
+ return this;
+ }
+
+ public build() {
+ return this.pipelineTemplateInvocation;
+ }
+
+
+}
+
diff --git a/ui/src/app/platform-services/apis/pipeline-template.service.ts b/ui/src/app/platform-services/apis/pipeline-template.service.ts
index ea6eaef..b0f6433 100644
--- a/ui/src/app/platform-services/apis/pipeline-template.service.ts
+++ b/ui/src/app/platform-services/apis/pipeline-template.service.ts
@@ -103,8 +103,7 @@ export class PipelineTemplateService {
return val as FreeTextStaticProperty;
}
- createPipelineTemplateInvocation(invocation: PipelineTemplateInvocation, pipelineName: string) {
- invocation.kviName = pipelineName;
+ createPipelineTemplateInvocation(invocation: PipelineTemplateInvocation) {
this.http
.post(this.getServerUrl() + '/api/v2/pipeline-templates', invocation)
.subscribe();