|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.farrago.ddl.gen.DdlGenerator
public abstract class DdlGenerator
Base class for DDL generators which use the visitor pattern to generate DDL given a catalog object.
Escape rules:
Nested Class Summary | |
---|---|
private static class |
DdlGenerator.MyComparator
Comparator for schema elements to ensure that export file occurs in an intuitive order. |
private static class |
DdlGenerator.NamerImpl
Implementation of JmiObjUtil.Namer which
generates names for objects based on their position in the CWM
catalog-schema-object hierarchy. |
Field Summary | |
---|---|
private static List<Class> |
ADDITIONAL_PARAMETER_TYPES
|
protected boolean |
dropCascade
|
protected static String |
NL
|
protected String |
previousSetSchema
|
private boolean |
schemaQualified
|
protected static String |
SEP
|
protected static SqlDialect |
sqlDialect
|
protected static String |
VALUE_NULL
|
private ReflectiveVisitDispatcher<DdlGenerator,CwmModelElement> |
visitDispatcher
|
Constructor Summary | |
---|---|
DdlGenerator()
|
Method Summary | |
---|---|
abstract void |
gatherElements(List<CwmModelElement> list,
String schemaName,
boolean includeNonSchemaElements,
CwmCatalog catalog)
Gathers a list of elements in a schema, optionally including elements which don't belong to any schema. |
private void |
generate(String method,
CwmModelElement e,
GeneratedDdlStmt stmt)
|
void |
generateCreate(CwmModelElement e,
GeneratedDdlStmt stmt)
|
void |
generateDrop(CwmModelElement e,
GeneratedDdlStmt stmt)
|
boolean |
generateSetSchema(GeneratedDdlStmt stmt,
String schemaName,
boolean evenIfUnchanged)
Appends a 'SET SCHEMA' command to stmt if
schemaName is not null. |
String |
getExportText(List<CwmModelElement> exportList,
boolean sort)
Converts a set of elements to a string using this generator. |
protected abstract JmiModelView |
getModelView()
|
protected static SqlTypeName |
getSqlTypeName(CwmClassifier classifier)
|
protected static boolean |
hasPrimaryKeyConstraint(FemStoredColumn col)
|
static String |
literal(String str)
|
private RefAssociation |
lookupAssoc(String assocName,
JmiModelGraph modelGraph)
Looks up a named association in the model, fails if not found. |
private RefClass |
lookupClass(String className,
JmiModelGraph modelGraph)
Looks up a named class in the model, fails if not found. |
protected void |
name(StringBuilder sb,
CwmNamespace schema,
String objectName)
Outputs the name of an object, optionally qualified by a schema name. |
static String |
quote(String str)
|
void |
setDropCascade(boolean dropCascade)
Sets whether DROP statements should include a CASCADE directive at the end. |
void |
setSchemaQualified(boolean schemaQualified)
Sets whether object names should be qualified with a schema name, if they have one. |
protected abstract boolean |
typeSupportsReplace(String typeName)
Returns whether an object type supports CREATE OR REPLACE
operation. |
static String |
unquoteLiteral(String str)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final SqlDialect sqlDialect
protected static final String VALUE_NULL
protected static final String NL
protected static final String SEP
private static final List<Class> ADDITIONAL_PARAMETER_TYPES
private boolean schemaQualified
protected boolean dropCascade
protected String previousSetSchema
private final ReflectiveVisitDispatcher<DdlGenerator,CwmModelElement> visitDispatcher
Constructor Detail |
---|
public DdlGenerator()
Method Detail |
---|
protected abstract JmiModelView getModelView()
public void setSchemaQualified(boolean schemaQualified)
schemaQualified
- whether to qualify object names with schema namepublic void setDropCascade(boolean dropCascade)
dropCascade
- whether to append CASCADE to DROP statementspublic boolean generateSetSchema(GeneratedDdlStmt stmt, String schemaName, boolean evenIfUnchanged)
stmt
if
schemaName
is not null. If evenIfUnchanged
is true,
does so even if the schema is the same as the previous call to this
method.
stmt
- Statement to append toschemaName
- Name of schemaevenIfUnchanged
- Whether to generate again for same schema name
public void generateCreate(CwmModelElement e, GeneratedDdlStmt stmt)
public void generateDrop(CwmModelElement e, GeneratedDdlStmt stmt)
private void generate(String method, CwmModelElement e, GeneratedDdlStmt stmt)
public static String quote(String str)
public static String literal(String str)
public static String unquoteLiteral(String str)
protected static SqlTypeName getSqlTypeName(CwmClassifier classifier)
protected static boolean hasPrimaryKeyConstraint(FemStoredColumn col)
public String getExportText(List<CwmModelElement> exportList, boolean sort)
If sort
is specified, sorts list first so that dependent
elements are created after their dependencies.
exportList
- List of elements to exportsort
- Whether to sort list in dependency order
private RefClass lookupClass(String className, JmiModelGraph modelGraph)
className
- Association namemodelGraph
- Model graph
private RefAssociation lookupAssoc(String assocName, JmiModelGraph modelGraph)
assocName
- Association namemodelGraph
- Model graph
protected abstract boolean typeSupportsReplace(String typeName)
CREATE OR REPLACE
operation.
typeName
- Name of object type, e.g. "CLUSTERED INDEX"
public abstract void gatherElements(List<CwmModelElement> list, String schemaName, boolean includeNonSchemaElements, CwmCatalog catalog)
list
- List to populateschemaName
- Name of schemaincludeNonSchemaElements
- Whether to include elements which do not
belong to a schemacatalog
- Catalogprotected void name(StringBuilder sb, CwmNamespace schema, String objectName)
sb
- StringBuilder to write toschema
- Schema object belongs to, or null if object does not belong
to a schemaobjectName
- Name of object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |