use of com.thoughtworks.studios.shine.semweb.Graph in project gocd by gocd.
the class StageResourceImporter method load.
public Graph load(StageIdentifier stageIdentifier, TempGraphFactory tempGraphFactory, final XSLTTransformerRegistry transformerRegistry) throws GoIntegrationException {
LOGGER.debug("Attempting to import stage with url <{}> !", stageIdentifier);
long importStartingTime = System.currentTimeMillis();
try {
Stage stage = stageFinder.findStageWithIdentifier(stageIdentifier);
String baseUri = "https://localhost:8154/go";
Graph graph = loadIsolatedStageGraph(stageIdentifier, tempGraphFactory, transformerRegistry, stage, baseUri);
importPipeline(pipelineInstanceLoader.loadPipelineForShine(stage.getPipelineId()), graph, transformerRegistry, baseUri);
importJobs(graph, transformerRegistry, stage, baseUri);
return graph;
} finally {
LOGGER.debug("Done importing stage with url <{}> with {} ms!", stageIdentifier, System.currentTimeMillis() - importStartingTime);
}
}
use of com.thoughtworks.studios.shine.semweb.Graph in project gocd by gocd.
the class StageResourceImporter method importPipeline.
private void importPipeline(PipelineInstanceModel pipelineInstance, Graph graph, XSLTTransformerRegistry transformerRegistry, String baseUri) throws GoIntegrationException {
final GoGRDDLResourceRDFizer pipeline = new GoGRDDLResourceRDFizer("pipeline", XSLTTransformerRegistry.CRUISE_PIPELINE_GRAPH_GRDDL_XSL, graph, transformerRegistry, xmlApiService);
Graph pipelineGraph = pipeline.importURIUsingGRDDL(new PipelineXmlViewModel(pipelineInstance), baseUri);
graph.addTriplesFromGraph(pipelineGraph);
}
use of com.thoughtworks.studios.shine.semweb.Graph in project gocd by gocd.
the class StageStorage method load.
public Graph load(StageIdentifier stageIdentifier) {
String fileName = stagePath(stageIdentifier);
try {
InputStream inputStream = new BufferedInputStream(new FileInputStream(fileName));
Graph tempGraph = new InMemoryTempGraphFactory().createTempGraph();
tempGraph.addTriplesFromTurtle(inputStream);
inputStream.close();
return tempGraph;
} catch (IOException e) {
throw new ShineRuntimeException(String.format("Unable to read stage n3 file for " + stageIdentifier + "(file: %s). This should never happen.", fileName), e);
}
}
use of com.thoughtworks.studios.shine.semweb.Graph in project gocd by gocd.
the class GRDDLTransformer method transform.
public Graph transform(final Document inputDoc, TempGraphFactory graphFactory) throws GrddlTransformException {
final DocumentResult result = new DocumentResult();
try {
xsltTransformerRegistry.transformWithCorrectClassLoader(key, new XSLTTransformerExecutor<Void>() {
@Override
public Void execute(Transformer transformer) throws TransformerException {
DocumentSource source = new DocumentSource(inputDoc);
transformer.transform(source, result);
return null;
}
});
// TODO: likely need to optimize with some sort of streaming document reader here
Graph graph = graphFactory.createTempGraph();
graph.addTriplesFromRDFXMLAbbrev(new StringReader(result.getDocument().asXML()));
return graph;
} catch (ShineRuntimeException e) {
LOGGER.error("Could not convert to a graph. The document was: \n{}", result.getDocument().asXML(), e);
throw e;
} catch (TransformerException e) {
LOGGER.warn("Could not perform grddl transform. The document was: \n{}", result.getDocument().asXML(), e);
throw new GrddlTransformException(e);
}
}
use of com.thoughtworks.studios.shine.semweb.Graph in project gocd by gocd.
the class SesameGraph method close.
public void close() {
try {
for (Graph tempGraph : tempGraphs) {
tempGraph.close();
}
tempGraphs.clear();
conn.commit();
conn.close();
} catch (RepositoryException e) {
throw new ShineRuntimeException("Could not close graph!", e);
}
}
Aggregations