r52531 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52530‎ | r52531 | r52532 >
Date:21:46, 28 June 2009
Author:daniel
Status:deferred
Tags:
Comment:
custom sql scripts, etc
Modified paths:
  • /trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/AbstractIntegratorApp.java (modified) (history)
  • /trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/FeatureSetSourceDescriptor.java (modified) (history)
  • /trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/RunIntegratorScript.java (modified) (history)
  • /trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/RunIntegratorSql.java (modified) (history)
  • /trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/list.sql (modified) (history)
  • /trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/scriptURL.bsh (added) (history)

Diff [purge]

Index: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/AbstractIntegratorApp.java
@@ -14,7 +14,6 @@
1515 import java.util.Collection;
1616 import java.util.List;
1717 import java.util.Map;
18 -import java.util.regex.Pattern;
1918
2019 import javax.sql.DataSource;
2120
@@ -389,9 +388,9 @@
390389 List<Functor<String, String>> more = sourceDescriptor.getScriptManglers();
391390 if (more!=null) list.addAll(more);
392391
393 - list.add( new SqlScriptRunner.RegularExpressionMangler(Pattern.compile("/\\* *wikiword_prefix* \\*/"), getConfiguredDataset().getDbPrefix()) );
394 - list.add( new SqlScriptRunner.RegularExpressionMangler(Pattern.compile("/\\* *wikiword_db* \\*/"), getConfiguredDatasetName()) );
395 - list.add( new SqlScriptRunner.RegularExpressionMangler(Pattern.compile("/\\* *wikiword_target_table* \\*/"), getTargetTableName()) );
 392+ list.add( SqlScriptRunner.makeCommentSubstitutionMangler("wikiword_prefix", getConfiguredDataset().getDbPrefix()) );
 393+ list.add( SqlScriptRunner.makeCommentSubstitutionMangler("wikiword_db", getConfiguredDatasetName()) );
 394+ list.add( SqlScriptRunner.makeCommentSubstitutionMangler("wikiword_target_table", getTargetTableName()) );
396395
397396 return list;
398397 }
Index: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/FeatureSetSourceDescriptor.java
@@ -11,6 +11,7 @@
1212 import java.util.regex.Pattern;
1313
1414 import de.brightbyte.data.Functor;
 15+import de.brightbyte.db.SqlScriptRunner;
1516 import de.brightbyte.db.SqlScriptRunner.RegularExpressionMangler;
1617 import de.brightbyte.text.Chunker;
1718 import de.brightbyte.text.CsvLineChunker;
@@ -144,9 +145,7 @@
145146 Map<String, String> subst = getTweak("sql-comment-subst", Collections.<String, String>emptyMap());
146147
147148 for (Map.Entry<String, String>e: subst.entrySet()) {
148 - Pattern p = Pattern.compile("/\\* *"+e.getKey()+" *\\*/");
149 - RegularExpressionMangler m = new RegularExpressionMangler(p, e.getValue());
150 - manglers.add(m);
 149+ manglers.add(SqlScriptRunner.makeCommentSubstitutionMangler(e.getKey(), e.getValue()));
151150 }
152151
153152 return manglers;
Index: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/scriptURL.bsh
@@ -0,0 +1,3 @@
 2+scriptURL( path ) {
 3+ return new java.net.URL(scriptBaseUrl, path).toString();
 4+}
\ No newline at end of file
Property changes on: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/scriptURL.bsh
___________________________________________________________________
Added: svn:mergeinfo
Index: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/RunIntegratorSql.java
@@ -12,6 +12,7 @@
1313 import java.util.ArrayList;
1414 import java.util.Collection;
1515 import java.util.Map;
 16+import java.util.regex.Matcher;
1617 import java.util.regex.Pattern;
1718
1819 import javax.sql.DataSource;
@@ -123,11 +124,15 @@
124125
125126 for (Map.Entry<Object, String> e: subst.entrySet()) {
126127 Object o = e.getKey();
127 - Pattern p;
128 - if (o instanceof Pattern) p = (Pattern)o;
129 - else p = Pattern.compile("/\\* *"+o+"* \\*/");
 128+ Functor<String, String> f;
 129+ if (o instanceof Pattern) {
 130+ f = new SqlScriptRunner.RegularExpressionMangler((Pattern)o, Matcher.quoteReplacement(e.getValue()));
 131+ }
 132+ else {
 133+ f = SqlScriptRunner.makeCommentSubstitutionMangler(e.getKey().toString(), e.getValue());
 134+ }
130135
131 - this.subsitutions.add(new SqlScriptRunner.RegularExpressionMangler(p, e.getValue()));
 136+ this.subsitutions.add(f);
132137 }
133138 }
134139
@@ -246,11 +251,11 @@
247252
248253 if (this.subsitutions!=null) list.addAll(this.subsitutions);
249254
250 - list.add( new SqlScriptRunner.RegularExpressionMangler(Pattern.compile("/\\* *wikiword_prefix* \\*/"), getConfiguredDataset().getDbPrefix()) );
251 - list.add( new SqlScriptRunner.RegularExpressionMangler(Pattern.compile("/\\* *wikiword_db* \\*/"), getConfiguredDatasetName()) );
 255+ list.add( SqlScriptRunner.makeCommentSubstitutionMangler("wikiword_prefix", getConfiguredDataset().getDbPrefix()) );
 256+ list.add( SqlScriptRunner.makeCommentSubstitutionMangler("wikiword_db", getConfiguredDatasetName()) );
252257
253 - if (getMappingTableName()!=null) list.add( new SqlScriptRunner.RegularExpressionMangler(Pattern.compile("/\\* *wikiword_mapping_table* \\*/"), getMappingTableName()) );
254 - if (getForeignTableName()!=null) list.add( new SqlScriptRunner.RegularExpressionMangler(Pattern.compile("/\\* *wikiword_foreign_table* \\*/"), getForeignTableName()) );
 258+ if (getMappingTableName()!=null) list.add( SqlScriptRunner.makeCommentSubstitutionMangler("wikiword_mapping_table", getMappingTableName()) );
 259+ if (getForeignTableName()!=null) list.add( SqlScriptRunner.makeCommentSubstitutionMangler("wikiword_foreign_table", getForeignTableName()) );
255260
256261 return list;
257262 }
Index: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/RunIntegratorScript.java
@@ -99,6 +99,7 @@
100100 i.set("datasource", getConfiguredDataSource());
101101 i.set("scriptManglers", getSqlScriptManglers());
102102 i.set("tablePrefix", getConfiguredDataset().getDbPrefix());
 103+ i.set("scriptBaseUrl", getInputHelper().getURL(n));
103104
104105 i.eval("import java.util.*;");
105106 i.eval("import de.brightbyte.wikiword.*;");
@@ -120,8 +121,8 @@
121122 protected Collection<Functor<String, String>> getSqlScriptManglers() {
122123 ArrayList<Functor<String, String>> list = new ArrayList<Functor<String, String>>();
123124
124 - list.add( new SqlScriptRunner.RegularExpressionMangler(Pattern.compile("/\\* *wikiword_prefix* \\*/"), getConfiguredDataset().getDbPrefix()) );
125 - list.add( new SqlScriptRunner.RegularExpressionMangler(Pattern.compile("/\\* *wikiword_db* \\*/"), getConfiguredDatasetName()) );
 125+ list.add( SqlScriptRunner.makeCommentSubstitutionMangler("wikiword_prefix", getConfiguredDataset().getDbPrefix()) );
 126+ list.add( SqlScriptRunner.makeCommentSubstitutionMangler("wikiword_db", getConfiguredDatasetName()) );
126127
127128 return list;
128129 }
Index: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/list.sql
@@ -1 +1 @@
2 -SELECT * FROM /* wikiword_prefix *//* wikiword_mapping_table */ /* list_order */ /* list_limit */;
\ No newline at end of file
 2+SELECT /* list_fields | * */ FROM /* wikiword_prefix *//* wikiword_mapping_table */ /* list_order */ /* list_limit */;
\ No newline at end of file

Status & tagging log