Permalink
Browse files

added custom converter (heapbytebuffer -> string)

added keyAlias field into CF info pane
  • Loading branch information...
1 parent d429010 commit 8709f8e5b7122269be10f6da46bbe02cda3c9398 tomek committed Oct 18, 2012
@@ -97,6 +97,7 @@ qx.Class.define("helenos.components.tab.ColumnFamilyInfoPage",
gb.add(new helenos.ui.RichAtom('Key validation: <b>' + cfDef.keyValidationClass.replace('org.apache.cassandra.db.marshal.','') + '</b>'));
gb.add(new helenos.ui.RichAtom('Default validation: <b>' + cfDef.defaultValidationClass.replace('org.apache.cassandra.db.marshal.','') + '</b>'));
+ gb.add(new helenos.ui.RichAtom('Key alias: <b>' + cfDef.keyAlias));
return gb;
},
@@ -0,0 +1,31 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.kuprowski.helenos.dozer.converters;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import org.dozer.CustomConverter;
+import org.dozer.MappingException;
+
+/**
+ *
+ * @author tomek
+ */
+public class HeapByteBufferConverter implements CustomConverter {
+
+ @Override
+ public Object convert(Object existingDestinationFieldValue, Object sourceFieldValue, Class<?> destinationClass, Class<?> sourceClass) {
+ if (sourceFieldValue == null) {
+ return null;
+ }
+ if (!(sourceFieldValue instanceof java.nio.ByteBuffer)) {
+ throw new MappingException("Converter " + this.getClass().toString() + " used incorrectly. Arguments passed in were:"
+ + existingDestinationFieldValue + " and " + sourceFieldValue);
+ }
+
+ return Charset.forName("UTF-8").decode((ByteBuffer) sourceFieldValue).toString();
+ }
+}
@@ -44,7 +44,7 @@ public JsonColumnFamilyDefinition() {
private Map<String, String> compactionStrategyOptions;
private Map<String, String> compressionOptions;
private double mergeShardsChance;
-
+ private String keyAlias;
public String getName() {
return name;
@@ -54,6 +54,14 @@ public void setName(String name) {
this.name = name;
}
+ public void setKeyAlias(String keyAlias) {
+ this.keyAlias = keyAlias;
+ }
+
+ public String getKeyAlias() {
+ return keyAlias;
+ }
+
public String getKeyspaceName() {
return keyspaceName;
}
@@ -5,6 +5,12 @@
<configuration>
<wildcard>false</wildcard>
+ <custom-converters>
+ <converter type="com.kuprowski.helenos.dozer.converters.HeapByteBufferConverter" >
+ <class-a>java.nio.HeapByteBuffer</class-a>
+ <class-b>java.lang.String</class-b>
+ </converter>
+ </custom-converters>
</configuration>
<mapping type="one-way">
@@ -35,12 +41,15 @@
<mapping type="one-way">
<class-a>me.prettyprint.cassandra.service.ThriftCfDef</class-a>
<class-b>com.kuprowski.helenos.types.JsonColumnFamilyDefinition</class-b>
-
<field>
<a>name</a>
<b>name</b>
</field>
<field>
+ <a>keyAlias</a>
+ <b>keyAlias</b>
+ </field>
+ <field>
<a>keyspaceName</a>
<b>keyspaceName</b>
</field>
@@ -203,7 +212,5 @@
<a>ttl</a>
<b>ttl</b>
</field>
- </mapping>
-
-
+ </mapping>
</mappings>

0 comments on commit 8709f8e

Please sign in to comment.