Search in sources :

Example 6 with Entity

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

the class EntityDataMappingGeneratorSpec 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._entityDataMappingHeaderFileCompiler.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)

Example 7 with Entity

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

the class DefaultListScreenEditActionCompiler method compileCommitEditing.

public CharSequence compileCommitEditing(final Screen it) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    Entity _resourceType = this._defaultListScreenClassExtensions.resourceType(it);
    String _typeName = this._typeExtensions.typeName(_resourceType);
    _builder.append(_typeName, "	");
    _builder.append(" *item= self.items[indexPath.row];");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("[item ");
    DataSourceAccessMethod _deleteMethod = this.deleteMethod(it);
    String _name = _deleteMethod.getName();
    _builder.append(_name, "	");
    _builder.append(":^(");
    Entity _resourceType_1 = this._defaultListScreenClassExtensions.resourceType(it);
    String _typeName_1 = this._typeExtensions.typeName(_resourceType_1);
    _builder.append(_typeName_1, "	");
    _builder.append(" *item, NSError *error)");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("if (error) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("NSLog(@\"Error %@\", error);");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("else {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("if (indexPath.row < self.items.count) {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("[self.items removeObjectAtIndex:indexPath.row];");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _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) DataSourceAccessMethod(org.applause.lang.applauseDsl.DataSourceAccessMethod) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 8 with Entity

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

the class DefaultDetailsScreenModuleFileCompiler method compileUpdateItemFragment.

public CharSequence compileUpdateItemFragment(final Screen it) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("[self.item ");
    String _dataAccessMethodNameForUpdate = this.dataAccessMethodNameForUpdate(it);
    _builder.append(_dataAccessMethodNameForUpdate, "");
    _builder.append(":^(");
    Entity _resourceType = this._defaultDetailsScreenClassExtensions.resourceType(it);
    String _typeName = this._typeExtensions.typeName(_resourceType);
    _builder.append(_typeName, "");
    _builder.append(" *item, NSError *error)");
    _builder.newLineIfNotEmpty();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("if(error == nil) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("if (self.doneBlock) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("self.doneBlock(item);");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("else {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("// use a HUD to display this to the user:");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("NSLog(@\"Problem saving the ");
    Entity _resourceType_1 = this._defaultDetailsScreenClassExtensions.resourceType(it);
    String _typeName_1 = this._typeExtensions.typeName(_resourceType_1);
    String _firstLower = StringExtensions.toFirstLower(_typeName_1);
    _builder.append(_firstLower, "		");
    _builder.append(". Try again later.\");");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}];");
    _builder.newLine();
    return _builder;
}
Also used : Entity(org.applause.lang.applauseDsl.Entity) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 9 with Entity

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

the class DefaultDetailsScreenModuleFileCompiler method compileCreateNewItemFragment.

public CharSequence compileCreateNewItemFragment(final Screen it) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("[self.item ");
    String _dataAccessMethodNameForCreate = this.dataAccessMethodNameForCreate(it);
    _builder.append(_dataAccessMethodNameForCreate, "");
    _builder.append(":^(");
    Entity _resourceType = this._defaultDetailsScreenClassExtensions.resourceType(it);
    String _typeName = this._typeExtensions.typeName(_resourceType);
    _builder.append(_typeName, "");
    _builder.append(" *item, NSError *error)");
    _builder.newLineIfNotEmpty();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("if(error == nil) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("if (self.doneBlock) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("self.doneBlock(item);");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("else {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("// use a HUD to display this to the user:");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("NSLog(@\"Problem saving the ");
    Entity _resourceType_1 = this._defaultDetailsScreenClassExtensions.resourceType(it);
    String _typeName_1 = this._typeExtensions.typeName(_resourceType_1);
    String _firstLower = StringExtensions.toFirstLower(_typeName_1);
    _builder.append(_firstLower, "		");
    _builder.append(". Try again later.\");");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}];");
    _builder.newLine();
    return _builder;
}
Also used : Entity(org.applause.lang.applauseDsl.Entity) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 10 with Entity

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

the class DefaultListScreenActionCompiler method compileActionMethod_EditItem.

private CharSequence compileActionMethod_EditItem(final Screen it) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("- (void)onEditItem:(");
    Entity _resourceType = this._defaultListScreenClassExtensions.resourceType(it);
    String _typeName = this._typeExtensions.typeName(_resourceType);
    _builder.append(_typeName, "");
    _builder.append(" *)item");
    _builder.newLineIfNotEmpty();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("[");
    Screen _targetNavigationScreen = this._defaultListScreenClassExtensions.targetNavigationScreen(it);
    String _controllerClassName = this._defaultListScreenClassExtensions.controllerClassName(_targetNavigationScreen);
    _builder.append(_controllerClassName, "	");
    _builder.append(" presentForEditingItem:item fromParent:self onDone:^(");
    Entity _resourceType_1 = this._defaultListScreenClassExtensions.resourceType(it);
    String _typeName_1 = this._typeExtensions.typeName(_resourceType_1);
    _builder.append(_typeName_1, "	");
    _builder.append(" *editedItem)");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("[self refresh];");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}];");
    _builder.newLine();
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    return _builder;
}
Also used : Entity(org.applause.lang.applauseDsl.Entity) Screen(org.applause.lang.applauseDsl.Screen) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

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