Revision: 14625
          http://gate.svn.sourceforge.net/gate/?rev=14625&view=rev
Author:   valyt
Date:     2011-12-01 15:49:33 +0000 (Thu, 01 Dec 2011)
Log Message:
-----------
Mimir indexing PR (copied over from 3.4 branch).

Modified Paths:
--------------
    mimir/trunk/mimir-client/build.xml

Added Paths:
-----------
    mimir/trunk/mimir-client/creole.xml.template
    mimir/trunk/mimir-client/src/gate/mimir/index/MimirIndexingPR.java

Modified: mimir/trunk/mimir-client/build.xml
===================================================================
--- mimir/trunk/mimir-client/build.xml  2011-12-01 15:49:00 UTC (rev 14624)
+++ mimir/trunk/mimir-client/build.xml  2011-12-01 15:49:33 UTC (rev 14625)
@@ -17,9 +17,11 @@
   <property name="src.dir" location="src" />
   <property name="doc.dir" location="doc" />
 
-       <property name="grails-plugin.dir" 
location="../${grails-plugin.dirname}" />
+  <property name="grails-plugin.dir" location="../${grails-plugin.dirname}" />
        
-  <property name="jar.file" location="${app.name}-${app.version}.jar" />
+  <property name="jar.name" value="${app.name}-${app.version}.jar" />
+  <property name="jar.file" location="${jar.name}" />  
+       
   <path id="compile.classpath">
     <path refid="libs" />
   </path>
@@ -45,6 +47,14 @@
     <jar file="${jar.file}" basedir="${classes.dir}" update="false"/>      
   </target>  
   
+  <target name="creole.xml">
+    <copy overwrite="true" file="creole.xml.template" tofile="creole.xml">
+      <filterset>
+        <filter token="jar" value="${jar.name}" />
+      </filterset>
+    </copy>
+  </target>
+       
   <target name="distro" depends="jar, javadoc" />
   
   <!-- Docs -->
@@ -71,7 +81,7 @@
     <delete dir="${doc.dir}/javadoc" />
   </target>
 
-  <target name="publish" depends="jar">
+  <target name="publish" depends="jar, creole.xml">
     <copy todir="${grails-plugin.dir}/lib" flatten="true">
       <fileset file="${jar.file}" />
     </copy>

Added: mimir/trunk/mimir-client/creole.xml.template
===================================================================
--- mimir/trunk/mimir-client/creole.xml.template                                
(rev 0)
+++ mimir/trunk/mimir-client/creole.xml.template        2011-12-01 15:49:33 UTC 
(rev 14625)
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<CREOLE-DIRECTORY>
+  <JAR scan="true">@jar@</JAR>
+</CREOLE-DIRECTORY>

Added: mimir/trunk/mimir-client/src/gate/mimir/index/MimirIndexingPR.java
===================================================================
--- mimir/trunk/mimir-client/src/gate/mimir/index/MimirIndexingPR.java          
                (rev 0)
+++ mimir/trunk/mimir-client/src/gate/mimir/index/MimirIndexingPR.java  
2011-12-01 15:49:33 UTC (rev 14625)
@@ -0,0 +1,103 @@
+/*
+ *  MimirIndexingPR.java
+ *
+ *  Copyright (c) 2007-2011, The University of Sheffield.
+ *
+ *  This file is part of GATE Mímir (see http://gate.ac.uk/family/mimir.html), 
+ *  and is free software, licenced under the GNU Lesser General Public License,
+ *  Version 3, June 2007 (also included with this distribution as file
+ *  LICENCE-LGPL3.html).
+ *
+ *  Valentin Tablan, 01 Dec 2011
+ *  
+ *  $Id$
+ */
+package gate.mimir.index;
+
+import java.io.IOException;
+import java.net.URL;
+
+import gate.Resource;
+import gate.creole.AbstractLanguageAnalyser;
+import gate.creole.ExecutionException;
+import gate.creole.ResourceInstantiationException;
+import gate.creole.metadata.CreoleParameter;
+import gate.creole.metadata.CreoleResource;
+import gate.creole.metadata.Optional;
+import gate.creole.metadata.RunTime;
+import gate.mimir.tool.WebUtils;
+
+
+/**
+ * A simple PR for sending documents to a Mímir index.
+ */
+@CreoleResource(comment="A PR that sends documents to a Mímir server for 
indexing.",
+ name="Mímir Indexing PR")
+public class MimirIndexingPR extends AbstractLanguageAnalyser {
+
+  private URL mimirIndexUrl;
+  
+  private String mimirUsername;
+  
+  private String mimirPassword;
+
+  protected MimirConnector mimirConnector;
+  
+  
+  
+  public URL getMimirIndexUrl() {
+    return mimirIndexUrl;
+  }
+
+  @CreoleParameter (comment="The Index URL, as obtained from the Mímir 
Server.")
+  @RunTime
+  public void setMimirIndexUrl(URL mimirIndexUrl) {
+    this.mimirIndexUrl = mimirIndexUrl;
+  }
+
+  public String getMimirUsername() {
+    return mimirUsername;
+  }
+
+  @CreoleParameter(comment="Username for authenticating to the Mímir server. 
Leave empty if no authentication is required.")
+  @Optional
+  public void setMimirUsername(String mimirUsername) {
+    this.mimirUsername = mimirUsername;
+  }
+
+  public String getMimirPassword() {
+    return mimirPassword;
+  }
+
+  @CreoleParameter(comment="Password for authenticating to the Mímir server. 
Leave empty if no authentication is required.")
+  @Optional
+  public void setMimirPassword(String mimirPassword) {
+    this.mimirPassword = mimirPassword;
+  }
+
+  @Override
+  public void cleanup() {
+    mimirConnector = null;
+  }
+
+  @Override
+  public Resource init() throws ResourceInstantiationException {
+    super.init();
+    WebUtils webUtils = null;
+    if(mimirUsername != null && mimirUsername.length() > 0) {
+      webUtils = new WebUtils(mimirUsername, mimirPassword);
+    }
+    mimirConnector = webUtils == null ? new MimirConnector() : new 
MimirConnector(webUtils);
+    return this;
+  }
+
+  @Override
+  public void execute() throws ExecutionException {
+    try {
+      mimirConnector.sendToMimir(getDocument(), null, mimirIndexUrl);
+    } catch(IOException e) {
+      throw new ExecutionException("Error communicating with the Mímir 
server", e);
+    }
+  }
+  
+}


Property changes on: 
mimir/trunk/mimir-client/src/gate/mimir/index/MimirIndexingPR.java
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to