Rev 2768 | Blame | Compare with Previous | Last modification | View Log | RSS feed
package in.shop2020.storage.bdb;import in.shop2020.metamodel.core.SpecialPage;import in.shop2020.metamodel.core.Entity;import in.shop2020.metamodel.core.EntityState;import in.shop2020.metamodel.core.Helpdoc;import com.sleepycat.bind.EntryBinding;import com.sleepycat.bind.serial.ClassCatalog;import com.sleepycat.bind.serial.SerialBinding;import com.sleepycat.collections.StoredEntrySet;import com.sleepycat.collections.StoredMap;public class ContentViews {private StoredMap entityMap;private StoredMap entityMetadataMap;private StoredMap helpdocMap;private StoredMap<Long, SpecialPage> specialPagesMap;private StoredMap dataObjectMap;private StoredMap definitionMap;private StoredMap entityByCategoryMap;/*** Create the data bindings and collection views.*/public ContentViews(ContentDatabase db) {// In this sample, the stored key and data entries are used directly// rather than mapping them to separate objects. Therefore, no binding// classes are defined here and the SerialBinding class is used.//ClassCatalog catalog = db.getClassCatalog();EntryBinding entityKeyBinding = new SerialBinding(catalog, Long.class);EntryBinding entityDataBinding = new SerialBinding(catalog, Entity.class);EntryBinding entityMetadataKeyBinding = new SerialBinding(catalog, Long.class);EntryBinding entityMetadataDataBinding = new SerialBinding(catalog, EntityState.class);EntryBinding helpdocKeyBinding = new SerialBinding(catalog, Long.class);EntryBinding helpdocDataBinding = new SerialBinding(catalog, Helpdoc.class);EntryBinding<Long> specialPageKeyBinding = new SerialBinding<Long>(catalog, Long.class);EntryBinding<SpecialPage> specialPageDataBinding = new SerialBinding<SpecialPage>(catalog, SpecialPage.class);EntryBinding commonKeyBinding = new SerialBinding(catalog, String.class);EntryBinding commonDataBinding = new SerialBinding(catalog, Object.class);EntryBinding definitionKeyBinding = new SerialBinding(catalog, String.class);EntryBinding definitionDataBinding = new SerialBinding(catalog, Object.class);EntryBinding entityByCategoryKeyBinding = new SerialBinding(catalog, Long.class);// Create map views for all stores and indices.// StoredSortedMap is not used since the stores and indices are// ordered by serialized key objects, which do not provide a very// useful ordering.//entityMap = new StoredMap(db.getEntityDatabase(),entityKeyBinding, entityDataBinding, true);entityMetadataMap = new StoredMap(db.getEntityMetadataDatabase(),entityMetadataKeyBinding, entityMetadataDataBinding, true);helpdocMap = new StoredMap(db.getHelpdocDatabase(), helpdocKeyBinding, helpdocDataBinding, true);specialPagesMap = new StoredMap<Long, SpecialPage>(db.getSpecialPageDatabase(), specialPageKeyBinding, specialPageDataBinding, true);dataObjectMap = new StoredMap(db.getDataObjectDatabase(), commonKeyBinding, commonDataBinding, true);definitionMap = new StoredMap(db.getDefinitionDatabase(), definitionKeyBinding, definitionDataBinding, true);entityByCategoryMap = new StoredMap(db.getCategoryByCategoryDatabase(), entityByCategoryKeyBinding, entityDataBinding, true);}// The views returned below can be accessed using the java.util.Map or// java.util.Set interfaces, or using the StoredMap and StoredEntrySet// classes, which provide additional methods. The entry sets could be// obtained directly from the Map.entrySet() method, but convenience// methods are provided here to return them in order to avoid down-casting// elsewhere./*** Return a map view of the entity storage container.*/public final StoredMap getEntityMap() {return entityMap;}/**** @return a map view of the entities by category storage container.*/public final StoredMap getEntityByCategoryMap() {return entityByCategoryMap;}/*** Return a map view of the entity metadata storage container.*/public final StoredMap getEntityMetadataMap() {return entityMetadataMap;}/*** Return a map view of the helpdoc storage container.*/public final StoredMap getHelpdocMap() {return helpdocMap;}/*** Return a map view of the special page storage container.*/public final StoredMap<Long, SpecialPage> getSpecialPagesMap() {return specialPagesMap;}/*** Return a map view of the definition storage container.*/public final StoredMap getDefinitionMap() {return definitionMap;}/*** Return a map view of the object storage container.*/public final StoredMap getDataObjectMap() {return dataObjectMap;}/*** Return an entry set view of the entity storage container.*/public final StoredEntrySet getEntityEntrySet() {return (StoredEntrySet) entityMap.entrySet();}/*** Return an entry set view of the entity metadata storage container.*/public final StoredEntrySet getEntityMetaDataEntrySet() {return (StoredEntrySet) entityMetadataMap.entrySet();}/*** Return an entry set view of the helpdoc storage container.*/public final StoredEntrySet getHelpdocEntrySet() {return (StoredEntrySet) helpdocMap.entrySet();}/*** Return an entry set view of the definitions storage container.*/public final StoredEntrySet getDefinitionEntrySet() {return (StoredEntrySet) definitionMap.entrySet();}/*** Return an entry set view of the object storage container.*/public final StoredEntrySet getDataObjectEntrySet() {return (StoredEntrySet) dataObjectMap.entrySet();}}