/** * Create a File-based resource reader * @param directory the data storage directory * @param identifier the resource to retrieve * @param data the resource data */ protected CachedResource(final File directory, final IRI identifier, final ResourceData data) { super(directory, identifier, data); LOGGER.debug("Fetching a Cached Resource for {}", identifier.getIRIString()); }
@Deprecated public String getValue() { return iri.getIRIString(); } }
/** * Test if the given ldp:constrainedBy link is present. * @param iri the IRI * @return true if present; false otherwise */ public static Predicate<Link> hasConstrainedBy(final IRI iri) { return link -> LDP.constrainedBy.getIRIString().equals(link.getRel()) && iri.getIRIString().equals(link.getUri().toString()); }
/** * Partition an identifier into a directory structure * @param identifier the identifier * @return a string usable as a directory path */ public static String partition(final IRI identifier) { return partition(identifier.getIRIString()); }
/** * Get the resource directory for a given identifier * @param dataLocation the data location * @param identifier the identifier * @return the file */ public static File resourceDirectory(final String dataLocation, final IRI identifier) { return resourceDirectory(dataLocation, identifier.getIRIString()); }
/** * This code is equivalent to the SPARQL query below. * * <p><pre><code> * SELECT ?subject ?predicate ?object * WHERE { GRAPH IDENTIFIER?ext=audit { ?subject ?predicate ?object } } * </code></pre> */ private Stream<Quad> fetchAuditQuads() { return fetchAllFromGraph(identifier.getIRIString() + "?ext=audit", Trellis.PreferAudit); }
public static String getObjectValue(final RDFTerm term) { if (term instanceof IRI) { return ((IRI) term).getIRIString(); } else if (term instanceof Literal) { return ((Literal) term).getLexicalForm(); } return null; }
protected InterProcessLock getLock(final IRI identifier) { final String path = ZNODE_COORDINATION + PATH_SEPARATOR + md5Hex(identifier.getIRIString()); return new InterProcessSemaphoreMutex(curator, path); } }
@Override public int compare(Datatype o1, Datatype o2) { return o1.getIRI().getIRIString().compareTo(o2.getIRI().getIRIString()); } };
@Override public String getAuthorizationHeader() { return buildJwt(Trellis.AdministratorAgent.getIRIString(), AbstractApplicationAuthTests.this.getJwtSecret()); } }
ClassImpl(IRI iri) { this.iri = iri; this.name = iri.getIRIString(); this.isNothing = iri.equals(OWL.NOTHING); this.isThing = iri.equals(OWL.THING); }
/** * Fetch a stream of the audit-related quads. */ private Stream<Quad> fetchAuditQuads() { final String query = "SELECT subject, predicate, object, lang, datatype FROM log WHERE id = ?"; return jdbi.withHandle(handle -> handle.select(query, getIdentifier().getIRIString()) .map((rs, ctx) -> rdf.createQuad(Trellis.PreferAudit, rdf.createIRI(rs.getString(SUBJECT)), rdf.createIRI(rs.getString(PREDICATE)), getObject(rs.getString(OBJECT), rs.getString(LANG), rs.getString(DATATYPE)))) .stream()); }
ObjectPropertyExpressionImpl(IRI iri) { this.iri = iri; this.isInverse = false; this.string = iri.getIRIString(); this.isTop = iri.equals(OWL.TOP_OBJECT_PROPERTY); this.isBottom = iri.equals(OWL.BOTTOM_OBJECT_PROPERTY); if (isTop || isBottom) this.inverseProperty = this; // rule [R6] else this.inverseProperty = new ObjectPropertyExpressionImpl(iri, this); this.domain = new ObjectSomeValuesFromImpl(this); }
public static Resource getResource(ObjectConstant obj) { if (obj instanceof BNode) return fact.createBNode(((BNode)obj).getName()); else if (obj instanceof IRIConstant) return fact.createIRI(((IRIConstant) obj).getIRI().getIRIString()); else return null; //throw new IllegalArgumentException("Invalid constant as subject!" + obj); }
/*** * Translates from assertion objects into * * @param constant * @return */ public OWLIndividual translate(ObjectConstant constant) { if (constant instanceof IRIConstant) return dataFactory.getOWLNamedIndividual(IRI.create(((IRIConstant)constant).getIRI().getIRIString())); else /*if (constant instanceof BNode)*/ return dataFactory.getOWLAnonymousIndividual(((BNode) constant).getName()); }
@Override public ImmutableTerm visitResource(ResourceContext ctx) { if (ctx.iriExt() != null) { return visitIriExt(ctx.iriExt()); } return constructIRI(this.visitIri(ctx.iri()).getIRIString()); }
public OWLAnnotationValue translateAnnotationValue(Constant constant) { if (constant instanceof ValueConstant) return translate((ValueConstant) constant); else if (constant instanceof IRIConstant) return IRI.create(((IRIConstant) constant).getIRI().getIRIString()); else if (constant instanceof BNode) return dataFactory.getOWLAnonymousIndividual(((BNode) constant).getName()); else throw new UnexceptedAssertionTermException(constant); }
private static Statement createStatement(ObjectPropertyAssertion assertion) { return fact.createStatement(getResource(assertion.getSubject()), createURI(assertion.getProperty().getIRI().getIRIString()), getResource(assertion.getObject())); }
private static Statement createStatement(DataPropertyAssertion assertion) { return fact.createStatement(getResource(assertion.getSubject()), createURI(assertion.getProperty().getIRI().getIRIString()), getLiteral(assertion.getValue()) ); }
@Test public void testCreateLiteral() throws Exception { final Literal example = factory.createLiteral("Example"); assertEquals("Example", example.getLexicalForm()); assertFalse(example.getLanguageTag().isPresent()); assertEquals("http://www.w3.org/2001/XMLSchema#string", example.getDatatype().getIRIString()); // http://lists.w3.org/Archives/Public/public-rdf-comments/2014Dec/0004.html assertEquals("\"Example\"", example.ntriplesString()); }