First commit
authorymh <ymh.work@gmail.com>
Fri, 19 Mar 2010 18:35:15 +0100
changeset 0 586a7e03cbb4
child 1 25dda14508ec
First commit
.classpath
.hgignore
.project
.settings/.jsdtscope
.settings/org.eclipse.jdt.core.prefs
.settings/org.eclipse.wst.common.component
.settings/org.eclipse.wst.common.project.facet.core.xml
.settings/org.eclipse.wst.jsdt.ui.superType.container
.settings/org.eclipse.wst.jsdt.ui.superType.name
WebContent/META-INF/MANIFEST.MF
WebContent/WEB-INF/lib/Movies.jar
WebContent/WEB-INF/lib/asm-3.1.jar
WebContent/WEB-INF/lib/csltools.jar
WebContent/WEB-INF/lib/jackson-core-asl-1.1.1.jar
WebContent/WEB-INF/lib/je-4.0.92.jar
WebContent/WEB-INF/lib/jersey-bundle-1.1.5.1.jar
WebContent/WEB-INF/lib/jettison-1.1.jar
WebContent/WEB-INF/lib/jsr311-api-1.1.1.jar
WebContent/WEB-INF/lib/libsvm.jar
WebContent/WEB-INF/lib/weka.jar
WebContent/WEB-INF/web.xml
build/.keepme
script/deploy.xml
script/lib/catalina-ant.jar
src/HelloResource.java
src/fr/iri/thd/sonyengine/DataAccessor.java
src/fr/iri/thd/sonyengine/DbEnv.java
src/fr/iri/thd/sonyengine/EngineResource.java
src/fr/iri/thd/sonyengine/MovieFragment.java
src/fr/iri/thd/sonyengine/MovieFragmentResource.java
src/fr/iri/thd/sonyengine/ServletContainer.java
src/fr/iri/thd/sonyengine/Tag.java
src/fr/iri/thd/sonyengine/TagResource.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.classpath	Fri Mar 19 18:35:15 2010 +0100
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/JVM 1.6.0">
+		<attributes>
+			<attribute name="owner.project.facets" value="jst.java"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0">
+		<attributes>
+			<attribute name="owner.project.facets" value="jst.web"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
+	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
+	<classpathentry kind="output" path="build/classes"/>
+</classpath>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Fri Mar 19 18:35:15 2010 +0100
@@ -0,0 +1,3 @@
+syntax: glob
+
+build/classes/*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.project	Fri Mar 19 18:35:15 2010 +0100
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>mosatags.sonyengine</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.wst.common.project.facet.core.builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.wst.validation.validationbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+		<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+		<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+	</natures>
+</projectDescription>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.settings/.jsdtscope	Fri Mar 19 18:35:15 2010 +0100
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
+		<attributes>
+			<attribute name="hide" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+	<classpathentry kind="output" path=""/>
+</classpath>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.settings/org.eclipse.jdt.core.prefs	Fri Mar 19 18:35:15 2010 +0100
@@ -0,0 +1,7 @@
+#Fri Mar 12 19:26:32 CET 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.settings/org.eclipse.wst.common.component	Fri Mar 19 18:35:15 2010 +0100
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+<wb-module deploy-name="mosatags.sonyengine">
+<wb-resource deploy-path="/" source-path="/WebContent"/>
+<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
+<property name="context-root" value="mosatags.sonyengine"/>
+<property name="java-output-path" value="/mosatags.sonyengine/build/classes"/>
+</wb-module>
+</project-modules>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.settings/org.eclipse.wst.common.project.facet.core.xml	Fri Mar 19 18:35:15 2010 +0100
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+  <runtime name="Apache Tomcat v6.0"/>
+  <fixed facet="jst.java"/>
+  <fixed facet="jst.web"/>
+  <installed facet="jst.java" version="6.0"/>
+  <installed facet="jst.web" version="2.5"/>
+  <installed facet="wst.jsdt.web" version="1.0"/>
+</faceted-project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.settings/org.eclipse.wst.jsdt.ui.superType.container	Fri Mar 19 18:35:15 2010 +0100
@@ -0,0 +1,1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.settings/org.eclipse.wst.jsdt.ui.superType.name	Fri Mar 19 18:35:15 2010 +0100
@@ -0,0 +1,1 @@
+Window
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebContent/META-INF/MANIFEST.MF	Fri Mar 19 18:35:15 2010 +0100
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path: 
+
Binary file WebContent/WEB-INF/lib/Movies.jar has changed
Binary file WebContent/WEB-INF/lib/asm-3.1.jar has changed
Binary file WebContent/WEB-INF/lib/csltools.jar has changed
Binary file WebContent/WEB-INF/lib/jackson-core-asl-1.1.1.jar has changed
Binary file WebContent/WEB-INF/lib/je-4.0.92.jar has changed
Binary file WebContent/WEB-INF/lib/jersey-bundle-1.1.5.1.jar has changed
Binary file WebContent/WEB-INF/lib/jettison-1.1.jar has changed
Binary file WebContent/WEB-INF/lib/jsr311-api-1.1.1.jar has changed
Binary file WebContent/WEB-INF/lib/libsvm.jar has changed
Binary file WebContent/WEB-INF/lib/weka.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebContent/WEB-INF/web.xml	Fri Mar 19 18:35:15 2010 +0100
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
+  <display-name>mosatags.sonyengine</display-name>
+  <welcome-file-list>
+    <welcome-file>index.html</welcome-file>
+    <welcome-file>index.htm</welcome-file>
+    <welcome-file>index.jsp</welcome-file>
+    <welcome-file>default.html</welcome-file>
+    <welcome-file>default.htm</welcome-file>
+    <welcome-file>default.jsp</welcome-file>
+  </welcome-file-list>
+  <servlet>
+    <servlet-name>sonyengine</servlet-name>
+    <servlet-class>
+        fr.iri.thd.sonyengine.ServletContainer
+    </servlet-class>
+    <init-param>
+      <param-name>initDatabasePath</param-name>
+      <param-value>/tmp/db</param-value>
+    </init-param>
+    <load-on-startup>1</load-on-startup>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>sonyengine</servlet-name>
+    <url-pattern>/*</url-pattern>
+  </servlet-mapping>
+</web-app>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/script/deploy.xml	Fri Mar 19 18:35:15 2010 +0100
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ====================================================================== 
+     Mar 18, 2010 4:31:09 PM                                                        
+
+     project    
+     description
+                   
+     ymh                                                                
+     ====================================================================== -->
+<project name="project" default="default">
+    <description>
+            description
+    </description>
+
+	<!-- Configure the custom Ant tasks for the Manager application -->
+	  <taskdef name="deploy"    classname="org.apache.catalina.ant.DeployTask"/>
+	  <taskdef name="list"      classname="org.apache.catalina.ant.ListTask"/>
+	  <taskdef name="reload"    classname="org.apache.catalina.ant.ReloadTask"/>
+	  <taskdef name="resources" classname="org.apache.catalina.ant.ResourcesTask"/>
+	  <taskdef name="roles"     classname="org.apache.catalina.ant.RolesTask"/>
+	  <taskdef name="start"     classname="org.apache.catalina.ant.StartTask"/>
+	  <taskdef name="stop"      classname="org.apache.catalina.ant.StopTask"/>
+	  <taskdef name="undeploy"  classname="org.apache.catalina.ant.UndeployTask"/>
+	
+    <!-- ================================= 
+          target: default              
+         ================================= -->
+    <target name="default" depends="depends" description="description">
+    </target>
+
+    <!-- - - - - - - - - - - - - - - - - - 
+          target: depends                      
+         - - - - - - - - - - - - - - - - - -->
+    <target name="depends">
+    </target>
+
+</project>
Binary file script/lib/catalina-ant.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/HelloResource.java	Fri Mar 19 18:35:15 2010 +0100
@@ -0,0 +1,13 @@
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+@Path ("helloworld")
+public class HelloResource {
+
+	@GET
+	@Produces ("text/plain")
+	public String sayHello() {
+		return "Hello World";
+		}	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fr/iri/thd/sonyengine/DataAccessor.java	Fri Mar 19 18:35:15 2010 +0100
@@ -0,0 +1,26 @@
+package fr.iri.thd.sonyengine;
+
+import com.sleepycat.je.DatabaseException;
+import com.sleepycat.persist.EntityStore;
+import com.sleepycat.persist.PrimaryIndex;
+import com.sleepycat.persist.SecondaryIndex;
+
+public class DataAccessor {
+
+	public PrimaryIndex<String, MovieFragment> movieFragmentById;
+	
+	public PrimaryIndex<String, Tag> tagById;
+	public SecondaryIndex<String, String, Tag> tagByName;
+	public SecondaryIndex<String, String, Tag> tagBySegment;
+	
+	public DataAccessor(EntityStore store) throws DatabaseException {
+		
+		movieFragmentById = store.getPrimaryIndex(String.class, MovieFragment.class);
+		
+		tagById = store.getPrimaryIndex(String.class, Tag.class);
+		tagByName = store.getSecondaryIndex(tagById, String.class, "name");
+		tagBySegment = store.getSecondaryIndex(tagById, String.class, "segment");	
+		
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fr/iri/thd/sonyengine/DbEnv.java	Fri Mar 19 18:35:15 2010 +0100
@@ -0,0 +1,77 @@
+package fr.iri.thd.sonyengine;
+
+import java.io.File;
+
+import com.sleepycat.je.DatabaseException;
+import com.sleepycat.je.Environment;
+import com.sleepycat.je.EnvironmentConfig;
+import com.sleepycat.persist.EntityStore;
+import com.sleepycat.persist.StoreConfig;
+
+public class DbEnv {
+
+    private Environment env;
+    private EntityStore store;
+
+    // Our constructor does nothing
+    public DbEnv() {}
+
+    // The setup() method opens the environment and store
+    // for us.
+    public void setup(File envHome, boolean readOnly)
+        throws DatabaseException {
+
+        EnvironmentConfig myEnvConfig = new EnvironmentConfig();
+        StoreConfig storeConfig = new StoreConfig();
+
+        myEnvConfig.setReadOnly(readOnly);
+        storeConfig.setReadOnly(readOnly);
+
+        // If the environment is opened for write, then we want to be 
+        // able to create the environment and entity store if 
+        // they do not exist.
+        myEnvConfig.setAllowCreate(!readOnly);
+        storeConfig.setAllowCreate(!readOnly);
+
+        // Open the environment and entity store
+        env = new Environment(envHome, myEnvConfig);
+        store = new EntityStore(env, "EntityStore", storeConfig);
+
+    }
+
+    // Return a handle to the entity store
+    public EntityStore getEntityStore() {
+        return store;
+    }
+
+    // Return a handle to the environment
+    public Environment getEnv() {
+        return env;
+    }
+
+    // Close the store and environment.
+    public void close() {
+        if (store != null) {
+            try {
+                store.close();
+            } catch(DatabaseException dbe) {
+                System.err.println("Error closing store: " +
+                                    dbe.toString());
+                throw dbe;
+            }
+        }
+
+        if (env != null) {
+            try {
+                // Finally, close the environment.
+                env.close();
+            } catch(DatabaseException dbe) {
+            	System.err.println("Error closing DbEnv: " +
+                                    dbe.toString());
+            	throw dbe;
+            }
+        }
+    }
+	
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fr/iri/thd/sonyengine/EngineResource.java	Fri Mar 19 18:35:15 2010 +0100
@@ -0,0 +1,30 @@
+package fr.iri.thd.sonyengine;
+
+import javax.ws.rs.Path;
+import javax.ws.rs.POST;
+import javax.ws.rs.PathParam;
+
+import thd.ThdEngine;
+
+@Path ("engine")
+public class EngineResource {
+
+	@POST
+	@Path("train")
+    public String train() {    	
+
+		ThdEngine.getEngine().reTrain();    	
+    	return "ok\n";
+    }
+    
+	@POST
+	@Path("train/{id}")
+    public String train(@PathParam("id") String tagName) {    	
+
+		ThdEngine.getEngine().reTrain(tagName);
+    	return tagName + " : ok\n";
+    }
+
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fr/iri/thd/sonyengine/MovieFragment.java	Fri Mar 19 18:35:15 2010 +0100
@@ -0,0 +1,24 @@
+package fr.iri.thd.sonyengine;
+
+import com.sleepycat.persist.model.Entity;
+import com.sleepycat.persist.model.PrimaryKey;
+
+@Entity
+public class MovieFragment {
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	@PrimaryKey
+	private String id;
+
+	public MovieFragment(String id) {
+		this.id = id;
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fr/iri/thd/sonyengine/MovieFragmentResource.java	Fri Mar 19 18:35:15 2010 +0100
@@ -0,0 +1,19 @@
+package fr.iri.thd.sonyengine;
+
+import javax.ws.rs.Path;
+
+@Path ("segment")
+public class MovieFragmentResource {
+
+    public void create(String id) {
+    }
+
+    public void find(String id, String tag, Float separation, Boolean b) {
+    }
+
+
+    public void get(String id) {
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fr/iri/thd/sonyengine/ServletContainer.java	Fri Mar 19 18:35:15 2010 +0100
@@ -0,0 +1,36 @@
+package fr.iri.thd.sonyengine;
+
+import java.io.File;
+
+import javax.servlet.ServletException;
+import javax.ws.rs.core.Application;
+
+public class ServletContainer extends
+		com.sun.jersey.spi.container.servlet.ServletContainer {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -447765110849619632L;
+
+	public ServletContainer() {
+	}
+
+	public ServletContainer(Class<? extends Application> appClass) {
+		super(appClass);
+	}
+
+	public ServletContainer(Application app) {
+		super(app);
+	}
+
+
+	public void init() throws ServletException {
+		super.init();
+		
+		String databasePath = this.getInitParameter("initDatabasePath");
+		
+		DbEnv env = new DbEnv();
+		env.setup(new File(databasePath), true);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fr/iri/thd/sonyengine/Tag.java	Fri Mar 19 18:35:15 2010 +0100
@@ -0,0 +1,42 @@
+package fr.iri.thd.sonyengine;
+
+import java.util.UUID;
+
+import com.sleepycat.persist.model.Entity;
+import com.sleepycat.persist.model.PrimaryKey;
+import com.sleepycat.persist.model.Relationship;
+import com.sleepycat.persist.model.SecondaryKey;
+
+@Entity
+public class Tag {
+
+	@PrimaryKey
+	private String id = UUID.randomUUID().toString();
+	
+	@SecondaryKey(relate=Relationship.MANY_TO_ONE)
+	private String name;
+	
+	@SecondaryKey(relate=Relationship.MANY_TO_ONE, relatedEntity=MovieFragment.class)
+	private String segment;
+
+
+	public String getId() {
+		return id;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setSegment(String segment) {
+		this.segment = segment;
+	}
+
+	public String getSegment() {
+		return segment;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fr/iri/thd/sonyengine/TagResource.java	Fri Mar 19 18:35:15 2010 +0100
@@ -0,0 +1,13 @@
+package fr.iri.thd.sonyengine;
+
+import javax.ws.rs.Path;
+
+@Path ("tag")
+public class TagResource {
+
+    public void get(String id) {
+    }
+
+}
+
+