Author: echatellier Date: 2012-04-26 15:32:21 +0200 (Thu, 26 Apr 2012) New Revision: 283 Url: http://forge.codelutin.com/repositories/revision/isis-fish-data/283 Log: Get result within an valid transaction to avoid lazyexceptions Modified: trunk/sensitivityexports/SensitivitySpawningBiomassReferenceY8.java trunk/sensitivityexports/SensitivitySpawningBiomassRelativeReferenceY11.java trunk/sensitivityexports/SensitivitySpawningBiomassRelativeY5.java trunk/sensitivityexports/SensitivitySpawningBiomassY2.java Modified: trunk/sensitivityexports/SensitivitySpawningBiomassReferenceY8.java =================================================================== --- trunk/sensitivityexports/SensitivitySpawningBiomassReferenceY8.java 2012-04-03 15:59:20 UTC (rev 282) +++ trunk/sensitivityexports/SensitivitySpawningBiomassReferenceY8.java 2012-04-26 13:32:21 UTC (rev 283) @@ -2,7 +2,7 @@ * #%L * IsisFish data * %% - * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau + * Copyright (C) 2009 - 2012 Ifremer, Code Lutin, Jean Couteau, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -80,8 +80,6 @@ map.put(group.getId(),group.getMaturityOgive()); } - tx.closeContext(); - //instantiate a reader that starts reading from the file end. ReverseFileReader reader = new ReverseFileReader(referenceFile); @@ -109,13 +107,14 @@ } line = reader.readLine(); } + reader.close(); for (Population pop : simulation.getParameter().getPopulations()) { if (pop.getName().equals(param_pop.getName())) { //Get the biomass of the last time step MatrixND matlastdate = resultStorage.getMatrix(pop, - ResultName.MATRIX_BIOMASS); + ResultName.MATRIX_BIOMASS, tx); for (MatrixIterator i = matlastdate.iterator(); i.hasNext();) { i.next(); Object[] sems = i.getSemanticsCoordinates(); @@ -127,6 +126,9 @@ } } } + + tx.closeContext(); + out.write(Double.toString(biomass / referenceBiomass)); } Modified: trunk/sensitivityexports/SensitivitySpawningBiomassRelativeReferenceY11.java =================================================================== --- trunk/sensitivityexports/SensitivitySpawningBiomassRelativeReferenceY11.java 2012-04-03 15:59:20 UTC (rev 282) +++ trunk/sensitivityexports/SensitivitySpawningBiomassRelativeReferenceY11.java 2012-04-26 13:32:21 UTC (rev 283) @@ -2,7 +2,7 @@ * #%L * IsisFish data * %% - * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau + * Copyright (C) 2009 - 2012 Ifremer, Code Lutin, Jean Couteau, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -85,8 +85,6 @@ map.put(group.getId(),group.getMaturityOgive()); } - tx.closeContext(); - //instantiate a reader that starts reading from the file end. ReverseFileReader reader = new ReverseFileReader(referenceFile); @@ -119,13 +117,14 @@ line = reader.readLine(); } + reader.close(); for (Population pop : simulation.getParameter().getPopulations()) { if (pop.getName().equals(param_pop.getName())) { //Get the biomass of the first time step MatrixND matfirstdate = resultStorage.getMatrix(pop, - ResultName.MATRIX_BIOMASS); + ResultName.MATRIX_BIOMASS, tx); for (MatrixIterator i = matfirstdate.iterator(); i.hasNext();) { i.next(); Object[] sems = i.getSemanticsCoordinates(); @@ -139,7 +138,7 @@ //Get the biomass of the last time step MatrixND matlastdate = resultStorage.getMatrix(pop, - ResultName.MATRIX_BIOMASS); + ResultName.MATRIX_BIOMASS, tx); for (MatrixIterator i = matlastdate.iterator(); i.hasNext();) { i.next(); Object[] sems = i.getSemanticsCoordinates(); @@ -152,6 +151,9 @@ } } } + + tx.closeContext(); + out.write(Double.toString((biomass / firstbiomass) / (biomassReference / firstBiomassReference))); } Modified: trunk/sensitivityexports/SensitivitySpawningBiomassRelativeY5.java =================================================================== --- trunk/sensitivityexports/SensitivitySpawningBiomassRelativeY5.java 2012-04-03 15:59:20 UTC (rev 282) +++ trunk/sensitivityexports/SensitivitySpawningBiomassRelativeY5.java 2012-04-26 13:32:21 UTC (rev 283) @@ -2,7 +2,7 @@ * #%L * IsisFish data * %% - * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau + * Copyright (C) 2009 - 2012 Ifremer, Code Lutin, Jean Couteau, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -32,6 +32,8 @@ import org.apache.commons.logging.LogFactory; import org.nuiton.math.matrix.MatrixIterator; import org.nuiton.math.matrix.MatrixND; +import org.nuiton.topia.TopiaContext; + import scripts.ResultName; import java.io.Writer; @@ -62,8 +64,9 @@ ResultStorage resultStorage = simulation.getResultStorage(); //Get the biomass of the first time step + TopiaContext tx = simulation.getStorage().beginTransaction(); MatrixND matfirstdate = resultStorage.getMatrix(pop, - ResultName.MATRIX_BIOMASS); + ResultName.MATRIX_BIOMASS, tx); for (MatrixIterator i = matfirstdate.iterator(); i.hasNext();) { i.next(); Object[] sems = i.getSemanticsCoordinates(); @@ -77,7 +80,7 @@ //Get the biomass of the last time step MatrixND matlastdate = resultStorage.getMatrix(pop, - ResultName.MATRIX_BIOMASS); + ResultName.MATRIX_BIOMASS, tx); for (MatrixIterator i = matlastdate.iterator(); i.hasNext();) { i.next(); Object[] sems = i.getSemanticsCoordinates(); @@ -86,6 +89,8 @@ if (step.equals(lastStep)) biomass += i.getValue() * group.getMaturityOgive(); } + + tx.closeContext(); } } out.write(Double.toString(biomass / firstbiomass)); Modified: trunk/sensitivityexports/SensitivitySpawningBiomassY2.java =================================================================== --- trunk/sensitivityexports/SensitivitySpawningBiomassY2.java 2012-04-03 15:59:20 UTC (rev 282) +++ trunk/sensitivityexports/SensitivitySpawningBiomassY2.java 2012-04-26 13:32:21 UTC (rev 283) @@ -2,7 +2,7 @@ * #%L * IsisFish data * %% - * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau + * Copyright (C) 2009 - 2012 Ifremer, Code Lutin, Jean Couteau, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -32,6 +32,8 @@ import org.apache.commons.logging.LogFactory; import org.nuiton.math.matrix.MatrixIterator; import org.nuiton.math.matrix.MatrixND; +import org.nuiton.topia.TopiaContext; + import scripts.ResultName; import java.io.Writer; @@ -60,8 +62,9 @@ ResultStorage resultStorage = simulation.getResultStorage(); //Get the biomass of the last time step + TopiaContext tx = simulation.getStorage().beginTransaction(); MatrixND matlastdate = resultStorage.getMatrix(pop, - ResultName.MATRIX_BIOMASS); + ResultName.MATRIX_BIOMASS, tx); for (MatrixIterator i = matlastdate.iterator(); i.hasNext();) { i.next(); Object[] sems = i.getSemanticsCoordinates(); @@ -71,6 +74,7 @@ biomass += i.getValue() * group.getMaturityOgive(); } } + tx.closeContext(); } } out.write(Double.toString(biomass));