blob: c81b21371d1eba9c86f5b94a294cb2eb3c8f5ec1 [file] [log] [blame]
/**
* Copyright (c) 2011, 2018 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
*
* generated by Xtext 2.11.0
*/
package org.eclipse.osbp.xtext.signal.jvmmodel;
import com.google.common.base.Objects;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.WatchEvent;
import java.util.Arrays;
import javax.inject.Inject;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.osbp.core.api.persistence.IPersistenceService;
import org.eclipse.osbp.datainterchange.api.IDataInterchange;
import org.eclipse.osbp.dsl.common.xtext.extensions.AnnotationExtension;
import org.eclipse.osbp.runtime.common.event.IEventDispatcher;
import org.eclipse.osbp.ui.api.customfields.IBlobService;
import org.eclipse.osbp.ui.api.metadata.IDSLMetadataService;
import org.eclipse.osbp.ui.api.user.IUser;
import org.eclipse.osbp.ui.api.useraccess.IUserAccessService;
import org.eclipse.osbp.xtext.datainterchange.DataInterchange;
import org.eclipse.osbp.xtext.datainterchange.DataInterchangeFile;
import org.eclipse.osbp.xtext.datainterchange.DataInterchangeFileCSV;
import org.eclipse.osbp.xtext.datainterchange.DataInterchangeFileEDI;
import org.eclipse.osbp.xtext.datainterchange.DataInterchangeFileXML;
import org.eclipse.osbp.xtext.datainterchange.DataInterchangePackage;
import org.eclipse.osbp.xtext.signal.SignalDSLPackage;
import org.eclipse.osbp.xtext.signal.SignalHandler;
import org.eclipse.osbp.xtext.signal.SignalHandling;
import org.eclipse.osbp.xtext.signal.SignalPackage;
import org.eclipse.osbp.xtext.signal.SignalTypeEnum;
import org.eclipse.osbp.xtext.signal.SignalWatcher;
import org.eclipse.osbp.xtext.signal.common.OSBPSignalWatcher;
import org.eclipse.osbp.xtext.signal.jvmmodel.SignalModelGenerator;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.common.types.JvmAnnotationReference;
import org.eclipse.xtext.common.types.JvmConstructor;
import org.eclipse.xtext.common.types.JvmField;
import org.eclipse.xtext.common.types.JvmFormalParameter;
import org.eclipse.xtext.common.types.JvmGenericType;
import org.eclipse.xtext.common.types.JvmMember;
import org.eclipse.xtext.common.types.JvmOperation;
import org.eclipse.xtext.common.types.JvmTypeReference;
import org.eclipse.xtext.common.types.JvmVisibility;
import org.eclipse.xtext.naming.IQualifiedNameProvider;
import org.eclipse.xtext.naming.QualifiedName;
import org.eclipse.xtext.xbase.compiler.output.ITreeAppendable;
import org.eclipse.xtext.xbase.jvmmodel.AbstractModelInferrer;
import org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor;
import org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.eclipse.xtext.xbase.lib.StringExtensions;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;
import org.slf4j.Logger;
/**
* <p>Infers a JVM model from the source model.</p>
*
* <p>The JVM model should contain all elements that would appear in the Java code
* which is generated from the source model. Other models link against the JVM model rather than the source model.</p>
*/
@SuppressWarnings("all")
public class SignalDSLJvmModelInferrer extends AbstractModelInferrer {
/**
* convenience API to build and initialize JVM types and their members.
*/
@Inject
@Extension
private JvmTypesBuilder _jvmTypesBuilder;
@Inject
@Extension
private IQualifiedNameProvider _iQualifiedNameProvider;
@Inject
@Extension
private SignalModelGenerator sg;
@Inject
@Extension
private AnnotationExtension _annotationExtension;
public static String pckgName = null;
private String binderClassName = "";
/**
* infer model on package base. Will be called for every defined package.
*
* @param dataInterchangePackage
* An instance of {@link SignalDSLPackage}
* @param acceptor
* the xtext acceptor interface
* @param isPreIndexingPhase
* true if in preindexing phase
*/
protected void _infer(final SignalPackage signalPackage, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) {
SignalDSLJvmModelInferrer.pckgName = signalPackage.getName();
String _firstUpper = StringExtensions.toFirstUpper(this._iQualifiedNameProvider.getFullyQualifiedName(signalPackage).getLastSegment());
String _plus = (_firstUpper + "ServiceBinder");
this.binderClassName = _plus;
JvmGenericType cls = this._jvmTypesBuilder.toClass(signalPackage, SignalDSLJvmModelInferrer.pckgName);
cls.setSimpleName(StringExtensions.toFirstUpper(cls.getSimpleName()));
EList<SignalWatcher> _watchers = signalPackage.getWatchers();
for (final SignalWatcher watcher : _watchers) {
{
QualifiedName watcherClass = this._iQualifiedNameProvider.getFullyQualifiedName(watcher);
final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
EList<JvmTypeReference> _superTypes = it.getSuperTypes();
JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(OSBPSignalWatcher.class);
this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _typeRef);
JvmAnnotationReference annotationRef = this._annotationTypesBuilder.annotationRef(Component.class);
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, annotationRef);
this.toWatcherFields(it, watcher);
this.toWatcherConstructor(it, watcher);
this.toWatcherOperations(it, watcher);
this._jvmTypesBuilder.setFileHeader(it, this._jvmTypesBuilder.getDocumentation(signalPackage));
EList<SignalHandler> _handlers = signalPackage.getHandlers();
for (final SignalHandler signalhandler : _handlers) {
SignalWatcher _watcher = signalhandler.getWatcher();
boolean _equals = Objects.equal(watcher, _watcher);
if (_equals) {
this.toHandlerOperations(it, watcher, signalhandler.getHandler());
}
}
};
acceptor.<JvmGenericType>accept(this._jvmTypesBuilder.toClass(watcher, watcherClass), _function);
}
}
cls = this._jvmTypesBuilder.toClass(signalPackage, SignalDSLJvmModelInferrer.pckgName.concat("ServiceBinder"));
cls.setSimpleName(StringExtensions.toFirstUpper(cls.getSimpleName()));
final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(SuppressWarnings.class, "serial");
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmAnnotationReference> _annotations_1 = it.getAnnotations();
JvmAnnotationReference _annotationRef_1 = this._annotationTypesBuilder.annotationRef(Component.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_1, _annotationRef_1);
this._jvmTypesBuilder.setFileHeader(it, this._jvmTypesBuilder.getDocumentation(signalPackage));
this.toBinderFields(it, signalPackage);
this.toBinderOperations(it, signalPackage);
};
acceptor.<JvmGenericType>accept(cls, _function);
}
public void toBinderFields(final JvmGenericType type, final SignalPackage signal) {
JvmField field = null;
final Procedure1<JvmField> _function = (JvmField it) -> {
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("org.slf4j.LoggerFactory.getLogger(\"servicebinder\")");
it_1.append(_builder);
};
this._jvmTypesBuilder.setInitializer(it, _function_1);
};
field = this._jvmTypesBuilder.toField(signal, "log", this._typeReferenceBuilder.typeRef(Logger.class), _function);
field.setStatic(true);
field.setVisibility(JvmVisibility.PRIVATE);
EList<JvmMember> _members = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members, field);
field = this._jvmTypesBuilder.toField(signal, "persistenceService", this._typeReferenceBuilder.typeRef(IPersistenceService.class));
field.setStatic(true);
field.setVisibility(JvmVisibility.PRIVATE);
EList<JvmMember> _members_1 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_1, field);
field = this._jvmTypesBuilder.toField(signal, "dataInterchange", this._typeReferenceBuilder.typeRef(IDataInterchange.class));
field.setStatic(true);
field.setVisibility(JvmVisibility.PRIVATE);
EList<JvmMember> _members_2 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_2, field);
field = this._jvmTypesBuilder.toField(signal, "userAccessService", this._typeReferenceBuilder.typeRef(IUserAccessService.class));
field.setStatic(true);
field.setVisibility(JvmVisibility.PRIVATE);
EList<JvmMember> _members_3 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_3, field);
field = this._jvmTypesBuilder.toField(signal, "blobService", this._typeReferenceBuilder.typeRef(IBlobService.class));
field.setStatic(true);
field.setVisibility(JvmVisibility.PRIVATE);
EList<JvmMember> _members_4 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_4, field);
}
public void toBinderOperations(final JvmGenericType type, final SignalPackage signal) {
EList<JvmMember> _members = type.getMembers();
final Procedure1<JvmOperation> _function = (JvmOperation it) -> {
it.setVisibility(JvmVisibility.PUBLIC);
it.setStatic(true);
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return dataInterchange;");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_1);
};
JvmOperation _method = this._jvmTypesBuilder.toMethod(signal, "getDataInterchange", this._typeReferenceBuilder.typeRef(IDataInterchange.class), _function);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method);
EList<JvmMember> _members_1 = type.getMembers();
final Procedure1<JvmOperation> _function_1 = (JvmOperation it) -> {
it.setVisibility(JvmVisibility.PUBLIC);
it.setStatic(true);
final Procedure1<ITreeAppendable> _function_2 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return blobService;");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_2);
};
JvmOperation _method_1 = this._jvmTypesBuilder.toMethod(signal, "getBlobService", this._typeReferenceBuilder.typeRef(IBlobService.class), _function_1);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_1, _method_1);
EList<JvmMember> _members_2 = type.getMembers();
final Procedure1<JvmOperation> _function_2 = (JvmOperation it) -> {
it.setVisibility(JvmVisibility.PUBLIC);
it.setStatic(true);
final Procedure1<ITreeAppendable> _function_3 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return persistenceService;");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_3);
};
JvmOperation _method_2 = this._jvmTypesBuilder.toMethod(signal, "getPersistenceService", this._typeReferenceBuilder.typeRef(IPersistenceService.class), _function_2);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_2, _method_2);
EList<JvmMember> _members_3 = type.getMembers();
final Procedure1<JvmOperation> _function_3 = (JvmOperation it) -> {
it.setVisibility(JvmVisibility.PUBLIC);
it.setStatic(true);
final Procedure1<ITreeAppendable> _function_4 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return userAccessService;");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_4);
};
JvmOperation _method_3 = this._jvmTypesBuilder.toMethod(signal, "getUserAccessService", this._typeReferenceBuilder.typeRef(IUserAccessService.class), _function_3);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_3, _method_3);
EList<JvmMember> _members_4 = type.getMembers();
final Procedure1<JvmOperation> _function_4 = (JvmOperation it) -> {
JvmAnnotationReference annotationRef = this._annotationTypesBuilder.annotationRef(Reference.class);
this._annotationExtension.addAnnAttr(annotationRef, signal, "cardinality", ReferenceCardinality.MANDATORY);
this._annotationExtension.addAnnAttr(annotationRef, signal, "policy", ReferencePolicy.STATIC);
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, annotationRef);
it.setVisibility(JvmVisibility.PUBLIC);
it.setSynchronized(true);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(signal, "dataInterchange", this._typeReferenceBuilder.typeRef(IDataInterchange.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_5 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _firstUpper = StringExtensions.toFirstUpper(this._iQualifiedNameProvider.getFullyQualifiedName(signal).getLastSegment());
String _plus = (_firstUpper + "ServiceBinder");
_builder.append(_plus);
_builder.append(".dataInterchange = dataInterchange;");
_builder.newLineIfNotEmpty();
_builder.append("log.debug(\"Signal DataInterchange bound\");");
_builder.newLine();
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_5);
};
JvmOperation _method_4 = this._jvmTypesBuilder.toMethod(signal, "bindDataInterchangeMethod", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_4);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_4, _method_4);
EList<JvmMember> _members_5 = type.getMembers();
final Procedure1<JvmOperation> _function_5 = (JvmOperation it) -> {
it.setVisibility(JvmVisibility.PUBLIC);
it.setSynchronized(true);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(signal, "dataInterchange", this._typeReferenceBuilder.typeRef(IDataInterchange.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_6 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _firstUpper = StringExtensions.toFirstUpper(this._iQualifiedNameProvider.getFullyQualifiedName(signal).getLastSegment());
String _plus = (_firstUpper + "ServiceBinder");
_builder.append(_plus);
_builder.append(".dataInterchange = null;");
_builder.newLineIfNotEmpty();
_builder.append("log.debug(\"Signal DataInterchange unbound\");");
_builder.newLine();
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_6);
};
JvmOperation _method_5 = this._jvmTypesBuilder.toMethod(signal, "unbindDataInterchangeMethod", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_5);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_5, _method_5);
EList<JvmMember> _members_6 = type.getMembers();
final Procedure1<JvmOperation> _function_6 = (JvmOperation it) -> {
JvmAnnotationReference annotationRef = this._annotationTypesBuilder.annotationRef(Reference.class);
this._annotationExtension.addAnnAttr(annotationRef, signal, "cardinality", ReferenceCardinality.MANDATORY);
this._annotationExtension.addAnnAttr(annotationRef, signal, "policy", ReferencePolicy.STATIC);
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, annotationRef);
it.setVisibility(JvmVisibility.PUBLIC);
it.setSynchronized(true);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(signal, "blobService", this._typeReferenceBuilder.typeRef(IBlobService.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_7 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _firstUpper = StringExtensions.toFirstUpper(this._iQualifiedNameProvider.getFullyQualifiedName(signal).getLastSegment());
String _plus = (_firstUpper + "ServiceBinder");
_builder.append(_plus);
_builder.append(".blobService = blobService;");
_builder.newLineIfNotEmpty();
_builder.append("log.debug(\"Signal BlobService bound\");");
_builder.newLine();
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_7);
};
JvmOperation _method_6 = this._jvmTypesBuilder.toMethod(signal, "bindBlobMethod", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_6);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_6, _method_6);
EList<JvmMember> _members_7 = type.getMembers();
final Procedure1<JvmOperation> _function_7 = (JvmOperation it) -> {
it.setVisibility(JvmVisibility.PUBLIC);
it.setSynchronized(true);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(signal, "blobService", this._typeReferenceBuilder.typeRef(IBlobService.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_8 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _firstUpper = StringExtensions.toFirstUpper(this._iQualifiedNameProvider.getFullyQualifiedName(signal).getLastSegment());
String _plus = (_firstUpper + "ServiceBinder");
_builder.append(_plus);
_builder.append(".blobService = null;");
_builder.newLineIfNotEmpty();
_builder.append("log.debug(\"Signal BlobService unbound\");");
_builder.newLine();
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_8);
};
JvmOperation _method_7 = this._jvmTypesBuilder.toMethod(signal, "unbindBlobMethod", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_7);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_7, _method_7);
EList<JvmMember> _members_8 = type.getMembers();
final Procedure1<JvmOperation> _function_8 = (JvmOperation it) -> {
JvmAnnotationReference annotationRef = this._annotationTypesBuilder.annotationRef(Reference.class);
this._annotationExtension.addAnnAttr(annotationRef, signal, "cardinality", ReferenceCardinality.MANDATORY);
this._annotationExtension.addAnnAttr(annotationRef, signal, "policy", ReferencePolicy.STATIC);
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, annotationRef);
it.setVisibility(JvmVisibility.PUBLIC);
it.setSynchronized(true);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(signal, "persistenceService", this._typeReferenceBuilder.typeRef(IPersistenceService.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_9 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _firstUpper = StringExtensions.toFirstUpper(this._iQualifiedNameProvider.getFullyQualifiedName(signal).getLastSegment());
String _plus = (_firstUpper + "ServiceBinder");
_builder.append(_plus);
_builder.append(".persistenceService = persistenceService;");
_builder.newLineIfNotEmpty();
_builder.append("log.debug(\"Signal PersistenceService bound\");");
_builder.newLine();
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_9);
};
JvmOperation _method_8 = this._jvmTypesBuilder.toMethod(signal, "bindPersistenceMethod", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_8);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_8, _method_8);
EList<JvmMember> _members_9 = type.getMembers();
final Procedure1<JvmOperation> _function_9 = (JvmOperation it) -> {
it.setVisibility(JvmVisibility.PUBLIC);
it.setSynchronized(true);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(signal, "persistenceService", this._typeReferenceBuilder.typeRef(IPersistenceService.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_10 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _firstUpper = StringExtensions.toFirstUpper(this._iQualifiedNameProvider.getFullyQualifiedName(signal).getLastSegment());
String _plus = (_firstUpper + "ServiceBinder");
_builder.append(_plus);
_builder.append(".persistenceService = null;");
_builder.newLineIfNotEmpty();
_builder.append("log.debug(\"Signal PersistenceService unbound\");");
_builder.newLine();
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_10);
};
JvmOperation _method_9 = this._jvmTypesBuilder.toMethod(signal, "unbindPersistenceMethod", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_9);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_9, _method_9);
EList<JvmMember> _members_10 = type.getMembers();
final Procedure1<JvmOperation> _function_10 = (JvmOperation it) -> {
JvmAnnotationReference annotationRef = this._annotationTypesBuilder.annotationRef(Reference.class);
this._annotationExtension.addAnnAttr(annotationRef, signal, "cardinality", ReferenceCardinality.MANDATORY);
this._annotationExtension.addAnnAttr(annotationRef, signal, "policy", ReferencePolicy.STATIC);
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, annotationRef);
it.setVisibility(JvmVisibility.PUBLIC);
it.setSynchronized(true);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(signal, "userAccessService", this._typeReferenceBuilder.typeRef(IUserAccessService.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_11 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _firstUpper = StringExtensions.toFirstUpper(this._iQualifiedNameProvider.getFullyQualifiedName(signal).getLastSegment());
String _plus = (_firstUpper + "ServiceBinder");
_builder.append(_plus);
_builder.append(".userAccessService = userAccessService;");
_builder.newLineIfNotEmpty();
_builder.append("log.debug(\"Signal UserAccessService bound\");");
_builder.newLine();
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_11);
};
JvmOperation _method_10 = this._jvmTypesBuilder.toMethod(signal, "bindUserAccessMethod", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_10);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_10, _method_10);
EList<JvmMember> _members_11 = type.getMembers();
final Procedure1<JvmOperation> _function_11 = (JvmOperation it) -> {
it.setVisibility(JvmVisibility.PUBLIC);
it.setSynchronized(true);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(signal, "userAccessService", this._typeReferenceBuilder.typeRef(IUserAccessService.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_12 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _firstUpper = StringExtensions.toFirstUpper(this._iQualifiedNameProvider.getFullyQualifiedName(signal).getLastSegment());
String _plus = (_firstUpper + "ServiceBinder");
_builder.append(_plus);
_builder.append(".userAccessService = null;");
_builder.newLineIfNotEmpty();
_builder.append("log.debug(\"Signal UserAccessService unbound\");");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_12);
};
JvmOperation _method_11 = this._jvmTypesBuilder.toMethod(signal, "unbindUserAccessMethod", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_11);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_11, _method_11);
}
public void toHandlerOperations(final JvmGenericType type, final SignalWatcher watcher, final SignalHandling handling) {
EList<JvmMember> _members = type.getMembers();
final Procedure1<JvmOperation> _function = (JvmOperation it) -> {
DataInterchange _dataRef = handling.getDataRef();
final DataInterchange ref = ((DataInterchange) _dataRef);
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _executeImport = this.executeImport(ref);
_builder.append(_executeImport);
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_1);
};
JvmOperation _method = this._jvmTypesBuilder.toMethod(watcher, "executeImport", this._typeReferenceBuilder.typeRef(Void.TYPE), _function);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method);
}
public String executeImport(final DataInterchange dataInterchange) {
StringConcatenation _builder = new StringConcatenation();
String _basicRunConfiguration = this.getBasicRunConfiguration(dataInterchange, true, this.getFileURL(dataInterchange), "IMPORT");
_builder.append(_basicRunConfiguration);
_builder.newLineIfNotEmpty();
String _defaultVariableName = this.getDefaultVariableName(dataInterchange);
_builder.append(_defaultVariableName);
_builder.append(".setDirection(WorkerThreadRunnable.Direction.IMPORT);");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("// later for notification in the dialog");
_builder.newLine();
_builder.append("//Notification.show(dslMetadataService.translate(user.getLocale().toLanguageTag(), \"datainterchangeStarted\"),Notification.Type.HUMANIZED_MESSAGE);");
_builder.newLine();
_builder.newLine();
_builder.append("//execution of code now\t\t");
_builder.newLine();
String _defaultVariableName_1 = this.getDefaultVariableName(dataInterchange);
_builder.append(_defaultVariableName_1);
_builder.append(".run();");
_builder.newLineIfNotEmpty();
return _builder.toString();
}
public String getFileURL(final DataInterchange dataInterchange) {
DataInterchangeFile _fileEndpoint = dataInterchange.getFileEndpoint();
boolean _matched = false;
if (_fileEndpoint instanceof DataInterchangeFileXML) {
_matched=true;
DataInterchangeFile _fileEndpoint_1 = dataInterchange.getFileEndpoint();
return ((DataInterchangeFileXML) _fileEndpoint_1).getFileURL();
}
if (!_matched) {
if (_fileEndpoint instanceof DataInterchangeFileCSV) {
_matched=true;
DataInterchangeFile _fileEndpoint_1 = dataInterchange.getFileEndpoint();
return ((DataInterchangeFileCSV) _fileEndpoint_1).getFileURL();
}
}
if (!_matched) {
if (_fileEndpoint instanceof DataInterchangeFileEDI) {
_matched=true;
DataInterchangeFile _fileEndpoint_1 = dataInterchange.getFileEndpoint();
return ((DataInterchangeFileEDI) _fileEndpoint_1).getFileURL();
}
}
return "";
}
public String getDefaultVariableName(final DataInterchange dataInterchange) {
return StringExtensions.toFirstLower(dataInterchange.getName());
}
public String getBasicRunConfiguration(final DataInterchange dataInterchange, final boolean fqClass, final String fileURL, final String direction) {
String className = "";
if (fqClass) {
className = this._iQualifiedNameProvider.getFullyQualifiedName(dataInterchange).toString();
} else {
className = dataInterchange.getName();
}
StringConcatenation _builder = new StringConcatenation();
_builder.append(className);
_builder.append(" ");
String _defaultVariableName = this.getDefaultVariableName(dataInterchange);
_builder.append(_defaultVariableName);
_builder.append(" = new ");
_builder.append(className);
_builder.append("();");
_builder.newLineIfNotEmpty();
_builder.append("String url = \"\"; //ProductConfiguration.getDatainterchangeConfiguration();");
_builder.newLine();
_builder.append("//if(url.isEmpty()) {");
_builder.newLine();
_builder.append("//\turl = System.getProperty(\"user.home\")+\"/.osbee/\"+\"");
EObject _eContainer = dataInterchange.eContainer();
String _title = ((DataInterchangePackage) _eContainer).getTitle();
_builder.append(_title);
_builder.append("Config.xml\";");
_builder.newLineIfNotEmpty();
_builder.append("//}");
_builder.newLine();
_builder.append("File file = new File(url);");
_builder.newLine();
_builder.append("if(file.exists()) {");
_builder.newLine();
_builder.append("\t");
_builder.append("FileInputStream fileInput;");
_builder.newLine();
_builder.append("\t");
_builder.append("try {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("fileInput = new FileInputStream(file);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("Properties properties = new Properties();");
_builder.newLine();
_builder.append("\t\t");
_builder.append("properties.loadFromXML(fileInput);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("fileInput.close();");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if(properties.getProperty(\"");
String _name = dataInterchange.getName();
_builder.append(_name, "\t\t");
_builder.append("-");
String _lowerCase = direction.toLowerCase();
_builder.append(_lowerCase, "\t\t");
_builder.append("\") == null) {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t\t");
String _defaultVariableName_1 = this.getDefaultVariableName(dataInterchange);
_builder.append(_defaultVariableName_1, "\t\t\t");
_builder.append(".setFileURL(\"");
_builder.append(fileURL, "\t\t\t");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("} else {");
_builder.newLine();
_builder.append("\t\t\t");
String _defaultVariableName_2 = this.getDefaultVariableName(dataInterchange);
_builder.append(_defaultVariableName_2, "\t\t\t");
_builder.append(".setFileURL(properties.getProperty(\"");
String _name_1 = dataInterchange.getName();
_builder.append(_name_1, "\t\t\t");
_builder.append("-");
String _lowerCase_1 = direction.toLowerCase();
_builder.append(_lowerCase_1, "\t\t\t");
_builder.append("\"));");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("} catch (IOException e) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("StringWriter sw = new StringWriter();");
_builder.newLine();
_builder.append("\t\t");
_builder.append("e.printStackTrace(new PrintWriter(sw));");
_builder.newLine();
_builder.append("\t\t");
_builder.append("log.error(\"{}\", sw.toString());");
_builder.newLine();
_builder.append("\t\t");
_builder.append("return;");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("} else {");
_builder.newLine();
_builder.append("\t");
String _defaultVariableName_3 = this.getDefaultVariableName(dataInterchange);
_builder.append(_defaultVariableName_3, "\t");
_builder.append(".setFileURL(\"");
_builder.append(fileURL, "\t");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
String _defaultVariableName_4 = this.getDefaultVariableName(dataInterchange);
_builder.append(_defaultVariableName_4);
_builder.append(".setPersistenceService(persistenceService);");
_builder.newLineIfNotEmpty();
String _defaultVariableName_5 = this.getDefaultVariableName(dataInterchange);
_builder.append(_defaultVariableName_5);
_builder.append(".setDataInterchange(dataInterchange);");
_builder.newLineIfNotEmpty();
String _defaultVariableName_6 = this.getDefaultVariableName(dataInterchange);
_builder.append(_defaultVariableName_6);
_builder.append(".setEventDispatcher(eventDispatcher);");
_builder.newLineIfNotEmpty();
String _defaultVariableName_7 = this.getDefaultVariableName(dataInterchange);
_builder.append(_defaultVariableName_7);
_builder.append(".setBlobService(blobService);");
_builder.newLineIfNotEmpty();
return _builder.toString();
}
public void toWatcherOperations(final JvmGenericType type, final SignalWatcher watcher) {
EList<JvmMember> _members = type.getMembers();
final Procedure1<JvmOperation> _function = (JvmOperation it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(watcher, "directory", this._typeReferenceBuilder.typeRef(Path.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
EList<JvmFormalParameter> _parameters_1 = it.getParameters();
JvmFormalParameter _parameter_1 = this._jvmTypesBuilder.toParameter(watcher, "signals", this._typeReferenceBuilder.typeRef(String.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1);
EList<JvmTypeReference> _exceptions = it.getExceptions();
JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(IOException.class);
this._jvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, _typeRef);
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _registerPathToWatcher = this.registerPathToWatcher(watcher);
_builder.append(_registerPathToWatcher);
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_1);
};
JvmOperation _method = this._jvmTypesBuilder.toMethod(watcher, "registerPathToWatcher", this._typeReferenceBuilder.typeRef(Void.TYPE), _function);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method);
EList<JvmMember> _members_1 = type.getMembers();
final Procedure1<JvmOperation> _function_1 = (JvmOperation it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(watcher, "rootpath", this._typeReferenceBuilder.typeRef(Path.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
EList<JvmFormalParameter> _parameters_1 = it.getParameters();
JvmFormalParameter _parameter_1 = this._jvmTypesBuilder.toParameter(watcher, "signals", this._typeReferenceBuilder.typeRef(String.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1);
EList<JvmTypeReference> _exceptions = it.getExceptions();
JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(IOException.class);
this._jvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, _typeRef);
final Procedure1<ITreeAppendable> _function_2 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _registerAll = this.registerAll(watcher);
_builder.append(_registerAll);
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_2);
};
JvmOperation _method_1 = this._jvmTypesBuilder.toMethod(watcher, "registerAll", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_1);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_1, _method_1);
EList<JvmMember> _members_2 = type.getMembers();
final Procedure1<JvmOperation> _function_2 = (JvmOperation it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(watcher, "event", this._typeReferenceBuilder.typeRef(WatchEvent.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_3 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _handleEvent = this.getHandleEvent(watcher);
_builder.append(_handleEvent);
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_3);
};
JvmOperation _method_2 = this._jvmTypesBuilder.toMethod(watcher, "handleEvent", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_2);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_2, _method_2);
EList<JvmMember> _members_3 = type.getMembers();
final Procedure1<JvmOperation> _function_3 = (JvmOperation it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
final Procedure1<ITreeAppendable> _function_4 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _processEvents = this.getProcessEvents(watcher);
_builder.append(_processEvents);
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_4);
};
JvmOperation _method_3 = this._jvmTypesBuilder.toMethod(watcher, "processEvents", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_3);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_3, _method_3);
EList<JvmMember> _members_4 = type.getMembers();
final Procedure1<JvmOperation> _function_4 = (JvmOperation it) -> {
EList<JvmTypeReference> _exceptions = it.getExceptions();
JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(IOException.class);
this._jvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, _typeRef);
final Procedure1<ITreeAppendable> _function_5 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _start = this.getStart(watcher);
_builder.append(_start);
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_5);
};
JvmOperation _method_4 = this._jvmTypesBuilder.toMethod(watcher, "start", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_4);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_4, _method_4);
EList<JvmMember> _members_5 = type.getMembers();
final Procedure1<JvmOperation> _function_5 = (JvmOperation it) -> {
EList<JvmTypeReference> _exceptions = it.getExceptions();
JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(IOException.class);
this._jvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, _typeRef);
final Procedure1<ITreeAppendable> _function_6 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _stop = this.getStop(watcher);
_builder.append(_stop);
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_6);
};
JvmOperation _method_5 = this._jvmTypesBuilder.toMethod(watcher, "stop", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_5);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_5, _method_5);
}
public void toWatcherFields(final JvmGenericType type, final SignalWatcher watcher) {
JvmField field = null;
final Procedure1<JvmField> _function = (JvmField it) -> {
it.setVisibility(JvmVisibility.PRIVATE);
};
field = this._jvmTypesBuilder.toField(watcher, "eventDispatcher", this._typeReferenceBuilder.typeRef(IEventDispatcher.class), _function);
EList<JvmMember> _members = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members, field);
final Procedure1<JvmField> _function_1 = (JvmField it) -> {
it.setVisibility(JvmVisibility.PRIVATE);
};
field = this._jvmTypesBuilder.toField(watcher, "persistenceService", this._typeReferenceBuilder.typeRef(IPersistenceService.class), _function_1);
EList<JvmMember> _members_1 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_1, field);
final Procedure1<JvmField> _function_2 = (JvmField it) -> {
it.setVisibility(JvmVisibility.PRIVATE);
};
field = this._jvmTypesBuilder.toField(watcher, "dataInterchange", this._typeReferenceBuilder.typeRef(IDataInterchange.class), _function_2);
EList<JvmMember> _members_2 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_2, field);
final Procedure1<JvmField> _function_3 = (JvmField it) -> {
it.setVisibility(JvmVisibility.PRIVATE);
};
field = this._jvmTypesBuilder.toField(watcher, "dslMetadataService", this._typeReferenceBuilder.typeRef(IDSLMetadataService.class), _function_3);
EList<JvmMember> _members_3 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_3, field);
final Procedure1<JvmField> _function_4 = (JvmField it) -> {
it.setVisibility(JvmVisibility.PRIVATE);
};
field = this._jvmTypesBuilder.toField(watcher, "blobService", this._typeReferenceBuilder.typeRef(IBlobService.class), _function_4);
EList<JvmMember> _members_4 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_4, field);
final Procedure1<JvmField> _function_5 = (JvmField it) -> {
it.setVisibility(JvmVisibility.PRIVATE);
};
field = this._jvmTypesBuilder.toField(watcher, "user", this._typeReferenceBuilder.typeRef(IUser.class), _function_5);
EList<JvmMember> _members_5 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_5, field);
final Procedure1<JvmField> _function_6 = (JvmField it) -> {
it.setVisibility(JvmVisibility.PRIVATE);
};
field = this._jvmTypesBuilder.toField(watcher, "eclipseContext", this._typeReferenceBuilder.typeRef(IEclipseContext.class), _function_6);
EList<JvmMember> _members_6 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_6, field);
final Procedure1<JvmField> _function_7 = (JvmField it) -> {
final Procedure1<ITreeAppendable> _function_8 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("LoggerFactory.getLogger(\"watcher\")");
it_1.append(_builder);
};
this._jvmTypesBuilder.setInitializer(it, _function_8);
it.setVisibility(JvmVisibility.PRIVATE);
};
field = this._jvmTypesBuilder.toField(watcher, "log", this._typeReferenceBuilder.typeRef(Logger.class), _function_7);
EList<JvmMember> _members_7 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_7, field);
final Procedure1<JvmField> _function_8 = (JvmField it) -> {
final Procedure1<ITreeAppendable> _function_9 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("\"");
String _directory = watcher.getDirectory();
_builder.append(_directory);
_builder.append("\"");
it_1.append(_builder);
};
this._jvmTypesBuilder.setInitializer(it, _function_9);
it.setVisibility(JvmVisibility.PRIVATE);
};
field = this._jvmTypesBuilder.toField(watcher, "path", this._typeReferenceBuilder.typeRef(String.class), _function_8);
EList<JvmMember> _members_8 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_8, field);
final Procedure1<JvmField> _function_9 = (JvmField it) -> {
final Procedure1<ITreeAppendable> _function_10 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("SignalTypeEnum.");
String _upperCase = watcher.getSignal().getLiteral().toUpperCase();
_builder.append(_upperCase);
it_1.append(_builder);
};
this._jvmTypesBuilder.setInitializer(it, _function_10);
it.setVisibility(JvmVisibility.PRIVATE);
};
field = this._jvmTypesBuilder.toField(watcher, "signal", this._typeReferenceBuilder.typeRef(SignalTypeEnum.class), _function_9);
EList<JvmMember> _members_9 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_9, field);
}
public void toWatcherConstructor(final JvmGenericType type, final SignalWatcher watcher) {
EList<JvmMember> _members = type.getMembers();
final Procedure1<JvmConstructor> _function = (JvmConstructor it) -> {
EList<JvmTypeReference> _exceptions = it.getExceptions();
JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(IOException.class);
this._jvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, _typeRef);
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("super();");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_1);
};
JvmConstructor _constructor = this._jvmTypesBuilder.toConstructor(watcher, _function);
this._jvmTypesBuilder.<JvmConstructor>operator_add(_members, _constructor);
}
public String registerAll(final SignalWatcher watcher) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("//TODO enter the register logic here");
_builder.newLine();
_builder.append("super.registerAll(rootpath, signals);");
_builder.newLine();
return _builder.toString();
}
public String registerPathToWatcher(final SignalWatcher watcher) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("if (signals != null && !signals.isEmpty()) {");
_builder.newLine();
_builder.append("\t");
_builder.append("boolean iscreate = signals.contains(StandardWatchEventKinds.ENTRY_CREATE.toString());");
_builder.newLine();
_builder.append("\t");
_builder.append("boolean isdelete = signals.contains(StandardWatchEventKinds.ENTRY_DELETE.toString());");
_builder.newLine();
_builder.append("\t");
_builder.append("boolean ismodify = signals.contains(StandardWatchEventKinds.ENTRY_MODIFY.toString());");
_builder.newLine();
_builder.append("\t");
_builder.append("// create one key for all kind of changes");
_builder.newLine();
_builder.append("\t");
_builder.append("// and save the key for later use");
_builder.newLine();
_builder.append("\t");
_builder.append("// TODO only applicable with xtext generation");
_builder.newLine();
_builder.append("\t");
_builder.append("// keys.put(directory.register(watcher, iscreate ? StandardWatchEventKinds.ENTRY_CREATE :");
_builder.newLine();
_builder.append("\t");
_builder.append("// null,");
_builder.newLine();
_builder.append("\t");
_builder.append("// isdelete ? StandardWatchEventKinds.ENTRY_DELETE : null, ismodify ? StandardWatchEventKinds.ENTRY_MODIFY : null),");
_builder.newLine();
_builder.append("\t");
_builder.append("// directory);");
_builder.newLine();
_builder.append("\t");
_builder.append("getRegisteredKeysAndPaths().put(directory.register(getWatcher(), StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_DELETE, StandardWatchEventKinds.ENTRY_MODIFY), directory);");
_builder.newLine();
_builder.append("} else {");
_builder.newLine();
_builder.append("\t");
_builder.append("// if none signals have been given by the user,");
_builder.newLine();
_builder.append("\t");
_builder.append("// create a default key for all kind of changes");
_builder.newLine();
_builder.append("\t");
_builder.append("// and save the key for later use");
_builder.newLine();
_builder.append("\t");
_builder.append("getRegisteredKeysAndPaths().put(directory.register(getWatcher(), StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_DELETE, StandardWatchEventKinds.ENTRY_MODIFY), directory);");
_builder.newLine();
_builder.append("}");
_builder.newLine();
return _builder.toString();
}
public String getHandleEvent(final SignalWatcher watcher) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("//super.handleEvent(event);");
_builder.newLine();
_builder.newLine();
_builder.append("Path filename = ((WatchEvent<Path>) event).context().getFileName();");
_builder.newLine();
_builder.newLine();
_builder.append("// get what to do based on the filename");
_builder.newLine();
_builder.append("SignalActionEnum action = super.checkFileMask(filename.toString());");
_builder.newLine();
_builder.newLine();
_builder.append("if (event.kind() == StandardWatchEventKinds.ENTRY_CREATE && !action.equals(SignalActionEnum.NONE)) {");
_builder.newLine();
_builder.append("\t");
_builder.append("switch (action) {");
_builder.newLine();
_builder.append("\t");
_builder.append("case DATAIMPORT:");
_builder.newLine();
_builder.append("\t\t");
_builder.append("executeImport();");
_builder.newLine();
_builder.append("\t\t");
_builder.append("break;");
_builder.newLine();
_builder.append("\t");
_builder.append("default: // do nothing");
_builder.newLine();
_builder.append("\t\t");
_builder.append("break;");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
return _builder.toString();
}
public String getStart(final SignalWatcher watcher) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("super.startWatcher(path, signal);");
_builder.newLine();
return _builder.toString();
}
public String getStop(final SignalWatcher watcher) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("// stop the service");
_builder.newLine();
_builder.append("super.getWatcher().close();");
_builder.newLine();
return _builder.toString();
}
public String getProcessEvents(final SignalWatcher watcher) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("super.processEvents();");
_builder.newLine();
return _builder.toString();
}
public void infer(final EObject signalPackage, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) {
if (signalPackage instanceof SignalPackage) {
_infer((SignalPackage)signalPackage, acceptor, isPreIndexingPhase);
return;
} else if (signalPackage != null) {
_infer(signalPackage, acceptor, isPreIndexingPhase);
return;
} else {
throw new IllegalArgumentException("Unhandled parameter types: " +
Arrays.<Object>asList(signalPackage, acceptor, isPreIndexingPhase).toString());
}
}
}