return resultGem;
}
private Gem appendGems(BasicCALServices calServices, GemGraph gemGraph, Gem gem1, Gem gem2) {
Gem appendGem = new FunctionalAgentGem(calServices.getGemEntity(QualifiedName.makeFromCompoundName("Cal.Samples.BusinessActivityMonitor.BAM.appendStrings")));
gemGraph.addGem(appendGem);
if ( !(gem1 instanceof ValueGem)) {
appendGem.getInputPart(0).setBurnt(true);
}
if ( !(gem2 instanceof ValueGem)) {
appendGem.getInputPart(1).setBurnt(true);
}
switch (appendGem.getTargetInputs().size()) {
case 2:
gemGraph.connectGems(gem1.getOutputPart(), appendGem.getInputPart(0));
gemGraph.connectGems(gem2.getOutputPart(), appendGem.getInputPart(1));
return appendGem;
case 1:
Gem mapGem = new FunctionalAgentGem(calServices.getGemEntity(CAL_List.Functions.map));
gemGraph.addGem(mapGem);
gemGraph.connectGems(appendGem.getOutputPart(), mapGem.getInputPart(0));
if (!(gem1 instanceof ValueGem)) {
gemGraph.connectGems(gem1.getOutputPart(), mapGem.getInputPart(1));
gemGraph.connectGems(gem2.getOutputPart(), appendGem.getInputPart(1));
} else {
gemGraph.connectGems(gem2.getOutputPart(), mapGem.getInputPart(1));
gemGraph.connectGems(gem1.getOutputPart(), appendGem.getInputPart(0));
}
return mapGem;
default:
Gem zipGem = new FunctionalAgentGem(calServices.getGemEntity(CAL_List.Functions.zipWith));
gemGraph.addGem(zipGem);
gemGraph.connectGems(appendGem.getOutputPart(), zipGem.getInputPart(0));
gemGraph.connectGems(gem1.getOutputPart(), zipGem.getInputPart(1));
gemGraph.connectGems(gem2.getOutputPart(), zipGem.getInputPart(2));
return zipGem;
}
}