Search in sources :

Example 1 with StringPersistenceProvider

use of org.whole.lang.codebase.StringPersistenceProvider in project whole by wholeplatform.

the class ClipboardUtils method unparseEntity.

public static String unparseEntity(IEntity entity) throws Exception {
    StringPersistenceProvider pp = new StringPersistenceProvider();
    ReflectionFactory.getDefaultPersistenceKit().writeModel(entity, pp);
    return pp.getStore();
}
Also used : StringPersistenceProvider(org.whole.lang.codebase.StringPersistenceProvider)

Example 2 with StringPersistenceProvider

use of org.whole.lang.codebase.StringPersistenceProvider in project whole by wholeplatform.

the class JSONPersistencesTest method testJSONLDPersistence.

@Test
public void testJSONLDPersistence() throws Exception {
    StringPersistenceProvider pp = new StringPersistenceProvider();
    for (String modelPath : models) {
        IEntity sourceModel = XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider(modelPath));
        pp.delete();
        JSONLDPersistenceKit.instance().writeModel(sourceModel, pp);
        IEntity targetModel = JSONLDPersistenceKit.instance().readModel(pp);
        assertTrue(Matcher.forceMatch(sourceModel, targetModel));
    }
}
Also used : StringPersistenceProvider(org.whole.lang.codebase.StringPersistenceProvider) IEntity(org.whole.lang.model.IEntity) ClasspathPersistenceProvider(org.whole.lang.codebase.ClasspathPersistenceProvider) Test(org.junit.Test)

Example 3 with StringPersistenceProvider

use of org.whole.lang.codebase.StringPersistenceProvider in project whole by wholeplatform.

the class JSONPersistencesTest method testPersistenceKit.

@Test
public void testPersistenceKit() throws Exception {
    IEntity sampleModel = JSONSourcePersistenceKit.instance().readModel(new StreamPersistenceProvider(getClass().getResourceAsStream("sample.json")));
    StringPersistenceProvider pp = new StringPersistenceProvider();
    JSONSourcePersistenceKit.instance().writeModel(sampleModel, pp);
    assertEquals(sampleString, pp.getStore());
}
Also used : StringPersistenceProvider(org.whole.lang.codebase.StringPersistenceProvider) IEntity(org.whole.lang.model.IEntity) StreamPersistenceProvider(org.whole.lang.codebase.StreamPersistenceProvider) Test(org.junit.Test)

Example 4 with StringPersistenceProvider

use of org.whole.lang.codebase.StringPersistenceProvider in project whole by wholeplatform.

the class ActionFactory method createPerformAction.

public IUpdatableAction createPerformAction(String label, String iconUri, IEntity predicate, IEntity behavior) {
    try {
        Map<String, Object> parameters = new HashMap<String, Object>();
        StringPersistenceProvider spp = new StringPersistenceProvider();
        ReflectionFactory.getDefaultPersistenceKit().writeModel(behavior, spp);
        parameters.put(BEHAVIOR_XWL_PARAMETER_ID, spp.getStore());
        spp = new StringPersistenceProvider();
        ReflectionFactory.getDefaultPersistenceKit().writeModel(predicate, spp);
        parameters.put(PREDICATE_XWL_PARAMETER_ID, spp.getStore());
        parameters.put(DESCRIPTION_PARAMETER_ID, label);
        return createE4ActionAdapter(label, iconUri, PERFORM_COMMAND_ID, parameters);
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
}
Also used : StringPersistenceProvider(org.whole.lang.codebase.StringPersistenceProvider) HashMap(java.util.HashMap)

Example 5 with StringPersistenceProvider

use of org.whole.lang.codebase.StringPersistenceProvider in project whole by wholeplatform.

the class ActionFactory method createActionCallAction.

public IUpdatableAction createActionCallAction(String label, boolean analyzing, IEntity predicate, String functionUri) {
    try {
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put(FUNCTION_URI_PARAMETER_ID, functionUri);
        StringPersistenceProvider spp = new StringPersistenceProvider();
        ReflectionFactory.getDefaultPersistenceKit().writeModel(predicate, spp);
        parameters.put(PREDICATE_XWL_PARAMETER_ID, spp.getStore());
        parameters.put(DESCRIPTION_PARAMETER_ID, label);
        parameters.put(ANALYSING_PARAMETER_ID, Boolean.valueOf(analyzing).toString());
        return createE4ActionAdapter(label, null, ACTION_CALL_COMMAND_ID, parameters);
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
}
Also used : StringPersistenceProvider(org.whole.lang.codebase.StringPersistenceProvider) HashMap(java.util.HashMap)

Aggregations

StringPersistenceProvider (org.whole.lang.codebase.StringPersistenceProvider)20 IEntity (org.whole.lang.model.IEntity)10 IPersistenceKit (org.whole.lang.codebase.IPersistenceKit)6 HashMap (java.util.HashMap)5 Test (org.junit.Test)4 IBindingManager (org.whole.lang.bindings.IBindingManager)4 CoreException (org.eclipse.core.runtime.CoreException)2 IPersistenceProvider (org.whole.lang.codebase.IPersistenceProvider)2 StreamPersistenceProvider (org.whole.lang.codebase.StreamPersistenceProvider)2 JsonFactory (com.fasterxml.jackson.core.JsonFactory)1 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 ArrayList (java.util.ArrayList)1 ChangeBoundsRequest (org.eclipse.gef.requests.ChangeBoundsRequest)1 Shell (org.eclipse.swt.widgets.Shell)1 IBindingScope (org.whole.lang.bindings.IBindingScope)1 ClasspathPersistenceProvider (org.whole.lang.codebase.ClasspathPersistenceProvider)1 JSONGeneratorBuilderOperation (org.whole.lang.json.util.JSONGeneratorBuilderOperation)1 Model (org.whole.lang.models.model.Model)1 PathExpression (org.whole.lang.queries.model.PathExpression)1 ILanguageKit (org.whole.lang.reflect.ILanguageKit)1