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:
parent
f44416d559
commit
c96b6cc551
|
@ -77,6 +77,15 @@
|
|||
top header in the portlet made invisible. GxtBorderLayout
|
||||
class modified.
|
||||
</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 component="org.gcube.portlets.user.databases-manager-portlet.1-1-0"
|
||||
date="2014-09-10">
|
||||
|
|
|
@ -16,7 +16,7 @@ public class Row extends BaseModelData implements Serializable {
|
|||
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);
|
||||
for (int i = 0; i < attributes.size(); i++) {
|
||||
set(attributes.get(i), values.get(i));
|
||||
|
|
|
@ -1678,7 +1678,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
}
|
||||
|
||||
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
|
||||
// dialog form is unmasked otherwise if a sampling
|
||||
|
|
|
@ -1457,30 +1457,38 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
if (isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
List<Row> rows = new ArrayList<Row>();
|
||||
|
||||
List<Row> rows = null;
|
||||
try{
|
||||
if (result != null) {
|
||||
rows = new ArrayList<Row>();
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
List<String> attrValues = parse(result.get(i).getValue());
|
||||
Row element = new Row(attrNames, attrValues, i);
|
||||
rows.add(element);
|
||||
}
|
||||
}
|
||||
|
||||
return rows;
|
||||
} catch (Exception e) {
|
||||
logger.error("dbmanager-> ", e);
|
||||
throw new Exception(e);
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> parse(String row) throws Exception {
|
||||
String delimiter = ",";
|
||||
|
||||
// print check
|
||||
// logger.info("row: " + row);
|
||||
|
||||
List<String> elements = new ArrayList<String>();
|
||||
|
||||
try{
|
||||
String phrase = row;
|
||||
// logger.info("row: " + phrase);
|
||||
int idxdelim = -1;
|
||||
boolean quot = false;
|
||||
phrase = phrase.trim();
|
||||
|
||||
while ((idxdelim = phrase.indexOf(delimiter)) >= 0) {
|
||||
// logger.info("delimiter: " + idxdelim);
|
||||
quot = phrase.startsWith("\"");
|
||||
if (quot) {
|
||||
phrase = phrase.substring(1);
|
||||
|
@ -1506,16 +1514,22 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
elements.add(phrase.substring(0, idxdelim));
|
||||
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);
|
||||
}
|
||||
|
||||
if (phrase.endsWith("\""))
|
||||
phrase = phrase.substring(0, phrase.length() - 1);
|
||||
|
||||
if (phrase.endsWith("\"")){
|
||||
phrase = phrase.substring(0, phrase.length() - 1);}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue