use of com.thoughtworks.studios.shine.semweb.Graph in project gocd by gocd.
the class NUnitRDFizer method importFile.
public Graph importFile(final String parentURI, Document document) throws GrddlTransformException {
final DocumentResult result = new DocumentResult();
final DocumentSource source = new DocumentSource(document);
try {
return xsltTransformerRegistry.transformWithCorrectClassLoader(XSLTTransformerRegistry.XUNIT_NUNIT_TO_JUNIT_XSL, new XSLTTransformerExecutor<Graph>() {
@Override
public Graph execute(Transformer transformer) throws TransformerException, GrddlTransformException {
transformer.transform(source, result);
return jUnitRDFizer.importFile(parentURI, result.getDocument());
}
});
} catch (TransformerException e) {
throw new ShineRuntimeException(e);
}
}
use of com.thoughtworks.studios.shine.semweb.Graph in project gocd by gocd.
the class StagesQuery method selectForSingleStage.
private <T> List<T> selectForSingleStage(String sparql, StageIdentifier stageIdentifier, RdfResultMapper<T> mapper) {
StagesQueryCache.CacheKey key = new StagesQueryCache.CacheKey(sparql, stageIdentifier);
List<T> mappedResults = (List<T>) cache.get(key);
if (mappedResults != null) {
return mappedResults;
}
synchronized (key.getKey().intern()) {
mappedResults = (List<T>) cache.get(key);
if (mappedResults != null) {
return mappedResults;
}
Graph graph = stageGraphLoader.load(stageIdentifier);
List<BoundVariables> boundVariableses = graph.select(sparql);
mappedResults = new ArrayList<>();
for (BoundVariables bv : boundVariableses) {
mappedResults.add(mapper.map(bv));
}
cache.put(mappedResults, key);
return mappedResults;
}
}
use of com.thoughtworks.studios.shine.semweb.Graph in project gocd by gocd.
the class JobResourceImporter method importJob.
public Graph importJob(JobInstance job, final String baseUri) throws GoIntegrationException {
LOGGER.debug("Attempting to import job {}", job);
JobXmlViewModel xmlModel = new JobXmlViewModel(job);
Graph jobGraph = rdfizer.importURIUsingGRDDL(xmlModel, baseUri);
URIReference jobURI = jobGraph.getURIReference(xmlModel.httpUrl(baseUri));
importArtifactsForJob(jobURI, jobGraph);
LOGGER.debug("Done building jobs graph with {} triples", jobGraph.size());
return jobGraph;
}
use of com.thoughtworks.studios.shine.semweb.Graph in project gocd by gocd.
the class LazyStageGraphLoader method load.
public Graph load(StageIdentifier stageIdentifier) {
if (stageStorage.isStageStored(stageIdentifier)) {
return stageStorage.load(stageIdentifier);
}
Graph graph;
try {
graph = importer.load(stageIdentifier, new InMemoryTempGraphFactory(), transformerRegistry);
} catch (Exception e) {
throw bomb(e);
}
stageStorage.save(graph);
return graph;
}
use of com.thoughtworks.studios.shine.semweb.Graph in project gocd by gocd.
the class StageResourceImporter method loadIsolatedStageGraph.
private Graph loadIsolatedStageGraph(StageIdentifier stageIdentifier, TempGraphFactory tempGraphFactory, XSLTTransformerRegistry transformerRegistry, final Stage stageWithIdentifier, final String baseUri) throws GoIntegrationException {
GoGRDDLResourceRDFizer stageRdfizer = new GoGRDDLResourceRDFizer("stage", XSLTTransformerRegistry.CRUISE_STAGE_GRAPH_GRDDL_XSL, tempGraphFactory, transformerRegistry, xmlApiService);
Graph graph = stageRdfizer.importURIUsingGRDDL(new StageXmlViewModel(stageWithIdentifier), baseUri);
if (!stageCompleted(graph)) {
throw new CanNotImportABuildingStageException(stageIdentifier + " is not completed yet, can not load test details");
}
return graph;
}
Aggregations