use of org.whole.lang.codebase.IPersistenceProvider in project whole by wholeplatform.
the class WorkflowsInterpreterVisitor method visit.
@Override
public void visit(LoadModel entity) {
try {
IPersistenceKit persistenceKit = getPersistenceKit(entity.getPersistence());
IPersistenceProvider provider = getPersistenceProvider(entity);
try {
IEntity model = persistenceKit.readModel(provider);
setResult(entity.getModel(), model);
} catch (Exception e) {
throw new IllegalArgumentException("Failed to load 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.IPersistenceProvider in project whole by wholeplatform.
the class AbstractReusablesSemanticsVisitor method writeModel.
public static void writeModel(IEntity model, IEntity resource) {
Object[] pkpp = (Object[]) resource.wGetValue();
IPersistenceKit pk = (IPersistenceKit) pkpp[0];
IPersistenceProvider pp = (IPersistenceProvider) pkpp[1];
try {
pk.writeModel(model, pp);
} catch (Exception e) {
throw new IllegalArgumentException("Failed to write the resource with the given persistence: " + pp + ", " + pk.getId(), e);
}
}
use of org.whole.lang.codebase.IPersistenceProvider in project whole by wholeplatform.
the class XmlPrettyPrinterPerformanceTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
ReflectionFactory.deployWholePlatform();
String packagePath = StringUtils.packagePath(XmlPrettyPrinterPerformanceTest.class.getPackage().getName());
IPersistenceProvider pp = new ClasspathPersistenceProvider(packagePath + "/content.xml");
xmlModel = XmlSourcePersistenceKit.instance().readModel(pp);
}
use of org.whole.lang.codebase.IPersistenceProvider in project whole by wholeplatform.
the class AbstractArtifactsGeneratorVisitor method writeContents.
protected void writeContents(IEntity model) {
IPersistenceProvider pp = (IPersistenceProvider) env().wGetValue("persistenceProvider");
boolean contentsWritten = false;
if (env().wIsSet("persistenceKitId")) {
IPersistenceKit pk = ReflectionFactory.getPersistenceKit(env().wStringValue("persistenceKitId"));
if (pk.canApply(model))
try {
pk.writeModel(model, pp);
contentsWritten = true;
} catch (Exception inner) {
throw new IllegalStateException(inner);
}
}
try {
if (!contentsWritten)
PrettyPrintPersistenceKit.instance().writeModel(model, pp);
} catch (RuntimeException runtime) {
throw runtime;
} catch (Exception outer) {
throw new IllegalStateException(outer);
}
}
use of org.whole.lang.codebase.IPersistenceProvider in project whole by wholeplatform.
the class XsdMappingTest method testXmi20.
@Category(SlowTests.class)
@Test
public void testXmi20() throws Exception {
InputStream is = loader.getResourceAsStream("xmi20.xsd");
StreamSource ss = new StreamSource(is);
Schema schema = factory.newSchema(ss);
is = loader.getResourceAsStream("xmi20.xml");
Validator v = schema.newValidator();
v.validate(new StreamSource(is));
is = loader.getResourceAsStream("xmi20.xml");
IPersistenceProvider pp = new StreamPersistenceProvider(is);
pp.getBindings().wDefValue("packageName", "org.whole.lang.xsd.mapping.samples");
IEntity model = XsiPersistenceKit.instance().readModel(pp);
Assert.assertTrue(Matcher.match(new Xmi20Instance().create(), model));
}
Aggregations