private Instance getConnectorConfiguration(Model model, StringToExpressionConverter converter) { final Instance configuration = model.newInstance("connectorconfiguration.ConnectorConfiguration"); configuration.set("definitionId", getDefinitionId()); configuration.set("version", getDefinitionVersion()); final Map<String, Object> additionalInputs = definitionMapper.getAdditionalInputs(inputs); final Map<String, Object> allInput = new HashMap<String, Object>(inputs); allInput.putAll(additionalInputs); for (Entry<String, Object> input : allInput.entrySet()) { final String parameterKeyFor = getParameterKeyFor(input.getKey()); if (parameterKeyFor != null) { final Instance parameter = model.newInstance("connectorconfiguration.ConnectorParameter"); parameter.set("key", parameterKeyFor); parameter.set( "expression", getParameterExpressionFor( model, parameterKeyFor, converter, definitionMapper.transformParameterValue(parameterKeyFor, input.getValue(), inputs), getReturnType(parameterKeyFor))); configuration.add("parameters", parameter); } else { if (BonitaStudioLog.isLoggable(IStatus.OK)) { BonitaStudioLog.debug( input.getKey() + " not mapped for " + getDefinitionId(), BarImporterPlugin.PLUGIN_ID); } } } return configuration; }
private void createOperation( Model model, Instance connectorInstance, StringToExpressionConverter converter, final String variableToSet, final String varValue) { Instance operationContainerInstance = connectorInstance.getContainer(); Instance originalVariable = getOriginalVariable(model, variableToSet); // set variable dependency of left operand String returnType = Object.class.getName(); Instance leftOperand = null; if (originalVariable != null) { returnType = StringToExpressionConverter.getDataReturnType(originalVariable); leftOperand = StringToExpressionConverter.createExpressionInstanceWithDependency( model, variableToSet, variableToSet, returnType, ExpressionConstants.VARIABLE_TYPE, true, originalVariable); } else { leftOperand = StringToExpressionConverter.createExpressionInstance( model, variableToSet, variableToSet, returnType, ExpressionConstants.VARIABLE_TYPE, true); } Instance rightOperand = converter.parse(varValue, returnType, false); Instance operatorInstance = model.newInstance("expression.Operator"); operatorInstance.set("type", ExpressionConstants.ASSIGNMENT_OPERATOR); Instance operationInstance = model.newInstance("expression.Operation"); operationInstance.set("leftOperand", leftOperand); operationInstance.set("rightOperand", rightOperand); operationInstance.set("operator", operatorInstance); operationContainerInstance.add("operations", operationInstance); }
private void populateNewConnectorInstance( Model model, Instance connectorInstance, StringToExpressionConverter converter) { connectorInstance.set(NAME, name); connectorInstance.set(DOCUMENTATION, documentation); connectorInstance.set(DEFINITION_ID, getDefinitionId()); connectorInstance.set(DEFINITION_VERSION, getDefinitionVersion()); connectorInstance.set(ERROR_HANDLE, ignoreErrors); connectorInstance.set(EVENT, toConnectorEvent(event)); connectorInstance.set(CONNECTOR_CONFIGURATION, getConnectorConfiguration(model, converter)); addOutputs(model, connectorInstance, converter); }