Mapstoragemanager-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
- 329 discussions
r159 - in trunk/msm-bighashmap: . src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap
by dlanglais@users.nuiton.org 02 Mar '10
by dlanglais@users.nuiton.org 02 Mar '10
02 Mar '10
Author: dlanglais
Date: 2010-03-02 13:21:23 +0100 (Tue, 02 Mar 2010)
New Revision: 159
Modified:
trunk/msm-bighashmap/pom.xml
trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/BigHashMap.java
trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Table.java
trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/package-info.java
Log:
retablissement du build... utf-8...
Modified: trunk/msm-bighashmap/pom.xml
===================================================================
--- trunk/msm-bighashmap/pom.xml 2010-03-02 12:10:28 UTC (rev 158)
+++ trunk/msm-bighashmap/pom.xml 2010-03-02 12:21:23 UTC (rev 159)
@@ -197,8 +197,31 @@
</plugins>
</pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <encoding>${project.build.sourceEncoding}</encoding>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <encoding>${project.build.sourceEncoding}</encoding>
+ </configuration>
+ </plugin>
+ </plugins>
</build>
-
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
</project>
+
Modified: trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/BigHashMap.java
===================================================================
--- trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/BigHashMap.java 2010-03-02 12:10:28 UTC (rev 158)
+++ trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/BigHashMap.java 2010-03-02 12:21:23 UTC (rev 159)
@@ -68,7 +68,6 @@
@Override
public final void deleteTable(final String table) {
this.tables.remove(table);
- a = a;
}
/**
Modified: trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Table.java
===================================================================
--- trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Table.java 2010-03-02 12:10:28 UTC (rev 158)
+++ trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Table.java 2010-03-02 12:21:23 UTC (rev 159)
@@ -14,7 +14,7 @@
* Create a column in the table.
* @param columnName the column name
* @param columnClass the column class
- * @param <columnClass> generics to sp�cify the class of the stored objects.
+ * @param <columnClass> generics to specify the class of the stored objects.
*/
<columnClass> void createColumn(final String columnName,
final Class<?> columnClass);
Modified: trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/package-info.java
===================================================================
--- trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/package-info.java 2010-03-02 12:10:28 UTC (rev 158)
+++ trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/package-info.java 2010-03-02 12:21:23 UTC (rev 159)
@@ -1,6 +1,6 @@
package org.nuiton.mapstoragemanager.plugins.bighashmap;
/**
* @package BigHashMap.
- * Permet la repr�sentation sous forme de hashMap d'une base de donn�es selon
- * la sp�cification bigTable.
+ * Permet la représentation sous forme de hashMap d'une base de données selon
+ * la spécification bigTable.
*/
2
1
r158 - trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap
by dlanglais@users.nuiton.org 02 Mar '10
by dlanglais@users.nuiton.org 02 Mar '10
02 Mar '10
Author: dlanglais
Date: 2010-03-02 13:10:28 +0100 (Tue, 02 Mar 2010)
New Revision: 158
Modified:
trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/BigHashMap.java
trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Cell.java
trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/CellImpl.java
trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Column.java
trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/ColumnImpl.java
trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Row.java
trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/RowImpl.java
trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Structure.java
trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/StructureImpl.java
trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Table.java
trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/TableImpl.java
trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/package-info.java
Log:
correction checkstyle sur le plugin MSM-BigHashMap
Modified: trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/BigHashMap.java
===================================================================
--- trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/BigHashMap.java 2010-03-02 11:24:35 UTC (rev 157)
+++ trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/BigHashMap.java 2010-03-02 12:10:28 UTC (rev 158)
@@ -39,7 +39,7 @@
* Create a new HashMap database.
*/
@Override
- public boolean connect(Properties properties) {
+ public final boolean connect(final Properties properties) {
//throw new UnsupportedOperationException("Not supported yet.");
new BigHashMap();
return true;
@@ -49,7 +49,7 @@
* {@inheritDoc}
*/
@Override
- public void selectTable(String table) {
+ public final void selectTable(final String table) {
// Not used
//this.currentTable = tables.get(table);
}
@@ -58,7 +58,7 @@
* {@inheritDoc}
*/
@Override
- public void createTable(String table) {
+ public final void createTable(final String table) {
this.tables.put(table, new TableImpl());
}
@@ -66,15 +66,16 @@
* {@inheritDoc}
*/
@Override
- public void deleteTable(String table) {
+ public final void deleteTable(final String table) {
this.tables.remove(table);
+ a = a;
}
/**
* {@inheritDoc}
*/
@Override
- public Set<String> getTablesNames() {
+ public final Set<String> getTablesNames() {
return this.tables.keySet();
}
@@ -82,7 +83,7 @@
* {@inheritDoc}
*/
@Override
- public void createColumn(String table, String column) {
+ public final void createColumn(final String table, final String column) {
this.tables.get(table).createColumn(column, null);
}
@@ -90,7 +91,7 @@
* {@inheritDoc}
*/
@Override
- public void deleteColumn(String table, String column) {
+ public final void deleteColumn(final String table, final String column) {
this.tables.get(table).deleteColumn(column);
}
@@ -98,7 +99,7 @@
* {@inheritDoc}
*/
@Override
- public Set<String> getColumnsNames(String table) {
+ public final Set<String> getColumnsNames(final String table) {
return this.tables.get(table).getColumnsNames();
}
@@ -106,7 +107,8 @@
* {@inheritDoc}
*/
@Override
- public void put(String table, String column, String key, String content) {
+ public final void put(final String table, final String column,
+ final String key, final String content) {
this.tables.get(table).put(column, key, content);
}
@@ -114,7 +116,8 @@
* {@inheritDoc}
*/
@Override
- public String get(String table, String column, String key) {
+ public final String get(final String table, final String column,
+ final String key) {
return this.tables.get(table).get(column, key).toString();
}
@@ -122,7 +125,8 @@
* {@inheritDoc}
*/
@Override
- public String get(String table, String column, String key, int version) {
+ public final String get(final String table, final String column,
+ final String key, final int version) {
return this.tables.get(table).get(column, key, version).toString();
}
@@ -130,14 +134,15 @@
* {@inheritDoc}
*/
@Override
- public Map<String, String> getRow(String table, String key) {
-
+ public final Map<String, String> getRow(final String table,
+ final String key) {
+
Row row = this.tables.get(table).getRow(key);
- Map<String,Object> rowContent = row.getRowContent();
- Map<String,String> rowMap = new HashMap<String,String>();
+ Map<String, Object> rowContent = row.getRowContent();
+ Map<String, String> rowMap = new HashMap<String, String>();
- for(String rowKey : rowContent.keySet()) {
+ for (String rowKey : rowContent.keySet()) {
String rowValue = rowContent.get(rowKey).toString();
rowMap.put(rowKey, rowValue);
}
@@ -148,7 +153,7 @@
* {@inheritDoc}
*/
@Override
- public Set<String> getKeys(String table) {
+ public final Set<String> getKeys(final String table) {
return this.tables.get(table).getKeys();
}
@@ -156,7 +161,7 @@
* {@inheritDoc}
*/
@Override
- public String getPluginName() {
+ public final String getPluginName() {
return this.getClass().getSimpleName();
}
Modified: trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Cell.java
===================================================================
--- trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Cell.java 2010-03-02 11:24:35 UTC (rev 157)
+++ trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Cell.java 2010-03-02 12:10:28 UTC (rev 158)
@@ -31,17 +31,20 @@
/**
* hashCode().
- * @return
+ * @return hashCode.
*/
int hashCode();
/**
* equals().
+ * @param o the object to compare
+ * @return true if instance equals to object o.
*/
boolean equals(Object o);
/**
* toString().
+ * @return a string representation of the cell.
*/
String toString();
}
Modified: trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/CellImpl.java
===================================================================
--- trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/CellImpl.java 2010-03-02 11:24:35 UTC (rev 157)
+++ trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/CellImpl.java 2010-03-02 12:10:28 UTC (rev 158)
@@ -10,7 +10,6 @@
* So a cell store objects and its version.
* @param <T> The type of the stored objects.
* @author dorian Langlais, amaury Fages, gilles Crieloue, florent Gilet.
- * @licence GPL.
*/
public class CellImpl<T> implements Cell<T> {
@@ -31,7 +30,7 @@
* Constructor with object.
* @param t The object to store.
*/
- public CellImpl(T t) {
+ public CellImpl(final T t) {
this.cell = new HashMap<Long, T>();
this.put(t);
}
@@ -40,7 +39,7 @@
* {@inheritDoc}
*/
public final void put(final T t) {
- cell.put((long)cell.size(), t);
+ cell.put((long) cell.size(), t);
//cell.put(System.currentTimeMillis(), t);
}
@@ -70,9 +69,9 @@
/**
* {@inheritDoc}
*/
- public int hashCode() {
+ public final int hashCode() {
int hash = 0;
- if (! this.cell.isEmpty()) {
+ if (!this.cell.isEmpty()) {
hash = this.get().hashCode();
}
return hash;
@@ -83,12 +82,12 @@
* //TODO : we consider only the last item... but it will be better to
* //TODO verify all the "versions" of the cell.
*/
- public boolean equals(Object o) {
+ public final boolean equals(final Object o) {
boolean equals = false;
if (o instanceof CellImpl) {
CellImpl another = (CellImpl) o;
- if(this.cell.size() == another.cell.size()) {
- if(this.cell.isEmpty()) {
+ if (this.cell.size() == another.cell.size()) {
+ if (this.cell.isEmpty()) {
equals = true;
} else {
equals = this.get().equals(another.get());
@@ -100,9 +99,9 @@
/**
* {@inheritDoc}
*/
- public String toString() {
+ public final String toString() {
String ret = "";
- if (! this.cell.isEmpty()) {
+ if (!this.cell.isEmpty()) {
ret = ((T) this.get()).toString();
}
return ret;
Modified: trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Column.java
===================================================================
--- trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Column.java 2010-03-02 11:24:35 UTC (rev 157)
+++ trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Column.java 2010-03-02 12:10:28 UTC (rev 158)
@@ -11,15 +11,15 @@
public interface Column<T> {
/**
- * Get the object which has key <b>key</key>.
+ * Get the object which has key <b>key</b>.
* @param key the key.
* @return the object stored at the line identified by <b>key</b>
*/
T get(String key);
/**
- * Get the object which has key <b>key</key> and version <b>version</b>.
- * @param key
+ * Get the object which has key <b>key</b> and version <b>version</b>.
+ * @param key the key
* @param version the version wanted (it can be timestamp, number..).
* @return The object corresponding to the "version".
*/
@@ -40,17 +40,20 @@
/**
* hashCode().
- * @return
+ * @return hashCode.
*/
int hashCode();
/**
* equals().
+ * @param o the object to compare
+ * @return true if instance equals to object o.
*/
boolean equals(Object o);
/**
* toString().
+ * @return a string representation of the column.
*/
String toString();
Modified: trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/ColumnImpl.java
===================================================================
--- trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/ColumnImpl.java 2010-03-02 11:24:35 UTC (rev 157)
+++ trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/ColumnImpl.java 2010-03-02 12:10:28 UTC (rev 158)
@@ -9,7 +9,6 @@
* Classe Column.
* @param <T> Type de contenu des cellules.
* @author dorian Langlais, amaury Fages, gilles Crieloue, florent Gilet.
- * @licence GPL.
*/
public class ColumnImpl<T> implements Column<T> {
@@ -47,10 +46,10 @@
* {@inheritDoc}
*/
public final void put(final String key, final Object content) {
- if(this.column.keySet().contains(key)) {
- this.column.get(key).put((T)content);
+ if (this.column.keySet().contains(key)) {
+ this.column.get(key).put((T) content);
} else {
- this.column.put(key, new CellImpl<T>((T)content));
+ this.column.put(key, new CellImpl<T>((T) content));
}
}
@@ -66,7 +65,7 @@
*/
public final int hashCode() {
int hash = 0;
- for(Cell c : column.values()) {
+ for (Cell c : column.values()) {
hash += c.hashCode();
}
return hash;
@@ -75,10 +74,10 @@
/**
* {@inheritDoc}
*/
- public boolean equals(Object o) {
+ public final boolean equals(final Object o) {
boolean equals = false;
if (o instanceof Column) {
-
+
ColumnImpl other = (ColumnImpl) o;
equals = other.column.equals(this.column);
@@ -103,7 +102,7 @@
/**
* {@inheritDoc}
*/
- public Set<String> getKeys() {
+ public final Set<String> getKeys() {
return this.column.keySet();
}
}
Modified: trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Row.java
===================================================================
--- trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Row.java 2010-03-02 11:24:35 UTC (rev 157)
+++ trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Row.java 2010-03-02 12:10:28 UTC (rev 158)
@@ -3,7 +3,7 @@
import java.util.Map;
/**
- * Interface to present the methods on a Row
+ * Interface to present the methods on a Row.
* @author Dorian Langlais
*
*/
Modified: trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/RowImpl.java
===================================================================
--- trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/RowImpl.java 2010-03-02 11:24:35 UTC (rev 157)
+++ trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/RowImpl.java 2010-03-02 12:10:28 UTC (rev 158)
@@ -24,8 +24,7 @@
* @param struct the row structure
* @param content the row content
*/
- public RowImpl(final Structure struct,
- final Map<String, Object> content) {
+ public RowImpl(final Structure struct, final Map<String, Object> content) {
this.rowStructure = struct;
this.rowContent = new HashMap<String, Object>();
for (String columnName : struct.getColumnsNames()) {
@@ -36,14 +35,14 @@
/**
* {@inheritDoc}
*/
- public Structure getRowStructure() {
+ public final Structure getRowStructure() {
return rowStructure;
}
/**
* {@inheritDoc}
*/
- public Map<String, Object> getRowContent() {
+ public final Map<String, Object> getRowContent() {
return rowContent;
}
@@ -59,7 +58,7 @@
/**
* {@inheritDoc}
*/
- public Object getContent(String columnName) {
+ public final Object getContent(final String columnName) {
return rowContent.get(columnName);
}
}
Modified: trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Structure.java
===================================================================
--- trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Structure.java 2010-03-02 11:24:35 UTC (rev 157)
+++ trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Structure.java 2010-03-02 12:10:28 UTC (rev 158)
@@ -44,7 +44,7 @@
/**
* Permit to verify if this is equals to another object.
- * @param another the object to compare
+ * @param o the object to compare
* @return true if this is equals to <b>another</b>
*/
boolean equals(Object o);
Modified: trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/StructureImpl.java
===================================================================
--- trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/StructureImpl.java 2010-03-02 11:24:35 UTC (rev 157)
+++ trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/StructureImpl.java 2010-03-02 12:10:28 UTC (rev 158)
@@ -61,8 +61,8 @@
*/
public final int hashCode() {
int hash = 0;
- if ( ! structure.isEmpty()) {
- for (String key : structure.keySet() ) {
+ if (!structure.isEmpty()) {
+ for (String key : structure.keySet()) {
hash += key.hashCode();
hash += structure.get(key).hashCode();
}
@@ -73,10 +73,10 @@
/**
* {@inheritDoc}
*/
- public final boolean equals(Object o) {
+ public final boolean equals(final Object o) {
boolean equals = false;
if (o instanceof StructureImpl) {
-
+
StructureImpl another = (StructureImpl) o;
equals = this.structure.equals(another.structure);
Modified: trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Table.java
===================================================================
--- trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Table.java 2010-03-02 11:24:35 UTC (rev 157)
+++ trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/Table.java 2010-03-02 12:10:28 UTC (rev 158)
@@ -14,7 +14,7 @@
* Create a column in the table.
* @param columnName the column name
* @param columnClass the column class
- * @param <columnClass> generics to spécify the class of the stored objects.
+ * @param <columnClass> generics to sp�cify the class of the stored objects.
*/
<columnClass> void createColumn(final String columnName,
final Class<?> columnClass);
Modified: trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/TableImpl.java
===================================================================
--- trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/TableImpl.java 2010-03-02 11:24:35 UTC (rev 157)
+++ trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/TableImpl.java 2010-03-02 12:10:28 UTC (rev 158)
@@ -9,7 +9,6 @@
* Class Table.
* Implements the interface Table.
* @author dorian Langlais, amaury Fages, gilles Crieloue, florent Gilet.
- * @licence GPL.
*/
public class TableImpl implements Table {
@@ -63,7 +62,7 @@
/**
* {@inheritDoc}
*/
- public void deleteRow(final String key) {
+ public final void deleteRow(final String key) {
for (Column column : tableColumns.values()) {
column.delete(key);
}
@@ -72,37 +71,39 @@
/**
* {@inheritDoc}
*/
- public void put(String columnName, String key, Object o) {
+ public final void put(final String columnName, final String key,
+ final Object o) {
this.tableColumns.get(columnName).put(key, o);
}
/**
* {@inheritDoc}
*/
- public Object get(String columnName, String key) {
+ public final Object get(final String columnName, final String key) {
return this.tableColumns.get(columnName).get(key);
}
/**
* {@inheritDoc}
*/
- public Object get(String columnName, String key, long version) {
+ public final Object get(final String columnName, final String key,
+ final long version) {
return this.tableColumns.get(columnName).get(key, version);
}
/**
* {@inheritDoc}
*/
- public Set<String> getColumnsNames() {
+ public final Set<String> getColumnsNames() {
return this.tableColumns.keySet();
}
/**
* {@inheritDoc}
*/
- public Set<String> getKeys() {
+ public final Set<String> getKeys() {
Set<String> keys = new HashSet<String>();
- for(Column col : this.tableColumns.values()){
+ for (Column col : this.tableColumns.values()) {
keys.addAll(col.getKeys());
}
return keys;
Modified: trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/package-info.java
===================================================================
--- trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/package-info.java 2010-03-02 11:24:35 UTC (rev 157)
+++ trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/package-info.java 2010-03-02 12:10:28 UTC (rev 158)
@@ -1,6 +1,6 @@
package org.nuiton.mapstoragemanager.plugins.bighashmap;
/**
- * package BigHashMap.
- * Permet la représentation sous forme de hashMap d'une base de données selon
- * la spécification bigTable.
+ * @package BigHashMap.
+ * Permet la repr�sentation sous forme de hashMap d'une base de donn�es selon
+ * la sp�cification bigTable.
*/
1
0
02 Mar '10
Author: dlanglais
Date: 2010-03-02 12:24:35 +0100 (Tue, 02 Mar 2010)
New Revision: 157
Modified:
trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/BigHashMap.java
trunk/msm-bighashmapV2/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmapv2/BigHashMap.java
trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXML.java
trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXML.java
trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/HBase.java
trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/BigTable.java
trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/Exporter.java
trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/Importer.java
trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/OurHashMap2.java
Log:
l'interface BigTable implemente plugin, r?\195?\169percussion sur les plugins
Modified: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/BigTable.java
===================================================================
--- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/BigTable.java 2010-03-02 11:13:24 UTC (rev 156)
+++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/BigTable.java 2010-03-02 11:24:35 UTC (rev 157)
@@ -8,7 +8,7 @@
* The interface for all the BigTable implementations.
* @author Dorian Langlais
*/
-public interface BigTable {
+public interface BigTable extends Plugin {
/**
* Connects to the database.
Modified: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/Exporter.java
===================================================================
--- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/Exporter.java 2010-03-02 11:13:24 UTC (rev 156)
+++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/Exporter.java 2010-03-02 11:24:35 UTC (rev 157)
@@ -6,7 +6,7 @@
* The interface for the exporter implementations.
* @author Dorian Langlais
*/
-public interface Exporter {
+public interface Exporter extends Plugin {
/**
* Export the content of a "bigTable" in a file.
Modified: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/Importer.java
===================================================================
--- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/Importer.java 2010-03-02 11:13:24 UTC (rev 156)
+++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/Importer.java 2010-03-02 11:24:35 UTC (rev 157)
@@ -6,7 +6,7 @@
* The interface for the importer implementations.
* @author Dorian Langlais
*/
-public interface Importer {
+public interface Importer extends Plugin {
/**
* Import the content of a file in a "bigTable".
Modified: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/OurHashMap2.java
===================================================================
--- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/OurHashMap2.java 2010-03-02 11:13:24 UTC (rev 156)
+++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/OurHashMap2.java 2010-03-02 11:24:35 UTC (rev 157)
@@ -116,4 +116,12 @@
Set<String> keys = new HashSet(mapColumn.get(column));
return keys;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getPluginName() {
+ return this.getClass().getSimpleName();
+ }
}
Modified: trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/BigHashMap.java
===================================================================
--- trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/BigHashMap.java 2010-03-02 11:13:24 UTC (rev 156)
+++ trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/BigHashMap.java 2010-03-02 11:24:35 UTC (rev 157)
@@ -38,6 +38,7 @@
* {@inheritDoc}
* Create a new HashMap database.
*/
+ @Override
public boolean connect(Properties properties) {
//throw new UnsupportedOperationException("Not supported yet.");
new BigHashMap();
@@ -47,6 +48,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void selectTable(String table) {
// Not used
//this.currentTable = tables.get(table);
@@ -55,6 +57,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void createTable(String table) {
this.tables.put(table, new TableImpl());
}
@@ -62,6 +65,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void deleteTable(String table) {
this.tables.remove(table);
}
@@ -69,6 +73,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Set<String> getTablesNames() {
return this.tables.keySet();
}
@@ -76,6 +81,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void createColumn(String table, String column) {
this.tables.get(table).createColumn(column, null);
}
@@ -83,6 +89,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void deleteColumn(String table, String column) {
this.tables.get(table).deleteColumn(column);
}
@@ -90,6 +97,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Set<String> getColumnsNames(String table) {
return this.tables.get(table).getColumnsNames();
}
@@ -97,6 +105,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void put(String table, String column, String key, String content) {
this.tables.get(table).put(column, key, content);
}
@@ -104,6 +113,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String get(String table, String column, String key) {
return this.tables.get(table).get(column, key).toString();
}
@@ -111,6 +121,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String get(String table, String column, String key, int version) {
return this.tables.get(table).get(column, key, version).toString();
}
@@ -118,6 +129,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Map<String, String> getRow(String table, String key) {
Row row = this.tables.get(table).getRow(key);
@@ -135,8 +147,17 @@
/**
* {@inheritDoc}
*/
+ @Override
public Set<String> getKeys(String table) {
return this.tables.get(table).getKeys();
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getPluginName() {
+ return this.getClass().getSimpleName();
+ }
+
}
Modified: trunk/msm-bighashmapV2/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmapv2/BigHashMap.java
===================================================================
--- trunk/msm-bighashmapV2/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmapv2/BigHashMap.java 2010-03-02 11:13:24 UTC (rev 156)
+++ trunk/msm-bighashmapV2/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmapv2/BigHashMap.java 2010-03-02 11:24:35 UTC (rev 157)
@@ -38,6 +38,7 @@
* {@inheritDoc}
* Create a new HashMap database.
*/
+ @Override
public boolean connect(Properties properties) {
//throw new UnsupportedOperationException("Not supported yet.");
new BigHashMap();
@@ -47,6 +48,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void selectTable(String table) {
// Not used
//this.currentTable = tables.get(table);
@@ -55,6 +57,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void createTable(String table) {
this.tables.put(table, new TableImpl());
}
@@ -62,6 +65,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void deleteTable(String table) {
this.tables.remove(table);
}
@@ -69,6 +73,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Set<String> getTablesNames() {
return this.tables.keySet();
}
@@ -76,6 +81,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void createColumn(String table, String column) {
this.tables.get(table).createColumn(column);
}
@@ -83,6 +89,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void deleteColumn(String table, String column) {
this.tables.get(table).deleteColumn(column);
}
@@ -90,6 +97,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Set<String> getColumnsNames(String table) {
return this.tables.get(table).getColumnsNames();
}
@@ -97,6 +105,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void put(String table, String column, String key, String content) {
this.tables.get(table).put(column, key, content);
}
@@ -104,6 +113,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String get(String table, String column, String key) {
return this.tables.get(table).get(column, key).toString();
}
@@ -111,6 +121,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String get(String table, String column, String key, int version) {
return this.tables.get(table).get(column, key, version).toString();
}
@@ -118,6 +129,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Map<String, String> getRow(String table, String key) {
Row row = this.tables.get(table).getRow(key);
@@ -135,8 +147,16 @@
/**
* {@inheritDoc}
*/
+ @Override
public Set<String> getKeys(String table) {
return this.tables.get(table).getKeys();
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getPluginName() {
+ return this.getClass().getSimpleName();
+ }
}
Modified: trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXML.java
===================================================================
--- trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXML.java 2010-03-02 11:13:24 UTC (rev 156)
+++ trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXML.java 2010-03-02 11:24:35 UTC (rev 157)
@@ -174,4 +174,12 @@
LOG.error(ex, ex);
}
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getPluginName() {
+ return this.getClass().getSimpleName();
+ }
}
Modified: trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXML.java
===================================================================
--- trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXML.java 2010-03-02 11:13:24 UTC (rev 156)
+++ trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXML.java 2010-03-02 11:24:35 UTC (rev 157)
@@ -7,11 +7,8 @@
import java.io.File;
import java.io.IOException;
import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jdom.Attribute;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
@@ -149,4 +146,12 @@
LOG.error(ex, ex);
}
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getPluginName() {
+ return this.getClass().getSimpleName();
+ }
}
Modified: trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/HBase.java
===================================================================
--- trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/HBase.java 2010-03-02 11:13:24 UTC (rev 156)
+++ trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/HBase.java 2010-03-02 11:24:35 UTC (rev 157)
@@ -68,6 +68,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean connect(Properties properties) {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -75,6 +76,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void createTable(String table) {
HTableDescriptor hTableDescriptor = new HTableDescriptor(table);
try {
@@ -88,6 +90,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void deleteTable(String table) {
try {
// to delete a table, we have to disable it.
@@ -102,6 +105,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Set<String> getTablesNames() {
Set<String> tablesNames = new HashSet<String>();
try {
@@ -121,6 +125,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void createColumn(String table, String column) {
HColumnDescriptor hColumnDescriptor = new HColumnDescriptor(column);
try {
@@ -134,6 +139,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void deleteColumn(String table, String column) {
try {
hBaseAdmin.deleteColumn(table, column);
@@ -146,6 +152,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Set<String> getColumnsNames(String table) {
Set<String> columnsNames = new HashSet<String>();
try {
@@ -179,6 +186,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void put(String table, String column, String key, String content) {
try {
Put put = new Put(key.getBytes());
@@ -199,6 +207,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String get(String table, String column, String key) {
String ret = "";
try {
@@ -224,6 +233,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String get(String table, String column, String key, int version) {
String ret = "";
try {
@@ -251,6 +261,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Map<String, String> getRow(String table, String key) {
Map<String, String> ret = new HashMap<String, String>();
try {
@@ -281,6 +292,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Set<String> getKeys(String table) {
Set<String> ret = new HashSet<String>();
try {
@@ -304,6 +316,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void selectTable(String table) {
try {
selectedTable = new HTable(config, table);
@@ -311,4 +324,12 @@
LOG.error(ex, ex);
}
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getPluginName() {
+ return this.getClass().getSimpleName();
+ }
}
1
0
Author: dlanglais
Date: 2010-03-02 12:13:24 +0100 (Tue, 02 Mar 2010)
New Revision: 156
Added:
trunk/DEADJOE
trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/HBase.java
trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/OLDHBase.java
trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/BigTable.java
Removed:
trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/HBase.java
trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/HBaseNewBigTable.java
trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/BigTable.java
trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/NewBigTable.java
trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/OurHashMap.java
Modified:
trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/BigHashMap.java
trunk/msm-bighashmapV2/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmapv2/BigHashMap.java
trunk/msm-fromtoXML/
trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXML.java
trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXML.java
trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXMLTest.java
trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLTest.java
trunk/msm-hbase/pom.xml
trunk/msm/src/main/java/org/nuiton/mapstoragemanager/core/BigTableLoader.java
trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/Exporter.java
trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/Importer.java
trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/OurHashMap2.java
trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/gui/ColumnModel.java
trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/gui/TableModel.java
trunk/msm/src/main/resources/i18n/msm-en_GB.properties
trunk/msm/src/main/resources/i18n/msm-fr_FR.properties
Log:
refactorisation NewBigTable -> BigTable, suppression interface BigTable
Added: trunk/DEADJOE
===================================================================
--- trunk/DEADJOE (rev 0)
+++ trunk/DEADJOE 2010-03-02 11:13:24 UTC (rev 156)
@@ -0,0 +1,32 @@
+
+*** Ces fichiers modifi�s �taient ouvert dans JOE quand il a quitt� le Tue Mar 2 12:03:47 2010
+*** JOE a quitt� suite � la fermeture du terminal
+
+*** Fichier '(Sans nom)'
+svn-commit.tmp
+svn-commit.tmp
+svn-commit.tmp
+svn-commit.tmp
+svn-commit.tmp
+svn-commit.tmp
+svn-commit.tmp
+svn-commit.tmp
+svn-commit.tmp
+svn-commit.2.tmp
+svn-commit.tmp
+
+*** Ces fichiers modifi�s �taient ouvert dans JOE quand il a quitt� le Tue Mar 2 12:11:05 2010
+*** JOE a quitt� suite � la fermeture du terminal
+
+*** Fichier '(Sans nom)'
+svn-commit.tmp
+svn-commit.tmp
+svn-commit.tmp
+svn-commit.tmp
+svn-commit.tmp
+svn-commit.tmp
+svn-commit.tmp
+svn-commit.tmp
+svn-commit.tmp
+svn-commit.2.tmp
+svn-commit.tmp
Modified: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/core/BigTableLoader.java
===================================================================
--- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/core/BigTableLoader.java 2010-03-02 11:01:50 UTC (rev 155)
+++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/core/BigTableLoader.java 2010-03-02 11:13:24 UTC (rev 156)
@@ -85,12 +85,12 @@
} else {
for (BigTable bt : bigTableSetLoader) {
s += bt.getClass().getName();
- bt.put("key", "value");
- if (bt.get("key").equals("value")) {
- s += " (working)" + "\n";
- } else {
- s += " (not working)" + "\n";
- }
+// bt.put("key", "value");
+// if (bt.get("key").equals("value")) {
+// s += " (working)" + "\n";
+// } else {
+// s += " (not working)" + "\n";
+// }
}
}
return s;
Deleted: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/BigTable.java
===================================================================
--- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/BigTable.java 2010-03-02 11:01:50 UTC (rev 155)
+++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/BigTable.java 2010-03-02 11:13:24 UTC (rev 156)
@@ -1,47 +0,0 @@
-package org.nuiton.mapstoragemanager.plugins;
-
-import java.util.Set;
-
-/**
- * The interface for all the BigTable implementations.
- * @author Crieloue Gilles
- *
- */
-public interface BigTable {
-
- /**
- * Connects to the database.
- * @param host the server
- * @param base the base name
- * @param username the user login
- * @param password the user password
- */
- void connect(String host, String base, String username, String password);
-
- /**
- * Selects the table.
- * @param table the table name
- */
- void selectTable(String table);
-
- /**
- * Get the value matching a key.
- * @param key the key
- * @return the value
- */
- String get(String key);
-
- /**
- * put a value matching the key.
- * @param key the key
- * @param value the value
- */
- void put(String key, String value);
-
- /**
- * Returns the keys set.
- * @return the keys set
- */
- Set < String > getKeys();
-
-}
Copied: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/BigTable.java (from rev 152, trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/NewBigTable.java)
===================================================================
--- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/BigTable.java (rev 0)
+++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/BigTable.java 2010-03-02 11:13:24 UTC (rev 156)
@@ -0,0 +1,127 @@
+package org.nuiton.mapstoragemanager.plugins;
+
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * The interface for all the BigTable implementations.
+ * @author Dorian Langlais
+ */
+public interface BigTable {
+
+ /**
+ * Connects to the database.
+ * @param properties the properties to initialize the connection.
+ * @return return true if connexion is established, else return false.
+ */
+ boolean connect(Properties properties);
+
+ /******************
+ * Tables *
+ ******************/
+ /**
+ * Selects the table.
+ * @param table the table to select
+ */
+ void selectTable(String table);
+
+ /**
+ * Create a new table in the base.
+ * @param table the name of the new table
+ */
+ void createTable(String table);
+
+ /**
+ * Delete a table in the base.
+ * @param table the table of the table to delete
+ */
+ void deleteTable(String table);
+
+ /**
+ * Get the tables' name which are in the base.
+ * @return Return a set containing the tables' name
+ */
+ Set<String> getTablesNames();
+
+ /*******************
+ * Columns *
+ *******************/
+ /**
+ * Create a new column in a table.
+ * Add a column <b>column</b> in the table <b>table</b>
+ * @param table the table name
+ * @param column the column name
+ */
+ void createColumn(String table, String column);
+
+ /**
+ * Delete a column in a table.
+ * Delete the column <b>column</b> in the table <b>table</b>
+ * @param table the table name
+ * @param column the column name
+ */
+ void deleteColumn(String table, String column);
+
+ /**
+ * Get the columns' name of one table.
+ * @param table the table name
+ * @return Return a set containing the columns' name of the table
+ * <b>table</b>
+ */
+ Set<String> getColumnsNames(String table);
+
+ /***************
+ * Cell *
+ ***************/
+ /**
+ * Put a new content in the table.
+ * Put a new <b>content</b> in the column <b>column</b> of the table
+ * <b>table</b> with the key <b>key</b>.
+ * @param table the table name
+ * @param column the column name
+ * @param key the key
+ * @param content the content to add
+ */
+ void put(String table, String column, String key, String content);
+
+ /**
+ * Get a content in the table.
+ * Get a content in the table <b>table</b> from the column <b>column</b>
+ * where the key is <b>key</b>.
+ * -> get the last value (with the greater timestamp).
+ * @param table the table name.
+ * @param column the column name.
+ * @param key the key
+ * @return the content
+ */
+ String get(String table, String column, String key);
+
+ /**
+ * Get a content in the table.
+ * Get a content in the table <b>table</b> from the column <b>column</b>
+ * where the key is <b>key</b>.
+ * -> get the content with the version <b>version</b>.
+ * @param table the table name.
+ * @param column the column name.
+ * @param key the key
+ * @param version
+ * @return the content
+ */
+ String get(String table, String column, String key, int version);
+
+ /**
+ * Get the row identified by the key <b>key<b> from the table <b>table</b>
+ * @param table the table name
+ * @param key the key
+ * @return a Map with key is column's name and value is content's value.
+ */
+ Map<String, String> getRow(String table, String key);
+
+ /**
+ * Get the keys from a table.
+ * @param table the table
+ * @return return a Set containing the keys a the table <b>table</b>.
+ */
+ Set<String> getKeys(String table);
+}
Property changes on: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/BigTable.java
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/Exporter.java
===================================================================
--- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/Exporter.java 2010-03-02 11:01:50 UTC (rev 155)
+++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/Exporter.java 2010-03-02 11:13:24 UTC (rev 156)
@@ -13,5 +13,5 @@
* @param bigTable the bigTable plugin.
* @param file the file in which export the content of the base.
*/
- void exportTo (final NewBigTable bigTable, final File file);
+ void exportTo (final BigTable bigTable, final File file);
}
\ No newline at end of file
Modified: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/Importer.java
===================================================================
--- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/Importer.java 2010-03-02 11:01:50 UTC (rev 155)
+++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/Importer.java 2010-03-02 11:13:24 UTC (rev 156)
@@ -13,5 +13,5 @@
* @param bigTable the bigTable plugin.
* @param file the file in which export the content of the base.
*/
- void importFrom (final NewBigTable bigTable, final File file);
+ void importFrom (final BigTable bigTable, final File file);
}
\ No newline at end of file
Deleted: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/NewBigTable.java
===================================================================
--- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/NewBigTable.java 2010-03-02 11:01:50 UTC (rev 155)
+++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/NewBigTable.java 2010-03-02 11:13:24 UTC (rev 156)
@@ -1,127 +0,0 @@
-package org.nuiton.mapstoragemanager.plugins;
-
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-/**
- * The interface for all the BigTable implementations.
- * @author Dorian Langlais
- */
-public interface NewBigTable {
-
- /**
- * Connects to the database.
- * @param properties the properties to initialize the connection.
- * @return return true if connexion is established, else return false.
- */
- boolean connect(Properties properties);
-
- /******************
- * Tables *
- ******************/
- /**
- * Selects the table.
- * @param table the table to select
- */
- void selectTable(String table);
-
- /**
- * Create a new table in the base.
- * @param table the name of the new table
- */
- void createTable(String table);
-
- /**
- * Delete a table in the base.
- * @param table the table of the table to delete
- */
- void deleteTable(String table);
-
- /**
- * Get the tables' name which are in the base.
- * @return Return a set containing the tables' name
- */
- Set<String> getTablesNames();
-
- /*******************
- * Columns *
- *******************/
- /**
- * Create a new column in a table.
- * Add a column <b>column</b> in the table <b>table</b>
- * @param table the table name
- * @param column the column name
- */
- void createColumn(String table, String column);
-
- /**
- * Delete a column in a table.
- * Delete the column <b>column</b> in the table <b>table</b>
- * @param table the table name
- * @param column the column name
- */
- void deleteColumn(String table, String column);
-
- /**
- * Get the columns' name of one table.
- * @param table the table name
- * @return Return a set containing the columns' name of the table
- * <b>table</b>
- */
- Set<String> getColumnsNames(String table);
-
- /***************
- * Cell *
- ***************/
- /**
- * Put a new content in the table.
- * Put a new <b>content</b> in the column <b>column</b> of the table
- * <b>table</b> with the key <b>key</b>.
- * @param table the table name
- * @param column the column name
- * @param key the key
- * @param content the content to add
- */
- void put(String table, String column, String key, String content);
-
- /**
- * Get a content in the table.
- * Get a content in the table <b>table</b> from the column <b>column</b>
- * where the key is <b>key</b>.
- * -> get the last value (with the greater timestamp).
- * @param table the table name.
- * @param column the column name.
- * @param key the key
- * @return the content
- */
- String get(String table, String column, String key);
-
- /**
- * Get a content in the table.
- * Get a content in the table <b>table</b> from the column <b>column</b>
- * where the key is <b>key</b>.
- * -> get the content with the version <b>version</b>.
- * @param table the table name.
- * @param column the column name.
- * @param key the key
- * @param version
- * @return the content
- */
- String get(String table, String column, String key, int version);
-
- /**
- * Get the row identified by the key <b>key<b> from the table <b>table</b>
- * @param table the table name
- * @param key the key
- * @return a Map with key is column's name and value is content's value.
- */
- Map<String, String> getRow(String table, String key);
-
- /**
- * Get the keys from a table.
- * @param table the table
- * @return return a Set containing the keys a the table <b>table</b>.
- */
- Set<String> getKeys(String table);
-}
Deleted: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/OurHashMap.java
===================================================================
--- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/OurHashMap.java 2010-03-02 11:01:50 UTC (rev 155)
+++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/OurHashMap.java 2010-03-02 11:13:24 UTC (rev 156)
@@ -1,31 +0,0 @@
-package org.nuiton.mapstoragemanager.plugins;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-public class OurHashMap implements BigTable {
-
- private Map<String, String> map = new HashMap<String, String>();
-
- public String get(String key) {
- return map.get(key);
- }
-
- public Set<String> getKeys() {
- return map.keySet();
- }
-
- public void put(String key, String value) {
- map.put(key, value);
- }
-
- public void connect(String host, String base, String username,
- String password) {
- // TODO Auto-generated method stub
- }
-
- public void selectTable(String table) {
- // TODO Auto-generated method stub
- }
-}
Modified: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/OurHashMap2.java
===================================================================
--- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/OurHashMap2.java 2010-03-02 11:01:50 UTC (rev 155)
+++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/OurHashMap2.java 2010-03-02 11:13:24 UTC (rev 156)
@@ -8,7 +8,7 @@
import java.util.Properties;
import java.util.Set;
-public class OurHashMap2 implements NewBigTable {
+public class OurHashMap2 implements BigTable {
private Map<String, ArrayList<String>> mapTable = new HashMap<String,ArrayList<String>>();
private Map<String, ArrayList<String>> mapColumn = new HashMap<String, ArrayList<String>>();
Modified: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/gui/ColumnModel.java
===================================================================
--- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/gui/ColumnModel.java 2010-03-02 11:01:50 UTC (rev 155)
+++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/gui/ColumnModel.java 2010-03-02 11:13:24 UTC (rev 156)
@@ -6,6 +6,7 @@
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;
import org.nuiton.mapstoragemanager.plugins.OurHashMap2;
+import static org.nuiton.i18n.I18n._;
/**
* Model of a table content
@@ -33,8 +34,8 @@
ApplicationEngine engine = ApplicationEngine.getInstance();
OurHashMap2 testHashmap2 = engine.getOurHashMap();
titres = new String[2];
- titres[0]="Key";
- titres[1]="Value";
+ titres[0] = _("table.keys");
+ titres[1] = _("table.values");
//content
Set<String> keySetTable = testHashmap2.getKeys(table,column);
Modified: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/gui/TableModel.java
===================================================================
--- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/gui/TableModel.java 2010-03-02 11:01:50 UTC (rev 155)
+++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/gui/TableModel.java 2010-03-02 11:13:24 UTC (rev 156)
@@ -5,6 +5,7 @@
import javax.swing.table.AbstractTableModel;
import javax.swing.tree.DefaultMutableTreeNode;
import org.nuiton.mapstoragemanager.plugins.OurHashMap2;
+import static org.nuiton.i18n.I18n._;
/**
* Model of a table content
@@ -50,7 +51,7 @@
if(showTableKeys) {
titles = new String[columnsNames.size() + 1];
- titles[0] = "Keys";
+ titles[0] = _("table.keys");
data = new String[columnsNames.size() + 1][keySetTable.size()];
colIndex++;
} else {
Modified: trunk/msm/src/main/resources/i18n/msm-en_GB.properties
===================================================================
--- trunk/msm/src/main/resources/i18n/msm-en_GB.properties 2010-03-02 11:01:50 UTC (rev 155)
+++ trunk/msm/src/main/resources/i18n/msm-en_GB.properties 2010-03-02 11:13:24 UTC (rev 156)
@@ -1,39 +1,41 @@
-Empty=
-Map\ Storage\ Manager=Map Storage Manager
-No\ help\ today,\ sorry\ \!=No help today, sorry \!
-connectionError=The connection attempt to failed, please retry \!
-jaxxdemo.message.goto.site=Visit site
-jaxxdemo.tree.component=
-keys=
-login\ \:=Login
-mapstoragemanager.action.aboutUs=About us
-mapstoragemanager.action.aboutUs.tip=About Code Lutin
-mapstoragemanager.action.connect=Connect
-mapstoragemanager.action.connect.tip=Start a new connection
-mapstoragemanager.action.disconnect=Disconnect
-mapstoragemanager.action.disconnect.tip=Disconnect the current session
-mapstoragemanager.action.edit=Edit
-mapstoragemanager.action.edit.tip=
-mapstoragemanager.action.exit=Exit
-mapstoragemanager.action.exit.tip=
-mapstoragemanager.action.file=File
-mapstoragemanager.action.file.tip=
-mapstoragemanager.action.fr=French
-mapstoragemanager.action.fr.tip=Change to french language
-mapstoragemanager.action.help=Help
-mapstoragemanager.action.help.tip=
-mapstoragemanager.action.language=Choose language
-mapstoragemanager.action.language.tip=
-mapstoragemanager.action.menuHelp=Help
-mapstoragemanager.action.menuHelp.tip=
-mapstoragemanager.action.preferences=Preferences
-mapstoragemanager.action.preferences.tip=
-mapstoragemanager.action.uk=English
-mapstoragemanager.action.uk.tip=Change to english language
-mapstoragemanager.action.visitSite=Visit our site
-mapstoragemanager.action.visitSite.tip=
-messageEntry=Welcome to MapStorageManager
-name\ base\ \:=Name base
-ok=Validate
-password\ \:=Password
-welcome.MapStorageManager=Welcome to MapStorageManager
+Empty=
+Map\ Storage\ Manager=Map Storage Manager
+No\ help\ today,\ sorry\ \!=No help today, sorry \!
+connectionError=The connection attempt to failed, please retry \!
+jaxxdemo.message.goto.site=Visit site
+jaxxdemo.tree.component=
+keys=
+login\ \:=Login
+mapstoragemanager.action.aboutUs=About us
+mapstoragemanager.action.aboutUs.tip=About Code Lutin
+mapstoragemanager.action.connect=Connect
+mapstoragemanager.action.connect.tip=Start a new connection
+mapstoragemanager.action.disconnect=Disconnect
+mapstoragemanager.action.disconnect.tip=Disconnect the current session
+mapstoragemanager.action.edit=Edit
+mapstoragemanager.action.edit.tip=
+mapstoragemanager.action.exit=Exit
+mapstoragemanager.action.exit.tip=
+mapstoragemanager.action.file=File
+mapstoragemanager.action.file.tip=
+mapstoragemanager.action.fr=French
+mapstoragemanager.action.fr.tip=Change to french language
+mapstoragemanager.action.help=Help
+mapstoragemanager.action.help.tip=
+mapstoragemanager.action.language=Choose language
+mapstoragemanager.action.language.tip=
+mapstoragemanager.action.menuHelp=Help
+mapstoragemanager.action.menuHelp.tip=
+mapstoragemanager.action.preferences=Preferences
+mapstoragemanager.action.preferences.tip=
+mapstoragemanager.action.uk=English
+mapstoragemanager.action.uk.tip=Change to english language
+mapstoragemanager.action.visitSite=Visit our site
+mapstoragemanager.action.visitSite.tip=
+messageEntry=Welcome to MapStorageManager
+name\ base\ \:=Name base
+ok=Validate
+password\ \:=Password
+table.keys=Keys
+table.values=Values
+welcome.MapStorageManager=Welcome to MapStorageManager
Modified: trunk/msm/src/main/resources/i18n/msm-fr_FR.properties
===================================================================
--- trunk/msm/src/main/resources/i18n/msm-fr_FR.properties 2010-03-02 11:01:50 UTC (rev 155)
+++ trunk/msm/src/main/resources/i18n/msm-fr_FR.properties 2010-03-02 11:13:24 UTC (rev 156)
@@ -1,39 +1,41 @@
-Empty=Vide
-Map\ Storage\ Manager=Map Storage Manager
-No\ help\ today,\ sorry\ \!=Pas d'aide pour l'instant, d\u00E9sol\u00E9 \!
-connectionError=La connexion \u00E0 \u00E9chou\u00E9e, r\u00E9essayez s'il vous pla\u00EEt \!
-jaxxdemo.message.goto.site=Visitez le site
-jaxxdemo.tree.component=
-keys=
-login\ \:=Identifiant
-mapstoragemanager.action.aboutUs=A propos
-mapstoragemanager.action.aboutUs.tip=A propos de Code Lutin
-mapstoragemanager.action.connect=Connexion
-mapstoragemanager.action.connect.tip=Etablis une nouvelle connexion
-mapstoragemanager.action.disconnect=D\u00E9connexion
-mapstoragemanager.action.disconnect.tip=D\u00E9connecte la session courante
-mapstoragemanager.action.edit=Edition
-mapstoragemanager.action.edit.tip=
-mapstoragemanager.action.exit=Quitter
-mapstoragemanager.action.exit.tip=Quitte l'application
-mapstoragemanager.action.file=Fichier
-mapstoragemanager.action.file.tip=
-mapstoragemanager.action.fr=Fran\u00E7ais
-mapstoragemanager.action.fr.tip=Changer la langue en fran\u00E7ais
-mapstoragemanager.action.help=Aide
-mapstoragemanager.action.help.tip=
-mapstoragemanager.action.language=choisir la langue
-mapstoragemanager.action.language.tip=
-mapstoragemanager.action.menuHelp=Aide
-mapstoragemanager.action.menuHelp.tip=Aide contextuelle
-mapstoragemanager.action.preferences=Pr\u00E9f\u00E9rences
-mapstoragemanager.action.preferences.tip=Permet de configurer l'application
-mapstoragemanager.action.uk=Anglais
-mapstoragemanager.action.uk.tip=Changer la langue en anglais
-mapstoragemanager.action.visitSite=Visiter notre site
-mapstoragemanager.action.visitSite.tip=
-messageEntry=Bienvenue dans MapStorageManager
-name\ base\ \:=Nom de la base
-ok=Valider
-password\ \:=Mot de passe
-welcome.MapStorageManager=Bienvenue dans MapStorageManager
+Empty=Vide
+Map\ Storage\ Manager=Map Storage Manager
+No\ help\ today,\ sorry\ \!=Pas d'aide pour l'instant, d\u00E9sol\u00E9 \!
+connectionError=La connexion \u00E0 \u00E9chou\u00E9e, r\u00E9essayez s'il vous pla\u00EEt \!
+jaxxdemo.message.goto.site=Visitez le site
+jaxxdemo.tree.component=
+keys=
+login\ \:=Identifiant
+mapstoragemanager.action.aboutUs=A propos
+mapstoragemanager.action.aboutUs.tip=A propos de Code Lutin
+mapstoragemanager.action.connect=Connexion
+mapstoragemanager.action.connect.tip=Etablis une nouvelle connexion
+mapstoragemanager.action.disconnect=D\u00E9connexion
+mapstoragemanager.action.disconnect.tip=D\u00E9connecte la session courante
+mapstoragemanager.action.edit=Edition
+mapstoragemanager.action.edit.tip=
+mapstoragemanager.action.exit=Quitter
+mapstoragemanager.action.exit.tip=Quitte l'application
+mapstoragemanager.action.file=Fichier
+mapstoragemanager.action.file.tip=
+mapstoragemanager.action.fr=Fran\u00E7ais
+mapstoragemanager.action.fr.tip=Changer la langue en fran\u00E7ais
+mapstoragemanager.action.help=Aide
+mapstoragemanager.action.help.tip=
+mapstoragemanager.action.language=choisir la langue
+mapstoragemanager.action.language.tip=
+mapstoragemanager.action.menuHelp=Aide
+mapstoragemanager.action.menuHelp.tip=Aide contextuelle
+mapstoragemanager.action.preferences=Pr\u00E9f\u00E9rences
+mapstoragemanager.action.preferences.tip=Permet de configurer l'application
+mapstoragemanager.action.uk=Anglais
+mapstoragemanager.action.uk.tip=Changer la langue en anglais
+mapstoragemanager.action.visitSite=Visiter notre site
+mapstoragemanager.action.visitSite.tip=
+messageEntry=Bienvenue dans MapStorageManager
+name\ base\ \:=Nom de la base
+ok=Valider
+password\ \:=Mot de passe
+table.keys=Cl\u00E9s
+table.values=Valeurs
+welcome.MapStorageManager=Bienvenue dans MapStorageManager
Modified: trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/BigHashMap.java
===================================================================
--- trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/BigHashMap.java 2010-03-02 11:01:50 UTC (rev 155)
+++ trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/BigHashMap.java 2010-03-02 11:13:24 UTC (rev 156)
@@ -4,14 +4,14 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import org.nuiton.mapstoragemanager.plugins.NewBigTable;
+import org.nuiton.mapstoragemanager.plugins.BigTable;
/**
* Interface listant les méthodes nécéssaires sur une base de données.
* @author Dorian Langlais
*
*/
-public class BigHashMap implements NewBigTable {
+public class BigHashMap implements BigTable {
/**
* tables.
Modified: trunk/msm-bighashmapV2/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmapv2/BigHashMap.java
===================================================================
--- trunk/msm-bighashmapV2/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmapv2/BigHashMap.java 2010-03-02 11:01:50 UTC (rev 155)
+++ trunk/msm-bighashmapV2/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmapv2/BigHashMap.java 2010-03-02 11:13:24 UTC (rev 156)
@@ -4,14 +4,14 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import org.nuiton.mapstoragemanager.plugins.NewBigTable;
+import org.nuiton.mapstoragemanager.plugins.BigTable;
/**
* Interface listant les méthodes nécéssaires sur une base de données.
* @author Dorian Langlais
*
*/
-public class BigHashMap implements NewBigTable {
+public class BigHashMap implements BigTable {
/**
* tables.
Property changes on: trunk/msm-fromtoXML
___________________________________________________________________
Added: svn:ignore
+ target
Modified: trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXML.java
===================================================================
--- trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXML.java 2010-03-02 11:01:50 UTC (rev 155)
+++ trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXML.java 2010-03-02 11:13:24 UTC (rev 156)
@@ -17,7 +17,7 @@
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
import org.nuiton.mapstoragemanager.plugins.Exporter;
-import org.nuiton.mapstoragemanager.plugins.NewBigTable;
+import org.nuiton.mapstoragemanager.plugins.BigTable;
/**
* A Class to export in xml files the content of Hbase database.
@@ -38,7 +38,7 @@
* {@inheritDoc}
*/
@Override
- public void exportTo(NewBigTable bigTable, File file) {
+ public void exportTo(BigTable bigTable, File file) {
Element database = new Element("database");
document = new Document(database);
@@ -56,7 +56,7 @@
* @param bigTable the bigTable.
* @param database the database Element.
*/
- private void forEachTable(final NewBigTable bigTable, Element database) {
+ private void forEachTable(final BigTable bigTable, Element database) {
// the tables name.
Set<String> tablesNames = bigTable.getTablesNames();
@@ -80,7 +80,7 @@
* @param bigTable the bigTable.
* @param table the table Element.
*/
- private void forEachColumn(final NewBigTable bigTable, Element table) {
+ private void forEachColumn(final BigTable bigTable, Element table) {
// the table name.
String tableName = table.getAttributeValue("tableName");
@@ -107,7 +107,7 @@
* @param bigTable the bigTable.
* @param column the column Element.
*/
- private void forEachCell(final NewBigTable bigTable, Element column) {
+ private void forEachCell(final BigTable bigTable, Element column) {
// the table name.
String tableName =
column.getParentElement().getAttributeValue("tableName");
Modified: trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXML.java
===================================================================
--- trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXML.java 2010-03-02 11:01:50 UTC (rev 155)
+++ trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXML.java 2010-03-02 11:13:24 UTC (rev 156)
@@ -19,7 +19,7 @@
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
import org.nuiton.mapstoragemanager.plugins.Importer;
-import org.nuiton.mapstoragemanager.plugins.NewBigTable;
+import org.nuiton.mapstoragemanager.plugins.BigTable;
/**
*
@@ -40,7 +40,7 @@
* {@inheritDoc}
*/
@Override
- public void importFrom(NewBigTable bigTable, File file) {
+ public void importFrom(BigTable bigTable, File file) {
try {
open(file);
@@ -61,7 +61,7 @@
* @param bigTable the bigTable.
* @param database the database Element.
*/
- private void forEachTable(NewBigTable bigTable, final Element database) {
+ private void forEachTable(BigTable bigTable, final Element database) {
// the table elements.
List<Element> tables = database.getChildren("table");
@@ -80,7 +80,7 @@
* @param bigTable the bigTable.
* @param table the table Element.
*/
- private void forEachColumn(NewBigTable bigTable, final Element table) {
+ private void forEachColumn(BigTable bigTable, final Element table) {
// the table name.
String tableName = table.getAttributeValue("tableName");
@@ -102,7 +102,7 @@
* @param bigTable the bigTable.
* @param column the column Element.
*/
- private void forEachCell(NewBigTable bigTable, final Element column) {
+ private void forEachCell(BigTable bigTable, final Element column) {
// the table name.
String tableName =
column.getParentElement().getAttributeValue("tableName");
Modified: trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXMLTest.java
===================================================================
--- trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXMLTest.java 2010-03-02 11:01:50 UTC (rev 155)
+++ trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXMLTest.java 2010-03-02 11:13:24 UTC (rev 156)
@@ -17,7 +17,7 @@
//import org.jdom.output.Format;
//import org.jdom.output.XMLOutputter;
import org.nuiton.mapstoragemanager.plugins.Exporter;
-import org.nuiton.mapstoragemanager.plugins.NewBigTable;
+import org.nuiton.mapstoragemanager.plugins.BigTable;
import org.nuiton.mapstoragemanager.plugins.AssertJdomElement;
import org.nuiton.mapstoragemanager.plugins.bighashmapv2.BigHashMap;
import org.nuiton.mapstoragemanager.plugins.getFile;
@@ -62,7 +62,7 @@
/********************************
* Creation of the database. *
********************************/
- NewBigTable nbt = new BigHashMap();
+ BigTable nbt = new BigHashMap();
Element database = new Element("database");
expected.addContent(database);
@@ -252,33 +252,33 @@
* @param args args.
*/
public static void main(String[] args) {
- NewBigTable nbt = new BigHashMap();
- nbt.createTable("table1");
- nbt.createTable("table2");
+ BigTable bt = new BigHashMap();
+ bt.createTable("table1");
+ bt.createTable("table2");
- nbt.createColumn("table1", "column1");
- nbt.createColumn("table1", "column2");
+ bt.createColumn("table1", "column1");
+ bt.createColumn("table1", "column2");
- nbt.createColumn("table2", "column3");
- nbt.createColumn("table2", "column4");
- nbt.createColumn("table2", "column5");
+ bt.createColumn("table2", "column3");
+ bt.createColumn("table2", "column4");
+ bt.createColumn("table2", "column5");
- nbt.put("table1", "column1", "1", "content1");
- nbt.put("table1", "column1", "2", "content2");
- nbt.put("table1", "column2", "3", "content3");
- nbt.put("table1", "column2", "4", "content4");
+ bt.put("table1", "column1", "1", "content1");
+ bt.put("table1", "column1", "2", "content2");
+ bt.put("table1", "column2", "3", "content3");
+ bt.put("table1", "column2", "4", "content4");
- nbt.put("table2", "column3", "5", "content5");
- nbt.put("table2", "column3", "6", "content6");
- nbt.put("table2", "column4", "7", "content7");
- nbt.put("table2", "column4", "8", "content8");
- nbt.put("table2", "column5", "9", "content9");
- nbt.put("table2", "column5", "10", "content10");
+ bt.put("table2", "column3", "5", "content5");
+ bt.put("table2", "column3", "6", "content6");
+ bt.put("table2", "column4", "7", "content7");
+ bt.put("table2", "column4", "8", "content8");
+ bt.put("table2", "column5", "9", "content9");
+ bt.put("table2", "column5", "10", "content10");
Exporter exporter = new ToXML();
File exportTest =
getFile.getTestFile("/src/test/resources/exportTest.xml");
- exporter.exportTo(nbt,exportTest);
+ exporter.exportTo(bt,exportTest);
exportTest.delete();
}
}
Modified: trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLTest.java
===================================================================
--- trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLTest.java 2010-03-02 11:01:50 UTC (rev 155)
+++ trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLTest.java 2010-03-02 11:13:24 UTC (rev 156)
@@ -15,7 +15,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.mapstoragemanager.plugins.Importer;
-import org.nuiton.mapstoragemanager.plugins.NewBigTable;
+import org.nuiton.mapstoragemanager.plugins.BigTable;
import org.nuiton.mapstoragemanager.plugins.bighashmapv2.BigHashMap;
import org.nuiton.mapstoragemanager.plugins.getFile;
@@ -45,7 +45,7 @@
// import fiveTables.
Importer importer = new FromXML();
- NewBigTable bigTable = new BigHashMap();
+ BigTable bigTable = new BigHashMap();
importer.importFrom(bigTable, fiveTables);
@@ -86,7 +86,7 @@
// import fiveTables.
Importer importer = new FromXML();
- NewBigTable bigTable = new BigHashMap();
+ BigTable bigTable = new BigHashMap();
importer.importFrom(bigTable, twoTablesFiveColumns);
@@ -143,7 +143,7 @@
// import fiveTables.
Importer importer = new FromXML();
- NewBigTable bigTable = new BigHashMap();
+ BigTable bigTable = new BigHashMap();
importer.importFrom(bigTable, twoTablesFiveColumns);
Modified: trunk/msm-hbase/pom.xml
===================================================================
--- trunk/msm-hbase/pom.xml 2010-03-02 11:01:50 UTC (rev 155)
+++ trunk/msm-hbase/pom.xml 2010-03-02 11:13:24 UTC (rev 156)
@@ -199,6 +199,15 @@
<packaging>jar</packaging>
<build>
+
+ <resources>
+ <resource>
+ <directory>src/main/java/org/nuiton/mapstoragemanager/plugins/hbase</directory>
+ <excludes>
+ <exclude>OLDHBase.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
<!--<plugins>
Deleted: trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/HBase.java
===================================================================
--- trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/HBase.java 2010-03-02 11:01:50 UTC (rev 155)
+++ trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/HBase.java 2010-03-02 11:13:24 UTC (rev 156)
@@ -1,176 +0,0 @@
-package org.nuiton.mapstoragemanager.plugins.hbase;
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.mapstoragemanager.plugins.BigTable;
-
-import org.apache.hadoop.hbase.HBaseConfiguration;
-//import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.client.ResultScanner;
-import org.apache.hadoop.hbase.client.Scan;
-import org.apache.hadoop.hbase.util.Bytes;
-
-public class HBase implements BigTable {
-
- /**
- * Logger.
- */
- private static final Log LOG = LogFactory.getLog(HBase.class);
-
- private HBaseConfiguration config;
- private HTable table;
- private String familyName = "mylittlecolumnfamily";
- private String rowName = "myLittleRow";
- private String tableName = "mylittletable";
-
- public HBase() {
- // You need a configuration object to tell the client where to connect.
- // When you create a HBaseConfiguration, it reads in whatever you've set
- // into your hbase-site.xml and in hbase-default.xml, as long as these can
- // be found on the CLASSPATH
- org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration();
- config = new HBaseConfiguration(conf);
- LOG.info("test");
- selectTable(tableName);
- put("test", "val");
- put("test", "val2");
- put("test2", "val3");
- }
-
- @Override
- public void put(String key, String value) {
-
- // To add to a row, use Put. A Put constructor takes the name of the row
- // you want to insert into as a byte array. In HBase, the Bytes class has
- // utility for converting all kinds of java types to byte arrays. In the
- // below, we are converting the String "myLittleRow" into a byte array to
- // use as a row key for our update. Once you have a Put instance, you can
- // adorn it by setting the names of columns you want to update on the row,
- // the timestamp to use in your update, etc.If no timestamp, the server
- // applies current time to the edits.
- Put p = new Put(Bytes.toBytes(rowName));
-
- // To set the value you'd like to update in the row 'myRow', specify the
- // column family, column qualifier, and value of the table cell you'd like
- // to update. The column family must already exist in your table schema.
- // The qualifier can be anything. All must be specified as byte arrays as
- // hbase is all about byte arrays. Lets pretend the table
- // 'myLittleHBaseTable' was created with a family 'myLittleFamily'.
- p.add(Bytes.toBytes(familyName), Bytes.toBytes(key),
- Bytes.toBytes(value));
-
- // Once you've adorned your Put instance with all the updates you want to
- // make, to commit it do the following (The HTable#put method takes the
- // Put instance you've been building and pushes the changes you made into
- // hbase)
-
- /*try {
- table.put(p);
- } catch (IOException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- */
- }
-
- @Override
- public String get(String key) {
-
- // Now, to retrieve the data we just wrote. The values that come back are
- // Result instances. Generally, a Result is an object that will package up
- // the hbase return into the form you find most palatable.
- /**Get g = new Get(Bytes.toBytes(rowName));
- Result r;*/
- byte[] value = null;
-// try {
-// r = table.get(g);
-// value = r.getValue(Bytes.toBytes(familyName),
-// Bytes.toBytes(key));
-// } catch (IOException e) {
-// e.printStackTrace();
-// }
-
- // If we convert the value bytes, we should get back 'Some Value', the
- // value we inserted at this location.
- /**String valueStr = Bytes.toString(value);*/
-
- return "valeur";
- //return valueStr;
- }
-
- @Override
- public Set<String> getKeys() {
-
- Set<String> keySet = new HashSet<String>();
-
- // Sometimes, you won't know the row you're looking for. In this case, you
- // use a Scanner. This will give you cursor-like interface to the contents
- // of the table. To set up a Scanner, do like you did above making a Put
- // and a Get, create a Scan. Adorn it with column names, etc.
- Scan s = new Scan();
- //s.addColumn(Bytes.toBytes(familyName), Bytes.toBytes("test"));
- ResultScanner scanner = null;
- try {
- scanner = table.getScanner(s);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- //e.printStackTrace();
- LOG.error(e.toString(), e);
- }
- try {
- // Scanners return Result instances.
- // Now, for the actual iteration. One way is to use a while loop like so:
- try {
- for (Result rr = scanner.next(); rr != null; rr = scanner.next()) {
- // print out the row we found and the columns we were looking for
- //System.out.println("Found row: " + rr);
- LOG.info("Found row: " + rr);
- keySet.add(rr.toString());
- }
-
- } catch (IOException e) {
- // TODO Auto-generated catch block
- //e.printStackTrace();
- LOG.error(e.toString(), e);
- }
-
- // The other approach is to use a foreach loop. Scanners are iterable!
- // for (Result rr : scanner) {
- // System.out.println("Found row: " + rr);
- // }
- } finally {
- // Make sure you close your scanners when you are done!
- // Thats why we have it inside a try/finally clause
- scanner.close();
- }
-
- return keySet;
- }
-
- public void selectTable(String tableName) {
- // This instantiates an HTable object that connects you to
- // the "myLittleHBaseTable" table.
- try {
- table = new HTable(config, tableName);
- } catch (IOException e) {
- //e.printStackTrace();
- LOG.error(e.toString(), e);
- }
- }
-
- @Override
- public void connect(String host, String base, String username,
- String password) {
- // TODO Auto-generated method stub
- }
-
- public static void main(String[] args) {
- /**HBase h = */new HBase();
- }
-}
Copied: trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/HBase.java (from rev 152, trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/HBaseNewBigTable.java)
===================================================================
--- trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/HBase.java (rev 0)
+++ trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/HBase.java 2010-03-02 11:13:24 UTC (rev 156)
@@ -0,0 +1,314 @@
+package org.nuiton.mapstoragemanager.plugins.hbase;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hbase.MasterNotRunningException;
+import org.nuiton.mapstoragemanager.plugins.BigTable;
+
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.HBaseAdmin;
+import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Result;
+
+/**
+ * A plugin for MSM using HBase API.
+ * @author Dorian Langlais
+ */
+public class HBase implements BigTable {
+
+ /**
+ * Logger.
+ */
+ private static final Log LOG = LogFactory.getLog(HBase.class);
+
+ /**
+ * HBaseAdmin.
+ * Permit to manage the HBase.
+ */
+ private HBaseAdmin hBaseAdmin;
+ /**
+ * HBaseConfiguration.
+ * Contains the configuration to connect to the HBase.
+ */
+ private HBaseConfiguration config;
+ /**
+ * The selected Table.
+ */
+ private HTable selectedTable;
+// private HTable table;
+// private String familyName = "mylittlecolumnfamily";
+// private String rowName = "myLittleRow";
+// private String tableName = "mylittletable";
+
+ /**
+ * HBase plugin Constructor.
+ * @throws MasterNotRunningException
+ */
+ public HBase() throws MasterNotRunningException {
+ // You need a configuration object to tell the client where to connect.
+ // When you create a HBaseConfiguration, it reads in whatever you've set
+ // into your hbase-site.xml and in hbase-default.xml, as long as these can
+ // be found on the CLASSPATH
+ org.apache.hadoop.conf.Configuration conf =
+ new org.apache.hadoop.conf.Configuration();
+ config = new HBaseConfiguration(conf);
+ hBaseAdmin = new HBaseAdmin(config);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean connect(Properties properties) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void createTable(String table) {
+ HTableDescriptor hTableDescriptor = new HTableDescriptor(table);
+ try {
+ hBaseAdmin.createTable(hTableDescriptor);
+ LOG.trace("table " + table + " created.");
+ } catch (IOException ex) {
+ LOG.error(ex, ex);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void deleteTable(String table) {
+ try {
+ // to delete a table, we have to disable it.
+ hBaseAdmin.disableTable(table);
+ hBaseAdmin.deleteTable(table);
+ LOG.trace("table " + table + " deleted.");
+ } catch (IOException ex) {
+ LOG.error(ex, ex);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set<String> getTablesNames() {
+ Set<String> tablesNames = new HashSet<String>();
+ try {
+ HTableDescriptor[] hTablesDescriptor;
+ hTablesDescriptor = hBaseAdmin.listTables();
+
+ for (int i = 0 ; i < hTablesDescriptor.length ; i++) {
+ tablesNames.add(hTablesDescriptor[i].getNameAsString());
+ }
+
+ } catch (IOException ex) {
+ LOG.error(ex, ex);
+ }
+ return tablesNames;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void createColumn(String table, String column) {
+ HColumnDescriptor hColumnDescriptor = new HColumnDescriptor(column);
+ try {
+ hBaseAdmin.addColumn(table, hColumnDescriptor);
+ LOG.trace("colum " + column + " created in table " + table + ".");
+ } catch (IOException ex) {
+ LOG.error(ex, ex);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void deleteColumn(String table, String column) {
+ try {
+ hBaseAdmin.deleteColumn(table, column);
+ LOG.trace("colum " + column + " deleted from table " + table + ".");
+ } catch (IOException ex) {
+ LOG.error(ex, ex);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set<String> getColumnsNames(String table) {
+ Set<String> columnsNames = new HashSet<String>();
+ try {
+ if (hBaseAdmin.tableExists(table)) {
+ HTableDescriptor hTableDescriptor;
+ hTableDescriptor =
+ hBaseAdmin.getTableDescriptor(table.getBytes());
+
+ HColumnDescriptor[] hColumnsDescriptor;
+ hColumnsDescriptor = hTableDescriptor.getColumnFamilies();
+
+ for (int i = 0 ; i < hColumnsDescriptor.length ; i++) {
+ columnsNames.add(hColumnsDescriptor[i].getNameAsString());
+ }
+
+ } else {
+ try {
+ throw new NoSuchTableException(table);
+ } catch (NoSuchTableException ex) {
+ LOG.error(ex, ex);
+ }
+ }
+ } catch (MasterNotRunningException ex) {
+ LOG.error(ex, ex);
+ } catch (IOException ex) {
+ LOG.error(ex, ex);
+ }
+ return columnsNames;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void put(String table, String column, String key, String content) {
+ try {
+ Put put = new Put(key.getBytes());
+ put.add(column.getBytes(), key.getBytes(), content.getBytes());
+
+ //HTable hTable = new HTable(config, table);
+ synchronized (selectedTable) {
+ this.selectTable(table);
+ this.selectedTable.put(put);
+ }
+
+ LOG.trace("put " + table + " " + column + " " + key + " " + content);
+ } catch (IOException ex) {
+ LOG.error(ex, ex);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String get(String table, String column, String key) {
+ String ret = "";
+ try {
+ Get get = new Get(key.getBytes());
+ get = get.addColumn(column.getBytes());
+
+ //HTable hTable = new HTable(config, table);
+ Result result;
+ synchronized (selectedTable) {
+ this.selectTable(table);
+ result = this.selectedTable.get(get);
+ }
+
+ ret = result.getCellValue().toString();
+
+ LOG.trace("put " + table + " " + column + " " + key + " " + ret);
+ } catch (IOException ex) {
+ LOG.error(ex, ex);
+ }
+ return ret;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String get(String table, String column, String key, int version) {
+ String ret = "";
+ try {
+ Get get = new Get(key.getBytes());
+ get = get.addColumn(column.getBytes());
+ get = get.setTimeStamp(version);
+
+ //HTable hTable = new HTable(config, table);
+ Result result;
+ synchronized (selectedTable) {
+ this.selectTable(table);
+ result = this.selectedTable.get(get);
+ }
+
+ ret = result.getCellValue().toString();
+
+ LOG.trace("put " + table + " " + column + " " + key + " " + ret
+ + " " + version);
+ } catch (IOException ex) {
+ LOG.error(ex, ex);
+ }
+ return ret;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Map<String, String> getRow(String table, String key) {
+ Map<String, String> ret = new HashMap<String, String>();
+ try {
+ for (String column : this.getColumnsNames(table)) {
+ Get get = new Get(key.getBytes());
+ get = get.addColumn(column.getBytes());
+
+ //HTable hTable = new HTable(config, table);
+ Result result;
+ synchronized (selectedTable) {
+ this.selectTable(table);
+ result = this.selectedTable.get(get);
+ }
+
+ String columnContent = result.getCellValue().toString();
+
+ ret.put(column, columnContent);
+ }
+
+
+ LOG.trace("row " + key + " " + ret.toString());
+ } catch (IOException ex) {
+ LOG.error(ex, ex);
+ }
+ return ret;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set<String> getKeys(String table) {
+ Set<String> ret = new HashSet<String>();
+ try {
+
+ synchronized (selectedTable) {
+ this.selectTable(table);
+ Set<byte[]> familiesKeys;
+ familiesKeys =
+ this.selectedTable.getTableDescriptor().getFamiliesKeys();
+ for (byte[] key : familiesKeys) {
+ ret.add(key.toString());
+ }
+ }
+
+ } catch (IOException ex) {
+ LOG.error(ex, ex);
+ }
+ return ret;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void selectTable(String table) {
+ try {
+ selectedTable = new HTable(config, table);
+ } catch (IOException ex) {
+ LOG.error(ex, ex);
+ }
+ }
+}
Property changes on: trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/HBase.java
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/HBaseNewBigTable.java
===================================================================
--- trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/HBaseNewBigTable.java 2010-03-02 11:01:50 UTC (rev 155)
+++ trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/HBaseNewBigTable.java 2010-03-02 11:13:24 UTC (rev 156)
@@ -1,314 +0,0 @@
-package org.nuiton.mapstoragemanager.plugins.hbase;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.hbase.MasterNotRunningException;
-import org.nuiton.mapstoragemanager.plugins.NewBigTable;
-
-import org.apache.hadoop.hbase.HBaseConfiguration;
-import org.apache.hadoop.hbase.HColumnDescriptor;
-import org.apache.hadoop.hbase.HTableDescriptor;
-import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Result;
-
-/**
- * A plugin for MSM using HBase API.
- * @author Dorian Langlais
- */
-public class HBaseNewBigTable implements NewBigTable {
-
- /**
- * Logger.
- */
- private static final Log LOG = LogFactory.getLog(NewBigTable.class);
-
- /**
- * HBaseAdmin.
- * Permit to manage the HBase.
- */
- private HBaseAdmin hBaseAdmin;
- /**
- * HBaseConfiguration.
- * Contains the configuration to connect to the HBase.
- */
- private HBaseConfiguration config;
- /**
- * The selected Table.
- */
- private HTable selectedTable;
-// private HTable table;
-// private String familyName = "mylittlecolumnfamily";
-// private String rowName = "myLittleRow";
-// private String tableName = "mylittletable";
-
- /**
- * HBase plugin Constructor.
- * @throws MasterNotRunningException
- */
- public HBaseNewBigTable() throws MasterNotRunningException {
- // You need a configuration object to tell the client where to connect.
- // When you create a HBaseConfiguration, it reads in whatever you've set
- // into your hbase-site.xml and in hbase-default.xml, as long as these can
- // be found on the CLASSPATH
- org.apache.hadoop.conf.Configuration conf =
- new org.apache.hadoop.conf.Configuration();
- config = new HBaseConfiguration(conf);
- hBaseAdmin = new HBaseAdmin(config);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean connect(Properties properties) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- /**
- * {@inheritDoc}
- */
- public void createTable(String table) {
- HTableDescriptor hTableDescriptor = new HTableDescriptor(table);
- try {
- hBaseAdmin.createTable(hTableDescriptor);
- LOG.trace("table " + table + " created.");
- } catch (IOException ex) {
- LOG.error(ex, ex);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void deleteTable(String table) {
- try {
- // to delete a table, we have to disable it.
- hBaseAdmin.disableTable(table);
- hBaseAdmin.deleteTable(table);
- LOG.trace("table " + table + " deleted.");
- } catch (IOException ex) {
- LOG.error(ex, ex);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public Set<String> getTablesNames() {
- Set<String> tablesNames = new HashSet<String>();
- try {
- HTableDescriptor[] hTablesDescriptor;
- hTablesDescriptor = hBaseAdmin.listTables();
-
- for (int i = 0 ; i < hTablesDescriptor.length ; i++) {
- tablesNames.add(hTablesDescriptor[i].getNameAsString());
- }
-
- } catch (IOException ex) {
- LOG.error(ex, ex);
- }
- return tablesNames;
- }
-
- /**
- * {@inheritDoc}
- */
- public void createColumn(String table, String column) {
- HColumnDescriptor hColumnDescriptor = new HColumnDescriptor(column);
- try {
- hBaseAdmin.addColumn(table, hColumnDescriptor);
- LOG.trace("colum " + column + " created in table " + table + ".");
- } catch (IOException ex) {
- LOG.error(ex, ex);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void deleteColumn(String table, String column) {
- try {
- hBaseAdmin.deleteColumn(table, column);
- LOG.trace("colum " + column + " deleted from table " + table + ".");
- } catch (IOException ex) {
- LOG.error(ex, ex);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public Set<String> getColumnsNames(String table) {
- Set<String> columnsNames = new HashSet<String>();
- try {
- if (hBaseAdmin.tableExists(table)) {
- HTableDescriptor hTableDescriptor;
- hTableDescriptor =
- hBaseAdmin.getTableDescriptor(table.getBytes());
-
- HColumnDescriptor[] hColumnsDescriptor;
- hColumnsDescriptor = hTableDescriptor.getColumnFamilies();
-
- for (int i = 0 ; i < hColumnsDescriptor.length ; i++) {
- columnsNames.add(hColumnsDescriptor[i].getNameAsString());
- }
-
- } else {
- try {
- throw new NoSuchTableException(table);
- } catch (NoSuchTableException ex) {
- LOG.error(ex, ex);
- }
- }
- } catch (MasterNotRunningException ex) {
- LOG.error(ex, ex);
- } catch (IOException ex) {
- LOG.error(ex, ex);
- }
- return columnsNames;
- }
-
- /**
- * {@inheritDoc}
- */
- public void put(String table, String column, String key, String content) {
- try {
- Put put = new Put(key.getBytes());
- put.add(column.getBytes(), key.getBytes(), content.getBytes());
-
- //HTable hTable = new HTable(config, table);
- synchronized (selectedTable) {
- this.selectTable(table);
- this.selectedTable.put(put);
- }
-
- LOG.trace("put " + table + " " + column + " " + key + " " + content);
- } catch (IOException ex) {
- LOG.error(ex, ex);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public String get(String table, String column, String key) {
- String ret = "";
- try {
- Get get = new Get(key.getBytes());
- get = get.addColumn(column.getBytes());
-
- //HTable hTable = new HTable(config, table);
- Result result;
- synchronized (selectedTable) {
- this.selectTable(table);
- result = this.selectedTable.get(get);
- }
-
- ret = result.getCellValue().toString();
-
- LOG.trace("put " + table + " " + column + " " + key + " " + ret);
- } catch (IOException ex) {
- LOG.error(ex, ex);
- }
- return ret;
- }
-
- /**
- * {@inheritDoc}
- */
- public String get(String table, String column, String key, int version) {
- String ret = "";
- try {
- Get get = new Get(key.getBytes());
- get = get.addColumn(column.getBytes());
- get = get.setTimeStamp(version);
-
- //HTable hTable = new HTable(config, table);
- Result result;
- synchronized (selectedTable) {
- this.selectTable(table);
- result = this.selectedTable.get(get);
- }
-
- ret = result.getCellValue().toString();
-
- LOG.trace("put " + table + " " + column + " " + key + " " + ret
- + " " + version);
- } catch (IOException ex) {
- LOG.error(ex, ex);
- }
- return ret;
- }
-
- /**
- * {@inheritDoc}
- */
- public Map<String, String> getRow(String table, String key) {
- Map<String, String> ret = new HashMap<String, String>();
- try {
- for (String column : this.getColumnsNames(table)) {
- Get get = new Get(key.getBytes());
- get = get.addColumn(column.getBytes());
-
- //HTable hTable = new HTable(config, table);
- Result result;
- synchronized (selectedTable) {
- this.selectTable(table);
- result = this.selectedTable.get(get);
- }
-
- String columnContent = result.getCellValue().toString();
-
- ret.put(column, columnContent);
- }
-
-
- LOG.trace("row " + key + " " + ret.toString());
- } catch (IOException ex) {
- LOG.error(ex, ex);
- }
- return ret;
- }
-
- /**
- * {@inheritDoc}
- */
- public Set<String> getKeys(String table) {
- Set<String> ret = new HashSet<String>();
- try {
-
- synchronized (selectedTable) {
- this.selectTable(table);
- Set<byte[]> familiesKeys;
- familiesKeys =
- this.selectedTable.getTableDescriptor().getFamiliesKeys();
- for (byte[] key : familiesKeys) {
- ret.add(key.toString());
- }
- }
-
- } catch (IOException ex) {
- LOG.error(ex, ex);
- }
- return ret;
- }
-
- /**
- * {@inheritDoc}
- */
- public void selectTable(String table) {
- try {
- selectedTable = new HTable(config, table);
- } catch (IOException ex) {
- LOG.error(ex, ex);
- }
- }
-}
Copied: trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/OLDHBase.java (from rev 152, trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/HBase.java)
===================================================================
--- trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/OLDHBase.java (rev 0)
+++ trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/OLDHBase.java 2010-03-02 11:13:24 UTC (rev 156)
@@ -0,0 +1,176 @@
+package org.nuiton.mapstoragemanager.plugins.hbase;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+//import org.nuiton.mapstoragemanager.plugins.BigTable;
+
+import org.apache.hadoop.hbase.HBaseConfiguration;
+//import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.ResultScanner;
+import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.util.Bytes;
+
+public class OLDHBase /*implements "old"BigTable*/ {
+
+ /**
+ * Logger.
+ */
+ private static final Log LOG = LogFactory.getLog(OLDHBase.class);
+
+ private HBaseConfiguration config;
+ private HTable table;
+ private String familyName = "mylittlecolumnfamily";
+ private String rowName = "myLittleRow";
+ private String tableName = "mylittletable";
+
+ public OLDHBase() {
+ // You need a configuration object to tell the client where to connect.
+ // When you create a HBaseConfiguration, it reads in whatever you've set
+ // into your hbase-site.xml and in hbase-default.xml, as long as these can
+ // be found on the CLASSPATH
+ org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration();
+ config = new HBaseConfiguration(conf);
+ LOG.info("test");
+ selectTable(tableName);
+ put("test", "val");
+ put("test", "val2");
+ put("test2", "val3");
+ }
+
+// @Override
+ public void put(String key, String value) {
+
+ // To add to a row, use Put. A Put constructor takes the name of the row
+ // you want to insert into as a byte array. In HBase, the Bytes class has
+ // utility for converting all kinds of java types to byte arrays. In the
+ // below, we are converting the String "myLittleRow" into a byte array to
+ // use as a row key for our update. Once you have a Put instance, you can
+ // adorn it by setting the names of columns you want to update on the row,
+ // the timestamp to use in your update, etc.If no timestamp, the server
+ // applies current time to the edits.
+ Put p = new Put(Bytes.toBytes(rowName));
+
+ // To set the value you'd like to update in the row 'myRow', specify the
+ // column family, column qualifier, and value of the table cell you'd like
+ // to update. The column family must already exist in your table schema.
+ // The qualifier can be anything. All must be specified as byte arrays as
+ // hbase is all about byte arrays. Lets pretend the table
+ // 'myLittleHBaseTable' was created with a family 'myLittleFamily'.
+ p.add(Bytes.toBytes(familyName), Bytes.toBytes(key),
+ Bytes.toBytes(value));
+
+ // Once you've adorned your Put instance with all the updates you want to
+ // make, to commit it do the following (The HTable#put method takes the
+ // Put instance you've been building and pushes the changes you made into
+ // hbase)
+
+ /*try {
+ table.put(p);
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ */
+ }
+
+// @Override
+ public String get(String key) {
+
+ // Now, to retrieve the data we just wrote. The values that come back are
+ // Result instances. Generally, a Result is an object that will package up
+ // the hbase return into the form you find most palatable.
+ /**Get g = new Get(Bytes.toBytes(rowName));
+ Result r;*/
+ byte[] value = null;
+// try {
+// r = table.get(g);
+// value = r.getValue(Bytes.toBytes(familyName),
+// Bytes.toBytes(key));
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+
+ // If we convert the value bytes, we should get back 'Some Value', the
+ // value we inserted at this location.
+ /**String valueStr = Bytes.toString(value);*/
+
+ return "valeur";
+ //return valueStr;
+ }
+
+// @Override
+ public Set<String> getKeys() {
+
+ Set<String> keySet = new HashSet<String>();
+
+ // Sometimes, you won't know the row you're looking for. In this case, you
+ // use a Scanner. This will give you cursor-like interface to the contents
+ // of the table. To set up a Scanner, do like you did above making a Put
+ // and a Get, create a Scan. Adorn it with column names, etc.
+ Scan s = new Scan();
+ //s.addColumn(Bytes.toBytes(familyName), Bytes.toBytes("test"));
+ ResultScanner scanner = null;
+ try {
+ scanner = table.getScanner(s);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ LOG.error(e.toString(), e);
+ }
+ try {
+ // Scanners return Result instances.
+ // Now, for the actual iteration. One way is to use a while loop like so:
+ try {
+ for (Result rr = scanner.next(); rr != null; rr = scanner.next()) {
+ // print out the row we found and the columns we were looking for
+ //System.out.println("Found row: " + rr);
+ LOG.info("Found row: " + rr);
+ keySet.add(rr.toString());
+ }
+
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ LOG.error(e.toString(), e);
+ }
+
+ // The other approach is to use a foreach loop. Scanners are iterable!
+ // for (Result rr : scanner) {
+ // System.out.println("Found row: " + rr);
+ // }
+ } finally {
+ // Make sure you close your scanners when you are done!
+ // Thats why we have it inside a try/finally clause
+ scanner.close();
+ }
+
+ return keySet;
+ }
+
+ public void selectTable(String tableName) {
+ // This instantiates an HTable object that connects you to
+ // the "myLittleHBaseTable" table.
+ try {
+ table = new HTable(config, tableName);
+ } catch (IOException e) {
+ //e.printStackTrace();
+ LOG.error(e.toString(), e);
+ }
+ }
+
+// @Override
+ public void connect(String host, String base, String username,
+ String password) {
+ // TODO Auto-generated method stub
+ }
+
+ public static void main(String[] args) {
+ /**HBase h = */new OLDHBase();
+ }
+}
Property changes on: trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/OLDHBase.java
___________________________________________________________________
Added: svn:mergeinfo
+
1
0
Author: gcrieloue
Date: 2010-03-02 12:01:50 +0100 (Tue, 02 Mar 2010)
New Revision: 155
Added:
tags/mapstoragemanager-154/
Log:
Avant suppression de l'interface BigTable
1
0
r154 - trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins
by gcrieloue@users.nuiton.org 02 Mar '10
by gcrieloue@users.nuiton.org 02 Mar '10
02 Mar '10
Author: gcrieloue
Date: 2010-03-02 11:50:58 +0100 (Tue, 02 Mar 2010)
New Revision: 154
Added:
trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/Plugin.java
Log:
Ajout d'une interface pour les plugins
Added: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/Plugin.java
===================================================================
--- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/Plugin.java (rev 0)
+++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/plugins/Plugin.java 2010-03-02 10:50:58 UTC (rev 154)
@@ -0,0 +1,11 @@
+package org.nuiton.mapstoragemanager.plugins;
+
+public interface Plugin {
+
+ /**
+ * Returns the plugin name.
+ * @return the plugin name
+ */
+ public String getPluginName();
+
+}
1
0
r153 - trunk/msm/src/main/java/org/nuiton/mapstoragemanager/core
by gcrieloue@users.nuiton.org 02 Mar '10
by gcrieloue@users.nuiton.org 02 Mar '10
02 Mar '10
Author: gcrieloue
Date: 2010-03-02 11:49:38 +0100 (Tue, 02 Mar 2010)
New Revision: 153
Modified:
trunk/msm/src/main/java/org/nuiton/mapstoragemanager/core/BigTableLoader.java
Log:
Ajout d'une m?\195?\169thode pour r?\195?\169cup?\195?\169rer les noms des plugins charg?\195?\169s
Modified: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/core/BigTableLoader.java
===================================================================
--- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/core/BigTableLoader.java 2010-03-01 19:52:08 UTC (rev 152)
+++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/core/BigTableLoader.java 2010-03-02 10:49:38 UTC (rev 153)
@@ -7,6 +7,8 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.ServiceLoader;
+import java.util.Set;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -119,4 +121,12 @@
public Collection<BigTable> getAllBigTable(){
return plugins.values();
}
+
+ /**
+ * Returns all the BigTable implementations names.
+ * @return all the BigTable implementations names
+ */
+ public Set<String> getAllBigTableNames(){
+ return plugins.keySet();
+ }
}
1
0
r152 - in trunk/msm-fromtoXML/src: main/java/org/nuiton/mapstoragemanager/plugins/exporter main/java/org/nuiton/mapstoragemanager/plugins/importer test/java/org/nuiton/mapstoragemanager/plugins/importer test/resources
by dlanglais@users.nuiton.org 01 Mar '10
by dlanglais@users.nuiton.org 01 Mar '10
01 Mar '10
Author: dlanglais
Date: 2010-03-01 20:52:08 +0100 (Mon, 01 Mar 2010)
New Revision: 152
Added:
trunk/msm-fromtoXML/src/test/resources/fiveColumns.xml
trunk/msm-fromtoXML/src/test/resources/sixCells.xml
Removed:
trunk/msm-fromtoXML/src/test/resources/twoTablesFiveColumns.xml
Modified:
trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXML.java
trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXML.java
trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLTest.java
Log:
Avancement test de FromXML.java.
Import cellules OK.
Pas de prise en compte de version.
Modified: trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXML.java
===================================================================
--- trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXML.java 2010-03-01 18:25:21 UTC (rev 151)
+++ trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXML.java 2010-03-01 19:52:08 UTC (rev 152)
@@ -52,7 +52,7 @@
}
/**
- * For eath table of the database, the document is constructed.
+ * For each table of the database, the document is constructed.
* @param bigTable the bigTable.
* @param database the database Element.
*/
@@ -76,7 +76,7 @@
}
/**
- * For eath column of the table, the document is constructed.
+ * For each column of the table, the document is constructed.
* @param bigTable the bigTable.
* @param table the table Element.
*/
@@ -103,7 +103,7 @@
}
/**
- * For eath cell of the column, the document is constructed.
+ * For each cell of the column, the document is constructed.
* @param bigTable the bigTable.
* @param column the column Element.
*/
Modified: trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXML.java
===================================================================
--- trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXML.java 2010-03-01 18:25:21 UTC (rev 151)
+++ trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXML.java 2010-03-01 19:52:08 UTC (rev 152)
@@ -57,15 +57,15 @@
}
/**
- * For eath table of the database, the document is constructed.
+ * For each table of the database, the document is constructed.
* @param bigTable the bigTable.
* @param database the database Element.
*/
private void forEachTable(NewBigTable bigTable, final Element database) {
- // the tables name.
- List<Element> tableElements = database.getChildren("table");
+ // the table elements.
+ List<Element> tables = database.getChildren("table");
- for (Element table : tableElements) {
+ for (Element table : tables) {
// get table name and add to the bigTable.
String tableName = table.getAttributeValue("tableName");
bigTable.createTable(tableName);
@@ -76,7 +76,7 @@
}
/**
- * For eath column of the table, the document is constructed.
+ * For each column of the table, the document is constructed.
* @param bigTable the bigTable.
* @param table the table Element.
*/
@@ -84,10 +84,10 @@
// the table name.
String tableName = table.getAttributeValue("tableName");
- // the columns name.
- List<Element> columnElements = table.getChildren("column");
+ // the column elements.
+ List<Element> columns = table.getChildren("column");
- for (Element column : columnElements) {
+ for (Element column : columns) {
// get column name and add to the table.
String columnName = column.getAttributeValue("columnName");
bigTable.createColumn(tableName, columnName);
@@ -98,7 +98,7 @@
}
/**
- * For eath cell of the column, the document is constructed.
+ * For each cell of the column, the document is constructed.
* @param bigTable the bigTable.
* @param column the column Element.
*/
@@ -109,36 +109,16 @@
// the column name.
String columnName = column.getAttributeValue("columnName");
- // the table keys.
- Set<String> keys = bigTable.getKeys(tableName);
+ // the cell elements.
+ List<Element> cells = column.getChildren("cell");
- String content = "";
- for (String key : keys) {
- try{
- content = bigTable.get(tableName, columnName, key);
- if ( ! "".equals(content)) {
+ for (Element cell : cells) {
+ // get cell key and content.
+ String cellKey = cell.getAttributeValue("key");
+ String cellContent = cell.getChild("value").getText();
- // new cell Element.
- Element cell = new Element("cell");
- // new attribute which contain the cell key.
- Attribute cellKeyAttr = new Attribute("key", key);
- cell.setAttribute(cellKeyAttr);
-
- // we add the cell to the column.
- column.addContent(cell);
-
- // new value Element.
- Element value = new Element("value");
- value.setText(content);
-
- // we add the value to the cell.
- cell.addContent(value);
- }
- }
- catch (NoSuchElementException e) {
- LOG.trace(e, e);
- }
-
+ // add content to the bigtable.
+ bigTable.put(tableName, columnName, cellKey, cellContent);
}
}
Modified: trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLTest.java
===================================================================
--- trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLTest.java 2010-03-01 18:25:21 UTC (rev 151)
+++ trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLTest.java 2010-03-01 19:52:08 UTC (rev 152)
@@ -8,8 +8,12 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
+import java.util.NoSuchElementException;
import java.util.Set;
+import junit.framework.Assert;
import junit.framework.TestCase;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.nuiton.mapstoragemanager.plugins.Importer;
import org.nuiton.mapstoragemanager.plugins.NewBigTable;
import org.nuiton.mapstoragemanager.plugins.bighashmapv2.BigHashMap;
@@ -21,12 +25,18 @@
*/
public class FromXMLTest extends TestCase {
+ /**
+ * Logger.
+ */
+ private static final Log LOG = LogFactory.getLog(FromXMLTest.class);
+
// public void testImportFrom() {
// Assert.fail();
// }
/**
- * Import the database from the file fiveTables and verify the content.
+ * Import the database from the file fiveTables.
+ * Verify the content.
*/
public void testImportFromFiveTables() {
@@ -39,6 +49,9 @@
importer.importFrom(bigTable, fiveTables);
+ /************************
+ * Test Tables *
+ ************************/
Set<String> tableNamesExpected;
{
/**
@@ -62,10 +75,14 @@
}
}
- public void testImportFromTwoTablesFiveColumns() {
+ /**
+ * Import the database from the file fiveColumns.
+ * Verify the content.
+ */
+ public void testImportFromFiveColumns() {
File twoTablesFiveColumns =
- getFile.getTestFile("/src/test/resources/twoTablesFiveColumns.xml");
+ getFile.getTestFile("/src/test/resources/fiveColumns.xml");
// import fiveTables.
Importer importer = new FromXML();
@@ -73,6 +90,9 @@
importer.importFrom(bigTable, twoTablesFiveColumns);
+ /************************
+ * Test Tables *
+ ************************/
Set<String> tableNamesExpected;
{
/**
@@ -85,6 +105,9 @@
Set<String> tableNamesActual = bigTable.getTablesNames();
assertEquals(tableNamesExpected, tableNamesActual);
+ /************************
+ * Test Columns *
+ ************************/
Map<String, Set<String>> columnNamesExpected;
{
/**
@@ -101,11 +124,143 @@
columnNamesExpected.put("table1", table1ColumnNames);
columnNamesExpected.put("table2", table2ColumnNames);
}
-
+
Set<String> columnNamesActual;
for (String tableName : tableNamesActual) {
columnNamesActual = bigTable.getColumnsNames(tableName);
assertEquals(columnNamesExpected.get(tableName), columnNamesActual);
}
}
+
+ /**
+ * Import the database from the file tenCells.
+ * Verify the content.
+ */
+ public void testImportFromThreeTenCells() {
+
+ File twoTablesFiveColumns =
+ getFile.getTestFile("/src/test/resources/sixCells.xml");
+
+ // import fiveTables.
+ Importer importer = new FromXML();
+ NewBigTable bigTable = new BigHashMap();
+
+ importer.importFrom(bigTable, twoTablesFiveColumns);
+
+ /************************
+ * Test Tables *
+ ************************/
+ Set<String> tableNamesExpected;
+ {
+ /**
+ * Init tableNames.
+ */
+ tableNamesExpected = new HashSet<String>();
+ tableNamesExpected.add("table1");
+ tableNamesExpected.add("table2");
+ }
+ Set<String> tableNamesActual = bigTable.getTablesNames();
+ assertEquals(tableNamesExpected, tableNamesActual);
+
+ /************************
+ * Test Columns *
+ ************************/
+ Map<String, Set<String>> columnNamesExpected;
+ {
+ /**
+ * Init columnNames.
+ */
+ columnNamesExpected = new HashMap<String, Set<String>>();
+ Set<String> table1ColumnNames = new HashSet<String>();
+ table1ColumnNames.add("column1");
+ Set<String> table2ColumnNames = new HashSet<String>();
+ table2ColumnNames.add("column2");
+ table2ColumnNames.add("column3");
+ columnNamesExpected.put("table1", table1ColumnNames);
+ columnNamesExpected.put("table2", table2ColumnNames);
+ }
+
+ Set<String> columnNamesActual;
+ for (String tableName : tableNamesActual) {
+ columnNamesActual = bigTable.getColumnsNames(tableName);
+ assertEquals(columnNamesExpected.get(tableName), columnNamesActual);
+ }
+
+ /************************
+ * Test Cells *
+ ************************/
+ Map<String, Map<String, Map<String, String>>> CellContentExpected;
+ {
+ /**
+ * Init cellContent.
+ */
+ CellContentExpected = new HashMap<String,
+ Map<String, Map<String, String>>>();
+ // table 1.
+ Map<String, Map<String, String>> table1 =
+ new HashMap<String, Map<String, String>>();
+ // column 1.
+ Map<String,String> column1 = new HashMap<String, String>();
+ column1.put("111", "111");
+ table1.put("column1", column1);
+ // table 2.
+ Map<String, Map<String, String>> table2 =
+ new HashMap<String, Map<String, String>>();
+ // column 2.
+ Map<String,String> column2 = new HashMap<String, String>();
+ column2.put("221", "221");
+ column2.put("222", "222");
+ table2.put("column2", column2);
+ // column 3.
+ Map<String,String> column3 = new HashMap<String, String>();
+ column3.put("231", "231");
+ column3.put("232", "232");
+ column3.put("233", "233");
+ table2.put("column3", column3);
+
+ CellContentExpected.put("table1", table1);
+ CellContentExpected.put("table2", table2);
+ LOG.info(CellContentExpected);
+ }
+
+ Set<String> tableKeys;
+ String cellContentActual;
+ String cellContentExpected = null;
+ for (String tableName : tableNamesActual) {
+ columnNamesActual = bigTable.getColumnsNames(tableName);
+ tableKeys = bigTable.getKeys(tableName);
+ for (String columnName : columnNamesActual) {
+ for (String cellKey : tableKeys) {
+
+ try {
+ try{
+ cellContentExpected =
+ CellContentExpected
+ .get(tableName)
+ .get(columnName)
+ .get(cellKey);
+ } catch (NullPointerException ex) {
+ LOG.trace(ex);
+ }
+
+ LOG.info(tableName + ' '
+ + columnName + ' '
+ + cellKey + ' '
+ + cellContentExpected);
+
+ cellContentActual =
+ bigTable.get(tableName, columnName, cellKey);
+ assertEquals(cellContentExpected, cellContentActual);
+ } catch (NoSuchElementException ex) {
+ if(cellContentExpected != null) {
+ LOG.error(ex, ex);
+ Assert.fail();
+ } else {
+ LOG.trace(ex);
+ }
+ }
+ }
+ }
+ }
+ }
}
Added: trunk/msm-fromtoXML/src/test/resources/fiveColumns.xml
===================================================================
--- trunk/msm-fromtoXML/src/test/resources/fiveColumns.xml (rev 0)
+++ trunk/msm-fromtoXML/src/test/resources/fiveColumns.xml 2010-03-01 19:52:08 UTC (rev 152)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<database>
+ <table tableName="table1">
+ <column columnName="column1" />
+ <column columnName="column2" />
+ </table>
+ <table tableName="table2">
+ <column columnName="column3" />
+ <column columnName="column4" />
+ <column columnName="column5" />
+ </table>
+</database>
+
Added: trunk/msm-fromtoXML/src/test/resources/sixCells.xml
===================================================================
--- trunk/msm-fromtoXML/src/test/resources/sixCells.xml (rev 0)
+++ trunk/msm-fromtoXML/src/test/resources/sixCells.xml 2010-03-01 19:52:08 UTC (rev 152)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<database>
+ <table tableName="table1">
+ <column columnName="column1">
+ <cell key="111">
+ <value>111</value>
+ </cell>
+ </column>
+ </table>
+ <table tableName="table2">
+ <column columnName="column2">
+ <cell key="221">
+ <value>221</value>
+ </cell>
+ <cell key="222">
+ <value>222</value>
+ </cell>
+ </column>
+ <column columnName="column3">
+ <cell key="231">
+ <value>231</value>
+ </cell>
+ <cell key="232">
+ <value>232</value>
+ </cell>
+ <cell key="233">
+ <value>233</value>
+ </cell>
+ </column>
+ </table>
+</database>
+
Deleted: trunk/msm-fromtoXML/src/test/resources/twoTablesFiveColumns.xml
===================================================================
--- trunk/msm-fromtoXML/src/test/resources/twoTablesFiveColumns.xml 2010-03-01 18:25:21 UTC (rev 151)
+++ trunk/msm-fromtoXML/src/test/resources/twoTablesFiveColumns.xml 2010-03-01 19:52:08 UTC (rev 152)
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<database>
- <table tableName="table1">
- <column columnName="column1" />
- <column columnName="column2" />
- </table>
- <table tableName="table2">
- <column columnName="column3" />
- <column columnName="column4" />
- <column columnName="column5" />
- </table>
-</database>
-
1
0
r151 - in trunk/msm-fromtoXML/src: main/java/org/nuiton/mapstoragemanager/plugins/exporter main/java/org/nuiton/mapstoragemanager/plugins/importer test test/java/org/nuiton/mapstoragemanager/plugins test/java/org/nuiton/mapstoragemanager/plugins/exporter test/java/org/nuiton/mapstoragemanager/plugins/importer test/resources
by dlanglais@users.nuiton.org 01 Mar '10
by dlanglais@users.nuiton.org 01 Mar '10
01 Mar '10
Author: dlanglais
Date: 2010-03-01 19:25:21 +0100 (Mon, 01 Mar 2010)
New Revision: 151
Added:
trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXML.java
trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/getFile.java
trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLTest.java
trunk/msm-fromtoXML/src/test/resources/
trunk/msm-fromtoXML/src/test/resources/fiveTables.xml
trunk/msm-fromtoXML/src/test/resources/twoTablesFiveColumns.xml
Modified:
trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXML.java
trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXMLTest.java
Log:
Commencement FromXML.java, et classe de test.
Pour le moment import Tables et Colonnes : OK.
Toujours pas de gestion des versions.
Modified: trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXML.java
===================================================================
--- trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXML.java 2010-02-28 17:58:02 UTC (rev 150)
+++ trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXML.java 2010-03-01 18:25:21 UTC (rev 151)
@@ -6,6 +6,7 @@
import java.io.File;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.util.NoSuchElementException;
import java.util.Set;
import org.apache.commons.logging.Log;
@@ -28,27 +29,26 @@
* Logger.
*/
private static final Log LOG = LogFactory.getLog(ToXML.class);
+ /**
+ * the jdom document.
+ */
+ private static Document document;
- // the racine which is the database.
- private static Element racine;
-
- // the jdom document.
- private static Document document;
-
+ /**
+ * {@inheritDoc}
+ */
@Override
public void exportTo(NewBigTable bigTable, File file) {
- racine = new Element("database");
- document = new Document(racine);
+ Element database = new Element("database");
+ document = new Document(database);
// Construction of the document.
- forEachTable(bigTable, racine);
+ forEachTable(bigTable, database);
- // the methods to print and to save the database in XML file.
- //toSreen();
- if (file != null) {
- save(file);
- }
+ // print the jdom document.
+// toSreen();
+ save(file);
}
/**
@@ -56,7 +56,7 @@
* @param bigTable the bigTable.
* @param database the database Element.
*/
- private void forEachTable(NewBigTable bigTable, Element database) {
+ private void forEachTable(final NewBigTable bigTable, Element database) {
// the tables name.
Set<String> tablesNames = bigTable.getTablesNames();
@@ -80,25 +80,25 @@
* @param bigTable the bigTable.
* @param table the table Element.
*/
- private void forEachColumn(NewBigTable bigTable, Element table) {
+ private void forEachColumn(final NewBigTable bigTable, Element table) {
// the table name.
String tableName = table.getAttributeValue("tableName");
// the columns name.
Set<String> columnNames = bigTable.getColumnsNames(tableName);
- for (String column : columnNames) {
+ for (String columnName : columnNames) {
// new column Element.
- Element columnElement = new Element("column");
+ Element column = new Element("column");
// new attribute which contain the column name.
- Attribute columnNameAttribute = new Attribute("columnName", column);
- columnElement.setAttribute(columnNameAttribute);
+ Attribute columnNameAttr = new Attribute("columnName", columnName);
+ column.setAttribute(columnNameAttr);
// we add the column to the table.
- table.addContent(columnElement);
+ table.addContent(column);
- // we search the columns of the table.
- forEachCell(bigTable, columnElement);
+ // we search the cells of the table.
+ forEachCell(bigTable, column);
}
}
@@ -107,7 +107,7 @@
* @param bigTable the bigTable.
* @param column the column Element.
*/
- private void forEachCell(NewBigTable bigTable, Element column) {
+ private void forEachCell(final NewBigTable bigTable, Element column) {
// the table name.
String tableName =
column.getParentElement().getAttributeValue("tableName");
@@ -124,27 +124,24 @@
if ( ! "".equals(content)) {
// new cell Element.
- Element cellElement = new Element("cell");
+ Element cell = new Element("cell");
// new attribute which contain the cell key.
- Attribute cellKeyAttribute = new Attribute("key", key);
- cellElement.setAttribute(cellKeyAttribute);
+ Attribute cellKeyAttr = new Attribute("key", key);
+ cell.setAttribute(cellKeyAttr);
// we add the cell to the column.
- column.addContent(cellElement);
+ column.addContent(cell);
// new value Element.
- Element valueElement = new Element("value");
- // // new attribute which contain the value version.
- // Attribute valueVersionAttribute = new Attribute("version", v);
- // valueElement.setAttribute(valueVersionAttribute);
- valueElement.setText(content);
+ Element value = new Element("value");
+ value.setText(content);
// we add the value to the cell.
- cellElement.addContent(valueElement);
+ cell.addContent(value);
}
}
catch (NoSuchElementException e) {
-// LOG.warn(e, e);
+ LOG.trace(e, e);
}
}
@@ -170,9 +167,11 @@
private static void save(File file) {
try {
XMLOutputter output = new XMLOutputter(Format.getPrettyFormat());
- output.output(document, new FileOutputStream(file));
- } catch (java.io.IOException e) {
- LOG.error(e, e);
+ FileOutputStream fos = new FileOutputStream(file);
+ output.output(document, fos);
+ fos.close();
+ } catch (IOException ex) {
+ LOG.error(ex, ex);
}
}
}
Added: trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXML.java
===================================================================
--- trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXML.java (rev 0)
+++ trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXML.java 2010-03-01 18:25:21 UTC (rev 151)
@@ -0,0 +1,172 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.nuiton.mapstoragemanager.plugins.importer;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdom.Attribute;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.input.SAXBuilder;
+import org.jdom.output.Format;
+import org.jdom.output.XMLOutputter;
+import org.nuiton.mapstoragemanager.plugins.Importer;
+import org.nuiton.mapstoragemanager.plugins.NewBigTable;
+
+/**
+ *
+ * @author Dorian Langlais
+ */
+public class FromXML implements Importer {
+
+ /**
+ * Logger.
+ */
+ private static final Log LOG = LogFactory.getLog(FromXML.class);
+ /**
+ * the jdom document.
+ */
+ private static Document document;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void importFrom(NewBigTable bigTable, File file) {
+ try {
+ open(file);
+
+ Element racine = document.getRootElement();
+
+ // Construction of the bigtable database.
+ forEachTable(bigTable, racine);
+
+ // print the jdomDocument.
+// toSreen();
+ } catch (IOException ex) {
+ LOG.error(ex, ex);
+ }
+ }
+
+ /**
+ * For eath table of the database, the document is constructed.
+ * @param bigTable the bigTable.
+ * @param database the database Element.
+ */
+ private void forEachTable(NewBigTable bigTable, final Element database) {
+ // the tables name.
+ List<Element> tableElements = database.getChildren("table");
+
+ for (Element table : tableElements) {
+ // get table name and add to the bigTable.
+ String tableName = table.getAttributeValue("tableName");
+ bigTable.createTable(tableName);
+
+ // we search the columns of the table.
+ forEachColumn(bigTable, table);
+ }
+ }
+
+ /**
+ * For eath column of the table, the document is constructed.
+ * @param bigTable the bigTable.
+ * @param table the table Element.
+ */
+ private void forEachColumn(NewBigTable bigTable, final Element table) {
+ // the table name.
+ String tableName = table.getAttributeValue("tableName");
+
+ // the columns name.
+ List<Element> columnElements = table.getChildren("column");
+
+ for (Element column : columnElements) {
+ // get column name and add to the table.
+ String columnName = column.getAttributeValue("columnName");
+ bigTable.createColumn(tableName, columnName);
+
+ // we search the cells of the table.
+ forEachCell(bigTable, column);
+ }
+ }
+
+ /**
+ * For eath cell of the column, the document is constructed.
+ * @param bigTable the bigTable.
+ * @param column the column Element.
+ */
+ private void forEachCell(NewBigTable bigTable, final Element column) {
+ // the table name.
+ String tableName =
+ column.getParentElement().getAttributeValue("tableName");
+ // the column name.
+ String columnName = column.getAttributeValue("columnName");
+
+ // the table keys.
+ Set<String> keys = bigTable.getKeys(tableName);
+
+ String content = "";
+ for (String key : keys) {
+ try{
+ content = bigTable.get(tableName, columnName, key);
+ if ( ! "".equals(content)) {
+
+ // new cell Element.
+ Element cell = new Element("cell");
+ // new attribute which contain the cell key.
+ Attribute cellKeyAttr = new Attribute("key", key);
+ cell.setAttribute(cellKeyAttr);
+
+ // we add the cell to the column.
+ column.addContent(cell);
+
+ // new value Element.
+ Element value = new Element("value");
+ value.setText(content);
+
+ // we add the value to the cell.
+ cell.addContent(value);
+ }
+ }
+ catch (NoSuchElementException e) {
+ LOG.trace(e, e);
+ }
+
+ }
+ }
+
+ /**
+ * toSreen().
+ * show the XML content on System.out
+ */
+ static void toSreen() {
+ try {
+ XMLOutputter output = new XMLOutputter(Format.getPrettyFormat());
+ output.output(document, System.out);
+ } catch (java.io.IOException e) {
+ LOG.error(e, e);
+ }
+ }
+
+ /**
+ * Method to load the jdom document of the file.
+ * @param file the file from which the database is saved.
+ */
+ private static void open(File file) throws IOException {
+ //On crée une instance de SAXBuilder
+ SAXBuilder saxBuilder = new SAXBuilder();
+ try {
+ // we construct the jdom document from the file.
+ document = saxBuilder.build(file);
+ } catch (JDOMException ex) {
+ LOG.error(ex, ex);
+ }
+ }
+}
Modified: trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXMLTest.java
===================================================================
--- trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXMLTest.java 2010-02-28 17:58:02 UTC (rev 150)
+++ trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXMLTest.java 2010-03-01 18:25:21 UTC (rev 151)
@@ -6,8 +6,8 @@
package org.nuiton.mapstoragemanager.plugins.exporter;
//import java.io.IOException;
+import java.io.File;
import java.lang.reflect.Field;
-import java.util.List;
import junit.framework.TestCase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -20,6 +20,7 @@
import org.nuiton.mapstoragemanager.plugins.NewBigTable;
import org.nuiton.mapstoragemanager.plugins.AssertJdomElement;
import org.nuiton.mapstoragemanager.plugins.bighashmapv2.BigHashMap;
+import org.nuiton.mapstoragemanager.plugins.getFile;
/**
*
@@ -40,14 +41,13 @@
/**
* Test to export a bigTable database in a xml format.
*/
- public void testToXML() {
- // init actual et expected.
+ public void testExportTo() {
createXMLDocument();
+ // init actual et expected.
Element actualRoot = actual.getRootElement();
Element expectedRoot = expected.getRootElement();
-// assertTrue(testEquals(expectedRoot, actualRoot));
AssertJdomElement.assertEquivalent(expectedRoot, actualRoot);
}
@@ -208,7 +208,10 @@
cell10.addContent(value10);
Exporter exporter = new ToXML();
- exporter.exportTo(nbt, null);
+ File exportTest =
+ getFile.getTestFile("/src/test/resources/exportTest.xml");
+ exporter.exportTo(nbt,exportTest);
+ exportTest.delete();
// expected.toString();
@@ -245,116 +248,9 @@
}
/**
- * Test if to Element are equal.
- * @param expected expected element.
- * @param actual actual element.
- * @return true if expected and actual are equivalents.
+ * A main to test quickly.
+ * @param args args.
*/
- /*public static boolean testEquals(Element expected, Element actual) {
-
- boolean trace = true;
-// String expectedContent = expected.getContent();
-// String actualContent = actual.getContent();
-
- if(trace) {
- System.out.println("---------------------------------------------");
- }
-// System.out.println(expected.getContent());
-// System.out.println(actual.getContent());
-
- String expectedElementName = expected.getName();
- String actualElementName = actual.getName();
-
- if(!expectedElementName.equals(actualElementName)) {
- return false;
- }
-
- List<Attribute> expectedAttributes = expected.getAttributes();
- List<Attribute> actualAttributes = actual.getAttributes();
-
- List<Element> expectedChildren = expected.getChildren();
- List<Element> actualChildren = actual.getChildren();
-
- String expectedValue = expected.getValue();
- String actualValue = actual.getValue();
-
-
- // we compare attributes.
- if (expectedAttributes.size() != actualAttributes.size()) {
- return false;
- } else if (expectedAttributes.size() == 1) {
- // case with only one attribute.
- String expectedAttribute = expectedAttributes.toString();
- String actualAttribute = actualAttributes.toString();
- if (! expectedAttribute.equals(actualAttribute)) {
- return false;
- }
- } else {
- // case with only many attribute.
- // TODO -> we have only one attribute for instance.
- }
-
- if(trace) {
- System.out.println("Attribues");
- System.out.println(expectedAttributes);
- System.out.println(actualAttributes);
-
-// System.out.println("Children");
-// System.out.println(expectedChildren);
-// System.out.println(actualChildren);
-
-// System.out.println("Value");
-// System.out.println(expectedValue);
-// System.out.println(actualValue);
- }
-
- if (expectedChildren.size() != actualChildren.size()) {
- return false;
- } else if (expectedChildren.isEmpty()) {
- if(trace) {
- System.out.println(expectedValue);
- System.out.println(actualValue);
- }
- return expected.getValue().equals(actual.getValue());
- }
-// System.out.println(expectedChildren);
-// System.out.println(actualChildren);
-
- boolean TF;
- // same elements.
- for (Element expectedChild : expectedChildren) {
- TF = false;
- for (Element actualChild : actualChildren) {
- if(actualChild.getChildren().size() ==
- expectedChild.getChildren().size()) {
- if (testEquals(expectedChild,actualChild)) {
-// actualChildren.remove(actualChild);
- TF = true;
- if(trace) {
- System.out.println("EQUIVALENT");
- System.out.println(expectedChild.getValue());
- System.out.println(actualChild.getValue());
- }
- } else {
- if(trace) {
- System.out.println("NOT EQUIVALENT");
- System.out.println(expectedChild.getValue());
- System.out.println(actualChild.getValue());
- }
- }
- }
- }
- if (TF == false) {
- if(trace) {
- System.out.println("RETURN FALSE");
- }
- return false;
- }
- }
-
- return true;
- }*/
-
public static void main(String[] args) {
NewBigTable nbt = new BigHashMap();
nbt.createTable("table1");
@@ -380,6 +276,9 @@
nbt.put("table2", "column5", "10", "content10");
Exporter exporter = new ToXML();
- exporter.exportTo(nbt, null);
+ File exportTest =
+ getFile.getTestFile("/src/test/resources/exportTest.xml");
+ exporter.exportTo(nbt,exportTest);
+ exportTest.delete();
}
}
Added: trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/getFile.java
===================================================================
--- trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/getFile.java (rev 0)
+++ trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/getFile.java 2010-03-01 18:25:21 UTC (rev 151)
@@ -0,0 +1,52 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.nuiton.mapstoragemanager.plugins;
+
+import java.io.File;
+
+/**
+ *
+ * @author Dorian Langlais
+ */
+public class getFile {
+
+ private static String basedir;
+
+ public static File getTestFile(String path) {
+ return new File(getBasedir(), path);
+ }
+
+ public static File getTestFile(String basedir, String path) {
+ File basedirFile = new File(basedir);
+
+ if (!basedirFile.isAbsolute()) {
+ basedirFile = getTestFile(basedir);
+ }
+
+ return new File(basedirFile, path);
+ }
+
+ public static String getTestPath(String path) {
+ return getTestFile(path).getAbsolutePath();
+ }
+
+ public static String getTestPath(String basedir, String path) {
+ return getTestFile(basedir, path).getAbsolutePath();
+ }
+
+ public static String getBasedir() {
+ if (basedir != null) {
+ return basedir;
+ }
+
+ basedir = System.getProperty("basedir");
+
+ if (basedir == null) {
+ basedir = new File("").getAbsolutePath();
+ }
+
+ return basedir;
+ }
+}
Added: trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLTest.java
===================================================================
--- trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLTest.java (rev 0)
+++ trunk/msm-fromtoXML/src/test/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLTest.java 2010-03-01 18:25:21 UTC (rev 151)
@@ -0,0 +1,111 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.nuiton.mapstoragemanager.plugins.importer;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import junit.framework.TestCase;
+import org.nuiton.mapstoragemanager.plugins.Importer;
+import org.nuiton.mapstoragemanager.plugins.NewBigTable;
+import org.nuiton.mapstoragemanager.plugins.bighashmapv2.BigHashMap;
+import org.nuiton.mapstoragemanager.plugins.getFile;
+
+/**
+ *
+ * @author Dorian Langlais
+ */
+public class FromXMLTest extends TestCase {
+
+// public void testImportFrom() {
+// Assert.fail();
+// }
+
+ /**
+ * Import the database from the file fiveTables and verify the content.
+ */
+ public void testImportFromFiveTables() {
+
+ File fiveTables =
+ getFile.getTestFile("/src/test/resources/fiveTables.xml");
+
+ // import fiveTables.
+ Importer importer = new FromXML();
+ NewBigTable bigTable = new BigHashMap();
+
+ importer.importFrom(bigTable, fiveTables);
+
+ Set<String> tableNamesExpected;
+ {
+ /**
+ * Init tableNames.
+ */
+ tableNamesExpected = new HashSet<String>();
+ tableNamesExpected.add("table1");
+ tableNamesExpected.add("table2");
+ tableNamesExpected.add("table3");
+ tableNamesExpected.add("table4");
+ tableNamesExpected.add("table5");
+ }
+ Set<String> tableNamesActual = bigTable.getTablesNames();
+ assertEquals(tableNamesExpected, tableNamesActual);
+
+
+ for (String tableName : tableNamesActual) {
+ Set<String> columnNamesExpected = new HashSet<String>();
+ assertEquals(columnNamesExpected,
+ bigTable.getColumnsNames(tableName));
+ }
+ }
+
+ public void testImportFromTwoTablesFiveColumns() {
+
+ File twoTablesFiveColumns =
+ getFile.getTestFile("/src/test/resources/twoTablesFiveColumns.xml");
+
+ // import fiveTables.
+ Importer importer = new FromXML();
+ NewBigTable bigTable = new BigHashMap();
+
+ importer.importFrom(bigTable, twoTablesFiveColumns);
+
+ Set<String> tableNamesExpected;
+ {
+ /**
+ * Init tableNames.
+ */
+ tableNamesExpected = new HashSet<String>();
+ tableNamesExpected.add("table1");
+ tableNamesExpected.add("table2");
+ }
+ Set<String> tableNamesActual = bigTable.getTablesNames();
+ assertEquals(tableNamesExpected, tableNamesActual);
+
+ Map<String, Set<String>> columnNamesExpected;
+ {
+ /**
+ * Init columnNames.
+ */
+ columnNamesExpected = new HashMap<String, Set<String>>();
+ Set<String> table1ColumnNames = new HashSet<String>();
+ table1ColumnNames.add("column1");
+ table1ColumnNames.add("column2");
+ Set<String> table2ColumnNames = new HashSet<String>();
+ table2ColumnNames.add("column3");
+ table2ColumnNames.add("column4");
+ table2ColumnNames.add("column5");
+ columnNamesExpected.put("table1", table1ColumnNames);
+ columnNamesExpected.put("table2", table2ColumnNames);
+ }
+
+ Set<String> columnNamesActual;
+ for (String tableName : tableNamesActual) {
+ columnNamesActual = bigTable.getColumnsNames(tableName);
+ assertEquals(columnNamesExpected.get(tableName), columnNamesActual);
+ }
+ }
+}
Added: trunk/msm-fromtoXML/src/test/resources/fiveTables.xml
===================================================================
--- trunk/msm-fromtoXML/src/test/resources/fiveTables.xml (rev 0)
+++ trunk/msm-fromtoXML/src/test/resources/fiveTables.xml 2010-03-01 18:25:21 UTC (rev 151)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<database>
+ <table tableName="table1" />
+ <table tableName="table2" />
+ <table tableName="table3" />
+ <table tableName="table4" />
+ <table tableName="table5" />
+</database>
+
Added: trunk/msm-fromtoXML/src/test/resources/twoTablesFiveColumns.xml
===================================================================
--- trunk/msm-fromtoXML/src/test/resources/twoTablesFiveColumns.xml (rev 0)
+++ trunk/msm-fromtoXML/src/test/resources/twoTablesFiveColumns.xml 2010-03-01 18:25:21 UTC (rev 151)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<database>
+ <table tableName="table1">
+ <column columnName="column1" />
+ <column columnName="column2" />
+ </table>
+ <table tableName="table2">
+ <column columnName="column3" />
+ <column columnName="column4" />
+ <column columnName="column5" />
+ </table>
+</database>
+
1
0
28 Feb '10
Author: dlanglais
Date: 2010-02-28 18:58:02 +0100 (Sun, 28 Feb 2010)
New Revision: 150
Added:
trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/package-info.java
trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/package-info.java
trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/package-info.java
Modified:
trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/package-info.java
trunk/msm-bighashmapV2/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmapv2/package-info.java
Log:
ajout des package-info.java manquants.
Modified: trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/package-info.java
===================================================================
--- trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/package-info.java 2010-02-28 17:51:58 UTC (rev 149)
+++ trunk/msm-bighashmap/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmap/package-info.java 2010-02-28 17:58:02 UTC (rev 150)
@@ -1,6 +1,6 @@
package org.nuiton.mapstoragemanager.plugins.bighashmap;
/**
* package BigHashMap.
- * permet la représentation sous forme de hashMap d'une base de données selon
+ * Permet la représentation sous forme de hashMap d'une base de données selon
* la spécification bigTable.
*/
Modified: trunk/msm-bighashmapV2/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmapv2/package-info.java
===================================================================
--- trunk/msm-bighashmapV2/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmapv2/package-info.java 2010-02-28 17:51:58 UTC (rev 149)
+++ trunk/msm-bighashmapV2/src/main/java/org/nuiton/mapstoragemanager/plugins/bighashmapv2/package-info.java 2010-02-28 17:58:02 UTC (rev 150)
@@ -1,6 +1,6 @@
package org.nuiton.mapstoragemanager.plugins.bighashmapv2;
/**
* package BigHashMap.
- * permet la représentation sous forme de hashMap d'une base de données selon
+ * Permet la représentation sous forme de hashMap d'une base de données selon
* la spécification bigTable.
*/
Added: trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/package-info.java
===================================================================
--- trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/package-info.java (rev 0)
+++ trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/package-info.java 2010-02-28 17:58:02 UTC (rev 150)
@@ -0,0 +1,5 @@
+package org.nuiton.mapstoragemanager.plugins.exporter;
+/**
+ * package exporter.
+ * Permet l'export dans un format XML d'une base bigtable.
+ */
Added: trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/package-info.java
===================================================================
--- trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/package-info.java (rev 0)
+++ trunk/msm-fromtoXML/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/package-info.java 2010-02-28 17:58:02 UTC (rev 150)
@@ -0,0 +1,6 @@
+package org.nuiton.mapstoragemanager.plugins.importer;
+/**
+ * package importer.
+ * Permet l'import dans une base bigtable du contenu d'une base bigtable stockée
+ * dans un fichier XML.
+ */
Added: trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/package-info.java
===================================================================
--- trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/package-info.java (rev 0)
+++ trunk/msm-hbase/src/main/java/org/nuiton/mapstoragemanager/plugins/hbase/package-info.java 2010-02-28 17:58:02 UTC (rev 150)
@@ -0,0 +1,5 @@
+package org.nuiton.mapstoragemanager.plugins.hbase;
+/**
+ * package hbase.
+ * Permet de se connecter à une base HBase.
+ */
1
0