You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by it...@apache.org on 2010/01/13 01:10:24 UTC

svn commit: r898580 - in /incubator/clerezza/issues/CLEREZZA-58: ./ org.apache.clerezza.platform.concepts/ org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ org.ap...

Author: ito
Date: Wed Jan 13 00:10:23 2010
New Revision: 898580

URL: http://svn.apache.org/viewvc?rev=898580&view=rev
Log:
CMS-58: widget for rendering a resource and its associated concepts, widget for rendering selected concepts

Added:
    incubator/clerezza/issues/CLEREZZA-58/
    incubator/clerezza/issues/CLEREZZA-58/org.apache.clerezza.platform.concepts/
      - copied from r898370, incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.concepts/
    incubator/clerezza/issues/CLEREZZA-58/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/SelectedConcepts.java
    incubator/clerezza/issues/CLEREZZA-58/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/generic-resource-page.ssp
    incubator/clerezza/issues/CLEREZZA-58/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/selected-concepts-page.ssp
Modified:
    incubator/clerezza/issues/CLEREZZA-58/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.ontologies/src/main/resources/org/apache/clerezza/platform/concepts/ontologies/concepts.rdf

Added: incubator/clerezza/issues/CLEREZZA-58/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/SelectedConcepts.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-58/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/SelectedConcepts.java?rev=898580&view=auto
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-58/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/SelectedConcepts.java (added)
+++ incubator/clerezza/issues/CLEREZZA-58/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/SelectedConcepts.java Wed Jan 13 00:10:23 2010
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.clerezza.platform.concepts.core;
+
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriInfo;
+import org.apache.clerezza.platform.graphprovider.content.ContentGraphProvider;
+import org.apache.clerezza.platform.typerendering.scalaserverpages.ScalaServerPagesRenderlet;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.clerezza.platform.concepts.ontologies.CONCEPTS;
+import org.apache.clerezza.platform.typerendering.RenderletManager;
+import org.apache.clerezza.rdf.core.BNode;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
+import org.apache.clerezza.rdf.ontologies.DCTERMS;
+import org.apache.clerezza.rdf.ontologies.PLATFORM;
+import org.apache.clerezza.rdf.ontologies.RDF;
+import org.apache.clerezza.rdf.ontologies.RDFS;
+import org.apache.clerezza.rdf.ontologies.SKOS;
+import org.apache.clerezza.rdf.utils.GraphNode;
+import org.apache.clerezza.rdf.utils.UnionMGraph;
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * This JAX-RS resource can be used to retrieve a resource and its associated
+ * concepts. There is also a method for adding concepts to a resource.
+ *
+ * The URI path of this service is /concepts/find.
+ *
+ * @author hasan
+ */
+@Component
+@Service(Object.class)
+@Property(name = "javax.ws.rs", boolValue = true)
+@Path("/concepts/suggestions")
+public class SelectedConcepts {
+
+	@Reference
+	protected ContentGraphProvider cgProvider;
+	@Reference
+	private RenderletManager renderletManager;
+
+	/**
+	 * The activate method is called when SCR activates the component
+	 * configuration. This method registers template definitions to be used for
+	 * presenting the overview page and edit-concept page.
+	 *
+	 * @param context
+	 * @throws URISyntaxException
+	 */
+	protected void activate(ComponentContext context)
+			throws URISyntaxException {
+
+
+		URL template = getClass().getResource("selected-concepts-page.ssp");
+		renderletManager.registerRenderlet(ScalaServerPagesRenderlet.class.getName(),
+				new UriRef(template.toURI().toString()),
+				RDFS.Resource, "selectedconcepts",
+				MediaType.APPLICATION_XHTML_XML_TYPE, true);
+
+		template = getClass().getResource("generic-resource-page.ssp");
+		renderletManager.registerRenderlet(ScalaServerPagesRenderlet.class.getName(),
+				new UriRef(template.toURI().toString()),
+				CONCEPTS.GenericResourcePage, "naked",
+				MediaType.APPLICATION_XHTML_XML_TYPE, true);
+	}
+
+	/**
+	 * Retrieves a resource and its associated concepts.
+	 *
+	 * @param uri specifies the uri of a resource
+	 *
+	 * @return GraphNode
+	 */
+	@GET
+	public GraphNode GenericResourcePage(@QueryParam("uri") UriRef uri,
+			@Context UriInfo uriInfo) {
+
+		GraphNode node = new GraphNode(new BNode(), new UnionMGraph(new SimpleMGraph(),
+				cgProvider.getContentGraph()));
+		node.addProperty(RDF.type, PLATFORM.HeadedPage);
+		node.addProperty(RDF.type, CONCEPTS.GenericResourcePage);
+		if (uri != null) {
+			node.addProperty(CONCEPTS.resource, uri);
+		} else {
+			throw new WebApplicationException(Response.status(Status.BAD_REQUEST).build());
+		}
+		return node;
+	}
+
+	/**
+	 * Adds concepts to a resource via DC.subject. If parameters uri and
+	 * subjects are not defined a response with code BAD_REQUEST is returned. If
+	 * the relation is succefully added code CREATED is returned.
+	 * otherwise
+	 *
+	 * @param uri specifies the uri of a resource
+	 * @param subjects specifies a list of concept uris.
+	 *
+	 * @return
+	 *		A Response
+	 */
+	@POST
+	@Path("add")
+	public Response addConcepts(@FormParam("resource") UriRef resource,
+			@FormParam("subjects") List<String> subjects) {
+
+		if (resource != null && subjects != null) {
+			GraphNode node = new GraphNode(resource, cgProvider.getContentGraph());
+			node.deleteProperties(DCTERMS.subject);
+			for (String subject : subjects) {
+				node.addProperty(DCTERMS.subject, new UriRef(subject));
+			}
+		} else {
+			return Response.status(Status.BAD_REQUEST).entity("No resource uri defined.").build();
+		}
+		return Response.status(Status.CREATED).entity(resource.getUnicodeString()).build();
+	}
+}

Added: incubator/clerezza/issues/CLEREZZA-58/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/generic-resource-page.ssp
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-58/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/generic-resource-page.ssp?rev=898580&view=auto
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-58/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/generic-resource-page.ssp (added)
+++ incubator/clerezza/issues/CLEREZZA-58/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/generic-resource-page.ssp Wed Jan 13 00:10:23 2010
@@ -0,0 +1,25 @@
+def skos(s: Any) = new UriRef("http://www.w3.org/2008/05/skos#"+s)
+def dct(s: Any) = new UriRef("http://purl.org/dc/terms/"+s)
+def cpt(s: Any) = new UriRef("http://clerezza.org/2010/01/concepts#"+s);
+
+resultDocModifier.setTitle("Generic Resource Page");
+resultDocModifier.addNodes2Elem("tx-module", <h1>Generic Resource Page</h1>);
+resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li class="tx-active"><a href="#">Resource</a></li>);
+resultDocModifier.addNodes2Elem("tx-contextual-buttons-ol", <li><a id="addButton" class="tx-button tx-button-create" href="#">Save</a></li>);
+
+<div id="tx-content">
+	<script type="text/javascript">
+		$(document).ready(function() {{
+			$("#addButton").click(function() {{
+				$("form").submit();
+			}});
+		}});
+	</script>
+	<h4>About: {res/cpt("resource")*}</h4>
+	<div><object width="200" data={res/cpt("resource")*}></object></div>
+	<br/>
+	<form action="/concepts/suggestions/add">
+		<input type="hidden" name="resource" value={res/cpt("resource")*}></input>
+		{render(res/cpt("resource"), "selectedconcepts")}
+	</form>
+</div>

Added: incubator/clerezza/issues/CLEREZZA-58/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/selected-concepts-page.ssp
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-58/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/selected-concepts-page.ssp?rev=898580&view=auto
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-58/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/selected-concepts-page.ssp (added)
+++ incubator/clerezza/issues/CLEREZZA-58/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/selected-concepts-page.ssp Wed Jan 13 00:10:23 2010
@@ -0,0 +1,23 @@
+def skos(s: Any) = new UriRef("http://www.w3.org/2008/05/skos#"+s)
+def dct(s: Any) = new UriRef("http://purl.org/dc/terms/"+s)
+
+<div>
+	<script type="text/javascript">
+		$(document).ready(function() {{
+			$(".tx-icon-delete").click(function() {{
+				$(this).parent().remove();
+			}});
+		}});
+	</script>
+	{for (concept <- (res/dct("subject"))) yield {
+	<div>
+		<div>{concept/skos("prefLabel")*}</div>
+		<div>{concept*}</div>
+		<input type="hidden" name="subjects" value={concept*}></input>
+		<a href="#" class="tx-icon tx-icon-delete" >Add</a>
+		<br />
+		<br />
+	</div>
+	}
+	}
+</div>

Modified: incubator/clerezza/issues/CLEREZZA-58/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.ontologies/src/main/resources/org/apache/clerezza/platform/concepts/ontologies/concepts.rdf
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-58/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.ontologies/src/main/resources/org/apache/clerezza/platform/concepts/ontologies/concepts.rdf?rev=898580&r1=898370&r2=898580&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-58/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.ontologies/src/main/resources/org/apache/clerezza/platform/concepts/ontologies/concepts.rdf (original)
+++ incubator/clerezza/issues/CLEREZZA-58/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.ontologies/src/main/resources/org/apache/clerezza/platform/concepts/ontologies/concepts.rdf Wed Jan 13 00:10:23 2010
@@ -85,6 +85,22 @@
 	</skos:definition>
 </rdfs:Class>
 
+<rdfs:Class rdf:about="#SelectedConceptsPage">
+	<rdf:type rdf:resource="owl:Class"/>
+	<rdfs:label xml:lang="en">Selected Concepts Page</rdfs:label>
+	<skos:definition xml:lang="en">
+		A web page containing concepts associated to a resource.
+	</skos:definition>
+</rdfs:Class>
+
+<rdfs:Class rdf:about="#GenericResourcePage">
+	<rdf:type rdf:resource="owl:Class"/>
+	<rdfs:label xml:lang="en">Generic Resource Page</rdfs:label>
+	<skos:definition xml:lang="en">
+		A web page containing a resource and selected concepts.
+	</skos:definition>
+</rdfs:Class>
+
 <!-- Properties -->
 
 <rdf:Property rdf:about="#selectedScheme">
@@ -152,4 +168,11 @@
 	<rdfs:domain rdf:resource="#ConceptCache"/>
 </rdf:Property>
 
+<rdf:Property rdf:about="#resource">
+	<rdf:type rdf:resource="owl:ObjectProperty"/>
+	<rdfs:label xml:lang="en">Resource</rdfs:label>
+	<skos:definition xml:lang="en">Points to a resource.</skos:definition>
+	<rdfs:domain rdf:resource="#GenericConceptScheme"/>
+</rdf:Property>
+
 </rdf:RDF>