########## admin ##########
# language: english
-# $Id: admin_en.properties,v 1.48.2.21 2004/01/11 20:35:50 zapata Exp $
+# $Id: admin_en.properties,v 1.48.2.22 2004/01/18 17:30:55 zapata Exp $
languagename=English
abuse.filters = Filters
abuse.filters.movedown = down
abuse.filters.moveup = up
+abuse.filters.movebottom = bottom
+abuse.filters.movetop = top
abuse.filter.type = Type
abuse.filter.expression = Expression
* Mir.java - main servlet, that dispatches to servletmodules
*
* @author $Author: zapata $
- * @version $Id: Mir.java,v 1.49.2.10 2004/01/11 20:35:51 zapata Exp $
+ * @version $Id: Mir.java,v 1.49.2.11 2004/01/18 17:30:56 zapata Exp $
*
*/
public class Mir extends AbstractServlet {
}
}
else if (moduleName.equals("logout")) {
- logger.info(userEntity.getValue("login") + " has logged out");
+ logger.info(userEntity.getFieldValue("login") + " has logged out");
session.invalidate();
_sendLoginPage(aResponse, aRequest);
return;
--- /dev/null
+/*
+ * Copyright (C) 2001, 2002 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * 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.entity;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import mir.config.MirPropertiesConfiguration;
+import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
+import mir.log.LoggerWrapper;
+import mir.storage.StorageObject;
+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.1 2004/01/18 17:30:56 zapata Exp $
+ */
+
+public class AbstractEntity implements Entity {
+ protected static MirPropertiesConfiguration configuration;
+
+ protected Map values;
+ protected StorageObject storageObject;
+ protected LoggerWrapper logger;
+
+ static {
+ try {
+ configuration = MirPropertiesConfiguration.instance();
+ }
+ catch (PropertiesConfigExc e) {
+ throw new RuntimeException(e.getMessage());
+ }
+ }
+
+ public AbstractEntity() {
+ logger = new LoggerWrapper("Entity");
+
+ values = new HashMap();
+ }
+
+ /**
+ * Constructor
+ * @param StorageObject The StorageObject of the Entity.
+ */
+
+ public AbstractEntity(StorageObject StorageObject) {
+ this();
+
+ setStorage(StorageObject);
+ }
+
+ public void setStorage(StorageObject storage) {
+ this.storageObject = storage;
+ }
+
+ /** {@inheritDoc} */
+ public void setValues(Map aMap) {
+ if (aMap!=null) {
+ Iterator i = aMap.entrySet().iterator();
+ synchronized(this) {
+ while (i.hasNext()) {
+ Map.Entry entry = (Map.Entry) i.next();
+
+ setFieldValue( (String) entry.getKey(), (String) entry.getValue());
+ }
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ public String getId() {
+ return getFieldValue(storageObject.getIdName());
+ }
+
+ /** {@inheritDoc} */
+ public void setId(String id) {
+ setFieldValue(storageObject.getIdName(), id);
+ }
+
+ /** {@inheritDoc} */
+ public String insert() throws StorageObjectExc {
+ logger.debug("Entity: trying to insert ...");
+
+ if (storageObject != null) {
+ return storageObject.insert(this);
+ }
+ else
+ throw new StorageObjectExc("storageObject == null!");
+ }
+
+ /** {@inheritDoc} */
+ public void update() throws StorageObjectFailure {
+ storageObject.update(this);
+ }
+
+ /** {@inheritDoc} */
+ public String getFieldValue(String aFieldName) {
+ String returnValue = null;
+
+ if (aFieldName != null) {
+ returnValue = (String) values.get(aFieldName);
+ }
+ return returnValue;
+ }
+
+ /** {@inheritDoc} */
+ public boolean hasFieldValue(String aFieldName) {
+ return values.containsKey(aFieldName);
+ }
+
+ /**
+ * Sets the value for a field. Issues a log message if the field name
+ * 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
+ */
+ public void setFieldValue(String theProp, String theValue) throws StorageObjectFailure {
+ if (hasField(theProp))
+ values.put(theProp, theValue);
+ else {
+ logger.warn("Entity.setFieldValue: Property not found: " + theProp + " (" + theValue + ")");
+ }
+ }
+
+ /**
+ * Returns the field names of the Entity
+ */
+ public List getFieldNames() throws StorageObjectFailure {
+ return storageObject.getFields();
+ }
+
+ /** 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
+ */
+ public boolean hasField(String fieldName) throws StorageObjectFailure {
+ return getFieldNames().contains(fieldName);
+ }
+}
+
import mir.storage.StorageObject;
import mir.storage.StorageObjectExc;
import mir.storage.StorageObjectFailure;
-import mir.util.*;
/**
- * Base class the entities are derived from. Provides base functionality of
- * an entity. Entities are used to represent rows of a database table.<p>
- *
- * @version $Id: Entity.java,v 1.21.2.6 2003/12/21 13:32:03 zapata Exp $
- * @author rk
+ * An <code>Entity</code> represents a persistent data object, typically
+ * stored in a database.<p>
*
+ * @version $Id: Entity.java,v 1.21.2.7 2004/01/18 17:30:56 zapata Exp $
*/
-public class Entity
+public interface Entity
{
- protected static MirPropertiesConfiguration configuration;
-
-// protected Map theValuesHash; // tablekey / value
- protected Map values;
- protected StorageObject theStorageObject;
- protected List streamedInput = null;
- protected LoggerWrapper logger;
-
- static {
- try {
- configuration = MirPropertiesConfiguration.instance();
- }
- catch (PropertiesConfigExc e) {
- throw new RuntimeException(e.getMessage());
- }
- }
-
- public Entity() {
- logger = new LoggerWrapper("Entity");
-
- values = new HashMap();
- }
-
- /**
- * Constructor
- * @param StorageObject The StorageObject of the Entity.
- */
-
- public Entity(StorageObject StorageObject) {
- this();
-
- setStorage(StorageObject);
- }
-
- /**
- *
- * @param storage
- */
-
- public void setStorage(StorageObject storage) {
- this.theStorageObject = storage;
- }
+ public void setStorage(StorageObject storage);
/**
* Sets the values of the Entity. (Only to be called by the Storage Object)
* @param aMap Map containing the new values of the Entity
*/
- public void setValues(Map aMap) {
- if (aMap!=null) {
- Iterator i = aMap.entrySet().iterator();
- synchronized(this) {
- while (i.hasNext()) {
- Map.Entry entry = (Map.Entry) i.next();
-
- setValueForProperty( (String) entry.getKey(), (String) entry.getValue());
- }
- }
- }
- }
+ public void setValues(Map aMap);
/**
* Returns the primary key of the Entity.
* @return String Id
*/
- public String getId() {
- return (String) getValue(theStorageObject.getIdName());
- }
+ public String getId();
/**
* Defines the primary key of the Entity (only to be set by the StorageObject)
* @param id
*/
- public void setId(String id) {
- setValueForProperty(theStorageObject.getIdName(), id);
- }
-
- /**
- * Returns the value of a field by field name.
- * @param field The name of the field
- * @return value of the field
- */
- public String getValue(String field) {
- String returnValue = null;
-
- if (field != null) {
- returnValue = (String) values.get(field);
- }
- return returnValue;
- }
-
- public boolean hasValueForField(String field) {
- return values.containsKey(field);
- }
+ public void setId(String id);
/**
* Insers Entity into the database via StorageObject
* @return Primary Key of the Entity
- * @exception StorageObjectException
+ * @exception StorageObjectExc
*/
- public String insert() throws StorageObjectExc {
- logger.debug("Entity: trying to insert ...");
-
- if (theStorageObject != null) {
- return theStorageObject.insert(this);
- }
- else
- throw new StorageObjectExc("theStorageObject == null!");
- }
+ public String insert() throws StorageObjectExc;
/**
* Saves changes of this Entity to the database
- * @exception StorageObjectException
+ * @exception StorageObjectFailure
*/
- public void update() throws StorageObjectFailure {
- theStorageObject.update(this);
- }
+ public void update() throws StorageObjectFailure;
/**
* Sets the value for a field. Issues a log message if the field name
* 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 StorageObjectException
+ * @exception StorageObjectFailure
*/
- public void setValueForProperty(String theProp, String theValue) throws StorageObjectFailure {
- try {
- if (isField(theProp))
- values.put(theProp, theValue);
- else {
- logger.warn("Entity.setValueForProperty: Property not found: " + theProp + " (" + theValue + ")");
- }
- }
- catch (Throwable t) {
- logger.error("Entity.setValueForProperty: " + t.toString());
- t.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));
-
- throw new StorageObjectFailure(t);
- }
- }
+ public void setFieldValue(String theProp, String theValue);
/**
- * Returns the field names of the Entity as ArrayListe.
- * @return ArrayList with field names
- * @exception StorageObjectException is throuwn if database access was impossible
+ * Returns the field names of the Entity
*/
- public List getFields() throws StorageObjectFailure {
- return theStorageObject.getFields();
- }
-
- /**
- * Returns an int[] with the types of the fields
- * @return int[] that contains the types of the fields
- * @exception StorageObjectException
- */
- public int[] getTypes() throws StorageObjectFailure {
- return theStorageObject.getTypes();
- }
-
- /**
- * Returns an ArrayList with field names
- * @return List with field names
- * @exception StorageObjectException
- */
- public List getLabels() throws StorageObjectFailure {
- return theStorageObject.getLabels();
- }
-
+ public List getFieldNames() throws StorageObjectFailure;
/**
- * Returns an ArrayList with all database fields that can
- * be evaluated as streamedInput.
- * Could be automated by the types (blob, etc.)
- * Until now to be created manually in the inheriting class
- *
- * Liefert einen ArrayList mit allen Datenbankfeldern, die
- * als streamedInput ausgelesen werden muessen.
- * Waere automatisierbar ueber die types (blob, etc.)
- * Bisher manuell anzulegen in der erbenden Klasse
+ * Returns the value of a field by field name.
+ * @param field The name of the field
+ * @return value of the field
*/
+ public String getFieldValue(String field);
- public List streamedInput() {
- return streamedInput;
- }
+ public boolean hasFieldValue(String field);
/** 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 StorageObjectException
- */
- public boolean isField(String fieldName) throws StorageObjectFailure {
- return theStorageObject.getFields().contains(fieldName);
- }
-
- protected void throwStorageObjectFailure(Throwable e, String wo) throws StorageObjectFailure {
- logger.error(e.toString() + " function: " + wo);
- e.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));
-
- throw new StorageObjectFailure("Storage Object Exception in entity", e);
- }
-
- /**
- * Helper method to append a line to a field
*/
- public void appendLineToField(String aFieldName, String aLine) {
- StringBuffer fieldContent = new StringBuffer();
- try {
- fieldContent.append(StringRoutines.interpretAsString(getValue(aFieldName)));
- }
- catch (Throwable t) {
- }
- if (fieldContent.length() > 0 && fieldContent.charAt(fieldContent.length() - 1) != '\n') {
- fieldContent.append('\n');
- }
-
- fieldContent.append(aLine);
- setValueForProperty(aFieldName, fieldContent.toString());
- }
+ public boolean hasField(String aFieldName) throws StorageObjectFailure;
}
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* 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.
+ * 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.
*/
private String whereClause;
private String orderByClause;
private int batchSize;
- private int toFetch;
private EntityList currentBatch;
private int skip;
batchSize=aBatchSize;
skip=aSkip;
limit=aLimit;
-
+
rewind();
}
return whereClause;
}
-
/**
* Sets the sorting criterium of this EntityList
* @param oc
*/
public Entity elementAt(int i) {
- /** @todo check if i is in list.size() */
- return (Entity)theEntityArrayList.get(i);
+ /** todo check if i is in list.size() */
+ return (Entity) theEntityArrayList.get(i);
}
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* 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.
+ * 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.entity;
* @author /rk
* @version 1.2
*/
-public class GenericEntity extends Entity {}
+public class GenericEntity extends AbstractEntity {}
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* 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.
+ * 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.entity;
import mir.storage.store.StoreIdentifier;
-public class StorableObjectEntity extends Entity
+public class StorableObjectEntity extends AbstractEntity
implements StorableObject {
/**
*/
public StoreIdentifier getStoreIdentifier() {
String id = getId();
- if ( id!=null && theStorageObject!= null )
- return new StoreIdentifier(this, id+"@"+theStorageObject.getTableName());
+ if ( id!=null && storageObject!= null )
+ return new StoreIdentifier(this, id+"@"+storageObject.getTableName());
return null;
}
return new StoreIdentifier(theEntityClass, id + "@" + theTable);
}
}
-
+
public static final StoreIdentifier getStoreIdentifier(Database theStorage,
Class theEntityClass, ResultSet rs) throws SQLException {
-
+
String idcol = theStorage.getIdName();
String idval = rs.getObject(idcol).toString();
return getStoreIdentifier(theEntityClass,
theStorage.getTableName(), idval);
}
-
+
return null;
}
public boolean containsKey(Object aKey) {
try {
if (aKey instanceof String)
- return entity.hasValueForField((String) aKey)
- || definition.hasCalculatedField((String) aKey)
- || entity.getFields().contains(aKey);
+ return entity.hasField((String) aKey)
+ || definition.hasCalculatedField((String) aKey);
}
catch (Throwable t) {
}
return result;
}
else if (aKey instanceof String) {
- return entity.getValue((String) aKey);
+ return entity.getFieldValue((String) aKey);
}
else {
return null;
String aWhereClause, String anOrderByClause, String aDefinition) {
try {
return
- new CachingRewindableIterator(
- new EntityIteratorAdapter(aMainTablePrefix, someExtraTables,
+ new CachingRewindableIterator(
+ new EntityIteratorAdapter(aMainTablePrefix, someExtraTables,
aWhereClause, anOrderByClause,
- -1, getModel(), aDefinition, -1, 0)
+ -1, getModel(), aDefinition, -1, 0)
);
}
catch (Throwable t) {
public Object getValue(EntityAdapter anEntityAdapter) {
Object result = null;
- String textValue = anEntityAdapter.getEntity().getValue(fieldName);
+ String textValue = anEntityAdapter.getEntity().getFieldValue(fieldName);
Calendar calendar = GregorianCalendar.getInstance();
int year;
int month;
public Object getValue(EntityAdapter anEntityAdapter) {
Object result = null;
- String text = anEntityAdapter.getEntity().getValue(fieldName);
+ String text = anEntityAdapter.getEntity().getFieldValue(fieldName);
if (text!=null) {
try {
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* 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.
+ * 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.entity.adapter;
this(new EntityBrowser(aModel.getMappingForName(aDefinitionName).getStorage(), aWhereClause, anOrderByClause, aBatchSize, aLimit, aSkip), aModel, aDefinitionName);
}
- public EntityIteratorAdapter(String aMainTablePrefix, List someExtraTables,
+ public EntityIteratorAdapter(String aMainTablePrefix, List someExtraTables,
String aWhereClause, String anOrderByClause,
int aBatchSize, EntityAdapterModel aModel, String aDefinitionName,
int aLimit, int aSkip) throws StorageObjectFailure, EntityAdapterExc {
package mir.module;
import java.util.Map;
+import java.sql.SQLException;
import mir.entity.Entity;
import mir.entity.EntityList;
*/
public class AbstractModule {
- protected StorageObject theStorage;
+ protected StorageObject storage;
public void setStorage(StorageObject storage) {
- this.theStorage = storage;
+ this.storage = storage;
}
/**
* @return Standard-StorageObject
*/
public StorageObject getStorageObject () {
- return theStorage;
+ return storage;
}
- /**
- * Holt eine Entity anhand der Id via StorageObject
- * @param String der Entity
- * @return Entity
- */
public Entity getById (String id) throws ModuleExc, ModuleFailure {
try {
- if (theStorage == null)
+ if (storage == null)
throw new ModuleExc("AbstractModule.getById: No StorageObject set!");
- Entity entity = (Entity)theStorage.selectById(id);
+ Entity entity = storage.selectById(id);
if (entity == null)
throw new ModuleExc("AbstractModule.getById: No object for id = " + id);
}
}
- /**
- * Holt eine EntityListe anhand des WhereClause via StorageObject
- * @param String whereclause
- * @param offset - ab welchem Datensatz die gematchten Entities zurueckgeliefert werden
- * @return EntityList Liste der gematchten Datens?tze
- */
public EntityList getByWhereClause (String whereClause, int offset) throws ModuleExc, ModuleFailure {
try {
- if (theStorage == null)
+ if (storage == null)
throw new ModuleExc("AbstractModule.getByWhereClause: No StorageObject set!");
- return theStorage.selectByWhereClause(whereClause, offset);
- }
- catch (Throwable e) {
- throw new ModuleFailure(e);
- }
- }
-
- /**
- * Holt eine EntityListe anhand des WhereClause aus dem StorageObject
- * @param String where WhereClause
- * @param String order Sortierreihenfolge
- * @param offset - ab welchem Datensatz die gematchten Entities zurueckgeliefert werden
- * @return EntityList Liste der gematchten Datens?tze
- */
- public EntityList getByWhereClause (String where, String order, int offset) throws ModuleExc, ModuleFailure {
- try {
- if (theStorage==null)
- throw new ModuleExc("AbstractModule.getByWhereClause: No StorageObject set!");
-
- return theStorage.selectByWhereClause(where, order, offset);
- }
- catch (Throwable e) {
- throw new ModuleFailure(e);
- }
- }
- /**
- * Executes a where clause on the StorageObject with order criteria
- * fetching from offset the number of limit objects
- *
- * @param String where
- * @param String order
- * @param int offset
- * @param int limit
- * @return EntityList
- */
-
- public EntityList getByWhereClause(String where, String order, int offset, int limit) throws ModuleExc, ModuleFailure {
- try {
- if (theStorage==null)
- throw new ModuleExc("AbstractModule.getByWhereClause: StorageObject not set!");
-
- return theStorage.selectByWhereClause(where, order, offset, limit);
+ return storage.selectByWhereClause(whereClause, offset);
}
catch (Throwable e) {
throw new ModuleFailure(e);
}
/**
- * Holt eine EntityListe anhand des Wertes aValue von Feld aField aus dem StorageObject
- * @param String aField - Feldname im StorageObject
- * @param String aValue - Wert in Feld im StorageObject
- * @param offset - ab welchem Datensatz die gematchten Entities zurueckgeliefert werden
- * @return EntityList Liste der gematchten Datens?tze
- */
- public EntityList getByFieldValue (String aField, String aValue, int offset) throws ModuleExc, ModuleFailure {
- String whereClause;
- whereClause = aField + " like '%" + aValue + "%'";
- return getByWhereClause(whereClause, offset);
- }
-
- /**
* * Standardfunktion, um einen Datensatz via StorageObject einzuf?gen
* @param theValues Hash mit Spalte/Wert-Paaren
* @return Id des eingef?gten Objekts
*/
public String add (Map theValues) throws ModuleExc, ModuleFailure {
try {
- Entity theEntity = (Entity)theStorage.getEntityClass().newInstance();
- theEntity.setStorage(theStorage);
+ Entity theEntity = (Entity)storage.getEntityClass().newInstance();
+ theEntity.setStorage(storage);
theEntity.setValues(theValues);
return theEntity.insert();
}
/**
* This function creates an Entity without yet storing it in the database
- *
- * @param theValues
- * @return
- * @throws ModuleExc
- * @throws ModuleFailure
*/
public Entity createNew() throws ModuleExc, ModuleFailure {
try {
- Entity result = (Entity)theStorage.getEntityClass().newInstance();
- result.setStorage(theStorage);
+ Entity result = (Entity)storage.getEntityClass().newInstance();
+ result.setStorage(storage);
return result;
}
*/
public String set (Map theValues) throws ModuleExc, ModuleFailure {
try {
- Entity theEntity = theStorage.selectById((String)theValues.get("id"));
+ Entity theEntity = storage.selectById((String)theValues.get("id"));
if (theEntity == null)
throw new ModuleExc("No object found with id " + theValues.get("id"));
theEntity.setValues(theValues);
*/
public void deleteById (String idParam) throws ModuleExc, ModuleFailure {
try {
- theStorage.delete(idParam);
+ storage.delete(idParam);
}
catch (Throwable e) {
throw new ModuleFailure(e);
*/
public int getSize(String where) throws ModuleExc, ModuleFailure {
try {
- return theStorage.getSize(where);
+ return storage.getSize(where);
}
- catch (Throwable e) {
- throw new ModuleFailure(e);
+ catch (SQLException e) {
+ throw new ModuleFailure("Can't retrieve number of entities: " + e.toString(), e);
}
}
Object value = ParameterExpander.evaluateExpression(aValueMap, valueExpression);
if (value instanceof String)
- entity.setValueForProperty(entityField, (String) value);
+ entity.setFieldValue(entityField, (String) value);
else if (value instanceof EntityAdapter)
- entity.setValueForProperty(entityField, ((EntityAdapter) value).getEntity().getId());
+ entity.setFieldValue(entityField, ((EntityAdapter) value).getEntity().getId());
else if (value instanceof Date) {
- entity.setValueForProperty(entityField, JDBCStringRoutines.formatDate((Date) value));
+ entity.setFieldValue(entityField, JDBCStringRoutines.formatDate((Date) value));
}
else
aLogger.warn("Can't set value " + value + " for field " + entityField);
public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
if (aHandler instanceof PropertyValueSectionHandler) {
usePropertyValueSectionHandler(resource, (PropertyValueSectionHandler) aHandler, currentTag);
-// resource.set(makeQualifiedName(currentTag), ( (PropertyValueSectionHandler) aHandler).getValue());
+// resource.set(makeQualifiedName(currentTag), ( (PropertyValueSectionHandler) aHandler).getFieldValue());
}
};
* Treiber, Host, User und Passwort, ueber den der Zugriff auf die
* Datenbank erfolgt.
*
- * @version $Id: Database.java,v 1.44.2.20 2003/11/28 17:21:50 rk Exp $
+ * @version $Id: Database.java,v 1.44.2.21 2004/01/18 17:30:57 zapata Exp $
* @author rk
*
*/
public class Database implements StorageObject {
private static Class GENERIC_ENTITY_CLASS = mir.entity.StorableObjectEntity.class;
- private static Class STORABLE_OBJECT_ENTITY_CLASS = mir.entity.StorableObjectEntity.class;
-
-
- private static Map POPUP_EMPTYLINE = new HashMap();
protected static final ObjectStore o_store = ObjectStore.getInstance();
private static final int _millisPerHour = 60 * 60 * 1000;
- private static final int _millisPerMinute = 60 * 1000;
-
- static {
- // always same object saves a little space
- POPUP_EMPTYLINE.put("key", "");
- POPUP_EMPTYLINE.put("value", "--");
- }
protected LoggerWrapper logger;
protected MirPropertiesConfiguration configuration;
- protected String theTable;
- protected String theCoreTable = null;
- protected String thePKeyName = "id";
- protected int thePKeyType;
- protected int thePKeyIndex;
+ protected String mainTable;
+ protected String primaryKeySequence = null;
+ protected String primaryKeyField = "id";
+
protected boolean evaluatedMetaData = false;
protected ArrayList metadataFields;
protected ArrayList metadataLabels;
protected ArrayList metadataNotNullFields;
protected int[] metadataTypes;
protected Class theEntityClass;
- protected List popupCache = null;
- protected boolean hasPopupCache = false;
- protected Map hashCache = null;
protected boolean hasTimestamp = true;
- private String database_driver;
- private String database_url;
private int defaultLimit;
TimeZone timezone;
SimpleDateFormat internalDateFormat;
SimpleDateFormat userInputDateFormat;
-/*
- private SimpleDateFormat _dateFormatterOut;
- private SimpleDateFormat _dateFormatterIn;
- _dateFormatterOut = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- _dateFormatterIn = new SimpleDateFormat("yyyy-MM-dd HH:mm");
-*/
/**
* Kontruktor bekommt den Filenamen des Konfigurationsfiles ?bergeben.
* <code>Database.Host</code> und <code>Database.Adaptor</code>
* ausgelesen und ein Broker f?r die Verbindugen zur Datenbank
* erzeugt.
- *
- * @param String confFilename Dateiname der Konfigurationsdatei
*/
public Database() throws StorageObjectFailure {
try {
userInputDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
userInputDateFormat.setTimeZone(timezone);
-
String theAdaptorName = configuration.getString("Database.Adaptor");
defaultLimit = Integer.parseInt(configuration.getString("Database.Limit"));
* @return Name des Primary-Keys
*/
public String getIdName() {
- return thePKeyName;
+ return primaryKeyField;
}
/**
* @return Name der Tabelle
*/
public String getTableName() {
- return theTable;
+ return mainTable;
}
- /*
- * Dient dazu vererbte Tabellen bei objectrelationalen DBMS
- * zu speichern, wenn die id einer Tabelle in der parenttabelle verwaltet
- * wird.
- * @return liefert theCoreTabel als String zurueck, wenn gesetzt, sonst
- * the Table
+ /**
+ * Returns the id that was most recently added to the database
*/
- public String getCoreTable() {
- if (theCoreTable != null) {
- return theCoreTable;
- }
- else {
- return theTable;
- }
+ private String getLatestInsertedId(Connection aConnection) throws SQLException {
+ if (primaryKeySequence==null)
+ primaryKeySequence = mainTable+"_id_seq";
+
+ PreparedStatement statement = aConnection.prepareStatement("select currval('" + primaryKeySequence + "')");
+
+ ResultSet rs = statement.executeQuery();
+ rs.next();
+ return rs.getString(1);
}
/**
* Liefert Feldtypen der Felder der Tabelle zurueck (s.a. java.sql.Types)
* @return int-Array mit den Typen der Felder
- * @exception StorageObjectException
+ * @exception StorageObjectFailure
*/
public int[] getTypes() throws StorageObjectFailure {
if (metadataTypes == null) {
/**
* Liefert eine Liste der Labels der Tabellenfelder
- * @return ArrayListe mit Labeln
- * @exception StorageObjectException
*/
public List getLabels() throws StorageObjectFailure {
if (metadataLabels == null) {
/**
* Liefert eine Liste der Felder der Tabelle
* @return ArrayList mit Feldern
- * @exception StorageObjectException
*/
public List getFields() throws StorageObjectFailure {
if (metadataFields == null) {
* Gets value out of ResultSet according to type and converts to String
* @param rs ResultSet.
* @param aType a type from java.sql.Types.*
- * @param index index in ResultSet
+ * @param valueIndex index in ResultSet
* @return returns the value as String. If no conversion is possible
* /unsupported value/ is returned
*/
case java.sql.Types.NUMERIC:
- /** @todo Numeric can be float or double depending upon
+ /** todo Numeric can be float or double depending upon
* metadata.getScale() / especially with oracle */
long outl = rs.getLong(valueIndex);
String uniqueId = id;
if (theEntityClass.equals(StorableObjectEntity.class)) {
- uniqueId += ("@" + theTable);
+ uniqueId += ("@" + mainTable);
}
StoreIdentifier search_sid = new StoreIdentifier(theEntityClass, uniqueId);
try {
ResultSet rs;
- /** @todo better prepared statement */
+ /** todo better prepared statement */
String selectSql =
- "select * from " + theTable + " where " + thePKeyName + "=" + id;
+ "select * from " + mainTable + " where " + primaryKeyField + "=" + id;
stmt = con.createStatement();
rs = executeSql(stmt, selectSql);
returnEntity = makeEntityFromResultSet(rs);
}
else {
- logger.warn("No data for id: " + id + " in table " + theTable);
+ logger.warn("No data for id: " + id + " in table " + mainTable);
}
rs.close();
}
else {
- logger.warn("No Data for Id " + id + " in Table " + theTable);
+ logger.warn("No Data for Id " + id + " in Table " + mainTable);
}
}
catch (SQLException sqe) {
/**
* This method makes it possible to make selects across multiple tables
- *
+ *
* @param mainTablePrefix prefix for the mainTable
* @param extraTables a vector of tables for relational select
* @param aWhereClause whereClause
* @throws StorageObjectFailure
*/
- public EntityList selectByWhereClauseWithExtraTables(String mainTablePrefix,
+ public EntityList selectByWhereClauseWithExtraTables(String mainTablePrefix,
List extraTables, String aWhereClause )
throws StorageObjectFailure {
return selectByWhereClause( mainTablePrefix, extraTables, aWhereClause, "", 0, defaultLimit);
/**
* select-Operator um Datensaetze zu bekommen, die key = value erfuellen.
- * @param key Datenbankfeld der Bedingung.
- * @param value Wert die der key anehmen muss.
+ * @param aField Datenbankfeld der Bedingung.
+ * @param aValue Wert die der key anehmen muss.
* @return EntityList mit den gematchten Entities
*/
public EntityList selectByFieldValue(String aField, String aValue) throws StorageObjectFailure {
/**
* select-Operator um Datensaetze zu bekommen, die key = value erfuellen.
- * @param key Datenbankfeld der Bedingung.
- * @param value Wert die der key anehmen muss.
+ * @param aField Datenbankfeld der Bedingung.
+ * @param aValue Wert die der key anehmen muss.
* @param offset Gibt an ab welchem Datensatz angezeigt werden soll.
* @return EntityList mit den gematchten Entities
*/
* select-Operator liefert eine EntityListe mit den gematchten Datens?tzen zur?ck.
* Also offset wird der erste Datensatz genommen.
*
- * @param wc where-Clause
+ * @param where where-Clause
* @return EntityList mit den gematchten Entities
- * @exception StorageObjectException
+ * @exception StorageObjectFailure
*/
public EntityList selectByWhereClause(String where) throws StorageObjectFailure {
return selectByWhereClause(where, 0);
* select-Operator liefert eine EntityListe mit den gematchten Datens?tzen zur?ck.
* Als maximale Anzahl wird das Limit auf der Konfiguration genommen.
*
- * @param wc where-Clause
+ * @param whereClause where-Clause
* @param offset ab welchem Datensatz.
* @return EntityList mit den gematchten Entities
- * @exception StorageObjectException
+ * @exception StorageObjectFailure
*/
public EntityList selectByWhereClause(String whereClause, int offset) throws StorageObjectFailure {
return selectByWhereClause(whereClause, null, offset);
* Also offset wird der erste Datensatz genommen.
* Als maximale Anzahl wird das Limit auf der Konfiguration genommen.
*
- * @param wc where-Clause
- * @param ob orderBy-Clause
+ * @param where where-Clause
+ * @param order orderBy-Clause
* @return EntityList mit den gematchten Entities
- * @exception StorageObjectException
+ * @exception StorageObjectFailure
*/
public EntityList selectByWhereClause(String where, String order) throws StorageObjectFailure {
return selectByWhereClause(where, order, 0);
* select-Operator liefert eine EntityListe mit den gematchten Datens?tzen zur?ck.
* Als maximale Anzahl wird das Limit auf der Konfiguration genommen.
*
- * @param wc where-Clause
- * @param ob orderBy-Clause
+ * @param whereClause where-Clause
+ * @param orderBy orderBy-Clause
* @param offset ab welchem Datensatz
* @return EntityList mit den gematchten Entities
- * @exception StorageObjectException
+ * @exception StorageObjectFailure
*/
public EntityList selectByWhereClause(String whereClause, String orderBy, int offset) throws StorageObjectFailure {
return selectByWhereClause(whereClause, orderBy, offset, defaultLimit);
* @param offset ab welchem Datensatz
* @param limit wieviele Datens?tze
* @return EntityList mit den gematchten Entities
- * @exception StorageObjectException
+ * @exception StorageObjectFailure
*/
public EntityList selectByWhereClause(String aWhereClause, String anOrderByClause,
int offset, int limit) throws StorageObjectFailure {
- return selectByWhereClause("", null, aWhereClause, anOrderByClause, offset, limit);
+ return selectByWhereClause("", null, aWhereClause, anOrderByClause, offset, limit);
}
* @param offset ab welchem Datensatz
* @param limit wieviele Datens?tze
* @return EntityList mit den gematchten Entities
- * @exception StorageObjectException
+ * @exception StorageObjectFailure
*/
public EntityList selectByWhereClause(String mainTablePrefix, List extraTables,
String aWhereClause, String anOrderByClause,
int offset, int limit) throws StorageObjectFailure {
-
+
// TODO get rid of emtpy Strings in extraTables
// make extraTables null, if single empty String in it
- // cause StringUtil.splitString puts in emptyString
+ // cause StringUtil.splitString puts in emptyString
if (extraTables != null && ((String)extraTables.get(0)).trim().equals(""))
{
logger.debug("+++ made extraTables to null!");
extraTables=null;
}
-
- String useTable = theTable;
+
+ String useTable = mainTable;
String selectStar = "*";
if (mainTablePrefix!=null && mainTablePrefix.trim().length()>0) {
useTable+=" "+mainTablePrefix;
selectStar=mainTablePrefix.trim() + ".*";
}
-
+
// check o_store for entitylist
// only if no relational select
if (extraTables==null) {
if (StoreUtil.extendsStorableEntity(theEntityClass)) {
StoreIdentifier searchSid = new StoreIdentifier(theEntityClass,
StoreContainerType.STOC_TYPE_ENTITYLIST,
- StoreUtil.getEntityListUniqueIdentifierFor(theTable,
+ StoreUtil.getEntityListUniqueIdentifierFor(mainTable,
aWhereClause, anOrderByClause, offset, limit));
EntityList hit = (EntityList) o_store.use(searchSid);
new StringBuffer("select count(*) from ").append(useTable);
StringBuffer selectSql =
new StringBuffer("select "+selectStar+" from ").append(useTable);
-
+
// append extratables, if necessary
if (extraTables!=null) {
for (int i=0;i < extraTables.size();i++) {
- if (!extraTables.get(i).equals("")) {
+ if (!extraTables.get(i).equals("")) {
countSql.append( ", " + extraTables.get(i));
selectSql.append( ", " + extraTables.get(i));
}
}
}
-
+
if (aWhereClause != null) {
selectSql.append(" where ").append(aWhereClause);
countSql.append(" where ").append(aWhereClause);
Entity returnEntity = null;
try {
- // ask object store for object @ thePKeyIndex
if (StoreUtil.extendsStorableEntity(theEntityClass)) {
StoreIdentifier searchSid = StorableObjectEntity.getStoreIdentifier(this,
theEntityClass, rs);
returnEntity.setValues(theResultHash);
if (returnEntity instanceof StorableObject) {
- logger.debug("CACHE: ( in) " + returnEntity.getId() + " :" + theTable);
+ logger.debug("CACHE: ( in) " + returnEntity.getId() + " :" + mainTable);
o_store.add(((StorableObject) returnEntity).getStoreIdentifier());
}
} else {
PreparedStatement pstmt = null;
try {
- List streamedInput = theEntity.streamedInput();
StringBuffer f = new StringBuffer();
StringBuffer v = new StringBuffer();
String aField;
for (int i = 0; i < getFields().size(); i++) {
aField = (String) getFields().get(i);
- if (!aField.equals(thePKeyName)) {
+ if (!aField.equals(primaryKeyField)) {
aValue = null;
// exceptions
- if (!theEntity.hasValueForField(aField) && (
+ if (!theEntity.hasFieldValue(aField) && (
aField.equals("webdb_create") ||
aField.equals("webdb_lastchange"))) {
aValue = "NOW()";
}
else {
- if ((streamedInput != null) && streamedInput.contains(aField)) {
- aValue = "?";
- }
- else {
- if (theEntity.hasValueForField(aField)) {
+ if (theEntity.hasFieldValue(aField)) {
aValue =
"'" +
- JDBCStringRoutines.escapeStringLiteral((String) theEntity.getValue(aField)) + "'";
+ JDBCStringRoutines.escapeStringLiteral(theEntity.getFieldValue(aField)) + "'";
}
- }
}
// wenn Wert gegeben, dann einbauen
// insert into db
StringBuffer sqlBuf =
- new StringBuffer("insert into ").append(theTable).append("(").append(f)
+ new StringBuffer("insert into ").append(mainTable).append("(").append(f)
.append(") values (").append(v).append(")");
String sql = sqlBuf.toString();
con.setAutoCommit(false);
pstmt = con.prepareStatement(sql);
- if (streamedInput != null) {
- for (int i = 0; i < streamedInput.size(); i++) {
- String inputString =
- (String) theEntity.getValue((String) streamedInput.get(i));
- pstmt.setBytes(i + 1, inputString.getBytes());
- }
- }
-
int ret = pstmt.executeUpdate();
if (ret == 0) {
return null;
}
- pstmt = con.prepareStatement("select currval('" + getCoreTable() + "_id_seq')");
+// pstmt = con.prepareStatement("select currval('" + + "_id_seq')");
- ResultSet rs = pstmt.executeQuery();
- rs.next();
- returnId = rs.getString(1);
+ returnId = getLatestInsertedId(con);
theEntity.setId(returnId);
}
catch (SQLException sqe) {
freeConnection(con, pstmt);
}
- /** @todo store entity in o_store */
+ /** todo store entity in o_store */
return returnId;
}
Connection con = null;
PreparedStatement pstmt = null;
- /** @todo this is stupid: why do we prepare statement, when we
+ /** todo this is stupid: why do we prepare statement, when we
* throw it away afterwards. should be regular statement
* update/insert could better be one routine called save()
* that chooses to either insert or update depending if we
* 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 extension: check if Entity did change, otherwise we don't need
* the roundtrip to the database */
/** invalidating corresponding entitylists in o_store*/
if (StoreUtil.extendsStorableEntity(theEntityClass)) {
o_store.invalidate(stoc_type);
}
- List streamedInput = theEntity.streamedInput();
String id = theEntity.getId();
String aField;
StringBuffer fv = new StringBuffer();
aField = (String) metadataFields.get(i);
// only normal cases
- if ( !(aField.equals(thePKeyName) ||
+ // todo if entity.hasFieldValue returns false, then the value should be stored as null
+ if (!(aField.equals(primaryKeyField) ||
aField.equals("webdb_create") ||
- aField.equals("webdb_lastchange") ||
- ((streamedInput != null) && streamedInput.contains(aField)))) {
- if (theEntity.hasValueForField(aField)) {
+ aField.equals("webdb_lastchange"))) {
+ if (theEntity.hasFieldValue(aField)) {
if (firstField == false) {
fv.append(", ");
}
firstField = false;
}
- fv.append(aField).append("='").append(JDBCStringRoutines.escapeStringLiteral((String) theEntity.getValue(aField))).append("'");
+ fv.append(aField).append("='").append(JDBCStringRoutines.escapeStringLiteral(theEntity.getFieldValue(aField))).append("'");
- // fv.append(aField).append("='").append(StringUtil.quote((String)theEntity.getValue(aField))).append("'");
+ // fv.append(aField).append("='").append(StringUtil.quote((String)theEntity.getFieldValue(aField))).append("'");
}
}
}
StringBuffer sql =
- new StringBuffer("update ").append(theTable).append(" set ").append(fv);
+ new StringBuffer("update ").append(mainTable).append(" set ").append(fv);
// exceptions
if (metadataFields.contains("webdb_lastchange")) {
// special case: the webdb_create requires the field in yyyy-mm-dd HH:mm
// format so anything extra will be ignored. -mh
if (metadataFields.contains("webdb_create") &&
- theEntity.hasValueForField("webdb_create")) {
+ theEntity.hasFieldValue("webdb_create")) {
// minimum of 10 (yyyy-mm-dd)...
- if (theEntity.getValue("webdb_create").length() >= 10) {
- String dateString = theEntity.getValue("webdb_create");
+ if (theEntity.getFieldValue("webdb_create").length() >= 10) {
+ String dateString = theEntity.getFieldValue("webdb_create");
// if only 10, then add 00:00 so it doesn't throw a ParseException
if (dateString.length() == 10) {
}
}
- if (streamedInput != null) {
- for (int i = 0; i < streamedInput.size(); i++) {
- sql.append(",").append(streamedInput.get(i)).append("=?");
- }
- }
-
sql.append(" where id=").append(id);
logger.info("UPDATE: " + sql);
con.setAutoCommit(false);
pstmt = con.prepareStatement(sql.toString());
- if (streamedInput != null) {
- for (int i = 0; i < streamedInput.size(); i++) {
- String inputString =
- theEntity.getValue((String) streamedInput.get(i));
- pstmt.setBytes(i + 1, inputString.getBytes());
- }
- }
-
pstmt.executeUpdate();
}
catch (SQLException sqe) {
String uniqueId = id;
if (theEntityClass.equals(StorableObjectEntity.class)) {
- uniqueId += ("@" + theTable);
+ uniqueId += ("@" + mainTable);
}
logger.debug("CACHE: (del) " + id);
o_store.invalidate(search_sid);
}
- /** @todo could be prepared Statement */
+ /** todo could be prepared Statement */
Statement stmt = null;
Connection con = null;
int res = 0;
String sql =
- "delete from " + theTable + " where " + thePKeyName + "='" + id + "'";
+ "delete from " + mainTable + " where " + primaryKeyField + "='" + id + "'";
//theLog.printInfo("DELETE " + sql);
try {
Connection con = null;
int res = 0;
String sql =
- "delete from " + theTable + " where " + aWhereClause;
+ "delete from " + mainTable + " where " + aWhereClause;
//theLog.printInfo("DELETE " + sql);
try {
return false;
}
- /* invalidates the popupCache
- */
protected void invalidatePopupCache() {
- /** @todo invalidates toooo much */
- popupCache = null;
- hashCache = null;
+ /** todo invalidates toooo much */
}
/**
* Diese Methode fuehrt den Sqlstring <i>sql</i> aus und timed im Logfile.
* @param stmt Statemnt
* @param sql Sql-String
- * @return ResultSet
- * @exception StorageObjectException
*/
public ResultSet executeSql(Statement stmt, String sql)
throws StorageObjectFailure, SQLException {
return rs;
}
- private Map processRow(ResultSet aResultSet) throws StorageObjectFailure, StorageObjectExc {
+ private Map processRow(ResultSet aResultSet) throws StorageObjectFailure {
try {
Map result = new HashMap();
ResultSetMetaData metaData = aResultSet.getMetaData();
* returns the number of rows in the table
*/
public int getSize(String mainTablePrefix, List extraTables, String where) throws SQLException, StorageObjectFailure {
-
+
long startTime = System.currentTimeMillis();
-
- String useTable = theTable;
+
+ String useTable = mainTable;
if (mainTablePrefix!=null && mainTablePrefix.trim().length()>0) {
useTable+=" "+mainTablePrefix;
}
// append extratables, if necessary
if (extraTables!=null) {
for (int i=0;i < extraTables.size();i++) {
- if (!extraTables.get(i).equals("")) {
+ if (!extraTables.get(i).equals("")) {
countSql.append( ", " + extraTables.get(i));
}
}
/**
* Wertet ResultSetMetaData aus und setzt interne Daten entsprechend
* @param md ResultSetMetaData
- * @exception StorageObjectException
*/
private void evalMetaData(ResultSetMetaData md) throws StorageObjectFailure {
this.evaluatedMetaData = true;
aType = md.getColumnType(i);
metadataTypes[i - 1] = aType;
- if (aField.equals(thePKeyName)) {
- thePKeyType = aType;
- thePKeyIndex = i;
+ if (aField.equals(primaryKeyField)) {
}
if (md.isNullable(i) == ResultSetMetaData.columnNullable) {
private void get_meta_data() throws StorageObjectFailure {
Connection con = null;
PreparedStatement pstmt = null;
- String sql = "select * from " + theTable + " where 0=1";
+ String sql = "select * from " + mainTable + " where 0=1";
try {
con = getPooledCon();
/**
* Wertet SQLException aus und wirft dannach eine StorageObjectException
* @param sqe SQLException
- * @param wo Funktonsname, in der die SQLException geworfen wurde
- * @exception StorageObjectException
+ * @param aFunction Funktonsname, in der die SQLException geworfen wurde
*/
protected void throwSQLException(SQLException sqe, String aFunction) throws StorageObjectFailure {
String state = "";
/**
* Loggt Fehlermeldung mit dem Parameter Message und wirft dannach
* eine StorageObjectException
- * @param message Nachricht mit dem Fehler
- * @exception StorageObjectException
+ * @param aMessage Nachricht mit dem Fehler
+ * @exception StorageObjectFailure
*/
void throwStorageObjectException(String aMessage) throws StorageObjectFailure {
logger.error(aMessage);
import mir.entity.Entity;
import mir.entity.EntityList;
-
/**
- * Implementiert Interface f?r die Speicherschicht.
- * Bislang gibt es in der Bibliothek nur die M?glichkeit
- * in einer Datenbank zu speichern.
- * @author RK
- * @version 29.6.1999
+ * Interface for low-level database actions.
*/
+
public interface StorageObject {
- /**
- * Dokumentation siehe Database.java
- * @param id
- * @return Entity
- * @exception StorageObjectException
- */
- abstract public Entity selectById(String id) throws StorageObjectExc;
+ public Entity selectById(String id) throws StorageObjectExc;
- /**
- * Dokumentation siehe Database.java
- * @param aField
- * @param aValue
- * @return EntityList
- * @exception StorageObjectException
- */
- abstract public EntityList selectByFieldValue(String aField, String aValue)
- throws StorageObjectFailure;
+ public EntityList selectByFieldValue(String aField, String aValue) throws StorageObjectFailure;
- /**
- * Dokumentation siehe Database.java
- * @param whereClause
- * @return EntityList
- * @exception StorageObjectException
- */
- abstract public EntityList selectByWhereClause(String whereClause)
- throws StorageObjectFailure;
+ public EntityList selectByWhereClause(String whereClause) throws StorageObjectFailure;
- /**
- * Dokumentation siehe Database.java
- * @param whereClause
- * @param offset
- * @return EntityList
- * @exception StorageObjectException
- */
- abstract public EntityList selectByWhereClause(String whereClause, int offset)
- throws StorageObjectFailure;
+ public EntityList selectByWhereClause(String whereClause, int offset) throws StorageObjectFailure;
- /**
- * Dokumentation siehe Database.java
- * @param whereClause
- * @param orderBy
- * @param offset
- * @return EntityList
- * @exception StorageObjectException
- */
- abstract public EntityList selectByWhereClause(String whereClause,
- String orderBy, int offset) throws StorageObjectFailure;
+ public EntityList selectByWhereClause(String whereClause, String orderBy, int offset) throws StorageObjectFailure;
- /**
- * Dokumentation siehe Database.java
- * @param whereClause
- * @param orderBy
- * @param offset
- * @param limit
- * @return EntityList
- * @exception StorageObjectException
- */
- abstract public EntityList selectByWhereClause(String whereClause,
- String orderBy, int offset, int limit) throws StorageObjectFailure;
-
- abstract public EntityList selectByWhereClause(String mainTablePrefix, List extraTables,
- String aWhereClause, String anOrderByClause,
- int offset, int limit) throws StorageObjectFailure;
+ public EntityList selectByWhereClause(String whereClause, String orderBy, int offset, int limit) throws StorageObjectFailure;
- /**
- * Dokumentation siehe Database.java
- * @param id
- * @return boolen
- * @exception StorageObjectException
- */
- abstract public boolean delete(String id) throws StorageObjectFailure;
+ public EntityList selectByWhereClause(String mainTablePrefix, List extraTables, String aWhereClause, String anOrderByClause, int offset, int limit) throws StorageObjectFailure;
+
+ public boolean delete(String id) throws StorageObjectFailure;
/**
* Deletes entities based on a where clause
- *
- * @param aWhereClause
- * @return
- * @throws StorageObjectFailure
*/
public int deleteByWhereClause(String aWhereClause) throws StorageObjectFailure;
- /**
- * Dokumentation siehe Database.java
- * @return ArrayList
- * @exception StorageObjectException
- */
- abstract public List getFields() throws StorageObjectFailure;
+ public List getFields() throws StorageObjectFailure;
- /**
- * Dokumentation siehe Database.java
- * @return int[]
- * @exception StorageObjectException
- */
- abstract public int[] getTypes() throws StorageObjectFailure;
+ public int[] getTypes() throws StorageObjectFailure;
- /**
- * Dokumentation siehe Database.java
- * @return ArrayList
- * @exception StorageObjectException
- */
- abstract public List getLabels() throws StorageObjectFailure;
+ public List getLabels() throws StorageObjectFailure;
- /**
- * Dokumentation siehe Database.java
- * @param a
- * @exception StorageObjectException
- */
- abstract public void update(Entity a) throws StorageObjectFailure;
-
+ public void update(Entity a) throws StorageObjectFailure;
- /**
- * Dokumentation siehe Database.java
- * @param a
- * @return String id
- * @exception StorageObjectException
- */
- abstract public String insert(Entity a) throws StorageObjectFailure;
+ public String insert(Entity a) throws StorageObjectFailure;
- /**
- * Dokumentation siehe Database.java
- * @return Class Klasse der Entity
- */
- abstract public Class getEntityClass();
+ public Class getEntityClass();
- /**
- * put your documentation comment here
- * @return
- */
- abstract public String getIdName();
+ public String getIdName();
- /**
- * Dokumentation siehe Database.java
- * @return String
- */
- abstract public String getTableName();
+ public String getTableName();
- /**
- * Dokumentation siehe Database.java
- * @return Connection
- * @exception StorageObjectException
- */
- abstract public Connection getPooledCon() throws StorageObjectFailure;
+ public Connection getPooledCon() throws StorageObjectFailure;
- /**
- *
- * @param a
- * @param sql
- * @return
- * @throws StorageObjectFailure
- * @throws SQLException
- */
- abstract public ResultSet executeSql(Statement a, String sql) throws StorageObjectFailure, SQLException;
+ public ResultSet executeSql(Statement a, String sql) throws StorageObjectFailure, SQLException;
/**
- * Executes 1 sql statement and returns the results as a <code>List</code> of <code>Map</code>s
- *
- * @param sql
- * @return
- * @throws StorageObjectFailure
- * @throws StorageObjectExc
+ * Executes 1 sql statement and returns the results as a <code>List</code> of
+ * <code>Map</code>s
*/
- abstract public List executeFreeSql(String sql, int aLimit) throws StorageObjectFailure, StorageObjectExc;
+ public List executeFreeSql(String sql, int aLimit) throws StorageObjectFailure, StorageObjectExc;
/**
* Executes 1 sql statement and returns the first result row as a <<code>Map</code>s
* (<code>null</code> if there wasn't any row)
- *
- * @param sql
- * @return
- * @throws StorageObjectFailure
- * @throws StorageObjectExc
*/
- abstract public Map executeFreeSingleRowSql(String sql) throws StorageObjectFailure, StorageObjectExc ;
+ public Map executeFreeSingleRowSql(String sql) throws StorageObjectFailure, StorageObjectExc ;
/**
* Executes 1 sql statement and returns the first column of the first result row as a <<code>String</code>s
* (<code>null</code> if there wasn't any row)
- *
- * @param sql
- * @return
- * @throws StorageObjectFailure
- * @throws StorageObjectExc
*/
- abstract public String executeFreeSingleValueSql(String sql) throws StorageObjectFailure, StorageObjectExc ;
+ public String executeFreeSingleValueSql(String sql) throws StorageObjectFailure, StorageObjectExc ;
- /**
- * @param con
- * @param stmt
- */
- abstract public void freeConnection(Connection con, Statement stmt) throws StorageObjectFailure;
+ public void freeConnection(Connection con, Statement stmt) throws StorageObjectFailure;
+
+ public int executeUpdate(Statement a, String sql) throws StorageObjectFailure, SQLException;
- abstract public int executeUpdate(Statement a, String sql) throws StorageObjectFailure, SQLException;
+ public int executeUpdate(String sql) throws StorageObjectFailure, SQLException;
- abstract public int executeUpdate(String sql) throws StorageObjectFailure, SQLException;
+ public int getSize(String where) throws SQLException, StorageObjectFailure;
- abstract public int getSize(String where) throws SQLException, StorageObjectFailure;
- abstract public int getSize(String mainTablePrefix, List extraTables, String where) throws SQLException, StorageObjectFailure;
+ public int getSize(String mainTablePrefix, List extraTables, String where) throws SQLException, StorageObjectFailure;
}
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* 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.
+ * 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.storage.store;
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* 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.
+ * 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.storage.store;
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* 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.
+ * 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.storage.store;
if (superclass != null) {
if (superclass == StorableObjectEntity.class) {
return true;
- } else {
+ }
+ else {
return extendsStorableEntity(superclass);
}
}
--- /dev/null
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two. You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries. If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mir.util;\r
+\r
+import mir.entity.Entity;\r
+\r
+/**\r
+ * Utility methods for entity manipulation\r
+ */\r
+public class EntityUtility {\r
+ /**\r
+ * This class should never get instances\r
+ */\r
+ private EntityUtility() {\r
+\r
+ }\r
+\r
+ /**\r
+ * Helper method to append a line to a field\r
+ */\r
+ public static void appendLineToField(Entity anEntity, String aFieldName, String aLine) {\r
+ StringBuffer fieldContent = new StringBuffer();\r
+ try {\r
+ fieldContent.append(StringRoutines.interpretAsString(anEntity.getFieldValue(aFieldName)));\r
+ }\r
+ catch (Throwable t) {\r
+ }\r
+ if (fieldContent.length() > 0 && fieldContent.charAt(fieldContent.length() - 1) != '\n') {\r
+ fieldContent.append('\n');\r
+ }\r
+\r
+ fieldContent.append(aLine);\r
+ anEntity.setFieldValue(aFieldName, fieldContent.toString());\r
+ }\r
+}\r
public static long parseIPAddress(String anIpAddress) throws Exception {
int[] parts = {0,0,0,0};
int i;
- long result;
List stringParts = StringRoutines.splitString(anIpAddress, ".");
if (stringParts.size()!=4)
}
public boolean mayAddUsers(EntityUsers aSubject) {
- return superusers.contains(aSubject.getValue("login"));
+ return superusers.contains(aSubject.getFieldValue("login"));
}
protected boolean isSuperUser(EntityUsers aUser) {
- return superusers.contains(aUser.getValue("login"));
+ return superusers.contains(aUser.getFieldValue("login"));
}
public void assertMayEditUser(EntityUsers aSubject, EntityUsers anObject) throws AuthorizationExc, AuthorizationFailure {
}
public boolean mayEditUser(EntityUsers aSubject, EntityUsers anObject) {
- return superusers.contains(aSubject.getValue("login"));
+ return superusers.contains(aSubject.getFieldValue("login"));
}
public boolean mayEditUsers(EntityUsers aSubject) {
- return superusers.contains(aSubject.getValue("login"));
+ return superusers.contains(aSubject.getFieldValue("login"));
}
public void assertMayDeleteUser(EntityUsers aSubject, EntityUsers anObject) throws AuthorizationExc, AuthorizationFailure {
}
public boolean mayDeleteUser(EntityUsers aSubject, EntityUsers anObject) {
- return superusers.contains(aSubject.getValue("login"));
+ return superusers.contains(aSubject.getFieldValue("login"));
}
public boolean mayDeleteUsers(EntityUsers aSubject) {
- return superusers.contains(aSubject.getValue("login"));
+ return superusers.contains(aSubject.getFieldValue("login"));
}
public boolean mayChangeUserPassword(EntityUsers aSubject, EntityUsers anObject) {
- return aSubject.getId().equals(anObject.getId()) || superusers.contains(aSubject.getValue("login"));
+ return aSubject.getId().equals(anObject.getId()) || superusers.contains(aSubject.getFieldValue("login"));
}
public void assertMayChangeUserPassword(EntityUsers aSubject, EntityUsers anObject) throws AuthorizationExc, AuthorizationFailure {
import java.util.Map;
-import mir.entity.Entity;
+import mir.entity.AbstractEntity;
import mir.storage.StorageObject;
import mir.storage.StorageObjectFailure;
import mircoders.storage.DatabaseCommentToMedia;
* This class maps one line of the comment-table to a java-object.
*
* @author $Author: zapata $
- * @version $Revision: 1.16.2.1 $ $Date: 2003/07/29 22:01:59 $
+ * @version $Revision: 1.16.2.2 $ $Date: 2004/01/18 17:30:58 $
*/
-public class EntityComment extends Entity
-{
+public class EntityComment extends AbstractEntity {
public EntityComment()
{
public void dettach(String aCommentId,String aMediaId) throws StorageObjectFailure
{
if (aMediaId!=null){
- try{
- DatabaseCommentToMedia.getInstance().delete(aCommentId, aMediaId);
- }
- catch (Exception e){
- throwStorageObjectFailure(e, "dettach: failed to get instance");
- }
-
- DatabaseContent.getInstance().setUnproduced("id="+getValue("to_media"));
+ DatabaseCommentToMedia.getInstance().delete(aCommentId, aMediaId);
+ DatabaseContent.getInstance().setUnproduced("id="+getFieldValue("to_media"));
}
}
public void attach(String aMediaId) throws StorageObjectFailure
{
if (aMediaId!=null) {
- try{
- DatabaseCommentToMedia.getInstance().addMedia(getId(), aMediaId);
- }
- catch(StorageObjectFailure e){
- throwStorageObjectFailure(e, "attach: could not get the instance");
- }
-
- DatabaseContent.getInstance().setUnproduced("id="+getValue("to_media"));
+ DatabaseCommentToMedia.getInstance().addMedia(getId(), aMediaId);
+ DatabaseContent.getInstance().setUnproduced("id="+getFieldValue("to_media"));
}
else {
logger.error("EntityContent: attach without mid");
import java.sql.Statement;
import java.util.Map;
-import mir.entity.Entity;
+import mir.entity.AbstractEntity;
import mir.log.LoggerWrapper;
import mir.storage.StorageObject;
import mir.storage.StorageObjectFailure;
-import mir.util.StringRoutines;
import mircoders.storage.DatabaseContentToMedia;
/**
* this class implements mapping of one line of the database table content
* to a java object
*
- * @version $Id: EntityContent.java,v 1.19.2.4 2003/12/21 13:32:04 zapata Exp $
+ * @version $Id: EntityContent.java,v 1.19.2.5 2004/01/18 17:30:58 zapata Exp $
* @author mir-coders group
*
*/
-public class EntityContent extends Entity
-{
+public class EntityContent extends AbstractEntity {
// constructors
public EntityContent()
setStorage(theStorage);
}
- //
- // methods
-
/**
* set is_produced flag for the article
*/
-
public void setProduced(boolean yesno) throws StorageObjectFailure
{
String value = (yesno) ? "1":"0";
- if (value.equals( getValue("is_produced") )) return;
+ if (value.equals( getFieldValue("is_produced") )) return;
Connection con=null;Statement stmt=null;
String sql = "update content set is_produced='" + value + "' where id='" + getId()+"'";
try {
- con = theStorageObject.getPooledCon();
- /** @todo should be preparedStatement: faster!! */
+ con = storageObject.getPooledCon();
+ /** todo should be preparedStatement: faster!! */
stmt = con.createStatement();
- theStorageObject.executeUpdate(stmt,sql);
+ storageObject.executeUpdate(stmt,sql);
}
catch (StorageObjectFailure e) {
- throwStorageObjectFailure(e, "\n -- set produced failed");
+ throw e;
}
catch (SQLException e) {
- throwStorageObjectFailure(e, "\n -- set produced failed");
+ throw new StorageObjectFailure(e);
}
finally {
- theStorageObject.freeConnection(con,stmt);
+ storageObject.freeConnection(con,stmt);
}
}
public void dettach(String anArticleId, String aMediaId) throws StorageObjectFailure
{
if (aMediaId!=null){
- try{
- DatabaseContentToMedia.getInstance().delete(anArticleId, aMediaId);
- }
- catch (Exception e){
- throwStorageObjectFailure(e, "\n -- failed to get instance");
- }
+ DatabaseContentToMedia.getInstance().delete(anArticleId, aMediaId);
setProduced(false);
}
}
/**
- * Attaches media to an article
- *
- * @param mid
- * @throws StorageObjectFailure
+ * Attaches media to the article
*/
public void attach(String aMediaId) throws StorageObjectFailure
{
if (aMediaId!=null) {
- try{
- DatabaseContentToMedia.getInstance().addMedia(getId(),aMediaId);
- }
- catch(StorageObjectFailure e){
- throwStorageObjectFailure(e, "attach: could not get the instance");
- }
+ DatabaseContentToMedia.getInstance().addMedia(getId(),aMediaId);
setProduced(false);
}
else {
/**
*
* @author RK, mh, mir-coders
- * @version $Id: EntityImages.java,v 1.21.2.3 2003/12/14 16:37:07 zapata Exp $
+ * @version $Id: EntityImages.java,v 1.21.2.4 2004/01/18 17:30:58 zapata Exp $
*/
Statement stmt=null;
BlobInputStream in;
InputStream img_in = null;
+
try {
- con = theStorageObject.getPooledCon();
+ con = storageObject.getPooledCon();
con.setAutoCommit(false);
LargeObjectManager lom;
java.sql.Connection jCon;
stmt = con.createStatement();
- ResultSet rs = theStorageObject.executeSql(stmt,
+ ResultSet rs = storageObject.executeSql(stmt,
"select image_data from images where id="+getId());
jCon = ((com.codestudio.sql.PoolManConnectionHandle)con)
.getNativeConnection();
}
try {
- theStorageObject.freeConnection(con, stmt);
+ storageObject.freeConnection(con, stmt);
}
catch (Throwable e) {
logger.error("EntityImages.getImage freeing connection failed: " +e.toString());
}
- throwStorageObjectFailure(t, "EntityImages -- getImage failed: ");
+ throw new StorageObjectFailure(t);
}
+
return img_in;
}
public void setImage(InputStream in, String type) throws StorageObjectFailure {
-
+ // todo: failures should be treated in a better way: exception -> rollback instead
+ // of commit
if (in != null) {
Connection con = null;
FileUtil.write(f, in);
ImageProcessor processor = new ImageProcessor(f);
- con = theStorageObject.getPooledCon();
+ con = storageObject.getPooledCon();
con.setAutoCommit(false);
LargeObjectManager lom;
java.sql.Connection connection;
processor.descaleImage(maxImageSize, minDescaleRatio, minDescaleReduction);
processor.writeScaledData(lobImage.getOutputStream(), type);
lobImage.close();
- setValueForProperty("img_height", new Integer(processor.getScaledHeight()).toString());
- setValueForProperty("img_width", new Integer(processor.getScaledWidth()).toString());
+ setFieldValue("img_height", new Integer(processor.getScaledHeight()).toString());
+ setFieldValue("img_width", new Integer(processor.getScaledWidth()).toString());
int oidIcon = lom.create();
LargeObject lobIcon = lom.open(oidIcon);
processor.writeScaledData(lobIcon.getOutputStream(), type);
lobIcon.close();
- setValueForProperty("icon_height", new Integer(processor.getScaledHeight()).toString());
- setValueForProperty("icon_width", new Integer(processor.getScaledWidth()).toString());
+ setFieldValue("icon_height", new Integer(processor.getScaledHeight()).toString());
+ setFieldValue("icon_width", new Integer(processor.getScaledWidth()).toString());
- setValueForProperty("image_data", new Integer(oidImage).toString());
- setValueForProperty("icon_data", new Integer(oidIcon).toString());
+ setFieldValue("image_data", new Integer(oidImage).toString());
+ setFieldValue("icon_data", new Integer(oidIcon).toString());
update();
}
catch (Exception e) {
- throwStorageObjectFailure(e, "settimage :: setImage failed: ");
+ throw new StorageObjectFailure(e);
}
finally {
try {
if (con!=null)
con.setAutoCommit(true);
// get rid of the temp. file
+ }
+ catch (Throwable e) {
+ logger.error("EntityImages.setImage: unable to reset the connection to auto-commit:" + e.toString());
+ }
+ try {
f.delete();
- } catch (SQLException e) {
- throwStorageObjectFailure(e,"Resetting transaction-mode failed");
}
- if (con!=null)
- theStorageObject.freeConnection(con,pstmt);
+ catch (Throwable t) {
+ logger.error("EntityImages.setImage: unable to delete the temporary file:" + t.toString());
+ }
+
+ try {
+ if (con!=null)
+ storageObject.freeConnection(con,pstmt);
+ }
+ catch (Throwable t) {
+ logger.error("EntityImages.setImage: unable to free the connection:" + t.toString());
+ }
}
}
}
ImageInputStream img_in=null;
try {
- con = theStorageObject.getPooledCon();
+ con = storageObject.getPooledCon();
con.setAutoCommit(false);
LargeObjectManager lom;
java.sql.Connection jCon;
stmt = con.createStatement();
- ResultSet rs = theStorageObject.executeSql(stmt, "select icon_data from images where id="+getId());
+ ResultSet rs = storageObject.executeSql(stmt, "select icon_data from images where id="+getId());
jCon = ((com.codestudio.sql.PoolManConnectionHandle)con)
.getNativeConnection();
lom = ((org.postgresql.Connection)jCon).getLargeObjectAPI();
e.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));
}
try {
- theStorageObject.freeConnection(con, stmt);
+ storageObject.freeConnection(con, stmt);
}
catch (Throwable e) {
logger.error("EntityImages -- freeing connection failed: " + e.getMessage());
}
- throwStorageObjectFailure(t, "EntityImages -- getIcon failed:");
+ throw new StorageObjectFailure(t);
}
return img_in;
_in.close();
try {
_con.setAutoCommit(true);
- theStorageObject.freeConnection(_con,_stmt);
+ storageObject.freeConnection(_con,_stmt);
}
catch (Exception e) {
throw new IOException("close(): "+e.toString());
package mircoders.entity;
import java.sql.SQLException;
-import java.util.List;
import java.util.Map;
+import mir.entity.AbstractEntity;
import mir.entity.Entity;
import mir.log.LoggerWrapper;
-import mircoders.media.MediaHelper;
-import mir.media.MediaHandler;
-import mir.misc.NumberUtils;
import mir.storage.StorageObject;
import mir.storage.StorageObjectFailure;
import mircoders.storage.DatabaseUploadedMedia;
/**
*
* @author mh, mir-coders group
- * @version $Id: EntityUploadedMedia.java,v 1.26.2.5 2003/12/21 13:32:04 zapata Exp $
+ * @version $Id: EntityUploadedMedia.java,v 1.26.2.6 2004/01/18 17:30:58 zapata Exp $
*/
-
-public class EntityUploadedMedia extends Entity {
+public class EntityUploadedMedia extends AbstractEntity {
public EntityUploadedMedia() {
super();
super.update();
try {
- theStorageObject.executeUpdate( "update content set is_produced='0' where exists(select * from content_x_media where content_id=content.id and media_id=" + getId()+")");
- theStorageObject.executeUpdate( "update content set is_produced='0' where exists(select * from comment_x_media, comment where comment_x_media.comment_id=comment.id and comment.to_media=content.id and comment_x_media.media_id=" + getId()+")");
+ storageObject.executeUpdate( "update content set is_produced='0' where exists(select * from content_x_media where content_id=content.id and media_id=" + getId()+")");
+ storageObject.executeUpdate( "update content set is_produced='0' where exists(select * from comment_x_media, comment where comment_x_media.comment_id=comment.id and comment.to_media=content.id and comment_x_media.media_id=" + getId()+")");
}
catch (SQLException e) {
- throwStorageObjectFailure(e, "EntityUploadedMedia :: update :: failed!! ");
+ throw new StorageObjectFailure(e);
}
}
ent = DatabaseUploadedMedia.getInstance().getMediaType(this);
}
catch (StorageObjectFailure e) {
- throwStorageObjectFailure(e, "get MediaType failed -- ");
+ throw new StorageObjectFailure(e);
}
return ent;
}
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* 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.
+ * 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 mircoders.entity;
import mir.entity.Entity;
+import mir.entity.AbstractEntity;
import mir.storage.StorageObject;
/**
*/
-public class EntityUsers extends Entity
-{
+public class EntityUsers extends AbstractEntity {
public EntityUsers()
{
public boolean isAdmin()
{
- String admin=getValue("is_admin");
+ String admin=getFieldValue("is_admin");
//theLog.printDebugInfo("admin::::"+admin);
return (admin!=null&&admin.equals("1"))?true:false;
}
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* 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.
+ * 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 mircoders.entity;
import mir.util.DateTimeFunctions;
import mir.util.GeneratorFormatAdapters;
import mir.util.StringRoutines;
+import mir.util.EntityUtility;
import mircoders.entity.EntityComment;
import mircoders.entity.EntityContent;
import mircoders.localizer.MirAdminInterfaceLocalizer;
line.append(" ");
line.append(filterRule.getType() +" ("+ filterRule.getExpression()+")");
- aComment.appendLineToField("comment", line.toString());
+ EntityUtility.appendLineToField(aComment, "comment", line.toString());
MirGlobal.performCommentOperation(null, aComment, filterRule.getCommentAction());
setCookie(aResponse);
line.append(" ");
line.append(filterRule.getType() +" ("+ filterRule.getExpression()+")");
- anArticle.appendLineToField("comment", line.toString());
+ EntityUtility.appendLineToField(anArticle, "comment", line.toString());
MirGlobal.performArticleOperation(null, anArticle, filterRule.getArticleAction());
setCookie(aResponse);
moveFilter(filterRules, anIdentifier, 1);
}
+ public void moveFilterToTop(String anIdentifier) {
+ setFilterPosition(filterRules, anIdentifier, 0);
+ }
+
+ public void moveFilterToBottom(String anIdentifier) {
+ setFilterPosition(filterRules, anIdentifier, Integer.MAX_VALUE);
+ }
+
private String addFilter(List aFilters, String aType, String anExpression, String aComments, String aCommentAction, String anArticleAction, Date aLastHit) {
MirAntiAbuseFilterType type = (MirAntiAbuseFilterType) filterTypes.get(aType);
return null;
}
+ private void setFilterPosition(List aFilters, String anIdentifier, int aPosition) {
+ synchronized (aFilters) {
+ if (aPosition<0)
+ aPosition=0;
+
+ for (int i = 0; i < aFilters.size(); i++) {
+ FilterRule rule = (FilterRule) aFilters.get(i);
+
+ if (rule.getId().equals(anIdentifier)) {
+ aFilters.remove(rule);
+
+ if (aPosition<aFilters.size())
+ aFilters.add(aPosition, rule);
+ else
+ aFilters.add(rule);
+ break;
+ }
+ }
+ }
+ }
private void moveFilter(List aFilters, String anIdentifier, int aDirection) {
synchronized (aFilters) {
for (int i = 0; i < aFilters.size(); i++) {
if (config().getString("Mir.Admin.LogAdminActivity", "0").equals("1")) {\r
String user = "unknown (" + aUser.toString() + ")";\r
if (aUser != null)\r
- user = aUser.getValue("login");\r
+ user = aUser.getFieldValue("login");\r
adminUsageLogger.info(user + " | " + anObject + " | " + aDescription);\r
}\r
}\r
import mir.misc.StringUtil;
import mir.storage.StorageObjectFailure;
import mir.util.DateTimeFunctions;
+import mir.util.EntityUtility;
import mircoders.entity.EntityComment;
import mircoders.entity.EntityContent;
import mircoders.global.MirGlobal;
line.append(" ");
line.append(getName());
- entity.appendLineToField("comment", line.toString());
+ EntityUtility.appendLineToField(entity, "comment", line.toString());
}
catch (Throwable t) {
logger.error("Error while trying to log an article operation: " + t.toString());
protected void performModification(EntityAdapter aUser, Entity anEntity) throws StorageObjectFailure {
performModification(aUser, (EntityComment) anEntity);
- DatabaseContent.getInstance().setUnproduced("id="+anEntity.getValue("to_media"));
+ DatabaseContent.getInstance().setUnproduced("id="+anEntity.getFieldValue("to_media"));
};
protected abstract boolean isAvailable(EntityComment aComment) throws StorageObjectFailure ;
protected void performModification(EntityAdapter aUser, Entity anEntity) throws StorageObjectFailure {
performModification(aUser, (EntityContent) anEntity);
- anEntity.setValueForProperty("is_produced", "0");
+ anEntity.setFieldValue("is_produced", "0");
};
protected abstract boolean isAvailable(EntityContent anArticle) throws StorageObjectFailure ;
}
protected void performModification(EntityAdapter aUser, EntityComment aComment) throws StorageObjectFailure {
- aComment.setValueForProperty(field, value);
+ aComment.setFieldValue(field, value);
}
}
while (i.hasNext()) {
Map.Entry entry = (Map.Entry) i.next();
- aComment.setValueForProperty((String) entry.getKey(), (String) entry.getValue());
+ aComment.setFieldValue((String) entry.getKey(), (String) entry.getValue());
}
}
}
}
protected boolean isAvailable(EntityComment aComment) {
- return aComment.getValue(field) == null || !aComment.getValue(field).equals(value);
+ return aComment.getFieldValue(field) == null || !aComment.getFieldValue(field).equals(value);
}
protected void performModification(EntityAdapter aUser, EntityComment aComment) throws StorageObjectFailure {
- aComment.setValueForProperty(field, value);
+ aComment.setFieldValue(field, value);
}
}
}
protected void performModification(EntityAdapter aUser, EntityContent anArticle) throws StorageObjectFailure {
- anArticle.setValueForProperty(field, value);
+ anArticle.setFieldValue(field, value);
}
}
}
protected boolean isAvailable(EntityContent anArticle) {
- return anArticle.getValue(field) == null || !anArticle.getValue(field).equals(value);
+ return anArticle.getFieldValue(field) == null || !anArticle.getFieldValue(field).equals(value);
}
protected void performModification(EntityAdapter aUser, EntityContent anArticle) throws StorageObjectFailure {
- anArticle.setValueForProperty(field, value);
+ anArticle.setFieldValue(field, value);
}
}
}
protected boolean isAvailable(EntityContent anArticle) {
- return anArticle.getValue(field) != null && oldValues.contains(anArticle.getValue(field));
+ return anArticle.getFieldValue(field) != null && oldValues.contains(anArticle.getFieldValue(field));
}
protected void performModification(EntityAdapter aUser, EntityContent anArticle) throws StorageObjectFailure {
- anArticle.setValueForProperty(field, newValue);
+ anArticle.setFieldValue(field, newValue);
}
}
}
if (selectedFields != null)
j = selectedFields.iterator();
else
- j = anEntity.getFields().iterator();
+ j = anEntity.getFieldNames().iterator();
while (j.hasNext()) {
- String field = anEntity.getValue( (String) j.next());
+ String field = anEntity.getFieldValue( (String) j.next());
if (exactMatch) {
if (field != null && regularExpression.isMatch(field)) {
public void finalizeArticle(Request aRequest, Session aSession, EntityContent anArticle) throws SessionExc, SessionFailure {
try {
- anArticle.setValueForProperty("is_published", "1");
- anArticle.setValueForProperty("is_produced", "0");
- anArticle.setValueForProperty("date", StringUtil.date2webdbDate(new GregorianCalendar()));
- anArticle.setValueForProperty("is_html", "0");
- anArticle.setValueForProperty("publish_path", StringUtil.webdbDate2path(anArticle. getValue("date")));
+ anArticle.setFieldValue("is_published", "1");
+ anArticle.setFieldValue("is_produced", "0");
+ anArticle.setFieldValue("date", StringUtil.date2webdbDate(new GregorianCalendar()));
+ anArticle.setFieldValue("is_html", "0");
+ anArticle.setFieldValue("publish_path", StringUtil.webdbDate2path(anArticle. getFieldValue("date")));
ModuleArticleType module = new ModuleArticleType(DatabaseArticleType.getInstance());
- anArticle.setValueForProperty("to_article_type", module.articleTypeIdForName(configuration.getString("Localizer.OpenSession.article.DefaultArticleType")));
- anArticle.setValueForProperty("to_publisher", "1");
+ anArticle.setFieldValue("to_article_type", module.articleTypeIdForName(configuration.getString("Localizer.OpenSession.article.DefaultArticleType")));
+ anArticle.setFieldValue("to_publisher", "1");
}
catch (Throwable t) {
throw new SessionFailure(t);
public void finalizeArticle(Request aRequest, Session aSession, EntityContent anArticle) throws SessionExc, SessionFailure {
super.finalizeArticle(aRequest, aSession, anArticle);
- anArticle.setValueForProperty("to_content", (String) aSession.getAttribute("to_content"));
+ anArticle.setFieldValue("to_content", (String) aSession.getAttribute("to_content"));
}
protected void initializeSession(Request aRequest, Session aSession) throws SessionExc, SessionFailure {
public void finalizeComment(Request aRequest, Session aSession, EntityComment aComment) throws SessionExc, SessionFailure {
try {
- aComment.setValueForProperty("is_published", "1");
+ aComment.setFieldValue("is_published", "1");
ModuleCommentStatus module = new ModuleCommentStatus(DatabaseCommentStatus.getInstance());
- aComment.setValueForProperty("to_comment_status", module.commentStatusIdForName(configuration.getString("Localizer.OpenSession.comment.DefaultCommentStatus")));
- aComment.setValueForProperty("is_html", "0");
- aComment.setValueForProperty("to_media", (String) aSession.getAttribute("to_media"));
+ aComment.setFieldValue("to_comment_status", module.commentStatusIdForName(configuration.getString("Localizer.OpenSession.comment.DefaultCommentStatus")));
+ aComment.setFieldValue("is_html", "0");
+ aComment.setFieldValue("to_media", (String) aSession.getAttribute("to_media"));
}
catch (Throwable t) {
throw new SessionFailure(t);
catch (Throwable t) {
throw new SessionFailure(t);
}
- DatabaseContent.getInstance().setUnproduced("id=" + comment.getValue("to_media"));
+ DatabaseContent.getInstance().setUnproduced("id=" + comment.getFieldValue("to_media"));
logger.info("Comment posted");
};
protected class ContentToParentField implements EntityAdapterDefinition.CalculatedField {\r
public Object getValue(EntityAdapter anEntityAdapter) {\r
try {\r
- logger.debug("ContentToParentField.getValue");\r
+ logger.debug("ContentToParentField.getFieldValue");\r
return anEntityAdapter.getToOneRelation(\r
"id="+anEntityAdapter.get("to_content"),\r
"id",\r
}\r
}\r
}\r
+\r
protected class ContentToUserField implements EntityAdapterDefinition.CalculatedField {\r
- /**\r
- *\r
- * @param aFieldName the source field. will be mapped to the id field in the user\r
- * table\r
- */\r
private String fieldName;\r
\r
public ContentToUserField(String aFieldName) {\r
*
* @see mir.media.MirMediaHandler
* @author mh <mh@nadir.org>
- * @version $Id: MediaHandlerGeneric.java,v 1.20.2.5 2003/12/14 16:37:07 zapata Exp $
+ * @version $Id: MediaHandlerGeneric.java,v 1.20.2.6 2004/01/18 17:30:58 zapata Exp $
*/
public class MediaHandlerGeneric implements MediaHandler
}
public void store (InputStream in, Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure {
- String ext = mediaTypeEnt.getValue("name");
+ String ext = mediaTypeEnt.getFieldValue("name");
String mediaFname = ent.getId() + "." + ext;
- String date = ent.getValue("date");
+ String date = ent.getFieldValue("date");
String datePath = StringUtil.webdbDate2path(date);
try {
long size = FileUtil.write(getStoragePath() + File.separator + datePath +
File.separator + mediaFname, in);
- ent.setValueForProperty("publish_path", datePath + mediaFname);
- ent.setValueForProperty("size", new Long(size).toString());
+ ent.setFieldValue("publish_path", datePath + mediaFname);
+ ent.setFieldValue("size", new Long(size).toString());
ent.update();
}
catch (Throwable e) {
//check first if the media file exist since produced
//location is also the storage location
- String date = ent.getValue("date");
+ String date = ent.getFieldValue("date");
String datePath = StringUtil.webdbDate2path(date);
- String relPath = datePath+ent.getId()+"."+mediaTypeEnt.getValue("name");
+ String relPath = datePath+ent.getId()+"."+mediaTypeEnt.getFieldValue("name");
String fname = getStoragePath()+relPath;
if(! new File(fname).exists())
throw new MediaExc("error in MirMediaHandler.produce(): " + relPath + " does not exist!");
}
public InputStream getMedia (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure {
- String publishPath = ent.getValue("publish_path");
+ String publishPath = ent.getFieldValue("publish_path");
String fname = getStoragePath()+publishPath;
File f = new File(fname);
if(! f.exists())
public String getThumbnailMimeType (Entity aMediaEntity, Entity aMediaType) throws MediaExc, MediaFailure {
ServletContext servletContext = MirPropertiesConfiguration.getContext();
- String fileName = aMediaEntity.getId()+"."+aMediaType.getValue("name");
+ String fileName = aMediaEntity.getId()+"."+aMediaType.getFieldValue("name");
return servletContext.getMimeType(fileName);
};
public String getDescr( Entity mediaType)
{
- return mediaType.getValue("mime_type");
+ return mediaType.getFieldValue("mime_type");
}
}
*
* @see mir.media.MirMediaHandler
* @author mh
- * @version $Id: MediaHandlerImages.java,v 1.23.2.3 2003/12/14 16:37:07 zapata Exp $
+ * @version $Id: MediaHandlerImages.java,v 1.23.2.4 2004/01/18 17:30:58 zapata Exp $
*/
}
public void produce(Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure {
- String date = ent.getValue("date");
+ String date = ent.getFieldValue("date");
String datePath = StringUtil.webdbDate2path(date);
- String ext = "."+mediaTypeEnt.getValue("name");
+ String ext = "."+mediaTypeEnt.getFieldValue("name");
String filepath = datePath+ent.getId()+ext;
String iconFilePath = configuration.getString("Producer.StorageRoot")
+getIconStoragePath() + filepath;
String productionFilePath = getStoragePath() + File.separator + filepath;
- if (ent.getValue("icon_data")!= null &&
- ent.getValue("image_data")!= null) {
+ if (ent.getFieldValue("icon_data")!= null &&
+ ent.getFieldValue("image_data")!= null) {
// make icon
try {
InputStream in = ((EntityImages)ent).getIcon();
FileUtil.write(iconFilePath, in);
in = ((EntityImages)ent).getImage();
FileUtil.write(productionFilePath, in);
- ent.setValueForProperty("icon_path",getIconStoragePath()+filepath);
- ent.setValueForProperty("publish_path",filepath);
+ ent.setFieldValue("icon_path",getIconStoragePath()+filepath);
+ ent.setFieldValue("publish_path",filepath);
ent.update();
}
catch (Throwable e) {
public void produce(Entity anImageEntity, Entity mediaTypeEnt) throws MediaExc, MediaFailure {
try {
- String date = anImageEntity.getValue("date");
+ String date = anImageEntity.getFieldValue("date");
String datePath = StringUtil.webdbDate2path(date);
- String ext = "." + mediaTypeEnt.getValue("name");
+ String ext = "." + mediaTypeEnt.getFieldValue("name");
String fileBasePath = datePath + anImageEntity.getId();
String filePath = fileBasePath + ext;
String iconPath = getIconStoragePath() + fileBasePath + ".jpg";
}
processor.writeScaledData(iconFile, "JPEG");
- anImageEntity.setValueForProperty("img_height", new Integer(processor.getHeight()).toString());
- anImageEntity.setValueForProperty("img_width", new Integer(processor.getWidth()).toString());
+ anImageEntity.setFieldValue("img_height", new Integer(processor.getHeight()).toString());
+ anImageEntity.setFieldValue("img_width", new Integer(processor.getWidth()).toString());
- anImageEntity.setValueForProperty("icon_height", new Integer(processor.getScaledHeight()).toString());
- anImageEntity.setValueForProperty("icon_width", new Integer(processor.getScaledWidth()).toString());
+ anImageEntity.setFieldValue("icon_height", new Integer(processor.getScaledHeight()).toString());
+ anImageEntity.setFieldValue("icon_width", new Integer(processor.getScaledWidth()).toString());
- anImageEntity.setValueForProperty("icon_path", iconPath);
- anImageEntity.setValueForProperty("publish_path", filePath);
+ anImageEntity.setFieldValue("icon_path", iconPath);
+ anImageEntity.setFieldValue("publish_path", filePath);
anImageEntity.update();
public InputStream getIcon(Entity anImageEntity) throws MediaExc, MediaFailure {
try {
String filePath =
- configuration.getString("Producer.StorageRoot") + anImageEntity.getValue("icon_path");
+ configuration.getString("Producer.StorageRoot") + anImageEntity.getFieldValue("icon_path");
logger.info(filePath);
*
* @see mir.media.MediaHandler
* @author mh <mh@nadir.org>
- * @version $Id: MediaHandlerMp3.java,v 1.15.2.3 2003/12/14 16:37:08 zapata Exp $
+ * @version $Id: MediaHandlerMp3.java,v 1.15.2.4 2004/01/18 17:30:59 zapata Exp $
*/
public class MediaHandlerMp3 extends MediaHandlerAudio implements MediaHandler
super.produce(ent, mediaTypeEnt);
String baseName = ent.getId();
- String date = ent.getValue("date");
+ String date = ent.getFieldValue("date");
String datePath = StringUtil.webdbDate2path(date);
- String mp3Pointer = getPublishHost() + ent.getValue("publish_path");
+ String mp3Pointer = getPublishHost() + ent.getFieldValue("publish_path");
String mpegURLFile = baseName + ".m3u";
String playlistFile = baseName + ".pls";
public List getURL(Entity ent, Entity mediaTypeEnt) {
List theList = new Vector();
- //String stringSize = ent.getValue("size");
+ //String stringSize = ent.getFieldValue("size");
//int size = Integer.parseInt(stringSize, 10)/1024;
theList.add(ent);
- String basePath = StringUtil.regexpReplace(ent.getValue("publish_path"),
+ String basePath = StringUtil.regexpReplace(ent.getFieldValue("publish_path"),
".mp3$", "");
// @todo the texts ("title") below urgently need to be sanely localizaeble
// somehow
Map m3uHash = new HashMap();
m3uHash.put("publish_path", basePath + ".m3u");
- m3uHash.put("publish_server", ent.getValue("publish_server"));
+ m3uHash.put("publish_server", ent.getFieldValue("publish_server"));
m3uHash.put("title", "stream URL");
theList.add(m3uHash);
Map plsHash = new HashMap();
plsHash.put("publish_path", basePath + ".pls");
- plsHash.put("publish_server", ent.getValue("publish_server"));
+ plsHash.put("publish_server", ent.getFieldValue("publish_server"));
plsHash.put("title", "playlist URL");
theList.add(plsHash);
super.produce(ent, mediaTypeEnt);
String baseName = ent.getId();
- String date = ent.getValue("date");
+ String date = ent.getFieldValue("date");
String datePath = StringUtil.webdbDate2path(date);
- String oggPointer = getPublishHost() + ent.getValue("publish_path");
+ String oggPointer = getPublishHost() + ent.getFieldValue("publish_path");
//String mpegURLFile = baseName + ".m3u";
String playlistFile = baseName + ".pls";
public List getURL(Entity ent, Entity mediaTypeEnt) {
List theList = new Vector();
- //String stringSize = ent.getValue("size");
+ //String stringSize = ent.getFieldValue("size");
//int size = Integer.parseInt(stringSize, 10)/1024;
theList.add(ent);
- String basePath = StringUtil.regexpReplace(ent.getValue("publish_path"),
+ String basePath = StringUtil.regexpReplace(ent.getFieldValue("publish_path"),
".ogg$", "");
// @todo the texts ("title") below urgently need to be sanely localizaeble
//no .m3u!
//Map m3uHash = new HashMap();
//m3uHash.put("publish_path", basePath + ".m3u");
- //m3uHash.put("publish_server", ent.getValue("publish_server"));
+ //m3uHash.put("publish_server", ent.getFieldValue("publish_server"));
//m3uHash.put("title", "stream URL");
//theList.add(m3uHash);
Map plsHash = new HashMap();
plsHash.put("publish_path", basePath + ".pls");
- plsHash.put("publish_server", ent.getValue("publish_server"));
+ plsHash.put("publish_server", ent.getFieldValue("publish_server"));
plsHash.put("title", "playlist URL");
theList.add(plsHash);
* @see mir.media.MediaHandlerGeneric
* @see mir.media.MediaHandler
* @author john <john@manifestor.org>, mh <heckmann@hbe.ca>
- * @version $Id: MediaHandlerRealAudio.java,v 1.19.2.3 2003/12/21 13:32:05 zapata Exp $
+ * @version $Id: MediaHandlerRealAudio.java,v 1.19.2.4 2004/01/18 17:30:59 zapata Exp $
*/
super.produce(ent, mediaTypeEnt);
String baseName = ent.getId();
- String date = ent.getValue("date");
+ String date = ent.getFieldValue("date");
String datePath = StringUtil.webdbDate2path(date);
String rtspDir = configuration.getString("Producer.RealMedia.Path");
String rtspMediaHost = configuration.getString("Producer.RealMedia.Host");
- String RealMediaPointer = rtspMediaHost+ent.getValue("publish_path");
+ String RealMediaPointer = rtspMediaHost+ent.getFieldValue("publish_path");
String RealMediaFile = datePath+ent.getId()+".ram";
try {
//write an rm (ram?. -mh) file
{
List theList = new Vector();
- //String stringSize = ent.getValue("size");
+ //String stringSize = ent.getFieldValue("size");
//int size = Integer.parseInt(stringSize, 10)/1024;
theList.add(ent);
- String basePath=StringUtil.regexpReplace(ent.getValue("publish_path"),
+ String basePath=StringUtil.regexpReplace(ent.getFieldValue("publish_path"),
".ra$","");
// @todo the texts ("title") below urgently need to be sanely localizaeble
* @see mir.media.MediaHandlerGeneric
* @see mir.media.MediaHandler
* @author john <john@manifestor.org>, mh <mh@nadir.org>
- * @version $Id: MediaHandlerRealVideo.java,v 1.19.2.3 2003/12/14 16:37:08 zapata Exp $
+ * @version $Id: MediaHandlerRealVideo.java,v 1.19.2.4 2004/01/18 17:30:59 zapata Exp $
*/
super.produce(ent, mediaTypeEnt);
String baseName = ent.getId();
- String date = ent.getValue("date");
+ String date = ent.getFieldValue("date");
String datePath = StringUtil.webdbDate2path(date);
String rtspDir = configuration.getString("Producer.RealMedia.Path");
String rtspMediaHost = configuration.getString("Producer.RealMedia.Host");
- String RealMediaPointer = rtspMediaHost+ent.getValue("publish_path");
+ String RealMediaPointer = rtspMediaHost+ent.getFieldValue("publish_path");
String RealMediaFile = datePath+ent.getId()+".ram";
try {
//write an rm (ram?. -mh) file
public List getURL(Entity ent, Entity mediaTypeEnt) {
List theList = new Vector();
- //String stringSize = ent.getValue("size");
+ //String stringSize = ent.getFieldValue("size");
//int size = Integer.parseInt(stringSize, 10)/1024;
theList.add(ent);
- String basePath=StringUtil.regexpReplace(ent.getValue("publish_path"),
+ String basePath=StringUtil.regexpReplace(ent.getFieldValue("publish_path"),
".rm$","");
// @todo the texts ("title") below urgently need to be sanely localizaeble
}
public static MediaHandler getHandler(Entity aMediaType) throws MediaExc, MediaFailure {
- String handlerName = aMediaType.getValue("classname");
+ String handlerName = aMediaType.getFieldValue("classname");
try {
return MirGlobal.localizer().media().getHandler(handlerName);
try {
mediaHandler = MediaHelper.getHandler(mediaType);
- mediaStorage = MediaHelper.getStorage(mediaType, mediaType.getValue("tablename"));
+ mediaStorage = MediaHelper.getStorage(mediaType, mediaType.getFieldValue("tablename"));
}
catch (Throwable e) {
throw new MediaFailure(e);
public List getURL(Entity aMediaEntity, Entity aMediaTypeEntity) throws MediaExc, MediaFailure {
List result = new ArrayList();
- result.add(aMediaTypeEntity.getValue("publish_server")+aMediaTypeEntity.getValue("publish_path"));
+ result.add(aMediaTypeEntity.getFieldValue("publish_server")+aMediaTypeEntity.getFieldValue("publish_path"));
return result;
}
if (theStorage == null)
logger.warn("ModuleArticleType -- StorageObject was null!");
- this.theStorage = theStorage;
+ this.storage = theStorage;
}
public String articleTypeIdForName(String aName) throws ModuleExc, ModuleFailure {
try {
- return theStorage.executeFreeSingleValueSql("select id from article_type where name = '" + JDBCStringRoutines.escapeStringLiteral(aName) + "'");
+ return storage.executeFreeSingleValueSql("select id from article_type where name = '" + JDBCStringRoutines.escapeStringLiteral(aName) + "'");
}
catch (Throwable t) {
throw new ModuleFailure(t);
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* 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.
+ * 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 mircoders.module;
-import mir.entity.EntityList;
import mir.log.LoggerWrapper;
import mir.module.AbstractModule;
import mir.storage.StorageObject;
public ModuleBreaking (StorageObject theStorage)
{
if (theStorage == null) logger.warn("ModuleBreaking -- StorageObject was null!");
- this.theStorage = theStorage;
+ this.storage = theStorage;
}
// Methoden
- public EntityList getBreakingNews() {
- EntityList returnList = null;
- try {
- returnList = getByWhereClause(null,"webdb_create desc",0,5);
- }
- catch (Exception ex) {
- logger.error("--getBreakingNews(): could not fetch Breaking News" + ex.toString());
- }
- return returnList;
- }
}
public ModuleComment(StorageObject theStorage)
{
if (theStorage == null) logger.warn("StorageObject was null!");
- this.theStorage = theStorage;
+ this.storage = theStorage;
}
public void deleteById (String anId) throws ModuleExc, ModuleFailure {
try {
- Entity theEntity = theStorage.selectById((String)anId);
+ Entity theEntity = storage.selectById((String)anId);
if (theEntity != null)
- DatabaseContent.getInstance().setUnproduced("id=" + theEntity.getValue("to_media"));
+ DatabaseContent.getInstance().setUnproduced("id=" + theEntity.getFieldValue("to_media"));
super.deleteById(anId);
}
public String set(Map theValues) throws ModuleExc, ModuleFailure {
try {
- Entity theEntity = theStorage.selectById((String)theValues.get("id"));
+ Entity theEntity = storage.selectById((String)theValues.get("id"));
if (theEntity == null)
throw new ModuleExc("No Object in the database with id " + theValues.get("id"));
- DatabaseContent.getInstance().setUnproduced("id=" + theEntity.getValue("to_media"));
+ DatabaseContent.getInstance().setUnproduced("id=" + theEntity.getFieldValue("to_media"));
theEntity.setValues(theValues);
theEntity.update();
return theEntity.getId();
if (theStorage == null)
logger.warn("ModuleCommentStatus -- StorageObject was null!");
- this.theStorage = theStorage;
+ this.storage = theStorage;
}
public String commentStatusIdForName(String aName) throws ModuleExc, ModuleFailure {
try {
- return theStorage.executeFreeSingleValueSql("select id from comment_status where name = '" + JDBCStringRoutines.escapeStringLiteral(aName) + "'");
+ return storage.executeFreeSingleValueSql("select id from comment_status where name = '" + JDBCStringRoutines.escapeStringLiteral(aName) + "'");
}
catch (Throwable t) {
throw new ModuleFailure(t);
}
public ModuleContent(StorageObject aStorage) {
- theStorage = aStorage;
+ storage = aStorage;
}
public void expireArticleLock(String anId, String aUserId) {
if (!aForce)
query = query + " and to_locking_user is null";
- return theStorage.executeUpdate(query) > 0;
+ return storage.executeUpdate(query) > 0;
}
catch (Throwable t) {
return false;
if (!aForce)
query = query + " and to_locking_user = "+JDBCStringRoutines.escapeStringLiteral(aUserId);
- return theStorage.executeUpdate(query) > 0;
+ return storage.executeUpdate(query) > 0;
}
catch (Throwable t) {
return false;
*/
public String queryArticleLock(String anId) {
try {
- String result = theStorage.executeFreeSingleValueSql("select to_locking_user from content where id = " + JDBCStringRoutines.escapeStringLiteral(anId));
+ String result = storage.executeFreeSingleValueSql("select to_locking_user from content where id = " + JDBCStringRoutines.escapeStringLiteral(anId));
if (result!=null && !MirGlobal.isUserLoggedIn(result)) {
expireArticleLock(anId, result);
public ModuleImages(StorageObject theStorage) {
if (theStorage == null)
logger.warn("ModuleImages: StorageObject was null!");
- this.theStorage = theStorage;
+ this.storage = theStorage;
}
}
if (theStorage == null)
logger.warn("ModuleLanguage -- StorageObject was null!");
- this.theStorage = theStorage;
+ this.storage = theStorage;
}
public String languageIdForCode(String aCode) throws ModuleExc, ModuleFailure {
try {
- return theStorage.executeFreeSingleValueSql("select id from language where code = '" + JDBCStringRoutines.escapeStringLiteral(aCode) + "'");
+ return storage.executeFreeSingleValueSql("select id from language where code = '" + JDBCStringRoutines.escapeStringLiteral(aCode) + "'");
}
catch (Throwable t) {
throw new ModuleFailure(t);
}
public ModuleMediaType(StorageObject aStorage) {
- this.theStorage = aStorage;
+ this.storage = aStorage;
}
public Entity findMediaTypeForMimeType(String aMimeType) throws ModuleExc, ModuleFailure {
if (aStorage == null)
logger.warn("ModuleMediafolder: StorageObject was null!");
- theStorage = aStorage;
+ storage = aStorage;
}
public String mediaFolderIdForName(String aName) throws ModuleExc, ModuleFailure {
try {
- return theStorage.executeFreeSingleValueSql("select id from media_folder where name = '" + JDBCStringRoutines.escapeStringLiteral(aName) + "'");
+ return storage.executeFreeSingleValueSql("select id from media_folder where name = '" + JDBCStringRoutines.escapeStringLiteral(aName) + "'");
}
catch (Throwable t) {
throw new ModuleFailure(t);
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* 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.
+ * 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 mircoders.module;
{
if (theStorage == null) logger.warn("ModuleMessage -- StorageObject was null!");
- this.theStorage = theStorage;
+ this.storage = theStorage;
}
}
\ No newline at end of file
import java.util.Map;
import mir.entity.Entity;
-import mir.entity.EntityList;
import mir.log.LoggerWrapper;
import mir.module.AbstractModule;
import mir.module.ModuleExc;
static LoggerWrapper logger = new LoggerWrapper("Module.Topics");
public ModuleTopics(StorageObject theStorage) {
- this.theStorage = theStorage;
- }
-
- /**
- * Method getTopicList
- *
- * @return SimpleList of all Topics sorted by title
- *
- */
- public EntityList getTopicsList() throws ModuleExc, ModuleFailure {
- try {
- return getByWhereClause("", "title", -1);
- }
- catch (Throwable e) {
- logger.error("ModuleTopics.getTopicsList: topics could not be fetched: " + e.getMessage());
-
- throw new ModuleFailure("ModuleTopics.getTopicsList: topics could not be fetched: " + e.getMessage(), e);
- }
+ this.storage = theStorage;
}
/**
* Overrides the AbstractModule.set(),
* All dependent ContentEntities are set unproduced.
+ *
* @param theValues Hash mit Spalte/Wert-Paaren
* @return Id des eingef?gten Objekts
- * @exception ModuleException
*/
public String set(Map theValues) throws ModuleExc, ModuleFailure {
try {
- Entity theEntity = theStorage.selectById((String) theValues.get("id"));
+ Entity theEntity = storage.selectById((String) theValues.get("id"));
if (theEntity == null) {
throw new ModuleExc("No topic with id " + theValues.get("id") + " found");
}
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* 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.
+ * 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.
*/
static LoggerWrapper logger = new LoggerWrapper("Module.UploadedMedia");
public ModuleUploadedMedia(StorageObject aStorage) {
- theStorage = aStorage;
+ storage = aStorage;
}
}
\ No newline at end of file
if (aStorage == null)
logger.warn("ModuleUsers(): StorageObject was null!");
- theStorage = aStorage;
+ storage = aStorage;
}
/**
if (userList != null && userList.getCount() == 1) {
EntityUsers result = (EntityUsers) userList.elementAt(0);
- if (result.getValue("is_disabled") == null ||
- result.getValue("is_disabled").equals("0"))
+ if (result.getFieldValue("is_disabled") == null ||
+ result.getFieldValue("is_disabled").equals("0"))
return result;
-
}
return null;
public boolean checkUserPassword(EntityUsers aUser, String aPassword) throws ModuleExc, ModuleFailure {
try {
- return aUser.getValue("password").equals(MirGlobal.localizer().adminInterface().makePasswordDigest(aPassword));
+ return aUser.getFieldValue("password").equals(MirGlobal.localizer().adminInterface().makePasswordDigest(aPassword));
}
catch (Throwable t) {
throw new ModuleFailure(t);
try {
String sql = "update webdb_users set lastlogin=now() where id = " + aUser.getId();
- theStorage.executeUpdate(sql);
+ storage.executeUpdate(sql);
}
catch (Throwable t) {
// no propagation of this error for now, to allow mir to still function
try {
ColumnText ict = new ColumnText(cb);
- String theTitle = entityContent.getValue("title");
- String theCreator = entityContent.getValue("creator");
+ String theTitle = entityContent.getFieldValue("title");
+ String theCreator = entityContent.getFieldValue("creator");
Phrase titleP=new Phrase(" - " + theTitle,new Font(indexFontFamily,indexFontSize,Font.BOLD));
Phrase creatorP=new Phrase( " :: " + theCreator,new Font(indexFontFamily,indexFontSize));
float toYPosition = currentYPosition - indexLineHeight;
while (images.hasNext()){
EntityImages currentImage=(EntityImages) images.next();
- float img_width=(new Float(currentImage.getValue("img_width"))).floatValue();
- float img_height=(new Float(currentImage.getValue("img_height"))).floatValue();
+ float img_width=(new Float(currentImage.getFieldValue("img_width"))).floatValue();
+ float img_height=(new Float(currentImage.getFieldValue("img_height"))).floatValue();
if (img_height>maxImageHeight){
img_width=(new Float((new Float(img_width*(maxImageHeight/img_height))).intValue())).floatValue();
img_height=maxImageHeight;
img_width=maxImageWidth;
}
- String img_title=currentImage.getValue("title");
- String img_path=currentImage.getValue("publish_path");
+ String img_title=currentImage.getFieldValue("title");
+ String img_path=currentImage.getFieldValue("publish_path");
if ((status & ColumnText.NO_MORE_TEXT) == 0){
// there is still text, so add an image which will have text wrapped around it, then add the text which
"cxm.content_id="+entityContent.getId()+"and cxm.media_id=i.id",
"i.id desc", 30, -1, 0);
- String isHTML = entityContent.getValue("is_html");
- String theTitle = entityContent.getValue("title");
- String theCreator = entityContent.getValue("creator");
+ String isHTML = entityContent.getFieldValue("is_html");
+ String theTitle = entityContent.getFieldValue("title");
+ String theCreator = entityContent.getFieldValue("creator");
String theDate = DateTimeFunctions.advancedDateFormat(
configuration.getString("RDF.Meta.DateFormat"),
- StringUtil.convertMirInternalDateToDate(entityContent.getValue("webdb_create")),
+ StringUtil.convertMirInternalDateToDate(entityContent.getFieldValue("webdb_create")),
configuration.getString("Mir.DefaultTimezone"));
- String theDescriptionRaw = entityContent.getValue("description");
- String theContentRaw = entityContent.getValue("content_data");
- String theSource = configuration.getString("Producer.PublicationHost") + "/" + configuration.getString("StandardLanguage") + entityContent.getValue("publish_path") + entityContent.getValue("id") + ".shtml";
+ String theDescriptionRaw = entityContent.getFieldValue("description");
+ String theContentRaw = entityContent.getFieldValue("content_data");
+ String theSource = configuration.getString("Producer.PublicationHost") + "/" + configuration.getString("StandardLanguage") + entityContent.getFieldValue("publish_path") + entityContent.getFieldValue("id") + ".shtml";
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* 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.
+ * 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 mircoders.producer;
value = ParameterExpander.expandExpression(aValueMap, valueExpression);
fieldName = ParameterExpander.expandExpression(aValueMap, fieldNameExpression);
- entity.setValueForProperty("is_produced", "0");
- entity.setValueForProperty(fieldName, value);
+ entity.setFieldValue("is_produced", "0");
+ entity.setFieldValue(fieldName, value);
entity.update();
aLogger.info(" Modified content " + entity.getId() + ": " + fieldName + " = " + value );
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* 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.
+ * 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 mircoders.producer;
entity.getClass().getName() + " adapter", null);
}
- aLogger.info("Indexing " + (String) entity.getValue("id") + " into " +
+ aLogger.info("Indexing " + (String) entity.getFieldValue("id") + " into " +
index);
// create an index here if one did not already exist
//this initialization should go somewhere global like an xml file....
(new KeywordSearchTerm("id", "", "id", "", "id")).index(theDoc, entity);
- String textValue = entity.getValue("webdb_create");
+ String textValue = entity.getFieldValue("webdb_create");
Calendar calendar = GregorianCalendar.getInstance();
int year;
int month;
(new KeywordSearchTerm("webdb_create_formatted", "search_date",
"webdb_create_formatted", "webdb_create_formatted",
"webdb_create_formatted")).indexValue(theDoc,formattedDate);
-
+
(new UnIndexedSearchTerm("", "", "", "where", "where")).indexValue(theDoc,
- StringUtil.webdbDate2path(entity.getValue("date")) +
- entity.getValue("id") + ".shtml");
+ StringUtil.webdbDate2path(entity.getFieldValue("date")) +
+ entity.getFieldValue("id") + ".shtml");
(new TextSearchTerm("creator", "search_creator", "creator", "creator",
"creator")).index(theDoc, entity);
"creationDate", "creationDate", "creationDate")).index(theDoc, entity);
(new ContentSearchTerm("content_data", "search_content", "content", "", "")).indexValue(theDoc,
- entity.getValue("content_data") + " " + entity.getValue("description") +
- " " + entity.getValue("title"));
+ entity.getFieldValue("content_data") + " " + entity.getFieldValue("description") +
+ " " + entity.getFieldValue("title"));
(new TopicSearchTerm()).index(theDoc, entity);
currentMediaHandler = MediaHelper.getHandler( mediaType );
currentMediaHandler.produce(entity, mediaType);
- entity.setValueForProperty("publish_server", currentMediaHandler.getPublishHost());
- entity.setValueForProperty("icon_is_produced", "1");
- entity.setValueForProperty("is_produced", "1");
+ entity.setFieldValue("publish_server", currentMediaHandler.getPublishHost());
+ entity.setFieldValue("icon_is_produced", "1");
+ entity.setFieldValue("is_produced", "1");
entity.update();
- aLogger.info("media with id "+uploadedMediaEntity.getValue("id") + ", mediaType " + mediaType.getValue("name") + " successfully produced");
+ aLogger.info("media with id "+uploadedMediaEntity.getFieldValue("id") + ", mediaType " + mediaType.getFieldValue("name") + " successfully produced");
}
catch (Throwable t) {
String message = "Error while generating media";
try {
if (uploadedMediaEntity!=null)
- message = message + " with id "+uploadedMediaEntity.getValue("id");
+ message = message + " with id "+uploadedMediaEntity.getFieldValue("id");
if (mediaType!=null) {
- message = message + ", mediaType " + mediaType.getValue("name");
+ message = message + ", mediaType " + mediaType.getFieldValue("name");
}
}
catch (Throwable s) {
"cxm.content_id="+entity.getId()+"and cxm.media_id=i.id",
"i.id desc", 30, -1, 0);
- String theContent = ((EntityContent) entity).getValue("content_data");
+ String theContent = ((EntityContent) entity).getFieldValue("content_data");
//remove pesky characters
theContent = HTMLRoutines.encodeXML(theContent);
//put in the <BR> tags so we can turn them to empty blocks
Map row1 = new HashMap();
Map row2 = new HashMap();
EntityImages currentImage=(EntityImages) images.next();
- float img_width=(new Float(currentImage.getValue("img_width"))).floatValue();
- float img_height=(new Float(currentImage.getValue("img_height"))).floatValue();
+ float img_width=(new Float(currentImage.getFieldValue("img_width"))).floatValue();
+ float img_height=(new Float(currentImage.getFieldValue("img_height"))).floatValue();
//oversize images must be shrunk
if (img_width>250){
row1.put("text_widthCM",Float.toString(text_widthCM));
- row1.put("img_title",currentImage.getValue("title"));
+ row1.put("img_title",currentImage.getFieldValue("title"));
row1.put("img_width",Float.toString(img_width));
row1.put("img_height",Float.toString(img_height));
aLogger.debug("img_width " +Float.toString(img_width));
aLogger.debug("img_height "+Float.toString(img_height));
- row1.put("img_src",currentImage.getValue("publish_path"));
+ row1.put("img_src",currentImage.getFieldValue("publish_path"));
row1.put("hasImage","1");
if (! outOfText){
try {
if (! (entity instanceof EntityContent)) {
throw new ProducerFailure("UnIndexingProducerNode: value of '"+contentKey+"' is not a content EntityAdapter, but a " + entity.getClass().getName() + " adapter", null);
}
- aLogger.info("UnIndexing " + (String) entity.getValue("id") + " out of " + index);
+ aLogger.info("UnIndexing " + (String) entity.getFieldValue("id") + " out of " + index);
IndexUtil.unindexEntity((EntityContent) entity, index);
}
}
public void index(Document doc, Entity entity){
- doc.add(Field.UnStored(matchField,entity.getValue(partOfEntity)));
+ doc.add(Field.UnStored(matchField,entity.getFieldValue(partOfEntity)));
}
public void indexValue(Document doc, String value){
if (k != 0){
imageURLString = imageURLString + ":";
}
- imageURLString = imageURLString + (images.elementAt(k)).getValue("icon_path");
+ imageURLString = imageURLString + (images.elementAt(k)).getFieldValue("icon_path");
}
doc.add(Field.UnIndexed("images",imageURLString));
}
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* 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.
+ * 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.
*/
public void index(Document doc, Entity entity){
- doc.add(Field.Keyword(matchField,entity.getValue(partOfEntity)));
+ doc.add(Field.Keyword(matchField,entity.getFieldValue(partOfEntity)));
}
public void indexValue(Document doc, String value){
}
public void index(Document doc, Entity entity){
- String value =entity.getValue(partOfEntity);
+ String value =entity.getFieldValue(partOfEntity);
if (value==null) value="";
EntityList topics = DatabaseContentToTopics.getInstance().getTopics((EntityContent) entity);
if (topics != null && topics.size()>0){
for(int k=0;k<topics.size();k++){
- doc.add(Field.UnStored(matchField,(topics.elementAt(k)).getValue("title")));
+ doc.add(Field.UnStored(matchField,(topics.elementAt(k)).getFieldValue("title")));
}
}
}
EntityList topics = DatabaseContentToTopics.getInstance().getTopics((EntityContent) entity);
if (topics != null && topics.size()>0){
for(int k=0;k<topics.size();k++){
- doc.add(Field.UnStored(matchField,(topics.elementAt(k)).getValue("title")));
+ doc.add(Field.UnStored(matchField,(topics.elementAt(k)).getFieldValue("title")));
}
}
}
}
public void index(Document doc, Entity entity){
- doc.add(Field.Text(dataField,entity.getValue(partOfEntity)));
+ doc.add(Field.Text(dataField,entity.getFieldValue(partOfEntity)));
}
public void indexValue(Document doc, String value){
}
public void index(Document doc, Entity entity){
- doc.add(Field.UnStored(matchField,entity.getValue(partOfEntity)));
+ doc.add(Field.UnStored(matchField,entity.getFieldValue(partOfEntity)));
}
public void indexValue(Document doc, String value){
EntityUsers user = getUser(aRequest);\r
\r
if (user!=null)\r
- return user.getValue("login");\r
+ return user.getFieldValue("login");\r
else\r
return "nobody";\r
}\r
String errorMessage;
- String userName = ServletHelper.getUserName(aRequest);
-
if (id.equals("")) {
errorMessage = MirGlobal.abuse().addFilter(type, expression,comments, commentaction, articleaction);
logAdminUsage(aRequest, "?", "object added");
showfilters(aRequest, aResponse);
}
+ public void movetop(HttpServletRequest aRequest, HttpServletResponse aResponse) {
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+
+ String id=requestParser.getParameterWithDefault("id", "");
+ MirGlobal.abuse().moveFilterToTop(id);
+
+ MirGlobal.abuse().save();
+ logAdminUsage(aRequest, id, "object moved to the top");
+
+ showfilters(aRequest, aResponse);
+ }
+
+ public void movebottom(HttpServletRequest aRequest, HttpServletResponse aResponse) {
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+
+ String id=requestParser.getParameterWithDefault("id", "");
+ MirGlobal.abuse().moveFilterToBottom(id);
+
+ MirGlobal.abuse().save();
+ logAdminUsage(aRequest, id, "object moved to the bottom");
+
+ showfilters(aRequest, aResponse);
+ }
+
public void add(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
editfilter(aRequest, aResponse, "", "", "", "", "", "", "");
}
public void showlog(HttpServletRequest aRequest, HttpServletResponse aResponse) {
URLBuilder urlBuilder = new URLBuilder();
- int count;
try {
Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
* ServletModuleContent -
* deliver html for the article admin form.
*
- * @version $Id: ServletModuleContent.java,v 1.52.2.13 2003/12/21 13:32:06 zapata Exp $
+ * @version $Id: ServletModuleContent.java,v 1.52.2.14 2004/01/18 17:31:00 zapata Exp $
* @author rk, mir-coders
*
*/
try {
EntityContent article = (EntityContent) mainModule.getById(articleId);
- article.setValueForProperty("to_content", parentId);
+ article.setFieldValue("to_content", parentId);
article.setProduced(false);
article.update();
logAdminUsage(aRequest, articleId, "parent set to " + parentId);
try {
EntityContent article = (EntityContent) mainModule.getById(articleId);
- article.setValueForProperty("to_content", "");
+ article.setFieldValue("to_content", "");
article.setProduced(false);
article.update();
logAdminUsage(aRequest, articleId, "parent cleared");
MediaHandler mediaHandler;
ServletContext ctx = MirPropertiesConfiguration.getContext();
- String fName = entity.getId()+"."+mediaType.getValue("name");
+ String fName = entity.getId()+"."+mediaType.getFieldValue("name");
mediaHandler = MediaHelper.getHandler(mediaType);
InputStream in = mediaHandler.getMedia(entity, mediaType);
String newPassword=validatePassword(ServletHelper.getUser(aRequest), requestParser);
if (newPassword!=null) {
- user.setValueForProperty("password", MirGlobal.localizer().adminInterface().makePasswordDigest(newPassword));
+ user.setFieldValue("password", MirGlobal.localizer().adminInterface().makePasswordDigest(newPassword));
user.update();
logAdminUsage(aRequest, id, "password changed");
private DatabaseArticleType() throws StorageObjectFailure {
super();
+
logger = new LoggerWrapper("Database.ArticleType");
this.hasTimestamp = false;
- this.theTable = "article_type";
+ this.mainTable = "article_type";
}
}
logger = new LoggerWrapper("Database.Audio");
hasTimestamp = true;
- theTable = "audio";
- theCoreTable = "media";
+ mainTable = "audio";
+ primaryKeySequence = "media_id_seq";
theEntityClass = mircoders.entity.EntityAudio.class;
}
public void update(Entity theEntity) throws StorageObjectFailure {
- String date = theEntity.getValue("date");
+ String date = theEntity.getFieldValue("date");
if (date == null) {
date = StringUtil.date2webdbDate(new GregorianCalendar());
- theEntity.setValueForProperty("date", date);
+ theEntity.setFieldValue("date", date);
}
super.update(theEntity);
}
public String insert(Entity theEntity) throws StorageObjectFailure {
- String date = theEntity.getValue("date");
+ String date = theEntity.getFieldValue("date");
if (date == null) {
date = StringUtil.date2webdbDate(new GregorianCalendar());
- theEntity.setValueForProperty("date", date);
+ theEntity.setFieldValue("date", date);
}
return super.insert(theEntity);
}
{
super();
logger = new LoggerWrapper("Database.Breaking");
- this.theTable="breaking";
+ this.mainTable="breaking";
}
private DatabaseComment() {
super();
hasTimestamp = false;
- theTable = "comment";
+ mainTable = "comment";
logger = new LoggerWrapper("Database.Comment");
this.theEntityClass = mircoders.entity.EntityComment.class;
int res = 0;
/** @todo comments and topics should be deleted */
- sql = "delete from " + theTable + " where to_media=" + id;
+ sql = "delete from " + mainTable + " where to_media=" + id;
logger.info("DELETE "+ sql);
try {
private DatabaseCommentStatus() throws StorageObjectFailure {
super();
hasTimestamp = false;
- theTable = "comment_status";
+ mainTable = "comment_status";
logger = new LoggerWrapper("Database.CommentStatus");
}
}
\ No newline at end of file
* <b>implements abstract DB connection to the comment_x_media SQL table
*
* @author RK, mir-coders group
- * @version $Id: DatabaseCommentToMedia.java,v 1.3.2.5 2003/11/26 19:23:16 rk Exp $
+ * @version $Id: DatabaseCommentToMedia.java,v 1.3.2.6 2004/01/18 17:31:01 zapata Exp $
*
*/
super();
logger = new LoggerWrapper("Database.CommentToMedia");
hasTimestamp = false;
- theTable = "comment_x_media";
+ mainTable = "comment_x_media";
theEntityClass = mir.entity.GenericEntity.class;
}
private EntityList getMultiMediaForComment(StorageObject store, EntityComment comment)
throws StorageObjectFailure {
-
+
EntityList returnList = null;
if (comment != null) {
String id = comment.getId();
- try {
+ try {
Vector extraTable = new Vector();
- extraTable.add(theTable+" cxm");
+ extraTable.add(mainTable+" cxm");
// media should stay in uploaded order. this is especially important
// for photo stories which require a specific chronologic order.
- // this is why we have the the second parameter "id"
- store.selectByWhereClause("m", extraTable,
+ // this is why we have the the second parameter "id"
+ store.selectByWhereClause("m", extraTable,
"m.id=cxm.media_id and cxm.comment_id="+id, "id", -1, -1);
-
+
} catch (Exception e) {
logger.error("DatabaseCommenttToMedia.getMultiMediaForComment: " + e.toString());
throw new StorageObjectFailure("DatabaseContentToMedia.etMultiMediaForComment: " +
return;
}
//first delete all row with comment_id=commentId
- String sql = "delete from " + theTable + " where comment_id=" + commentId;
+ String sql = "delete from " + mainTable + " where comment_id=" + commentId;
Connection con = null;
Statement stmt = null;
//now insert
//first delete all row with comment_id=commentId
for (int i = 0; i < mediaId.length; i++) {
- sql = "insert into " + theTable + " (comment_id,media_id) values ("
+ sql = "insert into " + mainTable + " (comment_id,media_id) values ("
+ commentId + "," + mediaId[i] + ")";
try {
con = getPooledCon();
Statement stmt = null;
//now insert
- String sql = "insert into " + theTable + " (comment_id,media_id) values ("
+ String sql = "insert into " + mainTable + " (comment_id,media_id) values ("
+ commentId + "," + mediaId + ")";
try {
con = getPooledCon();
return;
}
//first delete all row with comment_id=commentId
- String sql = "delete from " + theTable + " where comment_id=" + commentId;
+ String sql = "delete from " + mainTable + " where comment_id=" + commentId;
Connection con = null;
Statement stmt = null;
//now insert
//first delete all row with comment_id=commentId
- sql = "insert into " + theTable + " (comment_id,media_id) values ("
+ sql = "insert into " + mainTable + " (comment_id,media_id) values ("
+ commentId + "," + mediaId + ")";
try {
con = getPooledCon();
return;
}
//delete all row with comment_id=commentId
- String sql = "delete from " + theTable + " where comment_id=" + commentId;
+ String sql = "delete from " + mainTable + " where comment_id=" + commentId;
Connection con = null;
Statement stmt = null;
return;
}
//delete all row with comment_id=commentId
- String sql = "delete from " + theTable + " where media_id=" + mediaId;
+ String sql = "delete from " + mainTable + " where media_id=" + mediaId;
Connection con = null;
Statement stmt = null;
return;
}
//delete all row with comment_id=commentId and media_id=mediaId
- String sql = "delete from " + theTable + " where media_id=" + mediaId +
+ String sql = "delete from " + mainTable + " where media_id=" + mediaId +
" and comment_id= " + commentId;
Connection con = null;
public EntityList getComment(EntityUploadedMedia media) throws
StorageObjectFailure {
-
+
EntityList returnList = null;
if (media != null) {
String id = media.getId();
Vector extraTables = new Vector();
- extraTables.add(theTable + " cxm");
-
+ extraTables.add(mainTable + " cxm");
+
String mediaSelect = "cxm.comment_id=c.id and cxm.media_id="+id;
try {
returnList = DatabaseComment.getInstance().selectByWhereClause("c",
extraTables, mediaSelect, "c.id" );
-
+
}
catch (Exception e) {
logger.error("-- get comment failed");
}
/**
- * Returns a EntityList with all comment-objects having
+ * Returns a EntityList with all comment-objects having
* a relation to a media
*/
public EntityList getComment() throws StorageObjectFailure {
EntityList returnList = null;
-
+
Vector extraTables = new Vector();
- extraTables.add(theTable + " cxm");
-
+ extraTables.add(mainTable + " cxm");
+
String mediaSelect = "cxm.comment_id=c.id";
try {
returnList = DatabaseComment.getInstance().selectByWhereClause("c",
extraTables, mediaSelect, "c.webdb_lastchange desc" );
-
+
}
catch (Exception e) {
logger.error("-- get comment failed");
private DatabaseContent() throws StorageObjectFailure {
super();
- theTable="content";
- theCoreTable="media";
+ mainTable="content";
+ primaryKeySequence="media_id_seq";
logger = new LoggerWrapper("Database.Content");
theEntityClass = mircoders.entity.EntityContent.class;
* <b>implements abstract DB connection to the content_x_media SQL table
*
* @author RK, mir-coders group
- * @version $Id: DatabaseContentToMedia.java,v 1.19.2.4 2003/11/26 19:21:06 rk Exp $
+ * @version $Id: DatabaseContentToMedia.java,v 1.19.2.5 2004/01/18 17:31:01 zapata Exp $
*
*/
logger = new LoggerWrapper("Database.ContentToMedia");
hasTimestamp = false;
- theTable = "content_x_media";
+ mainTable = "content_x_media";
theEntityClass = mir.entity.GenericEntity.class;
}
public boolean hasMedia(EntityContent content) throws StorageObjectFailure,
StorageObjectExc {
if (content != null) {
- try {
+ try {
return (getSize("content_id=" + content.getId()) == 0) ? false:true;
}
catch (Exception e) {
private EntityList getMultiMediaForContent(StorageObject store, EntityContent content)
throws StorageObjectFailure {
-
+
EntityList returnList = null;
if (content != null) {
String id = content.getId();
- try {
+ try {
Vector extraTable = new Vector();
- extraTable.add(theTable+" cxm");
+ extraTable.add(mainTable+" cxm");
// media should stay in uploaded order. this is especially important
// for photo stories which require a specific chronologic order.
- // this is why we have the the second parameter "id"
- store.selectByWhereClause("m", extraTable,
+ // this is why we have the the second parameter "id"
+ store.selectByWhereClause("m", extraTable,
"m.id=cxm.media_id and cxm.content_id="+id, "id", -1, -1);
-
+
} catch (Exception e) {
logger.error("DatabaseContentToMedia.getMultiMediaForContent: " + e.toString());
throw new StorageObjectFailure("DatabaseContentToMedia.etMultiMediaForContent: " +
}
return returnList;
}
-
+
/**
* get all the audio belonging to a content entity
*/
return;
}
//first delete all row with content_id=contentId
- String sql = "delete from " + theTable + " where content_id=" + contentId;
+ String sql = "delete from " + mainTable + " where content_id=" + contentId;
Connection con = null;
Statement stmt = null;
//now insert
//first delete all row with content_id=contentId
for (int i = 0; i < mediaId.length; i++) {
- sql = "insert into " + theTable + " (content_id,media_id) values ("
+ sql = "insert into " + mainTable + " (content_id,media_id) values ("
+ contentId + "," + mediaId[i] + ")";
try {
con = getPooledCon();
Statement stmt = null;
//now insert
- String sql = "insert into " + theTable + " (content_id,media_id) values ("
+ String sql = "insert into " + mainTable + " (content_id,media_id) values ("
+ contentId + "," + mediaId + ")";
try {
con = getPooledCon();
return;
}
//first delete all row with content_id=contentId
- String sql = "delete from " + theTable + " where content_id=" + contentId;
+ String sql = "delete from " + mainTable + " where content_id=" + contentId;
Connection con = null;
Statement stmt = null;
//now insert
//first delete all row with content_id=contentId
- sql = "insert into " + theTable + " (content_id,media_id) values ("
+ sql = "insert into " + mainTable + " (content_id,media_id) values ("
+ contentId + "," + mediaId + ")";
try {
con = getPooledCon();
return;
}
//delete all row with content_id=contentId
- String sql = "delete from " + theTable + " where content_id=" + contentId;
+ String sql = "delete from " + mainTable + " where content_id=" + contentId;
Connection con = null;
Statement stmt = null;
}
public void deleteByMediaId(String mediaId) throws StorageObjectFailure {
-
+
if (mediaId == null) {
//theLog.printDebugInfo("-- delete topics failed -- no topic id");
return;
}
//delete all row with content_id=contentId
- String sql = "delete from " + theTable + " where media_id=" + mediaId;
+ String sql = "delete from " + mainTable + " where media_id=" + mediaId;
Connection con = null;
Statement stmt = null;
return;
}
//delete all row with content_id=contentId and media_id=mediaId
- String sql = "delete from " + theTable + " where media_id=" + mediaId +
+ String sql = "delete from " + mainTable + " where media_id=" + mediaId +
" and content_id= " + contentId;
Connection con = null;
public EntityList getContent(EntityUploadedMedia media) throws
StorageObjectFailure {
-
+
EntityList returnList = null;
if (media != null) {
String id = media.getId();
Vector extraTables = new Vector();
- extraTables.add(theTable + " cxm");
-
+ extraTables.add(mainTable + " cxm");
+
String mediaSelect = "cxm.content_id=c.id and cxm.media_id="+id;
try {
returnList = DatabaseContent.getInstance().selectByWhereClause("c",
extraTables, mediaSelect, "c.id" );
-
+
}
catch (Exception e) {
logger.error("-- get content failed");
public EntityList getContent() throws StorageObjectFailure {
EntityList returnList = null;
-
+
Vector extraTables = new Vector();
- extraTables.add(theTable + " cxm");
-
+ extraTables.add(mainTable + " cxm");
+
String mediaSelect = "cxm.content_id=c.id";
try {
returnList = DatabaseContent.getInstance().selectByWhereClause("c",
extraTables, mediaSelect, "c.webdb_lastchange desc" );
-
+
}
catch (Exception e) {
logger.error("-- get content failed");
logger = new LoggerWrapper("Database.ContentToTopics");
hasTimestamp = false;
- theTable="content_x_topic";
+ mainTable="content_x_topic";
theEntityClass = mir.entity.GenericEntity.class;
}
String id = content.getId();
try {
Vector extraTables = new Vector();
- extraTables.add(theTable+" cxt");
+ extraTables.add(mainTable+" cxt");
returnList = DatabaseTopics.getInstance()
- .selectByWhereClauseWithExtraTables("t",extraTables,
- "t.id=cxt.topic_id and cxt.content_id="+id );
+ .selectByWhereClauseWithExtraTables("t",extraTables,
+ "t.id=cxt.topic_id and cxt.content_id="+id );
}
catch (Exception e) {
logger.error("-- get topics failed " + e.toString());
ArrayList returnList = new ArrayList();
if (contentId != null) {
- String sql = "select topic_id from " + theTable + " where content_id=" + contentId;
+ String sql = "select topic_id from " + mainTable + " where content_id=" + contentId;
Connection con=null;Statement stmt=null;
try {
con = getPooledCon();
logger.debug("to add = " + topicsToAdd.toString());
- if (!topicsToDelete.isEmpty()) {
+ if (!topicsToDelete.isEmpty()) {
String sql =
- "delete from " + theTable + " " +
+ "delete from " + mainTable + " " +
"where content_id=" + anArticleId +
" and topic_id in (" + getIdListExpression(topicsToDelete) + ")";
while (i.hasNext()) {
Integer topicId = (Integer) i.next();
String sql =
- "insert into " + theTable + " (content_id, topic_id) "+
+ "insert into " + mainTable + " (content_id, topic_id) "+
"values (" + anArticleId + "," + topicId + ")";
Connection connection=null;
Statement statement=null;
return;
}
//delete all row with content_id=contentId
- String sql = "delete from "+ theTable +" where content_id=" + contentId;
+ String sql = "delete from "+ mainTable +" where content_id=" + contentId;
Connection con=null;Statement stmt=null;
try {
return;
}
//delete all row with content_id=contentId
- String sql = "delete from "+ theTable +" where topic_id=" + topicId;
+ String sql = "delete from "+ mainTable +" where topic_id=" + topicId;
Connection con=null;Statement stmt=null;
try {
freeConnection(con,stmt);
}
}
-
+
/**
* Returns list of Content for a specific topic
* @param topic
String id = topic.getId();
try {
Vector extraTables = new Vector();
- extraTables.add(theTable+" cxt");
+ extraTables.add(mainTable+" cxt");
returnList = DatabaseContent.getInstance()
- .selectByWhereClauseWithExtraTables("c",extraTables,
- "c.id=cxt.content_id and cxt.topic_id="+id );
+ .selectByWhereClauseWithExtraTables("c",extraTables,
+ "c.id=cxt.content_id and cxt.topic_id="+id );
}
catch (Exception e) {
logger.error("-- get content failed");
super();
logger = new LoggerWrapper("Database.ImageColor");
hasTimestamp = false;
- theTable = "img_color";
+ mainTable = "img_color";
}
}
super();
logger = new LoggerWrapper("Database.ImageFormat");
hasTimestamp = false;
- theTable = "img_format";
+ mainTable = "img_format";
}
}
logger = new LoggerWrapper("Database.ImageLayout");
hasTimestamp = false;
- theTable = "img_layout";
+ mainTable = "img_layout";
}
}
logger = new LoggerWrapper("Database.ImageType");
hasTimestamp = false;
- theTable = "img_type";
+ mainTable = "img_type";
}
}
logger = new LoggerWrapper("Database.Images");
hasTimestamp = true;
- theTable = "images";
- theCoreTable = "media";
+ mainTable = "images";
+ primaryKeySequence = "media_id_seq";
theEntityClass = mircoders.entity.EntityImages.class;
}
public void update(Entity theEntity) throws StorageObjectFailure {
- String date = theEntity.getValue("date");
+ String date = theEntity.getFieldValue("date");
if (date == null) {
date = StringUtil.date2webdbDate(new GregorianCalendar());
- theEntity.setValueForProperty("date", date);
+ theEntity.setFieldValue("date", date);
}
super.update(theEntity);
}
public String insert(Entity theEntity) throws StorageObjectFailure {
- String date = theEntity.getValue("date");
+ String date = theEntity.getFieldValue("date");
if (date == null) {
date = StringUtil.date2webdbDate(new GregorianCalendar());
- theEntity.setValueForProperty("date", date);
+ theEntity.setFieldValue("date", date);
}
return super.insert(theEntity);
logger = new LoggerWrapper("Database.Language");
this.hasTimestamp = false;
- this.theTable = "language";
+ this.mainTable = "language";
}
public List getPopupData() throws StorageObjectFailure {
Entity e = (Entity) i.next();
Map entry = new HashMap();
entry.put("key", e.getId());
- entry.put("value", e.getValue("name"));
+ entry.put("value", e.getFieldValue("name"));
result.add(entry);
}
logger = new LoggerWrapper("Database.MediaType");
hasTimestamp = false;
- theTable="media_type";
+ mainTable="media_type";
theEntityClass = mir.entity.GenericEntity.class;
}
logger = new LoggerWrapper("Database.Mediafolder");
hasTimestamp = false;
- theTable="media_folder";
+ mainTable="media_folder";
}
}
logger = new LoggerWrapper("Database.Messages");
- this.theTable="messages";
+ this.mainTable="messages";
}
logger = new LoggerWrapper("Database.OtherMedia");
hasTimestamp = true;
- theTable = "other_media";
- theCoreTable = "media";
+ mainTable = "other_media";
+ primaryKeySequence = "media_id_seq";
theEntityClass = mircoders.entity.EntityOther.class;
}
public void update(Entity theEntity) throws StorageObjectFailure {
- String date = theEntity.getValue("date");
+ String date = theEntity.getFieldValue("date");
if (date == null) {
date = StringUtil.date2webdbDate(new GregorianCalendar());
- theEntity.setValueForProperty("date", date);
+ theEntity.setFieldValue("date", date);
}
super.update(theEntity);
}
public String insert(Entity theEntity) throws StorageObjectFailure {
- String date = theEntity.getValue("date");
+ String date = theEntity.getFieldValue("date");
if (date == null) {
date = StringUtil.date2webdbDate(new GregorianCalendar());
- theEntity.setValueForProperty("date", date);
+ theEntity.setFieldValue("date", date);
}
return super.insert(theEntity);
}
logger = new LoggerWrapper("Database.Rights");
hasTimestamp = false;
- theTable = "rights";
+ mainTable = "rights";
}
}
logger = new LoggerWrapper("Database.Topics");
hasTimestamp = false;
- theTable = "topic";
+ mainTable = "topic";
theEntityClass = mircoders.entity.EntityTopics.class;
}
Entity e = (Entity) i.next();
Map entry = new HashMap();
entry.put("key", e.getId());
- entry.put("value", e.getValue("title"));
+ entry.put("value", e.getFieldValue("title"));
result.add(entry);
}
logger = new LoggerWrapper("Database.UploadedMedia");
- theTable="uploaded_media";
- theCoreTable="media";
+ mainTable="uploaded_media";
+ primaryKeySequence="media_id_seq";
theEntityClass = mircoders.entity.EntityUploadedMedia.class;
}
public Entity getMediaType(Entity ent) throws StorageObjectFailure {
Entity type=null;
try {
- Iterator i = new EntityBrowser(DatabaseMediaType.getInstance(), ent.getValue("to_media_type") + " = id" , "id", 1);
+ Iterator i = new EntityBrowser(DatabaseMediaType.getInstance(), ent.getFieldValue("to_media_type") + " = id" , "id", 1);
if (i.hasNext())
type = (Entity) i.next();
}
logger = new LoggerWrapper("Database.Users");
hasTimestamp = false;
- theTable = "webdb_users";
+ mainTable = "webdb_users";
theEntityClass = mircoders.entity.EntityUsers.class;
}
}
logger = new LoggerWrapper("Database.Video");
hasTimestamp = true;
- theTable = "video";
- theCoreTable = "media";
+ mainTable = "video";
+ primaryKeySequence = "media_id_seq";
theEntityClass = mircoders.entity.EntityVideo.class;
}
public void update(Entity theEntity) throws StorageObjectFailure {
- String date = theEntity.getValue("date");
+ String date = theEntity.getFieldValue("date");
if (date == null) {
date = StringUtil.date2webdbDate(new GregorianCalendar());
- theEntity.setValueForProperty("date", date);
+ theEntity.setFieldValue("date", date);
}
super.update(theEntity);
}
public String insert(Entity theEntity) throws StorageObjectFailure {
- String date = theEntity.getValue("date");
+ String date = theEntity.getFieldValue("date");
if (date == null) {
date = StringUtil.date2webdbDate(new GregorianCalendar());
- theEntity.setValueForProperty("date", date);
+ theEntity.setFieldValue("date", date);
}
return super.insert(theEntity);
}
f.lastHit.format(config["Mir.DefaultDateTimeFormat"], config["Mir.DefaultTimezone"])
],
"module=Abuse&id="+f.id,
- ["&do=moveup", "&do=movedown"],
- [lang("abuse.filters.moveup"), lang("abuse.filters.movedown")])
+ ["&do=moveup", "&do=movedown", "&do=movetop", "&do=movebottom"],
+ [lang("abuse.filters.moveup"), lang("abuse.filters.movedown"),
+ lang("abuse.filters.movetop"), lang("abuse.filters.movebottom")])
>
<else>
<call ListEntry([
"-"
],
"module=Abuse&id="+f.id,
- ["&do=moveup", "&do=movedown"],
- [lang("abuse.filters.moveup"), lang("abuse.filters.movedown")])
+ ["&do=moveup", "&do=movedown", "&do=movetop", "&do=movebottom"],
+ [lang("abuse.filters.moveup"), lang("abuse.filters.movedown"),
+ lang("abuse.filters.movetop"), lang("abuse.filters.movebottom")])
>
</if>
<tr height="2" class="${TABLE_HEAD_CLASS}"><td colspan="6"> </td></tr>