Updated pom version at 3.9.1

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/speciesdiscovery@145006 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2017-03-20 13:43:11 +00:00
parent 07cde19bbd
commit e7ccc34245
13 changed files with 262 additions and 158 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="lib" path="/home/francesco-mangiacrapa/libraries/asm-5.0.3/lib/asm-5.0.3.jar"/> <classpathentry kind="lib" path="/home/francesco-mangiacrapa/libraries/asm-5.0.3/lib/asm-5.0.3.jar"/>
<classpathentry kind="src" output="target/species-discovery-3.9.0-SNAPSHOT/WEB-INF/classes" path="src/main/java"> <classpathentry kind="src" output="target/species-discovery-3.9.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
@ -32,5 +32,5 @@
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/> <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="output" path="target/species-discovery-3.9.0-SNAPSHOT/WEB-INF/classes"/> <classpathentry kind="output" path="target/species-discovery-3.9.1-SNAPSHOT/WEB-INF/classes"/>
</classpath> </classpath>

View File

@ -1,5 +1,5 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
jarsExcludedFromWebInfLib= jarsExcludedFromWebInfLib=
lastWarOutDir=/home/francesco-mangiacrapa/wseclipseluna/species-discovery-TRUNK/target/species-discovery-3.7.2-SNAPSHOT lastWarOutDir=/home/francesco-mangiacrapa/wseclipseluna/species-discovery-TRUNK-TOTEST/target/species-discovery-3.9.1-SNAPSHOT
warSrcDir=src/main/webapp warSrcDir=src/main/webapp
warSrcDirIsOutput=false warSrcDirIsOutput=false

View File

@ -1,4 +1,8 @@
<ReleaseNotes> <ReleaseNotes>
<Changeset component="org.gcube.portlets-user.species-discovery.3-9-1"
date="20-03-2017">
<Change>[Bug #7568] Managed ASL session expiration during polling on SPD jobs </Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.species-discovery.3-9-0" <Changeset component="org.gcube.portlets-user.species-discovery.3-9-0"
date="11-01-2016"> date="11-01-2016">
<Change>[Feature #6313] SPD portlet upgrade: porting to spd-client-library 4.0.0 </Change> <Change>[Feature #6313] SPD portlet upgrade: porting to spd-client-library 4.0.0 </Change>

View File

@ -19,7 +19,7 @@
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>species-discovery</artifactId> <artifactId>species-discovery</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<version>3.9.0-SNAPSHOT</version> <version>3.9.1-SNAPSHOT</version>
<name>gCube Species Discovery</name> <name>gCube Species Discovery</name>
<description> <description>
gCube Species Discovery Portlet lets the users discovery species information from the Species Service. gCube Species Discovery Portlet lets the users discovery species information from the Species Service.
@ -92,6 +92,12 @@
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version> <version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>session-checker</artifactId>
<version>[1.0.0-SNAPSHOT,)</version>
</dependency>
<!-- USED TO SHOW A LAYER VIA GISVIEWER --> <!-- USED TO SHOW A LAYER VIA GISVIEWER -->
<!-- <dependency> --> <!-- <dependency> -->

View File

@ -93,9 +93,11 @@ import org.gcube.portlets.user.speciesdiscovery.shared.SearchByQueryParameter;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchFilters; import org.gcube.portlets.user.speciesdiscovery.shared.SearchFilters;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType; import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchType; import org.gcube.portlets.user.speciesdiscovery.shared.SearchType;
import org.gcube.portlets.user.speciesdiscovery.shared.SessionExpired;
import org.gcube.portlets.user.speciesdiscovery.shared.SpeciesCapability; import org.gcube.portlets.user.speciesdiscovery.shared.SpeciesCapability;
import org.gcube.portlets.user.speciesdiscovery.shared.filter.ResultFilter; import org.gcube.portlets.user.speciesdiscovery.shared.filter.ResultFilter;
import org.gcube.portlets.user.speciesdiscovery.shared.util.SearchTermValidator; import org.gcube.portlets.user.speciesdiscovery.shared.util.SearchTermValidator;
import org.gcube.portlets.widgets.sessionchecker.client.CheckSession;
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSaveNotification.WorskpaceExplorerSaveNotificationListener; import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSaveNotification.WorskpaceExplorerSaveNotificationListener;
import org.gcube.portlets.widgets.wsexplorer.client.save.WorkspaceExplorerSaveDialog; import org.gcube.portlets.widgets.wsexplorer.client.save.WorkspaceExplorerSaveDialog;
import org.gcube.portlets.widgets.wsexplorer.shared.Item; import org.gcube.portlets.widgets.wsexplorer.shared.Item;
@ -1763,6 +1765,8 @@ public class SearchController {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
if(caught instanceof SessionExpired)
CheckSession.showLogoutDialog();
} }
@Override @Override
@ -1794,6 +1798,8 @@ public class SearchController {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
if(caught instanceof SessionExpired)
CheckSession.showLogoutDialog();
} }
@Override @Override
@ -1826,6 +1832,9 @@ public class SearchController {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
if(caught instanceof SessionExpired)
CheckSession.showLogoutDialog();
} }
@Override @Override

View File

@ -24,6 +24,7 @@ import org.gcube.portlets.user.speciesdiscovery.shared.SearchFilters;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResult; import org.gcube.portlets.user.speciesdiscovery.shared.SearchResult;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchServiceException; import org.gcube.portlets.user.speciesdiscovery.shared.SearchServiceException;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchStatus; import org.gcube.portlets.user.speciesdiscovery.shared.SearchStatus;
import org.gcube.portlets.user.speciesdiscovery.shared.SessionExpired;
import org.gcube.portlets.user.speciesdiscovery.shared.Taxon; import org.gcube.portlets.user.speciesdiscovery.shared.Taxon;
import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow; import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterCommonNameDataSourceForResultRow; import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterCommonNameDataSourceForResultRow;
@ -89,7 +90,7 @@ public interface TaxonomySearchService extends RemoteService {
public SearchResult<ResultRow> getSearchResultRows(int start, int limit, public SearchResult<ResultRow> getSearchResultRows(int start, int limit,
ResultFilter activeFiltersObject, boolean onlySelected) ResultFilter activeFiltersObject, boolean onlySelected)
throws SearchServiceException; throws SearchServiceException, SessionExpired;
public SearchResult<TaxonomyRow> getSearchTaxonomyRow(int start, int limit, public SearchResult<TaxonomyRow> getSearchTaxonomyRow(int start, int limit,
ResultFilter activeFiltersObject, boolean showOnlySelected) ResultFilter activeFiltersObject, boolean showOnlySelected)
@ -104,7 +105,7 @@ public interface TaxonomySearchService extends RemoteService {
public OccurrencesStatus getCountOfOccurrencesBatch() public OccurrencesStatus getCountOfOccurrencesBatch()
throws SearchServiceException; throws SearchServiceException;
public List<JobTaxonomyModel> getListTaxonomyJobs() throws Exception; public List<JobTaxonomyModel> getListTaxonomyJobs() throws SessionExpired, Exception;
// public JobTaxonomyModel createTaxonomyJobByChildren(TaxonomyRow taxonomy, // public JobTaxonomyModel createTaxonomyJobByChildren(TaxonomyRow taxonomy,
// String dataSourceName) throws Exception; // String dataSourceName) throws Exception;
@ -124,7 +125,7 @@ public interface TaxonomySearchService extends RemoteService {
SaveFileFormat saveFileFormat, OccurrencesSaveEnum csvType, SaveFileFormat saveFileFormat, OccurrencesSaveEnum csvType,
boolean isByDataSource, int expectedOccurrence) throws Exception; boolean isByDataSource, int expectedOccurrence) throws Exception;
public List<JobOccurrencesModel> getListOccurrencesJob() throws Exception; public List<JobOccurrencesModel> getListOccurrencesJob() throws SessionExpired, Exception;
public boolean saveOccurrenceJob(JobOccurrencesModel jobModel, public boolean saveOccurrenceJob(JobOccurrencesModel jobModel,
String destinationFolderId, String fileName, String scientificName, String destinationFolderId, String fileName, String scientificName,
@ -208,8 +209,7 @@ public interface TaxonomySearchService extends RemoteService {
* @return * @return
* @throws Exception * @throws Exception
*/ */
List<JobGisLayerModel> getListGisLayerJob() List<JobGisLayerModel> getListGisLayerJob() throws SessionExpired, Exception;
throws Exception;
boolean saveGisLayerAsWsLink( boolean saveGisLayerAsWsLink(
JobGisLayerModel jobGisLayer, String destinationFolderId, String fileName) throws Exception; JobGisLayerModel jobGisLayer, String destinationFolderId, String fileName) throws Exception;

View File

@ -30,6 +30,7 @@ import org.gcube.portlets.user.speciesdiscovery.server.stream.CloseableIterator;
import org.gcube.portlets.user.speciesdiscovery.shared.CommonName; import org.gcube.portlets.user.speciesdiscovery.shared.CommonName;
import org.gcube.portlets.user.speciesdiscovery.shared.ItemParameter; import org.gcube.portlets.user.speciesdiscovery.shared.ItemParameter;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchServiceException; import org.gcube.portlets.user.speciesdiscovery.shared.SearchServiceException;
import org.gcube.portlets.user.speciesdiscovery.shared.SessionExpired;
import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow; import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
@ -190,6 +191,9 @@ public class TaxonomyRowTable extends HttpServlet {
} catch (Exception e) { } catch (Exception e) {
if(e instanceof SessionExpired)
throw new SessionExpired("Sorry, user session is expired, Refresh and Try again");
logger.error("Error in TaxonomyRowTable servlet ",e); logger.error("Error in TaxonomyRowTable servlet ",e);
throw new Exception("Error in ResultRowTable servlet ", e); throw new Exception("Error in ResultRowTable servlet ", e);
} }
@ -199,7 +203,12 @@ public class TaxonomyRowTable extends HttpServlet {
out.close(); //CLOSE STREAM out.close(); //CLOSE STREAM
}catch (Exception e) { }catch (Exception e) {
String error = "Sorry an error occurred when creating the table for taxonomy row with id: "+taxonomyServiceRowID; String error;
if(e instanceof SessionExpired)
error = e.getMessage();
else
error = "Sorry an error occurred when creating the table for taxonomy row with id: "+taxonomyServiceRowID;
if(out==null){ if(out==null){
try{ try{

View File

@ -93,6 +93,7 @@ import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchServiceException; import org.gcube.portlets.user.speciesdiscovery.shared.SearchServiceException;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchStatus; import org.gcube.portlets.user.speciesdiscovery.shared.SearchStatus;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchType; import org.gcube.portlets.user.speciesdiscovery.shared.SearchType;
import org.gcube.portlets.user.speciesdiscovery.shared.SessionExpired;
import org.gcube.portlets.user.speciesdiscovery.shared.Taxon; import org.gcube.portlets.user.speciesdiscovery.shared.Taxon;
import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyJob; import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyJob;
import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow; import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
@ -128,17 +129,12 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
public static final String BASETAXONOMY = "Kingdom"; public static final String BASETAXONOMY = "Kingdom";
public static final String UNK = "Unk"; public static final String UNK = "Unk";
// static {
// Logger root = Logger.getLogger("org.gcube.portlets.user.speciesdiscovery");
// root.setLevel(Level.ALL);
// }
/** /**
* Gets the ASL session. * Gets the ASL session.
* *
* @return the ASL session * @return the ASL session
*/ */
protected ASLSession getASLSession() protected ASLSession getASLSession()
{ {
return SessionUtil.getAslSession(this.getThreadLocalRequest().getSession()); return SessionUtil.getAslSession(this.getThreadLocalRequest().getSession());
} }
@ -334,7 +330,7 @@ protected ASLSession getASLSession()
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public SearchResult<ResultRow> getSearchResultRows(int start, int limit, ResultFilter activeFiltersObject, boolean onlySelected) throws SearchServiceException { public SearchResult<ResultRow> getSearchResultRows(int start, int limit, ResultFilter activeFiltersObject, boolean onlySelected) throws SessionExpired, SearchServiceException {
logger.info("getSearchResultRows start: "+start+" limit: "+limit+" onlySelected: "+onlySelected); logger.info("getSearchResultRows start: "+start+" limit: "+limit+" onlySelected: "+onlySelected);
Long startTime = System.currentTimeMillis(); Long startTime = System.currentTimeMillis();
@ -389,6 +385,10 @@ protected ASLSession getASLSession()
String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime)); String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
logger.info("returning "+chunk.size()+" elements in " + time); logger.info("returning "+chunk.size()+" elements in " + time);
} catch (Exception e) { } catch (Exception e) {
if(e instanceof SessionExpired)
throw new SessionExpired("The session is expired");
logger.error("Error in getSearchResultRows ", e); logger.error("Error in getSearchResultRows ", e);
throw new SearchServiceException(e.getMessage()); throw new SearchServiceException(e.getMessage());
} }
@ -1314,7 +1314,7 @@ protected ASLSession getASLSession()
* @see org.gcube.portlets.user.speciesdiscovery.client.rpc.TaxonomySearchService#getListTaxonomyJobs() * @see org.gcube.portlets.user.speciesdiscovery.client.rpc.TaxonomySearchService#getListTaxonomyJobs()
*/ */
@Override @Override
public List<JobTaxonomyModel> getListTaxonomyJobs() throws Exception { public List<JobTaxonomyModel> getListTaxonomyJobs() throws SessionExpired, Exception {
logger.info("getListTaxonomyJobs... "); logger.info("getListTaxonomyJobs... ");
List<JobTaxonomyModel> listJobs = new ArrayList<JobTaxonomyModel>(); List<JobTaxonomyModel> listJobs = new ArrayList<JobTaxonomyModel>();
@ -1836,7 +1836,7 @@ protected ASLSession getASLSession()
* @see org.gcube.portlets.user.speciesdiscovery.client.rpc.TaxonomySearchService#getListOccurrencesJob() * @see org.gcube.portlets.user.speciesdiscovery.client.rpc.TaxonomySearchService#getListOccurrencesJob()
*/ */
@Override @Override
public List<JobOccurrencesModel> getListOccurrencesJob() throws Exception{ public List<JobOccurrencesModel> getListOccurrencesJob() throws SessionExpired, Exception{
logger.info("getListOccurencesJob... "); logger.info("getListOccurencesJob... ");
List<JobOccurrencesModel> listJobs = new ArrayList<JobOccurrencesModel>(); List<JobOccurrencesModel> listJobs = new ArrayList<JobOccurrencesModel>();
@ -1876,6 +1876,13 @@ protected ASLSession getASLSession()
} }
} catch (Exception e) { } catch (Exception e) {
if(e instanceof SessionExpired){
logger.error("Session is expired");
throw new SessionExpired(e.getMessage());
}
logger.error("Error on get iterator "+e, e); logger.error("Error on get iterator "+e, e);
} }
@ -1888,7 +1895,7 @@ protected ASLSession getASLSession()
* @see org.gcube.portlets.user.speciesdiscovery.client.rpc.TaxonomySearchService#getListGisLayerJob() * @see org.gcube.portlets.user.speciesdiscovery.client.rpc.TaxonomySearchService#getListGisLayerJob()
*/ */
@Override @Override
public List<JobGisLayerModel> getListGisLayerJob() throws Exception{ public List<JobGisLayerModel> getListGisLayerJob() throws SessionExpired, Exception{
logger.info("getListGisLayerJob... "); logger.info("getListGisLayerJob... ");
List<JobGisLayerModel> listJobs = new ArrayList<JobGisLayerModel>(); List<JobGisLayerModel> listJobs = new ArrayList<JobGisLayerModel>();

View File

@ -107,7 +107,7 @@ public class SessionUtil {
//for test only //for test only
user = "test.user"; user = "test.user";
String scope = "/gcube/devsec"; //Development String scope = "/gcube/preprod/preVRE"; //Development
// String scope = "/d4science.research-infrastructures.eu/gCubeApps/BiodiversityResearchEnvironment"; //Production // String scope = "/d4science.research-infrastructures.eu/gCubeApps/BiodiversityResearchEnvironment"; //Production
httpSession.setAttribute(USERNAME_ATTRIBUTE, user); httpSession.setAttribute(USERNAME_ATTRIBUTE, user);
ASLSession session = SessionManager.getInstance().getASLSession(sessionID, user); ASLSession session = SessionManager.getInstance().getASLSession(sessionID, user);

View File

@ -18,13 +18,15 @@ import org.gcube.portlets.user.speciesdiscovery.server.persistence.dao.TaxonRowP
import org.gcube.portlets.user.speciesdiscovery.server.persistence.dao.TaxonomyJobPersistence; import org.gcube.portlets.user.speciesdiscovery.server.persistence.dao.TaxonomyJobPersistence;
import org.gcube.portlets.user.speciesdiscovery.server.persistence.dao.TaxonomyRowPersistence; import org.gcube.portlets.user.speciesdiscovery.server.persistence.dao.TaxonomyRowPersistence;
import org.gcube.portlets.user.speciesdiscovery.shared.DatabaseServiceException; import org.gcube.portlets.user.speciesdiscovery.shared.DatabaseServiceException;
import org.gcube.portlets.user.speciesdiscovery.shared.SessionExpired;
/** /**
* The Class DaoSession. * The Class DaoSession.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Feb 9, 2017 * Mar 17, 2017
*/ */
public class DaoSession { public class DaoSession {
@ -35,14 +37,48 @@ public class DaoSession {
private static final String JDBCDRIVER = "jdbc:h2:"; private static final String JDBCDRIVER = "jdbc:h2:";
/**
* Check asl session.
*
* @param session the session
* @return true, if is valid
* @throws SessionExpired the session expired
*/
public static boolean checkASLSession(ASLSession session) throws SessionExpired{
if(session==null){
String error = "ASL session is null!!!!";
logger.error(error);
throw new SessionExpired(error);
}
String username = session.getUsername();
String scope = session.getScopeName();
if(username==null || username.isEmpty() ){
String error = "Username is null or empty, throwing session expired exception";
logger.error(error);
throw new SessionExpired(error);
}
if(scope==null || scope.isEmpty() ){
String error = "Scope is null or empty, throwing session expired exception";
logger.error(error);
throw new SessionExpired(error);
}
logger.trace("Session is valid: [username: "+username+", scope: "+scope+"]");
return true;
}
/** /**
* Gets the username scope value. * Gets the username scope value.
* *
* @param username the username * @param username the username
* @param scope the scope * @param scope the scope
* @return the username scope value * @return the username scope value
* @throws SessionExpired the session expired
*/ */
public static String getUsernameScopeValue(String username, String scope){ public static String getUsernameScopeValue(String username, String scope) throws SessionExpired{
scope = scope.replaceAll("/",""); scope = scope.replaceAll("/","");
username = username.replaceAll("\\.",""); username = username.replaceAll("\\.","");
@ -51,8 +87,6 @@ public class DaoSession {
} }
/** /**
* Gets the tomcat folder. * Gets the tomcat folder.
* *
@ -75,12 +109,12 @@ public class DaoSession {
* *
* @param session the session * @param session the session
* @return the connection url * @return the connection url
* @throws SessionExpired the session expired
*/ */
public static String getConnectionUrl(ASLSession session){ public static String getConnectionUrl(ASLSession session) throws SessionExpired{
String username = session.getUsername(); checkASLSession(session);
String scope = session.getScopeName(); return JDBCDRIVER +getTomcatFolder()+PERSISTENCE_H2DBSPECIES_H2+getUsernameScopeValue(session.getUsername(),session.getScopeName())+";create=true";
return JDBCDRIVER +getTomcatFolder()+PERSISTENCE_H2DBSPECIES_H2+getUsernameScopeValue(username,scope)+";create=true";
} }
@ -112,8 +146,10 @@ public class DaoSession {
* *
* @param session the session * @param session the session
* @return the entity manager * @return the entity manager
* @throws SessionExpired the session expired
* @throws Exception the exception
*/ */
public static EntityManager newEntityManager(ASLSession session){ public static EntityManager newEntityManager(ASLSession session) throws SessionExpired, Exception{
return getEntityManagerFactory(session).createEntityManager(); return getEntityManagerFactory(session).createEntityManager();
} }
@ -123,8 +159,10 @@ public class DaoSession {
* *
* @param session the session * @param session the session
* @return the entity manager factory * @return the entity manager factory
* @throws SessionExpired the session expired
* @throws Exception the exception
*/ */
public static EntityManagerFactory getEntityManagerFactory(ASLSession session){ public static EntityManagerFactory getEntityManagerFactory(ASLSession session) throws SessionExpired, Exception{
EntityManagerFactory factory = SessionUtil.getEntityManagerFactory(session); EntityManagerFactory factory = SessionUtil.getEntityManagerFactory(session);
@ -142,11 +180,12 @@ public class DaoSession {
* *
* @param session the session * @param session the session
* @return the occurrences job dao * @return the occurrences job dao
* @throws SessionExpired the session expired
* @throws Exception the exception * @throws Exception the exception
*/ */
public static OccurrenceJobPersistence getOccurrencesJobDAO(ASLSession session) throws Exception public static OccurrenceJobPersistence getOccurrencesJobDAO(ASLSession session) throws SessionExpired, Exception{
{
checkASLSession(session);
OccurrenceJobPersistence occurrencesJobDao = SessionUtil.getCurrentDaoOccurrencesJob(session); OccurrenceJobPersistence occurrencesJobDao = SessionUtil.getCurrentDaoOccurrencesJob(session);
if(occurrencesJobDao==null){ if(occurrencesJobDao==null){
@ -164,10 +203,12 @@ public class DaoSession {
* *
* @param session the session * @param session the session
* @return the gis layers job dao * @return the gis layers job dao
* @throws SessionExpired the session expired
* @throws Exception the exception * @throws Exception the exception
*/ */
public static GisLayerJobPersistence getGisLayersJobDAO(ASLSession session) throws Exception { public static GisLayerJobPersistence getGisLayersJobDAO(ASLSession session) throws SessionExpired, Exception{
checkASLSession(session);
GisLayerJobPersistence gisLayerJobDao = SessionUtil.getCurrentGisLayersJob(session); GisLayerJobPersistence gisLayerJobDao = SessionUtil.getCurrentGisLayersJob(session);
if(gisLayerJobDao==null){ if(gisLayerJobDao==null){
@ -184,8 +225,10 @@ public class DaoSession {
* *
* @param session the session * @param session the session
* @return the gis layer job persistence * @return the gis layer job persistence
* @throws SessionExpired the session expired
* @throws Exception the exception
*/ */
private static GisLayerJobPersistence initGisLayerJobsDao(ASLSession session) { private static GisLayerJobPersistence initGisLayerJobsDao(ASLSession session) throws SessionExpired, Exception {
GisLayerJobPersistence gisLayerJobP = new GisLayerJobPersistence(getEntityManagerFactory(session)); GisLayerJobPersistence gisLayerJobP = new GisLayerJobPersistence(getEntityManagerFactory(session));
SessionUtil.setCurrentEJBGisLayerJob(session, gisLayerJobP); SessionUtil.setCurrentEJBGisLayerJob(session, gisLayerJobP);
return gisLayerJobP; return gisLayerJobP;
@ -196,11 +239,11 @@ public class DaoSession {
* *
* @param session the session * @param session the session
* @return the taxonomy job dao * @return the taxonomy job dao
* @throws SessionExpired the session expired
* @throws Exception the exception * @throws Exception the exception
*/ */
public static TaxonomyJobPersistence getTaxonomyJobDAO(ASLSession session) throws Exception public static TaxonomyJobPersistence getTaxonomyJobDAO(ASLSession session) throws SessionExpired, Exception {
{ checkASLSession(session);
TaxonomyJobPersistence taxonomyJobPeristence = SessionUtil.getCurrentDAOTaxonomyJob(session); TaxonomyJobPersistence taxonomyJobPeristence = SessionUtil.getCurrentDAOTaxonomyJob(session);
if(taxonomyJobPeristence==null){ if(taxonomyJobPeristence==null){
@ -216,9 +259,12 @@ public class DaoSession {
* *
* @param session the session * @param session the session
* @return the entity manager factory * @return the entity manager factory
* @throws SessionExpired the session expired
* @throws Exception the exception
*/ */
public static EntityManagerFactory createEntityManagerFactory(ASLSession session){ public static EntityManagerFactory createEntityManagerFactory(ASLSession session) throws SessionExpired, Exception {
checkASLSession(session);
Map<String,String> properties = new HashMap<String, String>(); Map<String,String> properties = new HashMap<String, String>();
// properties.put("javax.persistence.jdbc.driver", jdbcDriverH2); // properties.put("javax.persistence.jdbc.driver", jdbcDriverH2);
try{ try{
@ -226,9 +272,8 @@ public class DaoSession {
} }
catch (Exception e) { catch (Exception e) {
logger.error("error on get connection url "+e, e); logger.error("error on get connection url "+e, e);
String username = session.getUsername(); checkASLSession(session);
String scope = session.getScopeName(); properties.put("javax.persistence.jdbc.url", JDBCDRIVER+getTomcatFolder()+"/temp/h2dbspecies/h2"+getUsernameScopeValue(session.getUsername(),session.getScopeName())+";create=true");
properties.put("javax.persistence.jdbc.url", JDBCDRIVER+getTomcatFolder()+"/temp/h2dbspecies/h2"+getUsernameScopeValue(username,scope)+";create=true");
} }
//emf = Persistence.createEntityManagerFactory("jpablogPUnit"); //emf = Persistence.createEntityManagerFactory("jpablogPUnit");
return Persistence.createEntityManagerFactory("SPD_PERSISTENCE_FACTORY",properties); return Persistence.createEntityManagerFactory("SPD_PERSISTENCE_FACTORY",properties);
@ -241,14 +286,11 @@ public class DaoSession {
* *
* @param session the session * @param session the session
* @return the occurrence job persistence * @return the occurrence job persistence
* @throws SessionExpired the session expired
* @throws Exception the exception * @throws Exception the exception
*/ */
public static OccurrenceJobPersistence initOccurrencesJobsDao(ASLSession session) throws Exception public static OccurrenceJobPersistence initOccurrencesJobsDao(ASLSession session) throws SessionExpired, Exception {
{ return createOccurrencesJobDao(session.getUsername(), session.getScopeName(), session);
String username = session.getUsername();
String scope = session.getScopeName();
return createOccurrencesJobDao(username, scope, session);
} }
@ -274,9 +316,10 @@ public class DaoSession {
* @param scope the scope * @param scope the scope
* @param session the session * @param session the session
* @return the occurrence job persistence * @return the occurrence job persistence
* @throws SessionExpired the session expired
* @throws Exception the exception * @throws Exception the exception
*/ */
public static OccurrenceJobPersistence createOccurrencesJobDao(String username, String scope, ASLSession session) throws Exception{ public static OccurrenceJobPersistence createOccurrencesJobDao(String username, String scope, ASLSession session) throws SessionExpired, Exception{
OccurrenceJobPersistence occurrenceJobPersistence = new OccurrenceJobPersistence(getEntityManagerFactory(session)); OccurrenceJobPersistence occurrenceJobPersistence = new OccurrenceJobPersistence(getEntityManagerFactory(session));
SessionUtil.setCurrentEJBOccurrencesJob(session, occurrenceJobPersistence); SessionUtil.setCurrentEJBOccurrencesJob(session, occurrenceJobPersistence);
@ -310,11 +353,11 @@ public class DaoSession {
* *
* @param session the session * @param session the session
* @return the occurrence dao * @return the occurrence dao
* @throws SessionExpired the session expired
* @throws Exception the exception * @throws Exception the exception
*/ */
public static OccurrenceRowPersistence getOccurrenceDAO(ASLSession session) throws Exception public static OccurrenceRowPersistence getOccurrenceDAO(ASLSession session) throws SessionExpired, Exception {
{ checkASLSession(session);
OccurrenceRowPersistence occurrenceEJB = SessionUtil.getCurrentEJBOccurrence(session); OccurrenceRowPersistence occurrenceEJB = SessionUtil.getCurrentEJBOccurrence(session);
if(occurrenceEJB==null){ if(occurrenceEJB==null){
@ -330,10 +373,10 @@ public class DaoSession {
* *
* @param session the session * @param session the session
* @return the taxon row persistence * @return the taxon row persistence
* @throws SessionExpired the session expired
* @throws Exception the exception * @throws Exception the exception
*/ */
public static TaxonRowPersistence initTaxonDao(ASLSession session) throws Exception public static TaxonRowPersistence initTaxonDao(ASLSession session) throws SessionExpired, Exception {
{
TaxonRowPersistence taxonRowPersistence = new TaxonRowPersistence(getEntityManagerFactory(session)); TaxonRowPersistence taxonRowPersistence = new TaxonRowPersistence(getEntityManagerFactory(session));
SessionUtil.setCurrentEJBTaxonRow(session, taxonRowPersistence); SessionUtil.setCurrentEJBTaxonRow(session, taxonRowPersistence);
@ -367,11 +410,11 @@ public class DaoSession {
* *
* @param session the session * @param session the session
* @return the taxon dao * @return the taxon dao
* @throws SessionExpired the session expired
* @throws Exception the exception * @throws Exception the exception
*/ */
public static TaxonRowPersistence getTaxonDAO(ASLSession session) throws Exception public static TaxonRowPersistence getTaxonDAO(ASLSession session) throws SessionExpired, Exception{
{ checkASLSession(session);
TaxonRowPersistence taxonDao = SessionUtil.getCurrentEJBTaxonRow(session); TaxonRowPersistence taxonDao = SessionUtil.getCurrentEJBTaxonRow(session);
if(taxonDao==null){ if(taxonDao==null){
@ -390,10 +433,11 @@ public class DaoSession {
* *
* @param session the session * @param session the session
* @return the taxonomy dao * @return the taxonomy dao
* @throws SessionExpired the session expired
* @throws Exception the exception * @throws Exception the exception
*/ */
public static TaxonomyRowPersistence getTaxonomyDAO(ASLSession session) throws Exception public static TaxonomyRowPersistence getTaxonomyDAO(ASLSession session) throws SessionExpired, Exception{
{ checkASLSession(session);
logger.trace("In getTaxonomyDAO..."); logger.trace("In getTaxonomyDAO...");
TaxonomyRowPersistence taxonItemDAO = SessionUtil.getCurrentEJBTaxonomyItem(session); TaxonomyRowPersistence taxonItemDAO = SessionUtil.getCurrentEJBTaxonomyItem(session);
@ -430,27 +474,19 @@ public class DaoSession {
* *
* @param session the session * @param session the session
* @return the result row dao * @return the result row dao
* @throws SessionExpired the session expired
* @throws Exception the exception * @throws Exception the exception
*/ */
public static ResultRowPersistence getResultRowDAO(ASLSession session) throws Exception public static ResultRowPersistence getResultRowDAO(ASLSession session) throws SessionExpired, Exception {
{ checkASLSession(session);
logger.trace("In getResultRowDAO..."); logger.trace("In getResultRowDAO...");
ResultRowPersistence resultRowEJB = SessionUtil.getCurrentEJBResultRow(session); ResultRowPersistence resultRowEJB = SessionUtil.getCurrentEJBResultRow(session);
if(resultRowEJB==null){ if(resultRowEJB==null){
resultRowEJB = initResultRowDao(session); resultRowEJB = initResultRowDao(session);
SessionUtil.setCurrentEJBResultRow(session, resultRowEJB); SessionUtil.setCurrentEJBResultRow(session, resultRowEJB);
} }
// logger.trace("Return result row Dao : " + resultRowEJB + " table name: " + resultRowDAO.getTableConfig().getTableName());
// logger.trace("session id: " + session.getExternalSessionID() + " sessione username: " +session.getUsername() + " session scope: "+session.getScopeName());
return resultRowEJB; return resultRowEJB;
} }
} }

View File

@ -0,0 +1,30 @@
/**
*
*/
package org.gcube.portlets.user.speciesdiscovery.shared;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Mar 17, 2017
*/
public class SessionExpired extends Exception {
/**
*
*/
private static final long serialVersionUID = -4412298198084979081L;
/**
*
*/
public SessionExpired() {
}
public SessionExpired(String arg0){
super(arg0);
}
}

View File

@ -4,6 +4,8 @@
<inherits name='com.google.gwt.user.User' /> <inherits name='com.google.gwt.user.User' />
<inherits name='org.gcube.portlets.widgets.wsexplorer.WorkspaceExplorer' /> <inherits name='org.gcube.portlets.widgets.wsexplorer.WorkspaceExplorer' />
<inherits name='org.gcube.portlets.widgets.sessionchecker.SessionChecker' />
<!-- Other module inherits --> <!-- Other module inherits -->
<inherits name="com.extjs.gxt.ui.GXT" /> <inherits name="com.extjs.gxt.ui.GXT" />

View File

@ -1,5 +1,5 @@
/** /**
* *
*/ */
package org.gcube.portlets.user.speciesdiscovery.client; package org.gcube.portlets.user.speciesdiscovery.client;
@ -16,6 +16,7 @@ import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.common.scope.impl.ScopeBean; import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.portlets.user.speciesdiscovery.server.persistence.DaoSession; import org.gcube.portlets.user.speciesdiscovery.server.persistence.DaoSession;
import org.gcube.portlets.user.speciesdiscovery.shared.ResultRow; import org.gcube.portlets.user.speciesdiscovery.shared.ResultRow;
import org.gcube.portlets.user.speciesdiscovery.shared.SessionExpired;
import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow; import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
/** /**
@ -23,53 +24,53 @@ import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
* *
*/ */
public class H2TestResultItemRetrievingAndConverting { public class H2TestResultItemRetrievingAndConverting {
private static final int MAX_ELEMENTS = 20; private static final int MAX_ELEMENTS = 20;
static String sessionID = "1"; static String sessionID = "1";
static String user = "test.user"; static String user = "test.user";
static ScopeBean scope; static ScopeBean scope;
static ASLSession session; static ASLSession session;
public static void main(String[] args) throws Exception public static void main(String[] args) throws Exception
{ {
session = SessionManager.getInstance().getASLSession(sessionID, user); session = SessionManager.getInstance().getASLSession(sessionID, user);
scope = new ScopeBean("/gcube/devsec"); scope = new ScopeBean("/gcube/devsec");
session.setScope(scope.toString()); session.setScope(scope.toString());
EntityManagerFactory factory = DaoSession.getEntityManagerFactory(session); EntityManagerFactory factory = DaoSession.getEntityManagerFactory(session);
EntityManager em = factory.createEntityManager(); EntityManager em = factory.createEntityManager();
// ScopeProvider.instance.set("/gcube/devsec"); // ScopeProvider.instance.set("/gcube/devsec");
int removed; int removed;
String tableName; String tableName;
List<ResultRow> list; List<ResultRow> list;
// String tableName = "ParentTaxonomyRow"; // String tableName = "ParentTaxonomyRow";
// //
// List<ResultRow> list = getList(em, tableName); // List<ResultRow> list = getList(em, tableName);
// //
// System.out.println("list "+tableName+ "size is "+list.size()); // System.out.println("list "+tableName+ "size is "+list.size());
// em = factory.createEntityManager(); // em = factory.createEntityManager();
// removed = removeAll(em, tableName); // removed = removeAll(em, tableName);
// //
// System.out.println("removed " +removed); // System.out.println("removed " +removed);
tableName = "ResultRow"; tableName = "ResultRow";
em = factory.createEntityManager(); em = factory.createEntityManager();
list = getList(em, tableName); list = getList(em, tableName);
System.out.println("list "+tableName+ "size is "+list.size()); System.out.println("list "+tableName+ "size is "+list.size());
// removeAll(em, "ParentTaxonomyRow"); // removeAll(em, "ParentTaxonomyRow");
// em = factory.createEntityManager(); // em = factory.createEntityManager();
// removed = removeAll(em, tableName); // removed = removeAll(em, tableName);
// System.out.println("removed " +removed); // System.out.println("removed " +removed);
@ -87,130 +88,130 @@ public class H2TestResultItemRetrievingAndConverting {
// CloseableIterator<FetchingElement> output = IteratorChainBuilder.buildChain(input, resultType, session); // CloseableIterator<FetchingElement> output = IteratorChainBuilder.buildChain(input, resultType, session);
// //
// FetchingSession<TaxonomyRow> fetchingSession = (FetchingSession<TaxonomyRow>) FetchingSessionUtil.createFetchingSession(output, resultType, session); // FetchingSession<TaxonomyRow> fetchingSession = (FetchingSession<TaxonomyRow>) FetchingSessionUtil.createFetchingSession(output, resultType, session);
// //
// //
// while(!fetchingSession.isComplete()) { // while(!fetchingSession.isComplete()) {
// //
// System.out.println((System.currentTimeMillis()-start)+" buffer size "+fetchingSession.getBufferSize()); // System.out.println((System.currentTimeMillis()-start)+" buffer size "+fetchingSession.getBufferSize());
// last = System.currentTimeMillis(); // last = System.currentTimeMillis();
// //
// Thread.sleep(1000); // Thread.sleep(1000);
// //
// System.out.println("COMPLETE: "+(System.currentTimeMillis()-last)+"ms from last item to close the stream; buffer size "+fetchingSession.getBufferSize()); // System.out.println("COMPLETE: "+(System.currentTimeMillis()-last)+"ms from last item to close the stream; buffer size "+fetchingSession.getBufferSize());
// //
// System.out.println(fetchingSession.getBufferSize() + " results in "+(System.currentTimeMillis()-start)+"ms total; "+(last-start)+"ms from first to last result"); // System.out.println(fetchingSession.getBufferSize() + " results in "+(System.currentTimeMillis()-start)+"ms total; "+(last-start)+"ms from first to last result");
// } // }
// System.out.println("Start time: "+last); // System.out.println("Start time: "+last);
// //
// while(output.hasNext()) { // while(output.hasNext()) {
// //
// System.out.println((System.currentTimeMillis()-last)+"ms "+output.next()); // System.out.println((System.currentTimeMillis()-last)+"ms "+output.next());
// last = System.currentTimeMillis(); // last = System.currentTimeMillis();
// counter++; // counter++;
// } // }
// Stream<ResultElement> input = taxonomyService.searchByQuery2("'sarda sarda' as ScientificName return Taxon"); // Stream<ResultElement> input = taxonomyService.searchByQuery2("'sarda sarda' as ScientificName return Taxon");
// //from ResultItem to ResultRow // //from ResultItem to ResultRow
//// List<ResultItem> listElements = new ArrayList<ResultItem>(); //// List<ResultItem> listElements = new ArrayList<ResultItem>();
//// List<ResultRow> listRR = new ArrayList<ResultRow>(); //// List<ResultRow> listRR = new ArrayList<ResultRow>();
//// ResultItemConverter converter = new ResultItemConverter(session); //// ResultItemConverter converter = new ResultItemConverter(session);
// //
// TaxonomyItemConverter converter = new TaxonomyItemConverter(session); // TaxonomyItemConverter converter = new TaxonomyItemConverter(session);
// List<TaxonomyRow> listRR = new ArrayList<TaxonomyRow>(); // List<TaxonomyRow> listRR = new ArrayList<TaxonomyRow>();
// List<TaxonomyItem> listElements = new ArrayList<TaxonomyItem>(); // List<TaxonomyItem> listElements = new ArrayList<TaxonomyItem>();
// //
// while(input.hasNext()) { // while(input.hasNext()) {
// //
//// ResultItem result = (ResultItem) input.next(); //// ResultItem result = (ResultItem) input.next();
// //
// TaxonomyItem result = (TaxonomyItem) input.next(); // TaxonomyItem result = (TaxonomyItem) input.next();
// //
// System.out.println((System.currentTimeMillis()-last)+" ms to recover "+result); // System.out.println((System.currentTimeMillis()-last)+" ms to recover "+result);
// last = System.currentTimeMillis(); // last = System.currentTimeMillis();
// counter++; // counter++;
// //
// listElements.add(result); // listElements.add(result);
// //
// listRR.add(converter.convert(result)); // listRR.add(converter.convert(result));
// //
// System.out.println((System.currentTimeMillis()-last)+" ms to convert "+result); // System.out.println((System.currentTimeMillis()-last)+" ms to convert "+result);
// //
// if(MAX_ELEMENTS == counter) // if(MAX_ELEMENTS == counter)
// break; // break;
// } // }
// //
// input.close(); // input.close();
// //
// counter = 0; // counter = 0;
// start = System.currentTimeMillis(); // start = System.currentTimeMillis();
// last = System.currentTimeMillis(); // last = System.currentTimeMillis();
//
//
//// for (ResultRow resultRow : listRR) { //// for (ResultRow resultRow : listRR) {
// for (TaxonomyRow resultRow : listRR) { // for (TaxonomyRow resultRow : listRR) {
// //
// System.out.println(counter + ")" + (System.currentTimeMillis()-last)+" ms "+resultRow); // System.out.println(counter + ")" + (System.currentTimeMillis()-last)+" ms "+resultRow);
// last = System.currentTimeMillis(); // last = System.currentTimeMillis();
// //
// //
// try{ // try{
// //
//// storeTaxonParents(resultRow); //// storeTaxonParents(resultRow);
//// storeCommonName(listElements.get(counter), resultRow); //// storeCommonName(listElements.get(counter), resultRow);
// storeRR(resultRow); // storeRR(resultRow);
// //
// }catch (Exception e) { // }catch (Exception e) {
// e.printStackTrace(); // e.printStackTrace();
// } // }
// //
// if(counter==50) // if(counter==50)
// break; // break;
// //
// counter++; // counter++;
// } // }
// System.out.println("BUFFER SIZE: " + fetchingSession.getBuffer().getList().size()); // System.out.println("BUFFER SIZE: " + fetchingSession.getBuffer().getList().size());
// System.out.println("COMPLETE: "+(System.currentTimeMillis()-last)+" ms from last item to close the stream"); // System.out.println("COMPLETE: "+(System.currentTimeMillis()-last)+" ms from last item to close the stream");
// //
// System.out.println(counter + " results in "+(System.currentTimeMillis()-start)+" ms total; "+(last-start)+" ms from first to last result"); // System.out.println(counter + " results in "+(System.currentTimeMillis()-start)+" ms total; "+(last-start)+" ms from first to last result");
List<String> listServiceId = new ArrayList<String>(); List<String> listServiceId = new ArrayList<String>();
int i = 0; int i = 0;
for (ResultRow rr : list) { for (ResultRow rr : list) {
listServiceId.add(rr.getIdToString()); listServiceId.add(rr.getIdToString());
System.out.println(++i +")listserviceId "+listServiceId); System.out.println(++i +")listserviceId "+listServiceId);
if(i==30) if(i==30)
break; break;
} }
em = factory.createEntityManager(); em = factory.createEntityManager();
String queryStr = "select t from ResultRow t where t."+ResultRow.ID_FIELD+" IN :inclList"; String queryStr = "select t from ResultRow t where t."+ResultRow.ID_FIELD+" IN :inclList";
TypedQuery<ResultRow> query2 = em.createQuery(queryStr, ResultRow.class); TypedQuery<ResultRow> query2 = em.createQuery(queryStr, ResultRow.class);
query2.setParameter("inclList", listServiceId); query2.setParameter("inclList", listServiceId);
// query.setFirstResult(2); // query.setFirstResult(2);
// //
// query.setMaxResults(5); // query.setMaxResults(5);
start = System.currentTimeMillis(); start = System.currentTimeMillis();
List<ResultRow> results = query2.getResultList(); List<ResultRow> results = query2.getResultList();
// //
i = 0; i = 0;
for (ResultRow r: results) { for (ResultRow r: results) {
System.out.println("ResultRow query "+ ++i +") " + r); System.out.println("ResultRow query "+ ++i +") " + r);
@ -221,43 +222,43 @@ public class H2TestResultItemRetrievingAndConverting {
// //
// //
// CriteriaBuilder cb = em.getCriteriaBuilder(); // CriteriaBuilder cb = em.getCriteriaBuilder();
// //
// // Query for a List of objects. // // Query for a List of objects.
//// CriteriaQuery<Object> cq = cb.createQuery(); //// CriteriaQuery<Object> cq = cb.createQuery();
// //
// CriteriaQuery<Taxon> cq = cb.createQuery(Taxon.class); // CriteriaQuery<Taxon> cq = cb.createQuery(Taxon.class);
// //
// Root<Taxon> e = cq.from(Taxon.class); // Root<Taxon> e = cq.from(Taxon.class);
// //
// cq.where(cb.equal(e.get(Taxon.RANK), "class")); // cq.where(cb.equal(e.get(Taxon.RANK), "class"));
// //
// query = em.createQuery(cq); // query = em.createQuery(cq);
// //
// List<Taxon> result = query.getResultList(); // List<Taxon> result = query.getResultList();
// //
// for (Taxon taxon : result) { // for (Taxon taxon : result) {
// System.out.println("taxon: " + taxon); // System.out.println("taxon: " + taxon);
// } // }
} }
protected static void storeRR(TaxonomyRow row){ protected static void storeRR(TaxonomyRow row) throws SessionExpired, Exception{
EntityManagerFactory factory = DaoSession.getEntityManagerFactory(session); EntityManagerFactory factory = DaoSession.getEntityManagerFactory(session);
EntityManager em = factory.createEntityManager(); EntityManager em = factory.createEntityManager();
em.getTransaction().begin(); em.getTransaction().begin();
em.persist(row); em.persist(row);
em.getTransaction().commit(); em.getTransaction().commit();
em.close(); em.close();
} }
public static int removeAll(EntityManager em, String tableName) { public static int removeAll(EntityManager em, String tableName) {
int removed = 0; int removed = 0;
try { try {
@ -274,7 +275,7 @@ public class H2TestResultItemRetrievingAndConverting {
return removed; return removed;
} }
public static List<ResultRow> getList(EntityManager em, String tableName) { public static List<ResultRow> getList(EntityManager em, String tableName) {
List<ResultRow> listResultRow = new ArrayList<ResultRow>(); List<ResultRow> listResultRow = new ArrayList<ResultRow>();