Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## semorg.sql.tables
Class Company

    java.lang.Object
      semorg.sql.tables.AbstractTable
          semorg.sql.tables.Company

All Implemented Interfaces:
  SimpleIDKey

    public class Company

extends AbstractTable
implements SimpleIDKey

Models a company.

Field Summary
`protected String` | `annex` The annex.
`protected String` | `city` The city.
`protected static String` | `companyInsertString` Parameterized SQL statement for inserting a data record.
`protected static String` | `companyUpdateString` Parameterized SQL statement for updating a data record.
`protected String` | `country` The country.
`protected Date` | `cpBirthDay` The birthday of the contact person.
`protected String` | `cpDepartment` The departement of the contact person.
`protected String` | `cpEmail` The email address of the contact person.
`protected String` | `cpFax` The fax number of the contact person.
`protected String` | `cpFirstname` The firstname of the contact person.
`protected String` | `cpMobile` The number of the mobile phone of the contact person.
`protected String` | `cpName` The lastname of the contact person.
`protected String` | `cpPhone` The phone number of the contact person.
`protected String` | `cpSalutation` The salutation of the contact person.
`protected String` | `cpTask` The task of the contact person in the company.
`protected String` | `cpTitle` The title of the contact person.
`private static String` | `createTableSQLString` SQL statement for creating the table "person" (if not exists).
`protected Date` | `customerSince` The date of becoming a customer.
`protected String` | `email` The email address.
`protected String` | `fax` The fax number.
`protected String` | `firstname` The firstname.
`protected int` | `id` The DB-ID.
`static List<Integer>` | `lockedIds` A list of the ids of locked records.
`protected String` | `mobile` The number of the mobile phone.
`protected String` | `name` The name.
`protected String` | `notices` The notices.
`protected String` | `phone` The phone number.
`private static String` | `queryString` SQL query to get all company records from the database.
`protected String` | `salutation` The salutation.
`protected String` | `shortInfo` The short information.
`protected String` | `shortName` The short name of a company.
`protected String` | `street` The street.
`private static String` | `tableName` The name of the corresponding table in the db.
`protected String` | `title` The title.
`protected Float` | `turnover` The turnover produced by a company.
`protected String` | `zipCode` The Zipcode.

Fields inherited from class semorg.sql.tables.AbstractTable
`creationDate, modificationDate, NULL_ID`

Constructor Summary
`Company(int id, String shortName, 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, String cpSalutation, String cpTitle, String cpFirstname, String cpName, String cpPhone, String cpMobile, String cpFax, String cpEmail, String cpDepartment, Date cpBirthDay, String cpTask, String shortInfo, String notices, Float turnover, Date customerSince, Timestamp creationDate, Timestamp modificationDate)` Creates an instance of the class Company with the given parameters.

Method Summary
`static void` | `createCompanyTable(Statement statement)` Creates the table "company" if it does not exist.
`boolean` | `equals(Object otherCompany)` If the given object is an instance of the Company class this method compares the id of the given and the actual object, otherwise it calls the equal-method of the AbstractTable class with the given object.
`String` | `getAnnex()`
`String` | `getCity()`
`static Vector<DBColumn>` | `getColumns()` Returns a vector of `DBColumn` instances according to the properties of the table "company".
`static Company` | `getCompany(int companyId)` Returns a Company instance for a given company id.
`String` | `getCountry()`
`Date` | `getCpBirthDay()`
`String` | `getCpDepartment()`
`String` | `getCpEmail()`
`String` | `getCpFax()`
`String` | `getCpFirstname()`
`String` | `getCpMobile()`
`String` | `getCpName()`
`String` | `getCpPhone()`
`String` | `getCpSalutation()`
`String` | `getCpTask()`
`String` | `getCpTitle()`
`Date` | `getCustomerSince()`
`String` | `getEmail()`
`String` | `getFax()`
`String` | `getFirstname()`
`int` | `getId()` Returns the DB-ID of a database records.
`String` | `getMobile()`
`String` | `getName()`
`static Company` | `getNext(int lecturerId)` Returns for a DB-ID the Company instance according to the record which has the next bigger id.
`String` | `getNotices()`
`String` | `getPhone()`
`static Company` | `getPrevious(int lecturerId)` Returns for a DB-ID the Company instance according to the record which has the next smaller id.
`String` | `getSalutation()`
`String` | `getShortInfo()`
`String` | `getShortName()`
`String` | `getStreet()`
`String` | `getTitle()`
`Float` | `getTurnover()`
`private static DistinctVector<Company>` | `getVector(ResultSet resultSet)` Creates for each element in a given ResultSet instance an Company object and returns a vector with the resulting Company instances.
`static DistinctVector<Company>` | `getVectorFromDB(Vector<DBConstraint> additionalConstraints, String sortString)` Creates a PreparedStatement instance with the given parameters, executes the query and returns a vector of Company instances corresponding to the ResultSet of the query.
`String` | `getZipCode()`
`int` | `hashCode()` Returns the id.
`int` | `insertIntoDB()` Converts the actual Company object into a database record and inserts it into the table "company".
`static void` | `removeFromDB(Iterable selectedElements)` Removes the given elements from the table "company".
`void` | `setAnnex(String annex)`
`void` | `setCity(String city)`
`void` | `setCountry(String country)`
`void` | `setCpBirthDay(Date cpBirthDay)`
`void` | `setCpDepartment(String cpDepartment)`
`void` | `setCpEmail(String cpEmail)`
`void` | `setCpFax(String cpFax)`
`void` | `setCpFirstname(String cpFirstname)`
`void` | `setCpMobile(String cpMobile)`
`void` | `setCpName(String cpName)`
`void` | `setCpPhone(String cpPhone)`
`void` | `setCpSalutation(String cpSalutation)`
`void` | `setCpTask(String cpTask)`
`void` | `setCpTitle(String cpTitle)`
`void` | `setCustomerSince(Date customerSince)`
`void` | `setEmail(String email)`
`void` | `setFax(String fax)`
`void` | `setFirstname(String firstname)`
`void` | `setMobile(String mobile)`
`void` | `setName(String name)`
`void` | `setNotices(String notices)`
`void` | `setPhone(String phone)`
`void` | `setSalutation(String salutation)`
`void` | `setShortInfo(String shortInfo)`
`void` | `setShortName(String shortName)`
`void` | `setStreet(String street)`
`void` | `setTitle(String title)`
`void` | `setTurnover(Float turnover)`
`void` | `setZipCode(String zipCode)`
`static boolean` | `tableOK()` Checks if the according DB table exists.
`void` | `updateDB()` Converts the actual Company object into a database company record and updates a existing record to the changes made.

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

### lockedIds

    public static List<Integer> lockedIds

  A list of the ids of locked records. This list is meant to avoid the deletion of records, which are currently edited.

### id

    protected int id

  The DB-ID.

### shortName

    protected String shortName

  The short name of a company.

### salutation

    protected String salutation

  The salutation.

### title

    protected String title

  The title.

### firstname

    protected String firstname

  The firstname.

### name

    protected String name

  The name.

### street

    protected String street

  The street.

### zipCode

    protected String zipCode

  The Zipcode.

### city

    protected String city

  The city.

### country

    protected String country

  The country.

### annex

    protected String annex

  The annex.

### phone

    protected String phone

  The phone number.

### mobile

    protected String mobile

  The number of the mobile phone.

### fax

    protected String fax

  The fax number.

### email

    protected String email

  The email address.

### cpSalutation

    protected String cpSalutation

  The salutation of the contact person.

### cpTitle

    protected String cpTitle

  The title of the contact person.

### cpFirstname

    protected String cpFirstname

  The firstname of the contact person.

### cpName

    protected String cpName

  The lastname of the contact person.

### cpPhone

    protected String cpPhone

  The phone number of the contact person.

### cpMobile

    protected String cpMobile

  The number of the mobile phone of the contact person.

### cpFax

    protected String cpFax

  The fax number of the contact person.

### cpEmail

    protected String cpEmail

  The email address of the contact person.

### cpDepartment

    protected String cpDepartment

  The departement of the contact person.

### cpBirthDay

    protected Date cpBirthDay

  The birthday of the contact person.

### cpTask

    protected String cpTask

  The task of the contact person in the company.

### shortInfo

    protected String shortInfo

  The short information.

### notices

    protected String notices

  The notices.

### turnover

    protected Float turnover

  The turnover produced by a company.

### customerSince

    protected Date customerSince

  The date of becoming a customer.

### tableName

    private static String tableName

  The name of the corresponding table in the db.

### companyInsertString

    protected static String companyInsertString

  Parameterized SQL statement for inserting a data record.

### createTableSQLString

    private static String createTableSQLString

  SQL statement for creating the table "person" (if not exists).

### companyUpdateString

    protected static String companyUpdateString

  Parameterized SQL statement for updating a data record.

### queryString

    private static String queryString

  SQL query to get all company records from the database.

Constructor Detail

### Company

    public Company(int id,
                   String shortName,
                   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,
                   String cpSalutation,
                   String cpTitle,
                   String cpFirstname,
                   String cpName,
                   String cpPhone,
                   String cpMobile,
                   String cpFax,
                   String cpEmail,
                   String cpDepartment,
                   Date cpBirthDay,
                   String cpTask,
                   String shortInfo,
                   String notices,
                   Float turnover,
                   Date customerSince,
                   Timestamp creationDate,
                   Timestamp modificationDate)

  Creates an instance of the class Company with the given parameters.

Method Detail

### tableOK

    public static boolean tableOK()

  Checks if the according DB table exists.

  Returns:
    `true`, if the table is ok, `false` otherwise.
  See Also:
    `AbstractTable.tableOK(String)`

### createCompanyTable

    public static void createCompanyTable(Statement statement)
                                   throws SQLException

  Creates the table "company" if it does not exist.

  Parameters:
    `statement` - instance of the class Statement, which is used for executing the SQL statement `createTableSQLString`.
  Throws:
    `SQLException` - If the execution of the given statement with the query `createTableSQLString` or its closing fails.

### insertIntoDB

    public int insertIntoDB()
                     throws SQLException

  Converts the actual Company object into a database record and inserts it into the table "company". Furthermore this method queries the auto-generated id, sets the appropriate property `id` and returns the id. If a salutation, title, country, annex, contact person salutation or contact person title has been inserted into the form, this method also inserts the concerning properties into the table "enumeration" for later use. Finally it fires a TableChanged-EventListener to update the UI.

  Returns:
    the auto-generated id of the inserted company record.
  Throws:
    `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.

### updateDB

    public void updateDB()
                  throws SQLException

  Converts the actual Company object into a database company record and updates a existing record to the changes made. If a salutation, title, country or annex has been inserted into the form, this method also inserts the concerning properties into the table "enumeration" for later use. Finally it fires a TableChanged-EventListener to update the UI.

  Throws:
    `SQLException` - If the PreparedStatement instance can't be created or executed, this exception is thrown.

### removeFromDB

    public static void removeFromDB(Iterable selectedElements)
                             throws SQLException

  Removes the given elements from the table "company". Due to the FK connections (with an ON-DELETE-cascade) this method fires several TableChanged-Events to update the UI.

  Parameters:
    `selectedElements` - the elements, which should be deleted from the database.
  Throws:
    `SQLException` - Throws a SQL exception if the Statement instance can't be created or executed.

### getVector

    private static DistinctVector<Company> getVector(ResultSet resultSet)

  Creates for each element in a given ResultSet instance an Company object and returns a vector with the resulting Company instances.

  Parameters:
    `resultSet` - given ResultSet instance.
  Returns:
    a DistinctVector instance filled with the created `Company` instances.

### getVectorFromDB

    public static DistinctVector<Company> getVectorFromDB(Vector<DBConstraint> additionalConstraints,
                                                          String sortString)
                                                   throws SQLException

  Creates a PreparedStatement instance with the given parameters, executes the query and returns a vector of Company instances corresponding to the ResultSet of the query.

  Parameters:
    `additionalConstraints` - additional conditions of the WHERE-clause
    `sortString` - sort string with the following structure `ORDER BY attribute [ASC|DSC]`
  Returns:
    a DistinctVector instance filled with the created Company instances.
  Throws:
    `SQLException` - sf the PreparedStatement can't be created or the execution of the query fails.

### getColumns

    public static Vector<DBColumn> getColumns()

  Returns a vector of `DBColumn` instances according to the properties of the table "company".

  Returns:
    the vector of DBColumn instances according to the properties of the class Company.
  See Also:
    `AbstractTable.getColumns(String tableAbbreviation)`

### getNext

    public static Company getNext(int lecturerId)

  Returns for a DB-ID the Company instance according to the record which has the next bigger id.

  Parameters:
    `lecturerId` - the key of the current record
  Returns:
    the Company instance corresponding to the next record in the table "company" or if it does not exist the Company instance with the smallest id.
  See Also:
    `AbstractTable.getNext(String, DBColumn, int)`

### getPrevious

    public static Company getPrevious(int lecturerId)

  Returns for a DB-ID the Company instance according to the record which has the next smaller id.

  Parameters:
    `lecturerId` - the key of the current record
  Returns:
    the Company instance corresponding to the previous record in the table "company" or if it does not exist the Company instance with the biggest id.
  See Also:
    `AbstractTable.getPrevious(String, DBColumn, int)`

### getCompany

    public static Company getCompany(int companyId)
                              throws SQLException

  Returns a Company instance for a given company id.

  Parameters:
    `companyId` - id of the wanted Company instance
  Returns:
    the Company instance according to the given id
  Throws:
    `SQLException` - if the execution for the wanted company fails.

### hashCode

    public int hashCode()

  Returns the id.

  Overrides:
    `hashCode` in class `Object`

### equals

    public boolean equals(Object otherCompany)

  If the given object is an instance of the Company class this method compares the id of the given and the actual object, otherwise it calls the equal-method of the AbstractTable class with the given object.

  Overrides:
    `equals` in class `Object`
  Parameters:
    `otherCompany` - object to be compared with the actual object.
  Returns:
    `true` if the id of the given object and the actual object are the same, `false` otherwise.

### getId

    public int getId()

  Description copied from interface: `SimpleIDKey`
  Returns the DB-ID of a database records.

  Specified by:
    `getId` in interface `SimpleIDKey`

### getAnnex

    public String getAnnex()

### setAnnex

    public void setAnnex(String annex)

### getCity

    public String getCity()

### setCity

    public void setCity(String city)

### getCountry

    public String getCountry()

### setCountry

    public void setCountry(String country)

### getCpBirthDay

    public Date getCpBirthDay()

### setCpBirthDay

    public void setCpBirthDay(Date cpBirthDay)

### getCpDepartment

    public String getCpDepartment()

### setCpDepartment

    public void setCpDepartment(String cpDepartment)

### getCpEmail

    public String getCpEmail()

### setCpEmail

    public void setCpEmail(String cpEmail)

### getCpFax

    public String getCpFax()

### setCpFax

    public void setCpFax(String cpFax)

### getCpFirstname

    public String getCpFirstname()

### setCpFirstname

    public void setCpFirstname(String cpFirstname)

### getCpMobile

    public String getCpMobile()

### setCpMobile

    public void setCpMobile(String cpMobile)

### getCpName

    public String getCpName()

### setCpName

    public void setCpName(String cpName)

### getCpPhone

    public String getCpPhone()

### setCpPhone

    public void setCpPhone(String cpPhone)

### getCpSalutation

    public String getCpSalutation()

### setCpSalutation

    public void setCpSalutation(String cpSalutation)

### getCpTask

    public String getCpTask()

### setCpTask

    public void setCpTask(String cpTask)

### getCpTitle

    public String getCpTitle()

### setCpTitle

    public void setCpTitle(String cpTitle)

### getCustomerSince

    public Date getCustomerSince()

### setCustomerSince

    public void setCustomerSince(Date customerSince)

### getEmail

    public String getEmail()

### setEmail

    public void setEmail(String email)

### getFax

    public String getFax()

### setFax

    public void setFax(String fax)

### getFirstname

    public String getFirstname()

### setFirstname

    public void setFirstname(String firstname)

### getMobile

    public String getMobile()

### setMobile

    public void setMobile(String mobile)

### getName

    public String getName()

### setName

    public void setName(String name)

### getNotices

    public String getNotices()

### setNotices

    public void setNotices(String notices)

### getPhone

    public String getPhone()

### setPhone

    public void setPhone(String phone)

### getSalutation

    public String getSalutation()

### setSalutation

    public void setSalutation(String salutation)

### getShortInfo

    public String getShortInfo()

### setShortInfo

    public void setShortInfo(String shortInfo)

### getShortName

    public String getShortName()

### setShortName

    public void setShortName(String shortName)

### getStreet

    public String getStreet()

### setStreet

    public void setStreet(String street)

### getTitle

    public String getTitle()

### setTitle

    public void setTitle(String title)

### getTurnover

    public Float getTurnover()

### setTurnover

    public void setTurnover(Float turnover)

### getZipCode

    public String getZipCode()

### setZipCode

    public void setZipCode(String zipCode)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD