public R2RMLWriter(Mapping mapping) { super(mapping); this.mapping = mapping; prefixes.setNsPrefixes(mapping.getPrefixes()); if (!prefixes.getNsPrefixMap().containsValue(RR.NS)) { prefixes.setNsPrefix("rr", RR.NS); } }
/** * Creates a new component query for the provided web resource. * * @param resource a web resource */ private ComponentQuery(WebResource resource) { this.resource = resource.path(COMPONENTS_PATH); wfNode = NodeFactory.createVariable("w"); addPrefix(RDF_PREFIX, RDF_IRI); addPrefix(ONTOLOGY_PREFIX, ONTOLOGY_IRI); // Add prefixes already specified in the myExperiment API prefixMapping.setNsPrefix(WFDESC_PREFIX, WFDESC_IRI); prefixMapping.setNsPrefix(RDFS_PREFIX, RDFS_IRI); }
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)); } }
/** * Adds a prefix to the query. * * @param prefix the prefix * @param iri the IRI * @return this query */ private ComponentQuery addPrefix(String prefix, String iri) { if (prefix != null && !prefix.isEmpty() && iri != null && !iri.isEmpty()) { prefixes += "PREFIX " + prefix + ":<" + iri + ">\n"; prefixMapping.setNsPrefix(prefix, iri); } return this; }
@Test public void testWithDefaultMappings() { PrefixMapping pm = new PrefixMappingImpl(); pm.setNsPrefix("example", "http://example.com"); try { // make sure that it must update securedMapping.withDefaultMappings(pm); if (!securityEvaluator.evaluate(Action.Update, securedMapping.getModelNode())) { Assert.fail("Should have thrown AccessDenied Exception"); } } catch (final AccessDeniedException e) { if (securityEvaluator.evaluate(Action.Update, securedMapping.getModelNode())) { Assert.fail( String.format( "Should not have thrown AccessDenied Exception: %s - %s", e, e.getTriple())); } } }
@Override public SecuredPrefixMapping withDefaultMappings(final PrefixMapping map) { // mapping only updates if there are map entries to add. Since this gets called // when we are doing deep triple checks while writing we need to attempt the // update only if there are new updates to add. PrefixMapping m = holder.getBaseItem(); PrefixMappingImpl pm = new PrefixMappingImpl(); for (Entry<String, String> e : map.getNsPrefixMap().entrySet()) { if (m.getNsPrefixURI(e.getKey()) == null && m.getNsURIPrefix(e.getValue()) == null) { pm.setNsPrefix(e.getKey(), e.getValue()); } } if (!pm.getNsPrefixMap().isEmpty()) { checkUpdate(); holder.getBaseItem().withDefaultMappings(pm); } return holder.getSecuredItem(); }
/** * Create an instance of SecuredPrefixMapping * * @param graph The SecuredGraph that contains the prefixmapping. * @param prefixMapping The prefixmapping returned from the base graph. * @return The SecuredPrefixMapping. */ static SecuredPrefixMapping getInstance( final SecuredGraphImpl graph, final PrefixMapping prefixMapping) { final ItemHolder<PrefixMapping, SecuredPrefixMapping> holder = new ItemHolder<PrefixMapping, SecuredPrefixMapping>(prefixMapping); final SecuredPrefixMappingImpl checker = new SecuredPrefixMappingImpl(graph, holder); // if we are going to create a duplicate proxy just return this one. if (prefixMapping instanceof SecuredPrefixMapping) { if (checker.isEquivalent((SecuredPrefixMapping) prefixMapping)) { return (SecuredPrefixMapping) prefixMapping; } } return holder.setSecuredItem(new SecuredItemInvoker(prefixMapping.getClass(), checker)); }