/** * 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); }
/** * Remove a property from the RepositoryConnection con, Resource. * * @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) throws RepositoryException { return removeProperty(con,r,propLabel,(Locale) null); }
/** * Remove a property from the RepositoryConnection con, Resource. for all spaces !!! * * @param propLabel the property label in SeRQL syntax to remove * @param loc the locale of the property to remove * @return true if the property existed and was removed */ public static boolean removeProperty(RepositoryConnection con, Resource r, String propLabel, Locale loc) throws RepositoryException { return removeProperty(con,r, propLabel, loc, 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); }
/** * Remove a property from the RepositoryConnection con, Resource. * * @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) throws RepositoryException { return removeProperty(con,r,propLabel,(Locale) null); }
/** * Remove a property from the RepositoryConnection con, Resource. for all spaces !!! * * @param propLabel the property label in SeRQL syntax to remove * @param loc the locale of the property to remove * @return true if the property existed and was removed */ public static boolean removeProperty(RepositoryConnection con, Resource r, String propLabel, Locale loc) throws RepositoryException { return removeProperty(con,r, propLabel, loc, null); }
/** * Generic method to query for literal values related to this resource with the property * identified by "propLabel" (SeRQL/SPARQL short or long notation) and the given locale. * context define the knowledgespace in which this operation is. For the given context. * * @param propLabel label of the property; either RDF short form (e.g. "foaf:mbox") or long * form (e.g. <http://xmlns.com/foaf/0.1/mbox>) * @param loc * @param context context in which this property will set * @return */ public static <T> void setProperty(RepositoryConnection con, Resource r, String propLabel, String propValue, Locale loc, URI context) throws RepositoryException { if(propValue != null) { Resource[] contexts; if(context != null) { contexts = new Resource[] { context }; } else { contexts = new Resource[0]; } // remove previous property setting removeProperty(con,r,propLabel,loc,context); String prop_uri = resolvePropLabel(con, propLabel); // then set the new property value Literal value = con.getValueFactory().createLiteral(propValue, loc != null ? loc.getLanguage().toLowerCase() : null); URI prop = con.getValueFactory().createURI(prop_uri); con.add(r, prop, value, contexts); } else { removeProperty(con,r, propLabel,loc,context); } }
/** * Generic method to query for literal values related to this resource with the property * identified by "propLabel" (SeRQL/SPARQL short or long notation) and the given locale. * context define the knowledgespace in which this operation is. For the given context. * * @param propLabel label of the property; either RDF short form (e.g. "foaf:mbox") or long * form (e.g. <http://xmlns.com/foaf/0.1/mbox>) * @param loc * @param context context in which this property will set * @return */ public static <T> void setProperty(RepositoryConnection con, Resource r, String propLabel, String propValue, Locale loc, URI context) throws RepositoryException { if(propValue != null) { Resource[] contexts; if(context != null) { contexts = new Resource[] { context }; } else { contexts = new Resource[0]; } // remove previous property setting removeProperty(con,r,propLabel,loc,context); String prop_uri = resolvePropLabel(con, propLabel); // then set the new property value Literal value = con.getValueFactory().createLiteral(propValue, loc != null ? loc.getLanguage().toLowerCase() : null); URI prop = con.getValueFactory().createURI(prop_uri); con.add(r, prop, value, contexts); } else { removeProperty(con,r, propLabel,loc,context); } }
URI p = conn.getValueFactory().createURI(property); URI u = conn.getValueFactory().createURI(currentUser); ResourceUtils.removeProperty(conn,u, property); String val = formParams.getFirst(prop); if (val != null && val.length() > 0) {
URI p = conn.getValueFactory().createURI(property); URI u = conn.getValueFactory().createURI(currentUser); ResourceUtils.removeProperty(conn,u, property); String val = formParams.getFirst(prop); if (val != null && val.length() > 0) {