You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ri...@apache.org on 2020/05/18 21:30:15 UTC
[incubator-streampipes] branch dev updated: [STREAMPIPES-133]: Add
feature to reset code template
This is an automated email from the ASF dual-hosted git repository.
riemer pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git
The following commit(s) were added to refs/heads/dev by this push:
new 55c12a3 [STREAMPIPES-133]: Add feature to reset code template
55c12a3 is described below
commit 55c12a3b341195312d77e9d2ae4c2335584ee2d8
Author: Dominik Riemer <ri...@fzi.de>
AuthorDate: Mon May 18 23:29:59 2020 +0200
[STREAMPIPES-133]: Add feature to reset code template
---
.../staticproperty/CodeInputStaticProperty.java | 12 ++++++++++++
...AbstractConfigurablePipelineElementBuilder.java | 2 +-
.../sdk/extractor/AbstractParameterExtractor.java | 22 +++++-----------------
.../apache/streampipes/vocabulary/StreamPipes.java | 1 +
.../components/code/code-editor.directive.ts | 3 +++
.../app/editor/components/code/code.controller.ts | 13 +++++++++++++
ui/src/app/editor/components/code/code.tmpl.html | 9 +++++++--
7 files changed, 42 insertions(+), 20 deletions(-)
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/staticproperty/CodeInputStaticProperty.java b/streampipes-model/src/main/java/org/apache/streampipes/model/staticproperty/CodeInputStaticProperty.java
index 9d596c5..f41c12d 100644
--- a/streampipes-model/src/main/java/org/apache/streampipes/model/staticproperty/CodeInputStaticProperty.java
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/staticproperty/CodeInputStaticProperty.java
@@ -31,6 +31,9 @@ public class CodeInputStaticProperty extends StaticProperty {
@RdfProperty(StreamPipes.HAS_LANGUAGE)
private String language;
+ @RdfProperty(StreamPipes.HAS_CODE_TEMPLATE)
+ private String codeTemplate;
+
@RdfProperty(StreamPipes.HAS_CODE_INPUT)
private String value;
@@ -42,6 +45,7 @@ public class CodeInputStaticProperty extends StaticProperty {
super(other);
this.language = other.getLanguage();
this.value = other.getValue();
+ this.codeTemplate = other.getCodeTemplate();
}
public CodeInputStaticProperty(String internalName, String label, String description) {
@@ -63,4 +67,12 @@ public class CodeInputStaticProperty extends StaticProperty {
public void setValue(String value) {
this.value = value;
}
+
+ public String getCodeTemplate() {
+ return codeTemplate;
+ }
+
+ public void setCodeTemplate(String codeTemplate) {
+ this.codeTemplate = codeTemplate;
+ }
}
diff --git a/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/builder/AbstractConfigurablePipelineElementBuilder.java b/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/builder/AbstractConfigurablePipelineElementBuilder.java
index befc3d3..57646ed 100644
--- a/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/builder/AbstractConfigurablePipelineElementBuilder.java
+++ b/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/builder/AbstractConfigurablePipelineElementBuilder.java
@@ -149,7 +149,7 @@ public abstract class AbstractConfigurablePipelineElementBuilder<BU extends
CodeInputStaticProperty codeInputStaticProperty = new CodeInputStaticProperty(label.getInternalId(),
label.getLabel(), label.getDescription());
codeInputStaticProperty.setLanguage(codeLanguage.name());
- codeInputStaticProperty.setValue(codeLanguage.getDefaultSkeleton());
+ codeInputStaticProperty.setCodeTemplate(codeLanguage.getDefaultSkeleton());
this.staticProperties.add(codeInputStaticProperty);
return me();
diff --git a/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/extractor/AbstractParameterExtractor.java b/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/extractor/AbstractParameterExtractor.java
index 454d8af..e80577b 100644
--- a/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/extractor/AbstractParameterExtractor.java
+++ b/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/extractor/AbstractParameterExtractor.java
@@ -30,23 +30,7 @@ import org.apache.streampipes.model.schema.EventPropertyList;
import org.apache.streampipes.model.schema.EventPropertyNested;
import org.apache.streampipes.model.schema.EventPropertyPrimitive;
import org.apache.streampipes.model.schema.PropertyScope;
-import org.apache.streampipes.model.staticproperty.AnyStaticProperty;
-import org.apache.streampipes.model.staticproperty.CollectionStaticProperty;
-import org.apache.streampipes.model.staticproperty.DomainStaticProperty;
-import org.apache.streampipes.model.staticproperty.FileStaticProperty;
-import org.apache.streampipes.model.staticproperty.FreeTextStaticProperty;
-import org.apache.streampipes.model.staticproperty.MappingPropertyNary;
-import org.apache.streampipes.model.staticproperty.MappingPropertyUnary;
-import org.apache.streampipes.model.staticproperty.OneOfStaticProperty;
-import org.apache.streampipes.model.staticproperty.Option;
-import org.apache.streampipes.model.staticproperty.SecretStaticProperty;
-import org.apache.streampipes.model.staticproperty.SelectionStaticProperty;
-import org.apache.streampipes.model.staticproperty.StaticProperty;
-import org.apache.streampipes.model.staticproperty.StaticPropertyAlternative;
-import org.apache.streampipes.model.staticproperty.StaticPropertyAlternatives;
-import org.apache.streampipes.model.staticproperty.StaticPropertyGroup;
-import org.apache.streampipes.model.staticproperty.StaticPropertyType;
-import org.apache.streampipes.model.staticproperty.SupportedProperty;
+import org.apache.streampipes.model.staticproperty.*;
import java.io.IOException;
import java.util.ArrayList;
@@ -104,6 +88,10 @@ public abstract class AbstractParameterExtractor<T extends InvocableStreamPipesE
.getValue());
}
+ public String codeblockValue(String internalName) {
+ return getStaticPropertyByName(internalName,CodeInputStaticProperty.class).getValue();
+ }
+
public String fileContentsAsString(String internalName) throws IOException {
String filename =
getStaticPropertyByName(internalName, FileStaticProperty.class).getLocationPath();
diff --git a/streampipes-vocabulary/src/main/java/org/apache/streampipes/vocabulary/StreamPipes.java b/streampipes-vocabulary/src/main/java/org/apache/streampipes/vocabulary/StreamPipes.java
index 8aad8f9..2beb33a 100644
--- a/streampipes-vocabulary/src/main/java/org/apache/streampipes/vocabulary/StreamPipes.java
+++ b/streampipes-vocabulary/src/main/java/org/apache/streampipes/vocabulary/StreamPipes.java
@@ -385,4 +385,5 @@ public class StreamPipes {
public static final String CODE_INPUT_STATIC_PROPERTY = NS + "CodeInputStaticProperty";
public static final String HAS_LANGUAGE = NS + "hasLanguage";
public static final String HAS_CODE_INPUT = NS + "hasCodeInput";
+ public static final String HAS_CODE_TEMPLATE = NS + "hasCodeTemplate";
}
diff --git a/ui/src/app/editor/components/code/code-editor.directive.ts b/ui/src/app/editor/components/code/code-editor.directive.ts
index a712f50..c239888 100644
--- a/ui/src/app/editor/components/code/code-editor.directive.ts
+++ b/ui/src/app/editor/components/code/code-editor.directive.ts
@@ -37,7 +37,9 @@ export class CodeEditorDirective {
}
link(scope, element, attrs, ngModelCtrl, transclude) {
+
let selectedElement = scope.$eval(attrs.inputStreams);
+ let codeTemplate = attrs.codeTemplate;
scope.editor = CodeMirror(element[0], {
mode: "javascript",
autoRefresh: true,
@@ -65,6 +67,7 @@ export class CodeEditorDirective {
ngModelCtrl.$setViewValue(scope.editor.getValue());
scope.$emit('editor-change')
})
+
}
enableCodeHints(selectedElement: any) {
diff --git a/ui/src/app/editor/components/code/code.controller.ts b/ui/src/app/editor/components/code/code.controller.ts
index 7507c20..19f014e 100644
--- a/ui/src/app/editor/components/code/code.controller.ts
+++ b/ui/src/app/editor/components/code/code.controller.ts
@@ -25,7 +25,20 @@ export class CodeInputController {
showEditor: boolean = false;
+ $onInit() {
+ if (this.staticProperty.properties.value == undefined ||
+ this.staticProperty.properties.value == "") {
+ this.resetCode();
+ }
+ }
+
$postLink() {
this.showEditor = true;
}
+
+ resetCode() {
+ this.staticProperty.properties.value = this.staticProperty.properties.codeTemplate;
+ };
+
+
}
\ No newline at end of file
diff --git a/ui/src/app/editor/components/code/code.tmpl.html b/ui/src/app/editor/components/code/code.tmpl.html
index fe48ceb..2d21712 100644
--- a/ui/src/app/editor/components/code/code.tmpl.html
+++ b/ui/src/app/editor/components/code/code.tmpl.html
@@ -15,7 +15,12 @@
~ limitations under the License.
~
-->
-<div layout="row" flex="100">
+
+<div flex="100" layout="row" layout-align="start center">
+ <sp-button sp-button-blue sp-button-small-padding ng-click="ctrl.resetCode()">Reset template
+ </sp-button>
+</div>
+<div layout="row" layout-align="end center" flex="100">
<div layout="column" layout-align="start center">
<i class="material-icons">info</i>
</div>
@@ -23,6 +28,6 @@
</div>
<code-editor ng-model="ctrl.staticProperty.properties.value"
- ng-if="ctrl.showEditor"
+ ng-if="ctrl.showEditor" code-template="{{ctrl.staticProperty.properties.codeTemplate}}"
input-streams="{{ctrl.selectedElement}}">
</code-editor>
\ No newline at end of file