Permalink
Browse files

updated readme

fixed creation of CF
  • Loading branch information...
tomek
tomek committed Jul 19, 2012
1 parent 625f8cc commit 0c8861bd0985fae9ceb47287c91a4471920ba83d
View
@@ -13,4 +13,6 @@ The main goal is to develop a web application based on Qooxdoo Frontend which pr
## Features
* Listing keyspaces and column families
-* Viewing properties of above
+* Viewing properties of above
+* Add / remove / truncate column family
+* Drop keyspace
@@ -33,11 +33,11 @@ qx.Class.define("helenos.components.menu.ColumnFamilyContextMenu",
this.add(new qx.ui.menu.Separator());
- var removeButton = new qx.ui.menu.Button("Remove", "qx/icon/Oxygen/16/actions/edit-delete.png");
- removeButton.setUserData('KSNAME', ksName);
- removeButton.setUserData('CFNAME', cfName);
- removeButton.addListener("execute", this.__removeColumnFamily);
- this.add(removeButton);
+ var dropButton = new qx.ui.menu.Button("Drop", "qx/icon/Oxygen/16/actions/edit-delete.png");
+ dropButton.setUserData('KSNAME', ksName);
+ dropButton.setUserData('CFNAME', cfName);
+ dropButton.addListener("execute", this.__dropColumnFamily);
+ this.add(dropButton);
var truncateButton = new qx.ui.menu.Button("Truncate", "qx/icon/Oxygen/16/actions/edit-clear.png");
truncateButton.setUserData('KSNAME', ksName);
@@ -65,12 +65,12 @@ qx.Class.define("helenos.components.menu.ColumnFamilyContextMenu",
}, this);
},
- __removeColumnFamily : function(e) {
+ __dropColumnFamily : function(e) {
var ksName = e.getTarget().getUserData('KSNAME');
var cfName = e.getTarget().getUserData('CFNAME');
dialog.Dialog.confirm(this.tr('loss.data.alert'), function(ret) {
if (ret == true) {
- helenos.util.RpcActionsProvider.removeColumnFamily(ksName, cfName);
+ helenos.util.RpcActionsProvider.dropColumnFamily(ksName, cfName);
helenos.util.GuiObserver.refreshSchemaTree();
}
}, this);
@@ -31,7 +31,7 @@ qx.Class.define("helenos.components.menu.KeyspaceContextMenu",
addCFButton.addListener("execute", this.__addColumnFamily);
this.add(addCFButton);
- var dropButton = new qx.ui.menu.Button("Remove", "qx/icon/Oxygen/16/actions/edit-delete.png");
+ var dropButton = new qx.ui.menu.Button("Drop", "qx/icon/Oxygen/16/actions/edit-delete.png");
dropButton.setUserData('KSNAME', ksName);
dropButton.addListener("execute", this.__dropKeyspace);
this.add(dropButton);
@@ -64,7 +64,7 @@ qx.Class.define("helenos.components.menu.KeyspaceContextMenu",
"required" : true
}
},
- 'column' : {
+ 'columnType' : {
'type' : "SelectBox",
'label' : "Column",
'value' : 1,
@@ -73,7 +73,7 @@ qx.Class.define("helenos.components.menu.KeyspaceContextMenu",
"required" : true
}
},
- 'comparator' : {
+ 'comparatorType' : {
'type' : "SelectBox",
'label' : "Comparator",
'value' : 1,
@@ -82,14 +82,11 @@ qx.Class.define("helenos.components.menu.KeyspaceContextMenu",
"required" : true
}
},
- 'subComparator' : {
+ 'subComparatorType' : {
'type' : "SelectBox",
'label' : "Subcomparator",
'value' : 1,
- 'options' : helenos.util.CassandraTypes.comparatorTypes,
- "validation" : {
- "required" : true
- }
+ 'options' : helenos.util.CassandraTypes.comparatorTypes
}
,
'keyValidationclass' : {
@@ -110,6 +107,15 @@ qx.Class.define("helenos.components.menu.KeyspaceContextMenu",
"required" : true
}
},
+ 'gcGraceSeconds' : {
+ 'type' : "TextField",
+ 'label' : "GC grace seconds",
+ 'value' : '86400',
+ "validation" : {
+ "required" : true
+ //,"validator" : qx.util.Validate.number()
+ }
+ },
'comment' :
{
'type' : "TextArea",
@@ -119,8 +125,10 @@ qx.Class.define("helenos.components.menu.KeyspaceContextMenu",
}
};
dialog.Dialog.form('<h4>Create new column family</h4>', formData, function(result) {
-
- });
+ result['keyspaceName'] = ksName;
+ helenos.util.RpcActionsProvider.createColumnFamily(result);
+ helenos.util.GuiObserver.refreshSchemaTree();
+ });
}
}
});
@@ -32,7 +32,16 @@ qx.Class.define('helenos.util.RpcActionsProvider', {
truncateColumnFamily : function(keyspaceName, columnFamily) {
var rpc = new helenos.util.Rpc('Cluster');
return rpc.callSync('truncateColumnFamily', keyspaceName, columnFamily);
- }
+ },
+ dropColumnFamily : function(keyspaceName, columnFamily) {
+ var rpc = new helenos.util.Rpc('Cluster');
+ return rpc.callSync('dropColumnFamily', keyspaceName, columnFamily);
+ },
+
+ createColumnFamily : function(formData) {
+ var rpc = new helenos.util.Rpc('Cluster');
+ return rpc.callSync('createColumnFamily', formData);
+ }
}
});
@@ -6,6 +6,7 @@
import com.kuprowski.helenos.types.JsonColumnFamilyDefinition;
import com.kuprowski.helenos.types.JsonKeyspaceDefinition;
+import com.kuprowski.helenos.types.qx.QxJsonColumnFamilyDefinition;
import java.util.List;
/**
@@ -27,4 +28,6 @@
JsonKeyspaceDefinition describeKeyspace(String keyspaceName);
JsonColumnFamilyDefinition describeColumnFamily(String keyspaceName, String columnFamilyName);
+
+ void createColumnFamily(QxJsonColumnFamilyDefinition qxDef);
}
@@ -6,9 +6,14 @@
import com.kuprowski.helenos.types.JsonColumnFamilyDefinition;
import com.kuprowski.helenos.types.JsonKeyspaceDefinition;
+import com.kuprowski.helenos.types.qx.QxJsonColumnFamilyDefinition;
import java.util.ArrayList;
import java.util.List;
+import me.prettyprint.cassandra.model.BasicColumnFamilyDefinition;
+import me.prettyprint.cassandra.service.ThriftCfDef;
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition;
+import me.prettyprint.hector.api.ddl.ColumnType;
+import me.prettyprint.hector.api.ddl.ComparatorType;
import me.prettyprint.hector.api.ddl.KeyspaceDefinition;
import org.springframework.stereotype.Component;
@@ -67,4 +72,20 @@ public JsonColumnFamilyDefinition describeColumnFamily(String keyspaceName, Stri
}
return jsonDef;
}
+
+ @Override
+ public void createColumnFamily(QxJsonColumnFamilyDefinition qxDef) {
+ ColumnFamilyDefinition cfDef = new ThriftCfDef(qxDef.getKeyspaceName(), qxDef.getName());
+ cfDef.setGcGraceSeconds(qxDef.getGcGraceSeconds());
+ cfDef.setComment(qxDef.getComment());
+ cfDef.setColumnType(ColumnType.getFromValue(qxDef.getColumnType()));
+ cfDef.setComparatorType(ComparatorType.getByClassName(qxDef.getComparatorType()));
+ if (qxDef.getColumnType().equals(ColumnType.SUPER.getValue())) {
+ cfDef.setSubComparatorType(ComparatorType.getByClassName(qxDef.getSubComparatorType()));
+ }
+ cfDef.setKeyValidationClass(qxDef.getKeyValidationclass());
+ cfDef.setDefaultValidationClass(qxDef.getDefaultValidationclass());
+
+ cluster.addColumnFamily(cfDef, true);
+ }
}
@@ -0,0 +1,97 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.kuprowski.helenos.types.qx;
+
+/**
+ *
+ * @author tomek
+ */
+public class QxJsonColumnFamilyDefinition {
+
+ public QxJsonColumnFamilyDefinition() {
+ }
+
+ private String keyspaceName;
+ private String name;
+ private String columnType;
+ private String comparatorType;
+ private String subComparatorType;
+ private String keyValidationclass;
+ private String defaultValidationclass;
+ private String comment;
+ private int gcGraceSeconds;
+
+ public int getGcGraceSeconds() {
+ return gcGraceSeconds;
+ }
+
+ public void setGcGraceSeconds(int gcGraceSeconds) {
+ this.gcGraceSeconds = gcGraceSeconds;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getColumnType() {
+ return columnType;
+ }
+
+ public void setColumnType(String columnType) {
+ this.columnType = columnType;
+ }
+
+ public String getComparatorType() {
+ return comparatorType;
+ }
+
+ public void setComparatorType(String comparatorType) {
+ this.comparatorType = comparatorType;
+ }
+
+ public String getSubComparatorType() {
+ return subComparatorType;
+ }
+
+ public void setSubComparatorType(String subComparatorType) {
+ this.subComparatorType = subComparatorType;
+ }
+
+ public String getKeyValidationclass() {
+ return keyValidationclass;
+ }
+
+ public void setKeyValidationclass(String keyValidationclass) {
+ this.keyValidationclass = keyValidationclass;
+ }
+
+ public String getDefaultValidationclass() {
+ return defaultValidationclass;
+ }
+
+ public void setDefaultValidationclass(String defaultValidationclass) {
+ this.defaultValidationclass = defaultValidationclass;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
+ public String getKeyspaceName() {
+ return keyspaceName;
+ }
+
+ public void setKeyspaceName(String keyspaceName) {
+ this.keyspaceName = keyspaceName;
+ }
+}

0 comments on commit 0c8861b

Please sign in to comment.