Modified: websites/staging/marmotta/trunk/content/sesame.html ============================================================================== --- websites/staging/marmotta/trunk/content/sesame.html (original) +++ websites/staging/marmotta/trunk/content/sesame.html Thu Apr 25 13:05:59 2013 @@ -378,28 +378,37 @@ public interface ConceptFacade extends F <div class="source"> <pre>Resource concept = null; -RepositoryConnection conn = ... +URI context = null; +// a valid uri +String skosURI = "http://<host>/resource/concept1"; +String contextURI = "http://<host>/context/default"; +RepositoryConnection conn = ... // obtain a connection try { conn.begin(); + // obtain the Facading helper Facading facading = FacadingFactory.createFacading(conn); - Literal object = conn.getValueFactory().createLiteral(identifier); - URI prop = conn.getValueFactory().createURI(Namespace.DCTERMS.identifier); - if (object != null && prop != null) { - RepositoryResult<Statement> statements = conn.getStatements(null, prop, object, true, context); - while (statements.hasNext()) { - Statement stmt = statements.next(); - if ( stmt.getObject().equals(object)) { - concept = stmt.getSubject(); - break; - } - } - statements.close(); - } + // create or use an resource uri of a skos:Concept + concept = conn.getValueFactory().createURI(skosURI); + context = conn.getValueFactory().createURI(contextURI); + + // create a facade of the skos:Concept by providing the resource, the requested type and (optional) the context + ConceptFacade facade = facading.createFacade(concept, ConceptFacade.class, context); + // manage the resource via getter/setter methods + fadade.setPrefLabel("new label"); + facade.addAltLabel("new alternate label"); + // + // at this point, the resource "http://<host>/resource/concept1" + // - is created if not yet present + // - has a triple: rdf:Type <http://www.w3.org/2004/02/skos/core#Concept> + // - has a triple: skos:prefLabel "new label" + // - has a triple: skos:altLabel "new alternate label" + // + // return the resource uri of the facade, e.g. the concept resource's uri; + return resource.getDelegate(); } finally { conn.commit(); conn.close(); } -return concept; </pre></div></div> </div> </div>
