|
SMACS | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsmacs.find.InsertFrom
derived from earlier {link smacs.find.Selins}. - described as follows...
The usual way to transfer data from one database to another is in using a combination of SELECT (to get some records) with an INSERT (to put some records) in an sql statement. In actual essence a VIEW definition will look very similar which we will be checking for in another place. Here we want to be able to scan real world (handwritten) code for transfer rules - so we can implant them later into a larger schema mapping application.
Essentially, we try to find (a) an sql statement (b) with both an INSERT and SELECT subrule (c) which are embedded and close to each other - after having detected it we want to (x) split the embedded SELECT subrule getter from the INSERT setter part (y) create a jdbc/sqlj database cursor with the getter subrule and (z) create a java loop that execs an INSERT on the target for each record current on the cursor created with the SELECT.
The real compiler generation is being done in another part of this project. The example executions in here will handle very simple variants with a known set of statements in a known example transfer script. Let's try to keep it simple here to let a later developer know the code flow of the project ;-)
| Nested Class Summary | |
static class |
InsertFrom.Rule
a compact notation to pass around parts of a SelIns rule |
| Field Summary | |
static String |
FromClause
|
static String |
InsertFromStatement
|
static String |
InsertIntoClause
|
static String |
IntoTableClause
|
protected static Logger |
log
|
static String |
ScriptRoot
|
static String |
Selector
|
static String |
SelectWhereClause
|
static String |
WhereClause
|
| Constructor Summary | |
InsertFrom()
|
|
| Method Summary | |
String |
getRuleScript(SimpleNode tree)
generating glue code around getRules() javacode |
Vector |
getSelectInsertRuleVector(SimpleNode tree)
|
static void |
main(String[] args)
self test |
JavaWriter |
newJavaWriter()
overriding this one is the easiest way to generate some slightly different output code |
static Vector |
newRuleFromInsertFromStatement(SimpleNode statement)
build new Rule(s) from sql statement. |
SqlWriter |
newSqlWriter()
overriding this one is the easiest way to generate some slightly different output code |
String |
strFromTableCode(JavaWriter jj,
SqlWriter qq,
SimpleNode tree)
|
String |
strIntoTableCode(JavaWriter jj,
SqlWriter qq,
SimpleNode tree)
|
String |
strRuleScript(JavaWriter jj,
SqlWriter qq,
SimpleNode tree)
generating glue code around getRules() javacode |
String |
strSelectCode(JavaWriter jj,
SqlWriter qq,
SimpleNode tree)
|
String |
strSelectInsertRule(JavaWriter jj,
SqlWriter qq,
InsertFrom.Rule rule)
|
String |
strSelectInsertRules(JavaWriter jj,
SqlWriter qq,
SimpleNode tree)
|
String |
strWhereCode(JavaWriter jj,
SqlWriter qq,
SimpleNode tree)
|
static String |
toRuleScript(SimpleNode tree)
generating glue code around getRules() javacode |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static final Logger log
public static final String InsertFromStatement
public static final String SelectWhereClause
public static final String WhereClause
public static final String FromClause
public static final String InsertIntoClause
public static final String IntoTableClause
public static final String ScriptRoot
public static final String Selector
| Constructor Detail |
public InsertFrom()
| Method Detail |
public static Vector newRuleFromInsertFromStatement(SimpleNode statement)
public Vector getSelectInsertRuleVector(SimpleNode tree)
public String strIntoTableCode(JavaWriter jj,
SqlWriter qq,
SimpleNode tree)
public String strFromTableCode(JavaWriter jj,
SqlWriter qq,
SimpleNode tree)
public String strSelectCode(JavaWriter jj,
SqlWriter qq,
SimpleNode tree)
public String strWhereCode(JavaWriter jj,
SqlWriter qq,
SimpleNode tree)
public String strSelectInsertRule(JavaWriter jj,
SqlWriter qq,
InsertFrom.Rule rule)
public String strSelectInsertRules(JavaWriter jj,
SqlWriter qq,
SimpleNode tree)
public String strRuleScript(JavaWriter jj,
SqlWriter qq,
SimpleNode tree)
public JavaWriter newJavaWriter()
public SqlWriter newSqlWriter()
public String getRuleScript(SimpleNode tree)
public static String toRuleScript(SimpleNode tree)
public static void main(String[] args)
|
SMACS | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||