Author: reto
Date: Wed May  5 12:40:28 2010
New Revision: 941267

URL: http://svn.apache.org/viewvc?rev=941267&view=rev
Log:
CLEREZZA-180: applied pach André, do not suggest creation of existing concepts

Added:
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/scripts/
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/scripts/concept-find-create.js
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/scripts/concept-provider-manipulation.js
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/scripts/jquery.rdfquery.core-1.0.js
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/scripts/selected-concepts.js
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/style/
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/style/form.css
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.ontologies/src/main/resources/org/apache/clerezza/platform/concepts/ontologies/queryresult.rdf
Modified:
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/pom.xml
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptManipulator.java
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptsFinder.java
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/GenericResourcePage.java
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/META-INF/static-web/concepts/scripts/concept-find-create.js
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/META-INF/static-web/concepts/scripts/concept-provider-manipulation.js
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/META-INF/static-web/concepts/scripts/selected-concepts.js
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/META-INF/static-web/concepts/style/form.css
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/concept-find-create.ssp
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/manage-concept-providers-page.ssp
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/selected-concepts.ssp
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/test/java/org/apache/clerezza/platform/concepts/core/ConceptsFinderTest.java

Modified: 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/pom.xml?rev=941267&r1=941266&r2=941267&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/pom.xml
 (original)
+++ 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/pom.xml
 Wed May  5 12:40:28 2010
@@ -67,5 +67,12 @@
                        <artifactId>org.apache.clerezza.triaxrs</artifactId>
                        <scope>test</scope>
                </dependency>
+               <dependency>
+                       <groupId>org.apache.clerezza</groupId>
+                       
<artifactId>org.apache.clerezza.web.fileserver</artifactId>
+                       <version>0.9-incubating-SNAPSHOT</version>
+                       <type>bundle</type>
+                       <scope>compile</scope>
+               </dependency>
        </dependencies>
 </project>

Modified: 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptManipulator.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptManipulator.java?rev=941267&r1=941266&r2=941267&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptManipulator.java
 (original)
+++ 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptManipulator.java
 Wed May  5 12:40:28 2010
@@ -96,11 +96,11 @@ public class ConceptManipulator {
                                        .entity("A concept with the same label 
and language already exists!")
                                        .build();
                }
-               String baseUri = 
platformConfig.getDefaultBaseUri().getUnicodeString();
-               UriRef concept = new UriRef(baseUri + "concept/" +
-                               UriRefUtil.stripNonUriRefChars(prefLabel));
+               
+               UriRef concept = getConceptUriRef(platformConfig, prefLabel);
                contentGraph.add(new TripleImpl(concept, RDF.type,
                                SKOS.Concept));
+               String baseUri = 
platformConfig.getDefaultBaseUri().getUnicodeString();
                contentGraph.add(new TripleImpl(concept, SKOS.inScheme,
                                new UriRef(baseUri + FREE_CONCEPT_SCHEME)));
                contentGraph.add(new TripleImpl(concept, SKOS.prefLabel, 
preferredLabel));
@@ -111,6 +111,12 @@ public class ConceptManipulator {
                return 
Response.status(Status.CREATED).entity(concept.getUnicodeString())
                                .build();
        }
+
+       static UriRef getConceptUriRef(PlatformConfig platformConfig, String 
prefLabel) {
+               String baseUri = 
platformConfig.getDefaultBaseUri().getUnicodeString();
+               return new UriRef(baseUri + "concept/" +
+                               UriRefUtil.stripNonUriRefChars(prefLabel));
+       }
 }
 
 

Modified: 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptsFinder.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptsFinder.java?rev=941267&r1=941266&r2=941267&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptsFinder.java
 (original)
+++ 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptsFinder.java
 Wed May  5 12:40:28 2010
@@ -22,21 +22,21 @@ import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.Iterator;
 import java.util.List;
+
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.MediaType;
+
+import org.apache.clerezza.platform.concepts.ontologies.QUERYRESULT;
 import org.apache.clerezza.platform.config.PlatformConfig;
 import org.apache.clerezza.platform.graphprovider.content.ContentGraphProvider;
 import org.apache.clerezza.platform.typerendering.RenderletManager;
 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.rdf.core.BNode;
 import org.apache.clerezza.rdf.core.Graph;
 import org.apache.clerezza.rdf.core.Literal;
+import org.apache.clerezza.rdf.core.LiteralFactory;
 import org.apache.clerezza.rdf.core.MGraph;
 import org.apache.clerezza.rdf.core.NonLiteral;
 import org.apache.clerezza.rdf.core.Resource;
@@ -50,6 +50,10 @@ import org.apache.clerezza.rdf.ontologie
 import org.apache.clerezza.rdf.ontologies.RDFS;
 import org.apache.clerezza.rdf.ontologies.SKOS;
 import org.apache.clerezza.rdf.utils.GraphNode;
+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.osgi.service.component.ComponentContext;
 
 /**
@@ -63,9 +67,9 @@ import org.osgi.service.component.Compon
  * relation with this concept, but from a provider of lower priority.
  * Implicitly created {...@link LocalConceptProvider} for free concepts has the
  * lowest priority.
- *
+ * 
  * The URI path of this service is /concepts/find.
- *
+ * 
  * @author hasan
  */
 @Component
@@ -84,7 +88,7 @@ public class ConceptsFinder {
        private TcManager tcManager;
 
        @Reference
-       protected ContentGraphProvider cgProvider;
+       private ContentGraphProvider cgProvider;
 
        @Reference
        private PlatformConfig platformConfig;
@@ -114,9 +118,9 @@ public class ConceptsFinder {
         * However, concepts from providers of lower priority are only 
considered if
         * they are not staying in an OWL:sameAs relation with concepts from
         * providers of higher priority.
-        *
+        * 
         * @param searchTerm
-        *              The search term in form of a String.
+        *            The search term in form of a String.
         * @return
         *              A GraphNode containing the search results.
         */
@@ -149,28 +153,65 @@ public class ConceptsFinder {
                if (!freeConceptProviderFound && freeConceptProvider != null) {
                        retrieveConcepts(freeConceptProvider, first, 
resultNode, searchTerm);
                }
-               resultNode.addProperty(RDF.type, SKOS.Collection);
+               addCreationOfNewFreeConceptSuggested(resultNode, searchTerm);
+               resultNode.addProperty(RDF.type, QUERYRESULT.QueryResult);
                return resultNode;
        }
 
-       private void retrieveConcepts(ConceptProvider conceptProvider, boolean 
first,
-                       GraphNode resultNode, String searchTerm) {
+       /**
+        * Adds a boolean value that answers whether the UI shall suggest to 
create
+        * a new free concept. A new free concept may not be added if the has 
the
+        * same base uri and search term. Therefore the consumer shall be 
suggested
+        * not to propose creation.
+        * 
+        * @param resultNode
+        *            the result node to add the property to
+        * @param searchTerm
+        *            the search term the data was searched for
+        */
+       private void addCreationOfNewFreeConceptSuggested(GraphNode resultNode,
+                       String searchTerm) {
+               UriRef conceptUriRef = ConceptManipulator.getConceptUriRef(
+                               platformConfig, searchTerm);
+               
resultNode.addProperty(QUERYRESULT.creationOfNewFreeConceptSuggested,
+                               LiteralFactory.getInstance().createTypedLiteral(
+                                               
!cgProvider.getContentGraph().contains(
+                                                               new 
TripleImpl(conceptUriRef, RDF.type,
+                                                                               
SKOS.Concept))));
+       }
+
+       /**
+        * Retrieve concepts for the given search term.
+        * 
+        * @param conceptProvider
+        *            the provider delivers concepts
+        * @param first
+        *            is this the first execution
+        * @param resultNode
+        *            the node to attach the concepts to
+        * @param searchTerm
+        *            the search term that the concepts have to match against
+        */
+       private void retrieveConcepts(ConceptProvider conceptProvider,
+                       boolean first, GraphNode resultNode, String searchTerm) 
{
                MGraph resultMGraph = (MGraph) resultNode.getGraph();
                Graph graph = conceptProvider.retrieveConcepts(searchTerm);
                Iterator<Triple> concepts = graph.filter(null, RDF.type, 
SKOS.Concept);
                if (first) {
                        while (concepts.hasNext()) {
-                               resultNode.addProperty(SKOS.member, 
concepts.next().getSubject());
+                               resultNode.addProperty(QUERYRESULT.concept, 
concepts.next()
+                                               .getSubject());
                        }
                        resultMGraph.addAll(graph);
                } else {
                        while (concepts.hasNext()) {
                                NonLiteral concept = 
concepts.next().getSubject();
                                GraphNode conceptGraphNode = new 
GraphNode(concept, graph);
-                               Iterator<Resource> sameAsConcepts =
-                                               
conceptGraphNode.getObjects(OWL.sameAs);
-                               if (!(hasSameAs(resultMGraph, concept) || 
hasAnyConcept(resultMGraph, sameAsConcepts))) {
-                                       resultNode.addProperty(SKOS.member, 
concept);
+                               Iterator<Resource> sameAsConcepts = 
conceptGraphNode
+                                               .getObjects(OWL.sameAs);
+                               if (!(hasSameAs(resultMGraph, concept) || 
hasAnyConcept(
+                                               resultMGraph, sameAsConcepts))) 
{
+                                       
resultNode.addProperty(QUERYRESULT.concept, concept);
                                        addConceptToResultMGraph(resultMGraph, 
conceptGraphNode);
                                }
 

Modified: 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/GenericResourcePage.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/GenericResourcePage.java?rev=941267&r1=941266&r2=941267&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/GenericResourcePage.java
 (original)
+++ 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/GenericResourcePage.java
 Wed May  5 12:40:28 2010
@@ -20,6 +20,7 @@ package org.apache.clerezza.platform.con
 
 import java.net.URISyntaxException;
 import java.net.URL;
+
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.QueryParam;
@@ -27,16 +28,13 @@ import javax.ws.rs.WebApplicationExcepti
 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 javax.ws.rs.core.Response.Status;
+
 import org.apache.clerezza.platform.concepts.ontologies.CONCEPTS;
+import org.apache.clerezza.platform.graphprovider.content.ContentGraphProvider;
 import org.apache.clerezza.platform.typerendering.RenderletManager;
+import 
org.apache.clerezza.platform.typerendering.scalaserverpages.ScalaServerPagesRenderlet;
 import org.apache.clerezza.rdf.core.BNode;
 import org.apache.clerezza.rdf.core.UriRef;
 import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
@@ -44,19 +42,25 @@ import org.apache.clerezza.rdf.ontologie
 import org.apache.clerezza.rdf.ontologies.RDF;
 import org.apache.clerezza.rdf.utils.GraphNode;
 import org.apache.clerezza.rdf.utils.UnionMGraph;
+import org.apache.clerezza.utils.UriException;
+import org.apache.clerezza.web.fileserver.FileServer;
+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.osgi.service.component.ComponentContext;
 
 /**
  * This JAX-RS resource can be used to show selected concepts of a resource.
  * The URI path of this service is /concepts/generic-resource.
- *
+ * 
  * @author tio
  */
 @Component
 @Service(Object.class)
 @Property(name = "javax.ws.rs", boolValue = true)
 @Path("/concepts/generic-resource")
-public class GenericResourcePage {
+public class GenericResourcePage extends FileServer {
 
        @Reference
        protected ContentGraphProvider cgProvider;
@@ -67,7 +71,9 @@ public class GenericResourcePage {
 
        protected void activate(ComponentContext context)
                        throws URISyntaxException {
-
+               
+               configure(context.getBundleContext());
+               
                URL template = 
getClass().getResource("generic-resource-page.ssp");
                
renderletManager.registerRenderlet(ScalaServerPagesRenderlet.class.getName(),
                                new UriRef(template.toURI().toString()),
@@ -80,9 +86,9 @@ public class GenericResourcePage {
        /**
         * Retrieves a resource and its associated concepts to be rendered with 
a template
         * registered for CONCEPTS.GenericResourcePage.
-        *
+        * 
         * @param uri specifies the uri of a resource
-        *
+        * 
         * @return GraphNode
         */
        @GET

Modified: 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/META-INF/static-web/concepts/scripts/concept-find-create.js
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/META-INF/static-web/concepts/scripts/concept-find-create.js?rev=941267&r1=941266&r2=941267&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/META-INF/static-web/concepts/scripts/concept-find-create.js
 (original)
+++ 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/META-INF/static-web/concepts/scripts/concept-find-create.js
 Wed May  5 12:40:28 2010
@@ -1,130 +0,0 @@
-/*
- * 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.
- */
-function ConceptFinder(){};
-
-ConceptFinder.callback;
-
-ConceptFinder.setAddConceptCallback = function (callback) {
-       this.callback = callback;
-}
-
-ConceptFinder.search = function () {
-       $("#system-found-concepts").empty();
-       var searchTerm = $(":text[name=\"search-term\"]").val();
-       if (searchTerm.length > 0) {
-               var options = new AjaxOptions("find-concepts", "finding 
concepts", function(data) {
-                       var concepts = data.concepts;
-                       ConceptFinder.addFoundConcepts(concepts);
-                       $("#add-button-label")
-                               .html("<div>Add '"+searchTerm
-                                       +"' as new Free Concept</div>");
-                       $("#system-found-concepts-area").show();
-                       $("#user-defined-concept-area").show();
-               });
-               options.url = "/concepts/find";
-               options.data = "searchTerm=" + encodeURIComponent(searchTerm);
-               options.dataType = "json";
-               $.ajax(options);
-       }
-       return false;
-}
-
-ConceptFinder.addFoundConcepts = function (concepts) {
-       var selectedConceptsExists = false;
-       if (typeof(SelectedConcepts) != "undefined") {
-               selectedConceptsExists = true;
-       }
-       var added = false;
-       for (var i = 0; i < concepts.length; i++) {
-               if (!selectedConceptsExists || 
!SelectedConcepts.exists(concepts[i].uri)) {
-                       added = true;
-                       var div = 
$("<div/>").appendTo("#system-found-concepts");
-                       $("<div/>").text(concepts[i].prefLabel)
-                       .appendTo(div);
-                       $("<div/>").text(concepts[i].uri)
-                       .appendTo(div);
-                       $("<a/>").addClass("tx-icon tx-icon-plus")
-                       .attr({
-                               href: "#"
-                       })
-                       .text("Add")
-                       .click(function () {
-                               var searchTerm = $(this).prev().prev().text();
-                               var uri = $(this).prev().text();
-                               if (typeof(SelectedConcepts) != "undefined") {
-                                       SelectedConcepts.addConcept(searchTerm, 
uri);
-                               }
-                               if (typeof(ConceptFinder.callback) == 
"function") {
-                                       ConceptFinder.callback(searchTerm, uri);
-                               }
-                               $(this).parent().remove();
-                       })
-                       .appendTo(div);
-                       $("<br/>").appendTo(div);
-                       $("<br/>").appendTo(div);
-               }
-       }
-       if (added) {
-               $("#label-for-search-results").text("Concepts found:");
-       } else {
-               $("#label-for-search-results").text("No additional concepts 
found.");
-       }
-}
-
-function ConceptManipulator(){};
-
-ConceptManipulator.callback;
-
-ConceptManipulator.setAddConceptCallback = function (callback) {
-       this.callback = callback;
-}
-
-ConceptManipulator.addConcept = function () {
-       var searchTerm = $(":text[name='search-term']").val();
-       if (searchTerm.length > 0) {
-               var options = new AjaxOptions("add-concepts", "adding 
concepts", function(uri) {
-                       $("#concept-description").val("");
-                       if (typeof(SelectedConcepts) != "undefined") {
-                               SelectedConcepts.addConcept(searchTerm, uri);
-                       }
-                       if (typeof(this.callback) == "function") {
-                               this.callback(searchTerm, uri);
-                       }
-               });
-               options.type = "POST";
-               options.url = "/concepts/manipulator/add-concept";
-               options.data = {"pref-label":searchTerm,
-                       lang:$(":input[name='lang']").val(),
-                       comment:$(":textarea[name='comment']").val()}
-
-               $.ajax(options);
-       }
-       return false;
-}
-
-$(document).ready(function () {
-       $("#go-button").click(function() {
-               ConceptFinder.search();
-       });
-       $("#add-user-defined-concept").click(function() {
-               ConceptManipulator.addConcept();
-       });
-       $("#system-found-concepts-area").hide();
-       $("#user-defined-concept-area").hide();
-});

Modified: 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/META-INF/static-web/concepts/scripts/concept-provider-manipulation.js
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/META-INF/static-web/concepts/scripts/concept-provider-manipulation.js?rev=941267&r1=941266&r2=941267&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/META-INF/static-web/concepts/scripts/concept-provider-manipulation.js
 (original)
+++ 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/META-INF/static-web/concepts/scripts/concept-provider-manipulation.js
 Wed May  5 12:40:28 2010
@@ -1,213 +0,0 @@
-/*
- * 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.
- */
-function ConceptProviderGui(){};
-
-ConceptProviderGui.isModified = false;
-
-ConceptProviderGui.query = "PREFIX owl: <http://www.w3.org/2002/07/owl#> \n" +
-       "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
-       "PREFIX skos08: <http://www.w3.org/2008/05/skos#> \n" +
-       "PREFIX skos04: <http://www.w3.org/2004/02/skos/core#> \n" +
-       "CONSTRUCT { ?concept a skos08:Concept; skos08:prefLabel ?prefLabel; " +
-               "rdfs:comment ?comment; owl:sameAs ?sameConcept . } \n" +
-       "WHERE { ?concept a skos04:Concept; skos04:prefLabel ?prefLabel . \n" +
-       "OPTIONAL { ?concept rdfs:comment ?comment . } \n" +
-       "OPTIONAL { ?concept owl:sameAs ?sameConcept . } \n" +
-       "FILTER (REGEX(STR(?prefLabel), '${searchTerm}', 'i'))}";
-
-ConceptProviderGui.initButtons = function() {
-
-       ConceptProviderGui.updateButtonState();
-
-       $("#deleteButton").click(function(event) {
-               $("input:checked").each(function() {
-                       $(this).parent().parent().remove();
-               });
-               $(this).addClass("tx-inactive");
-               ConceptProviderGui.isModified = true;
-       });
-
-       $("#addProvider").click(function(event) {
-               ConceptProviderGui.addProvider($("#type").val(),
-                                       $("#conceptScheme").val(),
-                                       $("#sparqlEndPoint").val(),
-                                       $("#defaultGraph").val(),
-                                       $("#query").val());
-               $("#conceptScheme").val("");
-               $("#sparqlEndPoint").val("");
-               $("#defaultGraph").val("");
-               $("#query").val("");
-       });
-
-       $("#addButton").click(function(event) {
-               if($(this).text() == "Save") {
-                       var options = new AjaxOptions("update-providers", 
"updating providers", function(obj) {
-                       });
-                       $("textarea[id!=query]").each(function() {
-                               $(this).removeAttr("disabled");
-                       });
-                       options.type = "POST";
-                       options.url = "update-concept-provider-list";
-                       options.data = $("#providers").serialize();
-                       $.ajax(options);
-               }
-       });
-}
-
-ConceptProviderGui.addProvider = function(rdfType, conceptScheme, 
sparqlEndPoint, defaultGraph, query) {
-       var tr = $("<tr/>").attr("id", "");
-       var td1 = $("<td/>");
-       var div = $("<div/>").text("Provider:");
-       var td2 = $("<td/>");
-
-       var selection = $("<select/>").attr("name","types");
-
-       $("#type > option:not(:selected)").each(function() {
-               selection.append($(this).clone());
-       });
-       $("#type > option:selected").each(function() {
-               var option = $(this).clone();
-               option.attr("selected", "selected");
-               selection.append(option);
-       });
-
-       td2.append(div);
-       td2.append(selection);
-       
-       var inputText = $("<input/>").attr({
-                               "type":"text",
-                               "name":"conceptSchemes",
-                               "value": conceptScheme
-                               });
-       
-       div = $("<div/>").text("Concept Scheme:");
-       td2.append(div);
-       td2.append(inputText);
-
-       inputText = $("<input/>").attr({
-                               "type":"text",
-                               "name":"sparqlEndPoints",
-                               "value": sparqlEndPoint
-                               });
-
-       div = $("<div/>").text("SPARQL End Point");
-       td2.append(div);
-       td2.append(inputText);
-
-       inputText = $("<input/>").attr({
-                               "type":"text",
-                               "name":"defaultGraphs",
-                               "value": defaultGraph
-                               });
-
-       div = $("<div/>").text("Default Graph:");
-       td2.append(div);
-       td2.append(inputText)
-       var inputCheckbox = $("<input/>").attr({
-                               "type":"checkbox",
-                               "value": rdfType
-                               });
-
-       inputCheckbox.appendTo(td1);
-
-       td1.appendTo(tr);
-       
-       var textArea = $("<textarea/>").attr({
-                               "rows":"8",
-                               "name":"queryTemplates"
-                               }).val(query);
-       div = $("<div/>").text("Query Template:");
-       td2.append(div);
-       td2.append(textArea);
-       td2.append($("<br/>"));
-       td2.append($("<br/>"));
-       td2.appendTo(tr);
-       tr.insertBefore("#last");
-       ConceptProviderGui.isModified = true;
-
-       $("select[name=types] > option:selected").each(function() {
-               ConceptProviderGui.updateDropDown($(this), "conceptSchemes");
-       });
-}
-
-ConceptProviderGui.updateDropDown = function (obj, name) {
-       if(obj.val().indexOf("Local") != -1) {
-               obj.parent().parent().find("input[name!=" + name + 
"]").each(function() {
-                       $(this).prev().hide();
-                       $(this).hide();
-               });
-               obj.parent().parent().find("input[name=" + name + 
"]").each(function() {
-                       $(this).prev().show();
-                       $(this).show();
-               });
-               obj.parent().parent().find("textarea").each(function() {
-                       $(this).prev().hide();
-                       $(this).hide();
-               });
-       } else {
-               obj.parent().parent().find("input[name!=" + name + 
"]").each(function() {
-                       $(this).prev().show();
-                       $(this).show();
-               });
-               obj.parent().parent().find("input[name=" + name + 
"]").each(function() {
-                       $(this).prev().hide();
-                       $(this).hide();
-               });
-               obj.parent().parent().find("textarea").each(function() {
-                       $(this).prev().show();
-                       $(this).show();
-               });
-       }
-}
-
-ConceptProviderGui.updateButtonState = function() {
-       var counter = $("input:checked").length;
-       if(counter == 0) {
-               $("#deleteButton").addClass("tx-inactive");
-       } else {
-               $("#deleteButton").removeClass("tx-inactive");
-       }
-}
-
-$(document).ready(function () {
-
-       $("select[name=types]").live("change", function() {
-               $("select[name=types] > option:selected").each(function(){
-                       ConceptProviderGui.updateDropDown($(this), 
"conceptSchemes");
-               });
-       });
-       $("select[name=types] > option:selected").each(function() {
-               ConceptProviderGui.updateDropDown($(this), "conceptSchemes");
-       });
-       $("#type").live("change", function() {
-               $("#type > option:selected").each(function(){
-                       ConceptProviderGui.updateDropDown($(this), 
"conceptScheme");
-                       $("#query").val(ConceptProviderGui.query);
-               });
-       });
-       $("#type > option:selected").each(function() {
-               ConceptProviderGui.updateDropDown($(this), "conceptScheme");
-               $("#query").val(ConceptProviderGui.query);
-       });
-       $("input:checkbox").live("change",function() {
-               ConceptProviderGui.updateButtonState();
-       });
-
-       ConceptProviderGui.initButtons();
-});

Modified: 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/META-INF/static-web/concepts/scripts/selected-concepts.js
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/META-INF/static-web/concepts/scripts/selected-concepts.js?rev=941267&r1=941266&r2=941267&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/META-INF/static-web/concepts/scripts/selected-concepts.js
 (original)
+++ 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/META-INF/static-web/concepts/scripts/selected-concepts.js
 Wed May  5 12:40:28 2010
@@ -1,50 +0,0 @@
-/*
- * 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.
- */
-function SelectedConcepts(){};
-
-SelectedConcepts.exists = function (concept) {
-       var exists = false;
-       $("input[name='concepts']").each( function () {
-               if ($(this).val() == concept) {
-                       exists = true;
-               }
-       });
-       return exists;
-}
-
-SelectedConcepts.addConcept = function (prefLabel, uri) {
-       var div = $("<div/>");
-       $("<div/>").text("PrefLabel: " + prefLabel).appendTo(div);
-       $("<div/>").text("Uri: " + uri).appendTo(div);
-       $("<input/>").attr({
-               "type": "hidden",
-               "name": "concepts"
-       }).val(uri).appendTo(div);
-       $("<a/>").attr("href", "#").addClass("tx-icon 
tx-icon-delete").text("Add")
-               .appendTo(div);
-       $("<br />").appendTo(div);
-       $("<br />").appendTo(div);
-       $("#selected-concepts").append(div);
-}
-
-$(document).ready(function () {
-       $(".tx-icon-delete").click(function() {
-               $(this).parent().remove();
-       });
-});

Modified: 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/META-INF/static-web/concepts/style/form.css
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/META-INF/static-web/concepts/style/form.css?rev=941267&r1=941266&r2=941267&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/META-INF/static-web/concepts/style/form.css
 (original)
+++ 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/META-INF/static-web/concepts/style/form.css
 Wed May  5 12:40:28 2010
@@ -1,3 +0,0 @@
-input, select, textarea {
-       width: 32em;
-}

Modified: 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/concept-find-create.ssp
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/concept-find-create.ssp?rev=941267&r1=941266&r2=941267&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/concept-find-create.ssp
 (original)
+++ 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/concept-find-create.ssp
 Wed May  5 12:40:28 2010
@@ -1,5 +1,14 @@
 resultDocModifier.addScriptReference("/scripts/ajax-options.js");
-resultDocModifier.addScriptReference("/static/concepts/scripts/concept-find-create.js");
+
+resultDocModifier.addScriptReference("/concepts/generic-resource/scripts/concept-find-create.js");
+resultDocModifier.addScriptReference("/concepts/generic-resource/scripts/jquery.rdfquery.core-1.0.js");
+
+resultDocModifier.addScriptReference("/scripts/alert-message.js");
+resultDocModifier.addScriptReference("/yui/2/yahoo-dom-event/yahoo-dom-event.js");
+resultDocModifier.addScriptReference("/yui/2/element/element-min.js");
+resultDocModifier.addScriptReference("/yui/2/container/container-min.js");
+resultDocModifier.addStyleSheet("/yui/2/container/assets/container-core.css");
+
 
 <div>Add Concepts</div>
 <form onsubmit="return ConceptFinder.search()" id="search-form">

Modified: 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/manage-concept-providers-page.ssp
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/manage-concept-providers-page.ssp?rev=941267&r1=941266&r2=941267&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/manage-concept-providers-page.ssp
 (original)
+++ 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/manage-concept-providers-page.ssp
 Wed May  5 12:40:28 2010
@@ -43,7 +43,7 @@ resultDocModifier.addScriptReference("/j
 resultDocModifier.addScriptReference("/jquery/jquery.ajaxQueue.js");
 resultDocModifier.addScriptReference("/jquery/jquery.autocomplete.min.js");
 resultDocModifier.addScriptReference("/scripts/ajax-options.js");
-resultDocModifier.addScriptReference("/static/concepts/scripts/concept-provider-manipulation.js");
+resultDocModifier.addScriptReference("/concepts/generic-resource/scripts/e/scripts/concept-provider-manipulation.js");
 resultDocModifier.setTitle("Resource Tagging");
 resultDocModifier.addNodes2Elem("tx-module", <h1>Resource Tagging</h1>);
 

Modified: 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/selected-concepts.ssp
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/selected-concepts.ssp?rev=941267&r1=941266&r2=941267&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/selected-concepts.ssp
 (original)
+++ 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/selected-concepts.ssp
 Wed May  5 12:40:28 2010
@@ -1,7 +1,7 @@
 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)
 
-resultDocModifier.addScriptReference("/static/concepts/scripts/selected-concepts.js");
+resultDocModifier.addScriptReference("/concepts/generic-resource/scripts/selected-concepts.js");
 
 <div>
        <div id="selected-concepts">
@@ -10,7 +10,7 @@ resultDocModifier.addScriptReference("/s
                        <div>PrefLabel: {concept/skos("prefLabel")*}</div>
                        <div>Uri: {concept*}</div>
                        <input type="hidden" name="concepts" 
value={concept*}></input>
-                       <a href="#" class="tx-icon tx-icon-delete" >Add</a>
+                       <a href="#" class="tx-icon tx-icon-delete" >Remove</a>
                        <br />
                        <br />
                </div>

Added: 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/scripts/concept-find-create.js
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/scripts/concept-find-create.js?rev=941267&view=auto
==============================================================================
--- 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/scripts/concept-find-create.js
 (added)
+++ 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/scripts/concept-find-create.js
 Wed May  5 12:40:28 2010
@@ -0,0 +1,217 @@
+/*
+ * 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.
+ * 
+ * @author hasan, andre
+ */
+function ConceptFinder(){
+};
+
+ConceptFinder.callback;
+
+ConceptFinder.setAddConceptCallback = function(callback){
+       this.callback = callback;
+}
+
+/**
+ * Request the server concepts that match the search term in the input field 
"search-term"
+ */
+ConceptFinder.search = function(){
+       $("#system-found-concepts").empty();
+       var queryResult = null;
+       var searchTerm = $(":text[name=\"search-term\"]").val();
+       if (searchTerm.length > 0) {
+               var options = new AjaxOptions("find-concepts", "finding 
concepts", function(data){
+                       var databank = $.rdf.databank();
+                       var store = databank.load(data, {});
+                       var query = $.rdf({
+                               databank: store
+                       });
+                       query.prefix('rdf', 
'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
+                       query.prefix('concepts', 
'http://clerezza.org/2010/01/concepts#');
+                       query.prefix('rdfs', 
'http://www.w3.org/2000/01/rdf-schema#');
+                       query.prefix('qr', 
'http://clerezza.org/2010/04/queryresult#');
+                       var resultSet = query.where('?subject rdf:type 
qr:QueryResult');
+                       if (resultSet.size() != 1) {
+                               AlertMessage.show(function(){
+                               }, "The query results did not match what's 
expected: exactly 1 result");
+                       }
+                       var queryResult = query.node(resultSet.get(0).subject);
+                       var conceptProperty = 
$.rdf.resource("<http://clerezza.org/2010/04/queryresult#concept>");
+                       var conceptProperties = 
queryResult.get(conceptProperty);
+                       if (conceptProperties) {
+                               
ConceptFinder.addFoundConcepts(conceptProperties);
+                       }
+                       $("#add-button-label").html("<div>Add '" + searchTerm + 
"' as new Free Concept</div>");
+                       $("#system-found-concepts-area").show();
+                       var newFreeConceptProperty = 
$.rdf.resource("<http://clerezza.org/2010/04/queryresult#creationOfNewFreeConceptSuggested>");
+                       var creationOfNewFreeConceptSuggested = 
queryResult.get(newFreeConceptProperty)[0].value.toString() == "true";
+                       if (creationOfNewFreeConceptSuggested) {
+                               $("#user-defined-concept-area").show();
+                       } else {
+                               $("#user-defined-concept-area").hide();
+                       }
+               });
+               options.url = "/concepts/find";
+               options.data = "searchTerm=" + encodeURIComponent(searchTerm) + 
"&xPropObj=http://clerezza.org/2010/04/queryresult%23concept";;
+               options.dataType = "json";
+               options.beforeSend = function(req){
+                       req.setRequestHeader("Accept", "application/rdf+json");
+               };
+               
+               $.ajax(options);
+       }
+       return false;
+}
+
+/**
+ * Adds the given (array of) concepts to the UI (that's currently being 
displayed). Displays them by a 
+ * +-button and labels (for each of them)
+ *
+ * @param Json array of concepts
+ */
+ConceptFinder.addFoundConcepts = function(concepts){
+       var selectedConceptsExists = false;
+       if (typeof(SelectedConcepts) != "undefined") {
+               selectedConceptsExists = true;
+       }
+       var added = false;
+       for (var i = 0; i < concepts.length; i++) {
+               var concept = concepts[i];
+               if (!selectedConceptsExists || 
!SelectedConcepts.exists(concept.value)) {
+                       added = true;
+                       var prefLabelProperty = 
$.rdf.resource("<http://www.w3.org/2008/05/skos#prefLabel>"); 
+                       var prefLabel = concept.get(prefLabelProperty).value;
+                       var uri = concept.value;
+                       ConceptFinder.createSystemFoundConcept(prefLabel, uri);
+               }
+       }
+       if (added) {
+               $("#label-for-search-results").text("Concepts found:");
+       }
+       else {
+               $("#label-for-search-results").text("No additional concepts 
found.");
+       }
+}
+
+/**
+ * Creates the widget that show the user a concept that was found on the 
backend. Shows prefLabel, 
+ * uri and a button to add the concept to the backend
+ * 
+ * @param {Object} prefLabel
+ * @param {Object} uri
+ */
+ConceptFinder.createSystemFoundConcept = function(prefLabel, uri) {
+       var div = $("<div/>");
+       ConceptFinder.createConceptWidgets(prefLabel, uri).appendTo(div)
+       $("<a/>").addClass("tx-icon tx-icon-plus").attr({
+               href: "#"
+       }).text("Add").click(ConceptFinder.onAddClicked(prefLabel, 
uri)).appendTo(div);
+       $("<br/>").appendTo(div);
+       $("<br/>").appendTo(div);
+       div.appendTo("#system-found-concepts")
+}
+
+ConceptFinder.onAddClicked = function(prefLabel, uri){
+       return function(){
+               if (typeof(SelectedConcepts) != "undefined") {
+                       SelectedConcepts.addConcept(prefLabel, uri);
+               }
+               if (typeof(ConceptFinder.callback) == "function") {
+                       ConceptFinder.callback(prefLabel, uri);
+               }
+               $(this).parent().remove();
+       };
+}
+
+/**
+ * Creates html elements that show the given pref label and uri. Appends them 
to the given div.
+ * 
+ * @param {Object} prefLabel
+ * @param {Object} uri
+ * @param {Object} div
+ */
+ConceptFinder.createConceptWidgets = function(prefLabel, uri) {
+       var div = $("<div/>");
+       if (prefLabel.substr(0,1) == "\"") {
+               prefLabel = prefLabel.substring(1, prefLabel.length - 1);
+       }
+       $("<div/>").text("PrefLabel: " + prefLabel).appendTo(div);
+       $("<div/>").text("Uri: " + uri).appendTo(div);
+       $("<input/>").attr({
+               "type": "hidden",
+               "name": "concepts"
+       }).val(uri).appendTo(div);
+       return div;
+}
+
+/**
+ * Checks if a concept with the given uri already exists
+ * @param {Object} uri
+ */
+ConceptFinder.exists = function(uri){
+
+};
+
+function ConceptManipulator(){
+};
+
+ConceptManipulator.callback;
+
+ConceptManipulator.setAddConceptCallback = function(callback){
+       this.callback = callback;
+}
+
+/**
+ * sends a new concept to the backend for addition. Uses the search term 
entered by the user (in the same form).
+ */
+ConceptManipulator.addConcept = function(){
+       var searchTerm = $(":text[name='search-term']").val();
+       if (searchTerm.length > 0) {
+               var options = new AjaxOptions("add-concepts", "adding 
concepts", function(uri){
+                       $("#concept-description").val("");
+                       if (typeof(SelectedConcepts) != "undefined") {
+                               SelectedConcepts.addConcept(searchTerm, uri);
+                       }
+                       if (typeof(this.callback) == "function") {
+                               this.callback(searchTerm, uri);
+                       }
+               });
+               options.type = "POST";
+               options.url = "/concepts/manipulator/add-concept";
+               options.data = {
+                       "pref-label": searchTerm,
+                       lang: $(":input[name='lang']").val(),
+                       comment: $(":textarea[name='comment']").val()
+               }
+               
+               $.ajax(options);
+       }
+       return false;
+}
+
+$(document).ready(function(){
+       $("#go-button").click(function(){
+               ConceptFinder.search();
+       });
+       $("#add-user-defined-concept").click(function(){
+               ConceptManipulator.addConcept();
+               $("#user-defined-concept-area").hide();
+       });
+       $("#system-found-concepts-area").hide();
+       $("#user-defined-concept-area").hide();
+});

Added: 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/scripts/concept-provider-manipulation.js
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/scripts/concept-provider-manipulation.js?rev=941267&view=auto
==============================================================================
--- 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/scripts/concept-provider-manipulation.js
 (added)
+++ 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.concepts/org.apache.clerezza.platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/scripts/concept-provider-manipulation.js
 Wed May  5 12:40:28 2010
@@ -0,0 +1,213 @@
+/*
+ * 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.
+ */
+function ConceptProviderGui(){};
+
+ConceptProviderGui.isModified = false;
+
+ConceptProviderGui.query = "PREFIX owl: <http://www.w3.org/2002/07/owl#> \n" +
+       "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
+       "PREFIX skos08: <http://www.w3.org/2008/05/skos#> \n" +
+       "PREFIX skos04: <http://www.w3.org/2004/02/skos/core#> \n" +
+       "CONSTRUCT { ?concept a skos08:Concept; skos08:prefLabel ?prefLabel; " +
+               "rdfs:comment ?comment; owl:sameAs ?sameConcept . } \n" +
+       "WHERE { ?concept a skos04:Concept; skos04:prefLabel ?prefLabel . \n" +
+       "OPTIONAL { ?concept rdfs:comment ?comment . } \n" +
+       "OPTIONAL { ?concept owl:sameAs ?sameConcept . } \n" +
+       "FILTER (REGEX(STR(?prefLabel), '${searchTerm}', 'i'))}";
+
+ConceptProviderGui.initButtons = function() {
+
+       ConceptProviderGui.updateButtonState();
+
+       $("#deleteButton").click(function(event) {
+               $("input:checked").each(function() {
+                       $(this).parent().parent().remove();
+               });
+               $(this).addClass("tx-inactive");
+               ConceptProviderGui.isModified = true;
+       });
+
+       $("#addProvider").click(function(event) {
+               ConceptProviderGui.addProvider($("#type").val(),
+                                       $("#conceptScheme").val(),
+                                       $("#sparqlEndPoint").val(),
+                                       $("#defaultGraph").val(),
+                                       $("#query").val());
+               $("#conceptScheme").val("");
+               $("#sparqlEndPoint").val("");
+               $("#defaultGraph").val("");
+               $("#query").val("");
+       });
+
+       $("#addButton").click(function(event) {
+               if($(this).text() == "Save") {
+                       var options = new AjaxOptions("update-providers", 
"updating providers", function(obj) {
+                       });
+                       $("textarea[id!=query]").each(function() {
+                               $(this).removeAttr("disabled");
+                       });
+                       options.type = "POST";
+                       options.url = "update-concept-provider-list";
+                       options.data = $("#providers").serialize();
+                       $.ajax(options);
+               }
+       });
+}
+
+ConceptProviderGui.addProvider = function(rdfType, conceptScheme, 
sparqlEndPoint, defaultGraph, query) {
+       var tr = $("<tr/>").attr("id", "");
+       var td1 = $("<td/>");
+       var div = $("<div/>").text("Provider:");
+       var td2 = $("<td/>");
+
+       var selection = $("<select/>").attr("name","types");
+
+       $("#type > option:not(:selected)").each(function() {
+               selection.append($(this).clone());
+       });
+       $("#type > option:selected").each(function() {
+               var option = $(this).clone();
+               option.attr("selected", "selected");
+               selection.append(option);
+       });
+
+       td2.append(div);
+       td2.append(selection);
+       
+       var inputText = $("<input/>").attr({
+                               "type":"text",
+                               "name":"conceptSchemes",
+                               "value": conceptScheme
+                               });
+       
+       div = $("<div/>").text("Concept Scheme:");
+       td2.append(div);
+       td2.append(inputText);
+
+       inputText = $("<input/>").attr({
+                               "type":"text",
+                               "name":"sparqlEndPoints",
+                               "value": sparqlEndPoint
+                               });
+
+       div = $("<div/>").text("SPARQL End Point");
+       td2.append(div);
+       td2.append(inputText);
+
+       inputText = $("<input/>").attr({
+                               "type":"text",
+                               "name":"defaultGraphs",
+                               "value": defaultGraph
+                               });
+
+       div = $("<div/>").text("Default Graph:");
+       td2.append(div);
+       td2.append(inputText)
+       var inputCheckbox = $("<input/>").attr({
+                               "type":"checkbox",
+                               "value": rdfType
+                               });
+
+       inputCheckbox.appendTo(td1);
+
+       td1.appendTo(tr);
+       
+       var textArea = $("<textarea/>").attr({
+                               "rows":"8",
+                               "name":"queryTemplates"
+                               }).val(query);
+       div = $("<div/>").text("Query Template:");
+       td2.append(div);
+       td2.append(textArea);
+       td2.append($("<br/>"));
+       td2.append($("<br/>"));
+       td2.appendTo(tr);
+       tr.insertBefore("#last");
+       ConceptProviderGui.isModified = true;
+
+       $("select[name=types] > option:selected").each(function() {
+               ConceptProviderGui.updateDropDown($(this), "conceptSchemes");
+       });
+}
+
+ConceptProviderGui.updateDropDown = function (obj, name) {
+       if(obj.val().indexOf("Local") != -1) {
+               obj.parent().parent().find("input[name!=" + name + 
"]").each(function() {
+                       $(this).prev().hide();
+                       $(this).hide();
+               });
+               obj.parent().parent().find("input[name=" + name + 
"]").each(function() {
+                       $(this).prev().show();
+                       $(this).show();
+               });
+               obj.parent().parent().find("textarea").each(function() {
+                       $(this).prev().hide();
+                       $(this).hide();
+               });
+       } else {
+               obj.parent().parent().find("input[name!=" + name + 
"]").each(function() {
+                       $(this).prev().show();
+                       $(this).show();
+               });
+               obj.parent().parent().find("input[name=" + name + 
"]").each(function() {
+                       $(this).prev().hide();
+                       $(this).hide();
+               });
+               obj.parent().parent().find("textarea").each(function() {
+                       $(this).prev().show();
+                       $(this).show();
+               });
+       }
+}
+
+ConceptProviderGui.updateButtonState = function() {
+       var counter = $("input:checked").length;
+       if(counter == 0) {
+               $("#deleteButton").addClass("tx-inactive");
+       } else {
+               $("#deleteButton").removeClass("tx-inactive");
+       }
+}
+
+$(document).ready(function () {
+
+       $("select[name=types]").live("change", function() {
+               $("select[name=types] > option:selected").each(function(){
+                       ConceptProviderGui.updateDropDown($(this), 
"conceptSchemes");
+               });
+       });
+       $("select[name=types] > option:selected").each(function() {
+               ConceptProviderGui.updateDropDown($(this), "conceptSchemes");
+       });
+       $("#type").live("change", function() {
+               $("#type > option:selected").each(function(){
+                       ConceptProviderGui.updateDropDown($(this), 
"conceptScheme");
+                       $("#query").val(ConceptProviderGui.query);
+               });
+       });
+       $("#type > option:selected").each(function() {
+               ConceptProviderGui.updateDropDown($(this), "conceptScheme");
+               $("#query").val(ConceptProviderGui.query);
+       });
+       $("input:checkbox").live("change",function() {
+               ConceptProviderGui.updateButtonState();
+       });
+
+       ConceptProviderGui.initButtons();
+});


Reply via email to