org.eclipse.datatools.enablement.sybase.ddl
Class SybaseDdlBuilder

java.lang.Object
  extended by org.eclipse.datatools.connectivity.sqm.core.rte.fe.GenericDdlBuilder
      extended by org.eclipse.datatools.enablement.sybase.ddl.SybaseDdlBuilder
All Implemented Interfaces:
ISybaseDdlConstants
Direct Known Subclasses:
SybaseASADdlBuilder, SybaseASEDdlBuilder, SybaseDdlBuilderWrapper

public abstract class SybaseDdlBuilder
extends GenericDdlBuilder
implements ISybaseDdlConstants


Field Summary
 
Fields inherited from interface org.eclipse.datatools.enablement.sybase.ddl.ISybaseDdlConstants
ALTER_PRIVILEGE, ASC, AT, BEGIN, CAST, CHECKOPTION, CLUSTERED, COLUMN, COMMENT, COMMIT, DATABASE, DELETE_PRIVILEGE, DESC, END, END_IF, EQUAL, EVENT, EXEC_PRIVILEGE, EXISTS, EXTERNAL, EXTERNAL_NAME, FILE, FROM, GO, GO_FOR, GRANT, IF, IN, INOUT, INSERT_PRIVILEGE, IS, JAVA, LOCATOR, LOG, MESSAGE, NONCLUSTERED, OUT, OUTPUT, REFERENCE_PRIVILEGE, REFERENCES_PRIVILEGE, REMOVE, RENAME, REVOKE, SELECT_PRIVILEGE, SEMICOLUMN, SP_RENAME, THEN, TO, UPDATE_PRIVILEGE, WITH_GRANT_OPTION, WITH_RECOMPILE
 
Constructor Summary
SybaseDdlBuilder()
           
 
Method Summary
 java.lang.String[] addCheckConstraint(CheckConstraint constraint, boolean quoteIdentifiers, boolean qualifyNames, boolean fullSyntax)
          Returns the SQL Statement for adding check constraint clause.
abstract  java.lang.String[] addForeignKey(ForeignKey foreignKey, boolean quoteIdentifiers, boolean qualifyNames, boolean fullSyntax)
           
abstract  java.lang.String[] addUniqueConstraint(UniqueConstraint constraint, boolean quoteIdentifiers, boolean qualifyNames, boolean fullSyntax)
           
abstract  java.lang.String[] createAuthorizationId(AuthorizationIdentifier authId, boolean quoteIdentifiers, boolean qualifyNames, boolean fullSyntax)
           
abstract  java.lang.String[] createCatalogs(Catalog catalog, boolean quoteIdentifiers, boolean qualifyNames, boolean fullSyntax)
           
abstract  java.lang.String[] createColumn(Column col, boolean quoteIdentifiers, boolean qualifyNames, boolean fullSyntax)
           
abstract  java.lang.String[] createDatabase(Database database, boolean quoteIdentifiers, boolean qualifyNames, boolean fullSyntax)
           
abstract  java.lang.String[] createEvent(Event event, boolean quoteIdentifiers, boolean qualifyNames, boolean fullSyntax)
           
 java.lang.String[] createIndex(Index index, boolean quoteIdentifiers, boolean qualifyNames, boolean fullSyntax)
           
abstract  java.lang.String[] createProcedure(Procedure procedure, boolean quoteIdentifiers, boolean qualifyNames, boolean fullSyntax)
           
 java.lang.String[] createTable(BaseTable table, boolean quoteIdentifiers, boolean qualifyNames, boolean fullSyntax)
           
abstract  java.lang.String[] createTrigger(Trigger trigger, boolean quoteIdentifiers, boolean qualifyNames, boolean fullSyntax)
           
 java.lang.String createTSQLTrigger(Trigger trigger, boolean quoteIdentifiers, boolean qualifyNames)
           
abstract  java.lang.String[] createUserDefinedFunction(UserDefinedFunction function, boolean quoteIdentifiers, boolean qualifyNames, boolean fullSyntax)
           
abstract  java.lang.String[] createUserDefinedType(UserDefinedType udt, boolean quoteIdentifiers, boolean qualifyNames, boolean fullSyntax)
           
abstract  java.lang.String[] createView(ViewTable table, boolean quoteIdentifiers, boolean qualifyNames, boolean fullSyntax)
           
abstract  java.lang.String dropAuthorizationId(AuthorizationIdentifier authId, boolean quoteIdentifiers, boolean qualifyNames)
           
 java.lang.String dropCatalog(Catalog db, boolean quoteIdentifiers, boolean qualifyNames)
           
abstract  java.lang.String dropCheckConstraint(CheckConstraint constraint, boolean quoteIdentifiers, boolean qualifyNames)
           
 java.lang.String dropColumn(Column col, boolean quoteIdentifiers, boolean qualifyNames)
           
 java.lang.String dropDatabase(Database db, boolean quoteIdentifiers, boolean qualifyNames)
           
 java.lang.String dropEvent(Event event, boolean quoteIdentifiers, boolean qualifyNames)
           
abstract  java.lang.String dropForeignKey(ForeignKey foreignKey, boolean quoteIdentifiers, boolean qualifyNames)
           
 java.lang.String dropFunction(UserDefinedFunction function, boolean quoteIdentifiers, boolean qualifyNames)
           
 java.lang.String dropProcedure(Procedure procedure, boolean quoteIdentifiers, boolean qualifyNames)
           
abstract  java.lang.String dropUniqueConstraint(UniqueConstraint constraint, boolean quoteIdentifiers, boolean qualifyNames)
           
abstract  java.lang.String dropUserDefinedType(UserDefinedType udt, boolean quoteIdentifiers, boolean qualifyNames)
           
 java.lang.String dropView(ViewTable view, boolean quoteIdentifiers, boolean qualifyNames)
           DROP VIEW [ owner.]view-name
 org.eclipse.datatools.sqltools.core.DatabaseIdentifier getDatabaseIdentifier(org.eclipse.emf.ecore.EObject ojb)
           
 java.lang.String getIndexKeyColumns(Index index, boolean quoteIdentifiers)
           
 java.lang.String getName(org.eclipse.emf.ecore.ENamedElement element, boolean quoteIdentifiers, boolean qualifyNames)
           
 java.lang.String getTriggerBody(Trigger trigger)
           
 java.lang.String getTriggerEvents(Trigger trigger)
           
 java.lang.String getTSQLParameter(Routine routine, Parameter p)
          Returns the TSQL parameter declaration.
 java.lang.String getTSQLParameter(java.lang.String name, java.lang.String type, java.lang.String defValue, java.lang.String mode)
           
 java.lang.String[] grantPrivilege(Privilege privilege, boolean quoteIdentifiers, boolean qualifyNames, boolean fullSyntax)
          Assemble SQL statement to grant privilege.
One thing needs to be pointed out is, a privilege instance can be referenced by an instance of AuthorizationIdentifier (The grantor), it can also be contained by an instance of AuthorizationIdentifier (The grantee).
 java.lang.String revokePrivilege(Privilege privilege, boolean quoteIdentifiers, boolean qualifyNames)
          Assemble SQL statement to revoke privilege.
 
Methods inherited from class org.eclipse.datatools.connectivity.sqm.core.rte.fe.GenericDdlBuilder
addCheckConstraint, addForeignKey, addUniqueConstraint, alterTableAddColumn, createAssertion, createIndex, createProcedure, createSchema, createTable, createTrigger, createUserDefinedFunction, createUserDefinedType, createView, dropAssertion, dropIndex, dropSchema, dropTable, dropTableConstraint, dropTrigger, getEngineeringCallBack, isImplicitConstraint, setEngineeringCallBack
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SybaseDdlBuilder

public SybaseDdlBuilder()
Method Detail

createTable

public java.lang.String[] createTable(BaseTable table,
                                      boolean quoteIdentifiers,
                                      boolean qualifyNames,
                                      boolean fullSyntax)

createView

public abstract java.lang.String[] createView(ViewTable table,
                                              boolean quoteIdentifiers,
                                              boolean qualifyNames,
                                              boolean fullSyntax)

createEvent

public abstract java.lang.String[] createEvent(Event event,
                                               boolean quoteIdentifiers,
                                               boolean qualifyNames,
                                               boolean fullSyntax)

createProcedure

public abstract java.lang.String[] createProcedure(Procedure procedure,
                                                   boolean quoteIdentifiers,
                                                   boolean qualifyNames,
                                                   boolean fullSyntax)

createUserDefinedFunction

public abstract java.lang.String[] createUserDefinedFunction(UserDefinedFunction function,
                                                             boolean quoteIdentifiers,
                                                             boolean qualifyNames,
                                                             boolean fullSyntax)

createTrigger

public abstract java.lang.String[] createTrigger(Trigger trigger,
                                                 boolean quoteIdentifiers,
                                                 boolean qualifyNames,
                                                 boolean fullSyntax)

createDatabase

public abstract java.lang.String[] createDatabase(Database database,
                                                  boolean quoteIdentifiers,
                                                  boolean qualifyNames,
                                                  boolean fullSyntax)

createCatalogs

public abstract java.lang.String[] createCatalogs(Catalog catalog,
                                                  boolean quoteIdentifiers,
                                                  boolean qualifyNames,
                                                  boolean fullSyntax)

createUserDefinedType

public abstract java.lang.String[] createUserDefinedType(UserDefinedType udt,
                                                         boolean quoteIdentifiers,
                                                         boolean qualifyNames,
                                                         boolean fullSyntax)

createAuthorizationId

public abstract java.lang.String[] createAuthorizationId(AuthorizationIdentifier authId,
                                                         boolean quoteIdentifiers,
                                                         boolean qualifyNames,
                                                         boolean fullSyntax)

createColumn

public abstract java.lang.String[] createColumn(Column col,
                                                boolean quoteIdentifiers,
                                                boolean qualifyNames,
                                                boolean fullSyntax)

addUniqueConstraint

public abstract java.lang.String[] addUniqueConstraint(UniqueConstraint constraint,
                                                       boolean quoteIdentifiers,
                                                       boolean qualifyNames,
                                                       boolean fullSyntax)

addForeignKey

public abstract java.lang.String[] addForeignKey(ForeignKey foreignKey,
                                                 boolean quoteIdentifiers,
                                                 boolean qualifyNames,
                                                 boolean fullSyntax)

dropForeignKey

public abstract java.lang.String dropForeignKey(ForeignKey foreignKey,
                                                boolean quoteIdentifiers,
                                                boolean qualifyNames)

dropCheckConstraint

public abstract java.lang.String dropCheckConstraint(CheckConstraint constraint,
                                                     boolean quoteIdentifiers,
                                                     boolean qualifyNames)

dropUniqueConstraint

public abstract java.lang.String dropUniqueConstraint(UniqueConstraint constraint,
                                                      boolean quoteIdentifiers,
                                                      boolean qualifyNames)

dropUserDefinedType

public abstract java.lang.String dropUserDefinedType(UserDefinedType udt,
                                                     boolean quoteIdentifiers,
                                                     boolean qualifyNames)
Overrides:
dropUserDefinedType in class GenericDdlBuilder

dropAuthorizationId

public abstract java.lang.String dropAuthorizationId(AuthorizationIdentifier authId,
                                                     boolean quoteIdentifiers,
                                                     boolean qualifyNames)

dropView

public java.lang.String dropView(ViewTable view,
                                 boolean quoteIdentifiers,
                                 boolean qualifyNames)
     DROP VIEW
     [ owner.]view-name 
 

Overrides:
dropView in class GenericDdlBuilder

dropEvent

public java.lang.String dropEvent(Event event,
                                  boolean quoteIdentifiers,
                                  boolean qualifyNames)

dropProcedure

public java.lang.String dropProcedure(Procedure procedure,
                                      boolean quoteIdentifiers,
                                      boolean qualifyNames)
Overrides:
dropProcedure in class GenericDdlBuilder

dropFunction

public java.lang.String dropFunction(UserDefinedFunction function,
                                     boolean quoteIdentifiers,
                                     boolean qualifyNames)
Overrides:
dropFunction in class GenericDdlBuilder

dropColumn

public java.lang.String dropColumn(Column col,
                                   boolean quoteIdentifiers,
                                   boolean qualifyNames)

dropCatalog

public java.lang.String dropCatalog(Catalog db,
                                    boolean quoteIdentifiers,
                                    boolean qualifyNames)

dropDatabase

public java.lang.String dropDatabase(Database db,
                                     boolean quoteIdentifiers,
                                     boolean qualifyNames)

getName

public java.lang.String getName(org.eclipse.emf.ecore.ENamedElement element,
                                boolean quoteIdentifiers,
                                boolean qualifyNames)

addCheckConstraint

public java.lang.String[] addCheckConstraint(CheckConstraint constraint,
                                             boolean quoteIdentifiers,
                                             boolean qualifyNames,
                                             boolean fullSyntax)
Returns the SQL Statement for adding check constraint clause.

See following SQL Syntax:

   alter table [[database.][owner].table_name
      add {[constraint constraint_name]
      check (search_condition)}
 

Parameters:
constraint -
quoteIdentifiers -
qualifyNames -
fullSyntax -
Returns:
String[]

grantPrivilege

public java.lang.String[] grantPrivilege(Privilege privilege,
                                         boolean quoteIdentifiers,
                                         boolean qualifyNames,
                                         boolean fullSyntax)
Assemble SQL statement to grant privilege.
One thing needs to be pointed out is, a privilege instance can be referenced by an instance of AuthorizationIdentifier (The grantor), it can also be contained by an instance of AuthorizationIdentifier (The grantee).

In this case, to avoid generating a same grant statement two times, we only generate the statement for a contained privilege.

Syntax:
Adaptive Server Anywhere 9.x

        GRANT {
            ALL [ PRIVILEGES ],
            ALTER,
            DELETE,
            INSERT,
            REFERENCES [ ( column-name, ... ) ],
            SELECT [ ( column-name, ... ) ],
            UPDATE [ ( column-name, ... ) ],
            }
            ON [ owner.]table-name
            TO userid, ...
            [ WITH GRANT OPTION ]
            [ FROM userid  ]
 
   GRANT EXECUTE ON [ owner.]procedure-name TO userid, ...
 

Adaptive Server Enterprise 12.5.x & 15.x

        grant {all [privileges]| permission_list}
            on { table_name [(column_list)]
            | view_name[(column_list)]
            | stored_procedure_name}
            to {public | name_list | role_name}
            [with grant option]
 
           Object              permission_list
           ------------------------------------------------------
           Table               select, insert, delete, update, references
           View                select, insert, delete, update
           Column              select, update, references
           Stored procedure    execute
 
TODO: For ASE15, there're new types of permissions, I'll do research to find out if we should support them. The "[FROM userid]" sub clause won't be used here.
Generally speaking, the "[ALL PRIVILEGES]" won't appear since in system table there is no "[ALL PRIVILEGES]" type.

Parameters:
privilege - the privilege instance
quoteIdentifiers - the status of "quoted_identifier"
qualifyNames - if qulified name should be used

revokePrivilege

public java.lang.String revokePrivilege(Privilege privilege,
                                        boolean quoteIdentifiers,
                                        boolean qualifyNames)
Assemble SQL statement to revoke privilege. Syntax:
Adaptive Server Anywhere 9.x
       REVOKE table-priv, ...
           ON [ owner.]table-name
           FROM userid, ...
      
           table-priv :
           ALL [PRIVILEGES]
           | ALTER
           | DELETE
           | INSERT
           | REFERENCES [ ( column-name, ...) ]
           | SELECT [ ( column-name, ...) ]
           | UPDATE [ ( column-name, ...) ]
      
 
      REVOKE EXECUTE
          ON [ owner.]procedure-name
          FROM userid, ...
 
Adaptive Server Enterprise 12.5.x & 15.x
   revoke [grant option for]
       {all [privileges] | permission_list}
       on { table_name [(column_list)]
       | view_name [(column_list)]
       | stored_procedure_name}
       from {public | name_list | role_name}
       [cascade]
 
Generally speaking, the "[ALL PRIVILEGES]" won't appear since in system table there is no "[ALL PRIVILEGES]" type.
"[cascade]" is to control whether we should revoke the privilege granted by the revokee, thus won't used here.
"[grant option for]" will be used in delta ddl gen provider.

Parameters:
privilege - the privilege instance
quoteIdentifiers - the status of "quoted_identifier"
qualifyNames - if qulified name should be used

getTSQLParameter

public java.lang.String getTSQLParameter(Routine routine,
                                         Parameter p)
Returns the TSQL parameter declaration.

Parameters:
routine - the container of the parameter. Must have containing schema and database.
p -
Returns:

getTSQLParameter

public java.lang.String getTSQLParameter(java.lang.String name,
                                         java.lang.String type,
                                         java.lang.String defValue,
                                         java.lang.String mode)

createIndex

public java.lang.String[] createIndex(Index index,
                                      boolean quoteIdentifiers,
                                      boolean qualifyNames,
                                      boolean fullSyntax)

getTriggerEvents

public java.lang.String getTriggerEvents(Trigger trigger)

getTriggerBody

public java.lang.String getTriggerBody(Trigger trigger)

createTSQLTrigger

public java.lang.String createTSQLTrigger(Trigger trigger,
                                          boolean quoteIdentifiers,
                                          boolean qualifyNames)

getIndexKeyColumns

public java.lang.String getIndexKeyColumns(Index index,
                                           boolean quoteIdentifiers)

getDatabaseIdentifier

public org.eclipse.datatools.sqltools.core.DatabaseIdentifier getDatabaseIdentifier(org.eclipse.emf.ecore.EObject ojb)