|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsemorg.sql.tables.AbstractTable
semorg.sql.tables.Person
semorg.sql.tables.Client
public class Client
Models a person in the role of a client.
Field Summary | |
---|---|
private static String |
clientInsertString
SQL query to insert a client record. |
private static String |
clientUpdateString
SQL query to update a client record. |
private static String |
createTableSQLString
SQL statement for creating the table "client" (if not exists). |
private int |
employerId
The id of the company which employs the client. |
private static String |
queryString
SQL query to get all client records from the database. |
private static String |
tableName
The name of the corresponding db table. |
private String |
task
The task of the client in a company. |
private Float |
turnover
The turnover produced by a client. |
Fields inherited from class semorg.sql.tables.Person |
---|
annex, birthday, city, country, email, fax, firstContact, firstname, id, lockedIds, mobile, name, notices, personInsertString, personUpdateString, phone, salutation, shortinfo, street, title, zipCode |
Fields inherited from class semorg.sql.tables.AbstractTable |
---|
creationDate, modificationDate, NULL_ID |
Constructor Summary | |
---|---|
Client(int id,
String salutation,
String title,
String firstname,
String name,
String street,
String zipCode,
String city,
String country,
String annex,
String phone,
String mobile,
String fax,
String email,
Date birthday,
Date firstContact,
String task,
Float turnover,
int employerId,
String shortinfo,
String notices,
Timestamp creationDate,
Timestamp modificationDate)
Creates an instance of the class Client with the given parameters. |
Method Summary | |
---|---|
static void |
createClientTable(Statement statement)
Creates the table "client" if it does not exist. |
static Client |
getClient(int clientId)
Returns a Client instance for a given client id. |
static Vector<DBColumn> |
getColumns()
Returns a vector of DBColumn instances according to
the properties of the tables "person" and "client". |
static DistinctVector<Client> |
getEmployees(int companyId)
Returns all Client objects which are employed by a certain company specified by a given company id. |
String |
getEmployerDescription()
Retrieves the employer of a client (if exists) and returns its short name. |
int |
getEmployerId()
|
static Client |
getNext(int currentId)
Returns for a DB-ID the Client instance according to the record which has the next bigger id. |
static Client |
getPrevious(int currentId)
Returns for a DB-ID the Client instance according to the record which has the next smaller id. |
String |
getTask()
|
Float |
getTurnover()
|
private static DistinctVector<Client> |
getVector(ResultSet resultSet)
Creates for each element in a given ResultSet instance an Client object and returns a vector with the resulting Client instances. |
static DistinctVector<Client> |
getVectorFromDB(Vector<DBConstraint> additionalConstraints,
String sortString)
Creates a PreparedStatement instance with the given parameters, executes the query and returns a vector of Client instances corresponding to the ResultSet of the query. |
int |
insertIntoDB()
Inserts a client record into the db. |
void |
setEmployerId(int employerId)
|
void |
setTask(String task)
|
void |
setTurnover(Float turnover)
|
static boolean |
tableOK()
Checks if the according DB table exists. |
void |
updateDB()
Updates a client record in the database. |
Methods inherited from class semorg.sql.tables.Person |
---|
createPersonTable, equals, getAnnex, getBirthday, getCity, getCountry, getEmail, getFax, getFirstContact, getFirstname, getId, getMobile, getName, getNotices, getPhone, getSalutation, getShortinfo, getStreet, getTitle, getZipCode, hashCode, removeFromDB, setAnnex, setBirthday, setCity, setCountry, setEmail, setFax, setFirstContact, setFirstname, setMobile, setName, setNotices, setNumber, setPhone, setSalutation, setShortinfo, setStreet, setTitle, setZipCode |
Methods inherited from class semorg.sql.tables.AbstractTable |
---|
addDBTableChangedListener, createExtendedQueryString, fireTableChangedEvent, getColumns, getCreationDate, getModificationDate, getNext, getPrevious, removeDBTableChangedListener, setModificationDate, tableOK |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private String task
private Float turnover
private int employerId
private static String tableName
private static String queryString
private static String clientInsertString
private static String clientUpdateString
private static String createTableSQLString
Constructor Detail |
---|
public Client(int id, String salutation, String title, String firstname, String name, String street, String zipCode, String city, String country, String annex, String phone, String mobile, String fax, String email, Date birthday, Date firstContact, String task, Float turnover, int employerId, String shortinfo, String notices, Timestamp creationDate, Timestamp modificationDate)
Method Detail |
---|
public String getEmployerDescription()
private static DistinctVector<Client> getVector(ResultSet resultSet)
resultSet
- given ResultSet instance.
public static DistinctVector<Client> getVectorFromDB(Vector<DBConstraint> additionalConstraints, String sortString) throws SQLException
additionalConstraints
- additional conditions of the WHERE-clausesortString
- sort string with the following structure
ORDER BY attribute [ASC|DSC]
SQLException
- if the PreparedStatement can't be created or the
execution of the query fails.public static boolean tableOK()
true
, if the table is ok, false
otherwise.AbstractTable.tableOK(String)
public static void createClientTable(Statement statement) throws SQLException
statement
- instance of the class Statement, which is used for
executing the SQL statement createTableSQLString
.
SQLException
- If the execution of the given statement with the query
createTableSQLString
or its closing fails.public int insertIntoDB() throws SQLException
Inserts a client record into the db.
To do so, it first inserts a record into the table "person", secondly a record into the table "client". These two records are linked by a PK-FK-association.Finally it fires a TableChanged-Event-Listener to update the UI.
insertIntoDB
in class Person
SQLException
- If the auto-generated id can't resolved from the db, i.e.
it hasnt been generated, or the PreparedStatement
instance can't be created or executed etc.Person.insertIntoDB()
public void updateDB() throws SQLException
updateDB
in class Person
SQLException
- If the PreparedStatement instance can't be created or
executed, this exception is thrown.Person.updateDB()
public static Client getNext(int currentId)
currentId
- the key of the current record
AbstractTable.getNext(String, DBColumn, int)
public static Client getPrevious(int currentId)
currentId
- the key of the current record
AbstractTable.getPrevious(String, DBColumn, int)
public static Vector<DBColumn> getColumns()
DBColumn
instances according to
the properties of the tables "person" and "client".
Person.getColumns()
,
AbstractTable.getColumns(String tableAbbreviation)
public int getEmployerId()
public void setEmployerId(int employerId)
public String getTask()
public void setTask(String task)
public Float getTurnover()
public void setTurnover(Float turnover)
public static Client getClient(int clientId) throws SQLException
clientId
- id of the wanted Client instance
SQLException
- if the client can't retrieved from the database.public static DistinctVector<Client> getEmployees(int companyId) throws SQLException
companyId
- the id of a company
SQLException
- if the creation or execution of the database query fails.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |