package com.sleepycat.examples.bdb.shipment.index;
import com.sleepycat.bdb.bind.DataBinding;
import com.sleepycat.bdb.bind.serial.SerialBinding;
import com.sleepycat.bdb.collection.StoredEntrySet;
import com.sleepycat.bdb.collection.StoredMap;
public class SampleViews {
private StoredMap partMap;
private StoredMap supplierMap;
private StoredMap shipmentMap;
private StoredMap shipmentByPartMap;
private StoredMap shipmentBySupplierMap;
private StoredMap supplierByCityMap;
public SampleViews(SampleDatabase db) {
DataBinding partKeyBinding =
new SerialBinding(db.getPartKeyFormat());
DataBinding partValueBinding =
new SerialBinding(db.getPartValueFormat());
DataBinding supplierKeyBinding =
new SerialBinding(db.getSupplierKeyFormat());
DataBinding supplierValueBinding =
new SerialBinding(db.getSupplierValueFormat());
DataBinding shipmentKeyBinding =
new SerialBinding(db.getShipmentKeyFormat());
DataBinding shipmentValueBinding =
new SerialBinding(db.getShipmentValueFormat());
DataBinding cityKeyBinding =
new SerialBinding(db.getCityKeyFormat());
partMap =
new StoredMap(db.getPartStore(),
partKeyBinding, partValueBinding, true);
supplierMap =
new StoredMap(db.getSupplierStore(),
supplierKeyBinding, supplierValueBinding, true);
shipmentMap =
new StoredMap(db.getShipmentStore(),
shipmentKeyBinding, shipmentValueBinding, true);
shipmentByPartMap =
new StoredMap(db.getShipmentByPartIndex(),
partKeyBinding, shipmentValueBinding, true);
shipmentBySupplierMap =
new StoredMap(db.getShipmentBySupplierIndex(),
supplierKeyBinding, shipmentValueBinding, true);
supplierByCityMap =
new StoredMap(db.getSupplierByCityIndex(),
cityKeyBinding, supplierValueBinding, true);
}
public final StoredMap getPartMap() {
return partMap;
}
public final StoredMap getSupplierMap() {
return supplierMap;
}
public final StoredMap 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 final StoredMap getShipmentByPartMap() {
return shipmentByPartMap;
}
public final StoredMap getShipmentBySupplierMap() {
return shipmentBySupplierMap;
}
public final StoredMap getSupplierByCityMap() {
return supplierByCityMap;
}
public final StoredEntrySet getShipmentByPartEntrySet() {
return (StoredEntrySet) shipmentByPartMap.entrySet();
}
public final StoredEntrySet getShipmentBySupplierEntrySet() {
return (StoredEntrySet) shipmentBySupplierMap.entrySet();
}
public final StoredEntrySet getSupplierByCityEntrySet() {
return (StoredEntrySet) supplierByCityMap.entrySet();
}
}