当前位置: 首页>>代码示例>>Java>>正文


Java ContinuousConstruct类代码示例

本文整理汇总了Java中org.deri.cqels.engine.ContinuousConstruct的典型用法代码示例。如果您正苦于以下问题:Java ContinuousConstruct类的具体用法?Java ContinuousConstruct怎么用?Java ContinuousConstruct使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ContinuousConstruct类属于org.deri.cqels.engine包,在下文中一共展示了ContinuousConstruct类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeQuery

import org.deri.cqels.engine.ContinuousConstruct; //导入依赖的package包/类
@Override
public void removeQuery(int query_id) {
    if (queries.containsKey(query_id)) {
        logger.debug("Removing query");
        OpRouter1 op = queries.get(query_id);
        if (op instanceof ContinuousConstruct) {
            context.unregisterConstruct((ContinuousConstruct) op);
        } else {
            context.unregisterSelect((ContinuousSelect) op);
        }
        queries.remove(query_id, op);
    } else {
        logger.error("Select not found!");
        logger.debug(queries.keySet().toString());
    }
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:17,代码来源:CQELS.java

示例2: simpleConstruct

import org.deri.cqels.engine.ContinuousConstruct; //导入依赖的package包/类
@Test(timeout = 5000)
public void simpleConstruct() {
    final String STREAM_ID = STREAM_ID_PREFIX + "_1";
    RDFStream stream = new DefaultRDFStream(context, STREAM_ID);

    ContinuousConstruct query = context.registerConstruct(""
            + "CONSTRUCT{?x ?y ?z} WHERE {"
            + "STREAM <" + STREAM_ID + "> [NOW] {?x ?y ?z}"
            + "}");
    ConstructAssertListener listener = new ConstructAssertListener(
            context, STREAM_ID);
    query.register(listener);

    stream.stream(new Triple(
            Node.createURI("http://example.org/resource/1"),
            Node.createURI("http://example.org/ontology#hasValue"),
            Node.createLiteral("123")));

    List<Triple> graph = await().until(listener, hasSize(1));
    assertEquals("http://example.org/resource/1",
            graph.get(0).getSubject().getURI());
    assertEquals("http://example.org/ontology#hasValue",
            graph.get(0).getPredicate().getURI());
    assertEquals("123", graph.get(0).getObject().getLiteralLexicalForm());
}
 
开发者ID:KMax,项目名称:cqels,代码行数:26,代码来源:SimpleQueriesTest.java

示例3: registerQuery

import org.deri.cqels.engine.ContinuousConstruct; //导入依赖的package包/类
@Override
public boolean registerQuery(int query_id) {
    String query = db.getQuery(query_id).getString("text");
    try {
        if (query.toLowerCase().contains("select") || query.toLowerCase().contains("construct")) {
            if (query.toLowerCase().contains("construct")) {
                ContinuousConstruct cc = context.registerConstruct(query);
                cc.register(new ConstructListener(context) {

                    @Override
                    public void update(List<Triple> graph) {
                        String message = getString(graph);
                        sendToWAMP(message);
                        //appendData(message);
                    }
                });
                queries.put(query_id, cc);
            } else {
                ContinuousSelect cs = context.registerSelect(query);
                cs.register(new ContinuousListener() {

                    @Override
                    public void update(Mapping m) {
                        sendToWAMP(getString(m));
                    }
                });
                queries.put(query_id, cs);
            }
        }
    } catch (com.hp.hpl.jena.query.QueryException e) {
        logger.debug("Query \n" + query + "\n has ERROR!\n + " + e.getMessage());
        return false;
    }
    return true;
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:36,代码来源:CQELS.java

示例4: registerConstruct

import org.deri.cqels.engine.ContinuousConstruct; //导入依赖的package包/类
@Override
public int registerConstruct(final String query) {
    ContinuousConstruct construct = cqelsEngine.getContext()
            .registerConstruct(query);
    construct.register(new ConstructListener(cqelsEngine.getContext()) {

        @Override
        public void update(List<Triple> graph) {
            Model model = ModelFactory.createDefaultModel();
            graph.stream().forEach((t) -> {
                Resource subject = ResourceFactory
                        .createResource(t.getSubject().getURI());
                Property predicate = ResourceFactory
                        .createProperty(t.getPredicate().getURI());
                RDFNode object = null;
                if (t.getObject().isLiteral()) {
                    object = ResourceFactory.createTypedLiteral(
                            t.getObject().getLiteralValue());
                } else {
                    object = ResourceFactory.createResource(
                            t.getObject().getURI());
                }
                model.add(subject, predicate, object);
            });
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            model.write(out, "TTL");
            streamService.publish(STREAM_URI, out.toString());
        }
    });
    return 0;
}
 
开发者ID:ailabitmo,项目名称:DAAFSE,代码行数:32,代码来源:QueryExecutorServiceImpl.java

示例5: unregisterConstruct

import org.deri.cqels.engine.ContinuousConstruct; //导入依赖的package包/类
@Test
public void unregisterConstruct() throws InterruptedException {
    System.out.println("simpleUnregisterConstructTest");
    final String STREAM_ID = STREAM_ID_PREFIX + "_1";
    RDFStream stream = new DefaultRDFStream(context, STREAM_ID);

    ContinuousConstruct query = context.registerConstruct(""
            + "CONSTRUCT{?x ?y ?z} WHERE {"
            + "STREAM <" + STREAM_ID + "> [NOW] {?x ?y ?z}"
            + "}");
    ConstructAssertListener listener = new ConstructAssertListener(context,
            STREAM_ID);
    query.register(listener);

    stream.stream(new Triple(
            ResourceFactory.createResource(
                    "http://example.org/resource/1").asNode(),
            ResourceFactory.createProperty(
                    "http://example.org/ontology#hasValue").asNode(),
            ResourceFactory.createPlainLiteral("456").asNode()));

    List<Triple> triples = await().until(listener, hasSize(1));
    Helpers.print(triples);

    assertEquals("http://example.org/resource/1",
            triples.get(0).getSubject().getURI());
    assertEquals("http://example.org/ontology#hasValue",
            triples.get(0).getPredicate().getURI());
    assertEquals("456", triples.get(0).getObject().getLiteralLexicalForm());

    context.unregisterConstruct(query);

    stream.stream(new Triple(
            ResourceFactory.createResource(
                    "http://example.org/resource/1").asNode(),
            ResourceFactory.createProperty(
                    "http://example.org/ontology#hasValue").asNode(),
            ResourceFactory.createPlainLiteral("987789").asNode()));
    triples = await()
            .timeout(Duration.TWO_HUNDRED_MILLISECONDS)
            .until(listener, hasSize(1));
    Helpers.print(triples);
    assertTrue(triples.size() == 1);
}
 
开发者ID:KMax,项目名称:cqels,代码行数:45,代码来源:UnregisterQueryTest.java

示例6: complexUnregisterConstruct

import org.deri.cqels.engine.ContinuousConstruct; //导入依赖的package包/类
@Test
public void complexUnregisterConstruct() {
    System.out.println("complexUnregisterConstructTest");
    final String STREAM_ID
            = "amqp://192.168.134.114?exchangeName=meter_exchange&routingKey=meter.location.mercury230_14759537";
    DefaultRDFStream stream = new DefaultRDFStream(context, STREAM_ID);

    context.loadDefaultDataset(
            "src/test/resources/org/deri/cqels/QueryTest/complexConstruct/dataset.ttl");

    ContinuousConstruct query = context.registerConstruct(
            "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
            + "PREFIX em: <http://purl.org/NET/ssnext/electricmeters#> \n"
            + "PREFIX pne: <http://data.press.net/ontology/event/> \n"
            + "PREFIX ssn: <http://purl.oclc.org/NET/ssnx/ssn#> \n"
            + "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> \n"
            + "PREFIX dul: <http://www.loa-cnr.it/ontologies/DUL.owl#> \n"
            + "CONSTRUCT {\n"
            + "	?alert a <http://purl.org/daafse/alerts#TooHighVoltageValue> ;\n"
            + "		dul:hasEventDate ?time ;\n"
            + "		dul:involvesAgent ?meter .\n"
            + "}\n"
            + "WHERE {\n"
            + "  ?meter em:hasStream ?stream .\n"
            + "  STREAM ?stream [NOW] {\n"
            + "    ?observation a em:PolyphaseVoltageObservation ;\n"
            + "              ssn:observationResultTime ?time ;\n"
            + "              ssn:observationResult ?output ."
            + "    ?output a em:PolyphaseVoltageSensorOutput ;\n"
            + "              ssn:isProducedBy ?meter ;\n"
            + "              ssn:hasValue ?value .\n"
            + "    ?value em:hasQuantityValue ?qvalue .\n"
            + "  }\n"
            + "  FILTER(?qvalue > 220)\n"
            + "  BIND(IRI(CONCAT(STR(?meter), '/alerts/', STR(?time))) AS ?alert)\n"
            + "}");
    ConstructAssertListener listener = new ConstructAssertListener(
            context, STREAM_ID);
    query.register(listener);

    Model model = ModelFactory.createDefaultModel();
    InputStream input = this.getClass().getResourceAsStream(
            "QueryTest/complexConstruct/observation.ttl");
    model.read(input, null, "TURTLE");

    stream.stream(model);

    List<Triple> graph = await().until(listener, hasSize(3));
    
    assertTrue(graph.contains(new Triple(
            Node.createURI("http://purl.org/meters/mercury230_14759537/alerts/2014-07-16T05:50:20.890Z"),
            Node.createURI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
            Node.createURI("http://purl.org/daafse/alerts#TooHighVoltageValue"))));
    assertTrue(graph.contains(new Triple(
            Node.createURI("http://purl.org/meters/mercury230_14759537/alerts/2014-07-16T05:50:20.890Z"),
            Node.createURI("http://www.loa-cnr.it/ontologies/DUL.owl#hasEventDate"),
            Node.createLiteral("2014-07-16T05:50:20.890Z", XSDDatatype.XSDdateTime))));
    assertTrue(graph.contains(new Triple(
            Node.createURI("http://purl.org/meters/mercury230_14759537/alerts/2014-07-16T05:50:20.890Z"),
            Node.createURI("http://www.loa-cnr.it/ontologies/DUL.owl#involvesAgent"),
            Node.createURI("http://purl.org/meters/mercury230_14759537"))));
    
    context.unregisterConstruct(query);
    
    stream.stream(model);
    graph = await().timeout(Duration.TWO_HUNDRED_MILLISECONDS).until(listener, hasSize(3));
    assertTrue(graph.size()==3);
}
 
开发者ID:KMax,项目名称:cqels,代码行数:69,代码来源:UnregisterQueryTest.java

示例7: complexConstruct

import org.deri.cqels.engine.ContinuousConstruct; //导入依赖的package包/类
@Test(timeout = 10000)
public void complexConstruct() {
    final String STREAM_ID
            = "amqp://192.168.134.114?exchangeName=meter_exchange&routingKey=meter.location.mercury230_14759537";
    DefaultRDFStream stream = new DefaultRDFStream(context, STREAM_ID);

    context.loadDefaultDataset(
            "src/test/resources/org/deri/cqels/QueryTest/complexConstruct/dataset.ttl");

    ContinuousConstruct query = context.registerConstruct(
            "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
            + "PREFIX em: <http://purl.org/NET/ssnext/electricmeters#> \n"
            + "PREFIX pne: <http://data.press.net/ontology/event/> \n"
            + "PREFIX ssn: <http://purl.oclc.org/NET/ssnx/ssn#> \n"
            + "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> \n"
            + "PREFIX dul: <http://www.loa-cnr.it/ontologies/DUL.owl#> \n"
            + "CONSTRUCT {\n"
            + "	?alert a <http://purl.org/daafse/alerts#TooHighVoltageValue> ;\n"
            + "		dul:hasEventDate ?time ;\n"
            + "		dul:involvesAgent ?meter .\n"
            + "}\n"
            + "WHERE {\n"
            + "  ?meter em:hasStream ?stream .\n"
            + "  STREAM ?stream [NOW] {\n"
            + "    ?observation a em:PolyphaseVoltageObservation ;\n"
            + "              ssn:observationResultTime ?time ;\n"
            + "              ssn:observationResult ?output ."
            + "    ?output a em:PolyphaseVoltageSensorOutput ;\n"
            + "              ssn:isProducedBy ?meter ;\n"
            + "              ssn:hasValue ?value .\n"
            + "    ?value em:hasQuantityValue ?qvalue .\n"
            + "  }\n"
            + "  FILTER(?qvalue > 220)\n"
            + "  BIND(IRI(CONCAT(STR(?meter), '/alerts/', STR(?time))) AS ?alert)\n"
            + "}");
    ConstructAssertListener listener = new ConstructAssertListener(
            context, STREAM_ID);
    query.register(listener);

    Model model = ModelFactory.createDefaultModel();
    InputStream input = this.getClass().getResourceAsStream(
            "QueryTest/complexConstruct/observation.ttl");
    model.read(input, null, "TURTLE");

    stream.stream(model);

    List<Triple> graph = await().until(listener, hasSize(3));
    System.out.println(Arrays.toString(graph.toArray()));
    assertTrue(graph.contains(new Triple(
            Node.createURI("http://purl.org/meters/mercury230_14759537/alerts/2014-07-16T05:50:20.890Z"),
            Node.createURI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
            Node.createURI("http://purl.org/daafse/alerts#TooHighVoltageValue"))));
    assertTrue(graph.contains(new Triple(
            Node.createURI("http://purl.org/meters/mercury230_14759537/alerts/2014-07-16T05:50:20.890Z"),
            Node.createURI("http://www.loa-cnr.it/ontologies/DUL.owl#hasEventDate"),
            Node.createLiteral("2014-07-16T05:50:20.890Z", XSDDatatype.XSDdateTime))));
    assertTrue(graph.contains(new Triple(
            Node.createURI("http://purl.org/meters/mercury230_14759537/alerts/2014-07-16T05:50:20.890Z"),
            Node.createURI("http://www.loa-cnr.it/ontologies/DUL.owl#involvesAgent"),
            Node.createURI("http://purl.org/meters/mercury230_14759537"))));
}
 
开发者ID:KMax,项目名称:cqels,代码行数:62,代码来源:SimpleQueriesTest.java


注:本文中的org.deri.cqels.engine.ContinuousConstruct类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。