use of org.whole.lang.codebase.StringPersistenceProvider in project whole by wholeplatform.
the class ActionFactory method createReplaceFragmentAction.
public IUpdatableAction createReplaceFragmentAction(String label, IEntity predicate, IEntity fragment) {
try {
Map<String, Object> parameters = new HashMap<String, Object>();
StringPersistenceProvider spp = new StringPersistenceProvider();
ReflectionFactory.getDefaultPersistenceKit().writeModel(fragment, spp);
parameters.put(FRAGMENT_XWL_PARAMETER_ID, spp.getStore());
spp = new StringPersistenceProvider();
ReflectionFactory.getDefaultPersistenceKit().writeModel(predicate, spp);
parameters.put(PREDICATE_XWL_PARAMETER_ID, spp.getStore());
return createE4ActionAdapter(label, REPLACE_ICON_URI, REPLACE_FRAGMENT_COMMAND_ID, parameters);
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
use of org.whole.lang.codebase.StringPersistenceProvider in project whole by wholeplatform.
the class WorkflowsInterpreterVisitor method afterWriteModel.
protected void afterWriteModel(SaveModel entity, IPersistenceProvider provider) throws Exception {
if (getResourceKind(entity).wContainsValue(ResourceKindEnum.VARIABLE)) {
String result = ((StringPersistenceProvider) provider).getStore();
Variable variable = (Variable) entity.getResource();
getBindings().wDefValue(variable.getValue(), result);
}
}
use of org.whole.lang.codebase.StringPersistenceProvider 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.StringPersistenceProvider 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.StringPersistenceProvider in project whole by wholeplatform.
the class XsdMappingTest method testModelsToXmlSchemaXXX.
@Test
public void testModelsToXmlSchemaXXX() throws Exception {
IBindingManager bm = BindingManagerFactory.instance.createArguments();
PathExpression path = new ModelToXmlSchemaQuery().create();
Model model = (Model) ModelsTemplateManager.instance().create("Models model");
String uri = model.getUri().getValue();
ILanguageKit lk = ReflectionFactory.getLanguageKit(uri);
IEntity tuple = BehaviorUtils.evaluateFirstResult(path, model, bm);
Assert.assertNotNull(tuple);
InterpreterOperation.interpret(tuple.wGet(1));
ITemplateManager tm = lk.getTemplateManager();
IEntity entity = tm.create("Editors model");
IPersistenceProvider pp = new StringPersistenceProvider();
XsiPersistenceKit.instance().writeModel(entity, pp);
IEntity entity2 = XsiPersistenceKit.instance().readModel(pp);
boolean matches = Matcher.match(entity, entity2);
Assert.assertTrue(matches);
}
Aggregations