All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.nakeduml.javageneration.bpm.actions.OpaqueActionBuilder Maven / Gradle / Ivy

The newest version!
package net.sf.nakeduml.javageneration.bpm.actions;

import net.sf.nakeduml.javageneration.NakedStructuralFeatureMap;
import net.sf.nakeduml.javageneration.util.OJUtil;
import net.sf.nakeduml.javametamodel.OJOperation;
import net.sf.nakeduml.javametamodel.annotation.OJAnnotatedField;
import net.sf.nakeduml.metamodel.actions.INakedOpaqueAction;
import nl.klasse.octopus.oclengine.IOclEngine;

public class OpaqueActionBuilder extends PotentialTaskActionBuilder{

	public OpaqueActionBuilder(IOclEngine oclEngine,INakedOpaqueAction node){
		super(oclEngine, node);
	}
	@Override
	public void implementActionOn(OJOperation operation){
		NakedStructuralFeatureMap map = OJUtil.buildStructuralFeatureMap(node,getOclEngine().getOclLibrary());
		OJAnnotatedField field = new OJAnnotatedField();
		field.setName(node.getMappingInfo().getJavaName().getDecapped().getAsIs());
		field.setType(OJUtil.classifierPathname(node.getMessageStructure()));
		field.setInitExp("new " + field.getType().getLast() + "()");
		operation.getBody().addToLocals(field);
		String taskVarName = field.getName();
		if(map.isCollection()){
			operation.getBody().addToStatements(map.adder() + "(" + taskVarName + ")");
		}else{
			operation.getBody().addToStatements(map.setter() + "(" + taskVarName + ")");
		}
		StringBuilder arguments = populateArguments(operation, node.getArguments());
		operation.getBody().addToStatements(taskVarName + ".execute(" + arguments + ")");
		createTaskVariable(operation.getOwner(), operation.getBody(), node, taskVarName);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy