use of com.ibm.streamsx.topology.builder.BOperator in project streamsx.topology by IBMStreams.
the class DependencyResolver method resolveDependencies.
/**
* Resolve the dependencies.
* Creates entries in the graph config that will
* result in files being copied into the toolkit.
*/
public void resolveDependencies() throws IOException, URISyntaxException {
JSONObject graphConfig = topology.builder().getConfig();
JSONArray includes = (JSONArray) graphConfig.get("includes");
if (includes == null)
graphConfig.put("includes", includes = new JSONArray());
for (BOperatorInvocation op : operatorToJarDependencies.keySet()) {
ArrayList<String> jars = new ArrayList<String>();
for (Path source : operatorToJarDependencies.get(op)) {
String jarName = resolveDependency(source, includes);
jars.add("impl/lib/" + jarName);
}
String[] jarPaths = jars.toArray(new String[jars.size()]);
op.setParameter("jar", jarPaths);
}
ArrayList<String> jars = new ArrayList<String>();
for (Path source : globalDependencies) {
String jarName = resolveDependency(source, includes);
jars.add("impl/lib/" + jarName);
}
List<BOperator> ops = topology.builder().getOps();
if (jars.size() != 0) {
for (BOperator op : ops) {
if (op instanceof BOperatorInvocation) {
BOperatorInvocation bop = (BOperatorInvocation) op;
if (Functional.class.isAssignableFrom(bop.op().getOperatorClass())) {
JSONObject params = (JSONObject) bop.json().get("parameters");
JSONObject op_jars = (JSONObject) params.get("jar");
if (null == op_jars) {
JSONObject val = new JSONObject();
val.put("value", new JSONArray());
params.put("jar", val);
op_jars = val;
}
JSONArray value = (JSONArray) op_jars.get("value");
for (String jar : jars) {
value.add(jar);
}
}
}
}
}
for (Artifact dep : globalFileDependencies) resolveFileDependency(dep, includes);
}
Aggregations