public void addQaComponent(final WorkflowDescription workflowDescription, final String workflowContent,
final InputSource leftSource, final InputSource rightSource, final Map<String, String> parameters,
final List<String> measures, RelatedObject relatedObject) {
// Dataflow
NestedWorkflow qa = new NestedWorkflow(createProcessorName(workflowDescription.getName()),
workflowDescription.getDataflowId());
workflow.addProcessor(qa);
String dataflowContent = convertWorkflowToNested(workflowContent);
workflow.addDataflow(new Dataflow(workflowDescription.getDataflowId(), dataflowContent));
// Input ports
List<Port> inputPorts = workflowDescription.getInputPorts();
for (Port p : inputPorts) {
if (ComponentConstants.VALUE_LEFT_OBJECT.equals(p.getValue())) {
if (leftSource == InputSource.SOURCE_OBJECT) {
qa.addInputPort(new InputPort(p.getName(), 0));
workflow.addDatalink(new Datalink(workflow, SOURCE_PORT_NAME, qa, p.getName()));
} else if (leftSource == InputSource.TARGET_OBJECT) {
qa.addInputPort(new InputPort(p.getName(), 0));
workflow.addDatalink(new Datalink(migration, migrationTargetPortName, qa, p.getName()));
}
} else if (ComponentConstants.VALUE_RIGHT_OBJECT.equals(p.getValue())) {
if (rightSource == InputSource.SOURCE_OBJECT) {
qa.addInputPort(new InputPort(p.getName(), 0));
workflow.addDatalink(new Datalink(workflow, SOURCE_PORT_NAME, qa, p.getName()));
} else if (rightSource == InputSource.TARGET_OBJECT) {
qa.addInputPort(new InputPort(p.getName(), 0));
workflow.addDatalink(new Datalink(migration, migrationTargetPortName, qa, p.getName()));
}
} else if (ComponentConstants.VALUE_PARAMETER.equals(p.getValue())) {
qa.addInputPort(new InputPort(p.getName(), 0));
TextConstant c = new TextConstant(p.getName(), parameters.get(p.getName()));
workflow.addProcessor(c);
workflow.addDatalink(new Datalink(c, "value", qa, p.getName()));
}
}
// Output ports
List<Port> outputPorts = workflowDescription.getOutputPorts();
for (Port p : outputPorts) {
if (measures.contains(p.getValue())) {
if (p.getRelatedObject() == null || p.getRelatedObject().equals(relatedObject.toString())) {
String measurePortName = createMeasurePortName(p.getValue());
if (!workflow.hasSink(measurePortName)) {
addMeasurePort(p.getValue());
}
qa.addOutputPort(new OutputPort(p.getName()));
workflow.addDatalink(new Datalink(qa, p.getName(), workflow, measurePortName));
}
}
}
}