From 6b87523db1c2e104f5bb7b927c006c568c4ecc3f Mon Sep 17 00:00:00 2001 From: Loredana Liccardo Date: Wed, 17 Sep 2014 08:27:30 +0000 Subject: [PATCH] bug fixed and related to the cache. File related to cache removed with the portlet unregistering. Class GWTdbManagerServiceImpl modified adding the method destroy that removes the cache and file encache.xml changed setting the parameter diskPersistent to false value in order to remove the file in temp folder. git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@99964 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../server/GWTdbManagerServiceImpl.java | 1488 ++++++++--------- src/main/resources/encache.xml | 2 +- 2 files changed, 738 insertions(+), 752 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/databasesmanager/server/GWTdbManagerServiceImpl.java b/src/main/java/org/gcube/portlets/user/databasesmanager/server/GWTdbManagerServiceImpl.java index 5edab1a..0999705 100644 --- a/src/main/java/org/gcube/portlets/user/databasesmanager/server/GWTdbManagerServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/databasesmanager/server/GWTdbManagerServiceImpl.java @@ -5,7 +5,6 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URL; @@ -56,12 +55,9 @@ import org.gcube.portlets.user.databasesmanager.client.datamodel.Row; import org.gcube.portlets.user.databasesmanager.client.utils.ConstantsPortlet; import org.gcube.portlets.user.databasesmanager.server.util.SessionUtil; import org.gcube.portlets.user.databasesmanager.server.util.WsUtil; - -import com.extjs.gxt.ui.client.core.El; import com.extjs.gxt.ui.client.data.BasePagingLoadResult; import com.extjs.gxt.ui.client.data.PagingLoadConfig; import com.extjs.gxt.ui.client.data.PagingLoadResult; -import com.google.gwt.dom.client.Element; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.thoughtworks.xstream.XStream; import org.apache.log4j.Logger; @@ -84,7 +80,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements public static List listAlgorithms; public GWTdbManagerServiceImpl() throws Exception { - } @Override @@ -92,45 +87,55 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements super.init(); - - //craete cache + // create cache try { - + // System.out.println("*** CACHE NOT EXISTING"); URL url = getClass().getResource("/encache.xml"); CacheManager cacheManager = CacheManager.newInstance(url); // getcache employeeCache = cacheManager.getEhcache("DBCache"); - String path = System.getenv("CATALINA_TMPDIR"); -// System.out.println("Path: " + -// this.getServletContext().getRealPath("")); - + // CacheConfiguration config = + // employeeCache.getCacheConfiguration(); + // String DiskCacheFolderName = "DBManagerDisk"; - CacheConfiguration config = employeeCache.getCacheConfiguration(); - String DiskCacheFolderName = "DBManagerDisk"; - // File f = new File(path+"/"+DiskCacheFolderName); // if (!f.exists()){ // f.mkdir(); // // } - - config.setDiskStorePath(path); + + // config.setDiskStorePath(path); // config.setDiskPersistent(true); // config.setOverflowToDisk(true); } catch (Exception e) { - logger.error("Failed to get cache: " + e); + logger.error("dbmanager-> Failed to get cache: " + e); e.printStackTrace(); - throw e; } + } - // File f = new File(path+"/"+DiskCacheFolderName); - // - // if (!f.exists()){ - // f.mkdir(); - // } + public void destroy() { + super.destroy(); + + try { + // System.out.println("*** REMOVING CACHE"); + CacheManager cacheManager = CacheManager.getInstance(); + if (cacheManager.cacheExists("DBCache")) { + // System.out.println("*** cache exist"); + cacheManager.removeCache("DBCache"); + // cacheManager.removalAll(); + // System.out.println("*** cache removed"); + } + + cacheManager.shutdown(); + + } catch (Exception e) { + // TODO: handle exception + logger.error("dbmanager-> " + e); + e.printStackTrace(); + } } @@ -140,8 +145,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements .getSession()); // the result generated in the LoadTables method -// List result = new ArrayList(); -// session.setAttribute("TablesResult", result); + // List result = new ArrayList(); + // session.setAttribute("TablesResult", result); // map that contains the submit query result and the related uid HashMap> submitQueryResult = new HashMap>(); @@ -153,16 +158,16 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements session.setAttribute("submitQueryResultParsed", submitQueryResultParsed); // information about a database -// String currentDB = ""; -// session.setAttribute("currentDB", currentDB); -// String previousDB = ""; -// session.setAttribute("previousDB", previousDB); + // String currentDB = ""; + // session.setAttribute("currentDB", currentDB); + // String previousDB = ""; + // session.setAttribute("previousDB", previousDB); // information about a schema -// String currentSchema = ""; -// session.setAttribute("currentSchema", currentSchema); -// String previousSchema = ""; -// session.setAttribute("previousSchema", previousSchema); + // String currentSchema = ""; + // session.setAttribute("currentSchema", currentSchema); + // String previousSchema = ""; + // session.setAttribute("previousSchema", previousSchema); // Hashmap that contains computationId with a uid key HashMap computationIDMap = new HashMap(); @@ -188,79 +193,76 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements // get algorithmId String algorithmId = "LISTDBNAMES"; - Parameter maxNumber = new Parameter("MaxNumber", "", "String", "-1"); inputParameters.add(maxNumber); - // check if the value is in cache. If data does not exist in cache - // the computation is started otherwise data are retrieved from - // cache. - - try { - - // get data from cache - // check if data exist considering as key the input parameters - // String key = inputParameters.get(0).getDefaultValue(); - String key = "listResources"; + // check if the value is in cache. If data does not exist in cache + // the computation is started otherwise data are retrieved from + // cache. - // System.out.println("***KEY: " + key); - // net.sf.ehcache.Element dataFromCache = - // employeeCache.get(key); - net.sf.ehcache.Element dataFromCache = getDataFromCache(key); + try { - Object value = null; - if (dataFromCache != null) { - value = dataFromCache.getObjectValue(); -// System.out.println("***GETTING DATA FROM CACHE"); - } - if (value != null) { - outputParameters = (List) value; - } else { - - - // start the computation -// System.out.println("***STARTING THE COMPUTATION"); - // create data structure for data output - ComputationOutput outputData = new ComputationOutput(); - // computationId - String computationId = startComputation(algorithmId, - inputParameters, outputData); + // get data from cache + // check if data exist considering as key the input parameters + // String key = inputParameters.get(0).getDefaultValue(); + String key = "listResources"; - // print check - // retrieve data - // logger.info("output data retrieved"); + // System.out.println("***KEY: " + key); + // net.sf.ehcache.Element dataFromCache = + // employeeCache.get(key); - // data output - LinkedHashMap mapValues = new LinkedHashMap(); - mapValues = outputData.getMapValues(); + net.sf.ehcache.Element dataFromCache = getDataFromCache(key); - for (int i = 0; i < mapValues.size(); i++) { - FileModel obj = new FileModel(mapValues.get(String - .valueOf(i))); - // obj.setIsLoaded(true); - outputParameters.add(obj); - } - - if (outputParameters != null - && outputParameters.size() != 0) { - // put data in cache - net.sf.ehcache.Element dataToCache = new net.sf.ehcache.Element( - key, outputParameters); - - insertDataIntoCache(dataToCache); - // employeeCache.put(dataToCache); - - } - - - } - - } catch (Exception e) { - // TODO: handle exception -// e.printStackTrace(); - throw new Exception("Failed to load data. " + e); + Object value = null; + if (dataFromCache != null) { + value = dataFromCache.getObjectValue(); + // System.out.println("***GETTING DATA FROM CACHE"); } -// } + if (value != null) { + outputParameters = (List) value; + } else { + + // start the computation + // System.out.println("***STARTING THE COMPUTATION"); + // create data structure for data output + ComputationOutput outputData = new ComputationOutput(); + // computationId + String computationId = startComputation(algorithmId, + inputParameters, outputData); + + // print check + // retrieve data + // logger.info("output data retrieved"); + + // data output + LinkedHashMap mapValues = new LinkedHashMap(); + mapValues = outputData.getMapValues(); + + for (int i = 0; i < mapValues.size(); i++) { + FileModel obj = new FileModel(mapValues.get(String + .valueOf(i))); + // obj.setIsLoaded(true); + outputParameters.add(obj); + } + + if (outputParameters != null && outputParameters.size() != 0) { + // put data in cache + net.sf.ehcache.Element dataToCache = new net.sf.ehcache.Element( + key, outputParameters); + + insertDataIntoCache(dataToCache); + + } + + } + + } catch (Exception e) { + // TODO: handle exception + // e.printStackTrace(); + // throw new Exception("Failed to load data. " + e); + throw e; + } + // } return outputParameters; } @@ -272,90 +274,87 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements List inputParameters = new ArrayList(); // data output LinkedHashMap outputParameters = new LinkedHashMap(); - + String algorithmId = "LISTDBINFO"; - - //print check - logger.info("dbmanager-> ResourceName: " - + resourceName); - - Parameter resource = new Parameter("ResourceName", "", "String", ""); - inputParameters.add(resource); - inputParameters.get(0).setValue(resourceName); - - try { - // get data from cache - // check if data exist considering as key the input parameters - String key = inputParameters.get(0).getValue(); - // System.out.println("***KEY: " + key); - // net.sf.ehcache.Element dataFromCache = - // employeeCache.get(key); + // print check + logger.info("dbmanager-> ResourceName: " + resourceName); - net.sf.ehcache.Element dataFromCache = getDataFromCache(key); + Parameter resource = new Parameter("ResourceName", "", "String", ""); + inputParameters.add(resource); + inputParameters.get(0).setValue(resourceName); - Object value = null; - if (dataFromCache != null) { - value = dataFromCache.getObjectValue(); - } - if (value != null) { - outputParameters = (LinkedHashMap) value; - // System.out.println("***GETTING DATA FROM CACHE"); - } else { - - // start the computation - // System.out.println("***STARTING THE COMPUTATION"); - // create data structure - ComputationOutput outputData = new ComputationOutput(); - // computation id - String computationId = startComputation(algorithmId, - inputParameters, outputData); + try { + // get data from cache + // check if data exist considering as key the input parameters + String key = inputParameters.get(0).getValue(); - // print check - // retrieve data - // logger.info("output data retrieved"); + // System.out.println("***KEY: " + key); + // net.sf.ehcache.Element dataFromCache = + // employeeCache.get(key); - // data output values - LinkedHashMap mapValues = new LinkedHashMap(); - // data output keys - LinkedHashMap mapKeys = new LinkedHashMap(); + net.sf.ehcache.Element dataFromCache = getDataFromCache(key); - mapValues = outputData.getMapValues(); - mapKeys = outputData.getmapKeys(); - - for (int i = 0; i < mapValues.size(); i++) { - FileModel obj = new FileModel(mapValues.get(String - .valueOf(i))); - // obj.setIsLoaded(true); - - // print check - // logger.info("value: " + - // mapValues.get(String.valueOf(i))); - // logger.info("key: " + - // mapKeys.get(String.valueOf(i))); - outputParameters.put(mapKeys.get(String.valueOf(i)), - obj); - } - - // write data in cache - if (outputParameters != null - && outputParameters.size() != 0) { - // put data in cache - net.sf.ehcache.Element dataToCache = new net.sf.ehcache.Element( - inputParameters.get(0).getValue(), - outputParameters); - - insertDataIntoCache(dataToCache); - // employeeCache.put(dataToCache); - } - - } - - } catch (Exception e) { - // TODO: handle exception - e.printStackTrace(); - throw new Exception("Failed to load data. " + e); + Object value = null; + if (dataFromCache != null) { + value = dataFromCache.getObjectValue(); } + if (value != null) { + outputParameters = (LinkedHashMap) value; + // System.out.println("***GETTING DATA FROM CACHE"); + } else { + + // start the computation + // System.out.println("***STARTING THE COMPUTATION"); + // create data structure + ComputationOutput outputData = new ComputationOutput(); + // computation id + String computationId = startComputation(algorithmId, + inputParameters, outputData); + + // print check + // retrieve data + // logger.info("output data retrieved"); + + // data output values + LinkedHashMap mapValues = new LinkedHashMap(); + // data output keys + LinkedHashMap mapKeys = new LinkedHashMap(); + + mapValues = outputData.getMapValues(); + mapKeys = outputData.getmapKeys(); + + for (int i = 0; i < mapValues.size(); i++) { + FileModel obj = new FileModel(mapValues.get(String + .valueOf(i))); + // obj.setIsLoaded(true); + + // print check + // logger.info("value: " + + // mapValues.get(String.valueOf(i))); + // logger.info("key: " + + // mapKeys.get(String.valueOf(i))); + outputParameters.put(mapKeys.get(String.valueOf(i)), obj); + } + + // write data in cache + if (outputParameters != null && outputParameters.size() != 0) { + // put data in cache + net.sf.ehcache.Element dataToCache = new net.sf.ehcache.Element( + inputParameters.get(0).getValue(), outputParameters); + + insertDataIntoCache(dataToCache); + // employeeCache.put(dataToCache); + } + + } + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + // throw new Exception("Failed to load data " + ); + throw e; + } return outputParameters; } @@ -374,93 +373,91 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements // print check String rs = dataInput.get("ResourceName"); String db = dataInput.get("DatabaseName"); - - logger.info("dbmanager-> ResourceName: " - + rs); - logger.info("dbmanager-> DatabaseName: " - + db); - //set input parameters - Parameter resource = new Parameter("ResourceName", "", "String", ""); - Parameter database = new Parameter("DatabaseName", "", "String", ""); - inputParameters.add(resource); - inputParameters.add(database); + logger.info("dbmanager-> ResourceName: " + rs); + logger.info("dbmanager-> DatabaseName: " + db); - inputParameters.get(0).setValue(rs); - inputParameters.get(1).setValue(db); + // set input parameters + Parameter resource = new Parameter("ResourceName", "", "String", ""); + Parameter database = new Parameter("DatabaseName", "", "String", ""); + inputParameters.add(resource); + inputParameters.add(database); - // print check algorithm input parameters - // for (int i = 0; i < inputParameters.size(); i++) { - // logger.info(inputParameters.get(i).getName()); - // } + inputParameters.get(0).setValue(rs); + inputParameters.get(1).setValue(db); - try { - // get data from cache - // check if data exist considering as key the input parameters - String key = inputParameters.get(0).getValue() - + inputParameters.get(1).getValue(); - -// System.out.println("key in GETSCHEMA: " + key); + // print check algorithm input parameters + // for (int i = 0; i < inputParameters.size(); i++) { + // logger.info(inputParameters.get(i).getName()); + // } - net.sf.ehcache.Element dataFromCache = getDataFromCache(key); + try { + // get data from cache + // check if data exist considering as key the input parameters + String key = inputParameters.get(0).getValue() + + inputParameters.get(1).getValue(); - Object value = null; - if (dataFromCache != null) { - value = dataFromCache.getObjectValue(); - } - if (value != null) { - outputParameters = (List) value; - } else { + // System.out.println("key in GETSCHEMA: " + key); - // start the computation - // create data structure - ComputationOutput outputData = new ComputationOutput(); - // computation id - String computationId = startComputation(algorithmId, - inputParameters, outputData); + net.sf.ehcache.Element dataFromCache = getDataFromCache(key); - // print check - // retrieve data - // logger.info("dbmanager-> output data retrieved"); + Object value = null; + if (dataFromCache != null) { + value = dataFromCache.getObjectValue(); + } + if (value != null) { + outputParameters = (List) value; + } else { - // data output values - LinkedHashMap mapValues = new LinkedHashMap(); - // data output keys - LinkedHashMap mapKeys = new LinkedHashMap(); + // start the computation + // create data structure + ComputationOutput outputData = new ComputationOutput(); + // computation id + String computationId = startComputation(algorithmId, + inputParameters, outputData); - mapValues = outputData.getMapValues(); - mapKeys = outputData.getmapKeys(); + // print check + // retrieve data + // logger.info("dbmanager-> output data retrieved"); - for (int i = 0; i < mapValues.size(); i++) { - FileModel obj = new FileModel(mapValues.get(String - .valueOf(i))); - // obj.setIsSchema(true); - // obj.setIsLoaded(true); - outputParameters.add(obj); - } + // data output values + LinkedHashMap mapValues = new LinkedHashMap(); + // data output keys + LinkedHashMap mapKeys = new LinkedHashMap(); - // write data in cache - if (outputParameters != null - && outputParameters.size() != 0) { - // put data in cache - net.sf.ehcache.Element dataToCache = new net.sf.ehcache.Element( - inputParameters.get(0).getValue() - + inputParameters.get(1).getValue(), - outputParameters); - - insertDataIntoCache(dataToCache); - // employeeCache.put(dataToCache); - } - - } - - } catch (Exception e) { - // TODO: handle exception - e.printStackTrace(); - throw new Exception("Failed to load data. " + e); + mapValues = outputData.getMapValues(); + mapKeys = outputData.getmapKeys(); + for (int i = 0; i < mapValues.size(); i++) { + FileModel obj = new FileModel(mapValues.get(String + .valueOf(i))); + // obj.setIsSchema(true); + // obj.setIsLoaded(true); + outputParameters.add(obj); } + // write data in cache + if (outputParameters != null && outputParameters.size() != 0) { + // put data in cache + net.sf.ehcache.Element dataToCache = new net.sf.ehcache.Element( + inputParameters.get(0).getValue() + + inputParameters.get(1).getValue(), + outputParameters); + + insertDataIntoCache(dataToCache); + // employeeCache.put(dataToCache); + } + + } + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + // throw new Exception("Failed to load data. " + e); + throw e; + + } + return outputParameters; } @@ -472,121 +469,118 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements // data output List outputParameters = new ArrayList(); - String algorithmId = "LISTTABLES"; - - String rs= dataInput.get("ResourceName"); - String db= dataInput.get("DatabaseName"); - String scm= dataInput.get("SchemaName"); - - //print check - logger.info("dbmanager-> ResourceName: " - + rs); - logger.info("dbmanager-> DatabaseName: " - + db); - logger.info("dbmanager-> SchemaName: " - + scm); - - //set input parameters - Parameter resource = new Parameter("ResourceName", "", "String", ""); - Parameter database = new Parameter("DatabaseName", "", "String", ""); - Parameter schema = new Parameter("SchemaName","", "String", ""); - inputParameters.add(resource); - inputParameters.add(database); - inputParameters.add(schema); - inputParameters.get(0).setValue(rs); - inputParameters.get(1).setValue(db); - inputParameters.get(2).setValue(scm); - - try{ - // get data from cache - // check if data exist considering as key the input parameters - String key = inputParameters.get(0).getValue()+inputParameters.get(1).getValue()+ - inputParameters.get(2).getValue(); - - // System.out.println("***KEY: " + key); - net.sf.ehcache.Element dataFromCache = getDataFromCache(key); - - Object value = null; - if (dataFromCache != null) { - value = dataFromCache.getObjectValue(); -// System.out.println("***GETTING DATA FROM CACHE"); - } - if (value != null) { - outputParameters = (List) value; - - } else { - - //start computation - // create data structure - ComputationOutput outputData = new ComputationOutput(); - // computation id - String computationId = startComputation(algorithmId, inputParameters, - outputData); + String rs = dataInput.get("ResourceName"); + String db = dataInput.get("DatabaseName"); + String scm = dataInput.get("SchemaName"); - // print check on retrieving data - // logger.info("output data retrieved"); + // print check + logger.info("dbmanager-> ResourceName: " + rs); + logger.info("dbmanager-> DatabaseName: " + db); + logger.info("dbmanager-> SchemaName: " + scm); - // data output values - LinkedHashMap mapValues = new LinkedHashMap(); - // data output keys - LinkedHashMap mapKeys = new LinkedHashMap(); + // set input parameters + Parameter resource = new Parameter("ResourceName", "", "String", ""); + Parameter database = new Parameter("DatabaseName", "", "String", ""); + Parameter schema = new Parameter("SchemaName", "", "String", ""); + inputParameters.add(resource); + inputParameters.add(database); + inputParameters.add(schema); - mapValues = outputData.getMapValues(); - mapKeys = outputData.getmapKeys(); + inputParameters.get(0).setValue(rs); + inputParameters.get(1).setValue(db); + inputParameters.get(2).setValue(scm); - for (int i = 0; i < mapValues.size(); i++) { - Result row = new Result(String.valueOf(i), mapValues.get(String - .valueOf(i))); - outputParameters.add(row); - } - - // write data in cache - if (outputParameters != null - && outputParameters.size() != 0) { - // put data in cache - net.sf.ehcache.Element dataToCache = new net.sf.ehcache.Element( - inputParameters.get(0).getValue() - + inputParameters.get(1).getValue()+inputParameters.get(2).getValue(), - outputParameters); + try { + // get data from cache + // check if data exist considering as key the input parameters + String key = inputParameters.get(0).getValue() + + inputParameters.get(1).getValue() + + inputParameters.get(2).getValue(); - insertDataIntoCache(dataToCache); - // employeeCache.put(dataToCache); - } - - } + // System.out.println("***KEY: " + key); + net.sf.ehcache.Element dataFromCache = getDataFromCache(key); - - - }catch (Exception e) { -// e.printStackTrace(); - throw new Exception("Failed to load data. " + e); + Object value = null; + if (dataFromCache != null) { + value = dataFromCache.getObjectValue(); + // System.out.println("***GETTING DATA FROM CACHE"); } - - -// // create data structure -// ComputationOutput outputData = new ComputationOutput(); -// // computation id -// String computationId = startComputation(algorithmId, inputParameters, -// outputData); -// -// // print check on retrieving data -// // logger.info("output data retrieved"); -// -// // data output values -// LinkedHashMap mapValues = new LinkedHashMap(); -// // data output keys -// LinkedHashMap mapKeys = new LinkedHashMap(); -// -// mapValues = outputData.getMapValues(); -// mapKeys = outputData.getmapKeys(); -// -// for (int i = 0; i < mapValues.size(); i++) { -// Result row = new Result(String.valueOf(i), mapValues.get(String -// .valueOf(i))); -// outputParameters.add(row); -// } + if (value != null) { + outputParameters = (List) value; + + } else { + + // start computation + // create data structure + ComputationOutput outputData = new ComputationOutput(); + // computation id + String computationId = startComputation(algorithmId, + inputParameters, outputData); + + // print check on retrieving data + // logger.info("output data retrieved"); + + // data output values + LinkedHashMap mapValues = new LinkedHashMap(); + // data output keys + LinkedHashMap mapKeys = new LinkedHashMap(); + + mapValues = outputData.getMapValues(); + mapKeys = outputData.getmapKeys(); + + for (int i = 0; i < mapValues.size(); i++) { + Result row = new Result(String.valueOf(i), + mapValues.get(String.valueOf(i))); + outputParameters.add(row); + } + + // write data in cache + if (outputParameters != null && outputParameters.size() != 0) { + // put data in cache + net.sf.ehcache.Element dataToCache = new net.sf.ehcache.Element( + inputParameters.get(0).getValue() + + inputParameters.get(1).getValue() + + inputParameters.get(2).getValue(), + outputParameters); + + insertDataIntoCache(dataToCache); + // employeeCache.put(dataToCache); + } + + } + + } catch (Exception e) { + // e.printStackTrace(); + // throw new Exception("Failed to load data. " + e); + throw e; + } + + // // create data structure + // ComputationOutput outputData = new ComputationOutput(); + // // computation id + // String computationId = startComputation(algorithmId, inputParameters, + // outputData); + // + // // print check on retrieving data + // // logger.info("output data retrieved"); + // + // // data output values + // LinkedHashMap mapValues = new LinkedHashMap(); + // // data output keys + // LinkedHashMap mapKeys = new LinkedHashMap(); + // + // mapValues = outputData.getMapValues(); + // mapKeys = outputData.getmapKeys(); + // + // for (int i = 0; i < mapValues.size(); i++) { + // Result row = new Result(String.valueOf(i), mapValues.get(String + // .valueOf(i))); + // outputParameters.add(row); + // } return outputParameters; } @@ -597,38 +591,40 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements LinkedHashMap dataInput, boolean SearchTable, String keyword) throws Exception { - //tables' list stored for a user session -// ASLSession session = WsUtil.getAslSession(this.getThreadLocalRequest() -// .getSession()); -// List result = (List) session -// .getAttribute("TablesResult"); -// // check on a database -// String currentDB = ""; -// currentDB = dataInput.get("DatabaseName"); -// String previousDB = (String) session.getAttribute("previousDB"); -// -// if (!currentDB.equals(previousDB)) { -// // result = null; -// result = new ArrayList(); -// System.gc(); -// } -// -// previousDB = currentDB; -// session.setAttribute("previousDB", previousDB); -// -// // check on a schema -// String currentSchema = ""; -// currentSchema = dataInput.get("SchemaName"); -// String previousSchema = (String) session.getAttribute("previousSchema"); -// if (!currentSchema.equals(previousSchema)) { -// // result = null; -// result = new ArrayList(); -// System.gc(); -// } -// -// previousSchema = currentSchema; -// session.setAttribute("previousSchema", previousSchema); - + // tables' list stored for a user session + // ASLSession session = + // WsUtil.getAslSession(this.getThreadLocalRequest() + // .getSession()); + // List result = (List) session + // .getAttribute("TablesResult"); + // // check on a database + // String currentDB = ""; + // currentDB = dataInput.get("DatabaseName"); + // String previousDB = (String) session.getAttribute("previousDB"); + // + // if (!currentDB.equals(previousDB)) { + // // result = null; + // result = new ArrayList(); + // System.gc(); + // } + // + // previousDB = currentDB; + // session.setAttribute("previousDB", previousDB); + // + // // check on a schema + // String currentSchema = ""; + // currentSchema = dataInput.get("SchemaName"); + // String previousSchema = (String) + // session.getAttribute("previousSchema"); + // if (!currentSchema.equals(previousSchema)) { + // // result = null; + // result = new ArrayList(); + // System.gc(); + // } + // + // previousSchema = currentSchema; + // session.setAttribute("previousSchema", previousSchema); + List result = new ArrayList<>(); // get tables @@ -688,7 +684,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements loadResult = new BasePagingLoadResult(sublist, config.getOffset(), totalNumber); -// session.setAttribute("TablesResult", result); + // session.setAttribute("TablesResult", result); return loadResult; } @@ -711,108 +707,105 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements // list that contains table attributes List listAttributes = null; - String algorithmId = "SUBMITQUERY"; - + // print check - String rs= dataDB.get("ResourceName"); - String db= dataDB.get("DatabaseName"); - - - //print check - logger.info("dbmanager-> ResourceName: " - + rs); - logger.info("dbmanager-> DatabaseName: " - + db); - + String rs = dataDB.get("ResourceName"); + String db = dataDB.get("DatabaseName"); + + // print check + logger.info("dbmanager-> ResourceName: " + rs); + logger.info("dbmanager-> DatabaseName: " + db); + logger.info("dbmanager-> Query: " + query); logger.info("dbmanager-> SmartCorrections check: " + smartCorrectionQuery); - //set input parameters - Parameter resource = new Parameter("ResourceName", "", "String", ""); - Parameter database = new Parameter("DatabaseName", "", "String", ""); - Parameter readOnlyQuery = new Parameter("Read-Only Query", "", "Boolean", "true"); - Parameter applySmartCorrection = new Parameter("Apply Smart Correction", "", "Boolean", "true"); - Parameter lng = new Parameter("Language", "", "NONE", "NONE"); - Parameter q = new Parameter("Query", "", "String", ""); - - inputParameters.add(resource); - inputParameters.add(database); - inputParameters.add(readOnlyQuery); - inputParameters.add(applySmartCorrection); - inputParameters.add(lng); - inputParameters.add(q); - + // set input parameters + Parameter resource = new Parameter("ResourceName", "", "String", ""); + Parameter database = new Parameter("DatabaseName", "", "String", ""); + Parameter readOnlyQuery = new Parameter("Read-Only Query", "", + "Boolean", "true"); + Parameter applySmartCorrection = new Parameter( + "Apply Smart Correction", "", "Boolean", "true"); + Parameter lng = new Parameter("Language", "", "NONE", "NONE"); + Parameter q = new Parameter("Query", "", "String", ""); - inputParameters.get(0).setValue(rs); - inputParameters.get(1).setValue(db); - inputParameters.get(2).setValue(String.valueOf(valueReadOnlyQuery)); - inputParameters.get(3).setValue(String.valueOf(smartCorrectionQuery)); - inputParameters.get(4).setValue(language); - inputParameters.get(5).setValue(query); - - // create data structure - ComputationOutput outputData = new ComputationOutput(); - try { - // computation id - String computationId = startComputation(algorithmId, - inputParameters, outputData, UID); + inputParameters.add(resource); + inputParameters.add(database); + inputParameters.add(readOnlyQuery); + inputParameters.add(applySmartCorrection); + inputParameters.add(lng); + inputParameters.add(q); - // get JobID - if (checkJob(UID)) { - // computationIDMap.put(id, computationId); + inputParameters.get(0).setValue(rs); + inputParameters.get(1).setValue(db); + inputParameters.get(2).setValue(String.valueOf(valueReadOnlyQuery)); + inputParameters.get(3).setValue(String.valueOf(smartCorrectionQuery)); + inputParameters.get(4).setValue(language); + inputParameters.get(5).setValue(query); - // print check on retrieving data - // logger.info("output data retrieved"); + // create data structure + ComputationOutput outputData = new ComputationOutput(); + try { + // computation id + String computationId = startComputation(algorithmId, + inputParameters, outputData, UID); - // data output values - LinkedHashMap mapValues = new LinkedHashMap(); - // data output keys - LinkedHashMap mapKeys = new LinkedHashMap(); + // get JobID + if (checkJob(UID)) { + // computationIDMap.put(id, computationId); - mapValues = outputData.getMapValues(); - mapKeys = outputData.getmapKeys(); + // print check on retrieving data + // logger.info("output data retrieved"); - if (mapValues.size() != 0) { - output = new ArrayList(); + // data output values + LinkedHashMap mapValues = new LinkedHashMap(); + // data output keys + LinkedHashMap mapKeys = new LinkedHashMap(); - // logger.info("build the result - started"); - for (int i = 0; i < mapValues.size(); i++) { - Result row = new Result(mapKeys.get(String.valueOf(i)), - mapValues.get(String.valueOf(i))); - output.add(row); - } + mapValues = outputData.getMapValues(); + mapKeys = outputData.getmapKeys(); - // System.out.println("output size submit: " + - // output.size()); - // logger.info("build the result - finished"); + if (mapValues.size() != 0) { + output = new ArrayList(); - // get the attributes list for the result table - listAttributes = new ArrayList(); - listAttributes = getListAttributes(output.get(0).getValue()); - // remove the header in order to parse only the result - output.remove(0); - // store the result of the submit query operation - updateSubmitQueryResultMap(UID, output); - // remove job with the specified uid - removeJob(UID); + // logger.info("build the result - started"); + for (int i = 0; i < mapValues.size(); i++) { + Result row = new Result(mapKeys.get(String.valueOf(i)), + mapValues.get(String.valueOf(i))); + output.add(row); } - } else { - listAttributes = null; + + // System.out.println("output size submit: " + + // output.size()); + // logger.info("build the result - finished"); + + // get the attributes list for the result table + listAttributes = new ArrayList(); + listAttributes = getListAttributes(output.get(0).getValue()); + // remove the header in order to parse only the result + output.remove(0); + // store the result of the submit query operation + updateSubmitQueryResultMap(UID, output); + // remove job with the specified uid + removeJob(UID); } - } catch (Exception e) { - // e.printStackTrace(); - // TODO TO REMOVE. Exception Statistical management to remove a - // computation - if (e.getMessage() - .contains( - "javax.xml.ws.soap.SOAPFaultException: java.lang.IndexOutOfBoundsException")) { - e = new Exception("ServerException"); - } - throw e; + } else { + listAttributes = null; } - + } catch (Exception e) { + // e.printStackTrace(); + // TODO TO REMOVE. Exception Statistical management to remove a + // computation + if (e.getMessage() + .contains( + "javax.xml.ws.soap.SOAPFaultException: java.lang.IndexOutOfBoundsException")) { + e = new Exception("ServerException"); + } + throw e; + } + return listAttributes; } @@ -824,64 +817,58 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements // output sample result List output = new ArrayList(); - String algorithmId = "SAMPLEONTABLE"; - - //print check - String rs= dataInput.get("ResourceName"); - String db= dataInput.get("DatabaseName"); - String scm= dataInput.get("SchemaName"); - String tab= dataInput.get("TableName"); - - //print check - logger.info("dbmanager-> ResourceName: " - + rs); - logger.info("dbmanager-> DatabaseName: " - + db); - logger.info("dbmanager-> SchemaName: " - + scm); - logger.info("dbmanager-> TableName: " - + tab); - - //set input parameters - Parameter resource = new Parameter("ResourceName", "", "String", ""); - Parameter database = new Parameter("DatabaseName", "", "String", ""); - Parameter schema = new Parameter("SchemaName","", "String", ""); - Parameter table = new Parameter("TableName","", "String", ""); - inputParameters.add(resource); - inputParameters.add(database); - inputParameters.add(schema); - inputParameters.add(table); - - inputParameters.get(0).setValue(rs); - inputParameters.get(1).setValue(db); - inputParameters.get(2).setValue(scm); - inputParameters.get(3).setValue(tab); - - - // create data structure - ComputationOutput outputData = new ComputationOutput(); - // computation id - String computationId = startComputation(algorithmId, inputParameters, - outputData); - // print check on retrieving data - // logger.info("output data retrieved"); + // print check + String rs = dataInput.get("ResourceName"); + String db = dataInput.get("DatabaseName"); + String scm = dataInput.get("SchemaName"); + String tab = dataInput.get("TableName"); - // data output values - LinkedHashMap mapValues = new LinkedHashMap(); - // data output keys - LinkedHashMap mapKeys = new LinkedHashMap(); + // print check + logger.info("dbmanager-> ResourceName: " + rs); + logger.info("dbmanager-> DatabaseName: " + db); + logger.info("dbmanager-> SchemaName: " + scm); + logger.info("dbmanager-> TableName: " + tab); - mapValues = outputData.getMapValues(); - mapKeys = outputData.getmapKeys(); + // set input parameters + Parameter resource = new Parameter("ResourceName", "", "String", ""); + Parameter database = new Parameter("DatabaseName", "", "String", ""); + Parameter schema = new Parameter("SchemaName", "", "String", ""); + Parameter table = new Parameter("TableName", "", "String", ""); + inputParameters.add(resource); + inputParameters.add(database); + inputParameters.add(schema); + inputParameters.add(table); + + inputParameters.get(0).setValue(rs); + inputParameters.get(1).setValue(db); + inputParameters.get(2).setValue(scm); + inputParameters.get(3).setValue(tab); + + // create data structure + ComputationOutput outputData = new ComputationOutput(); + // computation id + String computationId = startComputation(algorithmId, inputParameters, + outputData); + + // print check on retrieving data + // logger.info("output data retrieved"); + + // data output values + LinkedHashMap mapValues = new LinkedHashMap(); + // data output keys + LinkedHashMap mapKeys = new LinkedHashMap(); + + mapValues = outputData.getMapValues(); + mapKeys = outputData.getmapKeys(); + + for (int i = 0; i < mapValues.size(); i++) { + Result row = new Result(mapKeys.get(String.valueOf(i)), + mapValues.get(String.valueOf(i))); + output.add(row); + } - for (int i = 0; i < mapValues.size(); i++) { - Result row = new Result(mapKeys.get(String.valueOf(i)), - mapValues.get(String.valueOf(i))); - output.add(row); - } - return output; } @@ -892,62 +879,58 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements List inputParameters = new ArrayList(); // output sample result List output = new ArrayList(); - + String algorithmId = "SMARTSAMPLEONTABLE"; - - //print check - String rs= dataInput.get("ResourceName"); - String db= dataInput.get("DatabaseName"); - String scm= dataInput.get("SchemaName"); - String tab= dataInput.get("TableName"); - - //print check - logger.info("dbmanager-> ResourceName: " - + rs); - logger.info("dbmanager-> DatabaseName: " - + db); - logger.info("dbmanager-> SchemaName: " - + scm); - logger.info("dbmanager-> TableName: " - + tab); - - //set input parameters - Parameter resource = new Parameter("ResourceName", "", "String", ""); - Parameter database = new Parameter("DatabaseName", "", "String", ""); - Parameter schema = new Parameter("SchemaName","", "String", ""); - Parameter table = new Parameter("TableName","", "String", ""); - inputParameters.add(resource); - inputParameters.add(database); - inputParameters.add(schema); - inputParameters.add(table); - - inputParameters.get(0).setValue(rs); - inputParameters.get(1).setValue(db); - inputParameters.get(2).setValue(scm); - inputParameters.get(3).setValue(tab); - - // create data structure - ComputationOutput outputData = new ComputationOutput(); - // computation id - String computationId = startComputation(algorithmId, inputParameters, - outputData); - // print check on retrieving data - // logger.info("dbmanager-> output data retrieved"); + // print check + String rs = dataInput.get("ResourceName"); + String db = dataInput.get("DatabaseName"); + String scm = dataInput.get("SchemaName"); + String tab = dataInput.get("TableName"); - // data output values - LinkedHashMap mapValues = new LinkedHashMap(); - // data output keys - LinkedHashMap mapKeys = new LinkedHashMap(); + // print check + logger.info("dbmanager-> ResourceName: " + rs); + logger.info("dbmanager-> DatabaseName: " + db); + logger.info("dbmanager-> SchemaName: " + scm); + logger.info("dbmanager-> TableName: " + tab); - mapValues = outputData.getMapValues(); - mapKeys = outputData.getmapKeys(); + // set input parameters + Parameter resource = new Parameter("ResourceName", "", "String", ""); + Parameter database = new Parameter("DatabaseName", "", "String", ""); + Parameter schema = new Parameter("SchemaName", "", "String", ""); + Parameter table = new Parameter("TableName", "", "String", ""); + inputParameters.add(resource); + inputParameters.add(database); + inputParameters.add(schema); + inputParameters.add(table); - for (int i = 0; i < mapValues.size(); i++) { - Result row = new Result(mapKeys.get(String.valueOf(i)), - mapValues.get(String.valueOf(i))); - output.add(row); - } + inputParameters.get(0).setValue(rs); + inputParameters.get(1).setValue(db); + inputParameters.get(2).setValue(scm); + inputParameters.get(3).setValue(tab); + + // create data structure + ComputationOutput outputData = new ComputationOutput(); + // computation id + String computationId = startComputation(algorithmId, inputParameters, + outputData); + + // print check on retrieving data + // logger.info("dbmanager-> output data retrieved"); + + // data output values + LinkedHashMap mapValues = new LinkedHashMap(); + // data output keys + LinkedHashMap mapKeys = new LinkedHashMap(); + + mapValues = outputData.getMapValues(); + mapKeys = outputData.getmapKeys(); + + for (int i = 0; i < mapValues.size(); i++) { + Result row = new Result(mapKeys.get(String.valueOf(i)), + mapValues.get(String.valueOf(i))); + output.add(row); + } return output; } @@ -960,62 +943,58 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements List inputParameters = new ArrayList(); // output sample result List output = new ArrayList(); - + String algorithmId = "RANDOMSAMPLEONTABLE"; - - //print check - String rs= dataInput.get("ResourceName"); - String db= dataInput.get("DatabaseName"); - String scm= dataInput.get("SchemaName"); - String tab= dataInput.get("TableName"); - - //print check - logger.info("dbmanager-> ResourceName: " - + rs); - logger.info("dbmanager-> DatabaseName: " - + db); - logger.info("dbmanager-> SchemaName: " - + scm); - logger.info("dbmanager-> TableName: " - + tab); - - //set input parameters - Parameter resource = new Parameter("ResourceName", "", "String", ""); - Parameter database = new Parameter("DatabaseName", "", "String", ""); - Parameter schema = new Parameter("SchemaName","", "String", ""); - Parameter table = new Parameter("TableName","", "String", ""); - inputParameters.add(resource); - inputParameters.add(database); - inputParameters.add(schema); - inputParameters.add(table); - - inputParameters.get(0).setValue(rs); - inputParameters.get(1).setValue(db); - inputParameters.get(2).setValue(scm); - inputParameters.get(3).setValue(tab); - - // create data structure - ComputationOutput outputData = new ComputationOutput(); - // computation id - String computationId = startComputation(algorithmId, inputParameters, - outputData); - // print check on retrieving data - // logger.info("dbmanager-> output data retrieved"); + // print check + String rs = dataInput.get("ResourceName"); + String db = dataInput.get("DatabaseName"); + String scm = dataInput.get("SchemaName"); + String tab = dataInput.get("TableName"); - // data output values - LinkedHashMap mapValues = new LinkedHashMap(); - // data output keys - LinkedHashMap mapKeys = new LinkedHashMap(); + // print check + logger.info("dbmanager-> ResourceName: " + rs); + logger.info("dbmanager-> DatabaseName: " + db); + logger.info("dbmanager-> SchemaName: " + scm); + logger.info("dbmanager-> TableName: " + tab); - mapValues = outputData.getMapValues(); - mapKeys = outputData.getmapKeys(); + // set input parameters + Parameter resource = new Parameter("ResourceName", "", "String", ""); + Parameter database = new Parameter("DatabaseName", "", "String", ""); + Parameter schema = new Parameter("SchemaName", "", "String", ""); + Parameter table = new Parameter("TableName", "", "String", ""); + inputParameters.add(resource); + inputParameters.add(database); + inputParameters.add(schema); + inputParameters.add(table); - for (int i = 0; i < mapValues.size(); i++) { - Result row = new Result(mapKeys.get(String.valueOf(i)), - mapValues.get(String.valueOf(i))); - output.add(row); - } + inputParameters.get(0).setValue(rs); + inputParameters.get(1).setValue(db); + inputParameters.get(2).setValue(scm); + inputParameters.get(3).setValue(tab); + + // create data structure + ComputationOutput outputData = new ComputationOutput(); + // computation id + String computationId = startComputation(algorithmId, inputParameters, + outputData); + + // print check on retrieving data + // logger.info("dbmanager-> output data retrieved"); + + // data output values + LinkedHashMap mapValues = new LinkedHashMap(); + // data output keys + LinkedHashMap mapKeys = new LinkedHashMap(); + + mapValues = outputData.getMapValues(); + mapKeys = outputData.getmapKeys(); + + for (int i = 0; i < mapValues.size(); i++) { + Result row = new Result(mapKeys.get(String.valueOf(i)), + mapValues.get(String.valueOf(i))); + output.add(row); + } return output; } @@ -1029,65 +1008,59 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements LinkedHashMap outputParameters = new LinkedHashMap(); String algorithmId = "GETTABLEDETAILS"; - - //print check - String rs= dataInput.get("ResourceName"); - String db= dataInput.get("DatabaseName"); - String scm= dataInput.get("SchemaName"); - String tab= dataInput.get("TableName"); - - //print check - logger.info("dbmanager-> ResourceName: " - + rs); - logger.info("dbmanager-> DatabaseName: " - + db); - logger.info("dbmanager-> SchemaName: " - + scm); - logger.info("dbmanager-> TableName: " - + tab); - - - //set input parameters - Parameter resource = new Parameter("ResourceName", "", "String", ""); - Parameter database = new Parameter("DatabaseName", "", "String", ""); - Parameter schema = new Parameter("SchemaName","", "String", ""); - Parameter table = new Parameter("TableName","", "String", ""); - inputParameters.add(resource); - inputParameters.add(database); - inputParameters.add(schema); - inputParameters.add(table); - - inputParameters.get(0).setValue(rs); - inputParameters.get(1).setValue(db); - inputParameters.get(2).setValue(scm); - inputParameters.get(3).setValue(tab); - - - // create data structure - ComputationOutput outputData = new ComputationOutput(); - // computation id - String computationId = startComputation(algorithmId, inputParameters, - outputData); - // print check on retrieving data - // logger.info("output data retrieved"); + // print check + String rs = dataInput.get("ResourceName"); + String db = dataInput.get("DatabaseName"); + String scm = dataInput.get("SchemaName"); + String tab = dataInput.get("TableName"); - // output data values - LinkedHashMap mapValues = new LinkedHashMap(); - // output data keys - LinkedHashMap mapKeys = new LinkedHashMap(); + // print check + logger.info("dbmanager-> ResourceName: " + rs); + logger.info("dbmanager-> DatabaseName: " + db); + logger.info("dbmanager-> SchemaName: " + scm); + logger.info("dbmanager-> TableName: " + tab); - mapValues = outputData.getMapValues(); - mapKeys = outputData.getmapKeys(); + // set input parameters + Parameter resource = new Parameter("ResourceName", "", "String", ""); + Parameter database = new Parameter("DatabaseName", "", "String", ""); + Parameter schema = new Parameter("SchemaName", "", "String", ""); + Parameter table = new Parameter("TableName", "", "String", ""); + inputParameters.add(resource); + inputParameters.add(database); + inputParameters.add(schema); + inputParameters.add(table); - for (int i = 0; i < mapValues.size(); i++) { - FileModel obj = new FileModel(mapValues.get(String.valueOf(i))); - // obj.setIsLoaded(true); - outputParameters.put(mapKeys.get(String.valueOf(i)), obj); - // print check - // logger.info("value: " + outputMap.get(String.valueOf(i))); - // logger.info("key: " + outputKey.get(String.valueOf(i))); - } + inputParameters.get(0).setValue(rs); + inputParameters.get(1).setValue(db); + inputParameters.get(2).setValue(scm); + inputParameters.get(3).setValue(tab); + + // create data structure + ComputationOutput outputData = new ComputationOutput(); + // computation id + String computationId = startComputation(algorithmId, inputParameters, + outputData); + + // print check on retrieving data + // logger.info("output data retrieved"); + + // output data values + LinkedHashMap mapValues = new LinkedHashMap(); + // output data keys + LinkedHashMap mapKeys = new LinkedHashMap(); + + mapValues = outputData.getMapValues(); + mapKeys = outputData.getmapKeys(); + + for (int i = 0; i < mapValues.size(); i++) { + FileModel obj = new FileModel(mapValues.get(String.valueOf(i))); + // obj.setIsLoaded(true); + outputParameters.put(mapKeys.get(String.valueOf(i)), obj); + // print check + // logger.info("value: " + outputMap.get(String.valueOf(i))); + // logger.info("key: " + outputKey.get(String.valueOf(i))); + } return outputParameters; } @@ -1235,55 +1208,55 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements return elements; } - //not called -// private List getDatabaseManagerAlgorithms() { -// ArrayList dbAlg = new ArrayList(); -// StatisticalManagerFactory factory = getFactory(); -// // get and print algorithms -// SMListGroupedAlgorithms groups = factory.getAlgorithms(); -// -// if (groups == null) -// logger.info("dbmanager-> GROUPS OF ALGORITHMS IS NULL!"); -// else -// logger.info("dbmanager-> GROUPS OF ALGORITHMS IS NOT NULL!"); -// -// // get list categories -// for (SMGroupedAlgorithms group : groups.thelist()) { -// for (SMAlgorithm algorithm : group.thelist()) { -// dbAlg.add(algorithm.name()); -// } -// } -// return dbAlg; -// } + // not called + // private List getDatabaseManagerAlgorithms() { + // ArrayList dbAlg = new ArrayList(); + // StatisticalManagerFactory factory = getFactory(); + // // get and print algorithms + // SMListGroupedAlgorithms groups = factory.getAlgorithms(); + // + // if (groups == null) + // logger.info("dbmanager-> GROUPS OF ALGORITHMS IS NULL!"); + // else + // logger.info("dbmanager-> GROUPS OF ALGORITHMS IS NOT NULL!"); + // + // // get list categories + // for (SMGroupedAlgorithms group : groups.thelist()) { + // for (SMAlgorithm algorithm : group.thelist()) { + // dbAlg.add(algorithm.name()); + // } + // } + // return dbAlg; + // } - //not used -// private List getParameters(String algorithmId) { -// StatisticalManagerFactory factory = getFactory(); -// SMParameters smParams = factory.getAlgorithmParameters(algorithmId); -// List params = new ArrayList(); -// -// for (SMParameter smParam : smParams.list()) { -// SMTypeParameter smType = smParam.type(); -// StatisticalServiceType smTypeName = smType.name(); -// -// String paramName = smParam.name(); -// String paramDescription = smParam.description(); -// String defaultValue = smParam.defaultValue(); -// String objectType = smType.values().get(0); -// -// // print CHECK -//// logger.info("parameters: "); -//// logger.info(paramName); -//// logger.info(paramDescription); -//// logger.info(objectType); -//// logger.info(defaultValue); -// -// Parameter objectParam = new Parameter(paramName, paramDescription, -// objectType, defaultValue); -// params.add(objectParam); -// } -// return params; -// } + // not used + // private List getParameters(String algorithmId) { + // StatisticalManagerFactory factory = getFactory(); + // SMParameters smParams = factory.getAlgorithmParameters(algorithmId); + // List params = new ArrayList(); + // + // for (SMParameter smParam : smParams.list()) { + // SMTypeParameter smType = smParam.type(); + // StatisticalServiceType smTypeName = smType.name(); + // + // String paramName = smParam.name(); + // String paramDescription = smParam.description(); + // String defaultValue = smParam.defaultValue(); + // String objectType = smType.values().get(0); + // + // // print CHECK + // // logger.info("parameters: "); + // // logger.info(paramName); + // // logger.info(paramDescription); + // // logger.info(objectType); + // // logger.info(defaultValue); + // + // Parameter objectParam = new Parameter(paramName, paramDescription, + // objectType, defaultValue); + // params.add(objectParam); + // } + // return params; + // } private synchronized List getSubmitQueryResult(String submitQueryUID) { ASLSession session = WsUtil.getAslSession(this.getThreadLocalRequest() @@ -1719,7 +1692,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements private synchronized void insertDataIntoCache(net.sf.ehcache.Element data) { employeeCache.put(data); -// System.out.println("data inserted"); + // System.out.println("data inserted"); } private synchronized net.sf.ehcache.Element getDataFromCache(String key) { @@ -1729,7 +1702,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements // clear the cache on the user request public GeneralOutputFromServlet refreshDataTree(String ElementType, - LinkedHashMap inputData, FileModel element) throws Exception { + LinkedHashMap inputData, FileModel element) + throws Exception { // // call the method related to the element selected // @@ -1739,11 +1713,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements GeneralOutputFromServlet result = null; if (inputData != null && inputData.size() != 0) { -// System.out.println("server-> input size not null"); + // System.out.println("server-> input size not null"); String key = ""; if (!ElementType.equals("")) { -// System.out.println("server-> element type not null"); + // System.out.println("server-> element type not null"); switch (ElementType) { case "listResources": key = inputData.get("listResources"); @@ -1752,41 +1726,45 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements key = inputData.get("ResourceName"); break; case "database": - if (element.getDatabaseType().equals(ConstantsPortlet.POSTGRES)){ //refresh schema list + if (element.getDatabaseType().equals( + ConstantsPortlet.POSTGRES)) { // refresh schema list key = inputData.get("ResourceName") - + inputData.get("DatabaseName"); + + inputData.get("DatabaseName"); } - if (element.getDatabaseType().equals(ConstantsPortlet.MYSQL)){ //refresh table list + if (element.getDatabaseType() + .equals(ConstantsPortlet.MYSQL)) { // refresh table + // list key = inputData.get("ResourceName") + inputData.get("DatabaseName") - + inputData.get("SchemaName"); + + inputData.get("SchemaName"); } break; - + case "schema": key = inputData.get("ResourceName") - + inputData.get("DatabaseName") - + inputData.get("SchemaName"); + + inputData.get("DatabaseName") + + inputData.get("SchemaName"); break; } } - -// System.out.println("server->KEY: " + key); + // System.out.println("server->KEY: " + key); net.sf.ehcache.Element dataFromCache = getDataFromCache(key); if (dataFromCache != null) { -// System.out.println("server-> data in cache with key: " + key); + // System.out.println("server-> data in cache with key: " + + // key); refreshCache(key); -// System.out.println("server-> data removed from cache with key: " + key); + // System.out.println("server-> data removed from cache with key: " + // + key); if (!ElementType.equals("")) { -// System.out.println("server-> element type not null"); + // System.out.println("server-> element type not null"); switch (ElementType) { case "listResources": List output1 = getResource(); result = new GeneralOutputFromServlet(output1); -// System.out.println("server-> output generated"); + // System.out.println("server-> output generated"); break; case "resource": resourceName = inputData.get("ResourceName"); @@ -1794,19 +1772,27 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements result = new GeneralOutputFromServlet(output2); break; case "database": - if (element.getDatabaseType()!=null && (element.getDatabaseType().equals(ConstantsPortlet.POSTGRES))){ //refresh schema list + if (element.getDatabaseType() != null + && (element.getDatabaseType() + .equals(ConstantsPortlet.POSTGRES))) { // refresh + // schema + // list List output3 = getDBSchema(inputData); result = new GeneralOutputFromServlet(output3); } - if (element.getDatabaseType()!=null && element.getDatabaseType().equals(ConstantsPortlet.MYSQL)){ //refresh table list + if (element.getDatabaseType() != null + && element.getDatabaseType().equals( + ConstantsPortlet.MYSQL)) { // refresh + // table + // list getTables(inputData); - + } -// resourceName = inputData.get("ResourceName"); -// databaseName = inputData.get("DatabaseName"); - + // resourceName = inputData.get("ResourceName"); + // databaseName = inputData.get("DatabaseName"); + break; - + case "schema": getTables(inputData); break; diff --git a/src/main/resources/encache.xml b/src/main/resources/encache.xml index b931a1d..8be2c60 100644 --- a/src/main/resources/encache.xml +++ b/src/main/resources/encache.xml @@ -27,7 +27,7 @@ memoryStoreEvictionPolicy="LRU" transactionalMode="off" overflowToDisk="true" - diskPersistent="true" + diskPersistent="false" >