Search in sources :

Example 6 with IPersistenceKit

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();
}
Also used : IPersistenceKit(org.whole.lang.codebase.IPersistenceKit)

Example 7 with IPersistenceKit

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());
    }
}
Also used : IEntity(org.whole.lang.model.IEntity) IPersistenceProvider(org.whole.lang.codebase.IPersistenceProvider) IPersistenceKit(org.whole.lang.codebase.IPersistenceKit) MissingVariableException(org.whole.lang.visitors.MissingVariableException) IOException(java.io.IOException) IWholeRuntimeException(org.whole.lang.exceptions.IWholeRuntimeException) VisitException(org.whole.lang.visitors.VisitException) ParseException(org.whole.lang.parsers.ParseException) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException)

Example 8 with IPersistenceKit

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);
        }
    });
}
Also used : StringPersistenceProvider(org.whole.lang.codebase.StringPersistenceProvider) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) IPersistenceKit(org.whole.lang.codebase.IPersistenceKit)

Example 9 with IPersistenceKit

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()));
    });
}
Also used : StringPersistenceProvider(org.whole.lang.codebase.StringPersistenceProvider) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) IPersistenceKit(org.whole.lang.codebase.IPersistenceKit)

Example 10 with IPersistenceKit

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)));
}
Also used : StringPersistenceProvider(org.whole.lang.codebase.StringPersistenceProvider) IPersistenceKit(org.whole.lang.codebase.IPersistenceKit)

Aggregations

IPersistenceKit (org.whole.lang.codebase.IPersistenceKit)33 IEntity (org.whole.lang.model.IEntity)13 IPersistenceProvider (org.whole.lang.codebase.IPersistenceProvider)7 StringPersistenceProvider (org.whole.lang.codebase.StringPersistenceProvider)6 IOException (java.io.IOException)4 IFile (org.eclipse.core.resources.IFile)4 GridData (org.eclipse.swt.layout.GridData)4 Shell (org.eclipse.swt.widgets.Shell)4 IBindingManager (org.whole.lang.bindings.IBindingManager)4 IFilePersistenceProvider (org.whole.lang.codebase.IFilePersistenceProvider)4 IWholeRuntimeException (org.whole.lang.exceptions.IWholeRuntimeException)4 WholeIllegalArgumentException (org.whole.lang.exceptions.WholeIllegalArgumentException)4 ParseException (org.whole.lang.parsers.ParseException)4 IImportAsModelDialog (org.whole.lang.ui.dialogs.IImportAsModelDialog)4 MissingVariableException (org.whole.lang.visitors.MissingVariableException)4 VisitException (org.whole.lang.visitors.VisitException)4 ArrayList (java.util.ArrayList)3 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 Label (org.eclipse.swt.widgets.Label)3