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:
parent
0b85126f89
commit
e2c1826227
|
@ -33,6 +33,8 @@ public interface GWTdbManagerService extends RemoteService {
|
||||||
String query, boolean valueReadOnlyQuery,
|
String query, boolean valueReadOnlyQuery,
|
||||||
boolean smartCorrectionQuery, String language) throws Exception;
|
boolean smartCorrectionQuery, String language) throws Exception;
|
||||||
|
|
||||||
|
List<Result> sample(LinkedHashMap<String, String> dataInput) throws Exception;
|
||||||
|
|
||||||
List<Row> parseCVSString(List<Result> result, List<String> attrNames)
|
List<Row> parseCVSString(List<Result> result, List<String> attrNames)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
|
|
|
@ -33,4 +33,7 @@ public interface GWTdbManagerServiceAsync {
|
||||||
void parseCVSString(List<Result> result, List<String> attrNames,
|
void parseCVSString(List<Result> result, List<String> attrNames,
|
||||||
AsyncCallback<List<Row>> callback);
|
AsyncCallback<List<Row>> callback);
|
||||||
|
|
||||||
|
void sample(LinkedHashMap<String, String> dataInput,
|
||||||
|
AsyncCallback<List<Result>> callback);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ public enum EventsTypeEnum {
|
||||||
|
|
||||||
SELECTED_ITEM_EVENT,
|
SELECTED_ITEM_EVENT,
|
||||||
SUBMIT_QUERY_EVENT,
|
SUBMIT_QUERY_EVENT,
|
||||||
SHOW_CREATE_TABLE_EVENT;
|
SHOW_CREATE_TABLE_EVENT,
|
||||||
|
SAMPLING_EVENT;
|
||||||
|
|
||||||
}
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -1,7 +1,5 @@
|
||||||
package org.gcube.portlets.user.databasesmanager.client.panels;
|
package org.gcube.portlets.user.databasesmanager.client.panels;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
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.Result;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.Row;
|
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.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.SelectedItemEvent;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.events.SubmitQueryEvent;
|
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.SelectedItemEventHandler;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.events.interfaces.SubmitQueryEventHandler;
|
import org.gcube.portlets.user.databasesmanager.client.events.interfaces.SubmitQueryEventHandler;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.toolbar.GxtToolbarFunctionality;
|
import org.gcube.portlets.user.databasesmanager.client.toolbar.GxtToolbarFunctionality;
|
||||||
|
@ -76,6 +76,9 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
// RPC service
|
// RPC service
|
||||||
private GWTdbManagerServiceAsync RPCservice = null;
|
private GWTdbManagerServiceAsync RPCservice = null;
|
||||||
|
|
||||||
|
// variable that keeps track of the managed event
|
||||||
|
private boolean submitQueryEventManaged = false;
|
||||||
|
|
||||||
public GxtBorderLayoutPanel(HandlerManager eBus,
|
public GxtBorderLayoutPanel(HandlerManager eBus,
|
||||||
GWTdbManagerServiceAsync service) throws Exception {
|
GWTdbManagerServiceAsync service) throws Exception {
|
||||||
|
|
||||||
|
@ -97,6 +100,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
|
|
||||||
private void initLayout() {
|
private void initLayout() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
north.setLayout(new FitLayout());
|
north.setLayout(new FitLayout());
|
||||||
north.setTopComponent(toolbar.getToolBar());
|
north.setTopComponent(toolbar.getToolBar());
|
||||||
north.add(toolbar.getToolBar());
|
north.add(toolbar.getToolBar());
|
||||||
|
@ -252,7 +257,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//display the table name in the right panel when a table is selected
|
// display the table name in the right panel when a
|
||||||
|
// table is selected
|
||||||
|
|
||||||
if (DepthSelectedItem == 5) {
|
if (DepthSelectedItem == 5) {
|
||||||
|
|
||||||
|
@ -264,7 +270,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((DepthSelectedItem == 4) && (data.get(0).isSchema() == false)){
|
if ((DepthSelectedItem == 4)
|
||||||
|
&& (data.get(0).isSchema() == false)) {
|
||||||
|
|
||||||
centerUpper.removeAll();
|
centerUpper.removeAll();
|
||||||
|
|
||||||
|
@ -290,24 +297,44 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
public void onSubmitQuery(SubmitQueryEvent submitQueryEvent) {
|
public void onSubmitQuery(SubmitQueryEvent submitQueryEvent) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
|
// submitQuery();
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// // TODO Auto-generated catch block
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
|
||||||
submitQuery();
|
submitQuery();
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
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");
|
rootLogger.log(Level.SEVERE, "Start RPC - submitQuery");
|
||||||
|
|
||||||
|
// variable that keeps track of the managed event
|
||||||
|
submitQueryEventManaged = false;
|
||||||
|
|
||||||
// recover input data
|
// recover input data
|
||||||
|
|
||||||
LinkedHashMap<String, String> dataDB = treePanel
|
LinkedHashMap<String, String> dataDB = treePanel
|
||||||
|
@ -336,7 +363,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
// determine the dialect recovering the dialect
|
// determine the dialect recovering the dialect
|
||||||
dialect = selectedItem.getDBInfo().get(2).getValue();
|
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 {
|
} else {
|
||||||
FileModel parent1 = treePanel.getTreeStore()
|
FileModel parent1 = treePanel.getTreeStore()
|
||||||
|
@ -351,7 +379,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
// determine the dialect recovering the dialect
|
// determine the dialect recovering the dialect
|
||||||
dialect = parent1.getDBInfo().get(2).getValue();
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,7 +395,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
// determine the dialect recovering the dialect
|
// determine the dialect recovering the dialect
|
||||||
dialect = parent2.getDBInfo().get(2).getValue();
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,7 +414,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
language = ConstantsPortlet.MYSQL;
|
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,
|
RPCservice.submitQuery(dataDB, dataQuery.getQuery(), true,
|
||||||
dataQuery.getSmartCorrection(), language,
|
dataQuery.getSmartCorrection(), language,
|
||||||
|
@ -408,7 +439,9 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() {
|
Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() {
|
||||||
public void handleEvent(MessageBoxEvent ce) {
|
public void handleEvent(MessageBoxEvent ce) {
|
||||||
// Button btn = ce.getButtonClicked();
|
// Button btn = ce.getButtonClicked();
|
||||||
// Info.display("MessageBox", "The '{0}' button was pressed", btn.getHtml());
|
// Info.display("MessageBox",
|
||||||
|
// "The '{0}' button was pressed",
|
||||||
|
// btn.getHtml());
|
||||||
|
|
||||||
// Button btn = ce.getButtonClicked();
|
// Button btn = ce.getButtonClicked();
|
||||||
|
|
||||||
|
@ -417,14 +450,13 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
if (form.isMasked())
|
if (form.isMasked())
|
||||||
form.unmask();
|
form.unmask();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// MessageBox.alert("Error "," <br/>Cause:"+caught.getCause()+"<br/>Message:"+caught.getMessage(), l);
|
// MessageBox.alert("Error "," <br/>Cause:"+caught.getCause()+"<br/>Message:"+caught.getMessage(),
|
||||||
MessageBox.alert("Error ","<br/>Message:"+caught.getMessage(), l);
|
// l);
|
||||||
|
MessageBox.alert("Error ",
|
||||||
|
"<br/>Message:" + caught.getMessage(), l);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,15 +470,14 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
|
|
||||||
rows = new ArrayList<Row>();
|
rows = new ArrayList<Row>();
|
||||||
|
|
||||||
|
|
||||||
// System.out.println("result size: " + result.size());
|
// System.out.println("result size: " + result.size());
|
||||||
|
|
||||||
rootLogger.log(Level.SEVERE, "output size: " + result.size());
|
rootLogger.log(Level.SEVERE,
|
||||||
|
"output size: " + result.size());
|
||||||
|
|
||||||
// recover query
|
// recover query
|
||||||
// Result query = result.remove(0);
|
// Result query = result.remove(0);
|
||||||
|
|
||||||
|
|
||||||
// recover converted query
|
// recover converted query
|
||||||
Result convertedQuery;
|
Result convertedQuery;
|
||||||
|
|
||||||
|
@ -463,6 +494,111 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
// remove the header in order to parse only the result
|
// remove the header in order to parse only the result
|
||||||
result.remove(0);
|
result.remove(0);
|
||||||
|
|
||||||
|
// variable that keeps track of the managed event
|
||||||
|
submitQueryEventManaged = true;
|
||||||
|
|
||||||
|
// parse the result in order to obtain a table
|
||||||
|
parseResult(result);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
// parse the result in order to obtain a table
|
||||||
parseResult(result);
|
parseResult(result);
|
||||||
|
|
||||||
|
@ -475,6 +611,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
// start the parsing of the submit result in order to obtain a table
|
// start the parsing of the submit result in order to obtain a table
|
||||||
private void parseResult(List<Result> result) {
|
private void parseResult(List<Result> result) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RPCservice.parseCVSString(result, listAttributes,
|
RPCservice.parseCVSString(result, listAttributes,
|
||||||
new AsyncCallback<List<Row>>() {
|
new AsyncCallback<List<Row>>() {
|
||||||
|
|
||||||
|
@ -492,22 +630,37 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<Row> rows) {
|
public void onSuccess(List<Row> rows) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// System.out.println("Success StartParse");
|
// System.out.println("Success StartParse");
|
||||||
|
|
||||||
rootLogger.log(Level.SEVERE, "SUCCESS RPC parseResult");
|
rootLogger.log(Level.SEVERE, "SUCCESS RPC parseResult");
|
||||||
|
|
||||||
if (rows != null) {
|
if (submitQueryEventManaged == true) {
|
||||||
|
|
||||||
Dialog form = toolbar.getDialogForm();
|
Dialog form = toolbar.getDialogForm();
|
||||||
|
|
||||||
if (form.isMasked())
|
if (form.isMasked())
|
||||||
form.unmask();
|
form.unmask();
|
||||||
|
|
||||||
|
|
||||||
form.hide();
|
form.hide();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// else {
|
||||||
|
|
||||||
|
if (rows != null) {
|
||||||
|
|
||||||
|
// Dialog form = toolbar.getDialogForm();
|
||||||
|
//
|
||||||
|
// if (form.isMasked())
|
||||||
|
// form.unmask();
|
||||||
|
//
|
||||||
|
// form.hide();
|
||||||
|
|
||||||
// Display the submit query result as a table
|
// Display the submit query result as a table
|
||||||
Dialog submitResult = new Dialog();
|
Dialog submitResult = new Dialog();
|
||||||
submitResult.setLayout(new FitLayout());
|
submitResult.setLayout(new FitLayout());
|
||||||
|
@ -550,6 +703,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
submitResult.show();
|
submitResult.show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -591,11 +746,10 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
|
|
||||||
listAttributes = parseAttributesTableResult(headers);
|
listAttributes = parseAttributesTableResult(headers);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// System.out.println("attributes number: " + listAttributes.size());
|
// System.out.println("attributes number: " + listAttributes.size());
|
||||||
|
|
||||||
rootLogger.log(Level.INFO, "attributes number: " + listAttributes.size());
|
rootLogger.log(Level.INFO,
|
||||||
|
"attributes number: " + listAttributes.size());
|
||||||
|
|
||||||
rootLogger.log(Level.INFO, "attributes list: ");
|
rootLogger.log(Level.INFO, "attributes list: ");
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package org.gcube.portlets.user.databasesmanager.client.panels;
|
package org.gcube.portlets.user.databasesmanager.client.panels;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -174,21 +172,27 @@ public class GxtTreePanel extends LayoutContainer {
|
||||||
// element
|
// element
|
||||||
// selected
|
// selected
|
||||||
|
|
||||||
|
FileModel selectedItem = data.get(0);
|
||||||
|
|
||||||
value = data.get(0).get("name");
|
value = data.get(0).get("name");
|
||||||
|
|
||||||
// System.out.println("GxtTreePanel Value: "
|
// System.out.println("GxtTreePanel Value: "
|
||||||
// + data.get(0).get("name"));
|
// + data.get(0).get("name"));
|
||||||
|
|
||||||
rootLogger.log(Level.INFO, "GxtTreePanel-> selectedItem value: " + value);
|
rootLogger.log(Level.INFO,
|
||||||
|
"GxtTreePanel-> selectedItem value: " + value);
|
||||||
|
|
||||||
// System.out.println("GxtTreePanel Depth: "
|
// System.out.println("GxtTreePanel Depth: "
|
||||||
// + store.getDepth(data.get(0)));
|
// + store.getDepth(data.get(0)));
|
||||||
|
|
||||||
treeDepthSelectedItem = store.getDepth(data.get(0));
|
treeDepthSelectedItem = store.getDepth(data.get(0));
|
||||||
|
|
||||||
// rootLogger.log(Level.INFO, "GxtTreePanel-> selectedItem level depth: " + treeDepthSelectedItem);
|
// rootLogger.log(Level.INFO,
|
||||||
|
// "GxtTreePanel-> selectedItem level depth: " +
|
||||||
|
// treeDepthSelectedItem);
|
||||||
|
|
||||||
rootLogger.log(Level.INFO, "selectedItem level depth: " + treeDepthSelectedItem);
|
rootLogger.log(Level.INFO, "selectedItem level depth: "
|
||||||
|
+ treeDepthSelectedItem);
|
||||||
|
|
||||||
int numChildrenFolder = store.getChildCount(data.get(0));
|
int numChildrenFolder = store.getChildCount(data.get(0));
|
||||||
|
|
||||||
|
@ -197,9 +201,12 @@ public class GxtTreePanel extends LayoutContainer {
|
||||||
|
|
||||||
setInfoOnSelectedItem(data.get(0));
|
setInfoOnSelectedItem(data.get(0));
|
||||||
|
|
||||||
|
// check to make the RPC call once
|
||||||
if ((numChildrenFolder == 0)
|
if ((numChildrenFolder == 0)
|
||||||
&& (data.get(0).isLoaded() != true)) {
|
&& (data.get(0).isLoaded() != true)) {
|
||||||
|
|
||||||
treePanel.mask("Loading", "x-mask-loading");
|
treePanel.mask("Loading", "x-mask-loading");
|
||||||
|
// selectedItem.setIsSchema(false);
|
||||||
|
|
||||||
switch (treeDepthSelectedItem) {
|
switch (treeDepthSelectedItem) {
|
||||||
// case 1:
|
// case 1:
|
||||||
|
@ -208,20 +215,27 @@ public class GxtTreePanel extends LayoutContainer {
|
||||||
// break;
|
// break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
// selectedItem.setIsSchema(false);
|
||||||
loadDBInfo(data.get(0));
|
loadDBInfo(data.get(0));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
|
// selectedItem.setIsSchema(false);
|
||||||
loadSchema(data.get(0));
|
loadSchema(data.get(0));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
|
// selectedItem.setIsSchema(false);
|
||||||
loadTables(data.get(0));
|
loadTables(data.get(0));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else{
|
||||||
|
setInfoOnSelectedItem(data.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
// fire event
|
// fire event
|
||||||
eventBus.fireEvent(new SelectedItemEvent());
|
eventBus.fireEvent(new SelectedItemEvent());
|
||||||
|
|
||||||
|
@ -236,7 +250,6 @@ public class GxtTreePanel extends LayoutContainer {
|
||||||
|
|
||||||
this.mask("Loading", "x-mask-loading");
|
this.mask("Loading", "x-mask-loading");
|
||||||
|
|
||||||
|
|
||||||
final FileModel root = new FileModel("Resources");
|
final FileModel root = new FileModel("Resources");
|
||||||
store.insert(root, 0, true);
|
store.insert(root, 0, true);
|
||||||
|
|
||||||
|
@ -261,7 +274,8 @@ public class GxtTreePanel extends LayoutContainer {
|
||||||
|
|
||||||
// System.out.println("Start RPC - getResources");
|
// System.out.println("Start RPC - getResources");
|
||||||
|
|
||||||
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> Start RPC - getResource");
|
// rootLogger.log(Level.SEVERE,
|
||||||
|
// "GxtTreePanel-> Start RPC - getResource");
|
||||||
rootLogger.log(Level.SEVERE, "Start RPC - getResource");
|
rootLogger.log(Level.SEVERE, "Start RPC - getResource");
|
||||||
|
|
||||||
// call remote service
|
// call remote service
|
||||||
|
@ -271,14 +285,16 @@ public class GxtTreePanel extends LayoutContainer {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
|
|
||||||
Window.alert(caught.getMessage());
|
// Window.alert(caught.getMessage());
|
||||||
// System.out.println("FAILURE");
|
// System.out.println("FAILURE");
|
||||||
|
|
||||||
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> FAILURE RPC getResource");
|
// rootLogger.log(Level.SEVERE,
|
||||||
|
// "GxtTreePanel-> FAILURE RPC getResource");
|
||||||
|
|
||||||
rootLogger.log(Level.SEVERE, "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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,7 +309,8 @@ public class GxtTreePanel extends LayoutContainer {
|
||||||
|
|
||||||
// System.out.println("SUCCESS");
|
// System.out.println("SUCCESS");
|
||||||
|
|
||||||
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> SUCCESS RPC getResource");
|
// rootLogger.log(Level.SEVERE,
|
||||||
|
// "GxtTreePanel-> SUCCESS RPC getResource");
|
||||||
|
|
||||||
rootLogger.log(Level.SEVERE, "SUCCESS RPC getResource");
|
rootLogger.log(Level.SEVERE, "SUCCESS RPC getResource");
|
||||||
|
|
||||||
|
@ -302,9 +319,11 @@ public class GxtTreePanel extends LayoutContainer {
|
||||||
|
|
||||||
// System.out.println(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, "GxtTreePanel-> Resource: " +
|
||||||
|
// result.get(i).getName());
|
||||||
|
|
||||||
rootLogger.log(Level.INFO, "Resource: " + result.get(i).getName());
|
rootLogger.log(Level.INFO, "Resource: "
|
||||||
|
+ result.get(i).getName());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +352,6 @@ public class GxtTreePanel extends LayoutContainer {
|
||||||
|
|
||||||
rootLogger.log(Level.SEVERE, "Start RPC - getDBInfo");
|
rootLogger.log(Level.SEVERE, "Start RPC - getDBInfo");
|
||||||
|
|
||||||
|
|
||||||
// call remote service
|
// call remote service
|
||||||
|
|
||||||
RPCservice.getDBInfo(element.getName(),
|
RPCservice.getDBInfo(element.getName(),
|
||||||
|
@ -342,15 +360,16 @@ public class GxtTreePanel extends LayoutContainer {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
|
|
||||||
Window.alert(caught.getMessage());
|
// Window.alert(caught.getMessage());
|
||||||
// System.out.println("FAILURE");
|
// System.out.println("FAILURE");
|
||||||
|
|
||||||
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> FAILURE RPC getDBInfo");
|
// rootLogger.log(Level.SEVERE,
|
||||||
|
// "GxtTreePanel-> FAILURE RPC getDBInfo");
|
||||||
|
|
||||||
rootLogger.log(Level.SEVERE, "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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,7 +382,8 @@ public class GxtTreePanel extends LayoutContainer {
|
||||||
|
|
||||||
// System.out.println("SUCCESS");
|
// System.out.println("SUCCESS");
|
||||||
|
|
||||||
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> SUCCESS RPC getDBInfo");
|
// rootLogger.log(Level.SEVERE,
|
||||||
|
// "GxtTreePanel-> SUCCESS RPC getDBInfo");
|
||||||
|
|
||||||
rootLogger.log(Level.SEVERE, "SUCCESS RPC getDBInfo");
|
rootLogger.log(Level.SEVERE, "SUCCESS RPC getDBInfo");
|
||||||
|
|
||||||
|
@ -375,7 +395,8 @@ public class GxtTreePanel extends LayoutContainer {
|
||||||
|
|
||||||
Object[] array = keys.toArray();
|
Object[] array = keys.toArray();
|
||||||
|
|
||||||
// System.out.println("array size: " + array.length);
|
// System.out.println("array size: " +
|
||||||
|
// array.length);
|
||||||
|
|
||||||
// recover information for each database
|
// recover information for each database
|
||||||
|
|
||||||
|
@ -468,9 +489,14 @@ public class GxtTreePanel extends LayoutContainer {
|
||||||
// System.out.println("children number: "
|
// System.out.println("children number: "
|
||||||
// + store.getChildCount(element));
|
// + store.getChildCount(element));
|
||||||
|
|
||||||
// rootLogger.log(Level.INFO, "GxtTreePanel-> children number: " + store.getChildCount(element));
|
// rootLogger.log(Level.INFO,
|
||||||
|
// "GxtTreePanel-> children number: " +
|
||||||
|
// store.getChildCount(element));
|
||||||
|
|
||||||
rootLogger.log(Level.INFO, "children number: " + store.getChildCount(element));
|
rootLogger.log(
|
||||||
|
Level.INFO,
|
||||||
|
"children number: "
|
||||||
|
+ store.getChildCount(element));
|
||||||
|
|
||||||
element.setIsLoaded(true);
|
element.setIsLoaded(true);
|
||||||
|
|
||||||
|
@ -493,7 +519,8 @@ public class GxtTreePanel extends LayoutContainer {
|
||||||
|
|
||||||
// System.out.println("Start RPC - getSchema");
|
// System.out.println("Start RPC - getSchema");
|
||||||
|
|
||||||
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> Start RPC - getDBSchema");
|
// rootLogger.log(Level.SEVERE,
|
||||||
|
// "GxtTreePanel-> Start RPC - getDBSchema");
|
||||||
|
|
||||||
rootLogger.log(Level.SEVERE, "Start RPC - getDBSchema");
|
rootLogger.log(Level.SEVERE, "Start RPC - getDBSchema");
|
||||||
|
|
||||||
|
@ -512,37 +539,42 @@ public class GxtTreePanel extends LayoutContainer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
Window.alert(caught.getMessage());
|
// Window.alert(caught.getMessage());
|
||||||
// System.out.println("FAILURE");
|
// System.out.println("FAILURE");
|
||||||
|
|
||||||
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> FAILURE RPC getDBSchema");
|
// rootLogger.log(Level.SEVERE,
|
||||||
|
// "GxtTreePanel-> FAILURE RPC getDBSchema");
|
||||||
|
|
||||||
rootLogger.log(Level.SEVERE, "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
|
@Override
|
||||||
public void onSuccess(List<FileModel> result) {
|
public void onSuccess(List<FileModel> result) {
|
||||||
|
|
||||||
if (treePanel.isMasked())
|
|
||||||
treePanel.unmask();
|
|
||||||
|
|
||||||
// System.out.println("SUCCESS");
|
// System.out.println("SUCCESS");
|
||||||
|
|
||||||
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> SUCCESS RPC getDBSchema");
|
// rootLogger.log(Level.SEVERE,
|
||||||
|
// "GxtTreePanel-> SUCCESS RPC getDBSchema");
|
||||||
|
|
||||||
rootLogger.log(Level.SEVERE, "SUCCESS RPC getDBSchema");
|
rootLogger.log(Level.SEVERE, "SUCCESS RPC getDBSchema");
|
||||||
|
|
||||||
|
|
||||||
if (result.size() == 0) { // the database has not schema
|
if (result.size() == 0) { // the database has not schema
|
||||||
|
|
||||||
|
// element.setIsSchema(false);
|
||||||
|
// element.setIsLoaded(false);
|
||||||
loadTables(element);
|
loadTables(element);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
if (treePanel.isMasked())
|
||||||
|
treePanel.unmask();
|
||||||
|
|
||||||
// // print check
|
// // print check
|
||||||
// for (int i = 0; i < result.size(); i++) {
|
// for (int i = 0; i < result.size(); i++) {
|
||||||
// System.out.println(result.get(i).getName());
|
// System.out.println(result.get(i).getName());
|
||||||
|
@ -583,15 +615,65 @@ public class GxtTreePanel extends LayoutContainer {
|
||||||
|
|
||||||
LinkedHashMap<String, String> dataInput = new LinkedHashMap<String, String>();
|
LinkedHashMap<String, String> dataInput = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
FileModel parent = store.getParent(element);
|
// check if the element is a schema or a database
|
||||||
FileModel parent1 = store.getParent(parent);
|
|
||||||
|
|
||||||
dataInput.put("ResourceName", parent1.getName());
|
// System.out.println("element is a schema: " + element.isSchema());
|
||||||
dataInput.put("DatabaseName", parent.getName());
|
//
|
||||||
|
// 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", resource.getName());
|
||||||
|
dataInput.put("DatabaseName", database.getName());
|
||||||
dataInput.put("SchemaName", element.getName());
|
dataInput.put("SchemaName", element.getName());
|
||||||
|
|
||||||
rootLogger.log(Level.INFO, "ResourceName: " + parent1.getName());
|
System.out.println("schema name: " + element.getName());
|
||||||
rootLogger.log(Level.INFO, "DatabaseName: " + parent.getName());
|
|
||||||
|
rootLogger.log(Level.INFO, "ResourceName: " + resource.getName());
|
||||||
|
rootLogger.log(Level.INFO, "DatabaseName: " + database.getName());
|
||||||
rootLogger.log(Level.INFO, "SchemaName: " + element.getName());
|
rootLogger.log(Level.INFO, "SchemaName: " + element.getName());
|
||||||
|
|
||||||
// System.out.println(parent1.getName());
|
// System.out.println(parent1.getName());
|
||||||
|
@ -604,11 +686,25 @@ public class GxtTreePanel extends LayoutContainer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
Window.alert(caught.getMessage());
|
// Window.alert(caught.getMessage());
|
||||||
// System.out.println("FAILURE");
|
// System.out.println("FAILURE");
|
||||||
rootLogger.log(Level.SEVERE, "FAILURE RPC getTables");
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,11 +734,19 @@ public class GxtTreePanel extends LayoutContainer {
|
||||||
for (int i = 0; i < result.size(); i++) {
|
for (int i = 0; i < result.size(); i++) {
|
||||||
|
|
||||||
result.get(i).setIsExpanded(false);
|
result.get(i).setIsExpanded(false);
|
||||||
|
|
||||||
result.get(i).setIsLoaded(true);
|
result.get(i).setIsLoaded(true);
|
||||||
|
|
||||||
|
result.get(i).setIsSchema(false);
|
||||||
|
|
||||||
|
// element.setIsLoaded(true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// System.out.println(result.get(i).getName());
|
// System.out.println(result.get(i).getName());
|
||||||
|
|
||||||
rootLogger.log(Level.INFO, "table: " + result.get(i).getName());
|
rootLogger.log(Level.INFO, "table: "
|
||||||
|
+ result.get(i).getName());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,7 +761,6 @@ public class GxtTreePanel extends LayoutContainer {
|
||||||
|
|
||||||
element.setIsLoaded(true);
|
element.setIsLoaded(true);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.gcube.portlets.user.databasesmanager.client.GWTdbManagerServiceAsync;
|
import org.gcube.portlets.user.databasesmanager.client.GWTdbManagerServiceAsync;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.SubmitQueryData;
|
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.events.SubmitQueryEvent;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.form.GxtFormSubmitQuery;
|
import org.gcube.portlets.user.databasesmanager.client.form.GxtFormSubmitQuery;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.utils.ConstantsPortlet;
|
import org.gcube.portlets.user.databasesmanager.client.utils.ConstantsPortlet;
|
||||||
|
@ -211,26 +212,32 @@ public class GxtToolbarFunctionality {
|
||||||
public void componentSelected(ButtonEvent ce) {
|
public void componentSelected(ButtonEvent ce) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
// TODO: insert the result of the sample operation
|
|
||||||
|
|
||||||
// TODO: manage the exception case (returned from
|
//fire event
|
||||||
// algorithm "Simple Sample") with an alert
|
|
||||||
|
|
||||||
// System.out.println("simple sample event");
|
eventBus.fireEvent(new SamplingEvent());
|
||||||
|
|
||||||
Dialog d = new Dialog();
|
|
||||||
d.setHeading("Simple Sample");
|
|
||||||
|
|
||||||
// d.setBodyStyle("fontWeight:bold;padding:13px;");
|
// // TODO: insert the result of the sample operation
|
||||||
|
//
|
||||||
d.setBodyStyle("padding:9px;");
|
// // TODO: manage the exception case (returned from
|
||||||
d.setSize(600, 400);
|
// // algorithm "Simple Sample") with an alert
|
||||||
d.setScrollMode(Scroll.AUTO);
|
//
|
||||||
d.setHideOnButtonClick(true);
|
// // System.out.println("simple sample event");
|
||||||
d.setModal(true);
|
//
|
||||||
d.setMaximizable(true);
|
// Dialog d = new Dialog();
|
||||||
d.addText("Result Table 1");
|
// d.setHeading("Simple Sample");
|
||||||
d.show();
|
//
|
||||||
|
// // 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();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package org.gcube.portlets.user.databasesmanager.server;
|
package org.gcube.portlets.user.databasesmanager.server;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -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)
|
public List<Row> parseCVSString(List<Result> result, List<String> attrNames)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
|
@ -664,7 +740,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
// System.out.println("GWTdbManagerServiceImpl->parameters");
|
// System.out.println("GWTdbManagerServiceImpl->parameters");
|
||||||
|
|
||||||
|
|
||||||
// CHECK
|
// CHECK
|
||||||
// rootLogger.log(Level.INFO, "parameters: ");
|
// rootLogger.log(Level.INFO, "parameters: ");
|
||||||
|
|
||||||
|
@ -673,8 +748,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
// rootLogger.log(Level.INFO, objectType);
|
// rootLogger.log(Level.INFO, objectType);
|
||||||
// rootLogger.log(Level.INFO, defaultValue);
|
// rootLogger.log(Level.INFO, defaultValue);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// System.out.println(paramName);
|
// System.out.println(paramName);
|
||||||
// System.out.println(paramDescription);
|
// System.out.println(paramDescription);
|
||||||
// System.out.println(objectType);
|
// System.out.println(objectType);
|
||||||
|
@ -786,20 +859,21 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
// System.out.println("GWTdbManagerServiceImpl-> SM resource Name: "
|
// System.out.println("GWTdbManagerServiceImpl-> SM resource Name: "
|
||||||
// + smResource.name());
|
// + smResource.name());
|
||||||
|
|
||||||
rootLogger.log(Level.SEVERE, "SM resource Name: " + smResource.name());
|
rootLogger.log(Level.SEVERE,
|
||||||
|
"SM resource Name: " + smResource.name());
|
||||||
|
|
||||||
// System.out.println("GWTdbManagerServiceImpl-> SM resource ID: "
|
// System.out.println("GWTdbManagerServiceImpl-> SM resource ID: "
|
||||||
// + smResource.resourceId());
|
// + smResource.resourceId());
|
||||||
|
|
||||||
rootLogger.log(Level.SEVERE, "SM resource ID: " + smResource.resourceId());
|
rootLogger.log(Level.SEVERE,
|
||||||
|
"SM resource ID: " + smResource.resourceId());
|
||||||
|
|
||||||
// System.out
|
// System.out
|
||||||
// .println("GWTdbManagerServiceImpl-> SM resource Description: "
|
// .println("GWTdbManagerServiceImpl-> SM resource Description: "
|
||||||
// + smResource.description());
|
// + smResource.description());
|
||||||
|
|
||||||
rootLogger.log(Level.SEVERE, "SM resource Description: " + smResource.description());
|
rootLogger.log(Level.SEVERE, "SM resource Description: "
|
||||||
|
+ smResource.description());
|
||||||
|
|
||||||
|
|
||||||
percentage = 100;
|
percentage = 100;
|
||||||
|
|
||||||
|
@ -912,7 +986,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
// System.out.println("Object:"
|
// System.out.println("Object:"
|
||||||
// + new String(outstring.getBytes(), "UTF-8"));
|
// + new String(outstring.getBytes(), "UTF-8"));
|
||||||
|
|
||||||
rootLogger.log(Level.INFO, "Object: " + new String(outstring.getBytes(), "UTF-8"));
|
rootLogger.log(Level.INFO,
|
||||||
|
"Object: " + new String(outstring.getBytes(), "UTF-8"));
|
||||||
|
|
||||||
// outputmap.put(key, outstring);
|
// outputmap.put(key, outstring);
|
||||||
|
|
||||||
|
@ -924,7 +999,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
// System.out.println("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());
|
rootLogger
|
||||||
|
.log(Level.SEVERE, "Map retrieved with size: " + smMap.size());
|
||||||
return outputmap;
|
return outputmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -955,4 +1031,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue