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();
}
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));
}
}
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());
}
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);
}
}
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);
}
}
Aggregations