exceptions management on algorithm input parameters

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@100094 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Loredana Liccardo 2014-09-22 09:10:07 +00:00
parent 6528b95a3b
commit 41bab2bbb1
5 changed files with 203 additions and 70 deletions

View File

@ -32,13 +32,13 @@ public interface GWTdbManagerService extends RemoteService {
boolean smartCorrectionQuery, String language, String UID)
throws Exception;
SamplingResultWithFileFromServlet sample(LinkedHashMap<String, String> dataInput)
SamplingResultWithFileFromServlet sample(LinkedHashMap<String, String> dataInput, String elementType)
throws Exception;
SamplingResultWithFileFromServlet smartSample(LinkedHashMap<String, String> dataInput)
SamplingResultWithFileFromServlet smartSample(LinkedHashMap<String, String> dataInput, String elementType)
throws Exception;
SamplingResultWithFileFromServlet randomSample(LinkedHashMap<String, String> dataInput)
SamplingResultWithFileFromServlet randomSample(LinkedHashMap<String, String> dataInput, String elementType)
throws Exception;
List<Row> parseCVSString(List<Result> result, List<String> attrNames)
@ -48,7 +48,7 @@ public interface GWTdbManagerService extends RemoteService {
LinkedHashMap<String, String> dataInput) throws Exception;
PagingLoadResult<Result> LoadTables(PagingLoadConfig config,
LinkedHashMap<String, String> dataInput, boolean SearchTable,
LinkedHashMap<String, String> dataInput, String elementType, boolean SearchTable,
String keyword) throws Exception;
PagingLoadResult<Row> loadSubmitResult(PagingLoadConfig config,

View File

@ -31,20 +31,20 @@ public interface GWTdbManagerServiceAsync {
void parseCVSString(List<Result> result, List<String> attrNames,
AsyncCallback<List<Row>> callback);
void sample(LinkedHashMap<String, String> dataInput,
void sample(LinkedHashMap<String, String> dataInput, String elementType,
AsyncCallback<SamplingResultWithFileFromServlet> callback);
void getTableDetails(LinkedHashMap<String, String> dataInput,
AsyncCallback<LinkedHashMap<String, FileModel>> callback);
void smartSample(LinkedHashMap<String, String> dataInput,
void smartSample(LinkedHashMap<String, String> dataInput, String elementType,
AsyncCallback<SamplingResultWithFileFromServlet> callback);
void randomSample(LinkedHashMap<String, String> dataInput,
void randomSample(LinkedHashMap<String, String> dataInput, String elementType,
AsyncCallback<SamplingResultWithFileFromServlet> callback);
void LoadTables(PagingLoadConfig config,
LinkedHashMap<String, String> dataInput, boolean SearchTable,
LinkedHashMap<String, String> dataInput, String elementType, boolean SearchTable,
String keyword, AsyncCallback<PagingLoadResult<Result>> callback);
void removeComputation(String uidSubmitQuery,

View File

@ -102,7 +102,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
private Dialog tablesLoaded = null;
// to keep track of selected table in the tables list
private String selectedTable = "";
private String currentselectedTable="";
private String currentselectedTable = "";
private FileModel table = new FileModel("");
// variables to perform the table search
private String keyword = "";
@ -235,10 +235,10 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// clean variable at each item selection event
table = new FileModel("");
// clean variable
selectedTable = "";
currentselectedTable="";
currentselectedTable = "";
if (DepthSelectedItem != 3) {
centerUpper.removeAll();
@ -334,10 +334,10 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// method to load the tables list
private void loadTables() {
// clean variable
// selectedTable = null;
// selectedTable = null;
// disable table details and sampling buttons
// toolbar.disableButtonsOperationsOnTable();
// toolbar.disableButtonsOperationsOnTable();
// clear the panel
// centerBottom.removeAll();
// centerBottom.layout(true);
@ -353,6 +353,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
String database = "";
String schema = "";
final String elementType;
if (element.isDatabase()) { // the selected item is a database
rootLogger.log(Level.INFO, "selected element is a database ");
database = element.getName();
@ -361,6 +363,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
dataInput.put("ResourceName", resource);
dataInput.put("DatabaseName", database);
dataInput.put("SchemaName", "");
elementType = ConstantsPortlet.DATABASE;
} else { // the selected item is a schema
rootLogger.log(Level.INFO, "selected element is a schema ");
FileModel db = treePanel.getTreeStore().getParent(element);
@ -371,6 +374,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
dataInput.put("ResourceName", resource);
dataInput.put("DatabaseName", database);
dataInput.put("SchemaName", schema);
elementType = ConstantsPortlet.SCHEMA;
}
// print check
@ -390,7 +394,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
+ startSearchTable);
// remote rpc
RPCservice.LoadTables((PagingLoadConfig) loadConfig, dataInput,
startSearchTable, keyword,
elementType, startSearchTable, keyword,
new AsyncCallback<PagingLoadResult<Result>>() {
@Override
public void onFailure(Throwable caught) {
@ -569,7 +573,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
}
});
// listener to manage the table selection in the grid
grid.addListener(Events.RowClick, new Listener<GridEvent<Result>>() {
@Override
@ -581,8 +584,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
grid.getSelectionModel().select(
grid.getSelectionModel().getSelectedItems().get(0),
true);
// tablesLoaded.addListener(Events.Hide, new
// Listener<WindowEvent>() {
// @Override
@ -593,7 +595,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// });
}
});
grid.addListener(Events.BeforeEdit, new Listener<GridEvent<Result>>() {
@Override
@ -683,17 +684,16 @@ public class GxtBorderLayoutPanel extends ContentPanel {
rootLogger.log(Level.INFO, "button: " + ok.getText());
Button canc = (Button) tablesLoaded.getButtonBar().getWidget(1);
rootLogger.log(Level.INFO, "button: " + canc.getText());
// listener for buttons
ok.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
keyword = null;
startSearchTable = false;
// if (selectedTable != null) {
if (!currentselectedTable.equals(selectedTable)){
// if (selectedTable != null) {
if (!currentselectedTable.equals(selectedTable)) {
currentselectedTable = selectedTable;
// refresh the content in the two panels
centerBottom.removeAll();
@ -727,23 +727,22 @@ public class GxtBorderLayoutPanel extends ContentPanel {
tablesLoaded.hide();
}
});
// listener to manage the table selection in the grid
grid.getSelectionModel().addSelectionChangedListener(
new SelectionChangedListener<Result>() {
@Override
public void selectionChanged(
SelectionChangedEvent<Result> se) {
selectedTable = grid.getSelectionModel()
.getSelectedItems().get(0).getValue();
rootLogger.log(Level.INFO, "SelectionChangedListener->table selected: "
// listener to manage the table selection in the grid
grid.getSelectionModel().addSelectionChangedListener(
new SelectionChangedListener<Result>() {
@Override
public void selectionChanged(
SelectionChangedEvent<Result> se) {
selectedTable = grid.getSelectionModel()
.getSelectedItems().get(0).getValue();
rootLogger.log(Level.INFO,
"SelectionChangedListener->table selected: "
+ selectedTable);
ok.enable();
}
});
ok.enable();
}
});
tablesLoaded.add(grid);
tablesLoaded.show();
}
@ -877,13 +876,14 @@ public class GxtBorderLayoutPanel extends ContentPanel {
}
@Override
public void onSuccess(SubmitQueryResultWithFileFromServlet obj) {
public void onSuccess(
SubmitQueryResultWithFileFromServlet obj) {
rootLogger.log(Level.SEVERE, "SUCCESS RPC submitQuery");
if (obj != null){
//get list attributes
if (obj != null) {
// get list attributes
List<String> listAttributes = obj.getListOutput();
if (form.getBody().isMasked())
form.getBody().unmask();
@ -919,7 +919,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// return;
// }
rootLogger.log(Level.SEVERE, "SUCCESS RPC submitQuery");
rootLogger.log(Level.SEVERE,
"SUCCESS RPC submitQuery");
rootLogger.log(Level.SEVERE, "output size: "
+ listAttributes.size());
@ -952,11 +953,11 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// get path
String fileName = obj.getFileName();
parseSubmitQueryResult(form, dialogID, listAttributes, fileName,
UID);
parseSubmitQueryResult(form, dialogID,
listAttributes, fileName, UID);
}
}
});
}
@ -1167,20 +1168,16 @@ public class GxtBorderLayoutPanel extends ContentPanel {
});
}
});
// add the button to download the result
final String urlFile = Window.Location
.getProtocol()
+ "//"
final String urlFile = Window.Location.getProtocol() + "//"
+ Window.Location.getHost() + fileName;
Button download = new Button("Download",
new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(
ButtonEvent ce) {
Window.open(urlFile, "Result File",
"_blank");
public void componentSelected(ButtonEvent ce) {
Window.open(urlFile, "Result File", "_blank");
}
});
submitResult.addButton(download);
@ -1205,6 +1202,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
FileModel database;
FileModel resource;
String elementType;
if (selectedItem.isDatabase()) {
// the table has not a schema because the selected item is a
// database
@ -1220,6 +1219,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
rootLogger.log(Level.INFO, "DatabaseName: " + database.getName());
rootLogger.log(Level.INFO, "SchemaName: " + "");
rootLogger.log(Level.INFO, "TableName: " + currentselectedTable);
elementType = ConstantsPortlet.DATABASE;
} else {
// the table has a schema because the selected item is a schema
schema = selectedItem;
@ -1235,13 +1236,15 @@ public class GxtBorderLayoutPanel extends ContentPanel {
rootLogger.log(Level.INFO, "DatabaseName: " + database.getName());
rootLogger.log(Level.INFO, "SchemaName: " + schema.getName());
rootLogger.log(Level.INFO, "TableName: " + currentselectedTable);
elementType = ConstantsPortlet.SCHEMA;
}
// to mask the entire content panel
obj.mask("Sampling the table", "x-mask-loading");
// call remote service
RPCservice.sample(dataInput,
RPCservice.sample(dataInput, elementType,
new AsyncCallback<SamplingResultWithFileFromServlet>() {
@Override
public void onFailure(Throwable caught) {
@ -1340,7 +1343,9 @@ public class GxtBorderLayoutPanel extends ContentPanel {
FileModel schema;
FileModel database;
FileModel resource;
String elementType;
if (selectedItem.isDatabase()) {
// the table has not a schema
database = selectedItem;
@ -1355,6 +1360,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
rootLogger.log(Level.INFO, "DatabaseName: " + database.getName());
rootLogger.log(Level.INFO, "SchemaName: " + "");
rootLogger.log(Level.INFO, "TableName: " + currentselectedTable);
elementType=ConstantsPortlet.DATABASE;
} else {
// the table has a schema
schema = selectedItem;
@ -1370,12 +1376,13 @@ public class GxtBorderLayoutPanel extends ContentPanel {
rootLogger.log(Level.INFO, "DatabaseName: " + database.getName());
rootLogger.log(Level.INFO, "SchemaName: " + schema.getName());
rootLogger.log(Level.INFO, "TableName: " + currentselectedTable);
elementType=ConstantsPortlet.SCHEMA;
}
// to mask the entire content panel
obj.mask("Sampling the table", "x-mask-loading");
// call remote service
RPCservice.smartSample(dataInput,
RPCservice.smartSample(dataInput, elementType,
new AsyncCallback<SamplingResultWithFileFromServlet>() {
@Override
public void onFailure(Throwable caught) {
@ -1438,6 +1445,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
FileModel database;
FileModel resource;
String elementType;
if (selectedItem.isDatabase()) {
// the table has not a schema
database = selectedItem;
@ -1452,6 +1461,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
rootLogger.log(Level.INFO, "DatabaseName: " + database.getName());
rootLogger.log(Level.INFO, "SchemaName: " + "");
rootLogger.log(Level.INFO, "TableName: " + currentselectedTable);
elementType = ConstantsPortlet.DATABASE;
} else {
// the table has a schema
schema = selectedItem;
@ -1467,13 +1477,14 @@ public class GxtBorderLayoutPanel extends ContentPanel {
rootLogger.log(Level.INFO, "DatabaseName: " + database.getName());
rootLogger.log(Level.INFO, "SchemaName: " + schema.getName());
rootLogger.log(Level.INFO, "TableName: " + currentselectedTable);
elementType = ConstantsPortlet.SCHEMA;
}
// to mask the entire content panel
obj.mask("Sampling the table", "x-mask-loading");
// call remote service
RPCservice.randomSample(dataInput,
RPCservice.randomSample(dataInput, elementType,
new AsyncCallback<SamplingResultWithFileFromServlet>() {
@Override
public void onFailure(Throwable caught) {

View File

@ -20,6 +20,9 @@ public class ConstantsPortlet {
public static final String MYSQL = "MYSQL";
public static final String NONE = "NONE";
//element types
public static final String DATABASE="Database";
public static final String SCHEMA="Schema";

View File

@ -300,6 +300,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// print check
logger.info("dbmanager-> ResourceName: " + resourceName);
if ((resourceName == null) || (resourceName.equals(""))) {
throw new Exception("Unable to load data");
}
Parameter resource = new Parameter("ResourceName", "", "String", "");
inputParameters.add(resource);
inputParameters.get(0).setValue(resourceName);
@ -398,6 +402,13 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
logger.info("dbmanager-> ResourceName: " + rs);
logger.info("dbmanager-> DatabaseName: " + db);
if ((rs == null) || (rs.equals(""))) {
throw new Exception("Unable to load data");
}
if ((db == null) || (db.equals(""))) {
throw new Exception("Unable to load data");
}
// set input parameters
Parameter resource = new Parameter("ResourceName", "", "String", "");
Parameter database = new Parameter("DatabaseName", "", "String", "");
@ -484,8 +495,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
}
// to get tables
private List<Result> getTables(LinkedHashMap<String, String> dataInput)
throws Exception {
private List<Result> getTables(LinkedHashMap<String, String> dataInput,
String elementType) throws Exception {
// data input
List<Parameter> inputParameters = new ArrayList<Parameter>();
// data output
@ -502,6 +513,26 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
logger.info("dbmanager-> DatabaseName: " + db);
logger.info("dbmanager-> SchemaName: " + scm);
if ((elementType!=null)&&(elementType.equals(ConstantsPortlet.SCHEMA))) {
if ((rs==null)||(rs.equals(""))){
throw new Exception("Unable to load data");
}
if ((db==null)||(db.equals(""))){
throw new Exception("Unable to load data");
}
if ((scm==null)||(scm.equals(""))){
throw new Exception("Unable to load data");
}
}
if ((elementType!=null)&&(elementType.equals(ConstantsPortlet.DATABASE))) {
if ((rs==null)||(rs.equals(""))){
throw new Exception("Unable to load data");
}
if ((db==null)||(db.equals(""))){
throw new Exception("Unable to load data");
}
}
// set input parameters
Parameter resource = new Parameter("ResourceName", "", "String", "");
Parameter database = new Parameter("DatabaseName", "", "String", "");
@ -611,8 +642,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// to load tables
@Override
public PagingLoadResult<Result> LoadTables(PagingLoadConfig config,
LinkedHashMap<String, String> dataInput, boolean SearchTable,
String keyword) throws Exception {
LinkedHashMap<String, String> dataInput, String elementType,
boolean SearchTable, String keyword) throws Exception {
// tables' list stored for a user session
// ASLSession session =
@ -654,7 +685,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// if (result == null)
// result = getTables(dataInput);
if (result.size() == 0)
result = getTables(dataInput);
result = getTables(dataInput, elementType);
// Create a sublist and add data to list according
// to the limit and offset value of the config
@ -743,6 +774,16 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
logger.info("dbmanager-> Query: " + query);
logger.info("dbmanager-> SmartCorrections check: "
+ smartCorrectionQuery);
if ((rs==null)||(rs.equals(""))){
throw new Exception("Unable to load data");
}
if ((db==null)||(db.equals(""))){
throw new Exception("Unable to load data");
}
if ((query==null)||(query.equals(""))){
throw new Exception("Unable to load data");
}
// set input parameters
Parameter resource = new Parameter("ResourceName", "", "String", "");
@ -919,7 +960,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
@Override
public SamplingResultWithFileFromServlet sample(
LinkedHashMap<String, String> dataInput) throws Exception {
LinkedHashMap<String, String> dataInput, String elementType) throws Exception {
// data input
List<Parameter> inputParameters = new ArrayList<Parameter>();
// output sample result
@ -938,6 +979,32 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
logger.info("dbmanager-> DatabaseName: " + db);
logger.info("dbmanager-> SchemaName: " + scm);
logger.info("dbmanager-> TableName: " + tab);
if ((elementType!=null)&&(elementType.equals(ConstantsPortlet.SCHEMA))) {
if ((rs==null)||(rs.equals(""))){
throw new Exception("Unable to load data");
}
if ((db==null)||(db.equals(""))){
throw new Exception("Unable to load data");
}
if ((scm==null)||(scm.equals(""))){
throw new Exception("Unable to load data");
}
if ((tab==null)||(tab.equals(""))){
throw new Exception("Unable to load data");
}
}
if ((elementType!=null)&&(elementType.equals(ConstantsPortlet.DATABASE))) {
if ((rs==null)||(rs.equals(""))){
throw new Exception("Unable to load data");
}
if ((db==null)||(db.equals(""))){
throw new Exception("Unable to load data");
}
if ((tab==null)||(tab.equals(""))){
throw new Exception("Unable to load data");
}
}
// set input parameters
Parameter resource = new Parameter("ResourceName", "", "String", "");
@ -993,7 +1060,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
@Override
public SamplingResultWithFileFromServlet smartSample(
LinkedHashMap<String, String> dataInput) throws Exception {
LinkedHashMap<String, String> dataInput, String elementType) throws Exception {
// data input
List<Parameter> inputParameters = new ArrayList<Parameter>();
// output sample result
@ -1012,6 +1079,32 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
logger.info("dbmanager-> DatabaseName: " + db);
logger.info("dbmanager-> SchemaName: " + scm);
logger.info("dbmanager-> TableName: " + tab);
if ((elementType!=null)&&(elementType.equals(ConstantsPortlet.SCHEMA))) {
if ((rs==null)||(rs.equals(""))){
throw new Exception("Unable to load data");
}
if ((db==null)||(db.equals(""))){
throw new Exception("Unable to load data");
}
if ((scm==null)||(scm.equals(""))){
throw new Exception("Unable to load data");
}
if ((tab==null)||(tab.equals(""))){
throw new Exception("Unable to load data");
}
}
if ((elementType!=null)&&(elementType.equals(ConstantsPortlet.DATABASE))) {
if ((rs==null)||(rs.equals(""))){
throw new Exception("Unable to load data");
}
if ((db==null)||(db.equals(""))){
throw new Exception("Unable to load data");
}
if ((tab==null)||(tab.equals(""))){
throw new Exception("Unable to load data");
}
}
// set input parameters
Parameter resource = new Parameter("ResourceName", "", "String", "");
@ -1067,7 +1160,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
@Override
public SamplingResultWithFileFromServlet randomSample(
LinkedHashMap<String, String> dataInput) throws Exception {
LinkedHashMap<String, String> dataInput, String elementType) throws Exception {
// data input
List<Parameter> inputParameters = new ArrayList<Parameter>();
@ -1087,6 +1180,32 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
logger.info("dbmanager-> DatabaseName: " + db);
logger.info("dbmanager-> SchemaName: " + scm);
logger.info("dbmanager-> TableName: " + tab);
if ((elementType!=null)&&(elementType.equals(ConstantsPortlet.SCHEMA))) {
if ((rs==null)||(rs.equals(""))){
throw new Exception("Unable to load data");
}
if ((db==null)||(db.equals(""))){
throw new Exception("Unable to load data");
}
if ((scm==null)||(scm.equals(""))){
throw new Exception("Unable to load data");
}
if ((tab==null)||(tab.equals(""))){
throw new Exception("Unable to load data");
}
}
if ((elementType!=null)&&(elementType.equals(ConstantsPortlet.DATABASE))) {
if ((rs==null)||(rs.equals(""))){
throw new Exception("Unable to load data");
}
if ((db==null)||(db.equals(""))){
throw new Exception("Unable to load data");
}
if ((tab==null)||(tab.equals(""))){
throw new Exception("Unable to load data");
}
}
// set input parameters
Parameter resource = new Parameter("ResourceName", "", "String", "");
@ -1928,7 +2047,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
ConstantsPortlet.MYSQL)) { // refresh
// table
// list
getTables(inputData);
getTables(inputData, ConstantsPortlet.DATABASE);
}
// resourceName = inputData.get("ResourceName");
@ -1937,7 +2056,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
break;
case "schema":
getTables(inputData);
getTables(inputData, ConstantsPortlet.SCHEMA);
break;
}
}