001: package de.webman.acl.db;
002:
003: import java.sql.ResultSet;
004: import java.sql.SQLException;
005: import com.teamkonzept.db.TKQuery;
006: import com.teamkonzept.lib.TKVector;
007: import de.webman.acl.Task;
008:
009: /**
010: * $Header: /cvsroot/webman-cms/source/webman/de/webman/acl/db/TaskDBData.java,v 1.1 2001/08/20 08:25:08 mischa Exp $
011: *
012: * Data container for tasks.
013: *
014: * @version 0.10
015: * @since 0.10
016: * @author © 2000 Team-Konzept
017: */
018: public class TaskDBData extends ObjectDBData {
019:
020: // Attributes
021:
022: /**
023: * The name field of the data container.
024: */
025: private String name = null;
026:
027: /**
028: * The context field of the data container.
029: */
030: private Integer context = null;
031:
032: // Constructors
033:
034: /**
035: * Creates a data container for tasks.
036: *
037: * @param id the ID of the task.
038: * @param name the name of the task.
039: * @param context the context of the task.
040: */
041: public TaskDBData(Integer id, String name, Integer context) {
042: super (id);
043:
044: this .name = name;
045: this .context = context;
046: }
047:
048: /**
049: * Creates a data container for tasks.
050: *
051: * @param task the task.
052: */
053: public TaskDBData(Task task) {
054: super (task);
055:
056: this .name = task.getName();
057: this .context = task.getContextID();
058: }
059:
060: // Method implementations
061:
062: /**
063: * Returns the database interface.
064: *
065: * @return the database interface.
066: */
067: public final ObjectDBInterface getDBInterface() {
068: return TaskDBInterface.getInstance();
069: }
070:
071: /**
072: * Inserts initial data into the given query.
073: * <P>
074: * This method is used for <CODE>INSERT</CODE> statements.
075: *
076: * @param query the query to be executed.
077: * @exception java.sql.SQLException if an database error occured.
078: */
079: public void insertInitialIntoQuery(TKQuery query)
080: throws SQLException {
081: super .insertInitialIntoQuery(query);
082:
083: query.setQueryParams("NAME", this .name);
084: query.setQueryParams(ContextDBInterface.getInstance()
085: .getPrimaryKeyName(), this .context);
086: }
087:
088: /**
089: * Reads all data from the given result set.
090: * <P>
091: * This method is used for <CODE>SELECT</CODE> and
092: * <CODE>INSERT</CODE> statements.
093: *
094: * @param result the result set to be read.
095: * @exception java.sql.SQLException if an database error occured.
096: */
097: public void fill(ResultSet result) throws SQLException {
098: this .name = result.getString("NAME");
099: this .context = new Integer(result.getInt(ContextDBInterface
100: .getInstance().getPrimaryKeyName()));
101:
102: super .fill(result);
103: }
104:
105: /**
106: * Returns the name field of the data container.
107: *
108: * @return the name field of the data container.
109: */
110: public final String getName() {
111: return this .name;
112: }
113:
114: /**
115: * Returns the context field of the data container.
116: *
117: * @return the context field of the data container.
118: */
119: public final Integer getContext() {
120: return this.context;
121: }
122:
123: }
|