Skip to content

Commit

Permalink
implemented search by single column and viewing JSON data parsed to T…
Browse files Browse the repository at this point in the history
…ree widget
  • Loading branch information
tomek committed Aug 10, 2012
1 parent 30279f8 commit 3610b34
Show file tree
Hide file tree
Showing 19 changed files with 355 additions and 78 deletions.
15 changes: 15 additions & 0 deletions pom.xml
Expand Up @@ -57,6 +57,20 @@
<groupId>org.hectorclient</groupId>
<artifactId>hector-core</artifactId>
<version>${hector.version}</version>
<exclusions>
<exclusion>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
Expand Down Expand Up @@ -145,6 +159,7 @@
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>

<systemProperties>
<systemProperty>
<name>org.apache.commons.logging.Log</name>
Expand Down
Expand Up @@ -59,7 +59,7 @@ qx.Class.define('helenos.components.menu.ColumnFamilyContextMenu',
var byKeyButton = new qx.ui.menu.Button('By key', 'icon/16/apps/utilities-keyring.png');
byKeyButton.setUserData('KSNAME', ksName);
byKeyButton.setUserData('CFNAME', cfName);
//byKeyButton.addListener('execute', this.__showBrowserPane);
byKeyButton.addListener('execute', this.__showBrowseByKeyPane);

var sliceButton = new qx.ui.menu.Button('Slice predicate', 'icon/16/apps/office-spreadsheet.png');
sliceButton.setUserData('KSNAME', ksName);
Expand All @@ -82,10 +82,10 @@ qx.Class.define('helenos.components.menu.ColumnFamilyContextMenu',
}, this);
},

__showBrowserPane : function(e) {
__showBrowseByKeyPane : function(e) {
var ksName = e.getTarget().getUserData('KSNAME');
var cfName = e.getTarget().getUserData('CFNAME');
helenos.util.GuiObserver.showBrowserTab(ksName, cfName);
helenos.util.GuiObserver.showBrowseByKeyTab(ksName, cfName);
},

__dropColumnFamily : function(e) {
Expand Down
@@ -0,0 +1,25 @@
/* ************************************************************************
Copyright:
2012 Tomek Kuprowski
License:
GPLv2: http://www.gnu.org/licences/gpl.html
Authors:
Tomek Kuprowski (tomekkuprowski at gmail dot com)
************************************************************************ */
qx.Class.define("helenos.components.tab.AbstractBrowsePage",
{
extend : helenos.components.tab.AbstractCloseablePage,

members : {
_rajCB : null,
_resultView : null
},

construct : function()
{
this.base(arguments);

this._rajCB = new qx.ui.form.CheckBox('Parse results to JSON');
this._resultView = new qx.ui.container.Composite(new qx.ui.layout.VBox());
}
});
@@ -0,0 +1,143 @@
/* ************************************************************************
Copyright:
2012 Tomek Kuprowski
License:
GPLv2: http://www.gnu.org/licences/gpl.html
Authors:
Tomek Kuprowski (tomekkuprowski at gmail dot com)
************************************************************************ */
/*
#asset(qx/icon/${qx.icontheme}/16/actions/system-search.png)
#asset(qx/icon/${qx.icontheme}/16/places/folder-open.png)
*/
qx.Class.define("helenos.components.tab.BrowseByKeyPage",
{
extend : helenos.components.tab.AbstractBrowsePage,

construct : function(ksName, cfName)
{
this.base(arguments);
this.set({
layout : new qx.ui.layout.VBox(3, 'top'),
icon : 'icon/16/apps/utilities-keyring.png',
label: (ksName + ' : ' + cfName)
});

var cfDef = helenos.util.RpcActionsProvider.describeColumnFamily(ksName, cfName);

this.__addFilterPane(cfDef);
this.add(this._resultView, {flex: 1});
},

members :
{
__keyTF : null,
__nameTF : null,
__sNameTF : null,
__cfDef : null,

__performSearch : function(e) {
var key = this.__keyTF.getValue();
var name = this.__nameTF.getValue();
var sName = (this.__sNameTF == null ? null : this.__sNameTF.getValue());
var result = helenos.util.RpcActionsProvider.querySingleColumn(this.__cfDef, key, name, sName );

this._resultView.removeAll();
if (this._rajCB.getValue()) {
this._resultView.add(this._getTreeFromJson(key, result), {flex: 1});
} else {
this._resultView.add(new qx.ui.form.TextArea(result), {flex: 1});
}
},

_getTreeFromJson : function(name, data) {
var tree = new qx.ui.tree.Tree();
var rootNode = new qx.ui.tree.TreeFolder(name);

tree.setRoot(rootNode);
rootNode.setOpen(true);

if (data == undefined || data == '') {
tree.getRoot().add(new qx.ui.tree.TreeFile('empty value'));
return tree;
}

var jsonVal = qx.lang.Json.parse(data);
var currentNode = tree.getRoot();
this._renderTreeItemFromJson(currentNode, jsonVal);
return tree;
},

_renderTreeItemFromJson : function(node, data) {
if (data == null) {
return;
}
if (Array.isArray(data)) {
for (var i = 0; i < data.length; i++) {
this._renderTreeItemFromJson(node, data[i]);
}
} else if(typeof data === 'object') {
for (var key in data) {
if(Array.isArray(data[key])) {
var subNode = new qx.ui.tree.TreeFolder(key);
subNode.setIcon('helenos/a.png');
node.add(subNode);
} else
if (typeof data[key] === 'number') {
var subNode = new qx.ui.tree.TreeFile(key + ' : ' + data[key]);
subNode.setIcon('helenos/n.png');
node.add(subNode);
} else
if (typeof data[key] === 'string') {
var subNode = new qx.ui.tree.TreeFile(key + ' : ' + data[key]);
subNode.setIcon('helenos/s.png');
node.add(subNode);
}
else {
var subNode = new qx.ui.tree.TreeFolder(key);
subNode.setIcon('icon/16/places/folder-open.png');

subNode.setOpen(true);
node.add(subNode);
this._renderTreeItemFromJson(subNode, data[key]);
}
}
} else {
node.add(new qx.ui.tree.TreeFile(data));
}
},

__addFilterPane : function(cfDef) {
this.__cfDef = cfDef;
this.__keyTF = new helenos.ui.TextField(this.__cfDef.keyValidationClass);
this.__nameTF = new helenos.ui.TextField(this.__cfDef.comparatorType.className);

this.__keyTF.setValue('239daf70-b3d8-11e1-8a37-50e549e89108');
this.__nameTF.setValue('1340376726872');

var searchButton = new qx.ui.form.Button('Search', 'icon/16/actions/system-search.png');
searchButton.addListener("execute", this.__performSearch, this);

var filterGB = new qx.ui.groupbox.GroupBox('Filter');
filterGB.setLayout(new qx.ui.layout.HBox(8));

filterGB.add(new qx.ui.basic.Label('Key:'));
filterGB.add(this.__keyTF);
filterGB.add(new qx.ui.core.Spacer(5));

if (this.__cfDef.columnType == 'Super') {
this.__sNameTF = new helenos.ui.TextField(this.__cfDef.subComparatorType.className);
filterGB.add(new qx.ui.core.Spacer(5));
filterGB.add(new qx.ui.basic.Label('Super column name:'));
filterGB.add(this.__sNameTF);
}

filterGB.add(new qx.ui.basic.Label('Column name:'));
filterGB.add(this.__nameTF);
filterGB.add(searchButton);
filterGB.add(this._rajCB);

this.add(filterGB);
}
}
});

This file was deleted.

63 changes: 63 additions & 0 deletions src/main/frontend/source/class/helenos/ui/TextField.js
@@ -0,0 +1,63 @@
/* ************************************************************************
Copyright:
2012 Tomek Kuprowski
License:
GPLv2: http://www.gnu.org/licences/gpl.html
Authors:
Tomek Kuprowski (tomekkuprowski at gmail dot com)
************************************************************************ */
qx.Class.define("helenos.ui.TextField",
{
extend : qx.ui.form.TextField,

statics : {
classDefs : {
'org.apache.cassandra.db.marshal.BytesType' : {
placeholder : 'bytes',
width : 190
},
'org.apache.cassandra.db.marshal.AsciiType' : {
placeholder : 'ascii',
width : 190
},
'org.apache.cassandra.db.marshal.UTF8Type' : {
placeholder : 'utf-8',
width : 190
},
'org.apache.cassandra.db.marshal.LongType' : {
placeholder : 'long',
width : 120,
filter : /[0-9]/
},
'org.apache.cassandra.db.marshal.LexicalUUIDType' : {
placeholder : 'lexical uuid',
maxLength : 36,
width : 260,
filter : /[a-fA-F0-9\-]/
},
'org.apache.cassandra.db.marshal.TimeUUIDType' : {
placeholder : 'time uuid',
maxLength : 36,
width : 260,
filter : /[a-fA-F0-9\-]/
}
}
},

construct : function(clazz)
{
this.base(arguments);

var cd = helenos.ui.TextField.classDefs[clazz];
if (cd != undefined) {
this.set(cd );
} else {
if (clazz.substring(0,45) == 'org.apache.cassandra.db.marshal.CompositeType') {
alert('Composite type not supported yet');
} else {
alert('type not known')
}

}
}
});
4 changes: 0 additions & 4 deletions src/main/frontend/source/class/helenos/util/CassandraTypes.js
Expand Up @@ -84,10 +84,6 @@ qx.Class.define('helenos.util.CassandraTypes', {
],

validationClasses : [
{
'label' : "SuperColumns",
'value' : "SuperColumns"
},
{
'label' : "BytesType",
'value' : "BytesType"
Expand Down
4 changes: 2 additions & 2 deletions src/main/frontend/source/class/helenos/util/GuiObserver.js
Expand Up @@ -29,9 +29,9 @@ qx.Class.define("helenos.util.GuiObserver",
this.__tabbedPane.setSelection([ksPage]);
},

showBrowserTab : function(keyspaceName, columnFamily) {
showBrowseByKeyTab : function(keyspaceName, columnFamily) {
qx.core.Assert.assertNotNull(this.__tabbedPane,'tabbed pane not registered yet');
var dataPage = new helenos.components.tab.BrowserPage(keyspaceName, columnFamily);
var dataPage = new helenos.components.tab.BrowseByKeyPage(keyspaceName, columnFamily);
this.__tabbedPane.add(dataPage);
this.__tabbedPane.setSelection([dataPage]);
},
Expand Down

0 comments on commit 3610b34

Please sign in to comment.