bug fixed in DatabasesResourcesManager component and related to samplings operations and the related column values truncation.If quote is truncated the parsecvsString in servlet does not work fine. Row, GxtBorderLayoutPanel, GWTdbManagerServiceImpl, GxtBorderLayoutPanel classes modified to manage in a correct way the exception generated in class Row while parsing a csv row in a values list for samplings operations.

changelogfile modified.

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@101167 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Loredana Liccardo 2014-10-29 15:59:36 +00:00
parent f44416d559
commit c96b6cc551
4 changed files with 36 additions and 13 deletions

View File

@ -77,6 +77,15 @@
top header in the portlet made invisible. GxtBorderLayout top header in the portlet made invisible. GxtBorderLayout
class modified. class modified.
</Change> </Change>
<Change>
bug fixed in DatabasesResourcesManager component and related
to samplings operations and the related column values truncation.If
quote is truncated the parsecvsString in servlet does not work fine.
Row, GxtBorderLayoutPanel, GWTdbManagerServiceImpl,
GxtBorderLayoutPanel classes modified to manage in a correct way the
exception generated in class Row while parsing a csv row in a values
list for samplings operations.
</Change>
</Changeset> </Changeset>
<Changeset component="org.gcube.portlets.user.databases-manager-portlet.1-1-0" <Changeset component="org.gcube.portlets.user.databases-manager-portlet.1-1-0"
date="2014-09-10"> date="2014-09-10">

View File

@ -16,7 +16,7 @@ public class Row extends BaseModelData implements Serializable {
public Row() { public Row() {
} }
public Row(List<String> attributes, List<String> values, int index) { public Row(List<String> attributes, List<String> values, int index) throws Exception{
set("index", index); set("index", index);
for (int i = 0; i < attributes.size(); i++) { for (int i = 0; i < attributes.size(); i++) {
set(attributes.get(i), values.get(i)); set(attributes.get(i), values.get(i));

View File

@ -1678,7 +1678,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
} }
MessageBox.alert("Error ", MessageBox.alert("Error ",
"<br/>Message:" + caught.getMessage(), null); "<br/>Message:Error in server while loading data. Exception: " + caught.getMessage(), null);
// if the submit query event has been performed the // if the submit query event has been performed the
// dialog form is unmasked otherwise if a sampling // dialog form is unmasked otherwise if a sampling

View File

@ -1457,30 +1457,38 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
if (isSessionExpired()) if (isSessionExpired())
throw new SessionExpiredException(); throw new SessionExpiredException();
List<Row> rows = new ArrayList<Row>(); List<Row> rows = null;
try{
if (result != null) { if (result != null) {
rows = new ArrayList<Row>();
for (int i = 0; i < result.size(); i++) { for (int i = 0; i < result.size(); i++) {
List<String> attrValues = parse(result.get(i).getValue()); List<String> attrValues = parse(result.get(i).getValue());
Row element = new Row(attrNames, attrValues, i); Row element = new Row(attrNames, attrValues, i);
rows.add(element); rows.add(element);
} }
} }
return rows; return rows;
} catch (Exception e) {
logger.error("dbmanager-> ", e);
throw new Exception(e);
}
} }
private List<String> parse(String row) throws Exception { private List<String> parse(String row) throws Exception {
String delimiter = ","; String delimiter = ",";
// print check
// logger.info("row: " + row);
List<String> elements = new ArrayList<String>(); List<String> elements = new ArrayList<String>();
try{
String phrase = row; String phrase = row;
// logger.info("row: " + phrase);
int idxdelim = -1; int idxdelim = -1;
boolean quot = false; boolean quot = false;
phrase = phrase.trim(); phrase = phrase.trim();
while ((idxdelim = phrase.indexOf(delimiter)) >= 0) { while ((idxdelim = phrase.indexOf(delimiter)) >= 0) {
// logger.info("delimiter: " + idxdelim);
quot = phrase.startsWith("\""); quot = phrase.startsWith("\"");
if (quot) { if (quot) {
phrase = phrase.substring(1); phrase = phrase.substring(1);
@ -1506,16 +1514,22 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
elements.add(phrase.substring(0, idxdelim)); elements.add(phrase.substring(0, idxdelim));
phrase = phrase.substring(idxdelim + 1).trim(); phrase = phrase.substring(idxdelim + 1).trim();
} }
// logger.info("server token: " + phrase); // logger.info("token: " + phrase);
} }
if (phrase.startsWith("\"")) if (phrase.startsWith("\"")){
phrase = phrase.substring(1); phrase = phrase.substring(1);
}
if (phrase.endsWith("\"")) if (phrase.endsWith("\"")){
phrase = phrase.substring(0, phrase.length() - 1); phrase = phrase.substring(0, phrase.length() - 1);}
elements.add(phrase); elements.add(phrase);
// logger.info("size: " + elements.size()); // logger.info("server token: " + phrase);
// logger.info("size: " + elements.size());
}catch (Exception e) {
logger.error("dbmanager-> ", e);
throw e;
}
return elements; return elements;
} }