Package com.hp.hpl.jena.rdf.model

Examples of com.hp.hpl.jena.rdf.model.Resource


    ResIterator subjectIter = model.listSubjectsWithProperty(
        ACCOUNTMANAGER.userName, username);
    if (!subjectIter.hasNext()) {
      return null;
    }
    Resource subject = subjectIter.nextResource();
    if (subjectIter.hasNext()) {
      throw new RuntimeException("Username ambiguos");
    }
    return subject;
  }
View Full Code Here


            model.notifyEvent( GraphEvents.finishRead );
        }
    }
   
    protected final void unwrappedReadRDF() {
        Resource subject;
        Property predicate = null;
        RDFNode object;

        while (!in.eof()) {
            while (!in.eof()) {
View Full Code Here

            }
        }
    }

    protected Resource lookupResource(String name)  {
        Resource r;
        r = model.createResource(getAnonId(name));
        return r;
    }
View Full Code Here

    Model logModel = JenaUtil.getModelFromGraph(currentLog);
    Set<Source> result = new HashSet<Source>();
    ResIterator sourceIter = configurationModel.listSubjectsWithProperty(
        RDF.type, AGGREGATOR.AggregatedSource);
    while (sourceIter.hasNext()) {
      Resource aggregatedSource = sourceIter.nextResource();
      Date lastAggregation = getLastAggregationDate((Resource) aggregatedSource
          .inModel(logModel));
      if (lastAggregation == null) {
        result.add(new SourceImpl(aggregatedSource.getURI()));
      } else {
        int aggregationInterval = aggregatedSource.getProperty(
            AGGREGATOR.interval).getInt();
        Date aggregationDueDate = new Date(lastAggregation.getTime()
            + aggregationInterval * 1000);
        if (!aggregationDueDate.after(now)) {
          result.add(new SourceImpl(aggregatedSource.getURI()));
        }
      }
    }
    return result;
  }
View Full Code Here

    public Configuration(Store store, GraphOverTime configGOT,
        NamedNode configuration) {

      Graph configGraph = configGOT.getGraph(new Date());
      Model configModel = JenaUtil.getModelFromGraph(configGraph);
      Resource httpConfigRes = configModel.createResource(configuration
          .getURIRef());
      Statement amConfigStmt = httpConfigRes
          .getProperty(WEBACCOUNTMANAGER.webAccountManagerConfiguration);
      if (amConfigStmt != null) {
        Resource amConfigRes = amConfigStmt.getResource();
        Statement smtpHostStmt = amConfigRes
            .getProperty(WEBACCOUNTMANAGER.smtpServer);
        if (smtpHostStmt != null) {
          smtpHost = smtpHostStmt.getString();
        }
        Statement fromAddressStmt = amConfigRes
            .getProperty(WEBACCOUNTMANAGER.fromAddress);
        if (fromAddressStmt != null) {
          fromAddress = fromAddressStmt.getString();
        }
      }
View Full Code Here

    Model model = aggregatedSource.getModel();
    ResIterator downloadAttempts = model
        .listSubjectsWithProperty(AGGREGATOR.aggregatedSource, aggregatedSource);
    Date result = null;
    while (downloadAttempts.hasNext()) {
      Resource downloadAtttempt = downloadAttempts.nextResource();
      Date time;
      try {
        time = new W3CDateFormat().parse(downloadAtttempt.getProperty(
            AGGREGATOR.time).getString());
      } catch (ParseException e) {
        throw new RuntimeException(e);
      }
      if ((result == null) || (time.after(result))) {
View Full Code Here

      throw new RuntimeException(e);
    }
    Date now = new Date();

    Model logEntryModel = ModelFactory.createDefaultModel();
    Resource downloadAttempt = logEntryModel
        .createResource(AGGREGATOR.DownloadAttempt);
    downloadAttempt.addProperty(AGGREGATOR.time, new W3CDateFormat()
        .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);
        }
      }
    } catch (Throwable th) {
      if (!(th instanceof AllreadyLoggedRuntimeException)) {
        String errorMessage = th.getMessage();
        if (errorMessage == null) {
          errorMessage = th.toString();
        }
        downloadAttempt.addProperty(AGGREGATOR.errorMessage, errorMessage);
      }
    }
    String warningMessage = aggregationWarningWriter.toString();
    if (!warningMessage.equals("")) {
      downloadAttempt.addProperty(AGGREGATOR.warningMessage, warningMessage);
    }

    updateWorkingGraph(store, identity, now, aggregatedSource, logEntryGraph);
    //store.assertGraph(identity, new FCAGraphImpl(logEntryGraph), now);
  }
View Full Code Here

    Source identity = new SourceImpl("http://example.org/tests/identity");
    Set<Source> trustedSources  = new HashSet<Source>();
    trustedSources.add(identity);
    NamedNode configuration = new NamedNodeImpl("http://example.org/tests/configuration#");
    Model authorizationModel = ModelFactory.createDefaultModel();
    Resource user = authorizationModel.createResource(FOAF.Agent);
    user.addProperty(ACCOUNTMANAGER.userName, "beta");
    user.addProperty(ACCOUNTMANAGER.passwordSha1, Util.sha1("tester"));
    user.addProperty(AUTHORIZATION.mayImpersonate, authorizationModel.createResource(sourceURL.toString()));
    store.assertGraph(identity, new FCAGraphImpl(authorizationModel));
    WebServer webServer = GVSServerLauncher.launchGVSServer(store, serverBinding, identity ,
        trustedSources, configuration);

    Model model = ModelFactory.createDefaultModel();
View Full Code Here

      private void addURIsForType(Model model, OntClass type) {
        ResIterator subjectIter = model.listSubjectsWithProperty(
            RDF.type, type);
        // model.write(System.out);
        while (subjectIter.hasNext()) {
          Resource infoDiscoResource = subjectIter.nextResource();
          RDFNode infoBitNode = infoDiscoResource.getProperty(
              DISCOBITS.infoBit).getObject();
          if (infoBitNode instanceof Literal) {
            final Literal literaInfoBit = (Literal) infoBitNode;
            infoDiscoBitURIs.put(infoDiscoResource.getURI(),
                new InfoBit() {

                  public MessageBody getContent() {
                    return new MessageBody2Read() {

                      public ReadableByteChannel read()
                          throws IOException {
                        // TODO Auto-generated method
                        // stub
                        return Channels
                            .newChannel(new ByteArrayInputStream(
                                literaInfoBit
                                    .getString()
                                    .getBytes(
                                        "utf-8")));
                      }

                    };
                  }

                  public String getMimeTypeString() {
                    return "application/xhtml+xml";
                  }

                });
          } else {
            final Resource literaInfoBit = (Resource) infoBitNode;
            infoDiscoBitURIs.put(infoDiscoResource.getURI(),
                new InfoBit() {

                  public MessageBody getContent() {
                    return new MessageBody2Read() {

                      public ReadableByteChannel read()
                          throws IOException {
                        // TODO Auto-generated method
                        // stub
                        return Channels
                            .newChannel(new ByteArrayInputStream(
                                (byte[]) literaInfoBit.getRequiredProperty(DISCOBITS.bytes).getLiteral().getValue()
                                    ));
                      }

                    };
                  }

                  public String getMimeTypeString() {
                    return literaInfoBit.getRequiredProperty(DISCOBITS.mediaType).getString();
                  }

                });
          }
        }
View Full Code Here

      throws HandlerException {
    MultiPartBody body = ParameterUtil.parseMultipart(request);
    final FormFile formFile = body.getFormFileParameterValues("file")[0];
    final String locationString = body.getTextParameterValues("location")[0];
    final Model editableModel = ModelFactory.createDefaultModel();
    final Resource infoBitResource = editableModel.createResource();
   
    infoBitResource.addProperty(DISCOBITS.mediaType, formFile
        .getMimeType().toString());
    infoBitResource.addProperty(DISCOBITS.bytes, editableModel
        .createTypedLiteral(formFile.getContent()));
    infoBitResource.addProperty(RDF.type, DISCOBITS.InfoBit);
    store.perform(identity, new StoreTransaction() {

      public void execute(SourceStoreView storeView) {
        NamedNode locationNode = new NamedNodeImpl(locationString);
        FCAGraph origGraph = storeView.getGraph().filter(
            Collections.singleton((GroundedNode) locationNode));
        Model origModel = ModelFactory.createModelForGraph(origGraph);
        editableModel.add(origModel);
        Resource locationResource = editableModel
            .createResource(locationString);
        locationResource.addProperty(RDF.type, DISCOBITS.InfoDiscoBit);
        locationResource.removeAll(DISCOBITS.infoBit);
        locationResource.addProperty(DISCOBITS.infoBit, infoBitResource);
        storeView.revokeGraph(origGraph);
        storeView.assertGraph(new FCAGraphImpl(editableModel));
      }

    });
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.rdf.model.Resource

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.