コード例 #1
0
  public List<ReMSerialisation> getReMSerialisations() throws OREException {
    try {
      List<ReMSerialisation> serialisations = new ArrayList<ReMSerialisation>();
      StmtIterator itr = res.listProperties(ORE.isDescribedBy);
      while (itr.hasNext()) {
        Statement statement = itr.nextStatement();
        Resource resource = (Resource) statement.getObject();
        StmtIterator itr2 = resource.listProperties(DC.format);
        StmtIterator itr3 = resource.listProperties(OREX.isAuthoritativeFor);
        String mime = "application/octet-stream";
        if (itr2.hasNext()) {
          Statement stmt = itr2.nextStatement();
          mime = ((Literal) stmt.getObject()).getLexicalForm();
        }
        boolean authoritative = false;
        if (itr3.hasNext()) {
          authoritative = true;
        }
        ReMSerialisation serialisation = new ReMSerialisation(mime, new URI(resource.getURI()));
        serialisation.setAuthoritative(authoritative);

        serialisations.add(serialisation);
      }
      return serialisations;
    } catch (URISyntaxException e) {
      throw new OREException(e);
    }
  }
コード例 #2
0
  public void addReMSerialisation(ReMSerialisation serialisation) throws OREException {
    URI uri = serialisation.getURI();
    ResourceMap rem = this.getResourceMap(uri);
    if (rem != null) {
      return;
    }
    this.addResourceMapURI(uri);

    String mime = serialisation.getMimeType();
    if (mime == null) {
      mime = "application/octet-stream";
    }
    Literal literal = model.createTypedLiteral(mime);
    Statement statement =
        model.createStatement(model.getResource(uri.toString()), DC.format, literal);
    model.add(statement);
  }