/**
* ban to add same transformers multiplicitly
*/
if(!existingTransformers.containsKey(transformer)){
//need to regenerate the instance of Designer since there's no graphical objects those are deserialized.
TransformerDesigner tfd = transformer.createDesigner(mapToolPanel.getLinkPanel());
//mapToolPanel.getLinkPanel().add(tfd);
existingTransformers.put(transformer, tfd);
//transformer.beforeSerialization();
}
Record target = (Record) sourceNodes.get(paramContext.getArgument().getText());
//the output argument of transformer must be the source which should be linked in the first order
TransformerArgument source = transformer.getTransferArgument(transformerMapping.getLinkedArgumentName());
if(paramContext.isKey()){
target.setKeyType(Record.KEY);
}
try{
mapToolPanel.getModel().addLink(source, target);
}catch(Exception e){
e.printStackTrace();
}
new RecursiveLoop(){
@Override
public boolean logic(Object tree) {
return false;
}
@Override
public List getChildren(Object tree) {
if(tree instanceof TransformerMapping){
System.out.println();
}
// stops the recursive tracing when it meets the endpoints
if(!(tree instanceof Transformer)){
return null;
}
Transformer transformer = (Transformer)tree;
final ArrayList children = new ArrayList();
if(transformer.getInputArguments()!=null)
for(int i=0; i<transformer.getInputArguments().length; i++){
Object argumentSource = transformer.getArgumentSourceMap().get(transformer.getInputArguments()[i]);
TransformerArgument target = transformer.getTransferArgument(transformer.getInputArguments()[i]);
if(argumentSource==null) continue;
ArrayList argumentSources;
if(argumentSource instanceof ArrayList){
argumentSources = (ArrayList)argumentSource;
}else{
argumentSources = new ArrayList();
argumentSources.add(argumentSource);
}
for(int j=0; j<argumentSources.size(); j++){
argumentSource = argumentSources.get(j);
if(argumentSource instanceof TransformerMapping){
TransformerMapping priorTransformerMapping = (TransformerMapping) argumentSource;
Transformer priorTransformer = priorTransformerMapping.getTransformer();
argumentSource = priorTransformer;
if(!existingTransformers.containsKey(priorTransformer)){
TransformerDesigner tfd = priorTransformer.createDesigner(mapToolPanel.getLinkPanel());
existingTransformers.put(priorTransformer, tfd);
}
TransformerArgument priorTransformerArgument = priorTransformer.getTransferArgument(priorTransformerMapping.getLinkedArgumentName());
children.add(argumentSource);