Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/rxm.git

Fixed parent table name for column and attribute mappings.

AuthorDave Jarvis <email>
Date2015-03-24 22:39:27 GMT-0700
Commitc61c0a35f1e97b5f0ab701607e6827494e795283
Parentea3a67e
gradle.properties
+# The Gradle daemon aims to improve the startup and execution time of Gradle.
+# When set to true the Gradle daemon is to run the build.
+org.gradle.daemon=true
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# Default value: -Xmx10248m -XX:MaxPermSize=256m
+org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects.
+org.gradle.parallel=true
+
+# Enables new incubating mode (selective when configuring projects).
+org.gradle.configureondemand=true
+
source/java/com/whitemagicsoftware/rxm/ProxyParseTreeListener.java
/**
+ * Removes all event notification recipients.
+ */
+ public void clear() {
+ getListeners().clear();
+ }
+
+ /**
* Returns the list of listeners.
*
source/java/com/whitemagicsoftware/rxm/QueryBuilder.java
QueryParser.QueryContext ctx = (new QueryParser( tokens )).query();
+ eventsDeregister();
+ eventsRegister();
+ eventsNotify( ctx );
+ }
+
+ private void eventsDeregister() {
+ getProxyParseTreeListener().clear();
+ }
+
+ private void eventsRegister() {
receiveEvents( this );
receiveEvents( getSelectClause() );
receiveEvents( getFromClause() );
receiveEvents( getJoinClause() );
- notifyEvents( ctx );
}
- private void notifyEvents( QueryParser.QueryContext ctx ) {
+ private void eventsNotify( QueryParser.QueryContext ctx ) {
ParseTreeWalker.DEFAULT.walk( getProxyParseTreeListener(), ctx );
}
source/java/com/whitemagicsoftware/rxm/xml/AttributeMapContext.java
private boolean hasFollowingPayload = false;
- public AttributeMapContext( ParserRuleContext ctx ) {
- super( ctx );
+ public AttributeMapContext( ParserRuleContext ctx, String name ) {
+ super( ctx, name );
}
public Token getStart() {
String
- tableName = getParentTableText(),
+ tableName = getParentTableName(),
columnName = getColumnText(),
attributeName = getAttributeText();
source/java/com/whitemagicsoftware/rxm/xml/ColumnMapContext.java
* the abstract syntax tree.
*/
- public ColumnMapContext( ParserRuleContext ctx ) {
- super( ctx );
+ public ColumnMapContext( ParserRuleContext ctx, String name ) {
+ super( ctx, name );
}
String.format( ",%s,%s.%s",
startElement( path() ),
- getParentTableText(),
+ getParentTableName(),
getColumnText()
)
source/java/com/whitemagicsoftware/rxm/xml/Context.java
private ParserRuleContext parserRuleContext;
+ private String parentTableName = "";
+
/**
* Constructs a wrapper class that provides the ParserRuleContext and
* tree for the *Context classes.
*
* @param payload The data that contains the ParserRuleContext.
*/
protected Context( ParserRuleContext payload ) {
setParserRuleContext( payload );
+ }
+
+ protected Context( ParserRuleContext payload, String tableName ) {
+ this( payload );
+ setParentTableName( tableName );
}
}
- protected String getParentTableText() {
- return getPayload().getText();
+ /**
+ * Returns the name of the parent table.
+ *
+ * @return A non-null string, possibly empty.
+ */
+ protected String getParentTableName() {
+ return this.parentTableName;
+ }
+
+ /**
+ * Changes the name of the parent table.
+ *
+ * @param name The new parent table name (can be null).
+ */
+ public String setParentTableName( String name ) {
+ return this.parentTableName = name == null ? "" : name;
}
source/java/com/whitemagicsoftware/rxm/xml/FromClause.java
append(
- String.format( "FROM%s %s %s%s",
+ String.format( "%sFROM%s %s %s%s",
+ getNewline(),
getNewlineIndent(),
tableName,
source/java/com/whitemagicsoftware/rxm/xml/SelectClause.java
*/
@Override
- public void enterColumnMap(
- QueryParser.ColumnMapContext ctx ) {
- addLeaf( new ColumnMapContext( ctx ) );
+ public void enterColumnMap( QueryParser.ColumnMapContext ctx ) {
+ addLeaf( new ColumnMapContext( ctx, getParentTableName() ) );
}
/**
* Invoked when parsing <b><code>column &gt; attribute</code></b>. Adds
* a new leaf to the context tree.
*
* @param ctx The payload to transform.
*/
@Override
- public void enterAttributeMap(
- QueryParser.AttributeMapContext ctx ) {
- addLeaf( new AttributeMapContext( ctx ) );
+ public void enterAttributeMap( QueryParser.AttributeMapContext ctx ) {
+ addLeaf( new AttributeMapContext( ctx, getParentTableName() ) );
}
private Tree<ParserRuleContext> createTree( ParserRuleContext ctx ) {
return new SelectTree( ctx );
+ }
+
+ private QueryParser.TableContext getParentTable() {
+ return ((QueryParser.TableMapContext)getParentParserRuleContext()).table(0);
+ }
+
+ private ParserRuleContext getParentParserRuleContext() {
+ return ((TableMapContext)getTreePayload()).getParserRuleContext();
+ }
+
+ private String getParentTableName() {
+ return getParentTable().getText();
+ }
+
+ private ParserRuleContext getTreePayload() {
+ return getTree().getPayload();
}
}
Delta85 lines added, 17 lines removed, 68-line increase