sampling added

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@98365 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Loredana Liccardo 2014-07-03 12:44:03 +00:00
parent 0b85126f89
commit e2c1826227
11 changed files with 777 additions and 387 deletions

View File

@ -32,6 +32,8 @@ public interface GWTdbManagerService extends RemoteService {
List<Result> submitQuery(LinkedHashMap<String, String> dataDB,
String query, boolean valueReadOnlyQuery,
boolean smartCorrectionQuery, String language) throws Exception;
List<Result> sample(LinkedHashMap<String, String> dataInput) throws Exception;
List<Row> parseCVSString(List<Result> result, List<String> attrNames)
throws Exception;

View File

@ -33,4 +33,7 @@ public interface GWTdbManagerServiceAsync {
void parseCVSString(List<Result> result, List<String> attrNames,
AsyncCallback<List<Row>> callback);
void sample(LinkedHashMap<String, String> dataInput,
AsyncCallback<List<Result>> callback);
}

View File

@ -12,7 +12,7 @@ public class FileModel extends BaseModelData implements Serializable {
private static int ID = 0;
// private int id;
private boolean isExpanded = true;
// private boolean isSchema = false;
// private boolean isSchema = false;
private boolean isLoaded = false;
// private boolean isTable = false;
private boolean isDatabase = false;

View File

@ -4,6 +4,7 @@ public enum EventsTypeEnum {
SELECTED_ITEM_EVENT,
SUBMIT_QUERY_EVENT,
SHOW_CREATE_TABLE_EVENT;
SHOW_CREATE_TABLE_EVENT,
SAMPLING_EVENT;
}

View File

@ -0,0 +1,32 @@
package org.gcube.portlets.user.databasesmanager.client.events;
import org.gcube.portlets.user.databasesmanager.client.events.interfaces.SamplingEventHandler;
import com.google.gwt.event.shared.GwtEvent;
public class SamplingEvent extends GwtEvent<SamplingEventHandler> {
public static Type<SamplingEventHandler> TYPE = new Type<SamplingEventHandler>();
@Override
public Type<SamplingEventHandler> getAssociatedType() {
// TODO Auto-generated method stub
return TYPE;
}
@Override
protected void dispatch(SamplingEventHandler handler) {
// TODO Auto-generated method stub
handler.onSampling(this);
}
public EventsTypeEnum getKey() {
// TODO Auto-generated method stub
return EventsTypeEnum.SAMPLING_EVENT;
}
}

View File

@ -8,7 +8,7 @@ import com.google.gwt.event.shared.GwtEvent;
//"SelectedItemEvent" event definition
public class SelectedItemEvent extends GwtEvent<SelectedItemEventHandler> {
public class SelectedItemEvent extends GwtEvent<SelectedItemEventHandler> {
public static Type<SelectedItemEventHandler> TYPE = new Type<SelectedItemEventHandler>();

View File

@ -0,0 +1,10 @@
package org.gcube.portlets.user.databasesmanager.client.events.interfaces;
import org.gcube.portlets.user.databasesmanager.client.events.SamplingEvent;
import com.google.gwt.event.shared.EventHandler;
public interface SamplingEventHandler extends EventHandler {
public void onSampling(SamplingEvent samplingEvent);
}

View File

@ -1,7 +1,5 @@
package org.gcube.portlets.user.databasesmanager.client.panels;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
@ -13,8 +11,10 @@ import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel;
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
import org.gcube.portlets.user.databasesmanager.client.datamodel.Row;
import org.gcube.portlets.user.databasesmanager.client.datamodel.SubmitQueryData;
import org.gcube.portlets.user.databasesmanager.client.events.SamplingEvent;
import org.gcube.portlets.user.databasesmanager.client.events.SelectedItemEvent;
import org.gcube.portlets.user.databasesmanager.client.events.SubmitQueryEvent;
import org.gcube.portlets.user.databasesmanager.client.events.interfaces.SamplingEventHandler;
import org.gcube.portlets.user.databasesmanager.client.events.interfaces.SelectedItemEventHandler;
import org.gcube.portlets.user.databasesmanager.client.events.interfaces.SubmitQueryEventHandler;
import org.gcube.portlets.user.databasesmanager.client.toolbar.GxtToolbarFunctionality;
@ -50,12 +50,12 @@ import com.extjs.gxt.ui.client.widget.layout.RowData;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.MessageBoxEvent;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.button.Button;
public class GxtBorderLayoutPanel extends ContentPanel {
/* Create Root Logger */
private static Logger rootLogger = Logger.getLogger("GxtBorderLayoutPanel");
@ -76,6 +76,9 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// RPC service
private GWTdbManagerServiceAsync RPCservice = null;
// variable that keeps track of the managed event
private boolean submitQueryEventManaged = false;
public GxtBorderLayoutPanel(HandlerManager eBus,
GWTdbManagerServiceAsync service) throws Exception {
@ -96,6 +99,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
}
private void initLayout() {
north.setLayout(new FitLayout());
north.setTopComponent(toolbar.getToolBar());
@ -197,24 +202,24 @@ public class GxtBorderLayoutPanel extends ContentPanel {
public void onSelectedItem(
SelectedItemEvent selectedItemEvent) {
// System.out
// .println("GxtBorderLayoutPanel: Event received");
// System.out
// .println("GxtBorderLayoutPanel: Event received");
rootLogger.log(Level.SEVERE, "Event received");
int DepthSelectedItem = treePanel
.getTreeDepthSelectedItem();
// System.out.println("GxtBorderLayoutPanel-> Depth: "
// + DepthSelectedItem);
// System.out.println("GxtBorderLayoutPanel-> Depth: "
// + DepthSelectedItem);
// element name selected
String text = treePanel.getValue();
// System.out
// .println("GxtBorderLayoutPanel-> item selected: "
// + text);
// System.out
// .println("GxtBorderLayoutPanel-> item selected: "
// + text);
rootLogger.log(Level.INFO, "item selected: " + text);
toolbar.disableButtonOnToolbar(DepthSelectedItem,
@ -227,10 +232,10 @@ public class GxtBorderLayoutPanel extends ContentPanel {
centerUpper.layout(true);
}
List<FileModel> data = treePanel.getTreePanel()
.getSelectionModel().getSelectedItems();
FileModel selectedItem = data.get(0);
if (DepthSelectedItem == 3) { // the item selected is a
@ -238,9 +243,9 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// show database information in the panel
// List<FileModel> data = treePanel.getTreePanel()
// .getSelectionModel().getSelectedItems();
// FileModel selectedItem = data.get(0);
// List<FileModel> data = treePanel.getTreePanel()
// .getSelectionModel().getSelectedItems();
// FileModel selectedItem = data.get(0);
FileModel parent = treePanel.getTreeStore()
.getParent(selectedItem);
@ -251,32 +256,34 @@ public class GxtBorderLayoutPanel extends ContentPanel {
displayDBInfo(data.get(0));
}
//display the table name in the right panel when a table is selected
if (DepthSelectedItem == 5){
// display the table name in the right panel when a
// table is selected
if (DepthSelectedItem == 5) {
centerUpper.removeAll();
centerUpper.addText(data.get(0).getName());
centerUpper.layout(true);
}
if ((DepthSelectedItem == 4) && (data.get(0).isSchema() == false)){
if ((DepthSelectedItem == 4)
&& (data.get(0).isSchema() == false)) {
centerUpper.removeAll();
centerUpper.addText(data.get(0).getName());
centerUpper.layout(true);
}
// System.out
// .println("GxtBorderLayoutPanel: Event finished");
// System.out
// .println("GxtBorderLayoutPanel: Event finished");
rootLogger.log(Level.SEVERE, "Event finished");
}
@ -290,24 +297,44 @@ public class GxtBorderLayoutPanel extends ContentPanel {
public void onSubmitQuery(SubmitQueryEvent submitQueryEvent) {
// TODO Auto-generated method stub
try {
submitQuery();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// try {
// submitQuery();
// } catch (Exception e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
submitQuery();
}
});
eventBus.addHandler(SamplingEvent.TYPE, new SamplingEventHandler() {
@Override
public void onSampling(SamplingEvent samplingEvent) {
// TODO Auto-generated method stub
sample();
}
});
}
private void submitQuery() throws Exception {
private void submitQuery() {
// System.out.println("Start RPC - submitQuery");
// System.out.println("Start RPC - submitQuery");
rootLogger.log(Level.SEVERE, "Start RPC - submitQuery");
// variable that keeps track of the managed event
submitQueryEventManaged = false;
// recover input data
LinkedHashMap<String, String> dataDB = treePanel
@ -329,44 +356,47 @@ public class GxtBorderLayoutPanel extends ContentPanel {
String dialect;
if (selectedItem.isDatabase()) { // the selected item is a database
// System.out.println("the selected item is a database");
// System.out.println("the selected item is a database");
rootLogger.log(Level.INFO, "the selected item is a database");
// determine the dialect recovering the dialect
dialect = selectedItem.getDBInfo().get(2).getValue();
rootLogger.log(Level.INFO, "determined Dialect for smart correction: " + dialect);
rootLogger.log(Level.INFO,
"determined Dialect for smart correction: " + dialect);
} else {
FileModel parent1 = treePanel.getTreeStore()
.getParent(selectedItem);
if (parent1.isDatabase()) { // the selected item is a schema
// System.out.println("the selected item is a schema");
// System.out.println("the selected item is a schema");
rootLogger.log(Level.INFO, "the selected item is a schema");
// determine the dialect recovering the dialect
dialect = parent1.getDBInfo().get(2).getValue();
rootLogger.log(Level.INFO, "determined Dialect for smart correction: " + dialect);
rootLogger.log(Level.INFO,
"determined Dialect for smart correction: " + dialect);
}
else { // the selected item is a table
// System.out.println("the selected item is a table");
// System.out.println("the selected item is a table");
rootLogger.log(Level.INFO, "the selected item is a table");
FileModel parent2 = treePanel.getTreeStore().getParent(parent1);
// determine the dialect recovering the dialect
dialect = parent2.getDBInfo().get(2).getValue();
rootLogger.log(Level.INFO, "determined Dialect for smart correction: " + dialect);
rootLogger.log(Level.INFO,
"determined Dialect for smart correction: " + dialect);
}
@ -383,8 +413,9 @@ public class GxtBorderLayoutPanel extends ContentPanel {
language = ConstantsPortlet.MYSQL;
}
rootLogger.log(Level.INFO, "Dialect used for smart correction: " + language);
rootLogger.log(Level.INFO, "Dialect used for smart correction: "
+ language);
RPCservice.submitQuery(dataDB, dataQuery.getQuery(), true,
dataQuery.getSmartCorrection(), language,
@ -399,32 +430,33 @@ public class GxtBorderLayoutPanel extends ContentPanel {
@Override
public void onFailure(Throwable caught) {
// Window.alert(caught.getMessage());
// System.out.println("FAILURE submitQuery");
// Window.alert(caught.getMessage());
// System.out.println("FAILURE submitQuery");
rootLogger.log(Level.SEVERE, "FAILURE RPC submitQuery");
Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() {
public void handleEvent(MessageBoxEvent ce) {
// Button btn = ce.getButtonClicked();
// Info.display("MessageBox", "The '{0}' button was pressed", btn.getHtml());
// Button btn = ce.getButtonClicked();
Dialog form = toolbar.getDialogForm();
if (form.isMasked())
form.unmask();
}
};
// MessageBox.alert("Error "," <br/>Cause:"+caught.getCause()+"<br/>Message:"+caught.getMessage(), l);
MessageBox.alert("Error ","<br/>Message:"+caught.getMessage(), l);
Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() {
public void handleEvent(MessageBoxEvent ce) {
// Button btn = ce.getButtonClicked();
// Info.display("MessageBox",
// "The '{0}' button was pressed",
// btn.getHtml());
// Button btn = ce.getButtonClicked();
Dialog form = toolbar.getDialogForm();
if (form.isMasked())
form.unmask();
}
};
// MessageBox.alert("Error "," <br/>Cause:"+caught.getCause()+"<br/>Message:"+caught.getMessage(),
// l);
MessageBox.alert("Error ",
"<br/>Message:" + caught.getMessage(), l);
}
@ -432,21 +464,20 @@ public class GxtBorderLayoutPanel extends ContentPanel {
public void onSuccess(List<Result> result) {
// TODO Auto-generated method stub
// System.out.println("SUCCESS submitQuery");
// System.out.println("SUCCESS submitQuery");
rootLogger.log(Level.SEVERE, "SUCCESS RPC submitQuery");
rows = new ArrayList<Row>();
// System.out.println("result size: " + result.size());
rootLogger.log(Level.SEVERE, "output size: " + result.size());
// System.out.println("result size: " + result.size());
rootLogger.log(Level.SEVERE,
"output size: " + result.size());
// recover query
// Result query = result.remove(0);
// recover converted query
Result convertedQuery;
@ -463,7 +494,10 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// remove the header in order to parse only the result
result.remove(0);
//parse the result in order to obtain a table
// variable that keeps track of the managed event
submitQueryEventManaged = true;
// parse the result in order to obtain a table
parseResult(result);
}
@ -472,8 +506,112 @@ public class GxtBorderLayoutPanel extends ContentPanel {
}
private void sample() {
// this.mask();
// System.out.println("Start RPC - submitQuery");
rootLogger.log(Level.SEVERE, "Start RPC - sample");
// get the selected table
List<FileModel> data = treePanel.getTreePanel().getSelectionModel()
.getSelectedItems();
// the selected item is a table
FileModel selectedItem = data.get(0);
rootLogger.log(Level.INFO, "the selected table is: " + selectedItem);
// recover data inputs
LinkedHashMap<String, String> dataInput = new LinkedHashMap<String, String>();
// check if the table has an associated schema
FileModel schema;
FileModel database;
FileModel resource;
if (treePanel.getTreeStore().getParent(selectedItem).isSchema()) {
schema = treePanel.getTreeStore().getParent(selectedItem);
database = treePanel.getTreeStore().getParent(schema);
resource = treePanel.getTreeStore().getParent(database);
dataInput.put("ResourceName", resource.getName());
dataInput.put("DatabaseName", database.getName());
dataInput.put("SchemaName", schema.getName());
dataInput.put("TableName", selectedItem.getName());
rootLogger.log(Level.INFO, "ResourceName: " + resource.getName());
rootLogger.log(Level.INFO, "DatabaseName: " + database.getName());
rootLogger.log(Level.INFO, "SchemaName: " + schema.getName());
rootLogger.log(Level.INFO, "SchemaName: " + selectedItem.getName());
} else {
// the table has not a schema
database = treePanel.getTreeStore().getParent(selectedItem);
resource = treePanel.getTreeStore().getParent(database);
dataInput.put("ResourceName", resource.getName());
dataInput.put("DatabaseName", database.getName());
dataInput.put("SchemaName", "");
dataInput.put("TableName", selectedItem.getName());
rootLogger.log(Level.INFO, "ResourceName: " + resource.getName());
rootLogger.log(Level.INFO, "DatabaseName: " + database.getName());
rootLogger.log(Level.INFO, "SchemaName: " + "");
rootLogger.log(Level.INFO, "SchemaName: " + selectedItem.getName());
}
// call remote service
RPCservice.sample(dataInput, new AsyncCallback<List<Result>>() {
@Override
public void onFailure(Throwable caught) {
// Window.alert(caught.getMessage());
// System.out.println("FAILURE");
rootLogger.log(Level.SEVERE, "FAILURE RPC sample");
MessageBox.alert("Error ",
"<br/>Message:" + caught.getMessage(), null);
}
@Override
public void onSuccess(List<Result> result) {
rootLogger.log(Level.SEVERE, "SUCCESS RPC sample");
rows = new ArrayList<Row>();
// System.out.println("result size: " + result.size());
rootLogger.log(Level.SEVERE, "output size: " + result.size());
// get the attributes list for the result table
getListAttributes(result.get(0).getValue());
// remove the header in order to parse only the result
result.remove(0);
// parse the result in order to obtain a table
parseResult(result);
}
});
}
// start the parsing of the submit result in order to obtain a table
private void parseResult(List<Result> result) {
RPCservice.parseCVSString(result, listAttributes,
new AsyncCallback<List<Row>>() {
@ -483,73 +621,90 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// TODO Auto-generated method stub
Window.alert(caught.getMessage());
// System.out.println("FAILURE StartParse");
// System.out.println("FAILURE StartParse");
rootLogger.log(Level.SEVERE, "FAILURE RPC parseResult");
}
@Override
public void onSuccess(List<Row> rows) {
// System.out.println("Success StartParse");
// System.out.println("Success StartParse");
rootLogger.log(Level.SEVERE, "SUCCESS RPC parseResult");
if (rows != null) {
if (submitQueryEventManaged == true) {
Dialog form = toolbar.getDialogForm();
if (form.isMasked())
form.unmask();
form.hide();
form.hide();
// Display the submit query result as a table
Dialog submitResult = new Dialog();
submitResult.setLayout(new FitLayout());
submitResult.setHeading("Result");
}
// else {
submitResult.setResizable(false);
// submitResult.setHeading("Submit Query");
// submitResult.setWidth(290);
// submitResult.setHeight(250);
if (rows != null) {
submitResult.setModal(true);
submitResult.setBlinkModal(true);
// Dialog form = toolbar.getDialogForm();
//
// if (form.isMasked())
// form.unmask();
//
// form.hide();
// submitResult.setBodyStyle("padding:9px;");
submitResult.setSize(600, 400);
// submitResult.setScrollMode(Scroll.AUTO);
submitResult.setScrollMode(Scroll.NONE);
submitResult.setHideOnButtonClick(true);
// Display the submit query result as a table
Dialog submitResult = new Dialog();
submitResult.setLayout(new FitLayout());
submitResult.setHeading("Result");
submitResult.setMaximizable(true);
// submitResult.addText("Result Table");
submitResult.setResizable(false);
// submitResult.setHeading("Submit Query");
// submitResult.setWidth(290);
// submitResult.setHeight(250);
ListStore<Row> store = new ListStore<Row>();
store.add(rows);
submitResult.setModal(true);
submitResult.setBlinkModal(true);
Grid<Row> grid;
// submitResult.setBodyStyle("padding:9px;");
submitResult.setSize(600, 400);
// submitResult.setScrollMode(Scroll.AUTO);
submitResult.setScrollMode(Scroll.NONE);
submitResult.setHideOnButtonClick(true);
grid = new Grid<Row>(store, createColumnModel());
submitResult.setMaximizable(true);
// submitResult.addText("Result Table");
// grid.setAutoExpandColumn("value");
grid.setBorders(true);
ListStore<Row> store = new ListStore<Row>();
store.add(rows);
// grid.setAutoWidth(true);
Grid<Row> grid;
RowData data = new RowData(.5, 1);
data.setMargins(new Margins(6));
grid = new Grid<Row>(store, createColumnModel());
submitResult.add(grid, data);
// grid.setAutoExpandColumn("value");
grid.setBorders(true);
submitResult.show();
// grid.setAutoWidth(true);
}
RowData data = new RowData(.5, 1);
data.setMargins(new Margins(6));
submitResult.add(grid, data);
submitResult.show();
}
// }
}
});
@ -585,24 +740,23 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// recover attribute fields fo the result table
String headers = value;
// System.out.println("headers: " + headers);
// System.out.println("headers: " + headers);
rootLogger.log(Level.INFO, "Headers fields table: " + headers);
listAttributes = parseAttributesTableResult(headers);
// System.out.println("attributes number: " + listAttributes.size());
rootLogger.log(Level.INFO,
"attributes number: " + listAttributes.size());
// System.out.println("attributes number: " + listAttributes.size());
rootLogger.log(Level.INFO, "attributes number: " + listAttributes.size());
rootLogger.log(Level.INFO, "attributes list: ");
for (int i = 0; i < listAttributes.size(); i++) {
// System.out.println(listAttributes.get(i));
// System.out.println(listAttributes.get(i));
rootLogger.log(Level.INFO, "attribute: " + listAttributes.get(i));
}
@ -625,7 +779,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
for (int i = 0; i < listAttributes.size(); i++) {
// System.out.println("attribute: " + listAttributes.get(i));
// System.out.println("attribute: " + listAttributes.get(i));
rootLogger.log(Level.INFO, "attribute: " + listAttributes.get(i));
column = new ColumnConfig();
column.setId(listAttributes.get(i));
@ -702,16 +856,16 @@ public class GxtBorderLayoutPanel extends ContentPanel {
private void displayDBInfo(FileModel element) {
// System.out.println("GxtBorderLayout->displaying info");
// System.out.println("GxtBorderLayout->displaying info");
rootLogger.log(Level.INFO, "displaying info");
// LinkedHashMap<String, FileModel> data = element.getDBInfo();
List<Result> dataDB = element.getDBInfo();
// System.out.println("GxtBorderLayout->size info: " + dataDB.size());
// System.out.println("GxtBorderLayout->size info: " + dataDB.size());
rootLogger.log(Level.INFO, "info size: " + dataDB.size());
ListStore<Result> store = new ListStore<Result>();

View File

@ -1,7 +1,5 @@
package org.gcube.portlets.user.databasesmanager.client.panels;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
@ -59,7 +57,7 @@ public class GxtTreePanel extends LayoutContainer {
private String TableNameSelected;
private LinkedHashMap<String, String> infoOnSelectedItem;
private static Logger rootLogger = Logger.getLogger("GxtTreePanel");
public GxtTreePanel(HandlerManager eBus, GWTdbManagerServiceAsync service)
@ -151,7 +149,7 @@ public class GxtTreePanel extends LayoutContainer {
public void selectionChanged(
SelectionChangedEvent<FileModel> se) {
// System.out.println("SelectionChangedListener");
// System.out.println("SelectionChangedListener");
dataDBInfo = null;
@ -174,22 +172,28 @@ public class GxtTreePanel extends LayoutContainer {
// element
// selected
FileModel selectedItem = data.get(0);
value = data.get(0).get("name");
// System.out.println("GxtTreePanel Value: "
// + data.get(0).get("name"));
rootLogger.log(Level.INFO, "GxtTreePanel-> selectedItem value: " + value);
// System.out.println("GxtTreePanel Value: "
// + data.get(0).get("name"));
// System.out.println("GxtTreePanel Depth: "
// + store.getDepth(data.get(0)));
rootLogger.log(Level.INFO,
"GxtTreePanel-> selectedItem value: " + value);
// System.out.println("GxtTreePanel Depth: "
// + store.getDepth(data.get(0)));
treeDepthSelectedItem = store.getDepth(data.get(0));
// rootLogger.log(Level.INFO, "GxtTreePanel-> selectedItem level depth: " + treeDepthSelectedItem);
rootLogger.log(Level.INFO, "selectedItem level depth: " + treeDepthSelectedItem);
// rootLogger.log(Level.INFO,
// "GxtTreePanel-> selectedItem level depth: " +
// treeDepthSelectedItem);
rootLogger.log(Level.INFO, "selectedItem level depth: "
+ treeDepthSelectedItem);
int numChildrenFolder = store.getChildCount(data.get(0));
// recover the appropriate information whenever an
@ -197,9 +201,12 @@ public class GxtTreePanel extends LayoutContainer {
setInfoOnSelectedItem(data.get(0));
// check to make the RPC call once
if ((numChildrenFolder == 0)
&& (data.get(0).isLoaded() != true)) {
treePanel.mask("Loading", "x-mask-loading");
// selectedItem.setIsSchema(false);
switch (treeDepthSelectedItem) {
// case 1:
@ -208,19 +215,26 @@ public class GxtTreePanel extends LayoutContainer {
// break;
case 2:
// selectedItem.setIsSchema(false);
loadDBInfo(data.get(0));
break;
case 3:
// selectedItem.setIsSchema(false);
loadSchema(data.get(0));
break;
case 4:
// selectedItem.setIsSchema(false);
loadTables(data.get(0));
break;
}
}
else{
setInfoOnSelectedItem(data.get(0));
}
// fire event
eventBus.fireEvent(new SelectedItemEvent());
@ -232,10 +246,9 @@ public class GxtTreePanel extends LayoutContainer {
private void loadRootItemTree() throws Exception {
// treePanel.mask("Loading", "x-mask-loading");
// treePanel.mask("Loading", "x-mask-loading");
this.mask("Loading", "x-mask-loading");
final FileModel root = new FileModel("Resources");
store.insert(root, 0, true);
@ -259,9 +272,10 @@ public class GxtTreePanel extends LayoutContainer {
private void loadResources(final FileModel element, final GxtTreePanel tree) {
// System.out.println("Start RPC - getResources");
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> Start RPC - getResource");
// System.out.println("Start RPC - getResources");
// rootLogger.log(Level.SEVERE,
// "GxtTreePanel-> Start RPC - getResource");
rootLogger.log(Level.SEVERE, "Start RPC - getResource");
// call remote service
@ -271,40 +285,45 @@ public class GxtTreePanel extends LayoutContainer {
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
// System.out.println("FAILURE");
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> FAILURE RPC getResource");
// Window.alert(caught.getMessage());
// System.out.println("FAILURE");
// rootLogger.log(Level.SEVERE,
// "GxtTreePanel-> FAILURE RPC getResource");
rootLogger.log(Level.SEVERE, "FAILURE RPC getResource");
MessageBox.alert("Error ","<br/>Message:"+caught.getMessage(), null);
MessageBox.alert("Error ",
"<br/>Message:" + caught.getMessage(), null);
}
@Override
public void onSuccess(List<FileModel> result) {
if (tree.isMasked())
tree.unmask();
// if (treePanel.isMasked())
// treePanel.unmask();
// if (treePanel.isMasked())
// treePanel.unmask();
// System.out.println("SUCCESS");
// rootLogger.log(Level.SEVERE,
// "GxtTreePanel-> SUCCESS RPC getResource");
// System.out.println("SUCCESS");
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> SUCCESS RPC getResource");
rootLogger.log(Level.SEVERE, "SUCCESS RPC getResource");
// print check
for (int i = 0; i < result.size(); i++) {
// System.out.println(result.get(i).getName());
// rootLogger.log(Level.INFO, "GxtTreePanel-> Resource: " + result.get(i).getName());
rootLogger.log(Level.INFO, "Resource: " + result.get(i).getName());
// System.out.println(result.get(i).getName());
// rootLogger.log(Level.INFO, "GxtTreePanel-> Resource: " +
// result.get(i).getName());
rootLogger.log(Level.INFO, "Resource: "
+ result.get(i).getName());
}
@ -318,21 +337,20 @@ public class GxtTreePanel extends LayoutContainer {
});
// System.out.println("End RPC - getResources");
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> End RPC - getResource");
// System.out.println("End RPC - getResources");
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> End RPC - getResource");
rootLogger.log(Level.SEVERE, "End RPC - getResource");
}
private void loadDBInfo(final FileModel element) {
// System.out.println("Start RPC - getDBInfo");
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> Start RPC - getDBInfo");
// System.out.println("Start RPC - getDBInfo");
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> Start RPC - getDBInfo");
rootLogger.log(Level.SEVERE, "Start RPC - getDBInfo");
// call remote service
@ -342,15 +360,16 @@ public class GxtTreePanel extends LayoutContainer {
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
// System.out.println("FAILURE");
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> FAILURE RPC getDBInfo");
// Window.alert(caught.getMessage());
// System.out.println("FAILURE");
// rootLogger.log(Level.SEVERE,
// "GxtTreePanel-> FAILURE RPC getDBInfo");
rootLogger.log(Level.SEVERE, "FAILURE RPC getDBInfo");
MessageBox.alert("Error ","<br/>Message:"+caught.getMessage(), null);
MessageBox.alert("Error ",
"<br/>Message:" + caught.getMessage(), null);
}
@ -361,10 +380,11 @@ public class GxtTreePanel extends LayoutContainer {
if (treePanel.isMasked())
treePanel.unmask();
// System.out.println("SUCCESS");
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> SUCCESS RPC getDBInfo");
// System.out.println("SUCCESS");
// rootLogger.log(Level.SEVERE,
// "GxtTreePanel-> SUCCESS RPC getDBInfo");
rootLogger.log(Level.SEVERE, "SUCCESS RPC getDBInfo");
if (result.size() != 0) {
@ -375,7 +395,8 @@ public class GxtTreePanel extends LayoutContainer {
Object[] array = keys.toArray();
// System.out.println("array size: " + array.length);
// System.out.println("array size: " +
// array.length);
// recover information for each database
@ -452,7 +473,7 @@ public class GxtTreePanel extends LayoutContainer {
}
FileModel child = new FileModel(DBName);
child.setIsDatabase(true);
child.setDBInfo(DBInfo);
@ -465,13 +486,18 @@ public class GxtTreePanel extends LayoutContainer {
}
// System.out.println("children number: "
// + store.getChildCount(element));
// rootLogger.log(Level.INFO, "GxtTreePanel-> children number: " + store.getChildCount(element));
rootLogger.log(Level.INFO, "children number: " + store.getChildCount(element));
// System.out.println("children number: "
// + store.getChildCount(element));
// rootLogger.log(Level.INFO,
// "GxtTreePanel-> children number: " +
// store.getChildCount(element));
rootLogger.log(
Level.INFO,
"children number: "
+ store.getChildCount(element));
element.setIsLoaded(true);
// // fire event
@ -481,20 +507,21 @@ public class GxtTreePanel extends LayoutContainer {
});
// System.out.println("End RPC - getDBInfo");
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> End RPC - getDBInfo");
// System.out.println("End RPC - getDBInfo");
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> End RPC - getDBInfo");
rootLogger.log(Level.SEVERE, "End RPC - getDBInfo");
}
private void loadSchema(final FileModel element) {
// System.out.println("Start RPC - getSchema");
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> Start RPC - getDBSchema");
// System.out.println("Start RPC - getSchema");
// rootLogger.log(Level.SEVERE,
// "GxtTreePanel-> Start RPC - getDBSchema");
rootLogger.log(Level.SEVERE, "Start RPC - getDBSchema");
// recover data inputs
@ -512,36 +539,41 @@ public class GxtTreePanel extends LayoutContainer {
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
// System.out.println("FAILURE");
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> FAILURE RPC getDBSchema");
// Window.alert(caught.getMessage());
// System.out.println("FAILURE");
// rootLogger.log(Level.SEVERE,
// "GxtTreePanel-> FAILURE RPC getDBSchema");
rootLogger.log(Level.SEVERE, "FAILURE RPC getDBSchema");
MessageBox.alert("Error ","<br/>Message:"+caught.getMessage(), null);
MessageBox.alert("Error ",
"<br/>Message:" + caught.getMessage(), null);
}
@Override
public void onSuccess(List<FileModel> result) {
if (treePanel.isMasked())
treePanel.unmask();
// System.out.println("SUCCESS");
// rootLogger.log(Level.SEVERE,
// "GxtTreePanel-> SUCCESS RPC getDBSchema");
// System.out.println("SUCCESS");
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> SUCCESS RPC getDBSchema");
rootLogger.log(Level.SEVERE, "SUCCESS RPC getDBSchema");
if (result.size() == 0) { // the database has not schema
// element.setIsSchema(false);
// element.setIsLoaded(false);
loadTables(element);
} else {
if (treePanel.isMasked())
treePanel.unmask();
// // print check
// for (int i = 0; i < result.size(); i++) {
@ -563,40 +595,90 @@ public class GxtTreePanel extends LayoutContainer {
}
});
// System.out.println("End RPC - getSchema");
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> End RPC - getDBSchema");
// System.out.println("End RPC - getSchema");
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> End RPC - getDBSchema");
rootLogger.log(Level.SEVERE, "End RPC - getDBSchema");
}
private void loadTables(final FileModel element) {
// System.out.println("Start RPC - getTables");
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> Start RPC - getTables");
// System.out.println("Start RPC - getTables");
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> Start RPC - getTables");
rootLogger.log(Level.SEVERE, "Start RPC - getTables");
// recover data inputs
LinkedHashMap<String, String> dataInput = new LinkedHashMap<String, String>();
FileModel parent = store.getParent(element);
FileModel parent1 = store.getParent(parent);
// check if the element is a schema or a database
// System.out.println("element is a schema: " + element.isSchema());
//
// if (element.isSchema()) {
//
// System.out.println("element is a schema: " + element.isSchema());
//
// FileModel database = store.getParent(element);
// FileModel resource = store.getParent(database);
//
// dataInput.put("ResourceName", resource.getName());
// dataInput.put("DatabaseName", database.getName());
// dataInput.put("SchemaName", element.getName());
//
// System.out.println("schema name: " + element.getName());
//
// rootLogger.log(Level.INFO, "ResourceName: " + resource.getName());
// rootLogger.log(Level.INFO, "DatabaseName: " + database.getName());
// rootLogger.log(Level.INFO, "SchemaName: " + element.getName());
//
// // System.out.println(parent1.getName());
// // System.out.println(parent.getName());
// // System.out.println(element.getName());
//
// }
//
// if (element.isDatabase()) {
//
// System.out.println("element is a database: " + element.isDatabase());
//
// FileModel resource = store.getParent(element);
// // FileModel parent1 = store.getParent(parent);
//
// dataInput.put("ResourceName", resource.getName());
// dataInput.put("DatabaseName", element.getName());
// dataInput.put("SchemaName", "");
//
// rootLogger.log(Level.INFO, "ResourceName: " + resource.getName());
// rootLogger.log(Level.INFO, "DatabaseName: " + element.getName());
// rootLogger.log(Level.INFO, "SchemaName: " + "");
//
// // System.out.println(parent1.getName());
// // System.out.println(parent.getName());
// // System.out.println(element.getName());
//
// }
FileModel database = store.getParent(element);
FileModel resource = store.getParent(database);
dataInput.put("ResourceName", parent1.getName());
dataInput.put("DatabaseName", parent.getName());
dataInput.put("ResourceName", resource.getName());
dataInput.put("DatabaseName", database.getName());
dataInput.put("SchemaName", element.getName());
rootLogger.log(Level.INFO, "ResourceName: " + parent1.getName());
rootLogger.log(Level.INFO, "DatabaseName: " + parent.getName());
System.out.println("schema name: " + element.getName());
rootLogger.log(Level.INFO, "ResourceName: " + resource.getName());
rootLogger.log(Level.INFO, "DatabaseName: " + database.getName());
rootLogger.log(Level.INFO, "SchemaName: " + element.getName());
// System.out.println(parent1.getName());
// System.out.println(parent.getName());
// System.out.println(element.getName());
// System.out.println(parent1.getName());
// System.out.println(parent.getName());
// System.out.println(element.getName());
// call remote service
@ -604,11 +686,25 @@ public class GxtTreePanel extends LayoutContainer {
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
// System.out.println("FAILURE");
// Window.alert(caught.getMessage());
// System.out.println("FAILURE");
rootLogger.log(Level.SEVERE, "FAILURE RPC getTables");
MessageBox.alert("Error ","<br/>Message:"+caught.getMessage(), null);
// no tables are available
if (caught.getMessage().equals(
"java.lang.Exception: Result not available")) {
element.setIsExpanded(false);
treePanel.setExpanded(element, false);
if (treePanel.isMasked())
treePanel.unmask();
}
// MessageBox.alert("Error ","<br/>Message:"+caught.getMessage(),
// null);
}
@ -618,14 +714,14 @@ public class GxtTreePanel extends LayoutContainer {
if (treePanel.isMasked())
treePanel.unmask();
// System.out.println("SUCCESS");
// System.out.println("SUCCESS");
rootLogger.log(Level.SEVERE, "SUCCESS RPC getTables");
if (result.size() == 0) { // the database has not tables
// System.out.println("the database has not tables");
// System.out.println("the database has not tables");
rootLogger.log(Level.SEVERE, "the database has not tables");
// loadTables(element);
@ -638,15 +734,23 @@ public class GxtTreePanel extends LayoutContainer {
for (int i = 0; i < result.size(); i++) {
result.get(i).setIsExpanded(false);
result.get(i).setIsLoaded(true);
// System.out.println(result.get(i).getName());
rootLogger.log(Level.INFO, "table: " + result.get(i).getName());
result.get(i).setIsLoaded(true);
result.get(i).setIsSchema(false);
// element.setIsLoaded(true);
// System.out.println(result.get(i).getName());
rootLogger.log(Level.INFO, "table: "
+ result.get(i).getName());
}
// int numChildrenFolder = store.getChildCount(element);
// int numChildrenFolder = store.getChildCount(element);
// if (numChildrenFolder == 0) {
@ -657,12 +761,11 @@ public class GxtTreePanel extends LayoutContainer {
element.setIsLoaded(true);
}
});
// System.out.println("End RPC - getTables");
// System.out.println("End RPC - getTables");
rootLogger.log(Level.SEVERE, "End RPC getTables");
}
@ -689,8 +792,8 @@ public class GxtTreePanel extends LayoutContainer {
store.add(parent, children, true);
// System.out.println("Added children in store");
// System.out.println("Added children in store");
rootLogger.log(Level.INFO, "Added children in store");
}
}
@ -730,8 +833,8 @@ public class GxtTreePanel extends LayoutContainer {
// a
// schema
// System.out.println("is a schema");
// System.out.println("is a schema");
rootLogger.log(Level.SEVERE, "setInfo for selected item schema");
SelectedItemIsSchema = true;
@ -766,8 +869,8 @@ public class GxtTreePanel extends LayoutContainer {
// mysql
// type
// System.out.println("is a table");
// System.out.println("is a table");
rootLogger.log(Level.SEVERE, "setInfo for selected item table");
// recover table name
@ -790,8 +893,8 @@ public class GxtTreePanel extends LayoutContainer {
// so the database is
// postgres type
// System.out.println("is a table");
// System.out.println("is a table");
rootLogger.log(Level.SEVERE, "setInfo for selected item table");
// recover table name
@ -818,8 +921,8 @@ public class GxtTreePanel extends LayoutContainer {
} else if (treeDepthSelectedItem == 3) { // the selected item is a
// database
// System.out.println("is a database");
// System.out.println("is a database");
rootLogger.log(Level.SEVERE, "setInfo for selected item database");
// recover database name

View File

@ -7,6 +7,7 @@ import java.util.logging.Logger;
import org.gcube.portlets.user.databasesmanager.client.GWTdbManagerServiceAsync;
import org.gcube.portlets.user.databasesmanager.client.datamodel.SubmitQueryData;
import org.gcube.portlets.user.databasesmanager.client.events.SamplingEvent;
import org.gcube.portlets.user.databasesmanager.client.events.SubmitQueryEvent;
import org.gcube.portlets.user.databasesmanager.client.form.GxtFormSubmitQuery;
import org.gcube.portlets.user.databasesmanager.client.utils.ConstantsPortlet;
@ -211,26 +212,32 @@ public class GxtToolbarFunctionality {
public void componentSelected(ButtonEvent ce) {
// TODO Auto-generated method stub
// TODO: insert the result of the sample operation
// TODO: manage the exception case (returned from
// algorithm "Simple Sample") with an alert
// System.out.println("simple sample event");
Dialog d = new Dialog();
d.setHeading("Simple Sample");
// d.setBodyStyle("fontWeight:bold;padding:13px;");
d.setBodyStyle("padding:9px;");
d.setSize(600, 400);
d.setScrollMode(Scroll.AUTO);
d.setHideOnButtonClick(true);
d.setModal(true);
d.setMaximizable(true);
d.addText("Result Table 1");
d.show();
//fire event
eventBus.fireEvent(new SamplingEvent());
// // TODO: insert the result of the sample operation
//
// // TODO: manage the exception case (returned from
// // algorithm "Simple Sample") with an alert
//
// // System.out.println("simple sample event");
//
// Dialog d = new Dialog();
// d.setHeading("Simple Sample");
//
// // d.setBodyStyle("fontWeight:bold;padding:13px;");
//
// d.setBodyStyle("padding:9px;");
// d.setSize(600, 400);
// d.setScrollMode(Scroll.AUTO);
// d.setHideOnButtonClick(true);
// d.setModal(true);
// d.setMaximizable(true);
// d.addText("Result Table 1");
// d.show();
}

View File

@ -1,7 +1,5 @@
package org.gcube.portlets.user.databasesmanager.server;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
@ -465,10 +463,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// retrieve data
// System.out.println("output data retrieved");
// System.out.println("output data retrieved");
// System.out.println("size outputMap: " + outputMap.size());
// System.out.println("size outputMap: " + outputMap.size());
rootLogger.log(Level.SEVERE, "output data retrieved");
rootLogger.log(Level.SEVERE, "output data size: " + outputMap.size());
@ -501,6 +499,84 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
}
@Override
public List<Result> sample(LinkedHashMap<String, String> dataInput)
throws Exception {
List<Parameter> inputParameters = new ArrayList<Parameter>();
// sample result
List<Result> output = new ArrayList<Result>();
// get list of algorithms
List<String> algorithms = new ArrayList<String>();
algorithms = getDatabaseManagerAlgorithms();
// get algorithmId
String algorithmId = null;
for (int i = 0; i < algorithms.size(); i++) {
if (algorithms.get(i).equals("SAMPLEONTABLE")) {
algorithmId = algorithms.get(i);
// System.out.println("algorithmId: " + algorithmId);
rootLogger.log(Level.SEVERE, "algorithmId: " + algorithmId);
}
}
// get input parameters of the algorithm
rootLogger.log(Level.SEVERE, "getting input parameters");
inputParameters = getParameters(algorithmId);
for (int i = 0; i < inputParameters.size(); i++) {
// System.out.println(inputParameters.get(i).getName());
rootLogger.log(Level.INFO, inputParameters.get(i).getName());
}
inputParameters.get(0).setValue(dataInput.get("ResourceName"));
inputParameters.get(1).setValue(dataInput.get("DatabaseName"));
inputParameters.get(2).setValue(dataInput.get("SchemaName"));
inputParameters.get(3).setValue(dataInput.get("TableName"));
// System.out.println("size outputMap pre computation: "
// + outputMap.size());
String computationId = startComputation(algorithmId, inputParameters);
// retrieve data
// System.out.println("output data retrieved");
// System.out.println("size outputMap: " + outputMap.size());
rootLogger.log(Level.SEVERE, "output data retrieved");
rootLogger.log(Level.SEVERE, "output data size: " + outputMap.size());
for (int i = 0; i < outputMap.size(); i++) {
Result row = new Result(outputKey.get(String.valueOf(i)),
outputMap.get(String.valueOf(i)));
output.add(row);
}
return output;
}
public List<Row> parseCVSString(List<Result> result, List<String> attrNames)
throws Exception {
@ -557,7 +633,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
String delimiter = ",";
// System.out.println("row: " + row);
// System.out.println("row: " + row);
List<String> elements = new ArrayList<String>();
String phrase = row;
@ -602,7 +678,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
elements.add(phrase);
// System.out.println("size: " + elements.size());
// System.out.println("size: " + elements.size());
return elements;
@ -617,10 +693,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
SMListGroupedAlgorithms groups = factory.getAlgorithms();
if (groups == null)
// System.out.println("GROUPS OF ALGORITHMS IS NULL!");
rootLogger.log(Level.SEVERE,"GROUPS OF ALGORITHMS IS NULL!");
// System.out.println("GROUPS OF ALGORITHMS IS NULL!");
rootLogger.log(Level.SEVERE, "GROUPS OF ALGORITHMS IS NULL!");
else
// System.out.println("GROUPS OF ALGORITHMS IS NOT NULL!");
// System.out.println("GROUPS OF ALGORITHMS IS NOT NULL!");
rootLogger.log(Level.SEVERE, "GROUPS OF ALGORITHMS IS NOT NULL!");
// get list categories
@ -662,23 +738,20 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
String defaultValue = smParam.defaultValue();
String objectType = smType.values().get(0);
// System.out.println("GWTdbManagerServiceImpl->parameters");
//CHECK
// rootLogger.log(Level.INFO, "parameters: ");
// rootLogger.log(Level.INFO, paramName);
// rootLogger.log(Level.INFO, paramDescription);
// rootLogger.log(Level.INFO, objectType);
// rootLogger.log(Level.INFO, defaultValue);
// System.out.println("GWTdbManagerServiceImpl->parameters");
// System.out.println(paramName);
// System.out.println(paramDescription);
// System.out.println(objectType);
// System.out.println(defaultValue);
// CHECK
// rootLogger.log(Level.INFO, "parameters: ");
// rootLogger.log(Level.INFO, paramName);
// rootLogger.log(Level.INFO, paramDescription);
// rootLogger.log(Level.INFO, objectType);
// rootLogger.log(Level.INFO, defaultValue);
// System.out.println(paramName);
// System.out.println(paramDescription);
// System.out.println(objectType);
// System.out.println(defaultValue);
Parameter objectParam = new Parameter(paramName, paramDescription,
objectType, defaultValue);
@ -727,7 +800,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
} catch (Exception e) {
// e.printStackTrace();
// e.printStackTrace();
throw e;
}
}
@ -751,8 +824,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
if (status == SMOperationStatus.RUNNING) {
// System.out.println("GWTdbManagerServiceImpl->RUNNING");
// System.out.println("GWTdbManagerServiceImpl->RUNNING");
rootLogger.log(Level.SEVERE, "RUNNING");
SMOperationInfo infos = factory.getComputationInfo(computationId,
@ -766,41 +839,42 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
} else if ((status == SMOperationStatus.COMPLETED)
|| (status == SMOperationStatus.FAILED)) {
// System.out.println("GWTdbManagerServiceImpl->COMPLETED OR FAILED");
// System.out.println("GWTdbManagerServiceImpl->COMPLETED OR FAILED");
rootLogger.log(Level.SEVERE, "COMPLETED OR FAILED");
SMAbstractResource abstractResource = computation
.abstractResource();
SMResource smResource = abstractResource.resource();
int resourceTypeIndex = smResource.resourceType();
SMResourceType smResType = SMResourceType.values()[resourceTypeIndex];
//TODO: ECXEPTION MANAGEMENT
// if (SMResourceType.ERROR){
//
//
// }
//throws(smResource.description());
// TODO: ECXEPTION MANAGEMENT
// if (SMResourceType.ERROR){
//
//
// }
// throws(smResource.description());
displayOutput(smResource, smResType);
// System.out.println("GWTdbManagerServiceImpl-> SM resource Name: "
// + smResource.name());
rootLogger.log(Level.SEVERE, "SM resource Name: " + smResource.name());
// System.out.println("GWTdbManagerServiceImpl-> SM resource ID: "
// + smResource.resourceId());
rootLogger.log(Level.SEVERE, "SM resource ID: " + smResource.resourceId());
// System.out
// .println("GWTdbManagerServiceImpl-> SM resource Description: "
// + smResource.description());
rootLogger.log(Level.SEVERE, "SM resource Description: " + smResource.description());
// System.out.println("GWTdbManagerServiceImpl-> SM resource Name: "
// + smResource.name());
rootLogger.log(Level.SEVERE,
"SM resource Name: " + smResource.name());
// System.out.println("GWTdbManagerServiceImpl-> SM resource ID: "
// + smResource.resourceId());
rootLogger.log(Level.SEVERE,
"SM resource ID: " + smResource.resourceId());
// System.out
// .println("GWTdbManagerServiceImpl-> SM resource Description: "
// + smResource.description());
rootLogger.log(Level.SEVERE, "SM resource Description: "
+ smResource.description());
percentage = 100;
}
@ -811,8 +885,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
private void displayOutput(SMResource smResource, SMResourceType smResType)
throws Exception {
// System.out.println("displayOutput");
// System.out.println("displayOutput");
rootLogger.log(Level.SEVERE, "displayOutput");
outputMap = new LinkedHashMap<String, String>();
@ -827,25 +901,25 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// case OBJECT:
SMObject objRes = (SMObject) smResource;
if (objRes.name().contentEquals(PrimitiveTypes.MAP.toString())) {
// System.out.println("Output is a map");
// System.out.println("Output is a map");
rootLogger.log(Level.SEVERE, "Output is a map");
// Map<String, String> outputMap = getMap(objRes);
this.outputMap = (LinkedHashMap<String, String>) getMap(objRes);
} else if (objRes.name().contentEquals(
PrimitiveTypes.IMAGES.toString())) {
// System.out.println("Output are images");
// System.out.println("Output are images");
rootLogger.log(Level.SEVERE, "Output are images");
} else
// System.out.println("Output is other");
// System.out.println("Output is other");
rootLogger.log(Level.SEVERE, "Output is other");
}
//EXCEPTION MANAGEMENT
if(smResType.equals(SMResourceType.ERROR)) {
// EXCEPTION MANAGEMENT
if (smResType.equals(SMResourceType.ERROR)) {
throw new Exception(smResource.description());
}
// break;
// case TABULAR:
@ -857,8 +931,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
private Map<String, String> getMap(SMObject objRes) throws Exception {
// System.out.println("getMap");
// System.out.println("getMap");
rootLogger.log(Level.SEVERE, "getMap");
outputKey = new LinkedHashMap<String, String>();
@ -895,24 +969,25 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
SMResource smres = smMap.get(key);
int resourceTypeIndex = smres.resourceType();
SMResourceType smsubResType = SMResourceType.values()[resourceTypeIndex];
// System.out.println("GWTdbManagerServiceImpl-> ResourceType:"
// + smsubResType);
// System.out.println("GWTdbManagerServiceImpl-> ResourceType:"
// + smsubResType);
rootLogger.log(Level.INFO, "ResourceType: " + smsubResType);
if (smsubResType == SMResourceType.OBJECT) {
SMObject obje = (SMObject) smres;
String outstring = obje.url();
// System.out.println("key :" + key);
// System.out.println("key :" + key);
rootLogger.log(Level.INFO, "key: " + smsubResType);
// System.out.println("Object:"
// + new String(outstring.getBytes(), "UTF-8"));
rootLogger.log(Level.INFO, "Object: " + new String(outstring.getBytes(), "UTF-8"));
// System.out.println("Object:"
// + new String(outstring.getBytes(), "UTF-8"));
rootLogger.log(Level.INFO,
"Object: " + new String(outstring.getBytes(), "UTF-8"));
// outputmap.put(key, outstring);
@ -922,9 +997,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
}
}
// System.out.println("Map retrieved with size: " + smMap.size());
rootLogger.log(Level.SEVERE, "Map retrieved with size: " + smMap.size());
// System.out.println("Map retrieved with size: " + smMap.size());
rootLogger
.log(Level.SEVERE, "Map retrieved with size: " + smMap.size());
return outputmap;
}
@ -955,4 +1031,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
}
}