/** * Add a creatable dependency for this model. * * @param creatable the creatable dependency. * @return the key to be used as parameter to taskResult(string) method to retrieve created dependency */ @SuppressWarnings("unchecked") protected String addDependency(Creatable<? extends Indexable> creatable) { TaskGroup.HasTaskGroup dependency = (TaskGroup.HasTaskGroup) creatable; return this.addDependency(dependency); }
/** * Add an appliable "post-run" dependent for this model. * * @param appliable the appliable "post-run" dependent. * @return the key to be used as parameter to taskResult(string) method to retrieve updated "post-run" dependent */ @SuppressWarnings("unchecked") protected String addPostRunDependent(Appliable<? extends Indexable> appliable) { TaskGroup.HasTaskGroup dependency = (TaskGroup.HasTaskGroup) appliable; return this.addPostRunDependent(dependency); }
/** * Clear the child collection. */ public void clear() { for (FluentModelTImpl child : childCollection.values()) { child.clear(); } this.childCollection.clear(); }
/** * Prepare the given model of an external child resource for inline create (along with the definition or update of parent resource). * * @param model the model to track create changes * @return the external child resource prepared for create */ protected final FluentModelTImpl prepareInlineDefine(FluentModelTImpl model) { FluentModelTImpl childResource = find(model.childResourceKey()); if (childResource != null) { throw new IllegalArgumentException(pendingOperationMessage(model.name(), model.childResourceKey())); } model.setPendingOperation(ExternalChildResourceImpl.PendingOperation.ToBeCreated); this.childCollection.put(model.childResourceKey(), model); return super.prepareForFutureCommitOrPostRun(model); }
/** * Prepare for inline update of an external child resource (along with the update of parent resource). * * @param name the name of the external child resource * @param key the key * @return the external child resource to be updated */ protected final FluentModelTImpl prepareInlineUpdate(String name, String key) { FluentModelTImpl childResource = find(key); if (childResource == null || childResource.pendingOperation() == ExternalChildResourceImpl.PendingOperation.ToBeCreated) { throw new IllegalArgumentException("A child resource ('" + childResourceName + "') with name (key) '" + name + " (" + key + ")' not found"); } if (childResource.pendingOperation() == ExternalChildResourceImpl.PendingOperation.ToBeRemoved) { throw new IllegalArgumentException("A child resource ('" + childResourceName + "') with name (key) '" + name + " (" + key + ")' is marked for deletion"); } childResource.setPendingOperation(ExternalChildResourceImpl.PendingOperation.ToBeUpdated); return super.prepareForFutureCommitOrPostRun(childResource); }
/** * @return the key of this child resource in the collection maintained by ExternalChildResourceCollectionImpl */ public String childResourceKey() { return name(); }
@Override public FluentModelT apply() { return applyAsync().toBlocking().last(); }
@Override public FluentModelT create() { return Utils.<FluentModelT>rootResource(createAsync()).toBlocking().single(); }
@Override public Observable<FluentModelT> refreshAsync() { final ExternalChildResourceImpl<FluentModelT, InnerModelT, ParentImplT, ParentT> self = this; return this.getInnerAsync().map(new Func1<InnerModelT, FluentModelT>() { @Override public FluentModelT call(InnerModelT innerModelT) { self.setInner(innerModelT); return (FluentModelT) self; } }); }
@Override public final FluentModelT refresh() { return refreshAsync().toBlocking().last(); }
/** * Initializes the external child resource collection. */ protected void cacheCollection() { this.clear(); for (FluentModelTImpl childResource : this.listChildResources()) { this.childCollection.put(childResource.childResourceKey(), childResource); } }
/** * Prepare the given model of an external child resource for inline removal (along with the definition or update of parent resource). * * @param model the model representing child resource to remove */ protected final void prepareInlineRemove(FluentModelTImpl model) { FluentModelTImpl childResource = find(model.childResourceKey()); if (childResource != null) { throw new IllegalArgumentException(pendingOperationMessage(model.name(), model.childResourceKey())); } model.setPendingOperation(ExternalChildResourceImpl.PendingOperation.ToBeRemoved); this.childCollection.put(model.childResourceKey(), model); super.prepareForFutureCommitOrPostRun(model); }
/** * Prepare for inline removal of an external child resource (along with the update of parent resource). * * @param name the name of the external child resource * @param key the key */ protected final void prepareInlineRemove(String name, String key) { FluentModelTImpl childResource = find(key); if (childResource == null || childResource.pendingOperation() == ExternalChildResourceImpl.PendingOperation.ToBeCreated) { throw new IllegalArgumentException("A child resource ('" + childResourceName + "') with name (key) '" + name + " (" + key + ")' not found"); } childResource.setPendingOperation(ExternalChildResourceImpl.PendingOperation.ToBeRemoved); super.prepareForFutureCommitOrPostRun(childResource); }
/** * Adds an external child resource to the childCollection. * * @param childResource the external child resource */ protected void addChildResource(FluentModelTImpl childResource) { this.addChildResource(childResource.name(), childResource); }
@Override public ServiceFuture<FluentModelT> applyAsync(ServiceCallback<FluentModelT> callback) { return ServiceFuture.fromBody(applyAsync(), callback); }
@Override public ServiceFuture<FluentModelT> createAsync(final ServiceCallback<FluentModelT> callback) { return ServiceFuture.fromBody(Utils.<FluentModelT>rootResource(createAsync()), callback); }
/** * Prepare the given model of an external child resource for inline update (along with the definition or update of parent resource). * * @param model the model to track update changes * @return the external child resource prepared for update */ protected final FluentModelTImpl prepareInlineUpdate(FluentModelTImpl model) { FluentModelTImpl childResource = find(model.childResourceKey()); if (childResource != null) { throw new IllegalArgumentException(pendingOperationMessage(model.name(), model.childResourceKey())); } model.setPendingOperation(ExternalChildResourceImpl.PendingOperation.ToBeUpdated); this.childCollection.put(model.childResourceKey(), model); return super.prepareForFutureCommitOrPostRun(model); }
/** * Add an executable dependency for this model. * * @param executable the executable dependency * @return the key to be used as parameter to taskResult(string) method to retrieve result of executing * the executable dependency */ @SuppressWarnings("unchecked") protected String addDependency(Executable<? extends Indexable> executable) { TaskGroup.HasTaskGroup dependency = (TaskGroup.HasTaskGroup) executable; return this.addDependency(dependency); }
/** * Add a creatable "post-run" dependent for this model. * * @param creatable the creatable "post-run" dependent. * @return the key to be used as parameter to taskResult(string) method to retrieve created "post-run" dependent */ @SuppressWarnings("unchecked") protected String addPostRunDependent(Creatable<? extends Indexable> creatable) { TaskGroup.HasTaskGroup dependency = (TaskGroup.HasTaskGroup) creatable; return this.addPostRunDependent(dependency); }
/** * Add an appliable dependency for this model. * * @param appliable the appliable dependency. * @return the key to be used as parameter to taskResult(string) method to retrieve updated dependency */ @SuppressWarnings("unchecked") protected String addeDependency(Appliable<? extends Indexable> appliable) { TaskGroup.HasTaskGroup dependency = (TaskGroup.HasTaskGroup) appliable; return this.addDependency(dependency); }