|
|||||||||
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 net.sf.farrago.ddl.gen.FarragoDdlGenerator
public class FarragoDdlGenerator
Generates DDL statements from catalog objects.
Nested Class Summary | |
---|---|
protected static class |
FarragoDdlGenerator.FemStorageOptionNameComparator
|
Field Summary | |
---|---|
protected JmiModelView |
modelView
|
private static List<String> |
NON_REPLACEABLE_TYPE_NAMES
|
Fields inherited from class net.sf.farrago.ddl.gen.DdlGenerator |
---|
dropCascade, NL, previousSetSchema, SEP, sqlDialect, VALUE_NULL |
Constructor Summary | |
---|---|
FarragoDdlGenerator(JmiModelView modelView)
Creates a DDL generator. |
Method Summary | ||
---|---|---|
private void |
add(FemRoutineParameter parameter,
ProcedureType routineType,
StringBuilder sb)
Generates DDL for a routine parameter. |
|
protected void |
addColumns(StringBuilder sb,
List<CwmColumn> columns)
|
|
protected void |
addColumns(StringBuilder sb,
List<CwmColumn> columns,
boolean skipDefaults,
boolean skipNullable)
|
|
protected void |
addDescription(StringBuilder sb,
FemAnnotatedElement element)
|
|
private void |
addOperations(StringBuilder sb,
List<CwmOperation> operations)
|
|
protected void |
addOptions(StringBuilder sb,
Collection<FemStorageOption> options)
|
|
protected void |
addOptions(StringBuilder sb,
Collection<FemStorageOption> options,
int indent)
|
|
private void |
addPrimaryKeyConstraint(StringBuilder sb,
List<String> keyColumns)
|
|
|
allOfClass(Class<T> clazz)
|
|
|
allOfType(Class<T> clazz)
|
|
private void |
appendType(StringBuilder sb,
CwmClassifier type,
Integer precision,
Integer scale,
Integer length,
NullableType nullable,
CwmExpression defaultValue,
boolean qualifyType)
|
|
void |
create(CwmDependency dependency,
GeneratedDdlStmt stmt)
|
|
void |
create(CwmOperation operation,
GeneratedDdlStmt stmt)
|
|
void |
create(FemDataServer server,
GeneratedDdlStmt stmt)
|
|
void |
create(FemDataWrapper wrapper,
GeneratedDdlStmt stmt)
|
|
void |
create(FemForeignTable table,
GeneratedDdlStmt stmt)
|
|
void |
create(FemLabel label,
GeneratedDdlStmt stmt)
|
|
void |
create(FemLocalIndex index,
GeneratedDdlStmt stmt)
|
|
void |
create(FemLocalSchema schema,
GeneratedDdlStmt stmt)
|
|
void |
create(FemLocalTable table,
GeneratedDdlStmt stmt)
|
|
void |
create(FemLocalView view,
GeneratedDdlStmt stmt)
|
|
void |
create(FemRoutine routine,
GeneratedDdlStmt stmt)
|
|
void |
create(FemSqldistinguishedType type,
GeneratedDdlStmt stmt)
|
|
void |
create(FemSqlobjectType type,
GeneratedDdlStmt stmt)
|
|
protected void |
createHeader(StringBuilder sb,
String typeName,
boolean replace,
String newName)
|
|
protected void |
createHeader(StringBuilder sb,
String typeName,
GeneratedDdlStmt stmt)
|
|
protected void |
drop(CwmModelElement e,
String elementType,
GeneratedDdlStmt stmt)
|
|
void |
drop(CwmSchema schema,
GeneratedDdlStmt stmt)
|
|
void |
drop(CwmTable table,
GeneratedDdlStmt stmt)
|
|
void |
drop(CwmView view,
GeneratedDdlStmt stmt)
|
|
void |
drop(FemDataServer server,
GeneratedDdlStmt stmt)
|
|
void |
drop(FemDataWrapper plugin,
GeneratedDdlStmt stmt)
|
|
void |
drop(FemLabel label,
GeneratedDdlStmt stmt)
|
|
void |
drop(FemLocalIndex index,
GeneratedDdlStmt stmt)
|
|
private RefClass |
findRefClass(Class<? extends RefObject> clazz)
|
|
static String |
formatTypeInfo(CwmColumn col)
Format the core elements of a column's type (type name, precision, scale, length) into SQL format. |
|
static void |
formatTypeInfo(StringBuilder sb,
CwmClassifier type,
Integer precision,
Integer scale,
Integer length)
Format the core elements of a column's type (type name, precision, scale, length) into SQL format. |
|
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. |
|
void |
generateColumnsAndKeys(StringBuilder sb,
List<CwmColumn> columns,
boolean skipDefaults,
boolean skipNullable,
List<String> imposedPrimaryKey)
Generates the column and key definitions of a table as a SQL string (enclosed in parentheses unless there are no columns). |
|
String |
getExportText(List<CwmModelElement> exportList,
boolean sort)
Converts a set of elements to a string using this generator. |
|
protected JmiModelView |
getModelView()
|
|
private static void |
indent(StringBuilder sb,
int indent)
|
|
protected static String |
maybeNot(boolean b,
String s)
Generates either "s" or "NOT s", depending on b . |
|
private void |
methodBody(FemRoutine routine,
StringBuilder sb)
Generates a parameters, keyword list and body of a method. |
|
protected boolean |
typeSupportsReplace(String typeName)
Returns whether an object type supports CREATE OR REPLACE
operation. |
Methods inherited from class net.sf.farrago.ddl.gen.DdlGenerator |
---|
generateCreate, generateDrop, generateSetSchema, getSqlTypeName, hasPrimaryKeyConstraint, literal, name, quote, setDropCascade, setSchemaQualified, unquoteLiteral |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final List<String> NON_REPLACEABLE_TYPE_NAMES
protected final JmiModelView modelView
Constructor Detail |
---|
public FarragoDdlGenerator(JmiModelView modelView)
The modelView
parameter can be null if you are generating
DDL for a single object. A model view is required if calling DdlGenerator.gatherElements(java.util.List
or getExportText(java.util.List,
boolean)
with sort=true
.
modelView
- Model graphMethod Detail |
---|
private RefClass findRefClass(Class<? extends RefObject> clazz)
public <T extends RefObject> Collection<T> allOfClass(Class<T> clazz)
public <T extends RefObject> Collection<T> allOfType(Class<T> clazz)
public String getExportText(List<CwmModelElement> exportList, boolean sort)
DdlGenerator
If sort
is specified, sorts list first so that dependent
elements are created after their dependencies.
getExportText
in class DdlGenerator
exportList
- List of elements to exportsort
- Whether to sort list in dependency order
protected boolean typeSupportsReplace(String typeName)
DdlGenerator
CREATE OR REPLACE
operation.
typeSupportsReplace
in class DdlGenerator
typeName
- Name of object type, e.g. "CLUSTERED INDEX"
protected JmiModelView getModelView()
getModelView
in class DdlGenerator
public void gatherElements(List<CwmModelElement> list, String schemaName, boolean includeNonSchemaElements, CwmCatalog catalog)
DdlGenerator
gatherElements
in class DdlGenerator
list
- List to populateschemaName
- Name of schemaincludeNonSchemaElements
- Whether to include elements which do not
belong to a schemacatalog
- Catalogprotected void createHeader(StringBuilder sb, String typeName, GeneratedDdlStmt stmt)
protected void createHeader(StringBuilder sb, String typeName, boolean replace, String newName)
public void create(FemLocalView view, GeneratedDdlStmt stmt)
public void create(FemLocalSchema schema, GeneratedDdlStmt stmt)
public void create(FemLocalTable table, GeneratedDdlStmt stmt)
public void create(FemForeignTable table, GeneratedDdlStmt stmt)
public void create(FemDataWrapper wrapper, GeneratedDdlStmt stmt)
public void create(CwmOperation operation, GeneratedDdlStmt stmt)
public void create(FemRoutine routine, GeneratedDdlStmt stmt)
private void methodBody(FemRoutine routine, StringBuilder sb)
routine
- Routinesb
- String buffer to write toprivate void add(FemRoutineParameter parameter, ProcedureType routineType, StringBuilder sb)
parameter
- ParameterroutineType
- Type of routine parameter belongs tosb
- StringBuilder to append toprivate void appendType(StringBuilder sb, CwmClassifier type, Integer precision, Integer scale, Integer length, NullableType nullable, CwmExpression defaultValue, boolean qualifyType)
public static String formatTypeInfo(CwmColumn col)
col
- CwmColumn object we want type info for
public static void formatTypeInfo(StringBuilder sb, CwmClassifier type, Integer precision, Integer scale, Integer length)
Note that this was refactored out of appendType(StringBuilder,
CwmClassifier, Integer, Integer, Integer, NullableType, CwmExpression,
boolean)
to allow separate access.
sb
- StringBuilder to hold the formatted type informationtype
- CwmClassifier object representing the column typeprecision
- Integer specifying the column's precisionscale
- Integer specifying the column's scalelength
- Integer specifying the column's lengthprotected static String maybeNot(boolean b, String s)
b
.
b
- Conditions
- Flag string
public void create(FemSqlobjectType type, GeneratedDdlStmt stmt)
private void addOperations(StringBuilder sb, List<CwmOperation> operations)
public void create(FemSqldistinguishedType type, GeneratedDdlStmt stmt)
public void create(FemDataServer server, GeneratedDdlStmt stmt)
public void create(CwmDependency dependency, GeneratedDdlStmt stmt)
public void drop(CwmSchema schema, GeneratedDdlStmt stmt)
public void drop(CwmView view, GeneratedDdlStmt stmt)
public void drop(FemDataServer server, GeneratedDdlStmt stmt)
public void drop(CwmTable table, GeneratedDdlStmt stmt)
public void drop(FemDataWrapper plugin, GeneratedDdlStmt stmt)
public void create(FemLocalIndex index, GeneratedDdlStmt stmt)
public void drop(FemLocalIndex index, GeneratedDdlStmt stmt)
public void create(FemLabel label, GeneratedDdlStmt stmt)
public void drop(FemLabel label, GeneratedDdlStmt stmt)
protected void addColumns(StringBuilder sb, List<CwmColumn> columns)
protected void addColumns(StringBuilder sb, List<CwmColumn> columns, boolean skipDefaults, boolean skipNullable)
public void generateColumnsAndKeys(StringBuilder sb, List<CwmColumn> columns, boolean skipDefaults, boolean skipNullable, List<String> imposedPrimaryKey)
sb
- receives generated stringcolumns
- list of column definitions to generateskipDefaults
- whether to omit default value definitionsskipNullable
- whether to omit NOT NULL constraint definitionsimposedPrimaryKey
- if not null, use as PRIMARY KEYprotected void addOptions(StringBuilder sb, Collection<FemStorageOption> options)
protected void addOptions(StringBuilder sb, Collection<FemStorageOption> options, int indent)
private static void indent(StringBuilder sb, int indent)
private void addPrimaryKeyConstraint(StringBuilder sb, List<String> keyColumns)
protected void addDescription(StringBuilder sb, FemAnnotatedElement element)
protected void drop(CwmModelElement e, String elementType, GeneratedDdlStmt stmt)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |