com.wm.app.tn.db
Class ProfileFldDefOps

java.lang.Object
  extended by com.wm.app.tn.db.ProfileFldDefOps

public class ProfileFldDefOps
extends java.lang.Object

Provides database operations for inserting, updating and deleting field definitions. Field definitions are represented by ProfileFieldMetaData objects. The methods that perform SELECTs, return ProfileFieldMetaData instances or Enumerations of them. The methods that INSERT and UPDATE take ProfileFieldMetaData instances as parameters.

This class has no application knowledge in it. The data is not validated before committing it to the database. That is the responsibility of the caller.


Field Summary
static java.util.ResourceBundle fldNames
           
 
Constructor Summary
ProfileFldDefOps()
           
 
Method Summary
static void addFieldDefinition(java.sql.Connection conn, ProfileFieldMetaData md)
          Inserts a field definition.
static void addFieldDefinition(ProfileFieldMetaData md)
          Inserts a field definition.
static void deleteFieldDefinition(java.sql.Connection conn, java.lang.String fldID)
          Deletes an extended field definition.
static void deleteFieldDefinition(java.lang.String fldID)
          Deletes an extended field definition.
static boolean doesFieldExists(java.sql.Connection conn, java.lang.String name, java.lang.String table, java.lang.String col)
           
static boolean doesFieldExists(java.lang.String name, java.lang.String table, java.lang.String col)
           
static ProfileFieldMetaData getFieldDefFromId(java.lang.String fieldId)
          Retrieves an extended field definition.
static ProfileFieldMetaData getFieldDefinition(java.sql.Connection conn, java.lang.String name)
          Retrieves an extended field definition.
static ProfileFieldMetaData getFieldDefinition(java.sql.Connection conn, java.lang.String table, java.lang.String column)
          Retrieves an standard field definition.
static ProfileFieldMetaData getFieldDefinition(java.lang.String name)
          Retrieves an extended field definition.
static ProfileFieldMetaData getFieldDefinition(java.lang.String table, java.lang.String column)
          Retrieves an standard field definition.
static ProfileFieldMetaData getFldDefinition(java.lang.String name, java.lang.String grpId)
          This returns the ProfileFieldMetaData with the given FieldName and group Id
static java.util.Enumeration getGroupFieldDefs(java.sql.Connection conn, int groupID, boolean extended, boolean deleted)
          Retrieves field definitions by group.
static java.util.Enumeration getGroupFieldDefs(int groupID)
          For testing and import/export.
static java.util.Enumeration getGroupFieldDefs(int groupID, boolean extended, boolean deleted)
          Retrieves field definitions by group.
static java.lang.String[] queryFieldDefsByName(java.lang.String regexName)
           
static void safeDeleteFieldDefinition(java.sql.Connection conn, ProfileFieldMetaData md)
          Marks an extended field definition as deleted.
static void safeDeleteFieldDefinition(ProfileFieldMetaData md)
          Marks an extended field definition as deleted.
static void updateFieldDefinition(java.sql.Connection conn, ProfileFieldMetaData md)
          Updates a field definition.
static void updateFieldDefinition(ProfileFieldMetaData md)
          Updates a field definition.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fldNames

public static java.util.ResourceBundle fldNames
Constructor Detail

ProfileFldDefOps

public ProfileFldDefOps()
Method Detail

getGroupFieldDefs

public static java.util.Enumeration getGroupFieldDefs(int groupID,
                                                      boolean extended,
                                                      boolean deleted)
                                               throws java.sql.SQLException,
                                                      ProfileStoreException
Retrieves field definitions by group.

Parameters:
groupID - identifies the group to retrieve fields for
extended - indicates whether to retrieve extended or standard fields. Pass true for extended fields and false for standard fields.
deleted - indicates whether to retrieve deleted or active fields. This paramater applies only if extended is true. Otherwise, it is ignored. Pass true for deleted fields and false for active fields.
Returns:
an Enumeration of ProfileFieldMetaData objects
Throws:
java.sql.SQLException
ProfileStoreException

getGroupFieldDefs

public static java.util.Enumeration getGroupFieldDefs(java.sql.Connection conn,
                                                      int groupID,
                                                      boolean extended,
                                                      boolean deleted)
                                               throws java.sql.SQLException,
                                                      ProfileStoreException
Retrieves field definitions by group.

Parameters:
conn - an open Connection to the Trading Networks database
groupID - identifies the group to retrieve fields for
extended - indicates whether to retrieve extended or standard fields. Pass true for extended fields and false for standard fields.
deleted - indicates whether to retrieve deleted or active extended fields. This paramater applies only if extended is true. Otherwise, it is ignored. Pass true for deleted fields and false for active fields.
Returns:
an Enumeration of ProfileFieldMetaData objects
Throws:
java.sql.SQLException
ProfileStoreException

getFieldDefinition

public static ProfileFieldMetaData getFieldDefinition(java.lang.String name)
                                               throws java.sql.SQLException,
                                                      ProfileStoreException
Retrieves an extended field definition.

Parameters:
name - the name of the extended field
Returns:
a ProfileFieldMetaData
Throws:
java.sql.SQLException
ProfileStoreException

getFldDefinition

public static ProfileFieldMetaData getFldDefinition(java.lang.String name,
                                                    java.lang.String grpId)
                                             throws java.sql.SQLException,
                                                    ProfileStoreException
This returns the ProfileFieldMetaData with the given FieldName and group Id

Parameters:
name -
grpId -
Returns:
ProfilefieldMetaData
Throws:
java.sql.SQLException
ProfileStoreException

getFieldDefFromId

public static ProfileFieldMetaData getFieldDefFromId(java.lang.String fieldId)
                                              throws java.sql.SQLException,
                                                     ProfileStoreException
Retrieves an extended field definition.

Parameters:
fieldId - profilefieldId
Returns:
a ProfileFieldMetaData
Throws:
java.sql.SQLException
ProfileStoreException

getFieldDefinition

public static ProfileFieldMetaData getFieldDefinition(java.sql.Connection conn,
                                                      java.lang.String name)
                                               throws java.sql.SQLException,
                                                      ProfileStoreException
Retrieves an extended field definition.

Parameters:
conn - an open Connection to the Trading Networks database
name - the name of the extended field
Returns:
a ProfileFieldMetaData
Throws:
java.sql.SQLException
ProfileStoreException

getFieldDefinition

public static ProfileFieldMetaData getFieldDefinition(java.lang.String table,
                                                      java.lang.String column)
                                               throws java.sql.SQLException,
                                                      ProfileStoreException
Retrieves an standard field definition.

Parameters:
table - the table of the standard field
table - the column of the standard field
Returns:
a ProfileFieldMetaData
Throws:
java.sql.SQLException
ProfileStoreException

getFieldDefinition

public static ProfileFieldMetaData getFieldDefinition(java.sql.Connection conn,
                                                      java.lang.String table,
                                                      java.lang.String column)
                                               throws java.sql.SQLException,
                                                      ProfileStoreException
Retrieves an standard field definition.

Parameters:
conn - an open Connection to the Trading Networks database
table - the table of the standard field
column - the column of the standard field
Returns:
a ProfileFieldMetaData
Throws:
java.sql.SQLException
ProfileStoreException

addFieldDefinition

public static void addFieldDefinition(ProfileFieldMetaData md)
                               throws java.sql.SQLException,
                                      ProfileStoreException
Inserts a field definition.

Parameters:
fld - the ExtendedProfileField to be inserted to the database
Throws:
java.sql.SQLException
ProfileStoreException

addFieldDefinition

public static void addFieldDefinition(java.sql.Connection conn,
                                      ProfileFieldMetaData md)
                               throws java.sql.SQLException,
                                      ProfileStoreException
Inserts a field definition.

Side effect: set's the FieldID of the supplied ProfileFieldMetaData

Parameters:
conn - an open Connection to the Trading Networks database
fld - the ExtendedProfileField to be inserted to the database
Throws:
java.sql.SQLException
ProfileStoreException

updateFieldDefinition

public static void updateFieldDefinition(ProfileFieldMetaData md)
                                  throws java.sql.SQLException,
                                         ProfileStoreException
Updates a field definition.

Parameters:
fld - the ExtendedProfileField to be inserted to the database
Throws:
java.sql.SQLException
ProfileStoreException

updateFieldDefinition

public static void updateFieldDefinition(java.sql.Connection conn,
                                         ProfileFieldMetaData md)
                                  throws java.sql.SQLException,
                                         ProfileStoreException
Updates a field definition.

Parameters:
conn - an open Connection to the Trading Networks database
fld - the ExtendedProfileField to be inserted to the database
Throws:
java.sql.SQLException
ProfileStoreException

safeDeleteFieldDefinition

public static void safeDeleteFieldDefinition(ProfileFieldMetaData md)
                                      throws java.sql.SQLException,
                                             ProfileStoreException
Marks an extended field definition as deleted.

Parameters:
md - a ProfileFieldMetaData that represents the field definition to be deleted
Throws:
java.sql.SQLException
ProfileStoreException

safeDeleteFieldDefinition

public static void safeDeleteFieldDefinition(java.sql.Connection conn,
                                             ProfileFieldMetaData md)
                                      throws java.sql.SQLException,
                                             ProfileStoreException
Marks an extended field definition as deleted.

Parameters:
conn - an open Connection to the Trading Networks database
md - a ProfileFieldMetaData that represents the field definition to be deleted
Throws:
java.sql.SQLException
ProfileStoreException

deleteFieldDefinition

public static void deleteFieldDefinition(java.lang.String fldID)
                                  throws java.sql.SQLException,
                                         ProfileStoreException
Deletes an extended field definition.

Parameters:
fldID - the ProfileFieldID of the extended field to be deleted. Given a ProfileField instance, this value can be retrieved by calling getMetaData().getFieldID() on it.
Throws:
java.sql.SQLException
ProfileStoreException

deleteFieldDefinition

public static void deleteFieldDefinition(java.sql.Connection conn,
                                         java.lang.String fldID)
                                  throws java.sql.SQLException,
                                         ProfileStoreException
Deletes an extended field definition.

Parameters:
conn - an open Connection to the Trading Networks database
fldID - the ProfileFieldID of the extended field to be deleted. Given a ProfileField instance, this value can be retrieved by calling getMetaData().getFieldID() on it.
Throws:
java.sql.SQLException
ProfileStoreException

getGroupFieldDefs

public static java.util.Enumeration getGroupFieldDefs(int groupID)
                                               throws java.sql.SQLException,
                                                      ProfileStoreException
For testing and import/export. Returns all field defintions for a group: standard, extended deleted, extended non-deleted.

Throws:
java.sql.SQLException
ProfileStoreException

doesFieldExists

public static boolean doesFieldExists(java.lang.String name,
                                      java.lang.String table,
                                      java.lang.String col)
                               throws java.sql.SQLException
Throws:
java.sql.SQLException

doesFieldExists

public static boolean doesFieldExists(java.sql.Connection conn,
                                      java.lang.String name,
                                      java.lang.String table,
                                      java.lang.String col)
                               throws java.sql.SQLException
Throws:
java.sql.SQLException

queryFieldDefsByName

public static java.lang.String[] queryFieldDefsByName(java.lang.String regexName)