You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by si...@apache.org on 2012/03/05 17:03:59 UTC
svn commit: r1297108 - in /incubator/stanbol/trunk: ./ contenthub/
contenthub/bundlelist/src/main/bundles/ contenthub/crawler/
contenthub/ldpath/
contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/backend/clerezza/
contenthub/ldpath/s...
Author: sinaci
Date: Mon Mar 5 16:03:58 2012
New Revision: 1297108
URL: http://svn.apache.org/viewvc?rev=1297108&view=rev
Log:
Moving CNN Crawler from contenthub into demos
Added:
incubator/stanbol/trunk/demos/crawler/ (props changed)
- copied from r1296946, incubator/stanbol/trunk/contenthub/crawler/
Removed:
incubator/stanbol/trunk/contenthub/crawler/
incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/model/
incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/CNNImporterResource.java
incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/CNNImporterResource/
incubator/stanbol/trunk/demos/crawler/cnn/
Modified:
incubator/stanbol/trunk/contenthub/bundlelist/src/main/bundles/list.xml
incubator/stanbol/trunk/contenthub/ldpath/pom.xml
incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/backend/clerezza/ClerezzaQuery.java
incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDPathUtils.java
incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/SemanticIndexManagerImpl.java
incubator/stanbol/trunk/contenthub/pom.xml
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/SemanticIndexManager.java
incubator/stanbol/trunk/contenthub/test/pom.xml
incubator/stanbol/trunk/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/CNNTest.java
incubator/stanbol/trunk/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/StoreTest.java
incubator/stanbol/trunk/contenthub/web/pom.xml
incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/fragment/ContenthubWebFragment.java
incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource/index.ftl
incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource/result.ftl
incubator/stanbol/trunk/parent/pom.xml
incubator/stanbol/trunk/pom.xml
Modified: incubator/stanbol/trunk/contenthub/bundlelist/src/main/bundles/list.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/bundlelist/src/main/bundles/list.xml?rev=1297108&r1=1297107&r2=1297108&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/bundlelist/src/main/bundles/list.xml (original)
+++ incubator/stanbol/trunk/contenthub/bundlelist/src/main/bundles/list.xml Mon Mar 5 16:03:58 2012
@@ -45,13 +45,13 @@
<artifactId>org.apache.stanbol.contenthub.web</artifactId>
<version>0.9.0-incubating-SNAPSHOT</version>
</bundle>
+ <!-- Moving CNN Crawler to demos/
<bundle>
<groupId>org.apache.stanbol</groupId>
<artifactId>org.apache.stanbol.contenthub.crawler.cnn</artifactId>
<version>0.9.0-incubating-SNAPSHOT</version>
</bundle>
-
- <!-- LDPath -->
+ -->
<bundle>
<groupId>org.apache.stanbol</groupId>
<artifactId>org.apache.stanbol.contenthub.ldpath</artifactId>
Modified: incubator/stanbol/trunk/contenthub/ldpath/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/ldpath/pom.xml?rev=1297108&r1=1297107&r2=1297108&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/ldpath/pom.xml (original)
+++ incubator/stanbol/trunk/contenthub/ldpath/pom.xml Mon Mar 5 16:03:58 2012
@@ -44,6 +44,7 @@
nu.xom.*
</Export-Package>
<Import-Package>
+ at.newmedialab.ldpath.*; version="[0.9.4, 1)",
!org.apache.xerces.*,
!com.sun.org.apache.xerces.internal.*,
!junit.framework.*,
@@ -70,11 +71,13 @@
<dependency>
<groupId>org.apache.stanbol</groupId>
<artifactId>org.apache.stanbol.commons.stanboltools.datafileprovider</artifactId>
- </dependency>
+ </dependency>
+ <!--
<dependency>
<groupId>org.apache.stanbol</groupId>
<artifactId>org.apache.stanbol.commons.ldpath.clerezza</artifactId>
- </dependency>
+ </dependency>
+ -->
<dependency>
<groupId>org.apache.stanbol</groupId>
<artifactId>org.apache.stanbol.commons.solr.core</artifactId>
Modified: incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/backend/clerezza/ClerezzaQuery.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/backend/clerezza/ClerezzaQuery.java?rev=1297108&r1=1297107&r2=1297108&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/backend/clerezza/ClerezzaQuery.java (original)
+++ incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/backend/clerezza/ClerezzaQuery.java Mon Mar 5 16:03:58 2012
@@ -1,180 +1,180 @@
-/*
- * 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.stanbol.contenthub.ldpath.backend.clerezza;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.Resource;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.clerezza.rdf.core.serializedform.Parser;
-import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
-import org.apache.clerezza.rdf.jena.parser.JenaParserProvider;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.commons.cli.OptionGroup;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.commons.cli.PosixParser;
-import org.apache.stanbol.commons.ldpath.clerezza.ClerezzaBackend;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.newmedialab.ldpath.LDPath;
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import at.newmedialab.ldpath.exception.LDPathParseException;
-
-/**
- * This class provides a main function for executing an LDProgram on {@link ClerezzaBackend} ,which is
- * Clerezza based implementation of {@link RDFBackend}, populated with RDF data.
- *
- * @author suat
- *
- */
-public class ClerezzaQuery {
- private static final Logger logger = LoggerFactory.getLogger(ClerezzaQuery.class);
-
- private static Parser clerezzaRDFParser;
-
- /**
- * This executable method provides execution of an LDPath program over an RDF data and prints out the
- * obtained results. Passed RDF data should be in <b>RDF/XML</b> format.<br>
- *
- * Usage of this main method is as follows: <br>
- * ClerezzaQuery -context <pre><uri></pre> -filePath <pre><filePath></pre> -path <pre><path></pre> | -program <pre><file></pre></br></br>
- *
- * <b><code>context</code>:</b> URI of the context node to start from<br>
- * <b><code>rdfData</code>:</b> File system path of the file holding RDF data<br>
- * <b><code>path</code>:</b> LD Path to evaluate on the file starting from the <code>context</code><br>
- * <b><code>program</code>:</b> LD Path program to evaluate on the file starting from the
- * <code>context</code><br>
- *
- * @param args
- * Collection of <code>context</code>, <code>rdfData</code>, <code>path</code> and <code>program</code> parameters
- *
- */
- public static void main(String[] args) {
- Options options = buildOptions();
-
- CommandLineParser parser = new PosixParser();
- try {
- CommandLine cmd = parser.parse(options, args);
-
- ClerezzaBackend clerezzaBackend = null;
- if (cmd.hasOption("rdfData")) {
- clerezzaRDFParser = new Parser();
- clerezzaRDFParser.bindParsingProvider(new JenaParserProvider());
- MGraph mGraph = new SimpleMGraph(clerezzaRDFParser.parse(
- new FileInputStream(cmd.getOptionValue("rdfData")), SupportedFormat.RDF_XML));
- clerezzaBackend = new ClerezzaBackend(mGraph);
- }
-
- Resource context = null;
- if (cmd.hasOption("context")) {
- context = clerezzaBackend.createURI(cmd.getOptionValue("context"));
- }
-
- if (clerezzaBackend != null && context != null) {
- LDPath<Resource> ldpath = new LDPath<Resource>(clerezzaBackend);
-
- if (cmd.hasOption("path")) {
- String path = cmd.getOptionValue("path");
-
- for (Resource r : ldpath.pathQuery(context, path, null)) {
- System.out.println(r.toString());
- }
- } else if (cmd.hasOption("program")) {
- File file = new File(cmd.getOptionValue("program"));
-
- Map<String,Collection<?>> result = ldpath.programQuery(context, new FileReader(file));
-
- for (String field : result.keySet()) {
- StringBuilder line = new StringBuilder();
- line.append(field);
- line.append(" = ");
- line.append("{");
- for (Iterator<?> it = result.get(field).iterator(); it.hasNext();) {
- line.append(it.next().toString());
- if (it.hasNext()) {
- line.append(", ");
- }
- }
- line.append("}");
- System.out.println(line);
-
- }
- }
- }
-
- } catch (ParseException e) {
- logger.error("invalid arguments");
- HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp("ClerezzaQuery", options, true);
- } catch (LDPathParseException e) {
- logger.error("path or program could not be parsed");
- e.printStackTrace();
- } catch (FileNotFoundException e) {
- logger.error("file or program could not be found");
- HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp("ClerezzaQuery", options, true);
- }
-
- }
-
- private static Options buildOptions() {
- Options result = new Options();
-
- OptionGroup query = new OptionGroup();
- OptionBuilder.withArgName("path");
- OptionBuilder.hasArg();
- OptionBuilder.withDescription("LD Path to evaluate on the file starting from the context");
- Option path = OptionBuilder.create("path");
- OptionBuilder.withArgName("file");
- OptionBuilder.hasArg();
- OptionBuilder.withDescription("LD Path program to evaluate on the file starting from the context");
- Option program = OptionBuilder.create("program");
- query.addOption(path);
- query.addOption(program);
- query.setRequired(true);
- result.addOptionGroup(query);
-
- OptionBuilder.withArgName("rdfData");
- OptionBuilder.hasArg();
- OptionBuilder.withDescription("File system path of the file holding RDF data");
- Option filePath = OptionBuilder.create("rdfData");
- filePath.setRequired(true);
- result.addOption(filePath);
-
- OptionBuilder.withArgName("uri");
- OptionBuilder.hasArg();
- OptionBuilder.withDescription("URI of the context node to start from");
- Option context = OptionBuilder.create("context");
- context.setRequired(true);
- result.addOption(context);
-
- return result;
- }
-}
+///*
+// * 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.stanbol.contenthub.ldpath.backend.clerezza;
+//
+//import java.io.File;
+//import java.io.FileInputStream;
+//import java.io.FileNotFoundException;
+//import java.io.FileReader;
+//import java.util.Collection;
+//import java.util.Iterator;
+//import java.util.Map;
+//
+//import org.apache.clerezza.rdf.core.MGraph;
+//import org.apache.clerezza.rdf.core.Resource;
+//import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
+//import org.apache.clerezza.rdf.core.serializedform.Parser;
+//import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
+//import org.apache.clerezza.rdf.jena.parser.JenaParserProvider;
+//import org.apache.commons.cli.CommandLine;
+//import org.apache.commons.cli.CommandLineParser;
+//import org.apache.commons.cli.HelpFormatter;
+//import org.apache.commons.cli.Option;
+//import org.apache.commons.cli.OptionBuilder;
+//import org.apache.commons.cli.OptionGroup;
+//import org.apache.commons.cli.Options;
+//import org.apache.commons.cli.ParseException;
+//import org.apache.commons.cli.PosixParser;
+//import org.apache.stanbol.commons.ldpath.clerezza.ClerezzaBackend;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+//
+//import at.newmedialab.ldpath.LDPath;
+//import at.newmedialab.ldpath.api.backend.RDFBackend;
+//import at.newmedialab.ldpath.exception.LDPathParseException;
+//
+///**
+// * This class provides a main function for executing an LDProgram on {@link ClerezzaBackend} ,which is
+// * Clerezza based implementation of {@link RDFBackend}, populated with RDF data.
+// *
+// * @author suat
+// *
+// */
+//public class ClerezzaQuery {
+// private static final Logger logger = LoggerFactory.getLogger(ClerezzaQuery.class);
+//
+// private static Parser clerezzaRDFParser;
+//
+// /**
+// * This executable method provides execution of an LDPath program over an RDF data and prints out the
+// * obtained results. Passed RDF data should be in <b>RDF/XML</b> format.<br>
+// *
+// * Usage of this main method is as follows: <br>
+// * ClerezzaQuery -context <pre><uri></pre> -filePath <pre><filePath></pre> -path <pre><path></pre> | -program <pre><file></pre></br></br>
+// *
+// * <b><code>context</code>:</b> URI of the context node to start from<br>
+// * <b><code>rdfData</code>:</b> File system path of the file holding RDF data<br>
+// * <b><code>path</code>:</b> LD Path to evaluate on the file starting from the <code>context</code><br>
+// * <b><code>program</code>:</b> LD Path program to evaluate on the file starting from the
+// * <code>context</code><br>
+// *
+// * @param args
+// * Collection of <code>context</code>, <code>rdfData</code>, <code>path</code> and <code>program</code> parameters
+// *
+// */
+// public static void main(String[] args) {
+// Options options = buildOptions();
+//
+// CommandLineParser parser = new PosixParser();
+// try {
+// CommandLine cmd = parser.parse(options, args);
+//
+// ClerezzaBackend clerezzaBackend = null;
+// if (cmd.hasOption("rdfData")) {
+// clerezzaRDFParser = new Parser();
+// clerezzaRDFParser.bindParsingProvider(new JenaParserProvider());
+// MGraph mGraph = new SimpleMGraph(clerezzaRDFParser.parse(
+// new FileInputStream(cmd.getOptionValue("rdfData")), SupportedFormat.RDF_XML));
+// clerezzaBackend = new ClerezzaBackend(mGraph);
+// }
+//
+// Resource context = null;
+// if (cmd.hasOption("context")) {
+// context = clerezzaBackend.createURI(cmd.getOptionValue("context"));
+// }
+//
+// if (clerezzaBackend != null && context != null) {
+// LDPath<Resource> ldpath = new LDPath<Resource>(clerezzaBackend);
+//
+// if (cmd.hasOption("path")) {
+// String path = cmd.getOptionValue("path");
+//
+// for (Resource r : ldpath.pathQuery(context, path, null)) {
+// System.out.println(r.toString());
+// }
+// } else if (cmd.hasOption("program")) {
+// File file = new File(cmd.getOptionValue("program"));
+//
+// Map<String,Collection<?>> result = ldpath.programQuery(context, new FileReader(file));
+//
+// for (String field : result.keySet()) {
+// StringBuilder line = new StringBuilder();
+// line.append(field);
+// line.append(" = ");
+// line.append("{");
+// for (Iterator<?> it = result.get(field).iterator(); it.hasNext();) {
+// line.append(it.next().toString());
+// if (it.hasNext()) {
+// line.append(", ");
+// }
+// }
+// line.append("}");
+// System.out.println(line);
+//
+// }
+// }
+// }
+//
+// } catch (ParseException e) {
+// logger.error("invalid arguments");
+// HelpFormatter formatter = new HelpFormatter();
+// formatter.printHelp("ClerezzaQuery", options, true);
+// } catch (LDPathParseException e) {
+// logger.error("path or program could not be parsed");
+// e.printStackTrace();
+// } catch (FileNotFoundException e) {
+// logger.error("file or program could not be found");
+// HelpFormatter formatter = new HelpFormatter();
+// formatter.printHelp("ClerezzaQuery", options, true);
+// }
+//
+// }
+//
+// private static Options buildOptions() {
+// Options result = new Options();
+//
+// OptionGroup query = new OptionGroup();
+// OptionBuilder.withArgName("path");
+// OptionBuilder.hasArg();
+// OptionBuilder.withDescription("LD Path to evaluate on the file starting from the context");
+// Option path = OptionBuilder.create("path");
+// OptionBuilder.withArgName("file");
+// OptionBuilder.hasArg();
+// OptionBuilder.withDescription("LD Path program to evaluate on the file starting from the context");
+// Option program = OptionBuilder.create("program");
+// query.addOption(path);
+// query.addOption(program);
+// query.setRequired(true);
+// result.addOptionGroup(query);
+//
+// OptionBuilder.withArgName("rdfData");
+// OptionBuilder.hasArg();
+// OptionBuilder.withDescription("File system path of the file holding RDF data");
+// Option filePath = OptionBuilder.create("rdfData");
+// filePath.setRequired(true);
+// result.addOption(filePath);
+//
+// OptionBuilder.withArgName("uri");
+// OptionBuilder.hasArg();
+// OptionBuilder.withDescription("URI of the context node to start from");
+// Option context = OptionBuilder.create("context");
+// context.setRequired(true);
+// result.addOption(context);
+//
+// return result;
+// }
+//}
Modified: incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDPathUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDPathUtils.java?rev=1297108&r1=1297107&r2=1297108&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDPathUtils.java (original)
+++ incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDPathUtils.java Mon Mar 5 16:03:58 2012
@@ -40,9 +40,6 @@ import nu.xom.ParsingException;
import nu.xom.Serializer;
import nu.xom.ValidityException;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.Resource;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
import org.apache.commons.compress.archivers.ArchiveException;
import org.apache.commons.compress.archivers.ArchiveInputStream;
import org.apache.commons.compress.archivers.ArchiveStreamFactory;
@@ -51,9 +48,10 @@ import org.apache.commons.compress.archi
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
import org.apache.commons.io.IOUtils;
-import org.apache.stanbol.commons.ldpath.clerezza.ClerezzaBackend;
import org.apache.stanbol.contenthub.servicesapi.Constants;
import org.apache.stanbol.contenthub.servicesapi.ldpath.LDPathException;
+import org.apache.stanbol.entityhub.ldpath.backend.SiteManagerBackend;
+import org.apache.stanbol.entityhub.servicesapi.site.ReferencedSiteManager;
import org.osgi.framework.Bundle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -127,6 +125,8 @@ public class LDPathUtils {
}
private Bundle bundle;
+
+ private ReferencedSiteManager referencedSiteManager;
/**
* Constructor taking a {@link Bundle} parameter. This bundle is used when obtaining Solr schema template.
@@ -134,8 +134,9 @@ public class LDPathUtils {
* @param bundle
* From which the template Solr schema is obtained.
*/
- public LDPathUtils(Bundle bundle) {
+ public LDPathUtils(Bundle bundle, ReferencedSiteManager referencedSiteManager) {
this.bundle = bundle;
+ this.referencedSiteManager = referencedSiteManager;
}
/**
@@ -176,17 +177,16 @@ public class LDPathUtils {
}
}
- private Program<Resource> getLDPathProgram(String ldPathProgram) throws LDPathException {
+ private Program<Object> getLDPathProgram(String ldPathProgram) throws LDPathException {
if (ldPathProgram == null || ldPathProgram.isEmpty()) {
String msg = "LDPath Program cannot be null.";
logger.error(msg);
throw new LDPathException(msg);
}
- MGraph mGraph = new SimpleMGraph();
- RDFBackend<Resource> rdfBackend = new ClerezzaBackend(mGraph);
- RdfPathParser<Resource> LDparser = new RdfPathParser<Resource>(rdfBackend,
+ RDFBackend<Object> rdfBackend = new SiteManagerBackend(referencedSiteManager);
+ RdfPathParser<Object> LDparser = new RdfPathParser<Object>(rdfBackend,
constructReader(ldPathProgram));
- Program<Resource> program = null;
+ Program<Object> program = null;
try {
program = LDparser.parseProgram();
} catch (ParseException e) {
@@ -308,7 +308,7 @@ public class LDPathUtils {
* @return created template in an array of bytes.
* @throws LDPathException
*/
- private byte[] createSchemaXML(Program<Resource> program, byte[] template) throws LDPathException {
+ private byte[] createSchemaXML(Program<Object> program, byte[] template) throws LDPathException {
Builder xmlParser = new Builder();
ByteArrayInputStream is = new ByteArrayInputStream(template);
@@ -334,7 +334,7 @@ public class LDPathUtils {
Element fieldsNode = (Element) fieldsNodes.get(0);
Element schemaNode = (Element) fieldsNode.getParent();
- for (FieldMapping<?,Resource> fieldMapping : program.getFields()) {
+ for (FieldMapping<?,Object> fieldMapping : program.getFields()) {
String fieldName = fieldMapping.getFieldName();
String solrType = getSolrFieldType(fieldMapping.getFieldType());
Modified: incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/SemanticIndexManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/SemanticIndexManagerImpl.java?rev=1297108&r1=1297107&r2=1297108&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/SemanticIndexManagerImpl.java (original)
+++ incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/SemanticIndexManagerImpl.java Mon Mar 5 16:03:58 2012
@@ -19,12 +19,10 @@ package org.apache.stanbol.contenthub.ld
import java.io.File;
import java.io.IOException;
import java.io.Reader;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -35,7 +33,6 @@ import org.apache.felix.scr.annotations.
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
-import org.apache.stanbol.commons.indexedgraph.IndexedMGraph;
import org.apache.stanbol.commons.solr.managed.ManagedSolrServer;
import org.apache.stanbol.contenthub.servicesapi.ldpath.LDPathException;
import org.apache.stanbol.contenthub.servicesapi.ldpath.LDProgramCollection;
@@ -45,7 +42,6 @@ import org.apache.stanbol.contenthub.sto
import org.apache.stanbol.entityhub.core.model.InMemoryValueFactory;
import org.apache.stanbol.entityhub.ldpath.EntityhubLDPath;
import org.apache.stanbol.entityhub.ldpath.backend.SiteManagerBackend;
-import org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory;
import org.apache.stanbol.entityhub.servicesapi.model.Representation;
import org.apache.stanbol.entityhub.servicesapi.model.ValueFactory;
import org.apache.stanbol.entityhub.servicesapi.site.ReferencedSiteManager;
@@ -55,7 +51,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.newmedialab.ldpath.exception.LDPathParseException;
-import at.newmedialab.ldpath.model.fields.FieldMapping;
import at.newmedialab.ldpath.model.programs.Program;
/**
@@ -93,7 +88,7 @@ public class SemanticIndexManagerImpl im
@Activate
public void activator(ComponentContext cc) throws LDPathException, IOException {
bundle = cc.getBundleContext().getBundle();
- ldPathUtils = new LDPathUtils(bundle);
+ ldPathUtils = new LDPathUtils(bundle, referencedSiteManager);
String slingHome = cc.getBundleContext().getProperty("sling.home");
if (!slingHome.endsWith(File.separator)) slingHome += File.separator;
Modified: incubator/stanbol/trunk/contenthub/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/pom.xml?rev=1297108&r1=1297107&r2=1297108&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/pom.xml (original)
+++ incubator/stanbol/trunk/contenthub/pom.xml Mon Mar 5 16:03:58 2012
@@ -40,7 +40,6 @@
<module>servicesapi</module>
<module>store</module>
<module>search</module>
- <module>crawler/cnn</module>
<module>web</module>
<module>bundlelist</module>
<module>ldpath</module>
Modified: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/SemanticIndexManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/SemanticIndexManager.java?rev=1297108&r1=1297107&r2=1297108&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/SemanticIndexManager.java (original)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/SemanticIndexManager.java Mon Mar 5 16:03:58 2012
@@ -23,7 +23,6 @@ import java.util.Map;
import java.util.Set;
import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.stanbol.entityhub.servicesapi.model.Representation;
/**
* This interface provides create, retrieve, delete operations for LDPath programs to be managed in the scope
Modified: incubator/stanbol/trunk/contenthub/test/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/test/pom.xml?rev=1297108&r1=1297107&r2=1297108&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/test/pom.xml (original)
+++ incubator/stanbol/trunk/contenthub/test/pom.xml Mon Mar 5 16:03:58 2012
@@ -28,7 +28,7 @@
</parent>
<artifactId>org.apache.stanbol.contenthub.test</artifactId>
- <version>1.0.7-SNAPSHOT</version>
+ <version>0.9.0-incubating-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>Apache Sling Sample Server-Side Tests</name>
@@ -73,36 +73,50 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
- <version>1.5.11</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.8.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<!-- TODO create separate API package, this is just to get the special Sling test runner -->
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.junit.core</artifactId>
- <version>1.0.7-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.commons.web.base</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.commons.testing.http</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.commons.testing.stanbol</artifactId>
+ </dependency>
+
<dependency>
<groupId>org.apache.stanbol</groupId>
<artifactId>org.apache.stanbol.contenthub.crawler.cnn</artifactId>
</dependency>
<dependency>
<groupId>org.apache.stanbol</groupId>
- <artifactId>org.apache.stanbol.contenthub.store.solr</artifactId>
+ <artifactId>org.apache.stanbol.contenthub.servicesapi</artifactId>
</dependency>
<dependency>
<groupId>org.apache.stanbol</groupId>
<artifactId>org.apache.stanbol.contenthub.search.solr</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.contenthub.search.related</artifactId>
+ </dependency>
</dependencies>
-
<profiles>
<profile>
<!--
Modified: incubator/stanbol/trunk/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/CNNTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/CNNTest.java?rev=1297108&r1=1297107&r2=1297108&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/CNNTest.java (original)
+++ incubator/stanbol/trunk/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/CNNTest.java Mon Mar 5 16:03:58 2012
@@ -18,21 +18,60 @@ package org.apache.stanbol.contenthub.te
import static org.junit.Assert.*;
+import java.io.IOException;
import java.net.URI;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
+import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.clerezza.rdf.core.Triple;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.sling.junit.annotations.SlingAnnotationsTestRunner;
import org.apache.sling.junit.annotations.TestReference;
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.stanbol.commons.solr.managed.ManagedSolrServer;
import org.apache.stanbol.contenthub.crawler.cnn.CNNImporter;
+import org.apache.stanbol.contenthub.servicesapi.store.StoreException;
+import org.apache.stanbol.contenthub.servicesapi.store.solr.SolrStore;
+import org.apache.stanbol.contenthub.store.solr.manager.SolrCoreManager;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.osgi.framework.BundleContext;
+@RunWith(SlingAnnotationsTestRunner.class)
public class CNNTest {
@TestReference
private CNNImporter cNNImporter;
+ @TestReference
+ private SolrStore solrStore;
+
+ @TestReference
+ private BundleContext bundleContext;
+
+ @TestReference
+ private ManagedSolrServer managedSolrServer;
+
@Test
- public void testImportCNNNews(){
-// Map<URI, String> res = cNNImporter.importCNNNews("paris", 1, false);
-// assertNotNull("abc"+res.values(),res);
+ public void testImportCNNNews() throws SolrServerException, IOException, StoreException{
+ Map<URI, String> res = cNNImporter.importCNNNews("Paris", 1, false);
+ assertTrue(res.size() > 0);
+
+ SolrServer solrServer = SolrCoreManager.getInstance(bundleContext, managedSolrServer).getServer();
+ MGraph enhancementGraph = solrStore.getEnhancementGraph();
+
+ Iterator<Triple> it = enhancementGraph.filter(new UriRef(TestVocabulary.attachedId), null, null);
+ List<Triple> willBeRemoved = new ArrayList<Triple>();
+ while (it.hasNext()) {
+ willBeRemoved.add(it.next());
+ }
+ enhancementGraph.removeAll(willBeRemoved);
+
+ solrServer.deleteById(res.keySet().toArray()[0].toString());
+ solrServer.commit();
}
}
Modified: incubator/stanbol/trunk/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/StoreTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/StoreTest.java?rev=1297108&r1=1297107&r2=1297108&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/StoreTest.java (original)
+++ incubator/stanbol/trunk/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/StoreTest.java Mon Mar 5 16:03:58 2012
@@ -18,48 +18,285 @@ package org.apache.stanbol.contenthub.te
import static org.junit.Assert.*;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
+import org.apache.commons.io.IOUtils;
import org.apache.sling.junit.annotations.SlingAnnotationsTestRunner;
import org.apache.sling.junit.annotations.TestReference;
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.common.SolrDocument;
+import org.apache.stanbol.commons.solr.managed.ManagedIndexState;
+import org.apache.stanbol.commons.solr.managed.ManagedSolrServer;
+import org.apache.stanbol.contenthub.servicesapi.Constants;
+import org.apache.stanbol.contenthub.servicesapi.ldpath.LDPathException;
+import org.apache.stanbol.contenthub.servicesapi.ldpath.SemanticIndexManager;
+import org.apache.stanbol.contenthub.servicesapi.store.StoreException;
import org.apache.stanbol.contenthub.servicesapi.store.solr.SolrContentItem;
import org.apache.stanbol.contenthub.servicesapi.store.solr.SolrStore;
+import org.apache.stanbol.contenthub.servicesapi.store.vocabulary.SolrVocabulary.SolrFieldName;
+import org.apache.stanbol.contenthub.store.solr.SolrContentItemImpl;
+import org.apache.stanbol.contenthub.store.solr.manager.SolrCoreManager;
import org.apache.stanbol.contenthub.store.solr.util.ContentItemIDOrganizer;
-import org.junit.BeforeClass;
+import org.apache.stanbol.enhancer.servicesapi.ContentItem;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.osgi.framework.BundleContext;
@RunWith(SlingAnnotationsTestRunner.class)
public class StoreTest {
+
@TestReference
private SolrStore solrStore;
- private static byte[] content;
- private static String id, title, contentType;
- private static Map<String, List<Object>> constraints = new HashMap<String, List<Object>>();
-
- @BeforeClass
- public static void beforeClass() {
- content = "I love Paris".getBytes();
- id = "ab41c32a";
- title = "Paris";
- contentType = "text/plain";
- List<Object> value = new ArrayList<Object>();
- value.add("meric");
- constraints.put("author", value);
+ @TestReference
+ private SemanticIndexManager semanticIndexManager;
+
+ @TestReference
+ private BundleContext bundleContext;
+
+ @TestReference
+ private ManagedSolrServer managedSolrServer;
+
+ @Before
+ public void before(){
+ if(semanticIndexManager.isManagedProgram(TestVocabulary.programName)){
+ semanticIndexManager.deleteProgram(TestVocabulary.programName);
+ }
+ if(SolrCoreManager.getInstance(bundleContext, managedSolrServer).isManagedSolrCore(TestVocabulary.programName)){
+ SolrCoreManager.getInstance(bundleContext, managedSolrServer).deleteSolrCore(TestVocabulary.programName);
+ }
+ }
+
+ @Test
+ public void testSolrContentItemImpl() throws IOException{
+ SolrContentItem sci = new SolrContentItemImpl(TestVocabulary.id,
+ TestVocabulary.title, TestVocabulary.contentByte,
+ TestVocabulary.contentType, null, TestVocabulary.constraints);
+ assertEqual(sci,false);
+ assertEquals(TestVocabulary.consValuesArray, sci.getConstraints().get(TestVocabulary.consFieldName));
+ }
+
+ @Test
+ public void testDummyCreate() throws IOException {
+ ContentItem ci = solrStore.create(TestVocabulary.id,
+ TestVocabulary.contentByte, TestVocabulary.contentType);
+
+ assertArrayEquals(TestVocabulary.contentByte,
+ IOUtils.toByteArray(ci.getStream()));
+ assertEquals(TestVocabulary.id,
+ ContentItemIDOrganizer.detachBaseURI(ci.getUri()
+ .getUnicodeString()));
+ assertEquals(TestVocabulary.contentType, ci.getMimeType());
}
@Test
- public void testCreate() {
- SolrContentItem sci = solrStore.create(content, id, title, contentType,
- constraints);
-// assertEquals(content, sci.getStream());
- assertEquals(id,ContentItemIDOrganizer.detachBaseURI(sci.getUri().toString()));
- assertEquals(title,sci.getTitle());
- assertEquals(contentType,sci.getMimeType());
- assertEquals(constraints,sci.getConstraints());
+ public void testCreate() throws IOException {
+ SolrContentItem sci = solrStore.create(TestVocabulary.contentByte,
+ TestVocabulary.id, TestVocabulary.title,
+ TestVocabulary.contentType, TestVocabulary.constraints);
+ assertEqual(sci,false);
+ assertEquals(TestVocabulary.consValuesArray, sci.getConstraints().get(TestVocabulary.consFieldName));
+ }
+
+ @Test
+ public void testPut() throws StoreException, IOException,
+ SolrServerException {
+
+ SolrContentItem sci = new SolrContentItemImpl(TestVocabulary.id,
+ TestVocabulary.title, TestVocabulary.contentByte,
+ TestVocabulary.contentType, null, TestVocabulary.constraints);
+ solrStore.put(sci);
+ SolrServer solrServer = SolrCoreManager.getInstance(bundleContext,managedSolrServer).getServer();
+ SolrDocument result = TestUtils.getSolrDocument(solrServer);
+ assertEqual(result,true);
+
+ TestUtils.deleteDocument(solrServer,solrStore.getEnhancementGraph());
+ }
+
+ @Test
+ public void testPutWithLD() throws StoreException, IOException,
+ LDPathException, SolrServerException {
+ //We assume that if user give an LD Program, he will not give any constraints
+ SolrContentItem sci = new SolrContentItemImpl(TestVocabulary.id,
+ TestVocabulary.title, TestVocabulary.contentByte,
+ TestVocabulary.contentType, null, null);
+
+ semanticIndexManager.submitProgram(TestVocabulary.programName,
+ TestVocabulary.ldPathProgram);
+ solrStore.put(sci, TestVocabulary.programName);
+ SolrServer solrServer = SolrCoreManager.getInstance(bundleContext,managedSolrServer).getServer(TestVocabulary.programName);
+ SolrDocument result = TestUtils.getSolrDocument(solrServer);
+ assertEqual(result,false);
+
+ TestUtils.deleteDocument(solrServer,solrStore.getEnhancementGraph());
+ semanticIndexManager.deleteProgram(TestVocabulary.programName);
+ }
+
+ @Test
+ public void testGet() throws StoreException, SolrServerException, IOException {
+ SolrServer solrServer = SolrCoreManager.getInstance(bundleContext, managedSolrServer).getServer();
+ TestUtils.submitDocumentToSolr(solrServer,1,true);
+
+ SolrContentItem sci = (SolrContentItem) solrStore.get(TestVocabulary.id);
+ assertEqual(sci,true);
+
+ TestUtils.deleteDocument(solrServer,solrStore.getEnhancementGraph());
+ }
+
+ @Test
+ public void testGetWithLD() throws LDPathException, StoreException, SolrServerException, IOException{
+ semanticIndexManager.submitProgram(TestVocabulary.programName, TestVocabulary.ldPathProgram);
+ SolrServer solrServer = SolrCoreManager.getInstance(bundleContext, managedSolrServer).getServer(TestVocabulary.programName);
+ TestUtils.submitDocumentToSolr(solrServer,1,false);
+
+ SolrContentItem sci = solrStore.get(TestVocabulary.id, TestVocabulary.programName);
+ assertEqual(sci,false);
+
+ TestUtils.deleteDocument(solrServer,solrStore.getEnhancementGraph());
+ semanticIndexManager.deleteProgram(TestVocabulary.programName);
+ }
+
+ @Test
+ public void testDeleteById() throws StoreException, SolrServerException, IOException{
+ SolrServer solrServer = SolrCoreManager.getInstance(bundleContext, managedSolrServer).getServer();
+ TestUtils.submitDocumentToSolr(solrServer,1,true);
+
+ solrStore.deleteById(TestVocabulary.id);
+ SolrDocument result = TestUtils.getSolrDocument(solrServer);
+ assertNull(result);
+ }
+
+ @Test
+ public void testDeleteByIdWithLD() throws StoreException, SolrServerException, IOException, LDPathException{
+
+ semanticIndexManager.submitProgram(TestVocabulary.programName, TestVocabulary.ldPathProgram);
+ SolrServer solrServer = SolrCoreManager.getInstance(bundleContext, managedSolrServer).getServer(TestVocabulary.programName);
+ TestUtils.submitDocumentToSolr(solrServer,1,false);
+
+ solrStore.deleteById(TestVocabulary.id, TestVocabulary.programName);
+ SolrDocument result = TestUtils.getSolrDocument(solrServer);
+ assertNull(result);
+
+ semanticIndexManager.deleteProgram(TestVocabulary.programName);
+ }
+
+ @Test
+ public void testDeleteByIds() throws StoreException, SolrServerException, IOException{
+ SolrServer solrServer = SolrCoreManager.getInstance(bundleContext, managedSolrServer).getServer();
+ TestUtils.submitDocumentToSolr(solrServer,2,true);
+
+ List<String> idList = new ArrayList<String>();
+ idList.add(TestVocabulary.id);
+ idList.add(TestVocabulary.id+"2");
+
+ solrStore.deleteById(idList);
+ SolrDocument result = TestUtils.getSolrDocument(solrServer);
+ assertNull(result);
+ }
+
+ @Test
+ public void testDeleteByIdsWithLD() throws StoreException, SolrServerException, IOException, LDPathException{
+
+ semanticIndexManager.submitProgram(TestVocabulary.programName, TestVocabulary.ldPathProgram);
+ SolrServer solrServer = SolrCoreManager.getInstance(bundleContext, managedSolrServer).getServer(TestVocabulary.programName);
+ TestUtils.submitDocumentToSolr(solrServer,2,false);
+
+ List<String> idList = new ArrayList<String>();
+ idList.add(TestVocabulary.id);
+ idList.add(TestVocabulary.id+"2");
+
+ solrStore.deleteById(idList, TestVocabulary.programName);
+ SolrDocument result = TestUtils.getSolrDocument(solrServer);
+ assertNull(result);
+
+ semanticIndexManager.deleteProgram(TestVocabulary.programName);
+ }
+
+ @Test
+ public void testGetInstance(){
+ assertNotNull(SolrCoreManager.getInstance(bundleContext, managedSolrServer));
+ }
+
+ @Test
+ public void testGetServer() throws StoreException, LDPathException{
+ assertNotNull(SolrCoreManager.getInstance(bundleContext, managedSolrServer).getServer());
+ semanticIndexManager.submitProgram(TestVocabulary.programName, TestVocabulary.ldPathProgram);
+ assertNotNull(SolrCoreManager.getInstance(bundleContext, managedSolrServer).getServer(TestVocabulary.programName));
+ semanticIndexManager.deleteProgram(TestVocabulary.programName);
+ }
+
+ @Test
+ public void testCreateDefaultSolrServer() throws StoreException{
+ SolrCoreManager.getInstance(bundleContext, managedSolrServer).createDefaultSolrServer();
+ assertEquals(ManagedIndexState.ACTIVE, managedSolrServer.getIndexState(SolrCoreManager.CONTENTHUB_SOLR_SERVER_NAME));
+ }
+
+// @Test
+// public void testCreateSolrCore(){
+// SolrCoreManager ins = SolrCoreManager.getInstance(bundleContext, managedSolrServer);
+// ins.createSolrCore(
+// TestVocabulary.programName, ldPathUtils.createSchemaArchive(TestVocabulary.programName, TestVocabulary.ldPathProgram));
+// ins.isManagedSolrCore(TestVocabulary.programName);
+// ins.deleteSolrCore(TestVocabulary.programName);
+// }
+
+// @Test
+// public void testDeleteSolrCore(){
+//
+// }
+
+
+ private Map<String, List<Object>> getSolrConstraints(SolrDocument result) {
+ Map<String, List<Object>> solrConstraints = new HashMap<String, List<Object>>();
+ Iterator<Entry<String, Object>> itr = result.iterator();
+ while (itr.hasNext()) {
+ Entry<String, Object> entry = itr.next();
+ String key = entry.getKey();
+ if (!SolrFieldName.isNameReserved(key)) {
+ List<Object> values = (List<Object>) result.getFieldValues(key);
+ solrConstraints.put(key, values);
+ }
+ }
+ return solrConstraints;
+ }
+
+ private void assertEqual(SolrContentItem sci, boolean checkCons) throws IOException{
+ assertEquals(TestVocabulary.attachedId, sci.getUri().getUnicodeString());
+ assertEquals(TestVocabulary.content, IOUtils.toString(sci.getStream(), Constants.DEFAULT_ENCODING));
+ assertEquals(TestVocabulary.contentType, sci.getMimeType());
+ assertEquals(TestVocabulary.title, sci.getTitle());
+ if(checkCons){
+ assertEquals(TestVocabulary.consValuesArray, sci.getConstraints().get(TestVocabulary.consFieldName+TestVocabulary.consFieldType));
+ }
+ }
+
+ private void assertEqual(SolrDocument result, boolean checkCons) {
+ assertEquals(TestVocabulary.content,
+ (String) result.getFieldValue(SolrFieldName.CONTENT.toString()));
+ assertEquals(TestVocabulary.id,
+ ContentItemIDOrganizer.detachBaseURI((String) result
+ .getFieldValue(SolrFieldName.ID.toString())));
+ assertEquals(TestVocabulary.title,
+ (String) result.getFieldValue(SolrFieldName.TITLE.toString()));
+ assertEquals(
+ TestVocabulary.contentType,
+ (String) result.getFieldValue(SolrFieldName.MIMETYPE.toString()));
+
+ Map<String, List<Object>> solrConstraints = getSolrConstraints(result);
+
+ if (checkCons) {
+ assertEquals(
+ TestVocabulary.constraints
+ .get(TestVocabulary.consFieldName),
+ solrConstraints.get(TestVocabulary.consFieldName+TestVocabulary.consFieldType));
+ }
}
}
Modified: incubator/stanbol/trunk/contenthub/web/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/pom.xml?rev=1297108&r1=1297107&r2=1297108&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/pom.xml (original)
+++ incubator/stanbol/trunk/contenthub/web/pom.xml Mon Mar 5 16:03:58 2012
@@ -78,7 +78,6 @@
</build>
<dependencies>
-
<dependency>
<groupId>org.apache.stanbol</groupId>
<artifactId>org.apache.stanbol.commons.web.base</artifactId>
@@ -100,12 +99,6 @@
<artifactId>org.apache.stanbol.contenthub.search.featured</artifactId>
</dependency>
- <!-- Search Helper -->
- <dependency>
- <groupId>org.apache.stanbol</groupId>
- <artifactId>org.apache.stanbol.contenthub.crawler.cnn</artifactId>
- </dependency>
-
<!-- needed for the ContentItem resource -->
<dependency>
<groupId>org.apache.stanbol</groupId>
Modified: incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/fragment/ContenthubWebFragment.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/fragment/ContenthubWebFragment.java?rev=1297108&r1=1297107&r2=1297108&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/fragment/ContenthubWebFragment.java (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/fragment/ContenthubWebFragment.java Mon Mar 5 16:03:58 2012
@@ -30,10 +30,9 @@ import org.apache.stanbol.commons.web.ba
import org.apache.stanbol.commons.web.base.NavigationLink;
import org.apache.stanbol.commons.web.base.ScriptResource;
import org.apache.stanbol.commons.web.base.WebFragment;
-import org.apache.stanbol.contenthub.web.resources.CNNImporterResource;
import org.apache.stanbol.contenthub.web.resources.FeaturedSearchResource;
-import org.apache.stanbol.contenthub.web.resources.SemanticIndexManagerResource;
import org.apache.stanbol.contenthub.web.resources.RootResource;
+import org.apache.stanbol.contenthub.web.resources.SemanticIndexManagerResource;
import org.apache.stanbol.contenthub.web.resources.StoreResource;
import org.apache.stanbol.contenthub.web.writers.LDProgramCollectionWriter;
import org.apache.stanbol.contenthub.web.writers.SearchResultWriter;
@@ -44,90 +43,94 @@ import freemarker.cache.ClassTemplateLoa
import freemarker.cache.TemplateLoader;
/**
- * Statically define the list of available resources and providers to be contributed to the the Stanbol JAX-RS
- * Endpoint.
+ * Statically define the list of available resources and providers to be
+ * contributed to the the Stanbol JAX-RS Endpoint.
*/
@Component(immediate = true, metatype = true)
@Service
public class ContenthubWebFragment implements WebFragment {
- private static final String NAME = "contenthub";
+ private static final String NAME = "contenthub";
- private static final String TEMPLATE_PATH = "/org/apache/stanbol/contenthub/web/templates";
- private static final String STATIC_RESOURCE_PATH = "/org/apache/stanbol/contenthub/web/static";
+ private static final String TEMPLATE_PATH = "/org/apache/stanbol/contenthub/web/templates";
+ private static final String STATIC_RESOURCE_PATH = "/org/apache/stanbol/contenthub/web/static";
- private BundleContext bundleContext;
+ private BundleContext bundleContext;
- @Override
- public String getName() {
- return NAME;
- }
-
- @Activate
- protected void activate(ComponentContext ctx) {
- this.bundleContext = ctx.getBundleContext();
- }
-
- @Override
- public Set<Class<?>> getJaxrsResourceClasses() {
- Set<Class<?>> classes = new HashSet<Class<?>>();
- classes.add(RootResource.class);
- classes.add(StoreResource.class);
- classes.add(CNNImporterResource.class);
- classes.add(FeaturedSearchResource.class);
- classes.add(SemanticIndexManagerResource.class);
-
- classes.add(LDProgramCollectionWriter.class);
- classes.add(SearchResultWriter.class);
-
- return classes;
- }
-
- @Override
- public Set<Object> getJaxrsResourceSingletons() {
- return Collections.emptySet();
- }
-
- @Override
- public String getStaticResourceClassPath() {
- return STATIC_RESOURCE_PATH;
- }
-
- @Override
- public TemplateLoader getTemplateLoader() {
- return new ClassTemplateLoader(getClass(), TEMPLATE_PATH);
- }
-
- @Override
- public List<LinkResource> getLinkResources() {
- List<LinkResource> resources = new ArrayList<LinkResource>();
- resources.add(new LinkResource("stylesheet", "style/contenthub.css", this, 0));
- resources.add(new LinkResource("stylesheet", "style/jquery-ui-1.8.11.custom.css", this, 1));
- return resources;
- }
-
- @Override
- public List<ScriptResource> getScriptResources() {
- List<ScriptResource> resources = new ArrayList<ScriptResource>();
- resources.add(new ScriptResource("text/javascript", "scripts/prettify/prettify.js", this, 0));
- resources.add(new ScriptResource("text/javascript", "scripts/jit.js", this, 1));
- resources.add(new ScriptResource("text/javascript", "scripts/jquery-1.5.1.min.js", this, 2));
- resources
- .add(new ScriptResource("text/javascript", "scripts/jquery-ui-1.8.11.custom.min.js", this, 3));
- return resources;
- }
-
- @Override
- public List<NavigationLink> getNavigationLinks() {
- List<NavigationLink> links = new ArrayList<NavigationLink>();
- links.add(new NavigationLink("contenthub/contenthub/store", "/contenthub", "/imports/contenthubDescription.ftl",
- 20));
- return links;
- }
-
- @Override
- public BundleContext getBundleContext() {
- return bundleContext;
- }
+ @Override
+ public String getName() {
+ return NAME;
+ }
+
+ @Activate
+ protected void activate(ComponentContext ctx) {
+ this.bundleContext = ctx.getBundleContext();
+ }
+
+ @Override
+ public Set<Class<?>> getJaxrsResourceClasses() {
+ Set<Class<?>> classes = new HashSet<Class<?>>();
+ classes.add(RootResource.class);
+ classes.add(StoreResource.class);
+ classes.add(FeaturedSearchResource.class);
+ classes.add(SemanticIndexManagerResource.class);
+
+ classes.add(LDProgramCollectionWriter.class);
+ classes.add(SearchResultWriter.class);
+
+ return classes;
+ }
+
+ @Override
+ public Set<Object> getJaxrsResourceSingletons() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public String getStaticResourceClassPath() {
+ return STATIC_RESOURCE_PATH;
+ }
+
+ @Override
+ public TemplateLoader getTemplateLoader() {
+ return new ClassTemplateLoader(getClass(), TEMPLATE_PATH);
+ }
+
+ @Override
+ public List<LinkResource> getLinkResources() {
+ List<LinkResource> resources = new ArrayList<LinkResource>();
+ resources.add(new LinkResource("stylesheet", "style/contenthub.css",
+ this, 0));
+ resources.add(new LinkResource("stylesheet",
+ "style/jquery-ui-1.8.11.custom.css", this, 1));
+ return resources;
+ }
+
+ @Override
+ public List<ScriptResource> getScriptResources() {
+ List<ScriptResource> resources = new ArrayList<ScriptResource>();
+ resources.add(new ScriptResource("text/javascript",
+ "scripts/prettify/prettify.js", this, 0));
+ resources.add(new ScriptResource("text/javascript", "scripts/jit.js",
+ this, 1));
+ resources.add(new ScriptResource("text/javascript",
+ "scripts/jquery-1.5.1.min.js", this, 2));
+ resources.add(new ScriptResource("text/javascript",
+ "scripts/jquery-ui-1.8.11.custom.min.js", this, 3));
+ return resources;
+ }
+
+ @Override
+ public List<NavigationLink> getNavigationLinks() {
+ List<NavigationLink> links = new ArrayList<NavigationLink>();
+ links.add(new NavigationLink("contenthub/contenthub/store",
+ "/contenthub", "/imports/contenthubDescription.ftl", 20));
+ return links;
+ }
+
+ @Override
+ public BundleContext getBundleContext() {
+ return bundleContext;
+ }
}
Modified: incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource/index.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource/index.ftl?rev=1297108&r1=1297107&r2=1297108&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource/index.ftl (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource/index.ftl Mon Mar 5 16:03:58 2012
@@ -265,7 +265,7 @@
}
function setChosenFacet(JSONObject) {
var resultString = "";
- var chosenCons = $("#chosenFacetsHidden").attr("innerHTML");
+ var chosenCons = "'" + $("#chosenFacetsHidden").attr("value") + "'";
if(JSONObject != null) {
for(var p in JSONObject) {
Modified: incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource/result.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource/result.ftl?rev=1297108&r1=1297107&r2=1297108&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource/result.ftl (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource/result.ftl Mon Mar 5 16:03:58 2012
@@ -49,7 +49,7 @@
<#if it.chosenFacets?exists && it.chosenFacets != "{}">
<fieldset>
<div id="chosenFacets"></div>
- <div id="chosenFacetsHidden" class="invisible">'${it.chosenFacets?js_string}'</div>
+ <div id="chosenFacetsHidden" class="invisible" value='${it.chosenFacets?js_string}'/>
</fieldset>
</#if>
</div>
Propchange: incubator/stanbol/trunk/demos/crawler/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Mar 5 16:03:58 2012
@@ -0,0 +1,4 @@
+.settings
+.classpath
+.project
+target
Modified: incubator/stanbol/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/parent/pom.xml?rev=1297108&r1=1297107&r2=1297108&view=diff
==============================================================================
--- incubator/stanbol/trunk/parent/pom.xml (original)
+++ incubator/stanbol/trunk/parent/pom.xml Mon Mar 5 16:03:58 2012
@@ -761,11 +761,11 @@
<artifactId>org.apache.stanbol.contenthub.search.related</artifactId>
<version>0.9.0-incubating-SNAPSHOT</version>
</dependency>
- <dependency>
- <groupId>org.apache.stanbol</groupId>
- <artifactId>org.apache.stanbol.contenthub.crawler.cnn</artifactId>
- <version>0.9.0-incubating-SNAPSHOT</version>
- </dependency>
+<!-- <dependency> -->
+<!-- <groupId>org.apache.stanbol</groupId> -->
+<!-- <artifactId>org.apache.stanbol.contenthub.crawler.cnn</artifactId> -->
+<!-- <version>0.9.0-incubating-SNAPSHOT</version> -->
+<!-- </dependency> -->
<!-- JTidy -->
<!-- Contenthub CNN News Crawler needs to parse DOM -->
Modified: incubator/stanbol/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/pom.xml?rev=1297108&r1=1297107&r2=1297108&view=diff
==============================================================================
--- incubator/stanbol/trunk/pom.xml (original)
+++ incubator/stanbol/trunk/pom.xml Mon Mar 5 16:03:58 2012
@@ -73,8 +73,8 @@
<module>contenthub</module>
<module>entityhub</module>
<module>factstore</module>
-
- <module>ontologymanager/ontonet</module>
+
+ <module>ontologymanager/ontonet</module>
<module>ontologymanager/registry</module>
<module>ontologymanager/web</module>
<module>ontologymanager/bundlelist</module>