/*
- * Copyright (C) 2001, 2002 The Mir-coders group
+ * Copyright (C) 2001-2006 The Mir-coders group
*
* This file is part of Mir.
*
*
* In addition, as a special exception, The Mir-coders gives permission to link
* the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
* and distribute linked combinations including the two. You must obey the
* GNU General Public License in all respects for all of the code used other than
* the above mentioned libraries. If you modify this file, you may extend this
* exception to your version of the file, but you are not obligated to do so.
* If you do not wish to do so, delete this exception statement from your version.
*/
-package mir.module;
-import java.sql.SQLException;
-import java.util.Map;
+package mir.module;
import mir.entity.Entity;
import mir.entity.EntityList;
import mir.storage.Database;
+import mir.storage.DatabaseExc;
+import java.util.Map;
/**
* This class provides the base functionality for the derived Module-Classes.
return database;
}
- public Entity getById (String id) throws ModuleExc, ModuleFailure {
- try {
- if (database == null)
- throw new ModuleExc("AbstractModule.getById: No Database set!");
- Entity entity = database.selectById(id);
+ public Entity getById (String anId) throws ModuleFailure, EntityNotFoundExc {
+ if (database == null) {
+ throw new ModuleFailure("AbstractModule.getById: No Database set!");
+ }
- if (entity == null)
- throw new ModuleExc("AbstractModule.getById: No object for id = " + id);
- return entity;
- }
- catch (Throwable e) {
- throw new ModuleFailure(e);
- }
+ try {
+ Entity result = database.selectById(anId);
+
+ if (result == null) {
+ throw new EntityNotFoundExc("AbstractModule.getById: No object for id = " + anId);
+ }
+
+ return result;
+ }
+ catch (DatabaseExc e) {
+ throw new ModuleFailure("Database exception while retrieving entity with id " + anId);
+ }
}
public EntityList getByWhereClause (String whereClause, int offset) throws ModuleExc, ModuleFailure {
}
}
- /**
- * * Standardfunktion, um einen Datensatz via Database einzuf?gen
- * @param theValues Hash mit Spalte/Wert-Paaren
- * @return Id des eingef?gten Objekts
- * @exception ModuleExc
- * @exception ModuleFailure
- */
public String add(Map theValues) throws ModuleExc, ModuleFailure {
try {
Entity entity = database.createNewEntity();
}
}
- /**
- * Standardfunktion, um einen Datensatz via Database zu aktualisieren
- * @param theValues Hash mit Spalte/Wert-Paaren
- * @return Id des eingef?gten Objekts
- * @exception ModuleExc
- * @exception ModuleFailure
- */
public String set (Map theValues) throws ModuleExc, ModuleFailure {
try {
Entity theEntity = database.selectById((String) theValues.get("id"));
throw new ModuleFailure(e);
}
}
-
- /**
- * returns the number of rows
- */
- public int getSize(String where) throws ModuleExc, ModuleFailure {
- try {
- return database.getSize(where);
- }
- catch (SQLException e) {
- throw new ModuleFailure("Can't retrieve number of entities: " + e.toString(), e);
- }
- }
-
}