diff --git a/src/main/java/org/gcube/portlets/user/databasesmanager/client/datamodel/Row.java b/src/main/java/org/gcube/portlets/user/databasesmanager/client/datamodel/Row.java index e849f28..ade60ca 100644 --- a/src/main/java/org/gcube/portlets/user/databasesmanager/client/datamodel/Row.java +++ b/src/main/java/org/gcube/portlets/user/databasesmanager/client/datamodel/Row.java @@ -16,17 +16,20 @@ public class Row extends BaseModelData implements Serializable { public Row() { } - public Row(List attributes, List values, int index) throws Exception{ + public Row(List attributes, List values, int index) + throws Exception { set("index", index); - for (int i = 0; i < attributes.size(); i++) { - set(attributes.get(i), values.get(i)); - // print check - // System.out.println("attribute: " + attributes.get(i) + " value: " - // + values.get(i)); - - // print check - // rootLogger.log(Level.INFO, "Row-> attribute: " - // +attributes.get(i)+ "value: " + values.get(i)); + if (attributes != null && !attributes.isEmpty() && values != null + && !values.isEmpty()){ + int limit; + if(attributes.size()>=values.size()){ + limit=values.size(); + } else { + limit=attributes.size(); + } + for (int i = 0; i < limit; i++) { + set(attributes.get(i), values.get(i)); + } } } diff --git a/src/main/java/org/gcube/portlets/user/databasesmanager/client/datamodel/SubmitQueryResultWithFileFromServlet.java b/src/main/java/org/gcube/portlets/user/databasesmanager/client/datamodel/SubmitQueryResultWithFileFromServlet.java index 6d2db02..f77a3ad 100644 --- a/src/main/java/org/gcube/portlets/user/databasesmanager/client/datamodel/SubmitQueryResultWithFileFromServlet.java +++ b/src/main/java/org/gcube/portlets/user/databasesmanager/client/datamodel/SubmitQueryResultWithFileFromServlet.java @@ -56,5 +56,14 @@ public class SubmitQueryResultWithFileFromServlet extends BaseModelData public int getSubmitQueryTotalRows(){ return get("submitQueryTotalRows"); } + + @Override + public String toString() { + return "SubmitQueryResultWithFileFromServlet [attributes=" + attributes + + ", convertedQuery=" + convertedQuery + ", urlFile=" + urlFile + + ", submitQueryTotalRows=" + submitQueryTotalRows + "]"; + } + + } diff --git a/src/main/java/org/gcube/portlets/user/databasesmanager/client/panels/GxtBorderLayoutPanel.java b/src/main/java/org/gcube/portlets/user/databasesmanager/client/panels/GxtBorderLayoutPanel.java index 7903049..533e0ad 100644 --- a/src/main/java/org/gcube/portlets/user/databasesmanager/client/panels/GxtBorderLayoutPanel.java +++ b/src/main/java/org/gcube/portlets/user/databasesmanager/client/panels/GxtBorderLayoutPanel.java @@ -83,7 +83,12 @@ import com.google.gwt.user.client.rpc.AsyncCallback; //class that represents the container of all components public class GxtBorderLayoutPanel extends ContentPanel { - + private static final String CREATE_TABLE_STATEMENT = "Create Table Statement"; + private static final String NAME_OF_COLUMNS = "Name Of Columns"; + private static final String ROWS_NUMBER = "Rows Number"; + + + /* Create Root Logger */ private static Logger rootLogger = Logger.getLogger("GxtBorderLayoutPanel"); private ContentPanel north; @@ -868,20 +873,6 @@ public class GxtBorderLayoutPanel extends ContentPanel { return; } - // Listener l = new - // Listener() { - // public void handleEvent(MessageBoxEvent ce) { - // // Button btn = ce.getButtonClicked(); - // // Info.display("MessageBox", - // // "The '{0}' button was pressed", - // // btn.getHtml()); - // // Button btn = ce.getButtonClicked(); - // - // if (form.getBody().isMasked()) - // form.getBody().unmask(); - // } - // }; - if (!(caught.getMessage().equals("ServerException"))) { if (caught.getMessage().contains( "Result not available")) { @@ -893,12 +884,6 @@ public class GxtBorderLayoutPanel extends ContentPanel { } } - // if (!(caught instanceof - // javax.xml.ws.soap.SOAPFaultException)){ - // MessageBox.alert("Error ", - // "
Message:" + caught.getMessage(), l); - // } - if (form.getBody().isMasked()) form.getBody().unmask(); @@ -947,52 +932,14 @@ public class GxtBorderLayoutPanel extends ContentPanel { } else { query = obj.getConvertedQuery(); } - // if ((listAttributes == null) - // || (listAttributes.size() == 0)) { - // - // // if (form.getBody().isMasked()) - // // form.getBody().unmask(); - // - // rootLogger.log(Level.SEVERE, - // "No results have been returned"); - // - // MessageBox.alert("Error ", "
Message:" - // + "Result not available", null); - // return; - // } + rootLogger.log(Level.SEVERE, "SUCCESS RPC submitQuery"); rootLogger.log(Level.SEVERE, "output size: " + listAttributes.size()); - // recover query - // Result query = result.remove(0); - // recover converted query - // Result convertedQuery; - - // if (dataQuery.getSmartCorrection() == true) { - // result.remove(0); - // // convertedQuery = result.get(1); - // } - - // get the attributes list for the result table - // List listAttributes = new - // ArrayList(); - // listAttributes = 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 - // boolean submitQueryEventManaged = true; - // parseResult(result, form, dialogID, - // submitQueryEventManaged); - - // parseSubmitQueryResult(result, form, dialogID, - // listAttributes, dataQuery.getQuery()); - + // get path // String fileName = obj.getFileName(); String urlFile = obj.getUrlFile(); @@ -2067,39 +2014,41 @@ public class GxtBorderLayoutPanel extends ContentPanel { for (int i = 0; i < result.size(); i++) { if (array[i].toString().contains( - "CreateTable")) { + CREATE_TABLE_STATEMENT)) { // recover the // showCreateTable // statement Result row = new Result( - "Create statement", result.get( + CREATE_TABLE_STATEMENT, result.get( array[i].toString()) .getName()); TableDetails.add(row); } if (array[i].toString().contains( - "Column Names")) { + NAME_OF_COLUMNS)) { // recover the // column names - Result row = new Result("Column names", + Result row = new Result(NAME_OF_COLUMNS, result.get(array[i].toString()) .getName()); TableDetails.add(row); } if (array[i].toString().contains( - "NumberRows")) { + ROWS_NUMBER)) { // recover the // column names Result row = new Result( - "Number of rows", result.get( + ROWS_NUMBER, result.get( array[i].toString()) .getName()); TableDetails.add(row); } } + rootLogger.log(Level.INFO, "Table Details: "+TableDetails); Table.setTableDetails(TableDetails); + rootLogger.log(Level.INFO, "File Model: "+Table); displayTableDetails(Table); Table.setTableDetailsDisplayed(true); } diff --git a/src/main/java/org/gcube/portlets/user/databasesmanager/server/GWTdbManagerServiceImpl.java b/src/main/java/org/gcube/portlets/user/databasesmanager/server/GWTdbManagerServiceImpl.java index af8c388..877cbc5 100644 --- a/src/main/java/org/gcube/portlets/user/databasesmanager/server/GWTdbManagerServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/databasesmanager/server/GWTdbManagerServiceImpl.java @@ -632,7 +632,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements mapValues = outputData.getMapValues(); mapKeys = outputData.getmapKeys(); - if (mapValues.size() != 0) { + if (mapValues != null && !mapValues.isEmpty()) { output = new ArrayList(); // logger.info("build the result - started"); @@ -643,10 +643,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements output.add(row); } - // System.out.println("output size submit: " + - // output.size()); - // logger.info("build the result - finished"); - // get the converted query if (smartCorrectionQuery == true) { convertedQuery = output.get(0).getValue(); @@ -697,6 +693,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements } } + logger.debug("SubmitQuery Result: " + result); + return result; } catch (Exception e) { // e.printStackTrace(); @@ -1213,7 +1211,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements return outputParameters; } catch (Exception e) { - logger.error("dbmanager-> ", e); + logger.error("dbmanager getTableDetails-> ", e); if (!(e instanceof StatisticalManagerException)) { // GWT can't serialize all exceptions throw new Exception( @@ -1242,7 +1240,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements // get the key to retrieve the submitQuery result String key = getKeySubmitQueryResult(UID); - if ((key != null) && (!key.equals(""))) { + if ((key != null) && (!key.isEmpty())) { // load data // get data from cache @@ -1275,6 +1273,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements int totalNumber = data.size(); sublist = new ArrayList(data.subList(start, limit)); + loadResult = new BasePagingLoadResult(sublist, config.getOffset(), totalNumber); @@ -1333,23 +1332,25 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements // parse a csv row in a list of values @Override - public List parseCVSString(List result, List attrNames) + public List parseCVSString(List results, List attrNames) throws Exception { - List rows = null; + List rows = new ArrayList(); try { - if (result != null) { - rows = new ArrayList(); - for (int i = 0; i < result.size(); i++) { - List attrValues = parse(result.get(i).getValue()); - Row element = new Row(attrNames, attrValues, i); - rows.add(element); + if (results != null && !results.isEmpty()) { + for (int i = 0; i < results.size(); i++) { + Result res = results.get(i); + if (res != null && res.getValue() != null) { + List attrValues = parse(res.getValue()); + Row element = new Row(attrNames, attrValues, i); + rows.add(element); + } } } return rows; } catch (Exception e) { - logger.error("dbmanager-> ", e); + logger.error("dbmanager parse csv string-> ", e); throw new Exception(e); } } @@ -1407,7 +1408,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements // logger.info("server token: " + phrase); // logger.info("size: " + elements.size()); } catch (Exception e) { - logger.error("dbmanager-> ", e); + logger.error("dbmanager parse string-> ", e); throw e; } return elements; @@ -1636,12 +1637,12 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements pars.add(par); } - logger.debug("Parameters: "+pars); + logger.debug("Parameters: " + pars); operator.setOperatorParameters(pars); ComputationId computationId = sClient.startComputation(operator); - //float percentage = 0; - //String scope = scopeValue; + // float percentage = 0; + // String scope = scopeValue; // String username = getUsername(); updateJobStatus(jobID, "computation started"); @@ -1736,18 +1737,19 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements logger.info("dbmanager-> Http link of the generated File: " + fileResource.getUrl()); } else { - if (key.compareToIgnoreCase("Total Rows") == 0) { - ObjectResource objectResource = (ObjectResource) value; + ObjectResource objectResource = (ObjectResource) value; + if (objectResource.getName().compareToIgnoreCase( + "Total Rows") == 0) { outputData.setSubmitQueryTotalRows(Integer .parseInt(objectResource.getValue())); } else { - ObjectResource objectResource = (ObjectResource) value; - logger.debug("ObjectResource: "+value); + logger.debug("ObjectResource: " + value); mapKeys.put(String.valueOf(i), value.getName()); mapValues.put(String.valueOf(i), objectResource.getValue()); i++; } + } } } @@ -2784,8 +2786,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements resource.setValue(resourceName); List inputParameters = new ArrayList(); inputParameters.add(resource); - logger.debug("InputParameters: "+inputParameters); - + logger.debug("InputParameters: " + inputParameters); + ComputationOutput outputData = new ComputationOutput(); // computation id ComputationId computationId = startComputation(algorithmId, @@ -2827,8 +2829,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements // + key); } } - logger.debug("dbmanager outputParameters-> "+outputParameters); - + logger.debug("dbmanager outputParameters-> " + outputParameters); + return outputParameters; } catch (Exception e) { // e.printStackTrace();