Search in sources :

Example 96 with StringConcatenation

use of org.eclipse.xtend2.lib.StringConcatenation in project applause by applause.

the class EntityDataAccessHeaderFileCompiler method compileHeaderFile.

public CharSequence compileHeaderFile(final DataSource it) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("#import <Foundation/Foundation.h>");
    _builder.newLine();
    _builder.append("#import \"");
    Entity _resourceType = it.getResourceType();
    String _entityModelHeaderFileName = this._entityClassExtensions.entityModelHeaderFileName(_resourceType);
    _builder.append(_entityModelHeaderFileName, "");
    _builder.append("\"");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("@interface ");
    Entity _resourceType_1 = it.getResourceType();
    String _typeName = this._typeExtensions.typeName(_resourceType_1);
    _builder.append(_typeName, "");
    _builder.append(" (DataAccess)");
    _builder.newLineIfNotEmpty();
    {
        EList<DataSourceAccessMethod> _methods = it.getMethods();
        for (final DataSourceAccessMethod method : _methods) {
            CharSequence _compileRESTMethod = this.compileRESTMethod(method);
            _builder.append(_compileRESTMethod, "");
            _builder.newLineIfNotEmpty();
        }
    }
    _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 97 with StringConcatenation

use of org.eclipse.xtend2.lib.StringConcatenation in project applause by applause.

the class EntityDataAccessHeaderFileCompiler method compilePOSTMethod.

public CharSequence compilePOSTMethod(final DataSourceAccessMethod it) {
    StringConcatenation _builder = new StringConcatenation();
    _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();
    return _builder;
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 98 with StringConcatenation

use of org.eclipse.xtend2.lib.StringConcatenation in project applause by applause.

the class EntityDataAccessHeaderFileCompiler method compileGETLISTMethod.

public CharSequence compileGETLISTMethod(final DataSourceAccessMethod it) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("+ (void)");
    String _name = it.getName();
    _builder.append(_name, "");
    _builder.append(":(void (^)(NSArray *");
    Entity _resourceType = this._entityDataAccessExtensions.resourceType(it);
    String _parameterName = this._entityDataAccessExtensions.parameterName(_resourceType);
    String _plural = this._entityDataAccessExtensions.plural(_parameterName);
    _builder.append(_plural, "");
    _builder.append(", NSError *error))block;");
    _builder.newLineIfNotEmpty();
    return _builder;
}
Also used : Entity(org.applause.lang.applauseDsl.Entity) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 99 with StringConcatenation

use of org.eclipse.xtend2.lib.StringConcatenation in project applause by applause.

the class EntityDataAccessHeaderFileCompiler method compileDELETEMethod.

public CharSequence compileDELETEMethod(final DataSourceAccessMethod it) {
    StringConcatenation _builder = new StringConcatenation();
    _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();
    return _builder;
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 100 with StringConcatenation

use of org.eclipse.xtend2.lib.StringConcatenation in project applause by applause.

the class EntityDataAccessModuleFileCompiler method compileGETLISTMethod.

public CharSequence compileGETLISTMethod(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 (^)(NSArray *");
    Entity _resourceType = this._entityDataAccessExtensions.resourceType(it);
    String _parameterName = this._entityDataAccessExtensions.parameterName(_resourceType);
    String _plural = this._entityDataAccessExtensions.plural(_parameterName);
    _builder.append(_plural, "");
    _builder.append(", NSError *error))block");
    _builder.newLineIfNotEmpty();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("[[");
    Entity _resourceType_1 = this._entityDataAccessExtensions.resourceType(it);
    String _apiClientClassName = this._aPIClientClassExtensions.apiClientClassName(_resourceType_1);
    _builder.append(_apiClientClassName, "	");
    _builder.append(" sharedClient] GET:");
    String _urlConstantForRESTMethod_1 = this.urlConstantForRESTMethod(it);
    _builder.append(_urlConstantForRESTMethod_1, "	");
    _builder.append(" parameters:nil success:^(NSURLSessionDataTask *task, id responseObject)");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("NSArray *elementsFromJSON = responseObject;");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("NSMutableArray *result = [[NSMutableArray alloc] initWithCapacity:[elementsFromJSON count]];");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("for (NSDictionary *attributes in elementsFromJSON) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    Entity _resourceType_2 = this._entityDataAccessExtensions.resourceType(it);
    String _typeName = this._typeExtensions.typeName(_resourceType_2);
    _builder.append(_typeName, "			");
    _builder.append(" *mappedElement = [[");
    Entity _resourceType_3 = this._entityDataAccessExtensions.resourceType(it);
    String _typeName_1 = this._typeExtensions.typeName(_resourceType_3);
    _builder.append(_typeName_1, "			");
    _builder.append(" alloc] initWithAttributes:attributes];");
    _builder.newLineIfNotEmpty();
    _builder.append("\t\t\t");
    _builder.append("[result addObject:mappedElement];");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("if (block) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("block([result copy], 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(@[], 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)

Aggregations

StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)205 Test (org.junit.Test)37 Named (org.jnario.runner.Named)35 Order (org.jnario.runner.Order)35 EList (org.eclipse.emf.common.util.EList)26 Entity (org.applause.lang.applauseDsl.Entity)17 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)17 ColumnSource (com.robotoworks.mechanoid.db.sqliteModel.ColumnSource)12 ComplexTypeLiteral (com.robotoworks.mechanoid.net.netModel.ComplexTypeLiteral)11 Member (com.robotoworks.mechanoid.net.netModel.Member)10 SkipMember (com.robotoworks.mechanoid.net.netModel.SkipMember)10 TypedMember (com.robotoworks.mechanoid.net.netModel.TypedMember)10 DatabaseBlock (com.robotoworks.mechanoid.db.sqliteModel.DatabaseBlock)9 ImportHelper (com.robotoworks.mechanoid.net.generator.ImportHelper)9 GenericListType (com.robotoworks.mechanoid.net.netModel.GenericListType)9 IntrinsicType (com.robotoworks.mechanoid.net.netModel.IntrinsicType)9 Type (com.robotoworks.mechanoid.net.netModel.Type)9 ServiceBlock (com.robotoworks.mechanoid.ops.opServiceModel.ServiceBlock)9 ColumnType (com.robotoworks.mechanoid.db.sqliteModel.ColumnType)7 BlockType (com.robotoworks.mechanoid.net.netModel.BlockType)7