Skip to content
Browse files

Initial checking. Allows searching for concepts by text search in the…

… Concept Wiki
  • Loading branch information...
1 parent bc83d6a commit 7a7ffbbf1d7543895131e612151532703e5ab0f5 @egonw committed Apr 24, 2012
View
3 README
@@ -0,0 +1,3 @@
+A Bioclipse plugin for interaction with Concept Wiki.
+
+License: EPL
View
17 features/net.bioclipse.conceptwiki_feature/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>net.bioclipse.conceptwiki_feature</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.pde.FeatureBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.FeatureNature</nature>
+ </natures>
+</projectDescription>
View
1 features/net.bioclipse.conceptwiki_feature/build.properties
@@ -0,0 +1 @@
+bin.includes = feature.xml
View
32 features/net.bioclipse.conceptwiki_feature/feature.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="net.bioclipse.conceptwiki_feature"
+ label="Bioclipse Concept Wiki Support"
+ version="2.5.0.qualifier"
+ provider-name="Bioclipse Team"
+ plugin="net.bioclipse.conceptwiki">
+
+ <license>
+ Eclipse Public License.
+ </license>
+
+ <requires>
+ <import feature="net.bioclipse.core_feature" version="2.4.0" match="greaterOrEqual"/>
+ <import feature="net.bioclipse.rdf_feature" version="2.4.0" match="greaterOrEqual"/>
+ </requires>
+
+ <plugin
+ id="net.bioclipse.conceptwiki"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.apache.commons.httpclient"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+</feature>
View
7 plugins/net.bioclipse.conceptwiki/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
View
28 plugins/net.bioclipse.conceptwiki/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>net.bioclipse.conceptwiki</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
View
19 plugins/net.bioclipse.conceptwiki/META-INF/MANIFEST.MF
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Concept Wiki API Support
+Bundle-SymbolicName: net.bioclipse.conceptwiki; singleton:=true
+Bundle-Version: 2.5.0.qualifier
+Bundle-Activator: net.bioclipse.conceptwiki.Activator
+Export-Package: net.bioclipse.conceptwiki, net.bioclipse.conceptwiki.business
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ net.bioclipse.core,
+ net.bioclipse.scripting,
+ org.springframework.bundle.spring.aop,
+ net.sf.cglib,
+ org.springframework.osgi.aopalliance.osgi,
+ org.apache.commons.httpclient,
+ net.bioclipse.rdf;bundle-version="2.5.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.apache.log4j
+Bundle-ActivationPolicy: lazy
View
68 plugins/net.bioclipse.conceptwiki/META-INF/spring/context.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:osgi="http://www.springframework.org/schema/osgi"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
+
+ <osgi:service id="javaConceptwikiManagerOSGI"
+ ref="javaConceptwikiManager"
+ interface="net.bioclipse.conceptwiki.business.IJavaConceptwikiManager" />
+
+ <osgi:service id="javaScriptConceptwikiManagerOSGI"
+ ref="javaScriptConceptwikiManager"
+ interface="net.bioclipse.conceptwiki.business.IJavaScriptConceptwikiManager" />
+
+ <osgi:reference id="recordingAdvice"
+ interface="net.bioclipse.recording.IRecordingAdvice" />
+
+ <osgi:reference id="javaManagerDispatcherAdvisor"
+ interface="net.bioclipse.managers.business.IJavaManagerDispatcherAdvisor" />
+
+ <osgi:reference id="javaScriptManagerDispatcherAdvisor"
+ interface="net.bioclipse.managers.business.IJavaScriptManagerDispatcherAdvisor" />
+
+ <osgi:reference id="wrapInProxyAdvice"
+ interface="net.bioclipse.recording.IWrapInProxyAdvice" />
+
+ <bean id="recordingAdvisor"
+ class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
+ <property name="advice" ref="recordingAdvice" />
+ <property name="pattern" value=".*" /> <!-- See also class implementation -->
+ </bean>
+
+ <bean id="ConceptwikiManagerTarget"
+ class="net.bioclipse.conceptwiki.business.ConceptwikiManager">
+ </bean>
+
+ <bean id="javaScriptConceptwikiManager"
+ class="org.springframework.aop.framework.ProxyFactoryBean">
+ <property name="target"
+ ref="ConceptwikiManagerTarget" />
+ <property name="proxyInterfaces"
+ value="net.bioclipse.conceptwiki.business.IJavaScriptConceptwikiManager" />
+ <property name="interceptorNames" >
+ <list>
+ <value>recordingAdvisor</value>
+ <value>wrapInProxyAdvice</value>
+ <value>javaScriptManagerDispatcherAdvisor</value>
+ </list>
+ </property>
+ </bean>
+
+ <bean id="javaConceptwikiManager"
+ class="org.springframework.aop.framework.ProxyFactoryBean">
+ <property name="target"
+ ref="ConceptwikiManagerTarget" />
+ <property name="proxyInterfaces"
+ value="net.bioclipse.conceptwiki.business.IJavaConceptwikiManager" />
+ <property name="interceptorNames" >
+ <list>
+ <value>recordingAdvisor</value>
+ <value>wrapInProxyAdvice</value>
+ <value>javaManagerDispatcherAdvisor</value>
+ </list>
+ </property>
+ </bean>
+</beans>
View
5 plugins/net.bioclipse.conceptwiki/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .
View
13 plugins/net.bioclipse.conceptwiki/plugin.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+ <extension
+ point="net.bioclipse.scripting.contribution">
+ <scriptContribution
+ service="net.bioclipse.conceptwiki.business.ConceptwikiManagerFactory"
+ id="net.bioclipse.conceptwiki.business.ConceptwikiManager">
+ </scriptContribution>
+ </extension>
+
+</plugin>
View
105 plugins/net.bioclipse.conceptwiki/src/net/bioclipse/conceptwiki/Activator.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Egon Willighagen <egonw@users.sf.net>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contact: http://www.bioclipse.net/
+ ******************************************************************************/
+package net.bioclipse.conceptwiki;
+
+import net.bioclipse.conceptwiki.business.IConceptwikiManager;
+import net.bioclipse.conceptwiki.business.IJavaConceptwikiManager;
+import net.bioclipse.conceptwiki.business.IJavaScriptConceptwikiManager;
+
+import org.apache.log4j.Logger;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * The Activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ private static final Logger logger = Logger.getLogger(Activator.class);
+
+ // The shared instance
+ private static Activator plugin;
+
+ // Trackers for getting the managers
+ private ServiceTracker javaFinderTracker;
+ private ServiceTracker jsFinderTracker;
+
+ public Activator() {
+ }
+
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ javaFinderTracker
+ = new ServiceTracker( context,
+ IJavaConceptwikiManager.class.getName(),
+ null );
+
+ javaFinderTracker.open();
+ jsFinderTracker
+ = new ServiceTracker( context,
+ IJavaScriptConceptwikiManager.class.getName(),
+ null );
+
+ jsFinderTracker.open();
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ public IConceptwikiManager getJavaConceptwikiManager() {
+ IConceptwikiManager manager = null;
+ try {
+ manager = (IConceptwikiManager)
+ javaFinderTracker.waitForService(1000*10);
+ }
+ catch (InterruptedException e) {
+ throw new IllegalStateException(
+ "Could not get the Java ConceptwikiManager",
+ e );
+ }
+ if (manager == null) {
+ throw new IllegalStateException(
+ "Could not get the Java ConceptwikiManager");
+ }
+ return manager;
+ }
+
+ public IJavaScriptConceptwikiManager getJavaScriptConceptwikiManager() {
+ IJavaScriptConceptwikiManager manager = null;
+ try {
+ manager = (IJavaScriptConceptwikiManager)
+ jsFinderTracker.waitForService(1000*10);
+ }
+ catch (InterruptedException e) {
+ throw new IllegalStateException(
+ "Could not get the JavaScript ConceptwikiManager",
+ e );
+ }
+ if (manager == null) {
+ throw new IllegalStateException(
+ "Could not get the JavaScript ConceptwikiManager");
+ }
+ return manager;
+ }
+}
View
69 .../net.bioclipse.conceptwiki/src/net/bioclipse/conceptwiki/business/ConceptwikiManager.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Egon Willighagen <egonw@users.sf.net>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contact: http://www.bioclipse.net/
+ ******************************************************************************/
+package net.bioclipse.conceptwiki.business;
+
+import java.net.URL;
+import java.net.URLEncoder;
+
+import net.bioclipse.core.business.BioclipseException;
+import net.bioclipse.core.domain.StringMatrix;
+import net.bioclipse.managers.business.IBioclipseManager;
+import net.bioclipse.rdf.business.IRDFStore;
+import net.bioclipse.rdf.business.RDFManager;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.log4j.Logger;
+
+public class ConceptwikiManager implements IBioclipseManager {
+
+ private static final Logger logger = Logger.getLogger(ConceptwikiManager.class);
+ private static final String QUERY_SEARCH_RESULTS =
+ "SELECT ?concept ?label {" +
+ " ?concept a <http://www.w3.org/2004/02/skos/core#Concept> ;" +
+ " <http://www.w3.org/2004/02/skos/core#prefLabel> ?label ." +
+ "}";
+
+ private static RDFManager rdf = new RDFManager();
+
+ /**
+ * Gives a short one word name of the manager used as variable name when
+ * scripting.
+ */
+ public String getManagerName() {
+ return "cw";
+ }
+
+ public StringMatrix search(String text) throws BioclipseException {
+ URL searchURL;
+ try {
+ searchURL = new URL(
+ "http://staging.conceptwiki.org/web-ws/concept/search/?q=" +
+ URLEncoder.encode(text, "UTF-8")
+ );
+ HttpClient client = new HttpClient();
+ GetMethod method = new GetMethod(searchURL.toString());
+ method.setRequestHeader("Accept", "text/turtle");
+ client.executeMethod(method);
+
+ String result = method.getResponseBodyAsString(); // without this things will fail??
+ System.out.println(result);
+ IRDFStore store = rdf.createInMemoryStore();
+ rdf.importFromStream(store, method.getResponseBodyAsStream(), "TURTLE", null);
+ method.releaseConnection();
+ StringMatrix matrix = rdf.sparql(store, QUERY_SEARCH_RESULTS);
+ method.releaseConnection();
+ return matrix;
+ } catch (Exception e) {
+ throw new BioclipseException("Error while searching the Concept Wiki: " + e.getMessage(), e);
+ }
+ }
+}
View
49 ...oclipse.conceptwiki/src/net/bioclipse/conceptwiki/business/ConceptwikiManagerFactory.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Egon Willighagen <egonw@users.sf.net>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contact: http://www.bioclipse.net/
+ ******************************************************************************/
+package net.bioclipse.conceptwiki.business;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.core.runtime.IExecutableExtensionFactory;
+
+import net.bioclipse.conceptwiki.Activator;
+
+/**
+ * Factory used for giving the manager to extension points.
+ *
+ * e.g. the extension point that is used for getting manager into the scripting
+ * environment.
+ *
+ * @author jonalv
+ */
+public class ConceptwikiManagerFactory
+ implements IExecutableExtension, IExecutableExtensionFactory {
+
+ private Object manager;
+
+ public void setInitializationData( IConfigurationElement config,
+ String propertyName,
+ Object data ) throws CoreException {
+
+ manager = Activator.getDefault().getJavaScriptConceptwikiManager();
+
+ if ( manager == null ) {
+ throw new IllegalStateException(
+ "Could not get the JavaScript flavoured " +
+ "ConceptwikiManager" );
+ }
+ }
+
+ public Object create() throws CoreException {
+ return manager;
+ }
+}
View
33 ...net.bioclipse.conceptwiki/src/net/bioclipse/conceptwiki/business/IConceptwikiManager.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Egon Willighagen <egonw@users.sf.net>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contact: http://www.bioclipse.net/
+ ******************************************************************************/
+package net.bioclipse.conceptwiki.business;
+
+import net.bioclipse.core.PublishedClass;
+import net.bioclipse.core.PublishedMethod;
+import net.bioclipse.core.Recorded;
+import net.bioclipse.core.business.BioclipseException;
+import net.bioclipse.core.domain.StringMatrix;
+import net.bioclipse.managers.business.IBioclipseManager;
+
+@PublishedClass(
+ value="Concept Wiki interaction."
+)
+public interface IConceptwikiManager extends IBioclipseManager {
+
+ @Recorded
+ @PublishedMethod(
+ methodSummary=
+ "Searches Concept Wiki for the given text.",
+ params="String text"
+ )
+ public StringMatrix search(String text) throws BioclipseException;
+
+}
View
15 ...bioclipse.conceptwiki/src/net/bioclipse/conceptwiki/business/IJavaConceptwikiManager.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Egon Willighagen <egonw@users.sf.net>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contact: Bioclipse Project <http://www.bioclipse.net>
+ ******************************************************************************/
+package net.bioclipse.conceptwiki.business;
+
+public interface IJavaConceptwikiManager extends IConceptwikiManager {
+
+}
View
18 ...pse.conceptwiki/src/net/bioclipse/conceptwiki/business/IJavaScriptConceptwikiManager.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Egon Willighagen <egonw@users.sf.net>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contact: Bioclipse Project <http://www.bioclipse.net>
+ ******************************************************************************/
+package net.bioclipse.conceptwiki.business;
+
+import net.bioclipse.managers.business.IBioclipseJSManager;
+
+public interface IJavaScriptConceptwikiManager
+ extends IConceptwikiManager, IBioclipseJSManager {
+
+}

0 comments on commit 7a7ffbb

Please sign in to comment.
Something went wrong with that request. Please try again.