Search in sources :

Example 26 with Entity

use of org.applause.lang.applauseDsl.Entity in project applause by applause.

the class EntityDataAccessExtensions method resourceType.

public Entity resourceType(final DataSourceAccessMethod it) {
    EObject _eContainer = it.eContainer();
    Entity _resourceType = ((DataSource) _eContainer).getResourceType();
    return _resourceType;
}
Also used : Entity(org.applause.lang.applauseDsl.Entity) EObject(org.eclipse.emf.ecore.EObject) DataSource(org.applause.lang.applauseDsl.DataSource)

Example 27 with Entity

use of org.applause.lang.applauseDsl.Entity in project applause by applause.

the class EntityDataAccessModuleFileCompiler method compileModuleFile.

public CharSequence compileModuleFile(final DataSource it) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("#import \"");
    Entity _resourceType = it.getResourceType();
    String _entityDataAccessCategoryHeaderFileName = this._dataAccessClassExtensions.entityDataAccessCategoryHeaderFileName(_resourceType);
    _builder.append(_entityDataAccessCategoryHeaderFileName, "");
    _builder.append("\"");
    _builder.newLineIfNotEmpty();
    _builder.append("#import \"");
    Entity _resourceType_1 = it.getResourceType();
    String _apiClientClassName = this._aPIClientClassExtensions.apiClientClassName(_resourceType_1);
    String _headerFileName = this._fileNameExtensions.headerFileName(_apiClientClassName);
    _builder.append(_headerFileName, "");
    _builder.append("\"");
    _builder.newLineIfNotEmpty();
    _builder.append("#import \"");
    Entity _resourceType_2 = it.getResourceType();
    String _mappingClassName = this.mappingClassName(_resourceType_2);
    String _headerFileName_1 = this._fileNameExtensions.headerFileName(_mappingClassName);
    _builder.append(_headerFileName_1, "");
    _builder.append("\"");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("@implementation ");
    Entity _resourceType_3 = it.getResourceType();
    String _typeName = this._typeExtensions.typeName(_resourceType_3);
    _builder.append(_typeName, "");
    _builder.append(" (DataAccess)");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    {
        EList<DataSourceAccessMethod> _methods = it.getMethods();
        for (final DataSourceAccessMethod method : _methods) {
            CharSequence _compileRESTMethod = this.compileRESTMethod(method);
            _builder.append(_compileRESTMethod, "");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
        }
    }
    _builder.append("@end");
    _builder.newLine();
    return _builder;
}
Also used : Entity(org.applause.lang.applauseDsl.Entity) EList(org.eclipse.emf.common.util.EList) DataSourceAccessMethod(org.applause.lang.applauseDsl.DataSourceAccessMethod) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 28 with Entity

use of org.applause.lang.applauseDsl.Entity in project applause by applause.

the class EntityDataAccessModuleFileCompiler method compilePUTMethod.

public CharSequence compilePUTMethod(final DataSourceAccessMethod it) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("static NSString *const ");
    String _urlConstantForRESTMethod = this.urlConstantForRESTMethod(it);
    _builder.append(_urlConstantForRESTMethod, "");
    _builder.append(" = @\"");
    RESTSpecification _restSpecification = it.getRestSpecification();
    RESTURL _path = _restSpecification.getPath();
    String _value = this._rESTURLExtensions.value(_path);
    _builder.append(_value, "");
    _builder.append("\";");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("- (void)");
    String _name = it.getName();
    _builder.append(_name, "");
    _builder.append(":(void (^)(");
    String _parameterList = this._entityDataAccessExtensions.parameterList(it);
    _builder.append(_parameterList, "");
    _builder.append(", NSError *error))block");
    _builder.newLineIfNotEmpty();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("NSDictionary *elementDictionary = [self attributes];");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("[[");
    Entity _resourceType = this._entityDataAccessExtensions.resourceType(it);
    String _apiClientClassName = this._aPIClientClassExtensions.apiClientClassName(_resourceType);
    _builder.append(_apiClientClassName, "	");
    _builder.append(" sharedClient] PUT:");
    String _urlConstantForRESTMethod_1 = this.urlConstantForRESTMethod(it);
    _builder.append(_urlConstantForRESTMethod_1, "	");
    _builder.append(" parameters:elementDictionary success:^(NSURLSessionDataTask *task, id responseObject)");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t\t");
    Entity _resourceType_1 = this._entityDataAccessExtensions.resourceType(it);
    String _typeName = this._typeExtensions.typeName(_resourceType_1);
    _builder.append(_typeName, "		");
    _builder.append(" *postedElement = responseObject;");
    _builder.newLineIfNotEmpty();
    _builder.append("\t\t");
    _builder.append("if(block) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("block(postedElement, nil);");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("} failure:^(NSURLSessionDataTask *task, NSError *error)");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("if(block) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("block(nil, error);");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}];");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    return _builder;
}
Also used : Entity(org.applause.lang.applauseDsl.Entity) RESTSpecification(org.applause.lang.applauseDsl.RESTSpecification) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) RESTURL(org.applause.lang.applauseDsl.RESTURL)

Example 29 with Entity

use of org.applause.lang.applauseDsl.Entity in project applause by applause.

the class APIClientGeneratorSpec method isGeneratedModuleFileFromModel.

public void isGeneratedModuleFileFromModel(final CharSequence expectedGeneratedCode, final String entityName, final CharSequence input) {
    final Entity entity = this.entity(input, entityName);
    final CharSequence result = this._aPIClientModuleFileCompiler.compileModuleFile(entity);
    String _string = result.toString();
    String _string_1 = expectedGeneratedCode.toString();
    Matcher<String> _equalTo = CoreMatchers.<String>equalTo(_string_1);
    Assert.<String>assertThat(_string, _equalTo);
}
Also used : Entity(org.applause.lang.applauseDsl.Entity)

Example 30 with Entity

use of org.applause.lang.applauseDsl.Entity in project applause by applause.

the class APIClientGeneratorSpec method isGeneratedHeaderFileFromModel.

public void isGeneratedHeaderFileFromModel(final CharSequence expectedGeneratedCode, final String entityName, final CharSequence input) {
    final Entity entity = this.entity(input, entityName);
    final CharSequence result = this._aPIClientHeaderFileCompiler.compileHeaderFile(entity);
    String _string = result.toString();
    String _string_1 = expectedGeneratedCode.toString();
    Matcher<String> _equalTo = CoreMatchers.<String>equalTo(_string_1);
    Assert.<String>assertThat(_string, _equalTo);
}
Also used : Entity(org.applause.lang.applauseDsl.Entity)

Aggregations

Entity (org.applause.lang.applauseDsl.Entity)34 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)17 DataSource (org.applause.lang.applauseDsl.DataSource)5 Model (org.applause.lang.applauseDsl.Model)5 NamedElement (org.applause.lang.applauseDsl.NamedElement)5 DataSourceAccessMethod (org.applause.lang.applauseDsl.DataSourceAccessMethod)4 RESTSpecification (org.applause.lang.applauseDsl.RESTSpecification)4 RESTURL (org.applause.lang.applauseDsl.RESTURL)4 Attribute (org.applause.lang.applauseDsl.Attribute)3 DataSourceCall (org.applause.lang.applauseDsl.DataSourceCall)3 Screen (org.applause.lang.applauseDsl.Screen)3 EList (org.eclipse.emf.common.util.EList)3 EObject (org.eclipse.emf.ecore.EObject)2 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 Type (org.applause.lang.applauseDsl.Type)1 UIComponentMemberConfiguration (org.applause.lang.applauseDsl.UIComponentMemberConfiguration)1 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)1 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)1