Search in sources :

Example 16 with Entity

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

the class EntityDataAccessModuleFileCompiler method compilePOSTMethod.

public CharSequence compilePOSTMethod(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] POST:");
    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 17 with Entity

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

the class DefaultDetailsScreenHeaderFileCompiler method compileHeader.

public CharSequence compileHeader(final Screen it) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("#import <Foundation/Foundation.h>");
    _builder.newLine();
    _builder.append("#import \"QuickDialogController.h\"");
    _builder.newLine();
    _builder.append("#import \"");
    Entity _resourceType = this._defaultDetailsScreenClassExtensions.resourceType(it);
    String _entityModelHeaderFileName = this._entityClassExtensions.entityModelHeaderFileName(_resourceType);
    _builder.append(_entityModelHeaderFileName, "");
    _builder.append("\"");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("@interface ");
    String _controllerClassName = this._defaultDetailsScreenClassExtensions.controllerClassName(it);
    _builder.append(_controllerClassName, "");
    _builder.append(" : QuickDialogController");
    _builder.newLineIfNotEmpty();
    _builder.append("@property (nonatomic, strong) ");
    Entity _resourceType_1 = this._defaultDetailsScreenClassExtensions.resourceType(it);
    String _typeName = this._typeExtensions.typeName(_resourceType_1);
    _builder.append(_typeName, "");
    _builder.append(" *item;");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("+ (void)presentForAddingNewItemFromParent:(UIViewController *)parent onDone:(void (^)(");
    Entity _resourceType_2 = this._defaultDetailsScreenClassExtensions.resourceType(it);
    String _typeName_1 = this._typeExtensions.typeName(_resourceType_2);
    _builder.append(_typeName_1, "");
    _builder.append(" *item))doneBlock;");
    _builder.newLineIfNotEmpty();
    _builder.append("+ (void)presentForEditingItem:(");
    Entity _resourceType_3 = this._defaultDetailsScreenClassExtensions.resourceType(it);
    String _typeName_2 = this._typeExtensions.typeName(_resourceType_3);
    _builder.append(_typeName_2, "");
    _builder.append(" *)item fromParent:(UIViewController *)parent onDone:(void (^)(");
    Entity _resourceType_4 = this._defaultDetailsScreenClassExtensions.resourceType(it);
    String _typeName_3 = this._typeExtensions.typeName(_resourceType_4);
    _builder.append(_typeName_3, "");
    _builder.append(" *editedItem))doneBlock;");
    _builder.newLineIfNotEmpty();
    _builder.append("@end");
    _builder.newLine();
    return _builder;
}
Also used : Entity(org.applause.lang.applauseDsl.Entity) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 18 with Entity

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

the class EntityImpl method setSuperType.

/**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
public void setSuperType(Entity newSuperType) {
    Entity oldSuperType = superType;
    superType = newSuperType;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ApplauseDslPackage.ENTITY__SUPER_TYPE, oldSuperType, superType));
}
Also used : Entity(org.applause.lang.applauseDsl.Entity) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 19 with Entity

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

the class DefaultListScreenClassExtensions method resourceType.

public Entity resourceType(final Screen it) {
    DataSourceCall _datasource = it.getDatasource();
    DataSource _datasource_1 = _datasource.getDatasource();
    Entity _resourceType = _datasource_1.getResourceType();
    return _resourceType;
}
Also used : Entity(org.applause.lang.applauseDsl.Entity) DataSourceCall(org.applause.lang.applauseDsl.DataSourceCall) DataSource(org.applause.lang.applauseDsl.DataSource)

Example 20 with Entity

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

the class DefaultListScreenModuleFileCompiler method compileModule.

public CharSequence compileModule(final Screen it) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("#import \"");
    String _screenHeaderFileName = this._defaultListScreenClassExtensions.screenHeaderFileName(it);
    _builder.append(_screenHeaderFileName, "");
    _builder.append("\"");
    _builder.newLineIfNotEmpty();
    _builder.append("#import \"");
    Entity _resourceType = this._defaultListScreenClassExtensions.resourceType(it);
    String _entityDataAccessCategoryHeaderFileName = this._dataAccessClassExtensions.entityDataAccessCategoryHeaderFileName(_resourceType);
    _builder.append(_entityDataAccessCategoryHeaderFileName, "");
    _builder.append("\"");
    _builder.newLineIfNotEmpty();
    _builder.append("#import \"");
    Screen _targetNavigationScreen = this._defaultListScreenClassExtensions.targetNavigationScreen(it);
    String _screenHeaderFileName_1 = this._defaultListScreenClassExtensions.screenHeaderFileName(_targetNavigationScreen);
    _builder.append(_screenHeaderFileName_1, "");
    _builder.append("\"");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("@interface ");
    String _controllerClassName = this._defaultListScreenClassExtensions.controllerClassName(it);
    _builder.append(_controllerClassName, "");
    _builder.append(" ()");
    _builder.newLineIfNotEmpty();
    _builder.append("@property(nonatomic, strong) NSMutableArray *items;\t\t");
    _builder.newLine();
    _builder.append("@end");
    _builder.newLine();
    _builder.newLine();
    _builder.append("@implementation ");
    String _controllerClassName_1 = this._defaultListScreenClassExtensions.controllerClassName(it);
    _builder.append(_controllerClassName_1, "");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("static NSString *kCellIdentifier = @\"");
    DataSourceCall _datasource = it.getDatasource();
    DataSource _datasource_1 = _datasource.getDatasource();
    Entity _resourceType_1 = _datasource_1.getResourceType();
    String _typeName = this._typeExtensions.typeName(_resourceType_1);
    _builder.append(_typeName, "");
    _builder.append("Cell\";");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("- (id)initWithStyle:(UITableViewStyle)style");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("self = [super initWithStyle:style];");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("if (self) {");
    _builder.newLine();
    {
        String _title = it.getTitle();
        boolean _notEquals = (!Objects.equal(_title, null));
        if (_notEquals) {
            _builder.append("\t\t");
            _builder.append("self.title = @\"");
            String _title_1 = it.getTitle();
            _builder.append(_title_1, "		");
            _builder.append("\";");
            _builder.newLineIfNotEmpty();
        }
    }
    _builder.append("\t\t");
    _builder.append("// register table view cell");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:kCellIdentifier];");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("[self.tableView setDelegate:self];;");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("// refresh control");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("self.refreshControl = [[UIRefreshControl alloc] init];");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("[self.refreshControl addTarget:self action:@selector(refresh) forControlEvents:UIControlEventValueChanged];");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.newLine();
    _builder.append("\t\t");
    CharSequence _compileActionButtons = this._defaultListScreenActionCompiler.compileActionButtons(it);
    _builder.append(_compileActionButtons, "		");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("return self;");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("- (void)viewDidLoad");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("[super viewDidLoad];");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("[self reload];");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("- (void)didReceiveMemoryWarning");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("[super didReceiveMemoryWarning];");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("#pragma mark - Table view data source");
    _builder.newLine();
    _builder.newLine();
    _builder.append("- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("return [self.items count];");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier forIndexPath:indexPath];");
    _builder.newLine();
    _builder.append("    ");
    _builder.newLine();
    _builder.append("\t");
    Entity _resourceType_2 = this._defaultListScreenClassExtensions.resourceType(it);
    String _typeName_1 = this._typeExtensions.typeName(_resourceType_2);
    _builder.append(_typeName_1, "	");
    _builder.append(" *item = self.items[(NSUInteger) indexPath.row];");
    _builder.newLineIfNotEmpty();
    {
        Iterable<UIComponentMemberConfiguration> _configurations = this._defaultListScreenClassExtensions.configurations(it);
        for (final UIComponentMemberConfiguration it_1 : _configurations) {
            _builder.append("\t");
            CharSequence _compileConfiguration = this.compileConfiguration(it_1);
            _builder.append(_compileConfiguration, "	");
            _builder.newLineIfNotEmpty();
        }
    }
    _builder.newLine();
    _builder.append("    ");
    _builder.append("return cell;");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("#pragma mark - Table view delegate");
    _builder.newLine();
    _builder.newLine();
    _builder.append("- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    Entity _resourceType_3 = this._defaultListScreenClassExtensions.resourceType(it);
    String _typeName_2 = this._typeExtensions.typeName(_resourceType_3);
    _builder.append(_typeName_2, "	");
    _builder.append(" *item = self.items[(NSUInteger) indexPath.row];");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("[self onEditItem:item];");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    {
        boolean _supportsDeleteAction = this._defaultListScreenEditActionCompiler.supportsDeleteAction(it);
        if (_supportsDeleteAction) {
            CharSequence _compileCommitEditing = this._defaultListScreenEditActionCompiler.compileCommitEditing(it);
            _builder.append(_compileCommitEditing, "");
            _builder.newLineIfNotEmpty();
        }
    }
    _builder.newLine();
    _builder.append("#pragma mark - Data access");
    _builder.newLine();
    _builder.newLine();
    _builder.append("- (void)refresh");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("[self reload];");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("- (void)reload");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("[");
    Entity _resourceType_4 = this._defaultListScreenClassExtensions.resourceType(it);
    String _typeName_3 = this._typeExtensions.typeName(_resourceType_4);
    _builder.append(_typeName_3, "	");
    _builder.append(" ");
    DataSourceAccessMethod _restMethod = this._defaultListScreenClassExtensions.restMethod(it);
    String _name = _restMethod.getName();
    _builder.append(_name, "	");
    _builder.append(":^(NSArray *items, NSError *error)");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("[self.refreshControl endRefreshing];");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("if (error) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("[[[UIAlertView alloc] initWithTitle:NSLocalizedString(@\"Error\", nil)");
    _builder.newLine();
    _builder.append("\t\t\t\t\t\t\t\t\t\t");
    _builder.append("message:[error localizedDescription]");
    _builder.newLine();
    _builder.append("\t\t\t\t\t\t\t\t\t   ");
    _builder.append("delegate:nil");
    _builder.newLine();
    _builder.append("\t\t\t\t\t\t\t  ");
    _builder.append("cancelButtonTitle:nil");
    _builder.newLine();
    _builder.append("\t\t\t\t\t\t\t  ");
    _builder.append("otherButtonTitles:NSLocalizedString(@\"OK\", nil), nil] show];");
    _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("self.items = [NSMutableArray arrayWithArray:items];");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("[self.tableView reloadData];");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}];");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("#pragma mark - Actions");
    _builder.newLine();
    _builder.newLine();
    CharSequence _compileActionMethods = this._defaultListScreenActionCompiler.compileActionMethods(it);
    _builder.append(_compileActionMethods, "");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("@end");
    _builder.newLine();
    return _builder;
}
Also used : Entity(org.applause.lang.applauseDsl.Entity) DataSourceCall(org.applause.lang.applauseDsl.DataSourceCall) DataSourceAccessMethod(org.applause.lang.applauseDsl.DataSourceAccessMethod) Screen(org.applause.lang.applauseDsl.Screen) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) UIComponentMemberConfiguration(org.applause.lang.applauseDsl.UIComponentMemberConfiguration) DataSource(org.applause.lang.applauseDsl.DataSource)

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