Package org.wymiwyg.rdf.graphs

Examples of org.wymiwyg.rdf.graphs.Graph


      return getNextSubGraph();
    }

    private Graph getNextSubGraph() {
      int count = 0;
      Graph currentGraph = new SimpleGraph();
      for (TripleInfo info : tripleInfos) {
        switch (info.status) {
        case undefined:
          if (count < omitUndefined) {
            count++;
            break;
          } else {
            currentGraph.add(info.triple);
          }
          ;
          break;
        case needed:
          currentGraph.add(info.triple);
        }
      }
      if (count == 0) {
        return null;
      }
      System.out.println("returning subgraph of size "
          + currentGraph.size());
      return currentGraph;
    }
View Full Code Here


   *
   * @throws Exception
   */
  public void testSimpleBody() throws Exception {
    Model model = modelWithStatements("_a dc:subject _b; _a rdfs:comment '���'");
    final Graph body = JenaUtil.getGraphFromModel(model, true);
    WebServer webServer = createServer().startNewWebServer(new GraphHandlerAdaptor(new GraphHandler() {

      public void handle(Request request, TypedResponse<Graph> response) throws HandlerException {
        response.setBody(body);
      }
View Full Code Here

            if (triples == null) {
              triples = new MoleculeReader<Graph>() {

                @Override
                protected Graph asMolecule(Graph graphFromModel) {
                  Graph deNaturalized = deNaturalize(graphFromModel);
                  if (deNaturalized.size() > 1) {
                    throw new RuntimeException(
                        "nt-molecules should be of size 1");
                  }
                  Triple triple = deNaturalized.iterator()
                      .next();
                  Node subject = triple.getSubject();
                  if (!(subject instanceof GroundedNode)) {
                    subject = NonTerminalMolecule.GROUNDED_NODE;
                  }
View Full Code Here

     */

    public M readComponent(ComponentDirectory componentDirectory) {
      File modelFile = new File(componentDirectory.getDirectory(),
          "graph");
      Graph graph = cache.get(modelFile);
      if (graph == null) {
        Model model = ModelFactory.createDefaultModel();
        try {
          URL modelFileUrl = modelFile.toURL();
          if (log.isDebugEnabled()) {
View Full Code Here

              .get(verificationParameters[0]);
          if (loginData == null) {
            throw new HandlerException(
                "Verification string not found, probably expired");
          }
          Graph graph = new SimpleGraph();
          addUser(loginData, graph, request);
          response
              .setDefaultStylesheet("/application/stylesheets/verification-result");
          response.setBody(graph);
          Resource user = getUserByUsernameInIdentityGOT(loginData.userName);
View Full Code Here

  /**
   * @param username
   * @return
   */
  private Resource getUserByUsername(String username) {
    Graph graph = configGOT.getGraph(new Date());
    Model model = JenaUtil.getModelFromGraph(graph);
    ResIterator subjectIter = model.listSubjectsWithProperty(
        ACCOUNTMANAGER.userName, username);
    if (!subjectIter.hasNext()) {
      return null;
View Full Code Here

    }
    // trustedSources.addAll(Arrays.asList(arguments.getTrustedSources()));
    if (trustedSources.contains(defaultConfigSource)) {
      ensureDefaultConfigLoaded(store);
    }
    Graph serviceConfig = store.getGraphOverTime(trustedSources).getGraph(
        new Date());
    Model serviceConfigModel = JenaUtil.getModelFromGraph(serviceConfig);
    serviceConfigModel.write(System.out);
    ResIterator servicesIter = serviceConfigModel.listSubjectsWithProperty(RDF.type, SERVICES.Service);
    while (servicesIter.hasNext()) {
View Full Code Here

    }
    return subject;
  }

  private Resource getUserByUsernameInIdentityGOT(String username) {
    Graph graph = store.getGraphOverTime(Collections.singleton(identity))
        .getGraph(new Date());
    Model model = JenaUtil.getModelFromGraph(graph);
    ResIterator subjectIter = model.listSubjectsWithProperty(
        ACCOUNTMANAGER.userName, username);
    if (!subjectIter.hasNext()) {
View Full Code Here

  @Override
  public void run() {
    while (true) {
      Date now = new Date();
      Graph currentConfiguration = configuration.getGraph(now);
      Graph currentLog = logReader.getGraph(now);
      Set<Source> dueSources = getDueSources(currentConfiguration,
          currentLog, now);
      for (Source node : dueSources) {
        aggregate(node, store, identity);
      }
View Full Code Here

        .format(now), XSDDatatype.XSDdateTime);
    downloadAttempt.addProperty(AGGREGATOR.aggregatedSource, logEntryModel
        .createResource(aggregatedSource.getURIRef()));
    downloadAttempt.addProperty(AGGREGATOR.aggregator, logEntryModel
        .createResource(identity.getURIRef()));
    Graph logEntryGraph = JenaUtil.getGraphFromModel(logEntryModel, true);
    final StringWriter aggregationWarningWriter = new StringWriter();
    final StringWriter aggregationErrorWriter = new StringWriter();
    try {
      Model model = ModelFactory.createDefaultModel();
      // model.read(url.toString());
      JenaReader jenaReader = new JenaReader();
      jenaReader.setErrorHandler(new RDFErrorHandler() {

        public void error(Exception e) {
          aggregationErrorWriter.write(e.getMessage());
        }

        public void fatalError(Exception e) {
          aggregationErrorWriter.write("FATAL: ");
          aggregationErrorWriter.write(e.getMessage());
          log.info("Fatal Error aggregating "+aggregatedSource, e);
          throw new AllreadyLoggedRuntimeException(e);
        }

        public void warning(Exception e) {
          aggregationWarningWriter.write(e.getMessage());
        }

      });
      jenaReader.read(model, url.toString());
      String errorMessage = aggregationErrorWriter.toString();
      if (errorMessage.equals("")) {
        Graph graph = JenaUtil.getGraphFromModel(model, true);
        store.updateGraph(aggregatedSource, new FCAGraphImpl(graph));
      } else {
        if (!errorMessage.equals("")) {
          downloadAttempt.addProperty(AGGREGATOR.errorMessage, errorMessage);
        }
View Full Code Here

TOP

Related Classes of org.wymiwyg.rdf.graphs.Graph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.