diff options
author | Chinthakayala, Sheshashailavas (sc2914) <sc2914@us.att.com> | 2017-08-28 05:25:46 -0900 |
---|---|---|
committer | Chinthakayala, Sheshashailavas (sc2914) <sc2914@att.com> | 2017-08-28 05:36:52 -0900 |
commit | d1569975bb18f4359fac18aa98f55b69c248a3ad (patch) | |
tree | c8681eeac12dca8673ccf841705daac88bf01ca6 /dgbuilder/nodes/dge/dgelogic | |
parent | a016ea661ff5767a3539734c4c07ef974a6e4614 (diff) |
[CCSDK-28] populated the seed code for dgbuilder
updated the code to point to the new package name for sli
Change-Id: I3b5a1d05dc5193664fd4a667afdcd0b2354010a4
Issue-ID:{CCSDK-28}
Signed-off-by: Chinthakayala, Sheshashailavas (sc2914) <sc2914@att.com>
Signed-off-by: Chinthakayala, Sheshashailavas (sc2914) <sc2914@att.com>
Diffstat (limited to 'dgbuilder/nodes/dge/dgelogic')
36 files changed, 4012 insertions, 0 deletions
diff --git a/dgbuilder/nodes/dge/dgelogic/block.html b/dgbuilder/nodes/dge/dgelogic/block.html new file mode 100644 index 00000000..fadf8a8c --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/block.html @@ -0,0 +1,223 @@ +<!-- + Copyright 2013 IBM Corp. + + Licensed 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. +--> +<script type="text/x-red" data-template-name="block"> + <div class="form-row"> + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> + <input type="text" id="node-input-name" placeholder="Name"> + </div> + <div class="form-row"> + <div> + <table border='0' width='100%' style='cellspacing:5px;'> + <tr> + <td> + <input type="checkbox" id="node-input-atomic-chkBox" onclick=updateXml()> + <input type="hidden" id="node-input-atomic" value=""> + </td> + <td> + <span style="font-size:.8em;">Atomic</span> + </td> + </tr> + </table> + </div> + <label for="node-input-xml"><i class="fa fa-wrench"></i> Node XML</label> + <input type="hidden" id="node-input-xml" autofocus="autofocus"> + <div style="height: 450px;" class="node-text-editor" id="node-input-xml-editor" onkeyup="resetStatus()" ></div> + </div> + <div class="form-row"> + <a href="#" class="btn btn-mini" id="node-input-validate" style="margin-top: 4px;"><b>Validate XML</b></a> + <a href="#" class="btn btn-mini" id="node-input-show-sli-values" style="margin-top: 4px;"><b>Show Values</b></a> + <input type="hidden" id="node-input-comments"> + <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a> + <div id="node-validate-result" class="form-tips" style="float:right;font-size:10px"></div> + </div> + <div class="form-tips">See the Info tab for help using this node.</div> +</script> + +<script type="text/x-red" data-help-name="block"> + <p>A block node.</p> + <p>Name can be anything.</p> + <p>Do not include closing tag - it will be automatically generated.</p> + + <div class="section"> +<h3><a name="Flow_Control"></a>Flow Control</h3> +<div class="section"> +<h4><a name="Block_node"></a>Block node</h4> +<div class="section"> +<h5><a name="Description"></a>Description</h5> +<p>A <b>block</b> node is used to executes a set of nodes. </p></div> +<div class="section"> +<h5><a name="Attributes"></a>Attributes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>atomic</b></td> +<td align="left">if <i>true</i>, then if a node returns failure, subsequent nodes will not be executed and nodes already executed will be backed out.</td></tr></table></div> +<div class="section"> +<h5><a name="Parameters"></a>Parameters</h5> +<p>None</p></div> +<div class="section"> +<h5><a name="Outcomes"></a>Outcomes</h5> +<p>None</p></div> +<div class="section"> +<h5><a name="Example"></a>Example</h5> +<div class="source"> +<pre><block> + <record plugin="org.onap.ccsdk.sli.core.sli.recording.FileRecorder"> + <parameter name="file" value="/tmp/sample_r1.log" /> + <parameter name="field1" value="__TIMESTAMP__"/> + <parameter name="field2" value="RESERVED"/> + <parameter name="field3" value="$asePort.uni_circuit_id"/> + </record> + <return status="success"> + <parameter name="uni-circuit-id" value="$asePort.uni_circuit_id" /> + </return> +</block></pre></div></div></div> + +</script> + + +<script type="text/javascript"> + var blockXmlEditor ; + RED.nodes.registerType('block',{ + color:"#fdd0a2", + category: 'DGElogic', + defaults: { + name: {value:"block"}, + xml: {value:"<block>\n"}, + atomic: {value:"false"}, + comments:{value:""}, + outputs: {value:1} + }, + inputs:1, + outputs:1, + icon: "arrow-in.png", + label: function() { + return this.name; + }, + oneditprepare: function() { + $( "#node-input-outputs" ).spinner({ + min:1 + }); + + var comments = $( "#node-input-comments").val(); + if(comments != null){ + comments = comments.trim(); + if(comments != ''){ + $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); + } + } + + var atomic = $( "#node-input-atomic").val(); + if(atomic == "true"){ + $('#node-input-atomic-chkBox').prop('checked', true); + }else{ + $('#node-input-atomic-chkBox').prop('checked', false); + } + + + function functionDialogResize(ev,ui) { + $("#node-input-xml-editor").css("height",(ui.size.height-275)+"px"); + }; + + $( "#dialog" ).dialog( "option", "width", 1200 ); + $( "#dialog" ).dialog( "option", "height", 750 ); + $( "#dialog" ).on("dialogresize", functionDialogResize); + $( "#dialog" ).one("dialogopen", function(ev) { + var size = $( "#dialog" ).dialog('option','sizeCache-function'); + if (size) { + functionDialogResize(null,{size:size}); + } + }); + + /* close dialog when ESC is pressed and released */ + $( "#dialog" ).keyup(function(event){ + if(event.which == 27 ) { + $("#node-dialog-cancel").click(); + } + }); + + $( "#dialog" ).one("dialogclose", function(ev,ui) { + var height = $( "#dialog" ).dialog('option','height'); + $( "#dialog" ).off("dialogresize",functionDialogResize); + }); + var that = this; + require(["orion/editor/edit"], function(edit) { + that.editor = edit({ + parent:document.getElementById('node-input-xml-editor'), + lang:"html", + contents: $("#node-input-xml").val() + }); + blockXmlEditor=that.editor; + RED.library.create({ + url:"functions", // where to get the data from + type:"function", // the type of object the library is for + editor:that.editor, // the field name the main text body goes to + fields:['name','outputs'] + }); + $("#node-input-name").focus(); + $("#node-input-validate").click(function(){ + //console.log("validate clicked."); + //console.dir(that.editor); + //console.log("getText:" + that.editor.getText()); + var val = that.editor.getText(); + validateXML(val); + }); + $("#node-input-show-sli-values").click(function(){ + //console.log("SLIValues clicked."); + showValuesBox(that.editor,sliValuesObj); + }); + + }); + //for click of add comments button + $("#node-input-btnComments").click(function(e){ + showCommentsBox(); + }); + }, + oneditsave: function() { + + $("#node-input-xml").val(this.editor.getText()); + var resp=validateXML(this.editor.getText()); + if(resp){ + this.status = {fill:"green",shape:"dot",text:"OK"}; + }else{ + this.status = {fill:"red",shape:"dot",text:"ERROR"}; + } + delete this.editor; + delete blockXmlEditor; + } + }); +function updateXml(){ + if($("#node-input-atomic-chkBox").is(':checked')){ + $("#node-input-name").val("block : atomic"); + $("#node-input-atomic").val("true"); + //alert($("#node-input-xml-editor div.textview div.textviewContent").text()); + var xmlStr = blockXmlEditor.getText(); + var re = new RegExp("<block[^<]+"); + xmlStr=xmlStr.replace(re,"<block atomic='true'>"); + //$("#node-input-xml-editor div.textview div.textviewContent").text(xmlStr); + blockXmlEditor.setText(xmlStr); + //console.log("block xmlStr:" + xmlStr); + }else{ + $("#node-input-name").val("block"); + $("#node-input-atomic").val("false"); + var xmlStr = blockXmlEditor.getText(); + var re = new RegExp("<block[^<]+"); + xmlStr=xmlStr.replace(re,"<block>"); + blockXmlEditor.setText(xmlStr); + //$("#node-input-xml-editor div.textview div.textviewContent").text(xmlStr); + //console.log("block xmlStr:" + xmlStr); + } +} +</script> diff --git a/dgbuilder/nodes/dge/dgelogic/block.js b/dgbuilder/nodes/dge/dgelogic/block.js new file mode 100644 index 00000000..4414d86d --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/block.js @@ -0,0 +1,31 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed 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. + **/ + +module.exports = function(RED) { + "use strict"; + var util = require("util"); + var vm = require("vm"); + + function block(n) { + RED.nodes.createNode(this,n); + this.name = n.name; + this.xml = n.xml; + this.topic = n.topic; + } + + RED.nodes.registerType("block",block); + // RED.library.register("block"); +} diff --git a/dgbuilder/nodes/dge/dgelogic/breakNode.html b/dgbuilder/nodes/dge/dgelogic/breakNode.html new file mode 100644 index 00000000..e3edef9d --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/breakNode.html @@ -0,0 +1,161 @@ +<!-- + Copyright 2013 IBM Corp. + + Licensed 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. +--> + +<script type="text/x-red" data-template-name="break"> + <div class="form-row"> + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> + <input type="text" id="node-input-name" placeholder="Name"> + </div> + <div class="form-row"> + <label for="node-input-xml"><i class="fa fa-wrench"></i> Node XML</label> + <input type="hidden" id="node-input-xml" autofocus="autofocus"> + <div style="height: 450px;" class="node-text-editor" id="node-input-xml-editor" onkeyup="resetStatus()" ></div> + </div> + <div class="form-row"> + <a href="#" class="btn btn-mini" id="node-input-validate" style="margin-top: 4px;"><b>Validate XML</b></a> + <a href="#" class="btn btn-mini" id="node-input-show-sli-values" style="margin-top: 4px;"><b>Show Values</b></a> + <input type="hidden" id="node-input-comments"> + <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a> + <div id="node-validate-result" class="form-tips" style="float:right;font-size:10px"></div> + </div> + <div class="form-tips">See the Info tab for help using this node.</div> +</script> + +<script type="text/x-red" data-help-name="break"> + <p>A break node.</p> + <p>First line of XML must contain opening tag.</p> + <p>Do not include closing tag - it will be automatically generated.</p> + +<div class="section"> +<h4><a name="Break_node"></a>Break node</h4> +<div class="section"> +<h5><a name="Description"></a>Description</h5> +<p>A <b>break</b> node works like a break in any programming language. So you can break out of a for loop.</p></div> +<div class="section"> +<h5><a name="Attributes"></a>Attributes</h5> +<p>Not applicable. The <b>break</b> node does not have attributes.</p></div> +<div class="section"> +<h5><a name="Parameters"></a>Parameters</h5> +<p>Not applicable. The <b>break</b> node does not have attributes.</p> </div> +<div class="section"> +<h5><a name="Outcomes"></a>Outcomes</h5> +<p>Not applicable. The <b>break</b> node has no outcomes.</p></div> +<div class="section"> +<h5><a name="Example"></a>Example</h5> +<div class="source"> +<pre><break> +</pre></div></div></div> + +</script> + + +<script type="text/javascript"> + RED.nodes.registerType('break',{ + color:"#fdd0a2", + category: 'DGElogic', + defaults: { + name: {value:"break"}, + xml: {value:"<break>\n"}, + comments:{value:""} + }, + inputs:1, + icon: "arrow-in.png", + label: function() { + return this.name; + }, + oneditprepare: function() { + $( "#node-input-outputs" ).spinner({ + min:1 + }); + + + var comments = $( "#node-input-comments").val(); + if(comments != null){ + comments = comments.trim(); + if(comments != ''){ + $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); + } + } + + function functionDialogResize(ev,ui) { + $("#node-input-xml-editor").css("height",(ui.size.height-275)+"px"); + }; + + $( "#dialog" ).dialog( "option", "width", 1200 ); + $( "#dialog" ).dialog( "option", "height", 750 ); + $( "#dialog" ).on("dialogresize", functionDialogResize); + $( "#dialog" ).one("dialogopen", function(ev) { + var size = $( "#dialog" ).dialog('option','sizeCache-function'); + if (size) { + functionDialogResize(null,{size:size}); + } + }); + + /* close dialog when ESC is pressed and released */ + $( "#dialog" ).keyup(function(event){ + if(event.which == 27 ) { + $("#node-dialog-cancel").click(); + } + }); + + $( "#dialog" ).one("dialogclose", function(ev,ui) { + var height = $( "#dialog" ).dialog('option','height'); + $( "#dialog" ).off("dialogresize",functionDialogResize); + }); + var that = this; + require(["orion/editor/edit"], function(edit) { + that.editor = edit({ + parent:document.getElementById('node-input-xml-editor'), + lang:"html", + contents: $("#node-input-xml").val() + }); + RED.library.create({ + url:"functions", // where to get the data from + type:"function", // the type of object the library is for + editor:that.editor, // the field name the main text body goes to + fields:['name','outputs'] + }); + $("#node-input-name").focus(); + $("#node-input-validate").click(function(){ + console.log("validate clicked."); + //console.dir(that.editor); + //console.log("getText:" + that.editor.getText()); + var val = that.editor.getText(); + validateXML(val); + }); + $("#node-input-show-sli-values").click(function(){ + console.log("SLIValues clicked."); + showValuesBox(that.editor,sliValuesObj); + }); + + }); + //for click of add comments button + $("#node-input-btnComments").click(function(e){ + showCommentsBox(); + }); + }, + oneditsave: function() { + $("#node-input-xml").val(this.editor.getText()); + var resp=validateXML(this.editor.getText()); + if(resp){ + this.status = {fill:"green",shape:"dot",text:"OK"}; + }else{ + this.status = {fill:"red",shape:"dot",text:"ERROR"}; + } + delete this.editor; + } + }); +</script> diff --git a/dgbuilder/nodes/dge/dgelogic/breakNode.js b/dgbuilder/nodes/dge/dgelogic/breakNode.js new file mode 100644 index 00000000..9b0b1b00 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/breakNode.js @@ -0,0 +1,31 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed 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. + **/ + +module.exports = function(RED) { + "use strict"; + var util = require("util"); + var vm = require("vm"); + + function breakNode(n) { + RED.nodes.createNode(this,n); + this.name = n.name; + this.xml = n.xml; + this.topic = n.topic; + } + + RED.nodes.registerType("break",breakNode); + // RED.library.register("block"); +} diff --git a/dgbuilder/nodes/dge/dgelogic/call.html b/dgbuilder/nodes/dge/dgelogic/call.html new file mode 100644 index 00000000..0e49e26c --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/call.html @@ -0,0 +1,183 @@ +<!-- + Copyright 2013 IBM Corp. + + Licensed 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. +--> + +<script type="text/x-red" data-template-name="call"> + <div class="form-row"> + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> + <input type="text" id="node-input-name" placeholder="Name"> + </div> + <div class="form-row"> + <label for="node-input-xml"><i class="fa fa-wrench"></i> Node XML</label> + <input type="hidden" id="node-input-xml" autofocus="autofocus"> + <div style="height: 450px;" class="node-text-editor" id="node-input-xml-editor" onkeyup="resetStatus()" ></div> + </div> + <div class="form-row"> + <a href="#" class="btn btn-mini" id="node-input-validate" style="margin-top: 4px;"><b>Validate XML</b></a> + <a href="#" class="btn btn-mini" id="node-input-show-sli-values" style="margin-top: 4px;"><b>Show Values</b></a> + <input type="hidden" id="node-input-comments"> + <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a> + <div id="node-validate-result" class="form-tips" style="float:right;font-size:10px"></div> + </div> + <div class="form-tips">See the Info tab for help using this node.</div> +</script> + +<script type="text/x-red" data-help-name="call"> + <p>A call node.</p> + <p>Name can be anything.</p> + <p>Do not include closing tag - it will be automatically generated.</p> + +<div class="section"> +<h4><a name="Call_node"></a>Call node</h4> +<div class="section"> +<h5><a name="Description"></a>Description</h5> +<p>A <b>call</b> node is used to call another graph</p></div> +<div class="section"> +<h5><a name="Attributes"></a>Attributes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>module</b></td> +<td align="left">Module of directed graph to call. If unset, defaults to that of calling graph</td></tr> +<tr class="b"> +<td align="center"><b>rpc</b></td> +<td align="left">rpc of directed graph to call.</td></tr> +<tr class="a"> +<td align="center"><b>version</b></td> +<td align="left">version of graph to call, If unset, uses active version.</td></tr> +<tr class="b"> +<td align="center"><b>mode</b></td> +<td align="left">mode (sync/async) of graph to call. If unset, defaults to that of calling graph.</td></tr></table></div> +<div class="section"> +<h5><a name="Parameters"></a>Parameters</h5> +<p>Not applicable</p></div> +<div class="section"> +<h5><a name="Outcomes"></a>Outcomes</h5> +<table border="1" class="table table-striped"><caption> .</caption> +<tr class="a"> +<td align="center"><b>success</b></td> +<td align="left">Sub graph returned success</td></tr> +<tr class="b"> +<td align="center"><b>not-found</b></td> +<td align="left">Graph not found</td></tr> +<tr class="a"> +<td align="center"><b>failure</b></td> +<td align="left">Subgraph returned success</td></tr></table></div> +<div class="section"> +<h5><a name="Example"></a>Example</h5> +<div class="source"> +<pre><call rpc="svc-topology-reserve" mode="sync" /></pre></div></div></div> + +</script> + + +<script type="text/javascript"> + RED.nodes.registerType('call',{ + color:"#fdd0a2", + category: 'DGElogic', + defaults: { + name: {value:"call"}, + xml: {value:"<call module='' rpc='' mode='sync' >\n"}, + comments:{value:""}, + outputs: {value:1} + }, + inputs:1, + outputs:1, + icon: "arrow-in.png", + label: function() { + return this.name; + }, + oneditprepare: function() { + $( "#node-input-outputs" ).spinner({ + min:1 + }); + + + var comments = $( "#node-input-comments").val(); + if(comments != null){ + comments = comments.trim(); + if(comments != ''){ + $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); + } + } + + function functionDialogResize(ev,ui) { + $("#node-input-xml-editor").css("height",(ui.size.height-275)+"px"); + }; + + $( "#dialog" ).dialog( "option", "width", 1200 ); + $( "#dialog" ).dialog( "option", "height", 750 ); + $( "#dialog" ).on("dialogresize", functionDialogResize); + $( "#dialog" ).one("dialogopen", function(ev) { + var size = $( "#dialog" ).dialog('option','sizeCache-function'); + if (size) { + functionDialogResize(null,{size:size}); + } + }); + + /* close dialog when ESC is pressed and released */ + $( "#dialog" ).keyup(function(event){ + if(event.which == 27 ) { + $("#node-dialog-cancel").click(); + } + }); + + $( "#dialog" ).one("dialogclose", function(ev,ui) { + var height = $( "#dialog" ).dialog('option','height'); + $( "#dialog" ).off("dialogresize",functionDialogResize); + }); + var that = this; + require(["orion/editor/edit"], function(edit) { + that.editor = edit({ + parent:document.getElementById('node-input-xml-editor'), + lang:"html", + contents: $("#node-input-xml").val() + }); + RED.library.create({ + url:"functions", // where to get the data from + type:"function", // the type of object the library is for + editor:that.editor, // the field name the main text body goes to + fields:['name','outputs'] + }); + $("#node-input-name").focus(); + $("#node-input-validate").click(function(){ + console.log("validate clicked."); + //console.dir(that.editor); + //console.log("getText:" + that.editor.getText()); + var val = that.editor.getText(); + validateXML(val); + }); + $("#node-input-show-sli-values").click(function(){ + //console.log("show Values clicked."); + showValuesBox(that.editor,rpcValues); + }); + + }); + //for click of add comments button + $("#node-input-btnComments").click(function(e){ + showCommentsBox(); + }); + }, + oneditsave: function() { + $("#node-input-xml").val(this.editor.getText()); + var resp=validateXML(this.editor.getText()); + if(resp){ + this.status = {fill:"green",shape:"dot",text:"OK"}; + }else{ + this.status = {fill:"red",shape:"dot",text:"ERROR"}; + } + delete this.editor; + } + }); +</script> diff --git a/dgbuilder/nodes/dge/dgelogic/call.js b/dgbuilder/nodes/dge/dgelogic/call.js new file mode 100644 index 00000000..3570e3db --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/call.js @@ -0,0 +1,31 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed 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. + **/ + +module.exports = function(RED) { + "use strict"; + var util = require("util"); + var vm = require("vm"); + + function call(n) { + RED.nodes.createNode(this,n); + this.name = n.name; + this.xml = n.xml; + this.topic = n.topic; + } + + RED.nodes.registerType("call",call); + // RED.library.register("call"); +} diff --git a/dgbuilder/nodes/dge/dgelogic/configure.html b/dgbuilder/nodes/dge/dgelogic/configure.html new file mode 100644 index 00000000..7503b1f1 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/configure.html @@ -0,0 +1,227 @@ +<!-- + Copyright 2013 IBM Corp. + + Licensed 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. +--> + +<script type="text/x-red" data-template-name="configure"> + <div class="form-row"> + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> + <input type="text" id="node-input-name" placeholder="Name"> + </div> + <div class="form-row"> + <label for="node-input-xml"><i class="fa fa-wrench"></i> Node XML</label> + <input type="hidden" id="node-input-xml" autofocus="autofocus"> + <div style="height: 450px;" class="node-text-editor" id="node-input-xml-editor" onkeyup="resetStatus()" ></div> + </div> + <div class="form-row"> + <a href="#" class="btn btn-mini" id="node-input-validate" style="margin-top: 4px;"><b>Validate XML</b></a> + <a href="#" class="btn btn-mini" id="node-input-show-sli-values" style="margin-top: 4px;"><b>Show Values</b></a> + <input type="hidden" id="node-input-comments"> + <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a> + <div id="node-validate-result" class="form-tips" style="float:right;font-size:10px"></div> + </div> + <div class="form-tips">See the Info tab for help using this node.</div> +</script> + +<script type="text/x-red" data-help-name="configure"> + <p>A configure node.</p> + <p>First line of XML must contain opening tag.</p> + <p>Do not include closing tag - it will be automatically generated.</p> + + + <div class="section"> +<h3><a name="Device_Management"></a>Device Management</h3> +<div class="section"> +<h4><a name="Configure_node"></a>Configure node</h4> +<div class="section"> +<h5><a name="Description"></a>Description</h5> +<p>A <b>configure</b> node is used to configure a device.</p></div> +<div class="section"> +<h5><a name="Attributes"></a>Attributes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>plugin</b></td> +<td align="left">Fully qualified Java class of resource adaptor to be used</td></tr> +<tr class="b"> +<td align="center"><b>activate</b></td> +<td align="left">Activate device/interface, for devices that support a separate activation step.</td></tr> +<tr class="a"> +<td align="center"><b>key</b></td> +<td align="left">SQL-like string specifying criteria for item to configure</td></tr></table></div> +<div class="section"> +<h5><a name="Parameters"></a>Parameters</h5> +<p>Specific to device adaptor.</p></div> +<div class="section"> +<h5><a name="Outcomes"></a>Outcomes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>success</b></td> +<td align="left">Device successfully configured</td></tr> +<tr class="b"> +<td align="center"><b>not-found</b></td> +<td align="left">Element to be configured does not exist.</td></tr> +<tr class="a"> +<td align="center"><b>not-ready</b></td> +<td align="left">Element is not in a state where it can be configured/activated</td></tr> +<tr class="b"> +<td align="center"><b>already-active</b></td> +<td align="left">Attempt to activate element that is already active</td></tr> +<tr class="a"> +<td align="center"><b>failure</b></td> +<td align="left">Configure failed for some other reason</td></tr></table></div> +<div class="section"> +<h5><a name="Example"></a>Example</h5> +<div class="source"> +<pre><configure adaptor="org.onap.ccsdk.sli.adaptor.emt.EmtAdaptor" + key="$uni-circuit-id" activate="true"> + <parameter name="circuit.id" value="$uni-circuit-id" /> + <parameter name="subscriber.name" value="$subscriber-name" /> + <parameter name="emt.clli" value="$edge-device-clli" /> + <parameter name="port.tagging" value="$port-tagging" /> + <parameter name="port.mediaSpeed" value="$media-speed" /> + <parameter name="location.state" value="$uni-location-state" /> + <parameter name="location.city" value="$uni-location-city" /> + <parameter name="cosCategory" value="$cos-category" /> + <parameter name="gosProfile" value="$gos-profile" /> + <parameter name="lldp" value="$asePort.resource-lldp" /> + <parameter name="mtu" value="$asePort.resource-mtu" /> + <outcome value="success"> + <block> + <record plugin="org.onap.ccsdk.sli.recording.FileRecorder"> + <parameter name="file" value="/tmp/sampler1.log" /> + <parameter name="field1" value="__TIMESTAMP__"/> + <parameter name="field2" value="ACTIVE"/> + <parameter name="field3" value="$uni-circuit-id"/> + </record> + <return status="success"> + <parameter name="edge-device-clli" value="$asePort.resource-emt-clli" /> + </return> + </block> + </outcome> + <outcome value="already-active"> + <return status="failure"> + <parameter name="error-code" value="1590" /> + <parameter name="error-message" value="Port already active" /> + </return> + </outcome> + <outcome value="Other"> + <return status="failure"> + <parameter name="error-code" value="1542" /> + <parameter name="error-message" value="Activation failure" /> + </return> + </outcome> +</configure></pre></div></div></div></div> + +</script> + + +<script type="text/javascript"> + RED.nodes.registerType('configure',{ + color:"#fdd0a2", + category: 'DGElogic', + defaults: { + name: {value:"configure"}, + xml: {value:"<configure adaptor='' key='' activate='' >\n"}, + comments:{value:""}, + outputs: {value:1} + }, + inputs:1, + outputs:1, + icon: "arrow-in.png", + label: function() { + return this.name; + }, + oneditprepare: function() { + $( "#node-input-outputs" ).spinner({ + min:1 + }); + + var comments = $( "#node-input-comments").val(); + if(comments != null){ + comments = comments.trim(); + if(comments != ''){ + $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); + } + } + + + function functionDialogResize(ev,ui) { + $("#node-input-xml-editor").css("height",(ui.size.height-275)+"px"); + }; + + $( "#dialog" ).dialog( "option", "width", 1200 ); + $( "#dialog" ).dialog( "option", "height", 750 ); + $( "#dialog" ).on("dialogresize", functionDialogResize); + $( "#dialog" ).one("dialogopen", function(ev) { + var size = $( "#dialog" ).dialog('option','sizeCache-function'); + if (size) { + functionDialogResize(null,{size:size}); + } + }); + + /* close dialog when ESC is pressed and released */ + $( "#dialog" ).keyup(function(event){ + if(event.which == 27 ) { + $("#node-dialog-cancel").click(); + } + }); + + $( "#dialog" ).one("dialogclose", function(ev,ui) { + var height = $( "#dialog" ).dialog('option','height'); + $( "#dialog" ).off("dialogresize",functionDialogResize); + }); + var that = this; + require(["orion/editor/edit"], function(edit) { + that.editor = edit({ + parent:document.getElementById('node-input-xml-editor'), + lang:"html", + contents: $("#node-input-xml").val() + }); + RED.library.create({ + url:"functions", // where to get the data from + type:"function", // the type of object the library is for + editor:that.editor, // the field name the main text body goes to + fields:['name','outputs'] + }); + $("#node-input-name").focus(); + $("#node-input-validate").click(function(){ + console.log("validate clicked."); + //console.dir(that.editor); + //console.log("getText:" + that.editor.getText()); + var val = that.editor.getText(); + validateXML(val); + }); + $("#node-input-show-sli-values").click(function(){ + console.log("SLIValues clicked."); + showValuesBox(that.editor,sliValuesObj); + }); + + }); + //for click of add comments button + $("#node-input-btnComments").click(function(e){ + showCommentsBox(); + }); + }, + oneditsave: function() { + $("#node-input-xml").val(this.editor.getText()); + var resp=validateXML(this.editor.getText()); + if(resp){ + this.status = {fill:"green",shape:"dot",text:"OK"}; + }else{ + this.status = {fill:"red",shape:"dot",text:"ERROR"}; + } + delete this.editor; + } + }); +</script> diff --git a/dgbuilder/nodes/dge/dgelogic/configure.js b/dgbuilder/nodes/dge/dgelogic/configure.js new file mode 100644 index 00000000..7345750d --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/configure.js @@ -0,0 +1,31 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed 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. + **/ + +module.exports = function(RED) { + "use strict"; + var util = require("util"); + var vm = require("vm"); + + function configure(n) { + RED.nodes.createNode(this,n); + this.name = n.name; + this.xml = n.xml; + this.topic = n.topic; + } + + RED.nodes.registerType("configure",configure); + // RED.library.register("configure"); +} diff --git a/dgbuilder/nodes/dge/dgelogic/delete.html b/dgbuilder/nodes/dge/dgelogic/delete.html new file mode 100644 index 00000000..b4c7f52f --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/delete.html @@ -0,0 +1,187 @@ +<!-- + Copyright 2013 IBM Corp. + + Licensed 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. +--> + +<script type="text/x-red" data-template-name="delete"> + <div class="form-row"> + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> + <input type="text" id="node-input-name" placeholder="Name"> + </div> + <div class="form-row"> + <label for="node-input-xml"><i class="fa fa-wrench"></i> Node XML</label> + <input type="hidden" id="node-input-xml" autofocus="autofocus"> + <div style="height: 450px;" class="node-text-editor" id="node-input-xml-editor" onkeyup="resetStatus()" ></div> + </div> + <div class="form-row"> + <a href="#" class="btn btn-mini" id="node-input-validate" style="margin-top: 4px;"><b>Validate XML</b></a> + <a href="#" class="btn btn-mini" id="node-input-show-sli-values" style="margin-top: 4px;"><b>Show Values</b></a> + <input type="hidden" id="node-input-comments"> + <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a> + <div id="node-validate-result" class="form-tips" style="float:right;font-size:10px"></div> + </div> + <div class="form-tips">See the Info tab for help using this node.</div> +</script> + +<script type="text/x-red" data-help-name="delete"> + <p>A delete node.</p> + <p>Name can be anything.</p> + <p>Do not include closing tag - it will be automatically generated.</p> + +<div class="section"> +<h4><a name="Delete_node"></a>Delete node</h4> +<div class="section"> +<h5><a name="Description"></a>Description</h5> +<p>A <b>delete</b> node is used to delete a resource from the local resource inventory.</p></div> +<div class="section"> +<h5><a name="Attributes"></a>Attributes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>plugin</b></td> +<td align="left">Fully qualified Java class of resource adaptor to be used</td></tr> +<tr class="b"> +<td align="center"><b>resource</b></td> +<td align="left">Type of resource to delete</td></tr> +<tr class="a"> +<td align="center"><b>key</b></td> +<td align="left">SQL-like string specifying key to delete</td></tr></table></div> +<div class="section"> +<h5><a name="Parameters"></a>Parameters</h5> +<p>None</p></div> +<div class="section"> +<h5><a name="Outcomes"></a>Outcomes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>success</b></td> +<td align="left">Resource specified deleted successfully.</td></tr> +<tr class="b"> +<td align="center"><i>failure</i>></td> +<td align="left">Resource specified was not deleted</td></tr></table></div> +<div class="section"> +<h5><a name="Example"></a>Example</h5> +<div class="source"> +<pre><delete plugin="org.onap.ccsdk.sli.resource.samplesvc.SampleServiceResource" + resource="ase-port" + key="uni_circuit_id == $uni-circuit-id"> + <outcome value="true"> + <return status="success"/> + </outcome> + <outcome value="false"> + <return status="failure"/> + </outcome> +</delete></pre></div></div></div> + + +</script> + + +<script type="text/javascript"> + RED.nodes.registerType('delete',{ + color:"#fdd0a2", + category: 'DGElogic', + defaults: { + name: {value:"delete"}, + xml: {value:"<delete plugin='' resource='' key=''>\n"}, + comments:{value:""}, + outputs: {value:1} + }, + inputs:1, + outputs:1, + icon: "arrow-in.png", + label: function() { + return this.name; + }, + oneditprepare: function() { + $( "#node-input-outputs" ).spinner({ + min:1 + }); + + + var comments = $( "#node-input-comments").val(); + if(comments != null){ + comments = comments.trim(); + if(comments != ''){ + $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); + } + } + + function functionDialogResize(ev,ui) { + $("#node-input-xml-editor").css("height",(ui.size.height-275)+"px"); + }; + + $( "#dialog" ).dialog( "option", "width", 1200 ); + $( "#dialog" ).dialog( "option", "height", 750 ); + $( "#dialog" ).on("dialogresize", functionDialogResize); + $( "#dialog" ).one("dialogopen", function(ev) { + var size = $( "#dialog" ).dialog('option','sizeCache-function'); + if (size) { + functionDialogResize(null,{size:size}); + } + }); + + /* close dialog when ESC is pressed and released */ + $( "#dialog" ).keyup(function(event){ + if(event.which == 27 ) { + $("#node-dialog-cancel").click(); + } + }); + + $( "#dialog" ).one("dialogclose", function(ev,ui) { + var height = $( "#dialog" ).dialog('option','height'); + $( "#dialog" ).off("dialogresize",functionDialogResize); + }); + var that = this; + require(["orion/editor/edit"], function(edit) { + that.editor = edit({ + parent:document.getElementById('node-input-xml-editor'), + lang:"html", + contents: $("#node-input-xml").val() + }); + RED.library.create({ + url:"functions", // where to get the data from + type:"function", // the type of object the library is for + editor:that.editor, // the field name the main text body goes to + fields:['name','outputs'] + }); + $("#node-input-name").focus(); + $("#node-input-validate").click(function(){ + console.log("validate clicked."); + //console.dir(that.editor); + //console.log("getText:" + that.editor.getText()); + var val = that.editor.getText(); + validateXML(val); + }); + $("#node-input-show-sli-values").click(function(){ + console.log("SLIValues clicked."); + showValuesBox(that.editor,sliValuesObj); + }); + + }); + //for click of add comments button + $("#node-input-btnComments").click(function(e){ + showCommentsBox(); + }); + }, + oneditsave: function() { + $("#node-input-xml").val(this.editor.getText()); + var resp=validateXML(this.editor.getText()); + if(resp){ + this.status = {fill:"green",shape:"dot",text:"OK"}; + }else{ + this.status = {fill:"red",shape:"dot",text:"ERROR"}; + } + delete this.editor; + } + }); +</script> diff --git a/dgbuilder/nodes/dge/dgelogic/delete.js b/dgbuilder/nodes/dge/dgelogic/delete.js new file mode 100644 index 00000000..37731061 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/delete.js @@ -0,0 +1,31 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed 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. + **/ + +module.exports = function(RED) { + "use strict"; + var util = require("util"); + var vm = require("vm"); + + function deleteNode(n) { + RED.nodes.createNode(this,n); + this.name = n.name; + this.xml = n.xml; + this.topic = n.topic; + } + + RED.nodes.registerType("delete",deleteNode); + // RED.library.register("delete"); +} diff --git a/dgbuilder/nodes/dge/dgelogic/execute.html b/dgbuilder/nodes/dge/dgelogic/execute.html new file mode 100644 index 00000000..3d5fc6d7 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/execute.html @@ -0,0 +1,197 @@ +<!-- + Copyright 2013 IBM Corp. + + Licensed 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. +--> + +<script type="text/x-red" data-template-name="execute"> + <div class="form-row"> + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> + <input type="text" id="node-input-name" placeholder="Name"> + </div> + <div class="form-row"> + <label for="node-input-xml"><i class="fa fa-wrench"></i> Node XML</label> + <input type="hidden" id="node-input-xml" autofocus="autofocus"> + <div style="height: 450px;" class="node-text-editor" id="node-input-xml-editor" onkeyup="resetStatus()" ></div> + </div> + <div class="form-row"> + <a href="#" class="btn btn-mini" id="node-input-validate" style="margin-top: 4px;"><b>Validate XML</b></a> + <a href="#" class="btn btn-mini" id="node-input-show-sli-values" style="margin-top: 4px;"><b>Show Values</b></a> + <input type="hidden" id="node-input-comments"> + <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a> + <div id="node-validate-result" class="form-tips" style="float:right;font-size:10px"></div> + </div> + <div class="form-tips">See the Info tab for help using this node.</div> +</script> + +<script type="text/x-red" data-help-name="execute"> + <p>A execute node.</p> + <p>Do not include closing tag - it will be automatically generated.</p> + <div class="section"> +<h3><a name="Java_Plugin_Support"></a>Java Plugin Support</h3> +<div class="section"> +<h4><a name="Execute_node"></a>Execute node</h4> +<div class="section"> +<h5><a name="Description"></a>Description</h5> +<p>An <b>execute</b> node is used to execute Java code supplied as a plugin</p></div> +<div class="section"> +<h5><a name="Attributes"></a>Attributes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>plugin</b></td> +<td align="left">Fully qualified Java class of plugin to be used</td></tr> +<tr class="b"> +<td align="center"><b>method</b></td> +<td align="left">Name of method in the plugin class to execute. Method must return void, and take 2 arguments: a Map (for parameters) and a SvcLogicContext (to allow plugin read/write access to context memory)</td></tr></table></div> +<div class="section"> +<h5><a name="Parameters"></a>Parameters</h5> +<p>Specific to plugin / method</p></div> +<div class="section"> +<h5><a name="Outcomes"></a>Outcomes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>success</b></td> +<td align="left">Device successfully configured</td></tr> +<tr class="b"> +<td align="center"><b>not-found</b></td> +<td align="left">Plugin class could not be loaded</td></tr> +<tr class="a"> +<td align="center"><b>unsupported-method</b></td> +<td align="left">Named method taking (Map, SvcLogicContext) could not be found</td></tr> +<tr class="b"> +<td align="center"><b>failure</b></td> +<td align="left">Configure failed for some other reason</td></tr></table></div> +<div class="section"> +<h5><a name="Example"></a>Example</h5> +<div class="source"> +<pre><execute plugin="org.onap.ccsdk.sli.plugin.HelloWorld" + method="log"> + <parameter name="message" value="Hello, world!" /> + <outcome value="success"> + <return status="success"/> + </outcome> + <outcome value="not-found"> + <return status="failure"> + <parameter name="error-code" value="1590" /> + <parameter name="error-message" value="Could not locate plugin" /> + </return> + </outcome> + <outcome value="Other"> + <return status="failure"> + <parameter name="error-code" value="1542" /> + <parameter name="error-message" value="Internal error" /> + </return> + </outcome> +</execute></pre></div></div></div></div> +</script> + + +<script type="text/javascript"> + RED.nodes.registerType('execute',{ + color:"#fdd0a2", + category: 'DGElogic', + defaults: { + name: {value:"execute"}, + xml: {value:"<execute plugin='' method='' >\n"}, + comments:{value:""}, + outputs: {value:1} + }, + inputs:1, + outputs:1, + icon: "arrow-in.png", + label: function() { + return this.name; + }, + oneditprepare: function() { + $( "#node-input-outputs" ).spinner({ + min:1 + }); + + var comments = $( "#node-input-comments").val(); + if(comments != null){ + comments = comments.trim(); + if(comments != ''){ + $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); + } + } + + + function functionDialogResize(ev,ui) { + $("#node-input-xml-editor").css("height",(ui.size.height-275)+"px"); + }; + + $( "#dialog" ).dialog( "option", "width", 1200 ); + $( "#dialog" ).dialog( "option", "height", 750 ); + $( "#dialog" ).on("dialogresize", functionDialogResize); + $( "#dialog" ).one("dialogopen", function(ev) { + var size = $( "#dialog" ).dialog('option','sizeCache-function'); + if (size) { + functionDialogResize(null,{size:size}); + } + }); + + /* close dialog when ESC is pressed and released */ + $( "#dialog" ).keyup(function(event){ + if(event.which == 27 ) { + $("#node-dialog-cancel").click(); + } + }); + + $( "#dialog" ).one("dialogclose", function(ev,ui) { + var height = $( "#dialog" ).dialog('option','height'); + $( "#dialog" ).off("dialogresize",functionDialogResize); + }); + var that = this; + require(["orion/editor/edit"], function(edit) { + that.editor = edit({ + parent:document.getElementById('node-input-xml-editor'), + lang:"html", + contents: $("#node-input-xml").val() + }); + RED.library.create({ + url:"functions", // where to get the data from + type:"function", // the type of object the library is for + editor:that.editor, // the field name the main text body goes to + fields:['name','outputs'] + }); + $("#node-input-name").focus(); + $("#node-input-validate").click(function(){ + console.log("validate clicked."); + //console.dir(that.editor); + //console.log("getText:" + that.editor.getText()); + var val = that.editor.getText(); + validateXML(val); + }); + $("#node-input-show-sli-values").click(function(){ + console.log("SLIValues clicked."); + showValuesBox(that.editor,sliValuesObj); + }); + + }); + //for click of add comments button + $("#node-input-btnComments").click(function(e){ + showCommentsBox(); + }); + }, + oneditsave: function() { + $("#node-input-xml").val(this.editor.getText()); + var resp=validateXML(this.editor.getText()); + if(resp){ + this.status = {fill:"green",shape:"dot",text:"OK"}; + }else{ + this.status = {fill:"red",shape:"dot",text:"ERROR"}; + } + delete this.editor; + } + }); +</script> diff --git a/dgbuilder/nodes/dge/dgelogic/execute.js b/dgbuilder/nodes/dge/dgelogic/execute.js new file mode 100644 index 00000000..66265f98 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/execute.js @@ -0,0 +1,31 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed 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. + **/ + +module.exports = function(RED) { + "use strict"; + var util = require("util"); + var vm = require("vm"); + + function execute(n) { + RED.nodes.createNode(this,n); + this.name = n.name; + this.xml = n.xml; + this.topic = n.topic; + } + + RED.nodes.registerType("execute",execute); + // RED.library.register("configure"); +} diff --git a/dgbuilder/nodes/dge/dgelogic/exists.html b/dgbuilder/nodes/dge/dgelogic/exists.html new file mode 100644 index 00000000..001e8ca1 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/exists.html @@ -0,0 +1,187 @@ +<!-- + Copyright 2013 IBM Corp. + + Licensed 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. +--> + +<script type="text/x-red" data-template-name="exists"> + <div class="form-row"> + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> + <input type="text" id="node-input-name" placeholder="Name"> + </div> + <div class="form-row"> + <label for="node-input-xml"><i class="fa fa-wrench"></i> Node XML</label> + <input type="hidden" id="node-input-xml" autofocus="autofocus"> + <div style="height: 450px;" class="node-text-editor" id="node-input-xml-editor" onkeyup="resetStatus()" ></div> + </div> + <div class="form-row"> + <a href="#" class="btn btn-mini" id="node-input-validate" style="margin-top: 4px;"><b>Validate XML</b></a> + <a href="#" class="btn btn-mini" id="node-input-show-sli-values" style="margin-top: 4px;"><b>Show Values</b></a> + <input type="hidden" id="node-input-comments"> + <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a> + <div id="node-validate-result" class="form-tips" style="float:right;font-size:10px"></div> + </div> + <div class="form-tips">See the Info tab for help using this node.</div> +</script> + +<script type="text/x-red" data-help-name="exists"> + <p>A exists node.</p> + <p>Name can be anything.</p> + <p>Do not include closing tag - it will be automatically generated.</p> + +<div class="section"> +<h4><a name="Exists_node"></a>Exists node</h4> +<div class="section"> +<h5><a name="Description"></a>Description</h5> +<p>An <b>exists</b> node is used to determine whether a particular instance of a resource exists. For example, this might be used to test whether a particular switch CLLI is provisioned.</p></div> +<div class="section"> +<h5><a name="Attributes"></a>Attributes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>plugin</b></td> +<td align="left">Fully qualified Java class of resource adaptor to be used</td></tr> +<tr class="b"> +<td align="center"><b>resource</b></td> +<td align="left">Type of resource to check</td></tr> +<tr class="a"> +<td align="center"><b>key</b></td> +<td align="left">SQL-like string specifying key to check for</td></tr></table></div> +<div class="section"> +<h5><a name="Parameters"></a>Parameters</h5> +<p>None</p></div> +<div class="section"> +<h5><a name="Outcomes"></a>Outcomes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>true</b></td> +<td align="left">Resource specified exists.</td></tr> +<tr class="b"> +<td align="center"><b>false</b></td> +<td align="left">Resource specified is unknown</td></tr></table></div> +<div class="section"> +<h5><a name="Example"></a>Example</h5> +<div class="source"> +<pre><exists plugin="org.onap.ccsdk.sli.resource.samplesvc.SampleServiceResource" + resource="ase-port" + key="uni_circuit_id == $uni-circuit-id"> + <outcome value="true"> + <return status="success"/> + </outcome> + <outcome value="false"> + <return status="failure"/> + </outcome> +</exists></pre></div></div></div> + +</script> + + +<script type="text/javascript"> + RED.nodes.registerType('exists',{ + color:"#fdd0a2", + category: 'DGElogic', + defaults: { + name: {value:"exists"}, + xml: {value:"<exists plugin='' resource='' key=''>\n"}, + comments:{value:""}, + outputs: {value:1} + }, + inputs:1, + outputs:1, + icon: "arrow-in.png", + label: function() { + return this.name; + }, + oneditprepare: function() { + $( "#node-input-outputs" ).spinner({ + min:1 + }); + + + var comments = $( "#node-input-comments").val(); + if(comments != null){ + comments = comments.trim(); + if(comments != ''){ + $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); + } + } + + function functionDialogResize(ev,ui) { + $("#node-input-xml-editor").css("height",(ui.size.height-275)+"px"); + }; + + $( "#dialog" ).dialog( "option", "width", 1200 ); + $( "#dialog" ).dialog( "option", "height", 750 ); + + $( "#dialog" ).on("dialogresize", functionDialogResize); + $( "#dialog" ).one("dialogopen", function(ev) { + var size = $( "#dialog" ).dialog('option','sizeCache-function'); + if (size) { + functionDialogResize(null,{size:size}); + } + }); + + /* close dialog when ESC is pressed and released */ + $( "#dialog" ).keyup(function(event){ + if(event.which == 27 ) { + $("#node-dialog-cancel").click(); + } + }); + + $( "#dialog" ).one("dialogclose", function(ev,ui) { + var height = $( "#dialog" ).dialog('option','height'); + $( "#dialog" ).off("dialogresize",functionDialogResize); + }); + var that = this; + require(["orion/editor/edit"], function(edit) { + that.editor = edit({ + parent:document.getElementById('node-input-xml-editor'), + lang:"html", + contents: $("#node-input-xml").val() + }); + RED.library.create({ + url:"functions", // where to get the data from + type:"function", // the type of object the library is for + editor:that.editor, // the field name the main text body goes to + fields:['name','outputs'] + }); + $("#node-input-name").focus(); + $("#node-input-validate").click(function(){ + console.log("validate clicked."); + //console.dir(that.editor); + //console.log("getText:" + that.editor.getText()); + var val = that.editor.getText(); + validateXML(val); + }); + $("#node-input-show-sli-values").click(function(){ + console.log("SLIValues clicked."); + showValuesBox(that.editor,sliValuesObj); + }); + + }); + //for click of add comments button + $("#node-input-btnComments").click(function(e){ + showCommentsBox(); + }); + }, + oneditsave: function() { + $("#node-input-xml").val(this.editor.getText()); + var resp=validateXML(this.editor.getText()); + if(resp){ + this.status = {fill:"green",shape:"dot",text:"OK"}; + }else{ + this.status = {fill:"red",shape:"dot",text:"ERROR"}; + } + delete this.editor; + } + }); +</script> diff --git a/dgbuilder/nodes/dge/dgelogic/exists.js b/dgbuilder/nodes/dge/dgelogic/exists.js new file mode 100644 index 00000000..d4482afc --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/exists.js @@ -0,0 +1,31 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed 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. + **/ + +module.exports = function(RED) { + "use strict"; + var util = require("util"); + var vm = require("vm"); + + function exists(n) { + RED.nodes.createNode(this,n); + this.name = n.name; + this.xml = n.xml; + this.topic = n.topic; + } + + RED.nodes.registerType("exists",exists); + // RED.library.register("exists"); +} diff --git a/dgbuilder/nodes/dge/dgelogic/forNode.html b/dgbuilder/nodes/dge/dgelogic/forNode.html new file mode 100644 index 00000000..c7327db4 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/forNode.html @@ -0,0 +1,172 @@ +<!-- + Copyright 2013 IBM Corp. + + Licensed 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. +--> + +<script type="text/x-red" data-template-name="for"> + <div class="form-row"> + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> + <input type="text" id="node-input-name" placeholder="Name"> + </div> + <div class="form-row"> + <label for="node-input-xml"><i class="fa fa-wrench"></i> Node XML</label> + <input type="hidden" id="node-input-xml" autofocus="autofocus"> + <div style="height: 450px;" class="node-text-editor" id="node-input-xml-editor" onkeyup="resetStatus()" ></div> + </div> + <div class="form-row"> + <a href="#" class="btn btn-mini" id="node-input-validate" style="margin-top: 4px;"><b>Validate XML</b></a> + <a href="#" class="btn btn-mini" id="node-input-show-sli-values" style="margin-top: 4px;"><b>Show Values</b></a> + <input type="hidden" id="node-input-comments"> + <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a> + <div id="node-validate-result" class="form-tips" style="float:right;font-size:10px"></div> + </div> + <div class="form-tips">See the Info tab for help using this node.</div> +</script> + +<script type="text/x-red" data-help-name="for"> + <p>A for node.</p> + <p>First line of XML must contain opening tag.</p> + <p>Do not include closing tag - it will be automatically generated.</p> + +<div class="section"> +<h5><a name="Description"></a>Description</h5> +<p>A <b>for</b> node provides a fixed iteration looping mechanism, similar to the Java for loop</p></div> +<div class="section"> +<h5><a name="Attributes"></a>Attributes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>index</b></td> +<td align="left">index variable</td></tr> +<tr class="b"> +<td align="center"><b>start</b></td> +<td align="left">initial value</td></tr> +<tr class="a"> +<td align="center"><b>end</b></td> +<td align="left">maximum value</td></tr></table></div> +<div class="section"> +<h5><a name="Parameters"></a>Parameters</h5> +<p>Not applicable.</p></div> +<div class="section"> +<h5><a name="Outcomes"></a>Outcomes</h5> +<p>Not applicable. The <b>status</b> node has no outcomes.</p></div> +<div class="section"> +<h5><a name="Example"></a>Example</h5> +<div class="source"> +<pre><for index="i" start="0" end="$network.num-segments"> + <set> + <parameter name="$vlanlist" value="$network.segment[i].provider-segmentation-id"/> + </set> +</for></pre></div></div></div> +</script> + + +<script type="text/javascript"> + RED.nodes.registerType('for',{ + color:"#fdd0a2", + category: 'DGElogic', + defaults: { + name: {value:"for"}, + xml: {value:"<for index='' start='' end='' >\n"}, + comments:{value:""}, + outputs: {value:1} + }, + inputs:1, + outputs:1, + icon: "arrow-in.png", + label: function() { + return this.name; + }, + oneditprepare: function() { + $( "#node-input-outputs" ).spinner({ + min:1 + }); + + + var comments = $( "#node-input-comments").val(); + if(comments != null){ + comments = comments.trim(); + if(comments != ''){ + $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); + } + } + + function functionDialogResize(ev,ui) { + $("#node-input-xml-editor").css("height",(ui.size.height-275)+"px"); + }; + + $( "#dialog" ).dialog( "option", "width", 1200 ); + $( "#dialog" ).dialog( "option", "height", 750 ); + $( "#dialog" ).on("dialogresize", functionDialogResize); + $( "#dialog" ).one("dialogopen", function(ev) { + var size = $( "#dialog" ).dialog('option','sizeCache-function'); + if (size) { + functionDialogResize(null,{size:size}); + } + }); + + /* close dialog when ESC is pressed and released */ + $( "#dialog" ).keyup(function(event){ + if(event.which == 27 ) { + $("#node-dialog-cancel").click(); + } + }); + + $( "#dialog" ).one("dialogclose", function(ev,ui) { + var height = $( "#dialog" ).dialog('option','height'); + $( "#dialog" ).off("dialogresize",functionDialogResize); + }); + var that = this; + require(["orion/editor/edit"], function(edit) { + that.editor = edit({ + parent:document.getElementById('node-input-xml-editor'), + lang:"html", + contents: $("#node-input-xml").val() + }); + RED.library.create({ + url:"functions", // where to get the data from + type:"function", // the type of object the library is for + editor:that.editor, // the field name the main text body goes to + fields:['name','outputs'] + }); + $("#node-input-name").focus(); + $("#node-input-validate").click(function(){ + console.log("validate clicked."); + //console.dir(that.editor); + //console.log("getText:" + that.editor.getText()); + var val = that.editor.getText(); + validateXML(val); + }); + $("#node-input-show-sli-values").click(function(){ + console.log("SLIValues clicked."); + showValuesBox(that.editor,sliValuesObj); + }); + + }); + //for click of add comments button + $("#node-input-btnComments").click(function(e){ + showCommentsBox(); + }); + }, + oneditsave: function() { + $("#node-input-xml").val(this.editor.getText()); + var resp=validateXML(this.editor.getText()); + if(resp){ + this.status = {fill:"green",shape:"dot",text:"OK"}; + }else{ + this.status = {fill:"red",shape:"dot",text:"ERROR"}; + } + delete this.editor; + } + }); +</script> diff --git a/dgbuilder/nodes/dge/dgelogic/forNode.js b/dgbuilder/nodes/dge/dgelogic/forNode.js new file mode 100644 index 00000000..567da858 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/forNode.js @@ -0,0 +1,31 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed 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. + **/ + +module.exports = function(RED) { + "use strict"; + var util = require("util"); + var vm = require("vm"); + + function forNode(n) { + RED.nodes.createNode(this,n); + this.name = n.name; + this.xml = n.xml; + this.topic = n.topic; + } + + RED.nodes.registerType("for",forNode); + // RED.library.register("for"); +} diff --git a/dgbuilder/nodes/dge/dgelogic/get-resource.html b/dgbuilder/nodes/dge/dgelogic/get-resource.html new file mode 100644 index 00000000..b3b65581 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/get-resource.html @@ -0,0 +1,192 @@ +<!-- + Copyright 2013 IBM Corp. + + Licensed 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. +--> + +<script type="text/x-red" data-template-name="get-resource"> + <div class="form-row"> + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> + <input type="text" id="node-input-name" placeholder="Name"> + </div> + <div class="form-row"> + <label for="node-input-xml"><i class="fa fa-wrench"></i> Node XML</label> + <input type="hidden" id="node-input-xml" autofocus="autofocus"> + <div style="height: 450px;" class="node-text-editor" id="node-input-xml-editor" onkeyup="resetStatus()" ></div> + </div> + <div class="form-row"> + <a href="#" class="btn btn-mini" id="node-input-validate" style="margin-top: 4px;"><b>Validate XML</b></a> + <a href="#" class="btn btn-mini" id="node-input-show-sli-values" style="margin-top: 4px;"><b>Show Values</b></a> + <input type="hidden" id="node-input-comments"> + <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a> + <div id="node-validate-result" class="form-tips" style="float:right;font-size:10px"></div> + </div> + <div class="form-tips">See the Info tab for help using this node.</div> +</script> + +<script type="text/x-red" data-help-name="get-resource"> + <p>A get-resource node.</p> + <p>First line of XML must contain opening tag.</p> + <p>Do not include closing tag - it will be automatically generated.</p> + +<div class="section"> +<h4><a name="Get-resource_node"></a>Get-resource node</h4> +<div class="section"> +<h5><a name="Description"></a>Description</h5> +<p>A <b>get-resource</b> node is used to retrieve information about a particular resource and make it available to other nodes in the service logic tree. For example, this might be used to retrieve information about a particular uni-port.</p></div> +<div class="section"> +<h5><a name="Attributes"></a>Attributes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>plugin</b></td> +<td align="left">Fully qualified Java class of resource adaptor to be used</td></tr> +<tr class="b"> +<td align="center"><b>resource</b></td> +<td align="left">Type of resource to retrieve</td></tr> +<tr class="a"> +<td align="center"><b>key</b></td> +<td align="left">SQL-like string specifying criteria for retrieval</td></tr></table></div> +<div class="section"> +<h5><a name="Parameters"></a>Parameters</h5> +<p>None</p></div> +<div class="section"> +<h5><a name="Outcomes"></a>Outcomes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>success</b></td> +<td align="left">Resource successfully released</td></tr> +<tr class="b"> +<td align="center"><b>not-found</b></td> +<td align="left">Resource referenced does not exist</td></tr> +<tr class="a"> +<td align="center"><b>failure</b></td> +<td align="left">Resource release failed for some other reason</td></tr></table></div> +<div class="section"> +<h5><a name="Example"></a>Example</h5> +<div class="source"> +<pre><get-resource plugin="org.onap.ccsdk.sli.resource.samplesvc.SampleServiceResource" + resource="ase-port" + key="uni_circuit_id == $uni-circuit-id"> + <outcome value="success"> + <return status="success"/> + </outcome> + <outcome value="not-found"> + <return status="failure"/> + </outcome> + <outcome value="failure"> + <return status="failure"/> + </outcome> +</get-resource></pre></div></div></div> + +</script> + + +<script type="text/javascript"> + RED.nodes.registerType('get-resource',{ + color:"#fdd0a2", + category: 'DGElogic', + defaults: { + name: {value:"get-resource"}, + xml: {value:"<get-resource plugin='' resource='' key='' >\n"}, + comments:{value:""}, + outputs: {value:1} + }, + inputs:1, + outputs:1, + icon: "arrow-in.png", + label: function() { + return this.name; + }, + oneditprepare: function() { + $( "#node-input-outputs" ).spinner({ + min:1 + }); + + + var comments = $( "#node-input-comments").val(); + if(comments != null){ + comments = comments.trim(); + if(comments != ''){ + $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); + } + } + + function functionDialogResize(ev,ui) { + $("#node-input-xml-editor").css("height",(ui.size.height-275)+"px"); + }; + + $( "#dialog" ).dialog( "option", "width", 1200 ); + $( "#dialog" ).dialog( "option", "height", 750 ); + $( "#dialog" ).on("dialogresize", functionDialogResize); + $( "#dialog" ).one("dialogopen", function(ev) { + var size = $( "#dialog" ).dialog('option','sizeCache-function'); + if (size) { + functionDialogResize(null,{size:size}); + } + }); + + /* close dialog when ESC is pressed and released */ + $( "#dialog" ).keyup(function(event){ + if(event.which == 27 ) { + $("#node-dialog-cancel").click(); + } + }); + + $( "#dialog" ).one("dialogclose", function(ev,ui) { + var height = $( "#dialog" ).dialog('option','height'); + $( "#dialog" ).off("dialogresize",functionDialogResize); + }); + var that = this; + require(["orion/editor/edit"], function(edit) { + that.editor = edit({ + parent:document.getElementById('node-input-xml-editor'), + lang:"html", + contents: $("#node-input-xml").val() + }); + RED.library.create({ + url:"functions", // where to get the data from + type:"function", // the type of object the library is for + editor:that.editor, // the field name the main text body goes to + fields:['name','outputs'] + }); + $("#node-input-name").focus(); + $("#node-input-validate").click(function(){ + console.log("validate clicked."); + //console.dir(that.editor); + //console.log("getText:" + that.editor.getText()); + var val = that.editor.getText(); + validateXML(val); + }); + $("#node-input-show-sli-values").click(function(){ + console.log("SLIValues clicked."); + showValuesBox(that.editor,sliValuesObj); + }); + + }); + //for click of add comments button + $("#node-input-btnComments").click(function(e){ + showCommentsBox(); + }); + }, + oneditsave: function() { + $("#node-input-xml").val(this.editor.getText()); + var resp=validateXML(this.editor.getText()); + if(resp){ + this.status = {fill:"green",shape:"dot",text:"OK"}; + }else{ + this.status = {fill:"red",shape:"dot",text:"ERROR"}; + } + delete this.editor; + } + }); +</script> diff --git a/dgbuilder/nodes/dge/dgelogic/get-resource.js b/dgbuilder/nodes/dge/dgelogic/get-resource.js new file mode 100644 index 00000000..597e0219 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/get-resource.js @@ -0,0 +1,31 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed 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. + **/ + +module.exports = function(RED) { + "use strict"; + var util = require("util"); + var vm = require("vm"); + + function getResource(n) { + RED.nodes.createNode(this,n); + this.name = n.name; + this.xml = n.xml; + this.topic = n.topic; + } + + RED.nodes.registerType("get-resource",getResource); + // RED.library.register("get-resource"); +} diff --git a/dgbuilder/nodes/dge/dgelogic/is-available.html b/dgbuilder/nodes/dge/dgelogic/is-available.html new file mode 100644 index 00000000..8bc45ef5 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/is-available.html @@ -0,0 +1,186 @@ +<!-- + Copyright 2013 IBM Corp. + + Licensed 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. +--> + +<script type="text/x-red" data-template-name="is-available"> + <div class="form-row"> + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> + <input type="text" id="node-input-name" placeholder="Name"> + </div> + <div class="form-row"> + <label for="node-input-xml"><i class="fa fa-wrench"></i> Node XML</label> + <input type="hidden" id="node-input-xml" autofocus="autofocus"> + <div style="height: 450px;" class="node-text-editor" id="node-input-xml-editor" onkeyup="resetStatus()" ></div> + </div> + <div class="form-row"> + <a href="#" class="btn btn-mini" id="node-input-validate" style="margin-top: 4px;"><b>Validate XML</b></a> + <a href="#" class="btn btn-mini" id="node-input-show-sli-values" style="margin-top: 4px;"><b>Show Values</b></a> + <input type="hidden" id="node-input-comments"> + <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a> + <div id="node-validate-result" class="form-tips" style="float:right;font-size:10px"></div> + </div> + <div class="form-tips">See the Info tab for help using this node.</div> +</script> + +<script type="text/x-red" data-help-name="is-available"> + <p>A is-available node.</p> + <p>First line of XML must contain opening tag.</p> + <p>Do not include closing tag - it will be automatically generated.</p> + +<div class="section"> +<h4><a name="Is-available_node"></a>Is-available node</h4> +<div class="section"> +<h5><a name="Description"></a>Description</h5> +<p>An <b>is-available</b> node is used to determine whether a particular type of resource is available. For example, this might be used to test whether any ports are available for assignment on a particular switch.</p></div> +<div class="section"> +<h5><a name="Attributes"></a>Attributes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>plugin</b></td> +<td align="left">Fully qualified Java class of resource adaptor to be used</td></tr> +<tr class="b"> +<td align="center"><b>resource</b></td> +<td align="left">Type of resource to check</td></tr> +<tr class="a"> +<td align="center"><b>key</b></td> +<td align="left">SQL-like string specifying key to check for</td></tr></table></div> +<div class="section"> +<h5><a name="Parameters"></a>Parameters</h5> +<p>None</p></div> +<div class="section"> +<h5><a name="Outcomes"></a>Outcomes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>true</b></td> +<td align="left">Resource requested is available</td></tr> +<tr class="b"> +<td align="center"><b>false</b></td> +<td align="left">Resource requested is not available</td></tr></table></div> +<div class="section"> +<h5><a name="Example"></a>Example</h5> +<div class="source"> +<pre><is-available plugin="org.onap.ccsdk.sli.resource.samplesvc.SampleServiceResource" + resource="ase-port" + key="resource-emt-clli == $edge-device-clli and speed >= $uni-cir-value"> + <outcome value="true"> + <return status="success"/> + </outcome> + <outcome value="false"> + <return status="failure"/> + </outcome> +</is-available></pre></div></div></div> + +</script> + + +<script type="text/javascript"> + RED.nodes.registerType('is-available',{ + color:"#fdd0a2", + category: 'DGElogic', + defaults: { + name: {value:"is-available"}, + xml: {value:"<is-available plugin='' resource='' key=''>\n"}, + comments:{value:""}, + outputs: {value:1} + }, + inputs:1, + outputs:1, + icon: "arrow-in.png", + label: function() { + return this.name; + }, + oneditprepare: function() { + $( "#node-input-outputs" ).spinner({ + min:1 + }); + + + var comments = $( "#node-input-comments").val(); + if(comments != null){ + comments = comments.trim(); + if(comments != ''){ + $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); + } + } + + function functionDialogResize(ev,ui) { + $("#node-input-xml-editor").css("height",(ui.size.height-275)+"px"); + }; + + $( "#dialog" ).dialog( "option", "width", 1200 ); + $( "#dialog" ).dialog( "option", "height", 750 ); + $( "#dialog" ).on("dialogresize", functionDialogResize); + $( "#dialog" ).one("dialogopen", function(ev) { + var size = $( "#dialog" ).dialog('option','sizeCache-function'); + if (size) { + functionDialogResize(null,{size:size}); + } + }); + + /* close dialog when ESC is pressed and released */ + $( "#dialog" ).keyup(function(event){ + if(event.which == 27 ) { + $("#node-dialog-cancel").click(); + } + }); + + $( "#dialog" ).one("dialogclose", function(ev,ui) { + var height = $( "#dialog" ).dialog('option','height'); + $( "#dialog" ).off("dialogresize",functionDialogResize); + }); + var that = this; + require(["orion/editor/edit"], function(edit) { + that.editor = edit({ + parent:document.getElementById('node-input-xml-editor'), + lang:"html", + contents: $("#node-input-xml").val() + }); + RED.library.create({ + url:"functions", // where to get the data from + type:"function", // the type of object the library is for + editor:that.editor, // the field name the main text body goes to + fields:['name','outputs'] + }); + $("#node-input-name").focus(); + $("#node-input-validate").click(function(){ + console.log("validate clicked."); + //console.dir(that.editor); + //console.log("getText:" + that.editor.getText()); + var val = that.editor.getText(); + validateXML(val); + }); + $("#node-input-show-sli-values").click(function(){ + console.log("SLIValues clicked."); + showValuesBox(that.editor,sliValuesObj); + }); + + }); + //for click of add comments button + $("#node-input-btnComments").click(function(e){ + showCommentsBox(); + }); + }, + oneditsave: function() { + $("#node-input-xml").val(this.editor.getText()); + var resp=validateXML(this.editor.getText()); + if(resp){ + this.status = {fill:"green",shape:"dot",text:"OK"}; + }else{ + this.status = {fill:"red",shape:"dot",text:"ERROR"}; + } + delete this.editor; + } + }); +</script> diff --git a/dgbuilder/nodes/dge/dgelogic/is-available.js b/dgbuilder/nodes/dge/dgelogic/is-available.js new file mode 100644 index 00000000..93f23f48 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/is-available.js @@ -0,0 +1,31 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed 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. + **/ + +module.exports = function(RED) { + "use strict"; + var util = require("util"); + var vm = require("vm"); + + function isAvailable(n) { + RED.nodes.createNode(this,n); + this.name = n.name; + this.xml = n.xml; + this.topic = n.topic; + } + + RED.nodes.registerType("is-available",isAvailable); + // RED.library.register("is-available"); +} diff --git a/dgbuilder/nodes/dge/dgelogic/notify.html b/dgbuilder/nodes/dge/dgelogic/notify.html new file mode 100644 index 00000000..e5bc24bc --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/notify.html @@ -0,0 +1,195 @@ +<!-- + Copyright 2013 IBM Corp. + + Licensed 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. +--> + +<script type="text/x-red" data-template-name="notify"> + <div class="form-row"> + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> + <input type="text" id="node-input-name" placeholder="Name"> + </div> + <div class="form-row"> + <label for="node-input-xml"><i class="fa fa-wrench"></i> Node XML</label> + <input type="hidden" id="node-input-xml" autofocus="autofocus"> + <div style="height: 450px;" class="node-text-editor" id="node-input-xml-editor" onkeyup="resetStatus()" ></div> + </div> + <div class="form-row"> + <a href="#" class="btn btn-mini" id="node-input-validate" style="margin-top: 4px;"><b>Validate XML</b></a> + <a href="#" class="btn btn-mini" id="node-input-show-sli-values" style="margin-top: 4px;"><b>Show Values</b></a> + <input type="hidden" id="node-input-comments"> + <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a> + <div id="node-validate-result" class="form-tips" style="float:right;font-size:10px"></div> + </div> + <div class="form-tips">See the Info tab for help using this node.</div> +</script> + +<script type="text/x-red" data-help-name="notify"> + <p>A notify node.</p> + <p>Do not include closing tag - it will be automatically generated.</p> +<!-- +<div class="section"> +<h5><a name="Description"></a>Description</h5> +<p>An <b>notify</b> node is used to execute Java code supplied as a plugin</p></div> +<div class="section"> +<h5><a name="Attributes"></a>Attributes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>plugin</b></td> +<td align="left">Fully qualified Java class of plugin to be used</td></tr> +<tr class="b"> +<td align="center"><b>method</b></td> +<td align="left">Name of method in the plugin class to execute. Method must return void, and take 2 arguments: a Map (for parameters) and a SvcLogicContext (to allow plugin read/write access to context memory)</td></tr></table></div> +<div class="section"> +<h5><a name="Parameters"></a>Parameters</h5> +<p>Specific to plugin / method</p></div> +<div class="section"> +<h5><a name="Outcomes"></a>Outcomes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>success</b></td> +<td align="left">Device successfully configured</td></tr> +<tr class="b"> +<td align="center"><b>not-found</b></td> +<td align="left">Plugin class could not be loaded</td></tr> +<tr class="a"> +<td align="center"><b>unsupported-method</b></td> +<td align="left">Named method taking (Map, SvcLogicContext) could not be found</td></tr> +<tr class="b"> +<td align="center"><b>failure</b></td> +<td align="left">Configure failed for some other reason</td></tr></table></div> +<div class="section"> +<h5><a name="Example"></a>Example</h5> +<div class="source"> +<pre><notify plugin="org.onap.ccsdk.sli.resource.samplesvc.SampleServiceResource" + resource="network-connection" action="DELETE" > + <parameter name="message" value="Hello, world!" /> + <outcome value="success"> + <return status="success"/> + </outcome> + <outcome value="not-found"> + <return status="failure"> + <parameter name="error-code" value="1590" /> + <parameter name="error-message" value="Could not locate plugin" /> + </return> + </outcome> + <outcome value="Other"> + <return status="failure"> + <parameter name="error-code" value="1542" /> + <parameter name="error-message" value="Internal error" /> + </return> + </outcome> +</notify></pre></div></div></div></div> +--> +</script> + + +<script type="text/javascript"> + RED.nodes.registerType('notify',{ + color:"#fdd0a2", + category: 'DGElogic', + defaults: { + name: {value:"notify"}, + xml: {value:"<notify plugin='' resource='' action='' >\n"}, + comments:{value:""}, + outputs: {value:1} + }, + inputs:1, + outputs:1, + icon: "arrow-in.png", + label: function() { + return this.name; + }, + oneditprepare: function() { + $( "#node-input-outputs" ).spinner({ + min:1 + }); + + var comments = $( "#node-input-comments").val(); + if(comments != null){ + comments = comments.trim(); + if(comments != ''){ + $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); + } + } + + + function functionDialogResize(ev,ui) { + $("#node-input-xml-editor").css("height",(ui.size.height-275)+"px"); + }; + + $( "#dialog" ).dialog( "option", "width", 1200 ); + $( "#dialog" ).dialog( "option", "height", 750 ); + $( "#dialog" ).on("dialogresize", functionDialogResize); + $( "#dialog" ).one("dialogopen", function(ev) { + var size = $( "#dialog" ).dialog('option','sizeCache-function'); + if (size) { + functionDialogResize(null,{size:size}); + } + }); + + /* close dialog when ESC is pressed and released */ + $( "#dialog" ).keyup(function(event){ + if(event.which == 27 ) { + $("#node-dialog-cancel").click(); + } + }); + + $( "#dialog" ).one("dialogclose", function(ev,ui) { + var height = $( "#dialog" ).dialog('option','height'); + $( "#dialog" ).off("dialogresize",functionDialogResize); + }); + var that = this; + require(["orion/editor/edit"], function(edit) { + that.editor = edit({ + parent:document.getElementById('node-input-xml-editor'), + lang:"html", + contents: $("#node-input-xml").val() + }); + RED.library.create({ + url:"functions", // where to get the data from + type:"function", // the type of object the library is for + editor:that.editor, // the field name the main text body goes to + fields:['name','outputs'] + }); + $("#node-input-name").focus(); + $("#node-input-validate").click(function(){ + //console.log("validate clicked."); + //console.dir(that.editor); + //console.log("getText:" + that.editor.getText()); + var val = that.editor.getText(); + validateXML(val); + }); + $("#node-input-show-sli-values").click(function(){ + //console.log("SLIValues clicked."); + showValuesBox(that.editor,sliValuesObj); + }); + + }); + //for click of add comments button + $("#node-input-btnComments").click(function(e){ + showCommentsBox(); + }); + }, + oneditsave: function() { + $("#node-input-xml").val(this.editor.getText()); + var resp=validateXML(this.editor.getText()); + if(resp){ + this.status = {fill:"green",shape:"dot",text:"OK"}; + }else{ + this.status = {fill:"red",shape:"dot",text:"ERROR"}; + } + delete this.editor; + } + }); +</script> diff --git a/dgbuilder/nodes/dge/dgelogic/notify.js b/dgbuilder/nodes/dge/dgelogic/notify.js new file mode 100644 index 00000000..8b58e9e4 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/notify.js @@ -0,0 +1,31 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed 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. + **/ + +module.exports = function(RED) { + "use strict"; + var util = require("util"); + var vm = require("vm"); + + function notify(n) { + RED.nodes.createNode(this,n); + this.name = n.name; + this.xml = n.xml; + this.topic = n.topic; + } + + RED.nodes.registerType("notify",notify); + // RED.library.register("configure"); +} diff --git a/dgbuilder/nodes/dge/dgelogic/record.html b/dgbuilder/nodes/dge/dgelogic/record.html new file mode 100644 index 00000000..3eb7a2e6 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/record.html @@ -0,0 +1,185 @@ +<!-- + Copyright 2013 IBM Corp. + + Licensed 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. +--> + +<script type="text/x-red" data-template-name="record"> + <div class="form-row"> + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> + <input type="text" id="node-input-name" placeholder="Name"> + </div> + <div class="form-row"> + <label for="node-input-xml"><i class="fa fa-wrench"></i> Node XML</label> + <input type="hidden" id="node-input-xml" autofocus="autofocus"> + <div style="height: 450px;" class="node-text-editor" id="node-input-xml-editor" onkeyup="resetStatus()" ></div> + </div> + <div class="form-row"> + <a href="#" class="btn btn-mini" id="node-input-validate" style="margin-top: 4px;"><b>Validate XML</b></a> + <a href="#" class="btn btn-mini" id="node-input-show-sli-values" style="margin-top: 4px;"><b>Show Values</b></a> + <input type="hidden" id="node-input-comments"> + <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a> + <div id="node-validate-result" class="form-tips" style="float:right;font-size:10px"></div> + </div> + <div class="form-tips">See the Info tab for help using this node.</div> +</script> + +<script type="text/x-red" data-help-name="record"> + <p>A record node.</p> + <p>First line of XML must contain opening tag.</p> + <p>Do not include closing tag - it will be automatically generated.</p> + +<div class="section"> +<h3><a name="Recording"></a>Recording</h3> +<div class="section"> +<h4><a name="Record_node"></a>Record node</h4> +<div class="section"> +<h5><a name="Description"></a>Description</h5> +<p>A <b>record</b> node is used to record an event. For example, this might be used to log provisioning events.</p></div> +<div class="section"> +<h5><a name="Attributes"></a>Attributes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>plugin</b></td> +<td align="left">Fully qualified Java class to handle recording.</td></tr></table></div> +<div class="section"> +<h5><a name="Parameters"></a>Parameters</h5> +<p>Parameters will depend on the plugin being used. For the FileRecorder class, the parameters are as follows</p> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>file</b></td> +<td align="left">The file to which the record should be written</td></tr> +<tr class="b"> +<td align="center"><b>field1</b></td> +<td align="left">First field to write. There will be <b>field</b> parameters for each field to write, from <b>field1</b> through <b>fieldN</b>. A special value __TIMESTAMP__ may be assigned to a field to insert the current timestamp</td></tr></table></div> +<div class="section"> +<h5><a name="Outcomes"></a>Outcomes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>success</b></td> +<td align="left">Record successfully written</td></tr> +<tr class="b"> +<td align="center"><b>failure</b></td> +<td align="left">Record could not be successfully written</td></tr></table></div> +<div class="section"> +<h5><a name="Example"></a>Example</h5> +<div class="source"> +<pre><record plugin="org.onap.ccsdk.sli.core.sli.recording.FileRecorder"> + <parameter name="file" value="/tmp/sample_r1.log" /> + <parameter name="field1" value="__TIMESTAMP__"/> + <parameter name="field2" value="ACTIVE"/> + <parameter name="field3" value="$uni-circuit-id"/> +</record></pre></div></div></div></div> + +</script> + + +<script type="text/javascript"> + RED.nodes.registerType('record',{ + color:"#fdd0a2", + category: 'DGElogic', + defaults: { + name: {value:"record"}, + xml: {value:"<record>\n"}, + comments:{value:""}, + outputs: {value:1} + }, + inputs:1, + outputs:1, + icon: "arrow-in.png", + label: function() { + return this.name; + }, + oneditprepare: function() { + $( "#node-input-outputs" ).spinner({ + min:1 + }); + + + var comments = $( "#node-input-comments").val(); + if(comments != null){ + comments = comments.trim(); + if(comments != ''){ + $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); + } + } + + function functionDialogResize(ev,ui) { + $("#node-input-xml-editor").css("height",(ui.size.height-275)+"px"); + }; + + $( "#dialog" ).dialog( "option", "width", 1200 ); + $( "#dialog" ).dialog( "option", "height", 750 ); + $( "#dialog" ).on("dialogresize", functionDialogResize); + $( "#dialog" ).one("dialogopen", function(ev) { + var size = $( "#dialog" ).dialog('option','sizeCache-function'); + if (size) { + functionDialogResize(null,{size:size}); + } + }); + + /* close dialog when ESC is pressed and released */ + $( "#dialog" ).keyup(function(event){ + if(event.which == 27 ) { + $("#node-dialog-cancel").click(); + } + }); + + $( "#dialog" ).one("dialogclose", function(ev,ui) { + var height = $( "#dialog" ).dialog('option','height'); + $( "#dialog" ).off("dialogresize",functionDialogResize); + }); + var that = this; + require(["orion/editor/edit"], function(edit) { + that.editor = edit({ + parent:document.getElementById('node-input-xml-editor'), + lang:"html", + contents: $("#node-input-xml").val() + }); + RED.library.create({ + url:"functions", // where to get the data from + type:"function", // the type of object the library is for + editor:that.editor, // the field name the main text body goes to + fields:['name','outputs'] + }); + $("#node-input-name").focus(); + $("#node-input-validate").click(function(){ + console.log("validate clicked."); + //console.dir(that.editor); + //console.log("getText:" + that.editor.getText()); + var val = that.editor.getText(); + validateXML(val); + }); + $("#node-input-show-sli-values").click(function(){ + console.log("SLIValues clicked."); + showValuesBox(that.editor,sliValuesObj); + }); + + }); + //for click of add comments button + $("#node-input-btnComments").click(function(e){ + showCommentsBox(); + }); + }, + oneditsave: function() { + $("#node-input-xml").val(this.editor.getText()); + var resp=validateXML(this.editor.getText()); + if(resp){ + this.status = {fill:"green",shape:"dot",text:"OK"}; + }else{ + this.status = {fill:"red",shape:"dot",text:"ERROR"}; + } + delete this.editor; + } + }); +</script> diff --git a/dgbuilder/nodes/dge/dgelogic/record.js b/dgbuilder/nodes/dge/dgelogic/record.js new file mode 100644 index 00000000..f29bf8f5 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/record.js @@ -0,0 +1,31 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed 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. + **/ + +module.exports = function(RED) { + "use strict"; + var util = require("util"); + var vm = require("vm"); + + function record(n) { + RED.nodes.createNode(this,n); + this.name = n.name; + this.xml = n.xml; + this.topic = n.topic; + } + + RED.nodes.registerType("record",record); + // RED.library.register("record"); +} diff --git a/dgbuilder/nodes/dge/dgelogic/release.html b/dgbuilder/nodes/dge/dgelogic/release.html new file mode 100644 index 00000000..044616a9 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/release.html @@ -0,0 +1,192 @@ +<!-- + Copyright 2013 IBM Corp. + + Licensed 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. +--> + +<script type="text/x-red" data-template-name="release"> + <div class="form-row"> + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> + <input type="text" id="node-input-name" placeholder="Name"> + </div> + <div class="form-row"> + <label for="node-input-xml"><i class="fa fa-wrench"></i> Node XML</label> + <input type="hidden" id="node-input-xml" autofocus="autofocus"> + <div style="height: 450px;" class="node-text-editor" id="node-input-xml-editor" onkeyup="resetStatus()" ></div> + </div> + <div class="form-row"> + <a href="#" class="btn btn-mini" id="node-input-validate" style="margin-top: 4px;"><b>Validate XML</b></a> + <a href="#" class="btn btn-mini" id="node-input-show-sli-values" style="margin-top: 4px;"><b>Show Values</b></a> + <input type="hidden" id="node-input-comments"> + <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a> + <div id="node-validate-result" class="form-tips" style="float:right;font-size:10px"></div> + </div> + <div class="form-tips">See the Info tab for help using this node.</div> +</script> + +<script type="text/x-red" data-help-name="release"> + <p>A release node.</p> + <p>First line of XML must contain opening tag.</p> + <p>Do not include closing tag - it will be automatically generated.</p> + +<div class="section"> +<h4><a name="Release_node"></a>Release node</h4> +<div class="section"> +<h5><a name="Description"></a>Description</h5> +<p>A <b>release</b> node is used to mark a resource as no longer in use, and thus available for assignment.</p></div> +<div class="section"> +<h5><a name="Attributes"></a>Attributes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>plugin</b></td> +<td align="left">Fully qualified Java class of resource adaptor to be used</td></tr> +<tr class="b"> +<td align="center"><b>resource</b></td> +<td align="left">Type of resource to release</td></tr> +<tr class="a"> +<td align="center"><b>key</b></td> +<td align="left">SQL-like string specifying key to check of resource to release</td></tr></table></div> +<div class="section"> +<h5><a name="Parameters"></a>Parameters</h5> +<p>None</p></div> +<div class="section"> +<h5><a name="Outcomes"></a>Outcomes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>success</b></td> +<td align="left">Resource successfully released</td></tr> +<tr class="b"> +<td align="center"><b>not-found</b></td> +<td align="left">Resource referenced does not exist</td></tr> +<tr class="a"> +<td align="center"><b>failure</b></td> +<td align="left">Resource release failed for some other reason</td></tr></table></div> +<div class="section"> +<h5><a name="Example"></a>Example</h5> +<div class="source"> +<pre><release plugin="org.onap.ccsdk.sli.resource.samplesvc.SampleServiceResource" + resource="ase-port" + key="uni_circuit_id == $uni-circuit-id"> + <outcome value="success"> + <return status="success"/> + </outcome> + <outcome value="not-found"> + <return status="failure"/> + </outcome> + <outcome value="failure"> + <return status="failure"/> + </outcome> +</release></pre></div></div></div> + +</script> + + +<script type="text/javascript"> + RED.nodes.registerType('release',{ + color:"#fdd0a2", + category: 'DGElogic', + defaults: { + name: {value:"release"}, + xml: {value:"<release plugin='' resource='' key='' >\n"}, + comments:{value:""}, + outputs: {value:1} + }, + inputs:1, + outputs:1, + icon: "arrow-in.png", + label: function() { + return this.name; + }, + oneditprepare: function() { + $( "#node-input-outputs" ).spinner({ + min:1 + }); + + + var comments = $( "#node-input-comments").val(); + if(comments != null){ + comments = comments.trim(); + if(comments != ''){ + $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); + } + } + + function functionDialogResize(ev,ui) { + $("#node-input-xml-editor").css("height",(ui.size.height-275)+"px"); + }; + + $( "#dialog" ).dialog( "option", "width", 1200 ); + $( "#dialog" ).dialog( "option", "height", 750 ); + $( "#dialog" ).on("dialogresize", functionDialogResize); + $( "#dialog" ).one("dialogopen", function(ev) { + var size = $( "#dialog" ).dialog('option','sizeCache-function'); + if (size) { + functionDialogResize(null,{size:size}); + } + }); + + /* close dialog when ESC is pressed and released */ + $( "#dialog" ).keyup(function(event){ + if(event.which == 27 ) { + $("#node-dialog-cancel").click(); + } + }); + + $( "#dialog" ).one("dialogclose", function(ev,ui) { + var height = $( "#dialog" ).dialog('option','height'); + $( "#dialog" ).off("dialogresize",functionDialogResize); + }); + var that = this; + require(["orion/editor/edit"], function(edit) { + that.editor = edit({ + parent:document.getElementById('node-input-xml-editor'), + lang:"html", + contents: $("#node-input-xml").val() + }); + RED.library.create({ + url:"functions", // where to get the data from + type:"function", // the type of object the library is for + editor:that.editor, // the field name the main text body goes to + fields:['name','outputs'] + }); + $("#node-input-name").focus(); + $("#node-input-validate").click(function(){ + console.log("validate clicked."); + //console.dir(that.editor); + //console.log("getText:" + that.editor.getText()); + var val = that.editor.getText(); + validateXML(val); + }); + $("#node-input-show-sli-values").click(function(){ + console.log("SLIValues clicked."); + showValuesBox(that.editor,sliValuesObj); + }); + + }); + //for click of add comments button + $("#node-input-btnComments").click(function(e){ + showCommentsBox(); + }); + }, + oneditsave: function() { + $("#node-input-xml").val(this.editor.getText()); + var resp=validateXML(this.editor.getText()); + if(resp){ + this.status = {fill:"green",shape:"dot",text:"OK"}; + }else{ + this.status = {fill:"red",shape:"dot",text:"ERROR"}; + } + delete this.editor; + } + }); +</script> diff --git a/dgbuilder/nodes/dge/dgelogic/release.js b/dgbuilder/nodes/dge/dgelogic/release.js new file mode 100644 index 00000000..ff03fff6 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/release.js @@ -0,0 +1,31 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed 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. + **/ + +module.exports = function(RED) { + "use strict"; + var util = require("util"); + var vm = require("vm"); + + function release(n) { + RED.nodes.createNode(this,n); + this.name = n.name; + this.xml = n.xml; + this.topic = n.topic; + } + + RED.nodes.registerType("release",release); + // RED.library.register("release"); +} diff --git a/dgbuilder/nodes/dge/dgelogic/reserve.html b/dgbuilder/nodes/dge/dgelogic/reserve.html new file mode 100644 index 00000000..bcd3fcb9 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/reserve.html @@ -0,0 +1,189 @@ +<!-- + Copyright 2013 IBM Corp. + + Licensed 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. +--> + +<script type="text/x-red" data-template-name="reserve"> + <div class="form-row"> + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> + <input type="text" id="node-input-name" placeholder="Name"> + </div> + <div class="form-row"> + <label for="node-input-xml"><i class="fa fa-wrench"></i> Node XML</label> + <input type="hidden" id="node-input-xml" autofocus="autofocus"> + <div style="height: 450px;" class="node-text-editor" id="node-input-xml-editor" onkeyup="resetStatus()" ></div> + </div> + <div class="form-row"> + <a href="#" class="btn btn-mini" id="node-input-validate" style="margin-top: 4px;"><b>Validate XML</b></a> + <a href="#" class="btn btn-mini" id="node-input-show-sli-values" style="margin-top: 4px;"><b>Show Values</b></a> + <input type="hidden" id="node-input-comments"> + <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a> + <div id="node-validate-result" class="form-tips" style="float:right;font-size:10px"></div> + </div> + <div class="form-tips">See the Info tab for help using this node.</div> +</script> + +<script type="text/x-red" data-help-name="reserve"> + <p>A reserve node.</p> + <p>First line of XML must contain opening tag.</p> + <p>Do not include closing tag - it will be automatically generated.</p> + +<div class="section"> +<h4><a name="Reserve_node"></a>Reserve node</h4> +<div class="section"> +<h5><a name="Description"></a>Description</h5> +<p>A <b>reserve</b> node is used to reserve a particular type of resource.. For example, this might be used to reserve a port on a particular switch.</p></div> +<div class="section"> +<h5><a name="Attributes"></a>Attributes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>plugin</b></td> +<td align="left">Fully qualified Java class of resource adaptor to be used</td></tr> +<tr class="b"> +<td align="center"><b>resource</b></td> +<td align="left">Type of resource to reserve</td></tr> +<tr class="a"> +<td align="center"><b>key</b></td> +<td align="left">SQL-like string specifying criteria for reservation</td></tr> +<tr class="b"> +<td align="center"><b>select</b></td> +<td align="left">String to specify, if <b>key</b> matches multiple entries, which entry should take precedence</td></tr></table></div> +<div class="section"> +<h5><a name="Parameters"></a>Parameters</h5> +<p>None</p></div> +<div class="section"> +<h5><a name="Outcomes"></a>Outcomes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>success</b></td> +<td align="left">Resource requested was successfully reserved</td></tr> +<tr class="b"> +<td align="center"><b>failure</b></td> +<td align="left">Resource requested was not successfully reserved</td></tr></table></div> +<div class="section"> +<h5><a name="Example"></a>Example</h5> +<div class="source"> +<pre><reserve plugin="org.onap.ccsdk.sli.resource.samplesvc.SampleServiceResource" + resource="ase-port" + key="resource-emt-clli == $edge-device-clli and speed >= $uni-cir-value" + select="min(speed)"> + <outcome value="success"> + <return status="success"/> + </outcome> + <outcome value="failure"> + <return status="failure"/> + </outcome> +</reserve></pre></div></div></div> + +</script> + + +<script type="text/javascript"> + RED.nodes.registerType('reserve',{ + color:"#fdd0a2", + category: 'DGElogic', + defaults: { + name: {value:"reserve"}, + xml: {value:"<reserve plugin='' resource='' key='' select=''>\n"}, + comments:{value:""}, + outputs: {value:1} + }, + inputs:1, + outputs:1, + icon: "arrow-in.png", + label: function() { + return this.name; + }, + oneditprepare: function() { + $( "#node-input-outputs" ).spinner({ + min:1 + }); + + var comments = $( "#node-input-comments").val(); + if(comments != null){ + comments = comments.trim(); + if(comments != ''){ + $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); + } + } + + function functionDialogResize(ev,ui) { + $("#node-input-xml-editor").css("height",(ui.size.height-275)+"px"); + }; + + $( "#dialog" ).dialog( "option", "width", 1200 ); + $( "#dialog" ).dialog( "option", "height", 750 ); + $( "#dialog" ).on("dialogresize", functionDialogResize); + $( "#dialog" ).one("dialogopen", function(ev) { + var size = $( "#dialog" ).dialog('option','sizeCache-function'); + if (size) { + functionDialogResize(null,{size:size}); + } + }); + + /* close dialog when ESC is pressed and released */ + $( "#dialog" ).keyup(function(event){ + if(event.which == 27 ) { + $("#node-dialog-cancel").click(); + } + }); + + $( "#dialog" ).one("dialogclose", function(ev,ui) { + var height = $( "#dialog" ).dialog('option','height'); + $( "#dialog" ).off("dialogresize",functionDialogResize); + }); + var that = this; + require(["orion/editor/edit"], function(edit) { + that.editor = edit({ + parent:document.getElementById('node-input-xml-editor'), + lang:"html", + contents: $("#node-input-xml").val() + }); + RED.library.create({ + url:"functions", // where to get the data from + type:"function", // the type of object the library is for + editor:that.editor, // the field name the main text body goes to + fields:['name','outputs'] + }); + $("#node-input-name").focus(); + $("#node-input-validate").click(function(){ + console.log("validate clicked."); + //console.dir(that.editor); + //console.log("getText:" + that.editor.getText()); + var val = that.editor.getText(); + validateXML(val); + }); + $("#node-input-show-sli-values").click(function(){ + console.log("SLIValues clicked."); + showValuesBox(that.editor,sliValuesObj); + }); + + }); + //for click of add comments button + $("#node-input-btnComments").click(function(e){ + showCommentsBox(); + }); + }, + oneditsave: function() { + $("#node-input-xml").val(this.editor.getText()); + var resp=validateXML(this.editor.getText()); + if(resp){ + this.status = {fill:"green",shape:"dot",text:"OK"}; + }else{ + this.status = {fill:"red",shape:"dot",text:"ERROR"}; + } + delete this.editor; + } + }); +</script> diff --git a/dgbuilder/nodes/dge/dgelogic/reserve.js b/dgbuilder/nodes/dge/dgelogic/reserve.js new file mode 100644 index 00000000..6aab1bd7 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/reserve.js @@ -0,0 +1,31 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed 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. + **/ + +module.exports = function(RED) { + "use strict"; + var util = require("util"); + var vm = require("vm"); + + function reserve(n) { + RED.nodes.createNode(this,n); + this.name = n.name; + this.xml = n.xml; + this.topic = n.topic; + } + + RED.nodes.registerType("reserve",reserve); + // RED.library.register("reserve"); +} diff --git a/dgbuilder/nodes/dge/dgelogic/save.html b/dgbuilder/nodes/dge/dgelogic/save.html new file mode 100644 index 00000000..6e022154 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/save.html @@ -0,0 +1,189 @@ +<!-- + Copyright 2013 IBM Corp. + + Licensed 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. +--> + +<script type="text/x-red" data-template-name="save"> + <div class="form-row"> + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> + <input type="text" id="node-input-name" placeholder="Name"> + </div> + <div class="form-row"> + <label for="node-input-xml"><i class="fa fa-wrench"></i> Node XML</label> + <input type="hidden" id="node-input-xml" autofocus="autofocus"> + <div style="height: 450px;" class="node-text-editor" id="node-input-xml-editor" onkeyup="resetStatus()" ></div> + </div> + <div class="form-row"> + <a href="#" class="btn btn-mini" id="node-input-validate" style="margin-top: 4px;"><b>Validate XML</b></a> + <a href="#" class="btn btn-mini" id="node-input-show-sli-values" style="margin-top: 4px;"><b>Show Values</b></a> + <input type="hidden" id="node-input-comments"> + <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a> + <div id="node-validate-result" class="form-tips" style="float:right;font-size:10px"></div> + </div> + <div class="form-tips">See the Info tab for help using this node.</div> +</script> + +<script type="text/x-red" data-help-name="save"> + <p>A save node.</p> + <p>First line of XML must contain opening tag.</p> + <p>Do not include closing tag - it will be automatically generated.</p> + +<div class="section"> +<h4><a name="Save_node"></a>Save node</h4> +<div class="section"> +<h5><a name="Description"></a>Description</h5> +<p>A <b>save</b> node is used to save information about a particular resource to persistent storage. For example, this might be used to save information about a particular uni-port.</p></div> +<div class="section"> +<h5><a name="Attributes"></a>Attributes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>plugin</b></td> +<td align="left">Fully qualified Java class of resource adaptor to be used</td></tr> +<tr class="b"> +<td align="center"><b>resource</b></td> +<td align="left">Type of resource to save</td></tr> +<tr class="a"> +<td align="center"><b>key</b></td> +<td align="left">SQL-like string specifying criteria for retrieval</td></tr> +<tr class="b"> +<td align="center"><b>force</b></td> +<td align="left">If "true", save resource even if this resource is already stored in persistent storage</td></tr> +<tr class="a"> +<td align="center"><b>pfx</b></td> +<td align="left">Prefix to be prepended to variable names, when attributes are set in SvcLogicContext</td></tr></table></div> +<div class="section"> +<h5><a name="Parameters"></a>Parameters</h5> +<p>Values to save (columns) are specified as parameters, with each name corresponding to a column name and each value corresponding to the value to set.</p></div> +<div class="section"> +<h5><a name="Outcomes"></a>Outcomes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>success</b></td> +<td align="left">Resource successfully saved</td></tr> +<tr class="b"> +<td align="center"><b>failure</b></td> +<td align="left">Resource save failed</td></tr></table></div> +<div class="section"> +<h5><a name="Example"></a>Example</h5> +<div class="source"> +<pre><save plugin="`$resource-plugin`" resource="resourceName" + key="keyName=value" + pfx="requests.resourceName"> + <parameter name="parameter1" + value="`$parameterOneValue`" /> + <parameter name="parameter2" value="`$parameterparameterTwoValue`" /> +</save></pre></div></div></div></div></div> + +</script> + + +<script type="text/javascript"> + RED.nodes.registerType('save',{ + color:"#fdd0a2", + category: 'DGElogic', + defaults: { + name: {value:"save"}, + xml: {value:"<save plugin='' resource='' key='' force='' pfx=''>\n<parameter name='' value='' />\n"}, + comments:{value:""}, + outputs: {value:1} + }, + inputs:1, + outputs:1, + icon: "arrow-in.png", + label: function() { + return this.name; + }, + oneditprepare: function() { + $( "#node-input-outputs" ).spinner({ + min:1 + }); + + + var comments = $( "#node-input-comments").val(); + if(comments != null){ + comments = comments.trim(); + if(comments != ''){ + $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); + } + } + + function functionDialogResize(ev,ui) { + $("#node-input-xml-editor").css("height",(ui.size.height-275)+"px"); + }; + + $( "#dialog" ).dialog( "option", "width", 1200 ); + $( "#dialog" ).dialog( "option", "height", 750 ); + $( "#dialog" ).on("dialogresize", functionDialogResize); + $( "#dialog" ).one("dialogopen", function(ev) { + var size = $( "#dialog" ).dialog('option','sizeCache-function'); + if (size) { + functionDialogResize(null,{size:size}); + } + }); + + /* close dialog when ESC is pressed and released */ + $( "#dialog" ).keyup(function(event){ + if(event.which == 27 ) { + $("#node-dialog-cancel").click(); + } + }); + + $( "#dialog" ).one("dialogclose", function(ev,ui) { + var height = $( "#dialog" ).dialog('option','height'); + $( "#dialog" ).off("dialogresize",functionDialogResize); + }); + var that = this; + require(["orion/editor/edit"], function(edit) { + that.editor = edit({ + parent:document.getElementById('node-input-xml-editor'), + lang:"html", + contents: $("#node-input-xml").val() + }); + RED.library.create({ + url:"functions", // where to get the data from + type:"function", // the type of object the library is for + editor:that.editor, // the field name the main text body goes to + fields:['name','outputs'] + }); + $("#node-input-name").focus(); + $("#node-input-validate").click(function(){ + console.log("validate clicked."); + //console.dir(that.editor); + //console.log("getText:" + that.editor.getText()); + var val = that.editor.getText(); + validateXML(val); + }); + $("#node-input-show-sli-values").click(function(){ + console.log("SLIValues clicked."); + showValuesBox(that.editor,sliValuesObj); + }); + + }); + //for click of add comments button + $("#node-input-btnComments").click(function(e){ + showCommentsBox(); + }); + }, + oneditsave: function() { + $("#node-input-xml").val(this.editor.getText()); + var resp=validateXML(this.editor.getText()); + if(resp){ + this.status = {fill:"green",shape:"dot",text:"OK"}; + }else{ + this.status = {fill:"red",shape:"dot",text:"ERROR"}; + } + delete this.editor; + } + }); +</script> diff --git a/dgbuilder/nodes/dge/dgelogic/save.js b/dgbuilder/nodes/dge/dgelogic/save.js new file mode 100644 index 00000000..5771ae98 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/save.js @@ -0,0 +1,31 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed 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. + **/ + +module.exports = function(RED) { + "use strict"; + var util = require("util"); + var vm = require("vm"); + + function save(n) { + RED.nodes.createNode(this,n); + this.name = n.name; + this.xml = n.xml; + this.topic = n.topic; + } + + RED.nodes.registerType("save",save); + // RED.library.register("save"); +} diff --git a/dgbuilder/nodes/dge/dgelogic/set.html b/dgbuilder/nodes/dge/dgelogic/set.html new file mode 100644 index 00000000..bcbcae30 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/set.html @@ -0,0 +1,162 @@ +<!-- + Copyright 2013 IBM Corp. + + Licensed 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. +--> + +<script type="text/x-red" data-template-name="set"> + <div class="form-row"> + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> + <input type="text" id="node-input-name" placeholder="Name"> + </div> + <div class="form-row"> + <label for="node-input-xml"><i class="fa fa-wrench"></i> Node XML</label> + <input type="hidden" id="node-input-xml" autofocus="autofocus"> + <div style="height: 450px;" class="node-text-editor" id="node-input-xml-editor" onkeyup="resetStatus()" ></div> + </div> + <div class="form-row"> + <a href="#" class="btn btn-mini" id="node-input-validate" style="margin-top: 4px;"><b>Validate XML</b></a> + <a href="#" class="btn btn-mini" id="node-input-show-sli-values" style="margin-top: 4px;"><b>Show Values</b></a> + <input type="hidden" id="node-input-comments"> + <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a> + <div id="node-validate-result" class="form-tips" style="float:right;font-size:10px"></div> + </div> + <div class="form-tips">See the Info tab for help using this node.</div> +</script> + +<script type="text/x-red" data-help-name="set"> + <p>A set node.</p> + <p>First line of XML must contain opening tag.</p> + <p>Do not include closing tag - it will be automatically generated.</p> + +<div class="section"> +<h4><a name="Set_node"></a>Set node</h4> +<div class="section"> +<h5><a name="Description"></a>Description</h5> +<p>A <b>set</b> node is used to set one or more values in the execution context</p></div> +<div class="section"> +<h5><a name="Attributes"></a>Attributes</h5> +<p>Not applicable. The <b>set</b> node does not have attributes.</p></div> +<div class="section"> +<h5><a name="Parameters"></a>Parameters</h5> +<p>Values to be set are passed as parameters</p></div> +<div class="section"> +<h5><a name="Outcomes"></a>Outcomes</h5> +<p>Not applicable. The <b>set</b> node has no outcomes.</p></div> +<div class="section"> +<h5><a name="Example"></a>Example</h5> +<div class="source"> +<pre><set> + <parameter name="vlan" value="$network.provider-segmentation-id" /> +</set></pre></div></div></div> + +</script> + + +<script type="text/javascript"> + RED.nodes.registerType('set',{ + color:"#fdd0a2", + category: 'DGElogic', + defaults: { + name: {value:"set"}, + xml: {value:"<set>\n<parameter name='' value='' />\n"}, + comments:{value:""} + }, + inputs:1, + icon: "arrow-in.png", + label: function() { + return this.name; + }, + oneditprepare: function() { + $( "#node-input-outputs" ).spinner({ + min:1 + }); + + + var comments = $( "#node-input-comments").val(); + if(comments != null){ + comments = comments.trim(); + if(comments != ''){ + $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); + } + } + + function functionDialogResize(ev,ui) { + $("#node-input-xml-editor").css("height",(ui.size.height-275)+"px"); + }; + + $( "#dialog" ).dialog( "option", "width", 1200 ); + $( "#dialog" ).dialog( "option", "height", 750 ); + $( "#dialog" ).on("dialogresize", functionDialogResize); + $( "#dialog" ).one("dialogopen", function(ev) { + var size = $( "#dialog" ).dialog('option','sizeCache-function'); + if (size) { + functionDialogResize(null,{size:size}); + } + }); + + /* close dialog when ESC is pressed and released */ + $( "#dialog" ).keyup(function(event){ + if(event.which == 27 ) { + $("#node-dialog-cancel").click(); + } + }); + + $( "#dialog" ).one("dialogclose", function(ev,ui) { + var height = $( "#dialog" ).dialog('option','height'); + $( "#dialog" ).off("dialogresize",functionDialogResize); + }); + var that = this; + require(["orion/editor/edit"], function(edit) { + that.editor = edit({ + parent:document.getElementById('node-input-xml-editor'), + lang:"html", + contents: $("#node-input-xml").val() + }); + RED.library.create({ + url:"functions", // where to get the data from + type:"function", // the type of object the library is for + editor:that.editor, // the field name the main text body goes to + fields:['name','outputs'] + }); + $("#node-input-name").focus(); + $("#node-input-validate").click(function(){ + console.log("validate clicked."); + //console.dir(that.editor); + //console.log("getText:" + that.editor.getText()); + var val = that.editor.getText(); + validateXML(val); + }); + $("#node-input-show-sli-values").click(function(){ + console.log("SLIValues clicked."); + showValuesBox(that.editor,sliValuesObj); + }); + + }); + //for click of add comments button + $("#node-input-btnComments").click(function(e){ + showCommentsBox(); + }); + }, + oneditsave: function() { + $("#node-input-xml").val(this.editor.getText()); + var resp=validateXML(this.editor.getText()); + if(resp){ + this.status = {fill:"green",shape:"dot",text:"OK"}; + }else{ + this.status = {fill:"red",shape:"dot",text:"ERROR"}; + } + delete this.editor; + } + }); +</script> diff --git a/dgbuilder/nodes/dge/dgelogic/set.js b/dgbuilder/nodes/dge/dgelogic/set.js new file mode 100644 index 00000000..9b939507 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/set.js @@ -0,0 +1,31 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed 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. + **/ + +module.exports = function(RED) { + "use strict"; + var util = require("util"); + var vm = require("vm"); + + function set(n) { + RED.nodes.createNode(this,n); + this.name = n.name; + this.xml = n.xml; + this.topic = n.topic; + } + + RED.nodes.registerType("set",set); + // RED.library.register("set"); +} diff --git a/dgbuilder/nodes/dge/dgelogic/switchNode.html b/dgbuilder/nodes/dge/dgelogic/switchNode.html new file mode 100644 index 00000000..35c9fe67 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/switchNode.html @@ -0,0 +1,232 @@ +<!-- + Copyright 2013 IBM Corp. + + Licensed 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. +--> + +<script type="text/x-red" data-template-name="switchNode"> + <div class="form-row"> + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> + <input type="text" id="node-input-name" placeholder="Name"> + </div> + <div class="form-row"> + <label for="node-input-xml"><i class="fa fa-wrench"></i> Node XML</label> + <input type="hidden" id="node-input-xml" autofocus="autofocus"> + <div style="height: 450px;" class="node-text-editor" id="node-input-xml-editor" onkeyup="resetStatus()" ></div> + </div> + <div class="form-row"> + <a href="#" class="btn btn-mini" id="node-input-validate" style="margin-top: 4px;"><b>Validate XML</b></a> + <a href="#" class="btn btn-mini" id="node-input-show-sli-values" style="margin-top: 4px;"><b>Show Values</b></a> + <input type="hidden" id="node-input-comments"> + <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a> + <div id="node-validate-result" class="form-tips" style="float:right;font-size:10px"></div> + </div> + <div class="form-tips">See the Info tab for help using this node.</div> +</script> + +<script type="text/x-red" data-help-name="switchNode"> + <p>A switch node.</p> + <p>First line of XML must contain opening tag.</p> + <p>Do not include closing tag - it will be automatically generated.</p> + +<div class="section"> +<h4><a name="Switch_node"></a>Switch node</h4> +<div class="section"> +<h5><a name="Description"></a>Description</h5> +<p>A <b>switch</b> node is used to make a decision based on its <b>test</b> attribute.</p></div> +<div class="section"> +<h5><a name="Attributes"></a>Attributes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>test</b></td> +<td align="left">Condition to test</td></tr></table></div> +<div class="section"> +<h5><a name="Parameters"></a>Parameters</h5> +<p>None</p></div> +<div class="section"> +<h5><a name="Outcomes"></a>Outcomes</h5> +<p>Depends on the <b>test</b> condition</p></div> +<div class="section"> +<h5><a name="Example"></a>Example</h5> +<div class="source"> +<pre><switch test="$uni-cir-units"> + <outcome value="Mbps"> + <reserve plugin="org.onap.ccsdk.sli.resource.samplesvc.SampleServiceResource" + resource="ase-port" + key="resource-emt-clli == $edge-device-clli and speed >= $uni-cir-value" + pfx="asePort"> + + <outcome value="success"> + <return status="success"> + <parameter name="uni-circuit-id" value="$asePort.uni_circuit_id" /> + </return> + </outcome> + <outcome value="Other"> + <return status="failure"> + <parameter name="error-code" value="1010" /> + <parameter name="error-message" value="No ports found that match criteria" /> + </return> + </outcome> + </reserve> + </outcome> + <outcome value="Gbps"> + <reserve plugin="org.onap.ccsdk.sli.resource.samplesvc.SampleServiceResource" + resource="ase-port" + key="resource-emt-clli == $edge-device-clli and speed >= $uni-cir-value*1000" + pfx="asePort"> + + <outcome value="success"> + <return status="success"> + <parameter name="uni-circuit-id" value="$asePort.uni_circuit_id" /> + </return> + </outcome> + <outcome value="Other"> + <return status="failure"> + <parameter name="error-code" value="1010" /> + <parameter name="error-message" value="No ports found that match criteria" /> + </return> + </outcome> + </reserve> + </outcome> +</switch></pre></div></div></div></div> + +</script> + + +<script type="text/javascript"> + RED.nodes.registerType('switchNode',{ + color:"#fdd0a2", + category: 'DGElogic', + defaults: { + name: {value:"switch"}, + xml: {value:"<switch test=''>\n"}, + comments:{value:""}, + outputs: {value:1} + }, + inputs:1, + outputs:1, + icon: "arrow-in.png", + label: function() { + return this.name; + }, + oneditprepare: function() { + $( "#node-input-outputs" ).spinner({ + min:1 + }); + + + var comments = $( "#node-input-comments").val(); + if(comments != null){ + comments = comments.trim(); + if(comments != ''){ + $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); + } + } + + function functionDialogResize(ev,ui) { + $("#node-input-xml-editor").css("height",(ui.size.height-275)+"px"); + }; + + $( "#dialog" ).dialog( "option", "width", 1200 ); + $( "#dialog" ).dialog( "option", "height", 750 ); + $( "#dialog" ).on("dialogresize", functionDialogResize); + $( "#dialog" ).one("dialogopen", function(ev) { + var size = $( "#dialog" ).dialog('option','sizeCache-function'); + //To increase the width of dialogbox + //$(".ui-dialog.ui-widget.ui-widget-content.ui-corner-all.ui-front.ui-dialog-buttons.ui-draggable.ui-resizable").css("width","1400px"); + if (size) { + functionDialogResize(null,{size:size}); + } + }); + + /* close dialog when ESC is pressed and released */ + $( "#dialog" ).keyup(function(event){ + if(event.which == 27 ) { + $("#node-dialog-cancel").click(); + } + }); + + $( "#dialog" ).one("dialogclose", function(ev,ui) { + var height = $( "#dialog" ).dialog('option','height'); + $( "#dialog" ).off("dialogresize",functionDialogResize); + }); + var that = this; + require(["orion/editor/edit"], function(edit) { + that.editor = edit({ + parent:document.getElementById('node-input-xml-editor'), + lang:"html", + contents: $("#node-input-xml").val() + }); + RED.library.create({ + url:"functions", // where to get the data from + type:"function", // the type of object the library is for + editor:that.editor, // the field name the main text body goes to + fields:['name','outputs'] + }); + $("#node-input-name").focus(); + $("#node-input-validate").click(function(){ + console.log("validate clicked."); + //console.dir(that.editor); + //console.log("getText:" + that.editor.getText()); + var val = that.editor.getText(); + validateXML(val); + }); + $("#node-input-show-sli-values").click(function(){ + console.log("SLIValues clicked."); + showValuesBox(that.editor,sliValuesObj); + }); + + }); + //for click of add comments button + $("#node-input-btnComments").click(function(e){ + showCommentsBox(); + }); + }, + oneditsave: function() { + $("#node-input-xml").val(this.editor.getText()); + var resp=validateXML(this.editor.getText()); + if(resp){ + this.status = {fill:"green",shape:"dot",text:"OK"}; + }else{ + this.status = {fill:"red",shape:"dot",text:"ERROR"}; + } + delete this.editor; + } + }); + +function encodeTestStr(xmlStr){ + var updatedXmlStr=xmlStr; + if(updatedXmlStr != null){ + var testCondition = getAttributeValue(xmlStr,"test"); + if(testCondition != null && testCondition != ''){ + if(testCondition.indexOf("<") == -1){ + testCondition=testCondition.replace(/</g,"<"); + } + updatedXmlStr="<switch test=\"" + testCondition + "\" >"; + } + } + return updatedXmlStr; +} + +function decodeTestStr(xmlStr){ + var updatedXmlStr=xmlStr; + if(updatedXmlStr != null){ + var testCondition = getAttributeValue(xmlStr,"test"); + if(testCondition != null && testCondition != ''){ + testCondition=testCondition.replace(/</g,"<"); + updatedXmlStr="<switch test=\"" + testCondition + "\" >"; + } + } + return updatedXmlStr; +} +</script> diff --git a/dgbuilder/nodes/dge/dgelogic/switchNode.js b/dgbuilder/nodes/dge/dgelogic/switchNode.js new file mode 100644 index 00000000..6a7a545d --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/switchNode.js @@ -0,0 +1,31 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed 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. + **/ + +module.exports = function(RED) { + "use strict"; + var util = require("util"); + var vm = require("vm"); + + function switchNode(n) { + RED.nodes.createNode(this,n); + this.name = n.name; + this.xml = n.xml; + this.topic = n.topic; + } + + RED.nodes.registerType("switchNode",switchNode); + // RED.library.register("switch"); +} diff --git a/dgbuilder/nodes/dge/dgelogic/update.html b/dgbuilder/nodes/dge/dgelogic/update.html new file mode 100644 index 00000000..a7d28283 --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/update.html @@ -0,0 +1,195 @@ +<!-- + Copyright 2013 IBM Corp. + + Licensed 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. +--> + +<script type="text/x-red" data-template-name="update"> + <div class="form-row"> + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> + <input type="text" id="node-input-name" placeholder="Name"> + </div> + <div class="form-row"> + <label for="node-input-xml"><i class="fa fa-wrench"></i> Node XML</label> + <input type="hidden" id="node-input-xml" autofocus="autofocus"> + <div style="height: 450px;" class="node-text-editor" id="node-input-xml-editor" onkeyup="resetStatus()" ></div> + </div> + <div class="form-row"> + <a href="#" class="btn btn-mini" id="node-input-validate" style="margin-top: 4px;"><b>Validate XML</b></a> + <a href="#" class="btn btn-mini" id="node-input-show-sli-values" style="margin-top: 4px;"><b>Show Values</b></a> + <input type="hidden" id="node-input-comments"> + <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a> + <div id="node-validate-result" class="form-tips" style="float:right;font-size:10px"></div> + </div> + <div class="form-tips">See the Info tab for help using this node.</div> +</script> + +<script type="text/x-red" data-help-name="update"> + <p>A update node.</p> + <p>Do not include closing tag - it will be automatically generated.</p> +<!-- +<div class="section"> +<h5><a name="Description"></a>Description</h5> +<p>An <b>update</b> node is used to execute Java code supplied as a plugin</p></div> +<div class="section"> +<h5><a name="Attributes"></a>Attributes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>plugin</b></td> +<td align="left">Fully qualified Java class of plugin to be used</td></tr> +<tr class="b"> +<td align="center"><b>method</b></td> +<td align="left">Name of method in the plugin class to execute. Method must return void, and take 2 arguments: a Map (for parameters) and a SvcLogicContext (to allow plugin read/write access to context memory)</td></tr></table></div> +<div class="section"> +<h5><a name="Parameters"></a>Parameters</h5> +<p>Specific to plugin / method</p></div> +<div class="section"> +<h5><a name="Outcomes"></a>Outcomes</h5> +<table border="1" class="table table-striped"> +<tr class="a"> +<td align="center"><b>success</b></td> +<td align="left">Device successfully configured</td></tr> +<tr class="b"> +<td align="center"><b>not-found</b></td> +<td align="left">Plugin class could not be loaded</td></tr> +<tr class="a"> +<td align="center"><b>unsupported-method</b></td> +<td align="left">Named method taking (Map, SvcLogicContext) could not be found</td></tr> +<tr class="b"> +<td align="center"><b>failure</b></td> +<td align="left">Configure failed for some other reason</td></tr></table></div> +<div class="section"> +<h5><a name="Example"></a>Example</h5> +<div class="source"> +<pre><update plugin="org.onap.ccsdk.sli.resource.samplesvc.SampleServiceResource" + resource="network-connection" action="DELETE" > + <parameter name="message" value="Hello, world!" /> + <outcome value="success"> + <return status="success"/> + </outcome> + <outcome value="not-found"> + <return status="failure"> + <parameter name="error-code" value="1590" /> + <parameter name="error-message" value="Could not locate plugin" /> + </return> + </outcome> + <outcome value="Other"> + <return status="failure"> + <parameter name="error-code" value="1542" /> + <parameter name="error-message" value="Internal error" /> + </return> + </outcome> +</update></pre></div></div></div></div> +--> +</script> + + +<script type="text/javascript"> + RED.nodes.registerType('update',{ + color:"#fdd0a2", + category: 'DGElogic', + defaults: { + name: {value:"update"}, + xml: {value:"<update resource='' force='' plugin='' key='' pfx='' local-only=''>\n"}, + comments:{value:""}, + outputs: {value:1} + }, + inputs:1, + outputs:1, + icon: "arrow-in.png", + label: function() { + return this.name; + }, + oneditprepare: function() { + $( "#node-input-outputs" ).spinner({ + min:1 + }); + + var comments = $( "#node-input-comments").val(); + if(comments != null){ + comments = comments.trim(); + if(comments != ''){ + $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); + } + } + + + function functionDialogResize(ev,ui) { + $("#node-input-xml-editor").css("height",(ui.size.height-275)+"px"); + }; + + $( "#dialog" ).dialog( "option", "width", 1200 ); + $( "#dialog" ).dialog( "option", "height", 750 ); + $( "#dialog" ).on("dialogresize", functionDialogResize); + $( "#dialog" ).one("dialogopen", function(ev) { + var size = $( "#dialog" ).dialog('option','sizeCache-function'); + if (size) { + functionDialogResize(null,{size:size}); + } + }); + + /* close dialog when ESC is pressed and released */ + $( "#dialog" ).keyup(function(event){ + if(event.which == 27 ) { + $("#node-dialog-cancel").click(); + } + }); + + $( "#dialog" ).one("dialogclose", function(ev,ui) { + var height = $( "#dialog" ).dialog('option','height'); + $( "#dialog" ).off("dialogresize",functionDialogResize); + }); + var that = this; + require(["orion/editor/edit"], function(edit) { + that.editor = edit({ + parent:document.getElementById('node-input-xml-editor'), + lang:"html", + contents: $("#node-input-xml").val() + }); + RED.library.create({ + url:"functions", // where to get the data from + type:"function", // the type of object the library is for + editor:that.editor, // the field name the main text body goes to + fields:['name','outputs'] + }); + $("#node-input-name").focus(); + $("#node-input-validate").click(function(){ + //console.log("validate clicked."); + //console.dir(that.editor); + //console.log("getText:" + that.editor.getText()); + var val = that.editor.getText(); + validateXML(val); + }); + $("#node-input-show-sli-values").click(function(){ + //console.log("SLIValues clicked."); + showValuesBox(that.editor,sliValuesObj); + }); + + }); + //for click of add comments button + $("#node-input-btnComments").click(function(e){ + showCommentsBox(); + }); + }, + oneditsave: function() { + $("#node-input-xml").val(this.editor.getText()); + var resp=validateXML(this.editor.getText()); + if(resp){ + this.status = {fill:"green",shape:"dot",text:"OK"}; + }else{ + this.status = {fill:"red",shape:"dot",text:"ERROR"}; + } + delete this.editor; + } + }); +</script> diff --git a/dgbuilder/nodes/dge/dgelogic/update.js b/dgbuilder/nodes/dge/dgelogic/update.js new file mode 100644 index 00000000..f614af8b --- /dev/null +++ b/dgbuilder/nodes/dge/dgelogic/update.js @@ -0,0 +1,31 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed 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. + **/ + +module.exports = function(RED) { + "use strict"; + var util = require("util"); + var vm = require("vm"); + + function update(n) { + RED.nodes.createNode(this,n); + this.name = n.name; + this.xml = n.xml; + this.topic = n.topic; + } + + RED.nodes.registerType("update",update); + // RED.library.register("configure"); +} |