/** * List resources with the given prefix * * @param prefix the prefix */ public static Iterable<URI> listResourcesByPrefix(final RepositoryConnection con, String prefix) { return listResourcesByPrefix(con,prefix,0,0); }
/** * Return the label of this resource in the language provided as parameter * <p/> * If no label is available for the given language, returns the identifier. * * @param context the space of the label * @return */ public static String getLabel(RepositoryConnection con, Resource r, URI context) throws RepositoryException { return getLabel(con, r, null,context); }
/** * Generic method to set the literal value of a property of this resource to the provided * value in the provided language. For all spaces. * * @param propLabel the SeRQL or SPARQL short or long notation for the property * @param propValue the String value of this property * @param loc the Locale representing the language of this property */ public static <T> void setProperty(RepositoryConnection con, Resource r, String propLabel, String propValue, Locale loc) throws RepositoryException { setProperty(con, r,propLabel,propValue,null, null); }
@Override public Iterator<Resource> iterator() { try { return ResultUtils.unwrap(rcon.getResources()); } catch (RepositoryException e) { ExceptionUtils.handleRepositoryException(e,ResourceUtils.class); return Iterators.emptyIterator(); } } };
/** * List all outgoing edges from this resource to other resources. Shortcut for listOutgoing(null). * For all spaces!!! * * @return all outgoing edges from this resource */ public static Iterable<? extends Statement> listOutgoing(RepositoryConnection con, Resource r) throws RepositoryException { return listOutgoing(con, r, (URI) null); }
/** * Remove a property from the RepositoryConnection con, Resource. Just for the given space!!! * * @param propLabel the property label in SeRQL syntax to remove * @return true if the property existed and was removed */ public static boolean removeProperty(RepositoryConnection con, Resource r, String propLabel, URI context) throws RepositoryException { return removeProperty(con,r,propLabel, null, context); }
/** * Check whether the {@link Resource} is ever used as context. * @param conn connection with the repository * @param rsc the {@link Resource} to check * @return true if the {@link Resource} is ever used as context. */ public static boolean isContext(RepositoryConnection conn, Resource rsc) { return existsStatement(conn, null, null, null, rsc); }
/** * Set the rdfs:label of this Resource in the configured getTripleStore().TripleStore * for the given Locale. Looking in all spaces!!! * * @param loc * @param label */ public static void setLabel(RepositoryConnection con, Resource r, Locale loc, String label) throws RepositoryException { setLabel(con, r,loc,label,null); }
/** * Check whether this Resource has a certain RDF type * * @param type the resource representing the type to check for * @return true if the type is in the list of RDF types of this resource, false otherwise */ public static boolean hasType(RepositoryConnection con, Resource r, URI type) throws RepositoryException { return hasType(con,r,type,null); }
/** * List all incoming edges from other resources to this resource * * @return */ public static Iterable<? extends Statement> listIncoming(RepositoryConnection con, Resource r) throws RepositoryException { return listIncoming(con, r, (URI) null); }
/** * Return a list of nodes that are the sources for edges with propLabel that have this resource * as endpoint. This is mostly a convenience method that wraps listIncoming(propLabel). * * @param propLabel the label that all edges listed must have, or null for wildcard * @return a list of resources that are sources of edges that have this resource as endpoint */ public static Iterable<? extends Resource> listIncomingNodes(RepositoryConnection con, Resource r, String propLabel) throws RepositoryException { return listIncomingNodes(con, r, propLabel, null); }
/** * List all resources contained in the KiWi System, regardless of knowledge space or type. Since this * operation works directly on the triple store, there is no guarantee the result is free of duplicates. * In case the underlying connection does not directly support listing resources (i.e. is not an instance of * ResourceConnection), the method will iterate over all triples and return their subjects * * @return */ public static Iterable<Resource> listSubjects(RepositoryConnection con) { return listSubjectsInternal(con, null, null, null); }
@Override public Iterator<Resource> iterator() { try { return ResultUtils.unwrap(rcon.getResources()); } catch (RepositoryException e) { ExceptionUtils.handleRepositoryException(e,ResourceUtils.class); return Iterators.emptyIterator(); } } };
/** * Set the rdfs:label of this Resource in the configured getTripleStore().TripleStore * for the given Locale. Just for the given space !!! * * @param loc * @param label * @param context */ public static void setLabel(RepositoryConnection con, Resource r, Locale loc, String label, URI context) throws RepositoryException { setProperty(con, r,"<"+ Namespaces.NS_RDFS+"label>", label, loc,context); }
/** * Check whether the {@link Resource} is ever used as subject. * @param conn connection with the repository * @param rsc the {@link Resource} to check * @return true if the {@link Resource} is ever used as subject. */ public static boolean isSubject(RepositoryConnection conn, final Resource rsc) { return existsStatement(conn, rsc, null, null); }
/** * Set the rdfs:label of this Resource in the configured getTripleStore().TripleStore * for the given Locale. Looking in all spaces!!! * * @param loc * @param label */ public static void setLabel(RepositoryConnection con, Resource r, Locale loc, String label) throws RepositoryException { setLabel(con, r,loc,label,null); }
/** * Check whether this Resource has a certain RDF type * * @param type the resource representing the type to check for * @return true if the type is in the list of RDF types of this resource, false otherwise */ public static boolean hasType(RepositoryConnection con, Resource r, URI type) throws RepositoryException { return hasType(con,r,type,null); }
/** * Generic method to set the literal value of a property of this resource to the provided * value in the provided language. For all spaces. * * @param propLabel the SeRQL or SPARQL short or long notation for the property * @param propValue the String value of this property * @param loc the Locale representing the language of this property */ public static <T> void setProperty(RepositoryConnection con, Resource r, String propLabel, String propValue, Locale loc) throws RepositoryException { setProperty(con, r,propLabel,propValue,null, null); }
/** * Check whether the {@link Value} is ever used as object. * @param conn connection with the repository * @param val {@link Value} to check * @return true if the {@link Value} is ever used as predicate. */ public static boolean isObject(RepositoryConnection conn, final Value val) { return existsStatement(conn, null, null, val); }
/** * Set the rdfs:label of this Resource in the configured getTripleStore().TripleStore * for the given Locale. Just for the given space !!! * * @param loc * @param label * @param context */ public static void setLabel(RepositoryConnection con, Resource r, Locale loc, String label, URI context) throws RepositoryException { setProperty(con, r,"<"+ Namespaces.NS_RDFS+"label>", label, loc,context); }