Flow control implementation with the use of script

From CelliP-en

Jump to: navigation, search

Contents

Overview

Paipurainapurishon in the flow created by the Run button to run, flow control creates a Script, Run Script button is pressed, Script can run the flow along the implements.
For example, if the output format to convert the file to load 100 in the directory, if you use the normal Run button, you must create a flow to match the input file 100. However, the execution flow of the loop and update the input file output file name when you create a Script in it, you can also get an output file 100 in a single flow. Here, we have included Script flow control implementation simple cases, please refer to.

- Flow control settings in the application pipeline Script: When components are not selected on the canvas, the screen displays the following parameters, set the Script here. Run Script button (triangle on the right, during the S button labeled. The shape will be changed in the future) by pressing, Script is executed.

FlowControlScript parameters.png



- Distributable Package on the startup screen flow control settings Script:
After setting the Script, "Run" button is pressed, Script is executed. In addition, Script is not set (empty) In the case of, "Run" button, will run as normal flow.

FlowControl scriptSample.png

★Note★

At 2010/5/24, ScriptLanguage: Auto, JavaFX, Jython is not supported.

Script for an example implementation of flow control

The following files CSML CSO flow to convert the file.
Input CSML --> Export CSML to CSO --> OutputCSO Input CSML -> Export CSML to CSO -> OutputCSO

FlowControlStript sampleFlow.PNG

A, [user.home] / ScriptTest / input / CSML directory files (extension csml) for all runs, [user.home] / ScriptTest / output / directory of the owl is a CSO file extension to output, Script and try to implement flow control.

First, Script Check the parameters to change the value. This will be shown in the table below.

Component Component ID Parameter Name Parameter Key
Input CSML c1 CSML File Name CSML File Name
Output CSO c3 Output File Name Output File Name


JavaScript sample

importPackage(java.io);
importPackage(java.lang);
importPackage(org.csml.pipeline.ui);
importPackage(org.csml.nci.utils);

directory = File(System.getProperty("user.home") + "/ScriptTest/input/");
listFiles = PipelineScriptHelper.getFiles(directory.getAbsolutePath(), "csml");

if (listFiles != null) {
	total = listFiles.length;

	for (i=0;i<total;i++) {
		if (PipelineScriptHelper.isCancelled()) {
			break;
		}

		listFile = listFiles[i];
		path = listFile.getAbsolutePath();

		PipelineScriptHelper.init();

		PipelineScriptHelper.setValue("c1.CSML File Name", listFile.toURI());

		outputPath = path.replaceFirst("input", "output").replaceFirst(".csml", ".owl");

		PipelineScriptHelper.setValue("c3.Output File Name", URIUtils.createURI(outputPath));

		PipelineScriptHelper.run();
	}
}


Code Explanation

importPackage(java.lang); Java packages using the import class. This time, java.lang.System, java.io.File, org.csml.pipeline.ui.PipelineScriptHelper, org.csml.nci.utils.URIUtils because it uses are specified for each package.
listFiles = PipelineScriptHelper.getFiles(directory.getAbsolutePath(), "csml"); The files in the specified directory with the extension "csml" is what is getting.
For more information about the methods of the class PipelineScriptHelper please refer to.
if (PipelineScriptHelper.isCancelled()) {
  break;
}
What Happens When You Run a cancellation. For a long script processing, handling cut (if the loop in it) be sure PipelineScriptHelper.isCancelled () checks the value of a,
true if so, please exit the implementation process.
For more information about the methods of the class PipelineScriptHelper please refer to.
PipelineScriptHelper.init(); Update values to initialize the flow.
PipelineScriptHelper.setValue("c1.CSML File Name", listFile.toURI()); CSML is set to enter a new file path.
For more information about the methods of the class PipelineScriptHelper please refer to.
outputPath = path.replaceFirst("input", "output").replaceFirst(".csml", ".owl"); ReplaceFirst replacement method, using the output file path is determined based on the input file path.
PipelineScriptHelper.setValue("c3.Output File Name", URIUtils.createURI(outputPath)); CSO output file path is set to the URI of the new type.
URI path string when converting to regular file types please URIUtils.createURI method.
rel with a file or a URI scheme, such as when converting a URI string type, java.net package to import, URI constructor: new URI (string) or URI.create please use the method.
Details of the method PipelineScriptHelper.setValue PipelineScriptHelper class methods please refer to.
PipelineScriptHelper.run(); Set parameters, run the flow.


Pnuts sample

import("java.io.*");
import("java.lang.*");
import("org.csml.pipeline.ui.*");
import("org.csml.nci.utils.*");

directory = File(System::getProperty("user.home") + "/ScriptTest/input/");
listFiles = PipelineScriptHelper::getFiles(directory.getAbsolutePath(), "csml");

if (listFiles != null) {
	total = listFiles.length;

	for (i=0;i<total;i++) {

		if (PipelineScriptHelper::isCancelled()) {
			break;
		}

		listFile = listFiles[i];
		path = listFile.getAbsolutePath();

		PipelineScriptHelper::init();

		PipelineScriptHelper::setValue("c1.CSML File Name", listFile.toURI());

		outputPath = path.replaceFirst("input", "output").replaceFirst(".csml", ".owl");
		PipelineScriptHelper::setValue("c3.Output File Name", URIUtils(outputPath));

		PipelineScriptHelper::run();
	}
}


Jython sample

2010/5/24 2010/5/24 not currently supported.

from java.io import *
from java.lang import *
from org.csml.pipeline.ui import *
from org.csml.nci.utils import *

directory = File(System.getProperty("user.home") + "/ScriptTest/input/")
listFiles = PipelineScriptHelper.getFiles(directory.getAbsolutePath(), "csml")

if (listFiles):
	total = len(listFiles)

	for i in range(total):

		if (PipelineScriptHelper.isCancelled()):
			break

		listFile = listFiles[i]
		path = listFile.getAbsolutePath()

		PipelineScriptHelper.init()

		PipelineScriptHelper.setValue("c1.CSML File Name", listFile.toURI())

		outputPath = path.replace("input", "output").replace(".csml", ".owl")
		PipelineScriptHelper.setValue("c3.Output File Name", URIUtils.createURI(outputPath))

		PipelineScriptHelper.run()



PipelineScriptHelper class methods

void init ()

SetValue below initializes the execution information such as the value set by the flow method. If you use the setValue method, please be sure to write.

boolean isCancelled ()

Stop Job Cancel button or canceled if the execution button is pressed, true is returned.

void setValue (String key, Object value)

Set the value to be updated with the flow. The parameters to be controlled exclusively between the two, can only be set to one. For value, true or false please set. The parameters for the exclusive control between more than two, true / false please go to all, regardless of the setting. (2010/5/27: true support is being set up to be just like what you want.)

key

Parameters to update the component with the component ID, the Key and parameters "." (Dot) in the form specified in concatenated.

Cases: c1.CSML File Name 

value

The updated value of the parameter.

void run ()

Set parameters, run the flow.

File [] getFiles (String directory, String fileExtension)

Specified directory (directory), located in a specified extension (fileExtension) with a list of files, File returns an array type. However, fileExtension are case insensitive.

directory

Directory you want to get a list of files

fileExtension

File extension

String [] getFileNames (String directory, String fileExtension)

Specified directory (directory), located in a specified extension (fileExtension) file with a list of paths, String returns the array. However, fileExtension are case insensitive.

directory

Directory you want to get a list of files

fileExtension

File extension

Personal tools