import freemarker.template.*;
import mir.misc.*;
+import mir.storage.*;
import mir.storage.store.*;
+
/**
*
* Container class for lists of Entities.
private static Logfile theLog;
private ArrayList theEntityArrayList = new ArrayList();
private String whereClause, orderClause;
- private Class theEntityClass;
+ private StorageObject theStorage;
private int count, offset, limit;
private int offsetnext = -1, offsetprev = -1;
private int freemarkerListPointer=-1;
public EntityList(){ }
/* get/set EntityClass of Objects stored in EntityList */
- public void setEntityClass(Class theEntityClass) { this.theEntityClass=theEntityClass; }
- public Class getEntityClass() { return theEntityClass; }
+ public void setStorage(StorageObject storage) { this.theStorage=storage; }
+ public StorageObject getStorage() { return theStorage; }
public void setLimit(int limit) { this.limit = limit; }
public Set getNotifyOnReleaseSet() { return null; }
public StoreIdentifier getStoreIdentifier() {
- if ( theEntityClass!=null ) {
+ if ( theStorage!=null ) {
return
new StoreIdentifier( this, StoreContainerType.STOC_TYPE_ENTITYLIST,
- StoreUtil.getEntityListUniqueIdentifierFor( whereClause, orderClause, offset, limit ));
+ StoreUtil.getEntityListUniqueIdentifierFor( theStorage.getTableName(),
+ whereClause, orderClause, offset, limit ));
}
theLog.printWarning("EntityList could not return StoreIdentifier");
return null;
// always same object saves a little space
POPUP_EMTYLINE.put("key", ""); POPUP_EMTYLINE.put("value", "--");
try {
- GENERIC_ENTITY_CLASS = Class.forName("mir.entity.GenericEntity");
+ GENERIC_ENTITY_CLASS = Class.forName("mir.entity.StorableObjectEntity");
STORABLE_OBJECT_ENTITY_CLASS = Class.forName("mir.entity.StorableObjectEntity");
}
catch (Exception e) {
StoreIdentifier search_sid =
new StoreIdentifier( theEntityClass,
StoreContainerType.STOC_TYPE_ENTITYLIST,
- StoreUtil.getEntityListUniqueIdentifierFor(wc,ob,offset,limit) );
+ StoreUtil.getEntityListUniqueIdentifierFor(theTable,wc,ob,offset,limit) );
EntityList hit = (EntityList)o_store.use(search_sid);
if ( hit!=null ) {
theLog.printDebugInfo("CACHE (hit): " + search_sid.toString());
theReturnList.setOffset(offset);
theReturnList.setWhere(wc);
theReturnList.setOrder(ob);
- theReturnList.setEntityClass(theEntityClass);
+ theReturnList.setStorage(this);
theReturnList.setLimit(limit);
if ( offset >= limit )
theReturnList.setPrevBatch(offset - limit);
* @return der Wert des Primary-keys der eingefügten Entity
*/
public String insert (Entity theEntity) throws StorageObjectException {
- String returnId = null;
- Connection con = null;
- PreparedStatement pstmt = null;
//cache
invalidatePopupCache();
- /** @todo OS: if Entity is StorableObject, invalidate in ObjectStore
- * careful: Entity has no id yet! */
- try {
+
+ // invalidating all EntityLists corresponding with theEntityClass
+ if ( StoreUtil.implementsStorableObject(theEntityClass) ) {
+ StoreContainerType stoc_type =
+ StoreContainerType.valueOf( theEntityClass,
+ StoreContainerType.STOC_TYPE_ENTITYLIST);
+ o_store.invalidate(stoc_type);
+ }
+
+ String returnId = null;
+ Connection con = null; PreparedStatement pstmt = null;
+
+ try {
ArrayList streamedInput = theEntity.streamedInput();
StringBuffer f = new StringBuffer();
StringBuffer v = new StringBuffer();
}
freeConnection(con, pstmt);
}
+ /** @todo store entity in o_store */
return returnId;
}
* have a primary key in the entity. i don't know if we
* still need the streamed input fields. // rk */
- /** @todo extension: check if Entity did change, otherwise we don't need */
- /** @todo OS: invalidate in Ostore if Entity is StorableObject */
+ /** @todo extension: check if Entity did change, otherwise we don't need
+ * the roundtrip to the database */
+
+ /** invalidating corresponding entitylists in o_store*/
+ if ( StoreUtil.implementsStorableObject(theEntityClass) ) {
+ StoreContainerType stoc_type =
+ StoreContainerType.valueOf( theEntityClass,
+ StoreContainerType.STOC_TYPE_ENTITYLIST);
+ o_store.invalidate(stoc_type);
+ }
ArrayList streamedInput = theEntity.streamedInput();
String id = theEntity.getId();
invalidatePopupCache();
// ostore send notification
- if (StoreUtil.implementsStorableObject(theEntityClass) ) {
+ if ( StoreUtil.implementsStorableObject(theEntityClass) ) {
+ String uniqueId = id;
+ if ( theEntityClass.equals(StorableObjectEntity.class) )
+ uniqueId+="@"+theTable;
theLog.printInfo("CACHE: (del) " + id);
StoreIdentifier search_sid =
- new StoreIdentifier(theEntityClass, StoreContainerType.STOC_TYPE_ENTITY, id);
+ new StoreIdentifier(theEntityClass, StoreContainerType.STOC_TYPE_ENTITY, uniqueId);
o_store.invalidate(search_sid);
}