use of org.whole.lang.codebase.IPersistenceKit in project whole by wholeplatform.
the class ArtifactsLoadFileContentsVisitor method acceptChild.
@Override
protected void acceptChild(IEntity child, T childResource) {
IPersistenceKit persistenceKit = getPersistenceKit(child);
persistenceKitStack.push(persistenceKit);
super.acceptChild(child, childResource);
persistenceKitStack.pop();
}
use of org.whole.lang.codebase.IPersistenceKit in project whole by wholeplatform.
the class WorkflowsInterpreterVisitor method visit.
@Override
public void visit(SaveModel entity) {
try {
IPersistenceKit persistenceKit = getPersistenceKit(entity.getPersistence());
IPersistenceProvider provider = getPersistenceProvider(entity);
entity.getModel().accept(this);
IEntity model = getResult();
try {
persistenceKit.writeModel(model, provider);
afterWriteModel(entity, provider);
} catch (Exception e) {
throw new IllegalArgumentException("Failed to save the resource with the given persistence: " + getResourceString(entity) + ", " + getPersistenceId(entity.getPersistence()), e);
}
} catch (Exception e) {
throw IWholeRuntimeException.asWholeException(e, entity, getBindings());
}
}
use of org.whole.lang.codebase.IPersistenceKit in project whole by wholeplatform.
the class PersistenceLibraryDeployer method stringToModelIterator.
public static IEntityIterator<IEntity> stringToModelIterator() {
return IteratorFactory.singleValuedRunnableIterator((IEntity selfEntity, IBindingManager bm, IEntity... arguments) -> {
StringPersistenceProvider pp = new StringPersistenceProvider(selfEntity.wStringValue());
IPersistenceKit persistenceKit = null;
try {
persistenceKit = derivePersistenceKit(bm, pp);
} catch (Exception e) {
throw new IllegalArgumentException("Failed to load the persistence kit", e);
}
try {
bm.setResult(persistenceKit.readModel(pp));
} catch (Exception e) {
throw new IllegalArgumentException("Failed to load the resource with the given persistence: " + persistenceKit.getId(), e);
}
});
}
use of org.whole.lang.codebase.IPersistenceKit in project whole by wholeplatform.
the class PersistenceLibraryDeployer method modelToStringIterator.
public static IEntityIterator<IEntity> modelToStringIterator() {
return IteratorFactory.singleValuedRunnableIterator((IEntity selfEntity, IBindingManager bm, IEntity... arguments) -> {
StringPersistenceProvider pp = new StringPersistenceProvider();
pp.getBindings().wDefValue("entityURI", selfEntity.wGetEntityDescriptor().getURI());
IPersistenceKit persistenceKit = null;
try {
persistenceKit = derivePersistenceKit(bm, pp);
} catch (Exception e) {
throw new IllegalArgumentException("Failed to load the persistence kit", e);
}
try {
persistenceKit.writeModel(selfEntity, pp);
} catch (Exception e) {
throw new IllegalArgumentException("Failed to load the resource with the given persistence: " + persistenceKit.getId(), e);
}
bm.setResult(BindingManagerFactory.instance.createValue(pp.getStore()));
});
}
use of org.whole.lang.codebase.IPersistenceKit in project whole by wholeplatform.
the class PerformHandler method defineBindings.
protected void defineBindings(String behaviorXwl, String predicateXwl, IBindingManager bm) throws Exception {
IPersistenceKit persistenceKit = ReflectionFactory.getDefaultPersistenceKit();
bm.wDef("behaviorEntity", persistenceKit.readModel(new StringPersistenceProvider(behaviorXwl)));
bm.wDef("predicateEntity", persistenceKit.readModel(new StringPersistenceProvider(predicateXwl)));
}
Aggregations