use of com.thoughtworks.studios.shine.semweb.Graph in project gocd by gocd.
the class BackgroundStageLoaderIntegrationTest method handleAStageURLNotYetSeenShouldStoreStageResourceIntoStageStorage.
@Test
public void handleAStageURLNotYetSeenShouldStoreStageResourceIntoStageStorage() {
TestFailureSetup.SavedStage savedStage = failureSetup.setupPipelineInstanceWithoutTestXmlStubbing(true, null, new Date());
loader.handle(feedEntry(savedStage), pipelineInstanceLoader);
assertTrue(stageStorage.isStageStored(savedStage.stageId));
Graph storedGraph = stageStorage.load(savedStage.stageId);
Stage stage = savedStage.stage;
String baseUrl = "https://localhost:8154/go";
String jobUrl = new JobXmlViewModel(stage.getJobInstances().first()).httpUrl(baseUrl);
assertTrue(storedGraph.containsResourceWithURI(jobUrl));
assertTrue(storedGraph.containsResourceWithURI(new StageXmlViewModel(stage).httpUrl(baseUrl)));
Pipeline pipeline = savedStage.pipeline;
assertTrue(storedGraph.containsResourceWithURI(PipelineXmlViewModel.httpUrlForPipeline(baseUrl, pipeline.getId(), pipeline.getName())));
Modification latestModification = pipeline.getMaterialRevisions().getRevisions().get(0).getLatestModification();
assertTrue(storedGraph.containsResourceWithURI(ScmMaterial.changesetUrl(latestModification, baseUrl, latestModification.getMaterialInstance().getId())));
}
use of com.thoughtworks.studios.shine.semweb.Graph in project gocd by gocd.
the class StageResourceImporterTest method shouldImportPipelineBuildTriggers.
@Test
public void shouldImportPipelineBuildTriggers() throws Exception {
TestFailureSetup.SavedStage savedStage = failureSetup.setupPipelineInstanceWithoutTestXmlStubbing(true, null, new Date());
Graph graph = importer.load(savedStage.stageId, graphFactory, new XSLTTransformerRegistry());
for (Modification modification : savedStage.pipeline.getMaterialRevisions().getRevisions().get(0).getModifications()) {
String changeSetUri = ScmMaterial.changesetUrl(modification, baseUrl, modification.getMaterialInstance().getId());
assertTrue(graph.containsResourceWithURI(changeSetUri));
String ask = "" + "PREFIX cruise: <" + GoOntology.URI + "> " + "PREFIX xsd:<http://www.w3.org/2001/XMLSchema#> " + "ASK WHERE {" + " <" + PipelineXmlViewModel.httpUrlForPipeline(baseUrl, savedStage.pipeline.getId(), savedStage.pipeline.getName()) + "> cruise:pipelineTrigger <" + changeSetUri + "> . " + "}";
assertAskIsTrue(graph, ask);
}
}
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);
}
}
Aggregations