use of org.whole.lang.codebase.StreamPersistenceProvider in project whole by wholeplatform.
the class GrammarsUtilsTest method testParseXmlDocument.
@Category(KnownFailingTests.class)
@Test
public void testParseXmlDocument() throws Exception {
InputStream is = getClass().getResourceAsStream("smallSample.xwl");
IEntity xmlDocument = XmlSourcePersistenceKit.instance().readModel(new StreamPersistenceProvider(is));
is.close();
is = getClass().getResourceAsStream("smallSample.xwl");
String source = StringUtils.readAsString(is, Charset.defaultCharset().name());
is.close();
IEntity xmlDocumentUsingGrammar = GrammarsUtils.parse(source, xmlGrammarURI);
Assert.assertTrue(Matcher.match(xmlDocument, xmlDocumentUsingGrammar));
}
use of org.whole.lang.codebase.StreamPersistenceProvider in project whole by wholeplatform.
the class ModelMergeViewer method readSideModel.
protected void readSideModel(MergeSide side, Object input, String label) {
IEntity sideModel = null;
if (input != null)
try {
IStreamContentAccessor accessor = (IStreamContentAccessor) input;
// TODO
IPersistenceKit persistenceKit = ReflectionFactory.getDefaultPersistenceKit();
sideModel = persistenceKit.readModel(new StreamPersistenceProvider(accessor.getContents()));
} catch (Exception e) {
E4Utils.reportError(getContext(), "Model Merge Viewer", "Unable to read the model", e);
// TODO ? sideModel = Status model instance with failure info
}
setSideModel(side, sideModel != null ? sideModel : CommonsEntityFactory.instance.createResolver(), label);
}
use of org.whole.lang.codebase.StreamPersistenceProvider in project whole by wholeplatform.
the class ModelMergeViewer method getSideModelBytes.
protected byte[] getSideModelBytes(MergeSide side) {
try {
// TODO
IPersistenceKit persistenceKit = ReflectionFactory.getDefaultPersistenceKit();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
persistenceKit.writeModel(getSideModel(side), new StreamPersistenceProvider(baos));
return baos.toByteArray();
} catch (Exception e) {
throw new IllegalStateException("cannot gather contents of " + side.name().toLowerCase() + " pane", e);
}
}
use of org.whole.lang.codebase.StreamPersistenceProvider in project whole by wholeplatform.
the class LoadContentsVisitor method visit.
@Override
public void visit(FileArtifact file) {
env().wEnterScope();
file.getName().accept(this);
file.getMetadata().accept(this);
String fileName = env().wStringValue("name");
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
IPath filePath = ArtifactsWorkspaceUtils.getParentPath(bindings).append(fileName);
InputStream in;
try {
in = workspaceRoot.getFile(filePath).getContents(true);
} catch (CoreException e) {
throw new OperationCanceledException(e);
}
env().wDefValue("className", StringUtils.stripFileExtension(fileName));
// TODO use IFile
env().wDefValue("persistenceProvider", new StreamPersistenceProvider(in, null, env()));
file.setContent(CommonsEntityAdapterFactory.createStageUpFragment(ArtifactsEntityDescriptorEnum.Content, readContents()));
env().wExitScope();
}
use of org.whole.lang.codebase.StreamPersistenceProvider in project whole by wholeplatform.
the class JSONPersistencesTest method setUp.
@Before
public void setUp() throws Exception {
IEntity sampleText = TextSourcePersistenceKit.instance().readModel(new StreamPersistenceProvider(getClass().getResourceAsStream("sample.json")));
sampleString = PrettyPrinterOperation.toPrettyPrintString(sampleText);
}
Aggregations