Search in sources :

Example 21 with Graph

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);
    }
}
Also used : Graph(com.thoughtworks.studios.shine.semweb.Graph) Transformer(javax.xml.transform.Transformer) ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) DocumentResult(org.dom4j.io.DocumentResult) DocumentSource(org.dom4j.io.DocumentSource) GrddlTransformException(com.thoughtworks.studios.shine.semweb.grddl.GrddlTransformException) TransformerException(javax.xml.transform.TransformerException)

Example 22 with Graph

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;
    }
}
Also used : Graph(com.thoughtworks.studios.shine.semweb.Graph) BoundVariables(com.thoughtworks.studios.shine.semweb.BoundVariables) List(java.util.List) ArrayList(java.util.ArrayList)

Example 23 with Graph

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;
}
Also used : Graph(com.thoughtworks.studios.shine.semweb.Graph) URIReference(com.thoughtworks.studios.shine.semweb.URIReference) JobXmlViewModel(com.thoughtworks.go.server.domain.xml.JobXmlViewModel)

Example 24 with Graph

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;
}
Also used : Graph(com.thoughtworks.studios.shine.semweb.Graph) InMemoryTempGraphFactory(com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory)

Example 25 with 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;
}
Also used : Graph(com.thoughtworks.studios.shine.semweb.Graph) StageXmlViewModel(com.thoughtworks.go.server.domain.xml.StageXmlViewModel) GoGRDDLResourceRDFizer(com.thoughtworks.studios.shine.cruise.GoGRDDLResourceRDFizer)

Aggregations

Graph (com.thoughtworks.studios.shine.semweb.Graph)41 Test (org.junit.Test)26 InMemoryTempGraphFactory (com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory)18 File (java.io.File)7 JobXmlViewModel (com.thoughtworks.go.server.domain.xml.JobXmlViewModel)5 ShineRuntimeException (com.thoughtworks.studios.shine.ShineRuntimeException)5 InputStream (java.io.InputStream)5 TestFailureSetup (com.thoughtworks.go.server.dao.sparql.TestFailureSetup)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 Date (java.util.Date)4 Pipeline (com.thoughtworks.go.domain.Pipeline)3 Stage (com.thoughtworks.go.domain.Stage)3 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)3 StageXmlViewModel (com.thoughtworks.go.server.domain.xml.StageXmlViewModel)3 XSLTTransformerRegistry (com.thoughtworks.studios.shine.semweb.grddl.XSLTTransformerRegistry)3 Modification (com.thoughtworks.go.domain.materials.Modification)2 GoGRDDLResourceRDFizer (com.thoughtworks.studios.shine.cruise.GoGRDDLResourceRDFizer)2 BoundVariables (com.thoughtworks.studios.shine.semweb.BoundVariables)2 IOException (java.io.IOException)2 Transformer (javax.xml.transform.Transformer)2