|
From: <pat...@us...> - 2011-01-11 17:26:27
|
Revision: 1191
http://cishell.svn.sourceforge.net/cishell/?rev=1191&view=rev
Author: pataphil
Date: 2011-01-11 17:26:18 +0000 (Tue, 11 Jan 2011)
Log Message:
-----------
* Added ${data_label[x]} placeholder syntax support to static executable config.properties files (for: http://cns-jira.slis.indiana.edu/browse/SCISQUARED-354 )
* Reviewed by Joseph.
Modified Paths:
--------------
trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java
Modified: trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java
===================================================================
--- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java 2011-01-10 02:34:09 UTC (rev 1190)
+++ trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableRunner.java 2011-01-11 17:26:18 UTC (rev 1191)
@@ -52,6 +52,10 @@
* @author Bruce Herr (bh...@bh...)
*/
public class StaticExecutableRunner implements Algorithm {
+ public static final String EXECUTABLE_PLACEHOLDER = "executable";
+ public static final String DATA_LABEL_PLACEHOLDER = "data_label";
+ public static final String IN_FILE_PLACEHOLDER = "inFile";
+
private String ALGORITHM;
private String ALGORITHM_MACOSX_PPC;
private String MACOSX;
@@ -439,17 +443,23 @@
// (real names of files instead of inFile[i], for instance)
// (also, real values like "6" or "dog" instead of placeholders for parameters)
protected String substituteVars(String str, Data[] data, Dictionary parameters) {
- str = str.replaceAll("\\$\\{executable\\}", props.getProperty("executable"));
+ str = str.replaceAll(
+ "\\$\\{" + EXECUTABLE_PLACEHOLDER + "\\}", props.getProperty(EXECUTABLE_PLACEHOLDER));
- for (int i = 0; i < data.length; i++) {
- File inFile = (File)data[i].getData();
+ for (int ii = 0; ii < data.length; ii++) {
+ String label = data[0].getMetadata().get(DataProperty.LABEL).toString();
+ String escapedLabel = label.replaceAll("\\\\", "/");
+ str = str.replaceAll(
+ "\\$\\{" + DATA_LABEL_PLACEHOLDER + "\\[" + ii + "\\]\\}", escapedLabel);
+
+ File inFile = (File)data[ii].getData();
String filePath = inFile.getAbsolutePath();
if (File.separatorChar == '\\') {
filePath = filePath.replace(File.separatorChar, '/');
}
- str = str.replaceAll("\\$\\{inFile\\[" + i + "\\]\\}", filePath);
+ str = str.replaceAll("\\$\\{" + IN_FILE_PLACEHOLDER + "\\[" + ii + "\\]\\}", filePath);
if (File.separatorChar == '\\') {
str = str.replace('/', File.separatorChar);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|