Sandbox-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
October 2009
- 6 participants
- 38 discussions
r302 - wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc
by kmorin@users.nuiton.org 30 Oct '09
by kmorin@users.nuiton.org 30 Oct '09
30 Oct '09
Author: kmorin
Date: 2009-10-30 15:36:35 +0100 (Fri, 30 Oct 2009)
New Revision: 302
Modified:
wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyExtensionStorageJDBC.java
Log:
Correction in the getAllExtensions(true) method
Modified: wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyExtensionStorageJDBC.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyExtensionStorageJDBC.java 2009-10-29 18:53:59 UTC (rev 301)
+++ wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyExtensionStorageJDBC.java 2009-10-30 14:36:35 UTC (rev 302)
@@ -269,7 +269,8 @@
adminResultSet.beforeFirst();
while (adminResultSet.next()) {
String extName = adminResultSet.getString(COL_NAME);
- String extId = getLastVersion(extName);
+ String extVersion = getLastVersion(extName);
+ String extId = WikittyExtension.computeId(extName, extVersion);
result.add(restore(extId));
}
} else {
1
0
r301 - in wikengo_core-wikitty: . wikengo_core-wikitty-api wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty wikengo_core-wikitty-jdbc-impl
by tchemit@users.nuiton.org 29 Oct '09
by tchemit@users.nuiton.org 29 Oct '09
29 Oct '09
Author: tchemit
Date: 2009-10-29 19:53:59 +0100 (Thu, 29 Oct 2009)
New Revision: 301
Modified:
wikengo_core-wikitty/
wikengo_core-wikitty/wikengo_core-wikitty-api/
wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntity.java
wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityBean.java
wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityWikitty.java
wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/
Log:
remove all PCS on Wikitty + svn:ignore on target + *.iml
Property changes on: wikengo_core-wikitty
___________________________________________________________________
Added: svn:ignore
+ target
*.iml
Property changes on: wikengo_core-wikitty/wikengo_core-wikitty-api
___________________________________________________________________
Added: svn:ignore
+ target
*.iml
Modified: wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntity.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntity.java 2009-10-29 15:12:30 UTC (rev 300)
+++ wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntity.java 2009-10-29 18:53:59 UTC (rev 301)
@@ -17,7 +17,6 @@
package org.sharengo.wikitty;
-import java.beans.PropertyChangeListener;
import java.io.Serializable;
import java.util.Collection;
@@ -78,17 +77,4 @@
* @return
*/
public FieldType getFieldType(String ext, String fieldName);
-
- public void addPropertyChangeListener(
- PropertyChangeListener listener);
-
- public void removePropertyChangeListener(
- PropertyChangeListener listener);
-
- public void addPropertyChangeListener(String propertyName,
- PropertyChangeListener listener);
-
- public void removePropertyChangeListener(String propertyName,
- PropertyChangeListener listener);
-
}
Modified: wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityBean.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityBean.java 2009-10-29 15:12:30 UTC (rev 300)
+++ wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityBean.java 2009-10-29 18:53:59 UTC (rev 301)
@@ -17,8 +17,6 @@
package org.sharengo.wikitty;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -39,9 +37,6 @@
protected String id;
protected String version;
- /** used to add property change support to wikitty object */
- protected PropertyChangeSupport propertyChange = new PropertyChangeSupport(this);
-
/**
* Map is LinkedHashMap to maintains order like user want
* key: extension name
@@ -88,31 +83,10 @@
public void setField(String ext, String fieldName, Object value) {
String key = ext + "$" + fieldName;
fieldValue.put(key, value);
- propertyChange.firePropertyChange(fieldName, null, value);
}
public FieldType getFieldType(String ext, String fieldName) {
throw new UnsupportedOperationException("Not supported yet.");
}
- public void addPropertyChangeListener(
- PropertyChangeListener listener) {
- propertyChange.addPropertyChangeListener(listener);
}
-
- public void removePropertyChangeListener(
- PropertyChangeListener listener) {
- propertyChange.removePropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String propertyName,
- PropertyChangeListener listener) {
- propertyChange.addPropertyChangeListener(propertyName, listener);
- }
-
- public void removePropertyChangeListener(String propertyName,
- PropertyChangeListener listener) {
- propertyChange.removePropertyChangeListener(propertyName, listener);
- }
-
- }
Modified: wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityWikitty.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityWikitty.java 2009-10-29 15:12:30 UTC (rev 300)
+++ wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityWikitty.java 2009-10-29 18:53:59 UTC (rev 301)
@@ -17,8 +17,6 @@
package org.sharengo.wikitty;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.Collection;
import java.util.Collections;
@@ -33,7 +31,7 @@
* Last update: $Date$
* by : $Author$
*/
-public class BusinessEntityWikitty implements BusinessEntity,PropertyChangeListener {
+public class BusinessEntityWikitty implements BusinessEntity {
private static final long serialVersionUID = 1L;
@@ -48,36 +46,8 @@
public BusinessEntityWikitty() {
setWikitty( new Wikitty() );
- // on ecoute les changement du wikkity
- wikitty.addPropertyChangeListener(this);
}
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- propertyChange.firePropertyChange(evt);
- }
-
- public void addPropertyChangeListener(
- PropertyChangeListener listener) {
- propertyChange.addPropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(
- PropertyChangeListener listener) {
- propertyChange.removePropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String propertyName,
- PropertyChangeListener listener) {
- System.out.println("addPRopertyChangeListener "+propertyName+" = "+listener);
- propertyChange.addPropertyChangeListener(propertyName, listener);
- }
-
- public void removePropertyChangeListener(String propertyName,
- PropertyChangeListener listener) {
- propertyChange.removePropertyChangeListener(propertyName, listener);
- }
-
public String getWikittyId() {
String result = getWikitty().getId();
return result;
Property changes on: wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl
___________________________________________________________________
Added: svn:ignore
+ target
*.iml
1
0
r300 - in wikengo_core-wikitty: wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc wikengo_core-wikitty-jdbc-impl/src/test/java/org/sharengo/wikitty/jdbc
by kmorin@users.nuiton.org 29 Oct '09
by kmorin@users.nuiton.org 29 Oct '09
29 Oct '09
Author: kmorin
Date: 2009-10-29 16:12:30 +0100 (Thu, 29 Oct 2009)
New Revision: 300
Modified:
wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/AbstractWikittyService.java
wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/WikittyExtensionStorage.java
wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/WikittyService.java
wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/WikittyServiceInMemory.java
wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/Restriction2Solr.java
wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyExtensionStorageJDBC.java
wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyJDBCUtil.java
wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyQueryParser.java
wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittySearchEnginSolr.java
wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyServiceJDBC.java
wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyStorageJDBC.java
wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/test/java/org/sharengo/wikitty/jdbc/JDBCStorageTest.java
wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/test/java/org/sharengo/wikitty/jdbc/TreeTest.java
Log:
add getAllExtensions(boolean) method + few corrections
Modified: wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/AbstractWikittyService.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/AbstractWikittyService.java 2009-10-29 08:51:03 UTC (rev 299)
+++ wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/AbstractWikittyService.java 2009-10-29 15:12:30 UTC (rev 300)
@@ -105,7 +105,7 @@
/**
* Store and index wikitties object
- * @param wikitty
+ * @param wikitties
*/
public UpdateResponse store(Collection<Wikitty> wikitties) {
return store(wikitties, false);
@@ -113,8 +113,8 @@
/**
* Store and index wikitties object
- * @param wikitty
- * @param TODO
+ * @param wikitties
+ * @param disableAutoVersionIncrement
*/
public UpdateResponse store(Collection<Wikitty> wikitties, boolean disableAutoVersionIncrement) {
try {
@@ -166,9 +166,14 @@
return result;
}
+ public List<WikittyExtension> getAllExtensions(boolean lastVersion) {
+ List<WikittyExtension> result = getExtensionStorage().getAllExtensions(lastVersion);
+ return result;
+ }
+
/**
* Save just one extension
- * @param ext
+ * @param exts
* @throws java.io.IOException
*/
public UpdateResponse storeExtension(Collection<WikittyExtension> exts) {
Modified: wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/WikittyExtensionStorage.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/WikittyExtensionStorage.java 2009-10-29 08:51:03 UTC (rev 299)
+++ wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/WikittyExtensionStorage.java 2009-10-29 15:12:30 UTC (rev 300)
@@ -61,6 +61,13 @@
public List<String> getAllExtensionIds();
/**
+ * Return all extensions (ex: "extName[version])")
+ * @param lastVersion if true, returns only the last version of each extension
+ * @return
+ */
+ public List<WikittyExtension> getAllExtensions(boolean lastVersion);
+
+ /**
* return last version available for specified extension name
* @param extName name of extension
* @return last version availble for this version, or null if extension
Modified: wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/WikittyService.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/WikittyService.java 2009-10-29 08:51:03 UTC (rev 299)
+++ wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/WikittyService.java 2009-10-29 15:12:30 UTC (rev 300)
@@ -17,6 +17,7 @@
package org.sharengo.wikitty;
+import javax.swing.tree.TreeNode;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -72,6 +73,13 @@
*/
List<String> getAllExtensionIds();
+ /**
+ * Return all extensions (ex: "extName[version])")
+ * @param lastVersion if true, returns only the last version of each extension
+ * @return
+ */
+ List<WikittyExtension> getAllExtensions(boolean lastVersion);
+
/**
* Manage Update and creation.
*
@@ -149,7 +157,7 @@
/**
*
- * @param addLabel
+ * @param label
* @return
*/
Wikitty findByLabel(String label);
@@ -183,7 +191,7 @@
* @param wikittyId
* @return
*/
- Map<TreeNode, Integer> restoreChildren(String wikittyId);
+ Map<org.sharengo.wikitty.TreeNode, Integer> restoreChildren(String wikittyId);
/*
@@ -203,7 +211,7 @@
/**
* synchonous or not ?
*
- * @param xmlData data to import
+ * @param xml data to import
*/
void syncImportFromXml(String xml);
Modified: wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/WikittyServiceInMemory.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/WikittyServiceInMemory.java 2009-10-29 08:51:03 UTC (rev 299)
+++ wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/WikittyServiceInMemory.java 2009-10-29 15:12:30 UTC (rev 300)
@@ -191,6 +191,11 @@
return result;
}
+ @Override
+ public List<WikittyExtension> getAllExtensions(boolean lastVersion) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public WikittyExtension restore(String id) throws WikittyException {
WikittyExtension result = extensions.get(id);
if (result == null) {
Modified: wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/Restriction2Solr.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/Restriction2Solr.java 2009-10-29 08:51:03 UTC (rev 299)
+++ wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/Restriction2Solr.java 2009-10-29 15:12:30 UTC (rev 300)
@@ -1,9 +1,5 @@
package org.sharengo.wikitty.jdbc;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
@@ -12,47 +8,38 @@
import org.apache.solr.common.SolrDocumentList;
import org.mortbay.log.Log;
import org.sharengo.wikitty.WikittyException;
-import org.sharengo.wikitty.search.And;
-import org.sharengo.wikitty.search.AssociatedRestriction;
-import org.sharengo.wikitty.search.Between;
-import org.sharengo.wikitty.search.Contains;
-import org.sharengo.wikitty.search.Element;
-import org.sharengo.wikitty.search.EndsWith;
-import org.sharengo.wikitty.search.Equals;
-import org.sharengo.wikitty.search.Greater;
-import org.sharengo.wikitty.search.GreaterOrEqual;
-import org.sharengo.wikitty.search.In;
-import org.sharengo.wikitty.search.Keyword;
-import org.sharengo.wikitty.search.Less;
-import org.sharengo.wikitty.search.LessOrEqual;
-import org.sharengo.wikitty.search.Not;
-import org.sharengo.wikitty.search.NotEquals;
-import org.sharengo.wikitty.search.Or;
-import org.sharengo.wikitty.search.Restriction;
-import org.sharengo.wikitty.search.RestrictionHelper;
-import org.sharengo.wikitty.search.StartsWith;
+import org.sharengo.wikitty.search.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
/**
* @author "Nicolas Chapurlat" <nicolas.chapurlat(a)logica.com>
* @author "Guillaume Dufrêne" <dufrene(a)argia.fr>
- *
- * This class is used to parse Restriction to create lucene request on
- * content. Every operators describe in RestrictionName is handle. Parsing may
- * throw exception when restriction parameters are incorrect.
+ * <p/>
+ * This class is used to parse Restriction to create lucene request on
+ * content. Every operators describe in RestrictionName is handle. Parsing may
+ * throw exception when restriction parameters are incorrect.
*/
public class Restriction2Solr {
-
- private static final int MAX_SUBQUERY_RESULT = 100;
- /** use to permit client to modify fieldname during query generation */
+ private static final int MAX_SUBQUERY_RESULT = 100;
+
+ /**
+ * use to permit client to modify fieldname during query generation
+ */
static public interface FieldModifier {
public String convertToSolr(String fieldname);
+
public String convertToField(String solrName);
}
+
final static protected FieldModifier dummyFieldModifier = new FieldModifier() {
public String convertToSolr(String fieldname) {
return fieldname;
}
+
public String convertToField(String solrName) {
return solrName;
}
@@ -69,331 +56,334 @@
}
public String toSolr(Restriction restriction) {
- return toSolr(restriction, null);
+ return toSolr(restriction, null);
}
-
- public String toSolr(Restriction restriction, SolrServer solr)
- throws WikittyException {
- // ParameterValidator.checkNullParameter(restriction, "restriction");
- switch (restriction.getName()) {
- case TRUE:
- return true2solr();
- case FALSE:
- return false2solr();
- case NOT:
- Not not = (Not) restriction;
- return not2solr(not);
- case AND:
- And and = (And) restriction;
- return and2solr(and);
- case OR:
- Or or = (Or) restriction;
- return or2solr(or);
- case EQUALS:
- Equals eq = (Equals) restriction;
- return eq2solr(eq);
- case NOT_EQUALS:
- NotEquals neq = (NotEquals) restriction;
- return neq2solr(neq);
- case LESS:
- Less less = (Less) restriction;
- return less2solr(less);
- case LESS_OR_EQUAL:
- LessOrEqual lessEq = (LessOrEqual) restriction;
- return lessEq2solr(lessEq);
- case GREATER:
- Greater great = (Greater) restriction;
- return great2solr(great);
- case GREATER_OR_EQUAL:
- GreaterOrEqual greatEq = (GreaterOrEqual) restriction;
- return greatEq2solr(greatEq);
- case BETWEEN:
- Between between = (Between) restriction;
- return between2solr(between);
- case CONTAINS:
- Contains contains = (Contains) restriction;
- return contains2solr(contains);
- case IN:
- In in = (In) restriction;
- return in2solr(in);
- case STARTS_WITH:
- StartsWith start = (StartsWith) restriction;
- return start2solr(start);
- case ENDS_WITH:
- EndsWith end = (EndsWith) restriction;
- return end2solr(end);
- case ASSOCIATED:
- AssociatedRestriction associated = (AssociatedRestriction) restriction;
- return associated2solr(associated, solr);
- case KEYWORD:
- Keyword keyword = (Keyword) restriction;
- return keyword2solr(keyword);
- default:
- throw new WikittyException("this kind of restriction is not supported : "
- + restriction.getName().toString());
- }
- }
- private String in2solr(In in) {
- boolean first = true;
- String result = in.getElement().getName() + ":[";
- for( String value : in.getValue() ) {
- if ( !first ) { result += ", "; first = false; }
- result += value;
- }
- result +="]";
- return result;
- }
+ public String toSolr(Restriction restriction, SolrServer solr)
+ throws WikittyException {
+ // ParameterValidator.checkNullParameter(restriction, "restriction");
+ switch (restriction.getName()) {
+ case TRUE:
+ return true2solr();
+ case FALSE:
+ return false2solr();
+ case NOT:
+ Not not = (Not) restriction;
+ return not2solr(not);
+ case AND:
+ And and = (And) restriction;
+ return and2solr(and);
+ case OR:
+ Or or = (Or) restriction;
+ return or2solr(or);
+ case EQUALS:
+ Equals eq = (Equals) restriction;
+ return eq2solr(eq);
+ case NOT_EQUALS:
+ NotEquals neq = (NotEquals) restriction;
+ return neq2solr(neq);
+ case LESS:
+ Less less = (Less) restriction;
+ return less2solr(less);
+ case LESS_OR_EQUAL:
+ LessOrEqual lessEq = (LessOrEqual) restriction;
+ return lessEq2solr(lessEq);
+ case GREATER:
+ Greater great = (Greater) restriction;
+ return great2solr(great);
+ case GREATER_OR_EQUAL:
+ GreaterOrEqual greatEq = (GreaterOrEqual) restriction;
+ return greatEq2solr(greatEq);
+ case BETWEEN:
+ Between between = (Between) restriction;
+ return between2solr(between);
+ case CONTAINS:
+ Contains contains = (Contains) restriction;
+ return contains2solr(contains);
+ case IN:
+ In in = (In) restriction;
+ return in2solr(in);
+ case STARTS_WITH:
+ StartsWith start = (StartsWith) restriction;
+ return start2solr(start);
+ case ENDS_WITH:
+ EndsWith end = (EndsWith) restriction;
+ return end2solr(end);
+ case ASSOCIATED:
+ AssociatedRestriction associated = (AssociatedRestriction) restriction;
+ return associated2solr(associated, solr);
+ case KEYWORD:
+ Keyword keyword = (Keyword) restriction;
+ return keyword2solr(keyword);
+ default:
+ throw new WikittyException("this kind of restriction is not supported : "
+ + restriction.getName().toString());
+ }
+ }
- private String associated2solr(AssociatedRestriction associated, SolrServer solr) throws WikittyException {
- String subQuery = toSolr( associated.getRestriction() );
- SolrQuery query = new SolrQuery(subQuery);
+ private String in2solr(In in) {
+ boolean first = true;
+ String result = in.getElement().getName() + ":[";
+ for (String value : in.getValue()) {
+ if (!first) {
+ result += ", ";
+ first = false;
+ }
+ result += value;
+ }
+ result += "]";
+ return result;
+ }
+
+ private String associated2solr(AssociatedRestriction associated, SolrServer solr) throws WikittyException {
+ String subQuery = toSolr(associated.getRestriction());
+ SolrQuery query = new SolrQuery(subQuery);
query.setRows(MAX_SUBQUERY_RESULT);
QueryResponse resp = null;
try {
- Log.info("Execute sub-query : " + subQuery);
- resp = solr.query(query);
- } catch (SolrServerException e) {
- throw new WikittyException("Unable to execute associative query on " + associated.getElement().getName(), e);
- }
+ Log.info("Execute sub-query : " + subQuery);
+ resp = solr.query(query);
+ } catch (SolrServerException e) {
+ throw new WikittyException("Unable to execute associative query on " + associated.getElement().getName(), e);
+ }
SolrDocumentList solrResults = resp.getResults();
-
+
Restriction generatedRestriction = null;
long size = solrResults.size();
- if ( size == 0 ) {
- throw new WikittyException("Associated " + associated.getElement().getName() + " do not retrieved any result");
+ if (size == 0) {
+ throw new WikittyException("Associated " + associated.getElement().getName() + " do not retrieved any result");
}
- if ( size == 1 ) {
- generatedRestriction = RestrictionHelper.eq( associated.getElement(), (String) solrResults.get(0).getFieldValue("id") );
+ if (size == 1) {
+ generatedRestriction = RestrictionHelper.eq(associated.getElement(), (String) solrResults.get(0).getFieldValue("id"));
} else {
- List<String> ids = new ArrayList<String>(solrResults.size());
- for (SolrDocument doc : solrResults) {
- String id = (String) doc.getFieldValue("id"); // FIXME : set a constant field reference
- ids.add(id);
- }
- generatedRestriction = new In(associated.getElement(), ids);
+ List<String> ids = new ArrayList<String>(solrResults.size());
+ for (SolrDocument doc : solrResults) {
+ String id = (String) doc.getFieldValue("id"); // FIXME : set a constant field reference
+ ids.add(id);
+ }
+ generatedRestriction = new In(associated.getElement(), ids);
}
Restriction parent = associated.getParentRestrictionDto();
And and;
- if ( parent instanceof And ) {
- and = (And) parent;
- and.getRestrictions().add( generatedRestriction );
+ if (parent instanceof And) {
+ and = (And) parent;
+ and.getRestrictions().add(generatedRestriction);
} else {
- and = RestrictionHelper.and( Arrays.asList(new Restriction[]{ associated.getParentRestrictionDto(), generatedRestriction }) );
+ and = RestrictionHelper.and(Arrays.asList(new Restriction[]{associated.getParentRestrictionDto(), generatedRestriction}));
}
- return toSolr(and);
- }
+ return toSolr(and);
+ }
- private String not2solr(Not not) throws WikittyException {
- if (not.getRestriction() == null) {
- throw new WikittyException( "not.restriction" );
- }
- return "( *:* - " + toSolr(not.getRestriction()) + " )";
- }
+ private String not2solr(Not not) throws WikittyException {
+ if (not.getRestriction() == null) {
+ throw new WikittyException("not.restriction");
+ }
+ return "( *:* - " + toSolr(not.getRestriction()) + " )";
+ }
- private String and2solr(And and) throws WikittyException {
- if (and.getRestrictions() == null) {
- throw new WikittyException( "and.restrictions is null" );
- }
- if (and.getRestrictions().size() < 2) {
- throw new WikittyException( "AND is an operator that handle 2 operand at least");
- }
- boolean first = true;
- StringBuffer result = new StringBuffer();
- for (Restriction restriction : and.getRestrictions()) {
- if (first) {
- result.append("( ").append(toSolr(restriction));
- first = false;
- } else {
- result.append(" AND ").append(toSolr(restriction));
- }
- }
- return result.append(" )").toString();
- }
+ private String and2solr(And and) throws WikittyException {
+ if (and.getRestrictions() == null) {
+ throw new WikittyException("and.restrictions is null");
+ }
+ if (and.getRestrictions().size() < 2) {
+ throw new WikittyException("AND is an operator that handle 2 operand at least");
+ }
+ boolean first = true;
+ StringBuffer result = new StringBuffer();
+ for (Restriction restriction : and.getRestrictions()) {
+ if (first) {
+ result.append("( ").append(toSolr(restriction));
+ first = false;
+ } else {
+ result.append(" AND ").append(toSolr(restriction));
+ }
+ }
+ return result.append(" )").toString();
+ }
- private String or2solr(Or or) throws WikittyException {
- if (or.getRestrictions() == null) {
- throw new WikittyException("or.restrictions is null");
- }
- if (or.getRestrictions().size() < 2) {
- throw new WikittyException("OR is an operator that handle 2 operand at least");
- }
- boolean first = true;
- StringBuffer result = new StringBuffer();
- for (Restriction restriction : or.getRestrictions()) {
- if (first) {
- result.append("( ");
- first = false;
- } else {
- result.append(" OR ");
- }
- result.append(toSolr(restriction));
- }
- return result.append(" )").toString();
- }
+ private String or2solr(Or or) throws WikittyException {
+ if (or.getRestrictions() == null) {
+ throw new WikittyException("or.restrictions is null");
+ }
+ if (or.getRestrictions().size() < 2) {
+ throw new WikittyException("OR is an operator that handle 2 operand at least");
+ }
+ boolean first = true;
+ StringBuffer result = new StringBuffer();
+ for (Restriction restriction : or.getRestrictions()) {
+ if (first) {
+ result.append("( ");
+ first = false;
+ } else {
+ result.append(" OR ");
+ }
+ result.append(toSolr(restriction));
+ }
+ return result.append(" )").toString();
+ }
- private String eq2solr(Equals eq) throws WikittyException {
- return element2solr(eq.getElement()) + ":" + value2solr(eq.getValue());
- }
+ private String eq2solr(Equals eq) throws WikittyException {
+ return element2solr(eq.getElement()) + ":" + value2solr(eq.getValue());
+ }
- private String neq2solr(NotEquals neq)
- throws WikittyException {
- return "( *:* - " + element2solr(neq.getElement()) + ":"
- + value2solr(neq.getValue()) + " )";
- }
+ private String neq2solr(NotEquals neq)
+ throws WikittyException {
+ return "( *:* - " + element2solr(neq.getElement()) + ":"
+ + value2solr(neq.getValue()) + " )";
+ }
- private String less2solr(Less less) throws WikittyException {
- return element2solr(less.getElement()) + ":{* TO "
- + value2solr(less.getValue()) + "}";
- }
+ private String less2solr(Less less) throws WikittyException {
+ return element2solr(less.getElement()) + ":{* TO "
+ + value2solr(less.getValue()) + "}";
+ }
- private String lessEq2solr(LessOrEqual lessEq)
- throws WikittyException {
- return element2solr(lessEq.getElement()) + ":[* TO "
- + value2solr(lessEq.getValue()) + "]";
- }
+ private String lessEq2solr(LessOrEqual lessEq)
+ throws WikittyException {
+ return element2solr(lessEq.getElement()) + ":[* TO "
+ + value2solr(lessEq.getValue()) + "]";
+ }
- private String great2solr(Greater great)
- throws WikittyException {
- return element2solr(great.getElement()) + ":{"
- + value2solr(great.getValue()) + " TO *}";
- }
+ private String great2solr(Greater great)
+ throws WikittyException {
+ return element2solr(great.getElement()) + ":{"
+ + value2solr(great.getValue()) + " TO *}";
+ }
- private String greatEq2solr(GreaterOrEqual greatEq)
- throws WikittyException {
- return element2solr(greatEq.getElement()) + ":["
- + value2solr(greatEq.getValue()) + " TO *]";
- }
+ private String greatEq2solr(GreaterOrEqual greatEq)
+ throws WikittyException {
+ return element2solr(greatEq.getElement()) + ":["
+ + value2solr(greatEq.getValue()) + " TO *]";
+ }
- private String between2solr(Between between)
- throws WikittyException {
- if (between.getElement() == null) {
- throw new WikittyException("contains.element");
- }
- if (between.getMin() == null) {
- throw new WikittyException("contains.min");
- }
- if (between.getMax() == null) {
- throw new WikittyException("contains.max");
- }
- return element2solr(between.getElement()) + ":["
- + value2solr(between.getMin()) + " TO "
- + value2solr(between.getMax()) + "]";
- }
+ private String between2solr(Between between)
+ throws WikittyException {
+ if (between.getElement() == null) {
+ throw new WikittyException("contains.element");
+ }
+ if (between.getMin() == null) {
+ throw new WikittyException("contains.min");
+ }
+ if (between.getMax() == null) {
+ throw new WikittyException("contains.max");
+ }
+ return element2solr(between.getElement()) + ":["
+ + value2solr(between.getMin()) + " TO "
+ + value2solr(between.getMax()) + "]";
+ }
- private String contains2solr(Contains contains)
- throws WikittyException {
- if (contains.getElement() == null) {
- throw new WikittyException("contains.element");
- }
- if (contains.getValue() == null) {
- throw new WikittyException("contains.values");
- }
- if (contains.getValue().size() < 1) {
- throw new WikittyException("CONTAINS is an operator that handle 1 operand at least");
- }
- boolean first = true;
- StringBuffer result = new StringBuffer();
- for (String value : contains.getValue()) {
- if (first) {
- result.append("( ");
- first = false;
- } else {
- result.append(" AND ");
- }
- result.append("( ");
- result.append(element2solr(contains.getElement()))
- .append(":").append(value2solr(value));
- result.append(" OR ");
- result.append(element2solr(contains.getElement()))
- .append(":").append(value2solr(value));
- result.append(" OR ");
- result.append(element2solr(contains.getElement()))
- .append(":").append(value2solr(value));
- result.append(" )");
- }
- return result.append(" )").toString();
- }
+ private String contains2solr(Contains contains)
+ throws WikittyException {
+ if (contains.getElement() == null) {
+ throw new WikittyException("contains.element");
+ }
+ if (contains.getValue() == null) {
+ throw new WikittyException("contains.values");
+ }
+ if (contains.getValue().size() < 1) {
+ throw new WikittyException("CONTAINS is an operator that handle 1 operand at least");
+ }
+ boolean first = true;
+ StringBuffer result = new StringBuffer();
+ for (String value : contains.getValue()) {
+ if (first) {
+ result.append("( ");
+ first = false;
+ } else {
+ result.append(" AND ");
+ }
+ result.append("( ");
+ result.append(element2solr(contains.getElement()))
+ .append(":").append(value2solr(value));
+ result.append(" OR ");
+ result.append(element2solr(contains.getElement()))
+ .append(":").append(value2solr(value));
+ result.append(" OR ");
+ result.append(element2solr(contains.getElement()))
+ .append(":").append(value2solr(value));
+ result.append(" )");
+ }
+ return result.append(" )").toString();
+ }
- private String start2solr(StartsWith start)
- throws WikittyException {
- return element2solr(start.getElement()) + ":"
- + value2solr(start.getValue(), true, false);
- }
+ private String start2solr(StartsWith start)
+ throws WikittyException {
+ return element2solr(start.getElement()) + ":"
+ + value2solr(start.getValue(), true, false);
+ }
- private String end2solr(EndsWith end) {
- return element2solr(end.getElement()) + ":" + value2solr(end.getValue());
- }
+ private String end2solr(EndsWith end) {
+ return element2solr(end.getElement()) + ":" + value2solr(end.getValue());
+ }
- private String true2solr() {
- return "( *:* )";
- }
+ private String true2solr() {
+ return "( *:* )";
+ }
- private String false2solr() {
- return "( *:* - *:* )";
- }
+ private String false2solr() {
+ return "( *:* - *:* )";
+ }
private String keyword2solr(Keyword keyword) {
return value2solr(keyword.getValue());
}
- private String value2solr(String value) {
- return value2solr(value, false, false);
- }
+ private String value2solr(String value) {
+ return value2solr(value, false, false);
+ }
- private String value2solr(String value, boolean starOnEnd,
- boolean revert) {
- String result;
- if (value != null) {
- if (value.equals("*")) {
- return "*";
- }
+ private String value2solr(String value, boolean starOnEnd,
+ boolean revert) {
+ String result;
+ if (value != null) {
+ if (value.equals("*")) {
+ return "*";
+ }
- if (revert) {
- result = Restriction2Solr.escapeValue(reverse(value));
- } else {
- result = Restriction2Solr.escapeValue(value);
- // result = value;
- }
- } else {
- result = "";
- }
- if (starOnEnd) {
- result += "*";
- }
- if (result.contains(" ")) {
- result = "\"" + result + "\"";
- }
- return result;
- }
+ if (revert) {
+ result = Restriction2Solr.escapeValue(reverse(value));
+ } else {
+ result = Restriction2Solr.escapeValue(value);
+ // result = value;
+ }
+ } else {
+ result = "";
+ }
+ if (starOnEnd) {
+ result += "*";
+ }
+ if (result.contains(" ")) {
+ result = "\"" + result + "\"";
+ }
+ return result;
+ }
- private String element2solr(Element element) throws WikittyException {
+ private String element2solr(Element element) throws WikittyException {
String result = element.getName();
- if(Element.ELT_EXTENSION.equals(result)) {
+ if (Element.ELT_EXTENSION.equals(result)) {
result = WikittySearchEnginSolr.SOLR_EXTENSIONS;
- } else if(Element.ELT_ID.equals(result)) {
+ } else if (Element.ELT_ID.equals(result)) {
result = WikittySearchEnginSolr.SOLR_ID;
} else {
result = element.getName();
}
result = fieldModifer.convertToSolr(result);
return result;
- }
+ }
- private static String escapeValue(String value) {
- final String LUCENE_REPLACE_PATTERN = "\\+" + "|-" + "|&&" + "|\\|\\|"
- + "|!" + "|\\(|\\)" + "|\\[|\\]" + "|\\{|\\}" + "|\\^" + "|\""
- + "|\\~" + "|\\*" + "|\\?" + "|:" + "|\\\\";
- return value.replaceAll(LUCENE_REPLACE_PATTERN, "\\\\$0");
- }
+ private static String escapeValue(String value) {
+ final String LUCENE_REPLACE_PATTERN = "\\+" + "|-" + "|&&" + "|\\|\\|"
+ + "|!" + "|\\(|\\)" + "|\\[|\\]" + "|\\{|\\}" + "|\\^" + "|\""
+ + "|\\~" + "|\\*" + "|\\?" + "|:" + "|\\\\";
+ return value.replaceAll(LUCENE_REPLACE_PATTERN, "\\\\$0");
+ }
- private String reverse(String source) {
- int i, len = source.length();
- StringBuffer dest = new StringBuffer(len);
+ private String reverse(String source) {
+ int i, len = source.length();
+ StringBuffer dest = new StringBuffer(len);
- for (i = (len - 1); i >= 0; i--)
- dest.append(source.charAt(i));
- return dest.toString();
- }
+ for (i = (len - 1); i >= 0; i--)
+ dest.append(source.charAt(i));
+ return dest.toString();
+ }
}
Modified: wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyExtensionStorageJDBC.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyExtensionStorageJDBC.java 2009-10-29 08:51:03 UTC (rev 299)
+++ wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyExtensionStorageJDBC.java 2009-10-29 15:12:30 UTC (rev 300)
@@ -16,62 +16,72 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*##%*/
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.sharengo.wikitty.*;
import static org.sharengo.wikitty.jdbc.WikittyJDBCUtil.*;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.sharengo.wikitty.FieldType;
-import org.sharengo.wikitty.UpdateResponse;
-import org.sharengo.wikitty.WikittyException;
-import org.sharengo.wikitty.WikittyExtension;
-import org.sharengo.wikitty.WikittyExtensionStorage;
-import org.sharengo.wikitty.WikittyTransaction;
-import org.sharengo.wikitty.WikittyUtil;
+import java.util.*;
/**
- *
* @author morin
* @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
+ * <p/>
+ * Last update: $Date$
+ * by : $Author$
*/
public class WikittyExtensionStorageJDBC implements WikittyExtensionStorage {
- /** to use log facility, just put in your code: log.info(\"...\"); */
+ /**
+ * to use log facility, just put in your code: log.info(\"...\");
+ */
static protected Log log = LogFactory.getLog(WikittyExtensionStorageJDBC.class);
- /** JDBC driver property name */
+ /**
+ * JDBC driver property name
+ */
static protected String driver = "jdbc.con.driver";
- /** extension_admin table creation query property name */
+ /**
+ * extension_admin table creation query property name
+ */
static protected String extAdminCreationQ = "jdbc.queries.creation.extension.admin";
- /** extension_data table creation query property name */
+ /**
+ * extension_data table creation query property name
+ */
static protected String extDataCreationQ = "jdbc.queries.creation.extension.data";
- /** basic selection without where clause query property name */
+ /**
+ * basic selection without where clause query property name
+ */
static protected String selectionQ = "jdbc.queries.select";
- /** basic selection with where clause query property name */
+ /**
+ * basic selection with where clause query property name
+ */
static protected String whereSelectionQ = "jdbc.queries.select.where";
- /** insertion in the admin table query property name */
+ /**
+ * insertion in the admin table query property name
+ */
static protected String adminInsertQ = "jdbc.queries.insert.extension.admin";
- /** insertion in the data table query property name */
+ /**
+ * insertion in the data table query property name
+ */
static protected String dataInsertQ = "jdbc.queries.insert.extension.data";
- /** admin table name */
+ /**
+ * admin table name
+ */
static protected String adminTable = "extension_admin";
- /** data table name */
+ /**
+ * data table name
+ */
static protected String dataTable = "extension_data";
-
- /** Properties file */
+
+ /**
+ * Properties file
+ */
protected Properties conf = loadProperties();
class CommandJDBC implements Command {
@@ -81,12 +91,16 @@
this.queries = queries;
}
}
-
- /** cache for extension key: ext id (extname[extversion]) value: WikittyExtension */
+
+ /**
+ * cache for extension key: ext id (extname[extversion]) value: WikittyExtension
+ */
protected Map<String, WikittyExtension> extensionCache =
new HashMap<String, WikittyExtension>();
-
- /** cache for last extension version; key: extName value: extVersion */
+
+ /**
+ * cache for last extension version; key: extName value: extVersion
+ */
protected Map<String, String> lastVersion = null;
public WikittyExtensionStorageJDBC() {
@@ -110,7 +124,7 @@
statement.execute(conf.getProperty(extAdminCreationQ));
statement.execute(conf.getProperty(extDataCreationQ));
con.commit();
- } catch(SQLException eee) {
+ } catch (SQLException eee) {
con.rollback();
}
closeConnection(con);
@@ -126,7 +140,7 @@
@Override
public List<Command> prepare(WikittyTransaction transaction,
- Collection<WikittyExtension> extensions)
+ Collection<WikittyExtension> extensions)
throws WikittyException {
Connection con = null;
try {
@@ -140,7 +154,7 @@
//select all the data with the id "id"
ResultSet versionResultSet = statement.executeQuery(
String.format(conf.getProperty(whereSelectionQ),
- COL_VERSION, adminTable, COL_ID, "'" + id + "'"));
+ COL_VERSION, adminTable, COL_ID, "'" + id + "'"));
StringBuffer batch = new StringBuffer();
//if the data is not already recorded
@@ -170,13 +184,13 @@
@Override
public UpdateResponse commit(WikittyTransaction transaction,
- List<Command> extensionStorageCommandList) {
+ List<Command> extensionStorageCommandList) {
Connection con = null;
try {
con = getConnection();
Statement statement = con.createStatement();
- for(Command command : extensionStorageCommandList) {
- CommandJDBC commandJDBC = (CommandJDBC)command;
+ for (Command command : extensionStorageCommandList) {
+ CommandJDBC commandJDBC = (CommandJDBC) command;
statement.execute(commandJDBC.queries);
}
con.commit();
@@ -202,7 +216,7 @@
//select the data with teh id "id" in the admin table
ResultSet resultSet = statement.executeQuery(
String.format(conf.getProperty(whereSelectionQ), adminTable,
- COL_ID, "'" + id + "'"));
+ COL_ID, "'" + id + "'"));
boolean result = resultSet.first();
closeConnection(con);
return result;
@@ -222,8 +236,8 @@
Statement statement = con.createStatement();
//get all extensions names and versions
ResultSet resultSet = statement.executeQuery(
- String.format(conf.getProperty(selectionQ),
- COL_ID, adminTable));
+ String.format(conf.getProperty(selectionQ),
+ COL_ID, adminTable));
resultSet.beforeFirst();
while (resultSet.next()) {
String id = resultSet.getString(COL_ID);
@@ -238,26 +252,64 @@
}
+ @Override
+ public List<WikittyExtension> getAllExtensions(boolean lastVersion) {
+ Connection con = null;
+ try {
+ con = getConnection();
+
+ List<WikittyExtension> result = new ArrayList<WikittyExtension>();
+ Statement statement = con.createStatement();
+ //get all extensions names and versions
+ ResultSet adminResultSet;
+ if (lastVersion) {
+ adminResultSet = statement.executeQuery(
+ String.format(conf.getProperty(selectionQ), "DISTINCT " + COL_NAME,
+ adminTable));
+ adminResultSet.beforeFirst();
+ while (adminResultSet.next()) {
+ String extName = adminResultSet.getString(COL_NAME);
+ String extId = getLastVersion(extName);
+ result.add(restore(extId));
+ }
+ } else {
+ adminResultSet = statement.executeQuery(
+ String.format(conf.getProperty(selectionQ), COL_ID,
+ adminTable));
+ adminResultSet.beforeFirst();
+ while (adminResultSet.next()) {
+ String extId = adminResultSet.getString(COL_ID);
+ result.add(restore(extId));
+ }
+ }
+ closeConnection(con);
+ return result;
+ } catch (SQLException eee) {
+ closeConnection(con);
+ throw new WikittyException(eee);
+ }
+ }
+
/**
* return last version available for specified extension name
- * @param name name of extension
+ *
+ * @param extName name of extension
* @return last version availble for this version, or null if extension
- * doesn't exist
+ * doesn't exist
*/
@Override
- public String getLastVersion(
- String extName) {
+ public String getLastVersion(String extName) {
if (lastVersion == null) {
// create cache for futur call
lastVersion = new HashMap<String, String>();
Connection con = null;
- try {
- con = getConnection();
+ try {
+ con = getConnection();
Statement statement = con.createStatement();
//get all extensions names and versions
ResultSet resultSet = statement.executeQuery(
String.format(conf.getProperty(selectionQ),
- COL_NAME + "," + COL_VERSION, adminTable));
+ COL_NAME + "," + COL_VERSION, adminTable));
resultSet.beforeFirst();
while (resultSet.next()) {
String name = resultSet.getString(COL_NAME);
@@ -280,8 +332,7 @@
}
@Override
- public WikittyExtension restore(
- String id) throws WikittyException {
+ public WikittyExtension restore(String id) throws WikittyException {
WikittyExtension result = extensionCache.get(id);
if (result == null) {
Connection con = null;
@@ -291,7 +342,7 @@
//get the data with the id "id" in the admin table
ResultSet adminResultSet = statement.executeQuery(
String.format(conf.getProperty(whereSelectionQ), "*",
- adminTable, COL_ID, "'" + id + "'"));
+ adminTable, COL_ID, "'" + id + "'"));
if (adminResultSet.first()) {
String extName = adminResultSet.getString(COL_NAME);
String extVersion = adminResultSet.getString(COL_VERSION);
@@ -300,7 +351,7 @@
//get the data with the id "id" in the data table
ResultSet dataResultSet = statement.executeQuery(
String.format(conf.getProperty(whereSelectionQ), "*",
- dataTable, COL_ID, "'" + id + "'"));
+ dataTable, COL_ID, "'" + id + "'"));
dataResultSet.beforeFirst();
while (dataResultSet.next()) {
String fieldDef = dataResultSet.getString(COL_FIELDTYPE);
Modified: wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyJDBCUtil.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyJDBCUtil.java 2009-10-29 08:51:03 UTC (rev 299)
+++ wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyJDBCUtil.java 2009-10-29 15:12:30 UTC (rev 300)
@@ -18,61 +18,95 @@
package org.sharengo.wikitty.jdbc;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import java.io.IOException;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
/**
- *
* @author morin
* @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
+ * <p/>
+ * Last update: $Date$
+ * by : $Author$
*/
public class WikittyJDBCUtil {
- /** to use log facility, just put in your code: log.info(\"...\"); */
+ /**
+ * to use log facility, just put in your code: log.info(\"...\");
+ */
static private Log log = LogFactory.getLog(WikittyJDBCUtil.class);
- /** extension list column in the wikitty_admin table */
- static final public String COL_EXTENSION = "extension_list";
- /** requires column in the extension_admin table */
- static final public String COL_REQUIRES = "requires";
- /** version column in the admin tables */
+ /**
+ * extension list column in the wikitty_admin table
+ */
+ static final public String COL_EXTENSION = "extension_list";
+ /**
+ * requires column in the extension_admin table
+ */
+ static final public String COL_REQUIRES = "requires";
+ /**
+ * version column in the admin tables
+ */
static final public String COL_VERSION = "version";
- /** id column in all the tables */
+ /**
+ * id column in all the tables
+ */
static final public String COL_ID = "id";
- /** name column in the extension_admin table */
+ /**
+ * name column in the extension_admin table
+ */
static final public String COL_NAME = "name";
- /** field name column in the data tables */
+ /**
+ * field name column in the data tables
+ */
static final public String COL_FIELDNAME = "fieldName";
- /** field type column in the extension_data table */
+ /**
+ * field type column in the extension_data table
+ */
static final public String COL_FIELDTYPE = "fieldType";
- /** boolean value column in the wikitty_data table */
+ /**
+ * boolean value column in the wikitty_data table
+ */
static final public String COL_BOOLEAN_VALUE = "booleanValue";
- /** number value column in the wikitty_data table */
+ /**
+ * number value column in the wikitty_data table
+ */
static final public String COL_NUMBER_VALUE = "numberValue";
- /** text value column in the wikitty_data table */
+ /**
+ * text value column in the wikitty_data table
+ */
static final public String COL_TEXT_VALUE = "textValue";
- /** date value column in the wikitty_data table */
+ /**
+ * date value column in the wikitty_data table
+ */
static final public String COL_DATE_VALUE = "dateValue";
- /** deletion date column in wikitty_admin table */
+ /**
+ * deletion date column in wikitty_admin table
+ */
static final public String COL_DELETION_DATE = "deletionDate";
- /** host property name */
+ /**
+ * host property name
+ */
static protected String host = "jdbc.con.host";
- /** user name property name */
+ /**
+ * user name property name
+ */
static protected String userName = "jdbc.con.userName";
- /** password property name */
+ /**
+ * password property name
+ */
static protected String password = "jdbc.con.password";
- /** Properties file */
+ /**
+ * Properties file
+ */
protected static Properties conf = loadProperties();
/**
@@ -83,10 +117,10 @@
public static Properties loadProperties() {
Properties properties = new Properties();
try {
- URL url = ClassLoader.getSystemResource("jdbc.properties");
- properties.load(url.openStream());
- } catch(IOException eee) {
- if(log.isErrorEnabled()) {
+ URL url = ClassLoader.getSystemResource("jdbc.properties");
+ properties.load(url.openStream());
+ } catch (IOException eee) {
+ if (log.isErrorEnabled()) {
log.error("Unable to load property file");
}
}
@@ -101,7 +135,7 @@
*/
public static Connection getConnection() throws SQLException {
Connection con = DriverManager.getConnection(conf.getProperty(host),
- conf.getProperty(userName), conf.getProperty(password));
+ conf.getProperty(userName), conf.getProperty(password));
con.setAutoCommit(false);
return con;
}
@@ -122,20 +156,20 @@
* If the option rollback is true, then all the modification made in
* the transaction are canceled.
*
- * @param con the connection to close
+ * @param con the connection to close
* @param rollBack if true, all the modification made in
- * the transaction are canceled.
+ * the transaction are canceled.
*/
public static void closeConnection(Connection con, boolean rollBack) {
try {
- if(con != null) {
- if(rollBack) {
+ if (con != null) {
+ if (rollBack) {
con.rollback();
}
con.close();
}
- } catch(SQLException eee) {
- if(log.isErrorEnabled()) {
+ } catch (SQLException eee) {
+ if (log.isErrorEnabled()) {
log.error(eee);
}
}
Modified: wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyQueryParser.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyQueryParser.java 2009-10-29 08:51:03 UTC (rev 299)
+++ wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyQueryParser.java 2009-10-29 15:12:30 UTC (rev 300)
@@ -11,7 +11,6 @@
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.search.LuceneQParserPlugin;
import org.apache.solr.search.QParser;
-import org.apache.solr.search.QParserPlugin;
import org.apache.solr.search.QueryParsing;
import org.apache.solr.search.SolrQueryParser;
@@ -36,6 +35,7 @@
return new SolrQParser(qstr, localParams, params, req);
}
}
+
class SolrQParser extends QParser {
static private Log log = LogFactory.getLog(SolrQParser.class);
Modified: wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittySearchEnginSolr.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittySearchEnginSolr.java 2009-10-29 08:51:03 UTC (rev 299)
+++ wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittySearchEnginSolr.java 2009-10-29 15:12:30 UTC (rev 300)
@@ -18,14 +18,6 @@
package org.sharengo.wikitty.jdbc;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.solr.client.solrj.SolrQuery;
@@ -38,44 +30,45 @@
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.core.CoreContainer;
-import org.sharengo.wikitty.Criteria;
-import org.sharengo.wikitty.FacetTopic;
-import org.sharengo.wikitty.FieldType;
+import org.sharengo.wikitty.*;
import org.sharengo.wikitty.FieldType.TYPE;
-import org.sharengo.wikitty.PagedResult;
-import org.sharengo.wikitty.TreeNode;
-import org.sharengo.wikitty.UpdateResponse;
-import org.sharengo.wikitty.Wikitty;
-import org.sharengo.wikitty.WikittyException;
-import org.sharengo.wikitty.WikittyExtension;
-import org.sharengo.wikitty.WikittyExtensionStorage;
-import org.sharengo.wikitty.WikittySearchEngin;
-import org.sharengo.wikitty.WikittyTransaction;
import org.sharengo.wikitty.search.Search;
+import java.io.IOException;
+import java.util.*;
+
/**
- *
* @author poussin
* @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
+ * <p/>
+ * Last update: $Date$
+ * by : $Author$
*/
public class WikittySearchEnginSolr implements WikittySearchEngin {
- /** to use log facility, just put in your code: log.info(\"...\"); */
+ /**
+ * to use log facility, just put in your code: log.info(\"...\");
+ */
static private Log log = LogFactory.getLog(WikittySearchEnginSolr.class);
- /** id field in solr */
+ /**
+ * id field in solr
+ */
static final protected String SOLR_ID = "id";
- /** extensions field name in solr */
+ /**
+ * extensions field name in solr
+ */
static final public String SOLR_EXTENSIONS = "extensions";
- /** extension use to store field without extension to search on all extesnion */
+ /**
+ * extension use to store field without extension to search on all extesnion
+ */
static final public String SOLR_ALL_EXTENSIONS = "all";
- /** Precise the query parser to use, is allow leading wildcard */
+ /**
+ * Precise the query parser to use, is allow leading wildcard
+ */
static final public String SOLR_QUERY_PARSER = "{!wikitty}";
// Use for indexation tree node
@@ -85,16 +78,24 @@
static final public String TREENODE_ROOT = TREENODE_PREFIX + "root";
static protected class CommandSolr implements Command {
- /** if is store command toStore is true, if is delete toStore is false */
+ /**
+ * if is store command toStore is true, if is delete toStore is false
+ */
boolean toStore;
String id;
Wikitty wikitty;
- /** use to store command */
+
+ /**
+ * use to store command
+ */
public CommandSolr(Wikitty wikitty) {
this.wikitty = wikitty;
this.toStore = true;
}
- /** use for deletion command */
+
+ /**
+ * use for deletion command
+ */
public CommandSolr(String id) {
this.id = id;
this.toStore = false;
@@ -103,6 +104,7 @@
static protected class TypeFieldModifer implements Restriction2Solr.FieldModifier {
protected WikittyExtensionStorage extensionStorage;
+
public TypeFieldModifer(WikittyExtensionStorage extensionStorage) {
this.extensionStorage = extensionStorage;
}
@@ -138,7 +140,7 @@
String fieldName = searchField[1];
String fieldType = searchField[2];
- if(Criteria.ALL_EXTENSIONS.equals(extName)) {
+ if (Criteria.ALL_EXTENSIONS.equals(extName)) {
TYPE type = FieldType.TYPE.valueOf(fieldType);
String solrFieldName = SOLR_ALL_EXTENSIONS + "." + fieldName;
result = WikittySearchEnginSolr.getSolrFieldName(solrFieldName, type);
@@ -174,9 +176,9 @@
String parent = super.get(id);
// If not found in map, search in index
- if(parent == null) {
+ if (parent == null) {
SolrDocument doc = searchEnginSolr.findById(id);
- if(doc == null) {
+ if (doc == null) {
// is root
return null;
}
@@ -193,7 +195,7 @@
WikittySearchEnginSolr searchEnginSolr,
WikittyTransaction transaction) {
ParentMap value = (ParentMap) transaction.getTagValue(ParentMap.class);
- if(value == null) {
+ if (value == null) {
value = new ParentMap(searchEnginSolr);
transaction.setTagValue(ParentMap.class, value);
}
@@ -201,11 +203,17 @@
}
}
- /** solr server */
+ /**
+ * solr server
+ */
protected SolrServer solrServer;
- /** Criteria transformer to solr */
+ /**
+ * Criteria transformer to solr
+ */
protected Restriction2Solr restriction2Solr;
- /** Field modifier use to transform to solr format */
+ /**
+ * Field modifier use to transform to solr format
+ */
protected TypeFieldModifer fieldModifier;
public WikittySearchEnginSolr(WikittyExtensionStorage extensionStorage) {
@@ -233,12 +241,12 @@
}
public List<Command> prepare(WikittyTransaction transaction,
- Collection<Wikitty> wikitties) {
+ Collection<Wikitty> wikitties) {
List<Command> result = new ArrayList<Command>(wikitties.size());
for (Wikitty w : wikitties) {
// Store known parent in transaction
- if(w.hasExtension(TreeNode.EXT_TREENODE)) {
+ if (w.hasExtension(TreeNode.EXT_TREENODE)) {
ParentMap parentMap = ParentMap.getParentMap(this, transaction);
String wikittyId = w.getId();
String parentId = w.getFieldAsWikitty(
@@ -252,7 +260,7 @@
}
public UpdateResponse commit(WikittyTransaction transaction,
- List<Command> wikittyIndexationCommandList) {
+ List<Command> wikittyIndexationCommandList) {
try {
for (Command c : wikittyIndexationCommandList) {
CommandSolr cs = (CommandSolr) c;
@@ -261,7 +269,7 @@
solrServer.add(doc);
Collection<SolrInputDocument> docs = createTreeNodeIndex(transaction, cs.wikitty);
- if(!docs.isEmpty()) {
+ if (!docs.isEmpty()) {
solrServer.add(docs);
}
@@ -275,7 +283,7 @@
}
}
solrServer.commit();
-
+
// no specific result needed
UpdateResponse result = new UpdateResponse();
return result;
@@ -285,7 +293,7 @@
}
public List<Command> delete(WikittyTransaction transaction,
- List<String> idList) throws WikittyException {
+ List<String> idList) throws WikittyException {
List<Command> result = new ArrayList<Command>(idList.size());
for (String id : idList) {
result.add(new CommandSolr(id));
@@ -294,37 +302,37 @@
}
public PagedResult<String> findAllByCriteria(Criteria criteria) {
- try {
+ try {
// Create query with restriction
String queryString = restriction2Solr.toSolr(criteria.getRestriction(), solrServer);
- SolrQuery query = new SolrQuery(SOLR_QUERY_PARSER + queryString);
+ SolrQuery query = new SolrQuery(SOLR_QUERY_PARSER + queryString);
// Add pagged
int firstIndex = criteria.getFirstIndex();
int endIndex = criteria.getEndIndex();
- query.setStart(firstIndex);
- int nbRows;
- if (endIndex == -1) {
- // WARNING It is necessary to substract 'start' otherwise, there is a capacity overlow in solR
- nbRows = Integer.MAX_VALUE - firstIndex;
- } else {
- nbRows = endIndex - firstIndex + 1;
- }
- query.setRows(nbRows);
+ query.setStart(firstIndex);
+ int nbRows;
+ if (endIndex == -1) {
+ // WARNING It is necessary to substract 'start' otherwise, there is a capacity overlow in solR
+ nbRows = Integer.MAX_VALUE - firstIndex;
+ } else {
+ nbRows = endIndex - firstIndex + 1;
+ }
+ query.setRows(nbRows);
// Add sorting
List<String> sortAscending = criteria.getSortAscending();
- if(sortAscending != null) {
+ if (sortAscending != null) {
for (String sort : sortAscending) {
String tranform = fieldModifier.convertToSolr(sort);
query.setSortField(tranform, SolrQuery.ORDER.asc);
}
}
-
+
List<String> sortDescending = criteria.getSortDescending();
- if(sortDescending != null) {
+ if (sortDescending != null) {
for (String sort : sortDescending) {
String tranform = fieldModifier.convertToSolr(sort);
query.setSortField(tranform, SolrQuery.ORDER.desc);
@@ -338,11 +346,11 @@
// use to map query string to criteria facet name
Map<String, String> facetQueryToName = new HashMap<String, String>();
- if ((facetField != null && !facetField.isEmpty())
+ if ((facetField != null && !facetField.isEmpty())
|| (facetCriteria != null && !facetCriteria.isEmpty())) {
- query.setFacet(true);
- query.setFacetMinCount(1);
- // query.setFacetLimit(8); // no limit actualy
+ query.setFacet(true);
+ query.setFacetMinCount(1);
+ // query.setFacetLimit(8); // no limit actualy
// field facetisation
if (facetField != null) {
@@ -361,12 +369,12 @@
query.addFacetQuery(queryFacet);
}
}
- }
+ }
- QueryResponse resp = solrServer.query(query);
- SolrDocumentList solrResults = resp.getResults();
+ QueryResponse resp = solrServer.query(query);
+ SolrDocumentList solrResults = resp.getResults();
- Map<String, List<FacetTopic>> facets = new HashMap<String, List<FacetTopic>>();
+ Map<String, List<FacetTopic>> facets = new HashMap<String, List<FacetTopic>>();
if (facetField != null && !facetField.isEmpty()) {
for (FacetField facet : resp.getFacetFields()) {
String facetName = fieldModifier.convertToField(facet.getName());
@@ -374,7 +382,7 @@
if (facet.getValues() != null) {
for (FacetField.Count value : facet.getValues()) {
String topicName = value.getName();
- if(!topicName.endsWith(TREENODE_EMPTY)) {
+ if (!topicName.endsWith(TREENODE_EMPTY)) {
int topicCount = (int) value.getCount();
FacetTopic topic = new FacetTopic(facetName, topicName, topicCount);
topics.add(topic);
@@ -399,32 +407,32 @@
}
}
- List<String> ids = new ArrayList<String>(solrResults.size());
- for (SolrDocument doc : solrResults) {
- String id = (String) doc.getFieldValue(SOLR_ID);
- ids.add(id);
- }
+ List<String> ids = new ArrayList<String>(solrResults.size());
+ for (SolrDocument doc : solrResults) {
+ String id = (String) doc.getFieldValue(SOLR_ID);
+ ids.add(id);
+ }
- int numFound = (int)resp.getResults().getNumFound();
+ int numFound = (int) resp.getResults().getNumFound();
PagedResult<String> result = new PagedResult<String>(
firstIndex, numFound, queryString, facets, ids);
- return result;
- } catch (SolrServerException e) {
- throw new WikittyException(e);
- }
+ return result;
+ } catch (SolrServerException e) {
+ throw new WikittyException(e);
+ }
}
public Map<String, Integer> findAllChildren(Wikitty w) {
String wikittyId = w.getId();
-
+
String parent = w.getFieldAsWikitty(TreeNode.EXT_TREENODE, TreeNode.FIELD_PARENT);
- if(parent == null) {
+ if (parent == null) {
parent = TREENODE_ROOT;
} else {
parent = TREENODE_PREFIX + parent;
}
-
+
// Find count with facet, if the node not contain recurcively content,
// the node not found with facet
Criteria criteria = Search.query().eq(parent, wikittyId).criteria()
@@ -434,7 +442,7 @@
Map<String, Integer> counts = new HashMap<String, Integer>();
List<FacetTopic> topics = search.getTopic(TREENODE_PREFIX + wikittyId);
- if(topics != null) {
+ if (topics != null) {
for (FacetTopic topic : topics) {
String topicName = topic.getTopicName();
int topicCount = topic.getCount();
@@ -451,7 +459,7 @@
List<String> children = search.getAll();
for (String child : children) {
- if(!counts.containsKey(child)) {
+ if (!counts.containsKey(child)) {
counts.put(child, 0);
}
}
@@ -462,6 +470,7 @@
/**
* Create all index document to used to modify indexation.
* this method don't modify index
+ *
* @param wikitties all wikitties object to index
* @return list of SolrInputDocument used to modify index
*/
@@ -481,7 +490,7 @@
// if (type.getType() == FieldType.TYPE.WIKITTY) {
// continue;
// }
- String solrFqFieldName = getSolrFieldName(fqfieldName, type );
+ String solrFqFieldName = getSolrFieldName(fqfieldName, type);
String[] extAndName = solrFqFieldName.split("\\.");
String solrFieldName = SOLR_ALL_EXTENSIONS + "." + extAndName[1];
if (type.isCollection()) {
@@ -489,7 +498,7 @@
for (Object objectValue : collection) {
if (objectValue != null) {
// String value = WikittyUtil.toString(type, objectValue);
- Object value = objectValue;
+ Object value = objectValue;
doc.addField(solrFqFieldName, value);
doc.addField(solrFieldName, value);
}
@@ -498,7 +507,7 @@
Object objectValue = w.getFqField(fqfieldName);
if (objectValue != null) {
// String value = WikittyUtil.toString(type, objectValue);
- Object value = objectValue;
+ Object value = objectValue;
log.debug("index field " + solrFqFieldName + " with value '" + value + "'");
doc.addField(solrFqFieldName, value);
doc.addField(solrFieldName, value);
@@ -516,9 +525,9 @@
protected Collection<SolrInputDocument> createTreeNodeIndex(
WikittyTransaction transaction, Wikitty w)
throws IOException, SolrServerException {
-
+
Collection<SolrInputDocument> result = new ArrayList<SolrInputDocument>();
- if(w.hasExtension(TreeNode.EXT_TREENODE)) {
+ if (w.hasExtension(TreeNode.EXT_TREENODE)) {
String treeNodeId = w.getId();
ParentMap parentMap = (ParentMap) transaction.getTagValue(ParentMap.class);
@@ -526,19 +535,19 @@
List<String> children = w.getFieldAsList(TreeNode.EXT_TREENODE,
TreeNode.FIELD_CHILDREN, String.class);
List<String> newChildren = new ArrayList<String>();
- if(children != null) {
+ if (children != null) {
newChildren.addAll(children);
}
// Find old document to do diff
SolrDocument treeNodeDoc = findById(treeNodeId);
- if(treeNodeDoc != null) {
+ if (treeNodeDoc != null) {
Collection oldChildren = treeNodeDoc.
getFieldValues(TreeNode.FQ_FIELD_CHILDREN + "_t");
// Remove old children not in current node
List<String> removeChildren = new ArrayList<String>();
- if(oldChildren != null) {
+ if (oldChildren != null) {
removeChildren.addAll(oldChildren);
removeChildren.removeAll(children);
for (String removeChild : removeChildren) {
@@ -558,7 +567,7 @@
SolrDocument solrDocument = iterator.next();
String child = (String) solrDocument.getFieldValue(TreeNode.EXT_TREENODE + ".wikittyId");
// Child is not deleted
- if(!removeChildren.contains(child)) {
+ if (!removeChildren.contains(child)) {
SolrInputDocument doc = createTreeNodeDocument(treeNodeId, child, parentMap);
// Copy other field after node
@@ -620,7 +629,7 @@
SolrDocumentList results = response.getResults();
long numFound = results.getNumFound();
- if(numFound == 1) {
+ if (numFound == 1) {
return results.get(0);
}
@@ -631,7 +640,7 @@
TYPE type = fieldType.getType();
String result = getSolrFieldName(fqfieldName, type);
return result;
- }
+ }
public static String getSolrFieldName(String fqfieldName, TYPE type) {
switch (type) {
Modified: wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyServiceJDBC.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyServiceJDBC.java 2009-10-29 08:51:03 UTC (rev 299)
+++ wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyServiceJDBC.java 2009-10-29 15:12:30 UTC (rev 300)
@@ -26,35 +26,36 @@
/**
* HBase must have 2 definitions, one for extension and one for wikitty object.
- *
+ * <p/>
* extension:
* - admin: id, version, ...
* - data: field definition
- *
+ * <p/>
* wikitty:
* - admin: id, version, extension name and version, ...
* - data: field value
- *
- *
+ * <p/>
+ * <p/>
* How to create this definition:
* <li> download and uncompress hbase distribution (from apache repository mirror)</li>
* <li> $hbase-0.19.3/bin/start-hbase.sh</li>
* <li> $hbase-0.19.3/bin/hbase shell</li>
* <li> in the shell
- * <li> create 'extension','admin','data'</li>
- * <li> create 'wikitty', 'admin', 'data'</li>
+ * <li> create 'extension','admin','data'</li>
+ * <li> create 'wikitty', 'admin', 'data'</li>
* </li>
*
- *
* @author poussin
* @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
+ * <p/>
+ * Last update: $Date$
+ * by : $Author$
*/
public class WikittyServiceJDBC extends AbstractWikittyService {
- /** to use log facility, just put in your code: log.info(\"...\"); */
+ /**
+ * to use log facility, just put in your code: log.info(\"...\");
+ */
static private Log log = LogFactory.getLog(WikittyServiceJDBC.class);
protected WikittySearchEngin searchEngin;
Modified: wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyStorageJDBC.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyStorageJDBC.java 2009-10-29 08:51:03 UTC (rev 299)
+++ wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyStorageJDBC.java 2009-10-29 15:12:30 UTC (rev 300)
@@ -16,79 +16,91 @@
*##%*/
package org.sharengo.wikitty.jdbc;
-import java.math.BigDecimal;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.sharengo.wikitty.*;
import static org.sharengo.wikitty.jdbc.WikittyJDBCUtil.*;
+import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
+import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.sharengo.wikitty.FieldType;
-import org.sharengo.wikitty.UpdateResponse;
-import org.sharengo.wikitty.Wikitty;
-import org.sharengo.wikitty.WikittyException;
-import org.sharengo.wikitty.WikittyExtension;
-import org.sharengo.wikitty.WikittyExtensionStorage;
-import org.sharengo.wikitty.WikittyStorage;
-import org.sharengo.wikitty.WikittyTransaction;
-import org.sharengo.wikitty.WikittyUtil;
/**
- *
* @author morin
* @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
+ * <p/>
+ * Last update: $Date$
+ * by : $Author$
*/
public class WikittyStorageJDBC implements WikittyStorage {
- /** to use log facility, just put in your code: log.info(\"...\"); */
+ /**
+ * to use log facility, just put in your code: log.info(\"...\");
+ */
static protected Log log = LogFactory.getLog(WikittyStorageJDBC.class);
- /** JDBC driver property name */
+ /**
+ * JDBC driver property name
+ */
static protected String driver = "jdbc.con.driver";
- /** wikitty_admin table creation query property name */
+ /**
+ * wikitty_admin table creation query property name
+ */
static protected String wikittyAdminCreationQ = "jdbc.queries.creation.wikitty.admin";
- /** wikitty_admin table creation query property name */
+ /**
+ * wikitty_admin table creation query property name
+ */
static protected String wikittyDataCreationQ = "jdbc.queries.creation.wikitty.data";
- /** basic selection with where clause query property name */
+ /**
+ * basic selection with where clause query property name
+ */
static protected String whereSelectionQ = "jdbc.queries.select.where";
- /** not dleeted data selection with where clause query property name */
+ /**
+ * not dleeted data selection with where clause query property name
+ */
static protected String notDeletedWhereSelectionQ = "jdbc.queries.select.where.notdeleted";
- /** insertion in the admin table query property name */
+ /**
+ * insertion in the admin table query property name
+ */
static protected String adminInsertQ = "jdbc.queries.insert.wikitty.admin";
- /** update in the admin table query property name */
+ /**
+ * update in the admin table query property name
+ */
static protected String adminUpdateQ = "jdbc.queries.update.wikitty.admin";
- /** insertion in the data table query property name */
+ /**
+ * insertion in the data table query property name
+ */
static protected String dataInsertQ = "jdbc.queries.insert.wikitty.data";
- /** deletion in the admin table query property name */
+ /**
+ * deletion in the admin table query property name
+ */
static protected String adminDeletionQ = "jdbc.queries.delete.wikitty.admin";
- /** deletion in the data table query property name */
+ /**
+ * deletion in the data table query property name
+ */
static protected String dataDeletionQ = "jdbc.queries.delete.wikitty.data";
- /** admin table name */
+ /**
+ * admin table name
+ */
static protected String adminTable = "wikitty_admin";
- /** data table name */
+ /**
+ * data table name
+ */
static protected String dataTable = "wikitty_data";
- /** Properties file */
+ /**
+ * Properties file
+ */
protected Properties conf = loadProperties();
- /** used to parse list field from hbase data. ex: extension.fieldname[11/15] */
+ /**
+ * used to parse list field from hbase data. ex: extension.fieldname[11/15]
+ */
static final private Pattern listFieldPattern =
Pattern.compile("(.*)\\[(\\d+)/(\\d+)\\]");
@@ -115,9 +127,9 @@
this.date = date;
}
}
-
+
protected WikittyExtensionStorage extensionStorage;
-
+
public WikittyStorageJDBC(WikittyExtensionStorage extensionStorage) {
this.extensionStorage = extensionStorage;
//check if driver ca be loaded
@@ -140,7 +152,7 @@
statement.execute(conf.getProperty(wikittyAdminCreationQ));
statement.execute(conf.getProperty(wikittyDataCreationQ));
con.commit();
- } catch(SQLException eee) {
+ } catch (SQLException eee) {
con.rollback();
}
closeConnection(con);
@@ -156,8 +168,8 @@
@Override
public List<Command> prepare(WikittyTransaction transaction,
- Collection<Wikitty> wikitties,
- boolean disableAutoVersionIncrement) throws WikittyException {
+ Collection<Wikitty> wikitties,
+ boolean disableAutoVersionIncrement) throws WikittyException {
Connection con = null;
try {
con = getConnection();
@@ -166,8 +178,8 @@
Statement statement = con.createStatement();
ResultSet versionResultSet = statement.executeQuery(
String.format(conf.getProperty(whereSelectionQ),
- COL_VERSION, adminTable, COL_ID,
- "'" + wikitty.getId() + "'"));
+ COL_VERSION, adminTable, COL_ID,
+ "'" + wikitty.getId() + "'"));
StringBuffer batch = new StringBuffer();
String version = null;
String newVersion = null;
@@ -207,68 +219,68 @@
if (list != null) {
switch (type.getType()) {
case BOOLEAN:
- for (int i = 0 ; i < list.size() ; i++) {
- Boolean value = (Boolean)list.get(i);
+ for (int i = 0; i < list.size(); i++) {
+ Boolean value = (Boolean) list.get(i);
batch.append(String.format(conf.getProperty(dataInsertQ),
- COL_BOOLEAN_VALUE, wikitty.getId(),
- ext.getName(),
- fieldName + "[" + i + "/" + list.size() + "]",
- value.toString()));
+ COL_BOOLEAN_VALUE, wikitty.getId(),
+ ext.getName(),
+ fieldName + "[" + i + "/" + list.size() + "]",
+ value.toString()));
}
break;
case DATE:
- for (int i = 0 ; i < list.size() ; i++) {
- Date value = (Date)list.get(i);
+ for (int i = 0; i < list.size(); i++) {
+ Date value = (Date) list.get(i);
batch.append(String.format(
conf.getProperty(dataInsertQ),
- COL_DATE_VALUE, wikitty.getId(),
- ext.getName(),
- fieldName + "[" + i + "/" + list.size() + "]",
- "'" + new java.sql.Date(value.getTime()) + "'"));
+ COL_DATE_VALUE, wikitty.getId(),
+ ext.getName(),
+ fieldName + "[" + i + "/" + list.size() + "]",
+ "'" + new java.sql.Date(value.getTime()) + "'"));
}
break;
case NUMERIC:
- for (int i = 0 ; i < list.size() ; i++) {
- BigDecimal value = (BigDecimal)list.get(i);
+ for (int i = 0; i < list.size(); i++) {
+ BigDecimal value = (BigDecimal) list.get(i);
batch.append(String.format(
conf.getProperty(dataInsertQ),
- COL_NUMBER_VALUE, wikitty.getId(),
- ext.getName(),
- fieldName + "[" + i + "/" + list.size() + "]",
- value.toString()));
+ COL_NUMBER_VALUE, wikitty.getId(),
+ ext.getName(),
+ fieldName + "[" + i + "/" + list.size() + "]",
+ value.toString()));
}
break;
case STRING:
- for (int i = 0 ; i < list.size() ; i++) {
- String value = (String)list.get(i);
+ for (int i = 0; i < list.size(); i++) {
+ String value = (String) list.get(i);
batch.append(String.format(
conf.getProperty(dataInsertQ),
- COL_TEXT_VALUE, wikitty.getId(),
- ext.getName(),
- fieldName + "[" + i + "/" + list.size() + "]",
- "'" + value + "'"));
+ COL_TEXT_VALUE, wikitty.getId(),
+ ext.getName(),
+ fieldName + "[" + i + "/" + list.size() + "]",
+ "'" + value + "'"));
}
break;
case WIKITTY:
- for (int i = 0 ; i < list.size() ; i++) {
- String value = (String)list.get(i);
+ for (int i = 0; i < list.size(); i++) {
+ String value = (String) list.get(i);
batch.append(String.format(
conf.getProperty(dataInsertQ),
- COL_TEXT_VALUE, wikitty.getId(),
- ext.getName(),
- fieldName + "[" + i + "/" + list.size() + "]",
- "'" + value + "'"));
+ COL_TEXT_VALUE, wikitty.getId(),
+ ext.getName(),
+ fieldName + "[" + i + "/" + list.size() + "]",
+ "'" + value + "'"));
}
break;
default:
- for (int i = 0 ; i < list.size() ; i++) {
- String value = (String)list.get(i);
+ for (int i = 0; i < list.size(); i++) {
+ String value = (String) list.get(i);
batch.append(String.format(
conf.getProperty(dataInsertQ),
- COL_TEXT_VALUE, wikitty.getId(),
- ext.getName(),
- fieldName + "[" + i + "/" + list.size() + "]",
- "'" + value + "'"));
+ COL_TEXT_VALUE, wikitty.getId(),
+ ext.getName(),
+ fieldName + "[" + i + "/" + list.size() + "]",
+ "'" + value + "'"));
}
break;
}
@@ -410,16 +422,16 @@
@Override
public UpdateResponse commit(WikittyTransaction transaction,
- List<Command> wikittyStorageCommandList) {
+ List<Command> wikittyStorageCommandList) {
Connection con = null;
try {
con = getConnection();
Statement statement = con.createStatement();
UpdateResponse result = new UpdateResponse();
- for(Command command : wikittyStorageCommandList) {
- CommandJDBC commandJDBC = (CommandJDBC)command;
+ for (Command command : wikittyStorageCommandList) {
+ CommandJDBC commandJDBC = (CommandJDBC) command;
statement.execute(commandJDBC.queries);
-
+
if (commandJDBC.toStore) {
Wikitty wikitty = commandJDBC.wikitty;
String newVersion = commandJDBC.version;
@@ -452,7 +464,7 @@
//select the data with the id "id" in the admin table
ResultSet resultSet = statement.executeQuery(
String.format(conf.getProperty(whereSelectionQ), COL_ID,
- adminTable, COL_ID, "'" + id + "'"));
+ adminTable, COL_ID, "'" + id + "'"));
// return true if the query has a result
boolean result = resultSet.first();
closeConnection(con);
@@ -472,18 +484,18 @@
//select the data with the id "id" in the admin table
ResultSet resultSet = statement.executeQuery(
String.format(conf.getProperty(whereSelectionQ),
- COL_DELETION_DATE, adminTable, COL_ID, "'" + id + "'"));
+ COL_DELETION_DATE, adminTable, COL_ID, "'" + id + "'"));
boolean result;
- if(resultSet.first()) {
+ if (resultSet.first()) {
result = resultSet.getDate(COL_DELETION_DATE) != null;
closeConnection(con);
return result;
} else {
closeConnection(con);
throw new WikittyException(String.format(
- "Wikitty with id '%s' doesn't exists", id));
+ "Wikitty with id '%s' doesn't exists", id));
}
-
+
} catch (SQLException eee) {
closeConnection(con);
throw new WikittyException(eee);
@@ -500,14 +512,14 @@
//select the data with the id "id" in the admin table
ResultSet adminResultSet = statement.executeQuery(
String.format(conf.getProperty(notDeletedWhereSelectionQ), "*",
- adminTable, COL_ID, "'" + id + "'"));
+ adminTable, COL_ID, "'" + id + "'"));
if (adminResultSet.first()) {
String version = adminResultSet.getString(COL_VERSION);
String extensionList = adminResultSet.getString(COL_EXTENSION);
//select the data with the id "id" in the data table
ResultSet dataResultSet = statement.executeQuery(
- String.format(conf.getProperty(whereSelectionQ), "*",
- dataTable, COL_ID, "'" + id + "'"));
+ String.format(conf.getProperty(whereSelectionQ), "*",
+ dataTable, COL_ID, "'" + id + "'"));
Wikitty result = constructWikitty(id, version, extensionList,
dataResultSet, fqFieldName);
return result;
@@ -523,7 +535,7 @@
@Override
public List<Wikitty> restore(Collection<String> ids,
- String... fqFieldName) throws WikittyException {
+ String... fqFieldName) throws WikittyException {
List<Wikitty> result = new ArrayList<Wikitty>(ids.size());
for (String id : ids) {
Wikitty w = restore(id, fqFieldName);
@@ -563,15 +575,16 @@
/**
* Create Wikitty from h2 tables
- * @param id the id of the wikitty to restore
- * @param version the version of the wikitty to restore
+ *
+ * @param id the id of the wikitty to restore
+ * @param version the version of the wikitty to restore
* @param extensionList the list of the extensions of the wikitty to restore
- * @param resulSet the ResultSet as the result of the selection of the in the data table
- * @param fqFieldName minimum field to restore
+ * @param resulSet the ResultSet as the result of the selection of the in the data table
+ * @param fqFieldName minimum field to restore
* @return
*/
protected Wikitty constructWikitty(String id, String version, String extensionList,
- ResultSet resultSet, String... fqFieldName) throws Exception {
+ ResultSet resultSet, String... fqFieldName) throws Exception {
Set<String> acceptedField = new HashSet<String>(Arrays.asList(fqFieldName));
Wikitty result = new Wikitty(id);
result.setVersion(version);
@@ -626,7 +639,7 @@
}
array[index] = value;
} else {
- if(log.isErrorEnabled()) {
+ if (log.isErrorEnabled()) {
log.error(String.format(
"Can't read list field correctly '%s'", fqfieldName));
}
@@ -641,7 +654,7 @@
for (String fieldName : listFieldMap.keySet()) {
Object[] array = listFieldMap.get(fieldName);
List list = new ArrayList(Arrays.asList(array));
- result.setFqField(fieldName, list );
+ result.setFqField(fieldName, list);
}
return result;
@@ -649,8 +662,9 @@
/**
* Test if fqfieldName is in acceptedField
+ *
* @param acceptedField list of all accepted field
- * @param fqfieldName fully qualified field name with potential [n/m] at end
+ * @param fqfieldName fully qualified field name with potential [n/m] at end
* @return if fqfieldName without potential [n/m] is in acceptedField or if acceptedField is empty
*/
protected boolean isAcceptedField(Set<String> acceptedField, String fqfieldName) {
Modified: wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/test/java/org/sharengo/wikitty/jdbc/JDBCStorageTest.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/test/java/org/sharengo/wikitty/jdbc/JDBCStorageTest.java 2009-10-29 08:51:03 UTC (rev 299)
+++ wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/test/java/org/sharengo/wikitty/jdbc/JDBCStorageTest.java 2009-10-29 15:12:30 UTC (rev 300)
@@ -21,6 +21,7 @@
import org.sharengo.wikitty.Criteria;
import org.sharengo.wikitty.Wikitty;
import org.sharengo.wikitty.WikittyService;
+import org.sharengo.wikitty.search.Element;
import org.sharengo.wikitty.search.Search;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
@@ -36,7 +37,7 @@
public void testExport() throws Exception {
final List<Wikitty> wikitties = createSampleWikitty(ws);
- Criteria criteria = Search.query().eqExt(EXTNAME).criteria();
+ Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, EXTNAME).criteria();
String result = ws.syncExportAllByCriteria(criteria);
log.debug("[XML] " + result);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
Modified: wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/test/java/org/sharengo/wikitty/jdbc/TreeTest.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/test/java/org/sharengo/wikitty/jdbc/TreeTest.java 2009-10-29 08:51:03 UTC (rev 299)
+++ wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/test/java/org/sharengo/wikitty/jdbc/TreeTest.java 2009-10-29 15:12:30 UTC (rev 300)
@@ -161,7 +161,7 @@
Wikitty root = findNode("root");
String rootId = root.getId();
- Criteria criteria = Search.query().eq(WikittySearchEngineSolr.TREENODE_ROOT, rootId).criteria()
+ Criteria criteria = Search.query().eq(WikittySearchEnginSolr.TREENODE_ROOT, rootId).criteria()
.setFirstIndex(0).setEndIndex(WikittyService.ALL_ELEMENTS)
.addFacetField(rootId);
PagedResult<Wikitty> result = ws.findAllByCriteria(criteria);
1
0
r299 - wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty
by sletellier@users.nuiton.org 29 Oct '09
by sletellier@users.nuiton.org 29 Oct '09
29 Oct '09
Author: sletellier
Date: 2009-10-29 09:51:03 +0100 (Thu, 29 Oct 2009)
New Revision: 299
Modified:
wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityBean.java
wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/Wikitty.java
Log:
Adding fire
Modified: wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityBean.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityBean.java 2009-10-29 01:53:08 UTC (rev 298)
+++ wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityBean.java 2009-10-29 08:51:03 UTC (rev 299)
@@ -88,6 +88,7 @@
public void setField(String ext, String fieldName, Object value) {
String key = ext + "$" + fieldName;
fieldValue.put(key, value);
+ propertyChange.firePropertyChange(fieldName, null, value);
}
public FieldType getFieldType(String ext, String fieldName) {
@@ -114,4 +115,4 @@
propertyChange.removePropertyChangeListener(propertyName, listener);
}
-}
+ }
Modified: wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/Wikitty.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/Wikitty.java 2009-10-29 01:53:08 UTC (rev 298)
+++ wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/Wikitty.java 2009-10-29 08:51:03 UTC (rev 299)
@@ -266,6 +266,8 @@
// mark field dirty and call listener
setFieldDirty(ext, fieldName, oldValue, validValue);
+
+ propertyChange.firePropertyChange(fieldName, oldValue, validValue);
}
public Object getFieldAsObject(String ext, String fieldName) {
1
0
r298 - wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty
by tchemit@users.nuiton.org 29 Oct '09
by tchemit@users.nuiton.org 29 Oct '09
29 Oct '09
Author: tchemit
Date: 2009-10-29 02:53:08 +0100 (Thu, 29 Oct 2009)
New Revision: 298
Modified:
wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityBean.java
wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityWikitty.java
Log:
- fix api + try to make bindings works (but I won't :))
Modified: wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityBean.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityBean.java 2009-10-28 23:36:39 UTC (rev 297)
+++ wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityBean.java 2009-10-29 01:53:08 UTC (rev 298)
@@ -17,6 +17,8 @@
package org.sharengo.wikitty;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -37,6 +39,9 @@
protected String id;
protected String version;
+ /** used to add property change support to wikitty object */
+ protected PropertyChangeSupport propertyChange = new PropertyChangeSupport(this);
+
/**
* Map is LinkedHashMap to maintains order like user want
* key: extension name
@@ -89,4 +94,24 @@
throw new UnsupportedOperationException("Not supported yet.");
}
+ public void addPropertyChangeListener(
+ PropertyChangeListener listener) {
+ propertyChange.addPropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(
+ PropertyChangeListener listener) {
+ propertyChange.removePropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName,
+ PropertyChangeListener listener) {
+ propertyChange.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName,
+ PropertyChangeListener listener) {
+ propertyChange.removePropertyChangeListener(propertyName, listener);
+ }
+
}
Modified: wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityWikitty.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityWikitty.java 2009-10-28 23:36:39 UTC (rev 297)
+++ wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityWikitty.java 2009-10-29 01:53:08 UTC (rev 298)
@@ -17,6 +17,7 @@
package org.sharengo.wikitty;
+import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.Collection;
@@ -32,7 +33,7 @@
* Last update: $Date$
* by : $Author$
*/
-public class BusinessEntityWikitty implements BusinessEntity {
+public class BusinessEntityWikitty implements BusinessEntity,PropertyChangeListener {
private static final long serialVersionUID = 1L;
@@ -47,11 +48,18 @@
public BusinessEntityWikitty() {
setWikitty( new Wikitty() );
+ // on ecoute les changement du wikkity
+ wikitty.addPropertyChangeListener(this);
}
-
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ propertyChange.firePropertyChange(evt);
+ }
+
public void addPropertyChangeListener(
PropertyChangeListener listener) {
- propertyChange.addPropertyChangeListener(listener);
+ propertyChange.addPropertyChangeListener(listener);
}
public void removePropertyChangeListener(
@@ -61,6 +69,7 @@
public void addPropertyChangeListener(String propertyName,
PropertyChangeListener listener) {
+ System.out.println("addPRopertyChangeListener "+propertyName+" = "+listener);
propertyChange.addPropertyChangeListener(propertyName, listener);
}
@@ -117,6 +126,7 @@
public void setField(String ext, String fieldName, Object value) {
getWikitty().setField(ext, fieldName, value);
+ propertyChange.firePropertyChange(fieldName,null,value);
}
public Collection<WikittyExtension> getStaticExtensions() {
1
0
r297 - wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty
by sletellier@users.nuiton.org 28 Oct '09
by sletellier@users.nuiton.org 28 Oct '09
28 Oct '09
Author: sletellier
Date: 2009-10-29 00:36:39 +0100 (Thu, 29 Oct 2009)
New Revision: 297
Modified:
wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntity.java
Log:
Adding property change in interface
Modified: wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntity.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntity.java 2009-10-28 17:54:10 UTC (rev 296)
+++ wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntity.java 2009-10-28 23:36:39 UTC (rev 297)
@@ -17,6 +17,7 @@
package org.sharengo.wikitty;
+import java.beans.PropertyChangeListener;
import java.io.Serializable;
import java.util.Collection;
@@ -78,4 +79,16 @@
*/
public FieldType getFieldType(String ext, String fieldName);
+ public void addPropertyChangeListener(
+ PropertyChangeListener listener);
+
+ public void removePropertyChangeListener(
+ PropertyChangeListener listener);
+
+ public void addPropertyChangeListener(String propertyName,
+ PropertyChangeListener listener);
+
+ public void removePropertyChangeListener(String propertyName,
+ PropertyChangeListener listener);
+
}
1
0
Author: tchemit
Date: 2009-10-28 18:54:10 +0100 (Wed, 28 Oct 2009)
New Revision: 296
Modified:
wikengo_core-wikitty/pom.xml
Log:
add some profiles
Modified: wikengo_core-wikitty/pom.xml
===================================================================
--- wikengo_core-wikitty/pom.xml 2009-10-28 17:52:55 UTC (rev 295)
+++ wikengo_core-wikitty/pom.xml 2009-10-28 17:54:10 UTC (rev 296)
@@ -77,7 +77,54 @@
</repository>
</repositories>
+
+ <profiles>
+ <!-- perform only on a release stage when using the maven-release-plugin -->
+ <profile>
+ <id>release-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+
+ <!-- always compute source jar -->
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- always compute javadoc jar -->
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+
+ </build>
+ </profile>
+
+ </profiles>
+
</project>
1
0
Author: tchemit
Date: 2009-10-28 18:52:55 +0100 (Wed, 28 Oct 2009)
New Revision: 295
Modified:
wikengo_core-wikitty/pom.xml
Log:
add temorary distributionManagement
Modified: wikengo_core-wikitty/pom.xml
===================================================================
--- wikengo_core-wikitty/pom.xml 2009-10-28 17:44:45 UTC (rev 294)
+++ wikengo_core-wikitty/pom.xml 2009-10-28 17:52:55 UTC (rev 295)
@@ -22,11 +22,17 @@
<version>1.0.0-SNAPSHOT</version>
</parent>
- <dependencyManagement>
- <dependencies>
- </dependencies>
- </dependencyManagement>
-
+ <distributionManagement>
+ <repository>
+ <id>nuiton</id>
+ <url>scpexe://nuiton.org/var/lib/maven/release</url>
+ </repository>
+ <snapshotRepository>
+ <id>nuiton</id>
+ <url>scpexe://nuiton.org/var/lib/maven/snapshot</url>
+ </snapshotRepository>
+ </distributionManagement>
+
<!-- ************************************************************* -->
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
1
0
r294 - in wikengo_core-wikitty: wikengo_core-wikitty-api wikengo_core-wikitty-jdbc-impl
by sletellier@users.nuiton.org 28 Oct '09
by sletellier@users.nuiton.org 28 Oct '09
28 Oct '09
Author: sletellier
Date: 2009-10-28 18:44:45 +0100 (Wed, 28 Oct 2009)
New Revision: 294
Modified:
wikengo_core-wikitty/wikengo_core-wikitty-api/pom.xml
wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/pom.xml
Log:
UP to 1.0-CL
Modified: wikengo_core-wikitty/wikengo_core-wikitty-api/pom.xml
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-api/pom.xml 2009-10-28 17:41:23 UTC (rev 293)
+++ wikengo_core-wikitty/wikengo_core-wikitty-api/pom.xml 2009-10-28 17:44:45 UTC (rev 294)
@@ -13,7 +13,7 @@
<parent>
<groupId>org.sharengo.wikengo</groupId>
<artifactId>core-wikitty</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0-CL-SNAPSHOT</version>
</parent>
<dependencies>
Modified: wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/pom.xml
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/pom.xml 2009-10-28 17:41:23 UTC (rev 293)
+++ wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/pom.xml 2009-10-28 17:44:45 UTC (rev 294)
@@ -9,7 +9,7 @@
<parent>
<groupId>org.sharengo.wikengo</groupId>
<artifactId>core-wikitty</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0-CL-SNAPSHOT</version>
</parent>
<dependencies>
@@ -28,7 +28,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>core-wikitty-test</artifactId>
- <version>${project.version}</version>
+ <version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
1
0
r293 - wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty
by sletellier@users.nuiton.org 28 Oct '09
by sletellier@users.nuiton.org 28 Oct '09
28 Oct '09
Author: sletellier
Date: 2009-10-28 18:41:23 +0100 (Wed, 28 Oct 2009)
New Revision: 293
Modified:
wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityWikitty.java
Log:
Adding property change listener
Modified: wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityWikitty.java
===================================================================
--- wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityWikitty.java 2009-10-28 17:04:20 UTC (rev 292)
+++ wikengo_core-wikitty/wikengo_core-wikitty-api/src/main/java/org/sharengo/wikitty/BusinessEntityWikitty.java 2009-10-28 17:41:23 UTC (rev 293)
@@ -17,6 +17,8 @@
package org.sharengo.wikitty;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
import java.util.Collection;
import java.util.Collections;
@@ -34,6 +36,9 @@
private static final long serialVersionUID = 1L;
+ /** used to add property change support to wikitty object */
+ protected PropertyChangeSupport propertyChange = new PropertyChangeSupport(this);
+
protected Wikitty wikitty;
public BusinessEntityWikitty(Wikitty wi) {
@@ -43,8 +48,27 @@
public BusinessEntityWikitty() {
setWikitty( new Wikitty() );
}
+
+ public void addPropertyChangeListener(
+ PropertyChangeListener listener) {
+ propertyChange.addPropertyChangeListener(listener);
+ }
-
+ public void removePropertyChangeListener(
+ PropertyChangeListener listener) {
+ propertyChange.removePropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName,
+ PropertyChangeListener listener) {
+ propertyChange.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName,
+ PropertyChangeListener listener) {
+ propertyChange.removePropertyChangeListener(propertyName, listener);
+ }
+
public String getWikittyId() {
String result = getWikitty().getId();
return result;
1
0