public Configuration(Model configurationModel) {
    model = configurationModel;
    StmtIterator it = model.listStatements(null, RDF.type, CONF.Configuration);
    if (!it.hasNext()) {
      throw new IllegalArgumentException("No conf:Configuration found in configuration model");
    }
    config = it.nextStatement().getSubject();

    datasets = new ArrayList();
    it = model.listStatements(config, CONF.dataset, (RDFNode) null);
    while (it.hasNext()) {
      datasets.add(new Dataset(it.nextStatement().getResource()));
    }
    labelProperties = new ArrayList();
    it = model.listStatements(config, CONF.labelProperty, (RDFNode) null);
    while (it.hasNext()) {
      labelProperties.add(it.nextStatement().getObject().as(Property.class));
    }
    if (labelProperties.isEmpty()) {
      labelProperties.add(RDFS.label);
      labelProperties.add(DC.title);
      labelProperties.add(model.createProperty("http://xmlns.com/foaf/0.1/name"));
    }
    commentProperties = new ArrayList();
    it = model.listStatements(config, CONF.commentProperty, (RDFNode) null);
    while (it.hasNext()) {
      commentProperties.add(it.nextStatement().getObject().as(Property.class));
    }
    if (commentProperties.isEmpty()) {
      commentProperties.add(RDFS.comment);
      commentProperties.add(DC.description);
    }
    imageProperties = new ArrayList();
    it = model.listStatements(config, CONF.imageProperty, (RDFNode) null);
    while (it.hasNext()) {
      imageProperties.add(it.nextStatement().getObject().as(Property.class));
    }
    if (imageProperties.isEmpty()) {
      imageProperties.add(model.createProperty("http://xmlns.com/foaf/0.1/depiction"));
    }

    prefixes = new PrefixMappingImpl();
    if (config.hasProperty(CONF.usePrefixesFrom)) {
      it = config.listProperties(CONF.usePrefixesFrom);
      while (it.hasNext()) {
        Statement stmt = it.nextStatement();
        prefixes.setNsPrefixes(FileManager.get().loadModel(stmt.getResource().getURI()));
      }
    } else {
      prefixes.setNsPrefixes(model);
    }
    if (prefixes.getNsURIPrefix(CONF.NS) != null) {
      prefixes.removeNsPrefix(prefixes.getNsURIPrefix(CONF.NS));
    }
  }
示例#2
0
 public R2RMLWriter(Mapping mapping) {
   super(mapping);
   this.mapping = mapping;
   prefixes.setNsPrefixes(mapping.getPrefixes());
   if (!prefixes.getNsPrefixMap().containsValue(RR.NS)) {
     prefixes.setNsPrefix("rr", RR.NS);
   }
 }