Author: glandais Date: 2008-01-22 14:11:10 +0000 (Tue, 22 Jan 2008) New Revision: 414 Added: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java Log: Added: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java =================================================================== --- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java (rev 0) +++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java 2008-01-22 14:11:10 UTC (rev 414) @@ -0,0 +1,189 @@ +package fr.cemagref.simexplorer.is.storage.engine; + +import java.io.InputStream; +import java.util.List; +import java.util.Map; + +import fr.cemagref.simexplorer.is.entities.metadata.MetaDataEntity; +import fr.cemagref.simexplorer.is.entities.metadata.Version; + +public interface StorageEngine { + + /** + * Open storage + * + * @throws Exception + */ + public abstract void open() throws Exception; + + /** + * Close storage + * + * @throws Exception + */ + public abstract void close() throws Exception; + + /** + * Commit changes to storage + * + * @throws Exception + */ + public abstract void commit() throws Exception; + + /** + * Save an element to storage + * + * @param element + * Element to save + * @param attachments + * Attachments related + * @throws Exception + */ + public abstract void saveElement(MetaDataEntity element, + Map<String, InputStream> attachments) throws Exception; + + /** + * Retrieve an element + * + * @param uuid + * Id of the element + * @return The element + * @throws Exception + */ + public abstract MetaDataEntity getMetadata(String uuid) throws Exception; + + /** + * Retrieve versions of an element<br> + * Empty list if no element with this id + * + * @param uuid + * Id of the element + * @return List of versions of the element<br> + * + * @throws Exception + */ + public abstract List<Version> getVersions(String uuid) throws Exception; + + /** + * Retrieve an element in a specific version + * + * @param uuid + * @param version + * @return + * @throws Exception + */ + public abstract MetaDataEntity getMetadata(String uuid, Version version) + throws Exception; + + /** + * Get data associated to an element + * + * @param entity + * Element related + * @param field + * Data field + * @return Data stream + * @throws Exception + */ + public abstract InputStream retrieveData(MetaDataEntity entity, String field) + throws Exception; + + /** + * Get number of items corresponding to query + * + * @param query + * @param onlyLatest + * @return + * @throws Exception + */ + public abstract int findFullTextCount(String query, boolean onlyLatest) + throws Exception; + + /** + * Retrieve list of items corresponding to query + * + * @param query + * @param onlyLatest + * @param indexStart + * @param count + * @param dateOrder + * @return + * @throws Exception + */ + public abstract MetaDataEntity[] findFullText(String query, + boolean onlyLatest, int indexStart, int count, int dateOrder) + throws Exception; + + /** + * Retrieve list of items of type wanted + * + * @param type + * @param onlyLatest + * @param start + * @param count + * @param dateOrder + * @return + * @throws Exception + */ + public abstract MetaDataEntity[] findElementsByType(String type, + boolean onlyLatest, int start, int count, int dateOrder) + throws Exception; + + /** + * Retrieve number of items of type wanted + * + * @param type + * @param onlyLatest + * @return + * @throws Exception + */ + public abstract int findElementsByTypeCount(String type, boolean onlyLatest) + throws Exception; + + /** + * Delete elements + * + * @param uuid + * @throws Exception + */ + public abstract void deleteElements(String uuid) throws Exception; + + /** + * Delete one element + * + * @param uuid + * @param version + * @throws Exception + */ + public abstract void deleteElement(String uuid, Version version) + throws Exception; + + /** + * Store temporary data, for stream duplication + * + * @param stream + * Stream to store + * @return id for retrieval + * @throws Exception + */ + public abstract String storeTempData(InputStream stream) throws Exception; + + /** + * Retrieve temporary data + * + * @param id + * Id associated + * @return Data stream + * @throws Exception + */ + public abstract InputStream retrieveTempData(String id) throws Exception; + + /** + * Delete temporary data + * + * @param id + * @throws Exception + */ + public abstract void deleteTempData(String id) throws Exception; + +} \ No newline at end of file