X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmir%2Fentity%2FAbstractEntity.java;h=108f4247cfd47b657ad7ef53a1f276bdd408eafc;hb=f2c82f962d2da630470760b0cadbcef91dec680d;hp=ee35074051d2e9928d9bc08a44ce63e75b1ccc0a;hpb=e44404fac09c8da04b5ef7874160cb91f8fc98a9;p=mir.git diff --git a/source/mir/entity/AbstractEntity.java b/source/mir/entity/AbstractEntity.java index ee350740..108f4247 100755 --- a/source/mir/entity/AbstractEntity.java +++ b/source/mir/entity/AbstractEntity.java @@ -36,15 +36,15 @@ import java.util.Map; import mir.config.MirPropertiesConfiguration; import mir.log.LoggerWrapper; +import mir.storage.DatabaseExc; +import mir.storage.DatabaseFailure; import mir.storage.Database; -import mir.storage.StorageObjectExc; -import mir.storage.StorageObjectFailure; /** * Base class the entities are derived from. Provides base functionality of * an entity. * - * @version $Id: AbstractEntity.java,v 1.8.2.6 2005/02/10 16:22:30 rhindes Exp $ + * @version $Id: AbstractEntity.java,v 1.8.2.8 2005/10/30 00:46:57 zapata Exp $ */ public class AbstractEntity implements Entity { @@ -52,11 +52,8 @@ public class AbstractEntity implements Entity { protected Map values; protected Database database; - protected LoggerWrapper logger; public AbstractEntity() { - logger = new LoggerWrapper("Entity"); - values = new HashMap(); } @@ -89,17 +86,18 @@ public class AbstractEntity implements Entity { } /** {@inheritDoc} */ - public String insert() throws StorageObjectExc { - logger.debug("Entity: trying to insert ..."); + public String insert() throws DatabaseExc { + getLogger().debug("Entity: trying to insert ..."); if (database != null) { return database.insert(this); } - throw new StorageObjectExc("database == null!"); + + throw new DatabaseExc("database == null!"); } /** {@inheritDoc} */ - public void update() throws StorageObjectFailure { + public void update() throws DatabaseFailure { database.update(this); } @@ -123,30 +121,34 @@ public class AbstractEntity implements Entity { * supplied was not found in the Entity. * @param theProp The field name whose value has to be set * @param theValue The new value of the field - * @exception StorageObjectFailure + * @exception DatabaseFailure */ - public void setFieldValue(String theProp, String theValue) throws StorageObjectFailure { + public void setFieldValue(String theProp, String theValue) throws DatabaseFailure { if (hasField(theProp)) values.put(theProp, theValue); else { - logger.warn("Entity.setFieldValue: Property not found: " + theProp + " (" + theValue + ")"); + getLogger().warn("Entity.setFieldValue: Property not found: " + theProp + " (" + theValue + ")"); } } /** * Returns the field names of the Entity */ - public List getFieldNames() throws StorageObjectFailure { + public List getFieldNames() throws DatabaseFailure { return database.getFieldNames(); } /** Returns whether fieldName is a valid field name of this Entity. * @param fieldName * @return true in case fieldName is a field name, else false. - * @exception StorageObjectFailure + * @exception DatabaseFailure */ - public boolean hasField(String fieldName) throws StorageObjectFailure { + public boolean hasField(String fieldName) throws DatabaseFailure { return getFieldNames().contains(fieldName); } + + protected LoggerWrapper getLogger() { + return new LoggerWrapper("Entity"); + } }