/** * Import the content from the XML file at the supplied file, specifying via the returned {@link ImportInto object} where the * content is to be imported. * * @param file the XML file that should be imported. * @return the object that should be used to specify into which the content is to be imported * @throws IllegalArgumentException if the <code>uri</code> or destination path are null */ public ImportInto<Conjunction<Graph>> importXmlFrom( File file ) { CheckArg.isNotNull(file, "file"); return importXmlFrom(file.toURI()); }
try { InputStream stream = new BufferedInputStream(new FileInputStream(file)); return importXmlFrom(stream); } catch (FileNotFoundException e) { return importXmlFrom(file.toURI()); InputStream stream = classLoader.getResourceAsStream(pathToFile); if (stream != null) { return importXmlFrom(stream); if (uri.isAbsolute()) { return importXmlFrom(new URI(pathToFile)); return importXmlFrom(pathToFile, getClass().getClassLoader());
throw new IllegalArgumentException(GraphI18n.errorImportingContent.text(sourceName, resourceName)); return importXmlFrom(stream); } catch (RuntimeException e) { error = e;
@Override @Before public void beforeEach() throws Exception { super.beforeEach(); // Set up the projection ... offsetSourceName = "Offset Source"; offsetWorkspaceName = "Offset Workspace"; // Add some data to the source ... Graph source = graphFor(offsetSourceName, offsetWorkspaceName); source.importXmlFrom(getClass().getClassLoader().getResource("cars.xml").toURI()).into("/"); }
@Override @Before public void beforeEach() throws Exception { super.beforeEach(); // Set up the projection ... offsetSourceName = "Offset Source"; offsetWorkspaceName = "Offset Workspace"; addProjection("fedSpace", "Offset Projection", offsetSourceName, offsetWorkspaceName, "/a/b => /"); // Add some data to the source ... Graph source = graphFor(offsetSourceName, offsetWorkspaceName); source.importXmlFrom(getClass().getClassLoader().getResource("cars.xml").toURI()).into("/"); }
protected void loadContentInto( RepositorySource source, String resourceOnClasspath ) throws SAXException, IOException, URISyntaxException { Graph graph = Graph.create(source, context); graph.importXmlFrom(getClass().getClassLoader().getResource(resourceOnClasspath).toURI()).into("/"); // Verify the content is there ... Node boeing777 = graph.getNodeAt("/Aircraft/Commercial/Boeing 777"); assertThat(boeing777, is(notNullValue())); }
@Override @Before public void beforeEach() throws Exception { super.beforeEach(); // Set up the projection ... mirrorSourceName = "Mirror Source"; mirrorWorkspaceName = "Mirror Workspace"; addProjection("fedSpace", "Mirror Projection", mirrorSourceName, mirrorWorkspaceName, "/ => /"); // Add some data to the source ... Graph source = graphFor(mirrorSourceName, mirrorWorkspaceName); source.importXmlFrom(getClass().getClassLoader().getResource("cars.xml").toURI()).into("/"); }
@Override @Before public void beforeEach() throws Exception { super.beforeEach(); // Set up the mirror projection ... mirrorSourceName = "Mirror Source"; mirrorWorkspaceName = "Mirror Workspace"; addProjection("fedSpace", "Mirror Projection", mirrorSourceName, mirrorWorkspaceName, "/ => /"); // Set up the branch projection ... branchSourceName = mirrorSourceName; branchWorkspaceName = "Branch Workspace"; addProjection("fedSpace", "Branch Projection", branchSourceName, branchWorkspaceName, "/Aircraft => /Aircraft"); // Add some data to the mirror source ... Graph source = graphFor(mirrorSourceName, mirrorWorkspaceName); source.importXmlFrom(getClass().getClassLoader().getResource("cars.xml").toURI()).into("/"); // Add some data to the mirror source ... Graph branch = graphFor(branchSourceName, branchWorkspaceName); branch.importXmlFrom(getClass().getClassLoader().getResource("aircraft.xml").toURI()).into("/"); }
/** * {@inheritDoc} * * @throws SAXException * @throws IOException * @see org.modeshape.graph.connector.test.AbstractConnectorTest#initializeContent(org.modeshape.graph.Graph) */ @Override protected void initializeContent( Graph graph ) throws IOException, SAXException { // Set up a workspace for 'cars' graph.createWorkspace().named("Cars"); graph.importXmlFrom("src/test/resources/cars.xml").into("/"); // Set up a workspace for 'aircraft' graph.createWorkspace().named("Aircraft"); graph.importXmlFrom("src/test/resources/aircraft.xml").into("/"); }
Graph graph = Graph.create(inMemorySource, context); graph.useWorkspace(defaultWorkspaceName); graph.importXmlFrom(content).into("/"); } catch (IOException e) { inMemorySource = null;
@Before public void beforeEaach() throws SAXException, IOException { context = new ExecutionContext(); graphSource = new InMemoryRepositorySource(); graphSource.setName("Graph source"); graph = Graph.create(graphSource, context); graph.importXmlFrom(resourceUrl("aircraft.xml")).into("/"); }
store.importXmlFrom(getClass().getClassLoader().getResourceAsStream("cars.xml")).into("/"); LOADING_STOPWATCH.stop(); numberOfConnections = 0; // reset the number of connections
graph.importXmlFrom(configurationFileInputStream).skippingRootElement(true).into(pathToParent);