Author: glandais Date: 2007-12-24 11:54:23 +0000 (Mon, 24 Dec 2007) New Revision: 82 Modified: trunk/simexplorer-si-storage/.classpath trunk/simexplorer-si-storage/.project trunk/simexplorer-si-storage/.settings/org.eclipse.jdt.core.prefs trunk/simexplorer-si-storage/pom.xml trunk/simexplorer-si-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java trunk/simexplorer-si-storage/src/java/fr/cemagref/simexplorer/is/storage/factories/XmlConstants.java trunk/simexplorer-si-storage/src/java/fr/cemagref/simexplorer/is/storage/service/StorageService.java trunk/simexplorer-si-storage/src/java/fr/cemagref/simexplorer/is/storage/service/StorageServiceImpl.java trunk/simexplorer-si-storage/src/test/fr/cemagref/simexplorer/is/storage/test/service/StorageServiceTest.java Log: MAJ service Modified: trunk/simexplorer-si-storage/.classpath =================================================================== --- trunk/simexplorer-si-storage/.classpath 2007-12-20 18:42:03 UTC (rev 81) +++ trunk/simexplorer-si-storage/.classpath 2007-12-24 11:54:23 UTC (rev 82) @@ -2,9 +2,10 @@ <classpath> <classpathentry kind="src" path="src/java"/> <classpathentry kind="src" path="src/test"/> + <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.jboss.ide.eclipse.as.core.server.runtime.runtimeTarget/JBoss v4.2"/> + <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/> + <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.generic.runtimeTarget/JBoss v4.2"/> - <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/> - <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> <classpathentry kind="output" path="target/classes"/> </classpath> Modified: trunk/simexplorer-si-storage/.project =================================================================== --- trunk/simexplorer-si-storage/.project 2007-12-20 18:42:03 UTC (rev 81) +++ trunk/simexplorer-si-storage/.project 2007-12-24 11:54:23 UTC (rev 82) @@ -25,12 +25,18 @@ <arguments> </arguments> </buildCommand> + <buildCommand> + <name>org.devzuz.q.maven.jdt.core.mavenIncrementalBuilder</name> + <arguments> + </arguments> + </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> <nature>org.maven.ide.eclipse.maven2Nature</nature> - <nature>org.eclipse.wst.common.project.facet.core.nature</nature> + <nature>org.devzuz.q.maven.jdt.core.mavenNature</nature> <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature> <nature>org.eclipse.jem.workbench.JavaEMFNature</nature> + <nature>org.eclipse.wst.common.project.facet.core.nature</nature> </natures> </projectDescription> Modified: trunk/simexplorer-si-storage/.settings/org.eclipse.jdt.core.prefs =================================================================== --- trunk/simexplorer-si-storage/.settings/org.eclipse.jdt.core.prefs 2007-12-20 18:42:03 UTC (rev 81) +++ trunk/simexplorer-si-storage/.settings/org.eclipse.jdt.core.prefs 2007-12-24 11:54:23 UTC (rev 82) @@ -1,4 +1,4 @@ -#Wed Dec 19 15:38:25 CET 2007 +#Fri Dec 21 11:44:03 CET 2007 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 org.eclipse.jdt.core.compiler.compliance=1.5 Modified: trunk/simexplorer-si-storage/pom.xml =================================================================== --- trunk/simexplorer-si-storage/pom.xml 2007-12-20 18:42:03 UTC (rev 81) +++ trunk/simexplorer-si-storage/pom.xml 2007-12-24 11:54:23 UTC (rev 82) @@ -1,15 +1,46 @@ <?xml version="1.0" encoding="UTF-8"?> -<project> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <parent> <artifactId>lutinproject</artifactId> <groupId>lutinlib</groupId> <version>2.2</version> </parent> + <modelVersion>4.0.0</modelVersion> <groupId>simexplorer-is-storage</groupId> <artifactId>simexplorer-is-storage</artifactId> <version>0.0.1-SNAPSHOT</version> <description></description> + + <profiles> + <profile> + <id>project</id> + + <activation> + <activeByDefault>true</activeByDefault> + </activation> + + <properties> + <!--Source base dir--> + <maven.src.dir> + ${basedir}/target/src-build + </maven.src.dir> + + <!--Test--> + <maven.test.skip>true</maven.test.skip> + + <!--Compile with ?--> + <maven.compile.source>1.5</maven.compile.source> + <maven.compile.target>1.5</maven.compile.target> + + <!--Verbose--> + <maven.verbose>false</maven.verbose> + </properties> + </profile> + </profiles> + <dependencies> <dependency> <groupId>com.healthmarketscience.rmiio</groupId> @@ -17,9 +48,9 @@ <version>2.0.0</version> </dependency> <dependency> - <groupId>lucene</groupId> + <groupId>org.apache.lucene</groupId> <artifactId>lucene-core</artifactId> - <version>2.0.0</version> + <version>2.2.0</version> </dependency> <dependency> <groupId>junit</groupId> @@ -35,11 +66,4 @@ <reporting> <outputDirectory>target/site</outputDirectory> </reporting> - <properties> - <maven.test.skip>true</maven.test.skip> - <maven.compile.source>1.5</maven.compile.source> - <maven.compile.target>1.5</maven.compile.target> - <maven.verbose>false</maven.verbose> - <maven.src.dir>${basedir}/target/src-build</maven.src.dir> - </properties> </project> \ No newline at end of file Modified: trunk/simexplorer-si-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java =================================================================== --- trunk/simexplorer-si-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java 2007-12-20 18:42:03 UTC (rev 81) +++ trunk/simexplorer-si-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java 2007-12-24 11:54:23 UTC (rev 82) @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.UUID; import fr.cemagref.simexplorer.is.storage.attachment.Content; @@ -129,7 +130,7 @@ * @return The element * @throws Exception */ - public MetaDataEntity getElement(String uuid) throws Exception { + public MetaDataEntity getMetadata(String uuid) throws Exception { MetaDataEntity mde = database.getElementLatestVersion(uuid); return mde; } @@ -156,7 +157,7 @@ * @return * @throws Exception */ - public MetaDataEntity getElementVersion(String uuid, Version version) + public MetaDataEntity getMetadata(String uuid, Version version) throws Exception { MetaDataEntity mde = database.getElement(uuid, version); return mde; @@ -168,6 +169,23 @@ return result; } + public int findFullTextCount(String query) throws Exception { + return database.findElementsByContentSearchCount(query); + } + + public MetaDataEntity[] findFullText(String query) throws Exception { + MetaDataEntity[] result = database.findElementsByContentSearch(query) + .toArray(new MetaDataEntity[0]); + return result; + } + + public MetaDataEntity[] findFullText(String query, int indexStart, int count) + throws Exception { + MetaDataEntity[] result = database.findElementsByContentSearch(query, + indexStart, count).toArray(new MetaDataEntity[0]); + return result; + } + // Delete public void deleteElements(String uuid) throws Exception { @@ -178,7 +196,7 @@ } public void deleteElement(String uuid, Version version) throws Exception { - MetaDataEntity element = getElementVersion(uuid, version); + MetaDataEntity element = getMetadata(uuid, version); Map<String, Content> attachments = element.getAttachments(); for (Map.Entry<String, Content> entry : attachments.entrySet()) { attachmentHandler.deleteData(element, entry.getKey()); @@ -203,8 +221,4 @@ attachmentHandler.deleteData(mdTmp, id); } - public int findCount(String query) throws Exception { - return database.findElementsByContentSearchCount(query); - } - } Modified: trunk/simexplorer-si-storage/src/java/fr/cemagref/simexplorer/is/storage/factories/XmlConstants.java =================================================================== --- trunk/simexplorer-si-storage/src/java/fr/cemagref/simexplorer/is/storage/factories/XmlConstants.java 2007-12-20 18:42:03 UTC (rev 81) +++ trunk/simexplorer-si-storage/src/java/fr/cemagref/simexplorer/is/storage/factories/XmlConstants.java 2007-12-24 11:54:23 UTC (rev 82) @@ -5,7 +5,10 @@ public static final String KEY_METADATA_UUID = "uuid"; public static final String KEY_METADATA_VERSION = "version"; public static final String KEY_METADATA_NAME = "name"; + public static final String KEY_METADATA_TYPE = "type"; + public static final String KEY_METADATA_TYPE_VALUE_EA = "EA"; + public static final String KEY_METADATA_DESCRIPTION = "description"; public static final String KEY_METADATA_CREATIONDATE = "creationdate"; public static final String KEY_METADATA_HASH = "hash"; @@ -24,4 +27,12 @@ public static final String KEY_ATTACHMENT_NAME = "name"; public static final String KEY_ATTACHMENT_TYPE = "type"; + public static final String KEY_COMPONENT = "C"; + public static final String KEY_ED = "ED"; + public static final String KEY_RESULT = "R"; + public static final String KEY_FILE = "FILE"; + + public static final String FILE_XML = "data.xml"; + public static final String FILE_DATA_PREFIX = "attachment"; + } Modified: trunk/simexplorer-si-storage/src/java/fr/cemagref/simexplorer/is/storage/service/StorageService.java =================================================================== --- trunk/simexplorer-si-storage/src/java/fr/cemagref/simexplorer/is/storage/service/StorageService.java 2007-12-20 18:42:03 UTC (rev 81) +++ trunk/simexplorer-si-storage/src/java/fr/cemagref/simexplorer/is/storage/service/StorageService.java 2007-12-24 11:54:23 UTC (rev 82) @@ -1,6 +1,5 @@ package fr.cemagref.simexplorer.is.storage.service; -import java.util.List; import java.util.Map; import javax.ejb.Remote; @@ -30,6 +29,11 @@ public MetaDataEntity getMetadata(String uuid, String version) throws Exception; - public int findCount(String query) throws Exception; + public int findFullTextCount(String query) throws Exception; + public MetaDataEntity[] findFullText(String query) throws Exception; + + public MetaDataEntity[] findFullText(String query, int indexStart, int count) + throws Exception; + } Modified: trunk/simexplorer-si-storage/src/java/fr/cemagref/simexplorer/is/storage/service/StorageServiceImpl.java =================================================================== --- trunk/simexplorer-si-storage/src/java/fr/cemagref/simexplorer/is/storage/service/StorageServiceImpl.java 2007-12-20 18:42:03 UTC (rev 81) +++ trunk/simexplorer-si-storage/src/java/fr/cemagref/simexplorer/is/storage/service/StorageServiceImpl.java 2007-12-24 11:54:23 UTC (rev 82) @@ -24,29 +24,19 @@ import fr.cemagref.simexplorer.is.storage.entities.metadata.Version; import fr.cemagref.simexplorer.is.storage.factories.BaseEntityFactory; import fr.cemagref.simexplorer.is.storage.factories.MetaDataEntityFactory; +import fr.cemagref.simexplorer.is.storage.factories.XmlConstants; import fr.cemagref.simexplorer.is.storage.xml.MetaDataParser; import fr.cemagref.simexplorer.is.storage.xml.Parser; @Stateless(name = "StorageService") @Remote(StorageService.class) @RemoteBinding(jndiBinding = "/ejb3/StorageService") -public class StorageServiceImpl implements StorageService { +public class StorageServiceImpl implements StorageService, XmlConstants { private StorageEngine storageEngine; - // FIXME centralized - private static String KEY_METADATA = "metadata"; - private static String KEY_XML = "xml"; - // private static String KEY_ATTACHMENT = "attachment"; - private static String KEY_TYPE_EA = "EA"; - private static String KEY_COMPONENT = "C"; - private static String KEY_ED = "ED"; - private static String KEY_RESULT = "R"; - private static String KEY_FILE = "FILE"; + private static final String KEY_XML = "_xml"; - private static String FILE_XML = "data.xml"; - private static String FILE_DATA_PREFIX = "attachment"; - public StorageServiceImpl() { super(); storageEngine = new StorageEngine(); @@ -84,18 +74,27 @@ } public MetaDataEntity getMetadata(String uuid) throws Exception { - return storageEngine.getElement(uuid); + return storageEngine.getMetadata(uuid); } public MetaDataEntity getMetadata(String uuid, String version) throws Exception { - return storageEngine.getElementVersion(uuid, new Version(version)); + return storageEngine.getMetadata(uuid, new Version(version)); } - public int findCount(String query) throws Exception { - return storageEngine.findCount(query); + public MetaDataEntity[] findFullText(String query) throws Exception { + return storageEngine.findFullText(query); } + public MetaDataEntity[] findFullText(String query, int indexStart, int count) + throws Exception { + return storageEngine.findFullText(query, indexStart, count); + } + + public int findFullTextCount(String query) throws Exception { + return storageEngine.findFullTextCount(query); + } + private MetaDataEntity saveElement(InputStream zipStream) throws Exception { String xmlFile = null; Map<String, String> attachments = new HashMap<String, String>(); @@ -153,7 +152,7 @@ // If element is an EA, save inner Components and Data if (metaData.getType() != null - && metaData.getType().equals(KEY_TYPE_EA)) { + && metaData.getType().equals(KEY_METADATA_TYPE_VALUE_EA)) { List<String> components = new ArrayList<String>(); List<String[]> explorationDatas = new ArrayList<String[]>(); @@ -188,7 +187,7 @@ } // Check existing version in storage - MetaDataEntity previousVersion = storageEngine.getElementVersion(uuid, + MetaDataEntity previousVersion = storageEngine.getMetadata(uuid, metaData.getVersion()); /* * MetaDataEntity parentData = storageEngine.getElementVersion(metaData Modified: trunk/simexplorer-si-storage/src/test/fr/cemagref/simexplorer/is/storage/test/service/StorageServiceTest.java =================================================================== --- trunk/simexplorer-si-storage/src/test/fr/cemagref/simexplorer/is/storage/test/service/StorageServiceTest.java 2007-12-20 18:42:03 UTC (rev 81) +++ trunk/simexplorer-si-storage/src/test/fr/cemagref/simexplorer/is/storage/test/service/StorageServiceTest.java 2007-12-24 11:54:23 UTC (rev 82) @@ -119,7 +119,7 @@ storageService.commit(); assertNotNull(storageService.getMetadata(id)); for (int i = 0; i < randomcontent.length; i++) { - assertTrue(storageService.findCount(randomcontent[i]) > 0); + assertTrue(storageService.findFullTextCount(randomcontent[i]) > 0); } }