use of com.robotoworks.mechanoid.ops.opServiceModel.Operation in project mechanoid by robotoworks.
the class OpServiceModelGenerator method doGenerate.
public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
EList<EObject> _contents = resource.getContents();
EObject _head = IterableExtensions.<EObject>head(_contents);
Model model = ((Model) _head);
this.generateOperationProcessor(resource, fsa);
this.generateService(resource, fsa);
this.generateServiceConfiguration(resource, fsa);
this.generateOperationRegistry(resource, fsa);
ServiceBlock _service = model.getService();
EList<Operation> _ops = _service.getOps();
final Consumer<Operation> _function = new Consumer<Operation>() {
public void accept(final Operation item) {
OpServiceModelGenerator.this.generateOps(resource, fsa, item);
}
};
_ops.forEach(_function);
}
use of com.robotoworks.mechanoid.ops.opServiceModel.Operation in project mechanoid by robotoworks.
the class OperationRegistryGenerator method generate.
public CharSequence generate(final Model model) {
StringConcatenation _builder = new StringConcatenation();
ServiceBlock svc = model.getService();
_builder.newLineIfNotEmpty();
_builder.append("/*");
_builder.newLine();
_builder.append(" ");
_builder.append("* Generated by Robotoworks Mechanoid");
_builder.newLine();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("package ");
String _packageName = model.getPackageName();
_builder.append(_packageName, "");
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("import java.util.HashMap;");
_builder.newLine();
_builder.newLine();
_builder.append("import com.robotoworks.mechanoid.ops.OperationConfigurationRegistry;");
_builder.newLine();
_builder.append("import com.robotoworks.mechanoid.ops.OperationConfiguration;");
_builder.newLine();
_builder.newLine();
_builder.append("public abstract class Abstract");
String _name = svc.getName();
String _formatServiceName = Extensions.formatServiceName(_name);
_builder.append(_formatServiceName, "");
_builder.append("OperationConfigurationRegistry extends OperationConfigurationRegistry {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("private HashMap<String, OperationConfiguration> mOperationConfigurations;");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("public Abstract");
String _name_1 = svc.getName();
String _formatServiceName_1 = Extensions.formatServiceName(_name_1);
_builder.append(_formatServiceName_1, "\t");
_builder.append("OperationConfigurationRegistry() {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.newLine();
_builder.append("\t\t");
_builder.append("mOperationConfigurations = new HashMap<String, OperationConfiguration>();");
_builder.newLine();
_builder.append("\t\t");
_builder.newLine();
_builder.append("\t\t");
_builder.append("registerOperationConfigurations();");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("protected void registerOperationConfigurations(){");
_builder.newLine();
{
EList<Operation> _ops = svc.getOps();
for (final Operation op : _ops) {
_builder.append("\t\t");
_builder.append("registerOperationConfiguration(");
String _name_2 = op.getName();
String _pascalize = Strings.pascalize(_name_2);
_builder.append(_pascalize, "\t\t");
_builder.append("Operation.ACTION_");
String _name_3 = op.getName();
String _underscore = Strings.underscore(_name_3);
String _upperCase = _underscore.toUpperCase();
_builder.append(_upperCase, "\t\t");
_builder.append(", new ");
String _name_4 = op.getName();
String _pascalize_1 = Strings.pascalize(_name_4);
_builder.append(_pascalize_1, "\t\t");
_builder.append("Operation.Configuration());");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("protected void registerOperationConfiguration(String action, OperationConfiguration config) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("mOperationConfigurations.put(action, config);");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public OperationConfiguration getOperationConfiguration(String action) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("return mOperationConfigurations.get(action);");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
return _builder;
}
Aggregations