Author: jcouteau Date: 2010-04-19 16:44:30 +0200 (Mon, 19 Apr 2010) New Revision: 205 Log: Deal with autocommit mode in DataFrame getData() method Modified: trunk/src/main/java/org/nuiton/j2r/types/RDataFrame.java Modified: trunk/src/main/java/org/nuiton/j2r/types/RDataFrame.java =================================================================== --- trunk/src/main/java/org/nuiton/j2r/types/RDataFrame.java 2010-04-19 13:20:43 UTC (rev 204) +++ trunk/src/main/java/org/nuiton/j2r/types/RDataFrame.java 2010-04-19 14:44:30 UTC (rev 205) @@ -499,13 +499,38 @@ } /** - * Method to get the ArrayLists of the R data.frame (there is no - * synchronizing with R). + * Method to get the ArrayLists of the R data.frame. Synchronize with R only + * if in autocommit mode and variable set. * - * @return a ArrayList containing the ArrayLists of the R data.frame + * @return the data of the data.frame */ public List<List<?>> getData() { - //TODO JC manage the autocommit mode here. + if (this.engine.isAutoCommit()){ + + int rowNumber; + int columnNumber; + + try { + checkVariable(); + int[] dim = dim(); + rowNumber = dim[0]; + columnNumber = dim[1]; + } catch (RException eee) { + return data; + } + + try { + for(int i=0;i<columnNumber;i++){ + for(int j=0;j<rowNumber;j++){ + get(i,j); + } + } + + } catch (RException eee) { + log.error("An error occurred while trying to contact R"); + } + + } return data; }
participants (1)
-
jcouteau@users.nuiton.org