use of org.whole.lang.codebase.StreamPersistenceProvider in project whole by wholeplatform.
the class ArtifactsLoadFileContentsVisitor method visit.
@Override
public void visit(FileArtifact entity) {
if (force || EntityUtils.isResolver(entity.getContent())) {
InputStream is = getArtifactsOperations().getContents(getResource());
IPersistenceKit persistenceKit = persistenceKitStack.peek();
try {
IEntity model = persistenceKit.readModel(new StreamPersistenceProvider(is));
entity.setContent(CommonsEntityAdapterFactory.createStageUpFragment(ArtifactsEntityDescriptorEnum.Content, model));
} catch (Exception e) {
// TODO parameterize throw new IllegalStateException(e);
}
}
}
use of org.whole.lang.codebase.StreamPersistenceProvider 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));
}
use of org.whole.lang.codebase.StreamPersistenceProvider in project whole by wholeplatform.
the class XsdMappingTest method testSCTScf.
@Category(SlowTests.class)
@Test
public void testSCTScf() throws Exception {
InputStream is = loader.getResourceAsStream("SepaSct.xsd");
StreamSource ss = new StreamSource(is);
Schema schema = factory.newSchema(ss);
is = loader.getResourceAsStream("SepaSct.xml");
Validator v = schema.newValidator();
v.validate(new StreamSource(is));
is = loader.getResourceAsStream("SepaSct.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 SepaSctInstance().create(), model));
}
use of org.whole.lang.codebase.StreamPersistenceProvider in project whole by wholeplatform.
the class XsdMappingTest method testAppEngine.
@Category(SlowTests.class)
@Test
public void testAppEngine() throws Exception {
InputStream is = loader.getResourceAsStream("appengine-web.xsd");
StreamSource ss = new StreamSource(is);
Schema schema = factory.newSchema(ss);
is = loader.getResourceAsStream("appengine-web.xml");
Validator v = schema.newValidator();
v.validate(new StreamSource(is));
is = loader.getResourceAsStream("appengine-web.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 AppEngineWebInstance().create(), model));
is = loader.getResourceAsStream("cron.xsd");
ss = new StreamSource(is);
schema = factory.newSchema(ss);
is = loader.getResourceAsStream("cron.xml");
v = schema.newValidator();
v.validate(new StreamSource(is));
is = loader.getResourceAsStream("cron.xml");
pp = new StreamPersistenceProvider(is);
pp.getBindings().wDefValue("packageName", "org.whole.lang.xsd.mapping.samples");
model = XsiPersistenceKit.instance().readModel(pp);
Assert.assertTrue(Matcher.match(new CronInstance(model.wGetLanguageKit()).create(), model));
is = loader.getResourceAsStream("queue.xsd");
ss = new StreamSource(is);
schema = factory.newSchema(ss);
is = loader.getResourceAsStream("queue.xml");
v = schema.newValidator();
v.validate(new StreamSource(is));
is = loader.getResourceAsStream("queue.xml");
pp = new StreamPersistenceProvider(is);
pp.getBindings().wDefValue("packageName", "org.whole.lang.xsd.mapping.samples");
model = XsiPersistenceKit.instance().readModel(pp);
Assert.assertTrue(Matcher.match(new QueueInstance(model.wGetLanguageKit()).create(), model));
is = loader.getResourceAsStream("datastore-indexes.xsd");
ss = new StreamSource(is);
schema = factory.newSchema(ss);
is = loader.getResourceAsStream("datastore-indexes.xml");
v = schema.newValidator();
v.validate(new StreamSource(is));
is = loader.getResourceAsStream("datastore-indexes.xml");
pp = new StreamPersistenceProvider(is);
pp.getBindings().wDefValue("packageName", "org.whole.lang.xsd.mapping.samples");
model = XsiPersistenceKit.instance().readModel(pp);
Assert.assertTrue(Matcher.match(new DatastoreIndexesInstance(model.wGetLanguageKit()).create(), model));
is = loader.getResourceAsStream("dos.xsd");
ss = new StreamSource(is);
schema = factory.newSchema(ss);
is = loader.getResourceAsStream("dos.xml");
v = schema.newValidator();
v.validate(new StreamSource(is));
is = loader.getResourceAsStream("dos.xml");
pp = new StreamPersistenceProvider(is);
pp.getBindings().wDefValue("packageName", "org.whole.lang.xsd.mapping.samples");
model = XsiPersistenceKit.instance().readModel(pp);
Assert.assertTrue(Matcher.match(new DosInstance(model.wGetLanguageKit()).create(), model));
is = loader.getResourceAsStream("jdoconfig_2_3.xsd");
ss = new StreamSource(is);
schema = factory.newSchema(ss);
is = loader.getResourceAsStream("jdoconfig.xml");
v = schema.newValidator();
v.validate(new StreamSource(is));
is = loader.getResourceAsStream("jdoconfig.xml");
pp = new StreamPersistenceProvider(is);
pp.getBindings().wDefValue("packageName", "org.whole.lang.xsd.mapping.samples");
model = XsiPersistenceKit.instance().readModel(pp);
Assert.assertTrue(Matcher.match(new JDOConfigInstance().create(), model));
}
use of org.whole.lang.codebase.StreamPersistenceProvider in project whole by wholeplatform.
the class JSONPersistencesTest method testParseAndGenerateWithBuilderOperation.
@Test
public void testParseAndGenerateWithBuilderOperation() throws Exception {
IEntity sampleModel = JSONSourcePersistenceKit.instance().readModel(new StreamPersistenceProvider(getClass().getResourceAsStream("sample.json")));
StringPersistenceProvider pp = new StringPersistenceProvider();
JsonGenerator generator = new JsonFactory().createGenerator(pp.getOutputStream());
generator.useDefaultPrettyPrinter();
JSONGeneratorBuilderOperation op = new JSONGeneratorBuilderOperation(generator);
new ModelTemplate(sampleModel).apply(op);
generator.close();
assertEquals(sampleString, pp.getStore());
}
Aggregations