package collections.ship.index;
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.StoredSortedMap;
public class SampleViews {
private StoredSortedMap partMap;
private StoredSortedMap supplierMap;
private StoredSortedMap shipmentMap;
private StoredSortedMap shipmentByPartMap;
private StoredSortedMap shipmentBySupplierMap;
private StoredSortedMap supplierByCityMap;
public SampleViews(SampleDatabase db) {
ClassCatalog catalog = db.getClassCatalog();
EntryBinding partKeyBinding =
new SerialBinding(catalog, PartKey.class);
EntryBinding partDataBinding =
new SerialBinding(catalog, PartData.class);
EntryBinding supplierKeyBinding =
new SerialBinding(catalog, SupplierKey.class);
EntryBinding supplierDataBinding =
new SerialBinding(catalog, SupplierData.class);
EntryBinding shipmentKeyBinding =
new SerialBinding(catalog, ShipmentKey.class);
EntryBinding shipmentDataBinding =
new SerialBinding(catalog, ShipmentData.class);
EntryBinding cityKeyBinding =
new SerialBinding(catalog, String.class);
partMap =
new StoredSortedMap(db.getPartDatabase(),
partKeyBinding, partDataBinding, true);
supplierMap =
new StoredSortedMap(db.getSupplierDatabase(),
supplierKeyBinding, supplierDataBinding, true);
shipmentMap =
new StoredSortedMap(db.getShipmentDatabase(),
shipmentKeyBinding, shipmentDataBinding, true);
shipmentByPartMap =
new StoredSortedMap(db.getShipmentByPartDatabase(),
partKeyBinding, shipmentDataBinding, true);
shipmentBySupplierMap =
new StoredSortedMap(db.getShipmentBySupplierDatabase(),
supplierKeyBinding, shipmentDataBinding, true);
supplierByCityMap =
new StoredSortedMap(db.getSupplierByCityDatabase(),
cityKeyBinding, supplierDataBinding, true);
}
public final StoredSortedMap getPartMap() {
return partMap;
}
public final StoredSortedMap getSupplierMap() {
return supplierMap;
}
public final StoredSortedMap getShipmentMap() {
return shipmentMap;
}
public final StoredEntrySet getPartEntrySet() {
return (StoredEntrySet) partMap.entrySet();
}
public final StoredEntrySet getSupplierEntrySet() {
return (StoredEntrySet) supplierMap.entrySet();
}
public final StoredEntrySet getShipmentEntrySet() {
return (StoredEntrySet) shipmentMap.entrySet();
}
public StoredSortedMap getShipmentByPartMap() {
return shipmentByPartMap;
}
public StoredSortedMap getShipmentBySupplierMap() {
return shipmentBySupplierMap;
}
public final StoredSortedMap getSupplierByCityMap() {
return supplierByCityMap;
}
}