private AdmireRegistry mRegistry;
public void process(String dispel) throws IOException
{
DISPELCompiler compiler = new DISPELCompiler();
DISPELGraphBuilder builder = new DISPELGraphBuilder(
mRegistry,
new SimpleDispelOptimiser());
compiler.setRequestBuilder(builder);
compiler.addErrorListener(this);
compiler.parse(dispel);
Map<String, RegisteredObject> registered = builder.getRegistered();
Map<String, Variable> variables = builder.getDispelExecutionState().getVariables();
for (Entry<String, RegisteredObject> entry : registered.entrySet())
{
LOG.debug("Processing registered object " + entry.getKey());
DispelObject reg = null;
try
{
if (entry.getValue().getObject() instanceof Variable)
{
Variable var = (Variable)entry.getValue().getObject();
if (var.getValue() != null)
{
reg = new DispelObject(entry.getKey(), var.getValue());
}
else
{
error(0, 0, new VariableNotInitialisedException(entry.getKey()));
return;
}
}
else
{
reg = new DispelObject(entry.getKey(), entry.getValue());
}
}
catch(IllegalArgumentException e)
{
error(0, 0, e);
return;
}
if (reg.getType() == DispelObjectType.PROCESSING_ELEMENT_TYPE)
{
ProcessingElementType peType = (ProcessingElementType)entry.getValue().getObject();
if (peType.getImplementation() != null)
{
LOG.debug("Writing registered composite processing element " + entry.getKey());
Graph component = GraphUtilities.getConnectedComponent(
peType.getImplementation());
String image =
convertToImage(component, variables);
mRegistered.put(reg.name, image);
}
else
{
LOG.debug("Registering processing element type " + entry.getKey());
StringBuilder pe = new StringBuilder();
pe.append("Type ");
pe.append(reg.name);
if (peType.getDescriptor().getSuperType() != null
&& !peType.getDescriptor().getSuperType().isEmpty())
{
pe.append(" is PE<");
pe.append(peType.getDescriptor().getSuperType().iterator().next());
pe.append(">;");
}
else
{
pe.append(" is PE(<");
for (ProcessingElementInputDescriptor input : peType.getDescriptor().getInputs())
{
pe.append("Connection ");
if (input.getIsDataSourceInput())
{
pe.append("locator ");
}
pe.append(input.getName());
pe.append("; ");
}
if (!peType.getDescriptor().getInputs().isEmpty())
{
pe.delete(pe.length()-2, pe.length());
}
pe.append("> => <");
for (ProcessingElementOutputDescriptor output : peType.getDescriptor().getOutputs())
{
pe.append("Connection ");
pe.append(output.getName());
pe.append("; ");
}
if (!peType.getDescriptor().getOutputs().isEmpty())
{
pe.delete(pe.length()-2, pe.length());
}
pe.append(">);");
}
mRegistered.put(reg.name, pe.toString());
}
}
else
{
mRegistered.put(reg.getName(), reg.getDispel());
}
}
LOG.debug("Writing submitted graphs.");
for (Graph graph : builder.getSubmittedGraphs())
{
String image = convertToImage(graph, variables);
mSubmitted.add(image);
}