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
This commit is contained in:
parent
5e277ab215
commit
6b87523db1
|
@ -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<String> listAlgorithms;
|
||||
|
||||
public GWTdbManagerServiceImpl() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,22 +87,17 @@ 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()){
|
||||
|
@ -115,22 +105,37 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
//
|
||||
// }
|
||||
|
||||
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> result = new ArrayList<Result>();
|
||||
// session.setAttribute("TablesResult", result);
|
||||
// List<Result> result = new ArrayList<Result>();
|
||||
// session.setAttribute("TablesResult", result);
|
||||
|
||||
// map that contains the submit query result and the related uid
|
||||
HashMap<String, List<Result>> submitQueryResult = new HashMap<String, List<Result>>();
|
||||
|
@ -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<String, String> computationIDMap = new HashMap<String, String>();
|
||||
|
@ -188,7 +193,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// get algorithmId
|
||||
String algorithmId = "LISTDBNAMES";
|
||||
|
||||
|
||||
Parameter maxNumber = new Parameter("MaxNumber", "", "String", "-1");
|
||||
inputParameters.add(maxNumber);
|
||||
|
||||
|
@ -206,20 +210,20 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// System.out.println("***KEY: " + key);
|
||||
// net.sf.ehcache.Element dataFromCache =
|
||||
// employeeCache.get(key);
|
||||
|
||||
net.sf.ehcache.Element dataFromCache = getDataFromCache(key);
|
||||
|
||||
Object value = null;
|
||||
if (dataFromCache != null) {
|
||||
value = dataFromCache.getObjectValue();
|
||||
// System.out.println("***GETTING DATA FROM CACHE");
|
||||
// System.out.println("***GETTING DATA FROM CACHE");
|
||||
}
|
||||
if (value != null) {
|
||||
outputParameters = (List<FileModel>) value;
|
||||
} else {
|
||||
|
||||
|
||||
// start the computation
|
||||
// System.out.println("***STARTING THE COMPUTATION");
|
||||
// System.out.println("***STARTING THE COMPUTATION");
|
||||
// create data structure for data output
|
||||
ComputationOutput outputData = new ComputationOutput();
|
||||
// computationId
|
||||
|
@ -241,26 +245,24 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
outputParameters.add(obj);
|
||||
}
|
||||
|
||||
if (outputParameters != null
|
||||
&& outputParameters.size() != 0) {
|
||||
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);
|
||||
// e.printStackTrace();
|
||||
// throw new Exception("Failed to load data. " + e);
|
||||
throw e;
|
||||
}
|
||||
// }
|
||||
// }
|
||||
return outputParameters;
|
||||
}
|
||||
|
||||
|
@ -275,9 +277,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
String algorithmId = "LISTDBINFO";
|
||||
|
||||
//print check
|
||||
logger.info("dbmanager-> ResourceName: "
|
||||
+ resourceName);
|
||||
// print check
|
||||
logger.info("dbmanager-> ResourceName: " + resourceName);
|
||||
|
||||
Parameter resource = new Parameter("ResourceName", "", "String", "");
|
||||
inputParameters.add(resource);
|
||||
|
@ -333,17 +334,14 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// mapValues.get(String.valueOf(i)));
|
||||
// logger.info("key: " +
|
||||
// mapKeys.get(String.valueOf(i)));
|
||||
outputParameters.put(mapKeys.get(String.valueOf(i)),
|
||||
obj);
|
||||
outputParameters.put(mapKeys.get(String.valueOf(i)), obj);
|
||||
}
|
||||
|
||||
// write data in cache
|
||||
if (outputParameters != null
|
||||
&& outputParameters.size() != 0) {
|
||||
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);
|
||||
inputParameters.get(0).getValue(), outputParameters);
|
||||
|
||||
insertDataIntoCache(dataToCache);
|
||||
// employeeCache.put(dataToCache);
|
||||
|
@ -354,7 +352,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
throw new Exception("Failed to load data. " + e);
|
||||
// throw new Exception("Failed to load data " + );
|
||||
throw e;
|
||||
}
|
||||
|
||||
return outputParameters;
|
||||
|
@ -375,12 +374,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
String rs = dataInput.get("ResourceName");
|
||||
String db = dataInput.get("DatabaseName");
|
||||
|
||||
logger.info("dbmanager-> ResourceName: "
|
||||
+ rs);
|
||||
logger.info("dbmanager-> DatabaseName: "
|
||||
+ db);
|
||||
logger.info("dbmanager-> ResourceName: " + rs);
|
||||
logger.info("dbmanager-> DatabaseName: " + db);
|
||||
|
||||
//set input parameters
|
||||
// set input parameters
|
||||
Parameter resource = new Parameter("ResourceName", "", "String", "");
|
||||
Parameter database = new Parameter("DatabaseName", "", "String", "");
|
||||
inputParameters.add(resource);
|
||||
|
@ -400,7 +397,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
String key = inputParameters.get(0).getValue()
|
||||
+ inputParameters.get(1).getValue();
|
||||
|
||||
// System.out.println("key in GETSCHEMA: " + key);
|
||||
// System.out.println("key in GETSCHEMA: " + key);
|
||||
|
||||
net.sf.ehcache.Element dataFromCache = getDataFromCache(key);
|
||||
|
||||
|
@ -440,8 +437,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
|
||||
// write data in cache
|
||||
if (outputParameters != null
|
||||
&& outputParameters.size() != 0) {
|
||||
if (outputParameters != null && outputParameters.size() != 0) {
|
||||
// put data in cache
|
||||
net.sf.ehcache.Element dataToCache = new net.sf.ehcache.Element(
|
||||
inputParameters.get(0).getValue()
|
||||
|
@ -457,7 +453,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
throw new Exception("Failed to load data. " + e);
|
||||
// throw new Exception("Failed to load data. " + e);
|
||||
throw e;
|
||||
|
||||
}
|
||||
|
||||
|
@ -472,25 +469,21 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// data output
|
||||
List<Result> outputParameters = new ArrayList<Result>();
|
||||
|
||||
|
||||
String algorithmId = "LISTTABLES";
|
||||
|
||||
String rs= dataInput.get("ResourceName");
|
||||
String db= dataInput.get("DatabaseName");
|
||||
String scm= dataInput.get("SchemaName");
|
||||
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);
|
||||
// print check
|
||||
logger.info("dbmanager-> ResourceName: " + rs);
|
||||
logger.info("dbmanager-> DatabaseName: " + db);
|
||||
logger.info("dbmanager-> SchemaName: " + scm);
|
||||
|
||||
//set input parameters
|
||||
// set input parameters
|
||||
Parameter resource = new Parameter("ResourceName", "", "String", "");
|
||||
Parameter database = new Parameter("DatabaseName", "", "String", "");
|
||||
Parameter schema = new Parameter("SchemaName","", "String", "");
|
||||
Parameter schema = new Parameter("SchemaName", "", "String", "");
|
||||
inputParameters.add(resource);
|
||||
inputParameters.add(database);
|
||||
inputParameters.add(schema);
|
||||
|
@ -499,11 +492,12 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
inputParameters.get(1).setValue(db);
|
||||
inputParameters.get(2).setValue(scm);
|
||||
|
||||
try{
|
||||
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();
|
||||
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);
|
||||
|
@ -511,19 +505,19 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
Object value = null;
|
||||
if (dataFromCache != null) {
|
||||
value = dataFromCache.getObjectValue();
|
||||
// System.out.println("***GETTING DATA FROM CACHE");
|
||||
// System.out.println("***GETTING DATA FROM CACHE");
|
||||
}
|
||||
if (value != null) {
|
||||
outputParameters = (List<Result>) value;
|
||||
|
||||
} else {
|
||||
|
||||
//start computation
|
||||
// start computation
|
||||
// create data structure
|
||||
ComputationOutput outputData = new ComputationOutput();
|
||||
// computation id
|
||||
String computationId = startComputation(algorithmId, inputParameters,
|
||||
outputData);
|
||||
String computationId = startComputation(algorithmId,
|
||||
inputParameters, outputData);
|
||||
|
||||
// print check on retrieving data
|
||||
// logger.info("output data retrieved");
|
||||
|
@ -537,18 +531,18 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
mapKeys = outputData.getmapKeys();
|
||||
|
||||
for (int i = 0; i < mapValues.size(); i++) {
|
||||
Result row = new Result(String.valueOf(i), mapValues.get(String
|
||||
.valueOf(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) {
|
||||
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(),
|
||||
+ inputParameters.get(1).getValue()
|
||||
+ inputParameters.get(2).getValue(),
|
||||
outputParameters);
|
||||
|
||||
insertDataIntoCache(dataToCache);
|
||||
|
@ -557,36 +551,36 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
throw new Exception("Failed to load data. " + e);
|
||||
} 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<String, String> mapValues = new LinkedHashMap<String, String>();
|
||||
// // data output keys
|
||||
// LinkedHashMap<String, String> mapKeys = new LinkedHashMap<String, String>();
|
||||
//
|
||||
// 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);
|
||||
// }
|
||||
// // 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<String, String> mapValues = new LinkedHashMap<String,
|
||||
// String>();
|
||||
// // data output keys
|
||||
// LinkedHashMap<String, String> mapKeys = new LinkedHashMap<String,
|
||||
// String>();
|
||||
//
|
||||
// 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,37 +591,39 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
LinkedHashMap<String, String> dataInput, boolean SearchTable,
|
||||
String keyword) throws Exception {
|
||||
|
||||
//tables' list stored for a user session
|
||||
// ASLSession session = WsUtil.getAslSession(this.getThreadLocalRequest()
|
||||
// .getSession());
|
||||
// List<Result> result = (List<Result>) 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<Result>();
|
||||
// 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<Result>();
|
||||
// System.gc();
|
||||
// }
|
||||
//
|
||||
// previousSchema = currentSchema;
|
||||
// session.setAttribute("previousSchema", previousSchema);
|
||||
// tables' list stored for a user session
|
||||
// ASLSession session =
|
||||
// WsUtil.getAslSession(this.getThreadLocalRequest()
|
||||
// .getSession());
|
||||
// List<Result> result = (List<Result>) 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<Result>();
|
||||
// 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<Result>();
|
||||
// System.gc();
|
||||
// }
|
||||
//
|
||||
// previousSchema = currentSchema;
|
||||
// session.setAttribute("previousSchema", previousSchema);
|
||||
|
||||
List<Result> result = new ArrayList<>();
|
||||
|
||||
|
@ -688,7 +684,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
loadResult = new BasePagingLoadResult<Result>(sublist,
|
||||
config.getOffset(), totalNumber);
|
||||
// session.setAttribute("TablesResult", result);
|
||||
// session.setAttribute("TablesResult", result);
|
||||
return loadResult;
|
||||
}
|
||||
|
||||
|
@ -711,29 +707,27 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// list that contains table attributes
|
||||
List<String> listAttributes = null;
|
||||
|
||||
|
||||
String algorithmId = "SUBMITQUERY";
|
||||
|
||||
// print check
|
||||
String rs= dataDB.get("ResourceName");
|
||||
String db= dataDB.get("DatabaseName");
|
||||
String rs = dataDB.get("ResourceName");
|
||||
String db = dataDB.get("DatabaseName");
|
||||
|
||||
|
||||
//print check
|
||||
logger.info("dbmanager-> ResourceName: "
|
||||
+ rs);
|
||||
logger.info("dbmanager-> DatabaseName: "
|
||||
+ db);
|
||||
// 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
|
||||
// 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 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", "");
|
||||
|
||||
|
@ -744,7 +738,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
inputParameters.add(lng);
|
||||
inputParameters.add(q);
|
||||
|
||||
|
||||
inputParameters.get(0).setValue(rs);
|
||||
inputParameters.get(1).setValue(db);
|
||||
inputParameters.get(2).setValue(String.valueOf(valueReadOnlyQuery));
|
||||
|
@ -824,30 +817,25 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// output sample result
|
||||
List<Result> output = new ArrayList<Result>();
|
||||
|
||||
|
||||
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
|
||||
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);
|
||||
// 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
|
||||
// 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", "");
|
||||
Parameter schema = new Parameter("SchemaName", "", "String", "");
|
||||
Parameter table = new Parameter("TableName", "", "String", "");
|
||||
inputParameters.add(resource);
|
||||
inputParameters.add(database);
|
||||
inputParameters.add(schema);
|
||||
|
@ -858,7 +846,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
inputParameters.get(2).setValue(scm);
|
||||
inputParameters.get(3).setValue(tab);
|
||||
|
||||
|
||||
// create data structure
|
||||
ComputationOutput outputData = new ComputationOutput();
|
||||
// computation id
|
||||
|
@ -895,27 +882,23 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
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
|
||||
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);
|
||||
// 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
|
||||
// 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", "");
|
||||
Parameter schema = new Parameter("SchemaName", "", "String", "");
|
||||
Parameter table = new Parameter("TableName", "", "String", "");
|
||||
inputParameters.add(resource);
|
||||
inputParameters.add(database);
|
||||
inputParameters.add(schema);
|
||||
|
@ -963,27 +946,23 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
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
|
||||
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);
|
||||
// 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
|
||||
// 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", "");
|
||||
Parameter schema = new Parameter("SchemaName", "", "String", "");
|
||||
Parameter table = new Parameter("TableName", "", "String", "");
|
||||
inputParameters.add(resource);
|
||||
inputParameters.add(database);
|
||||
inputParameters.add(schema);
|
||||
|
@ -1030,28 +1009,23 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
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
|
||||
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);
|
||||
// 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
|
||||
// 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", "");
|
||||
Parameter schema = new Parameter("SchemaName", "", "String", "");
|
||||
Parameter table = new Parameter("TableName", "", "String", "");
|
||||
inputParameters.add(resource);
|
||||
inputParameters.add(database);
|
||||
inputParameters.add(schema);
|
||||
|
@ -1062,7 +1036,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
inputParameters.get(2).setValue(scm);
|
||||
inputParameters.get(3).setValue(tab);
|
||||
|
||||
|
||||
// create data structure
|
||||
ComputationOutput outputData = new ComputationOutput();
|
||||
// computation id
|
||||
|
@ -1235,55 +1208,55 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
return elements;
|
||||
}
|
||||
|
||||
//not called
|
||||
// private List<String> getDatabaseManagerAlgorithms() {
|
||||
// ArrayList<String> dbAlg = new ArrayList<String>();
|
||||
// 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<String> getDatabaseManagerAlgorithms() {
|
||||
// ArrayList<String> dbAlg = new ArrayList<String>();
|
||||
// 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<Parameter> getParameters(String algorithmId) {
|
||||
// StatisticalManagerFactory factory = getFactory();
|
||||
// SMParameters smParams = factory.getAlgorithmParameters(algorithmId);
|
||||
// List<Parameter> params = new ArrayList<Parameter>();
|
||||
//
|
||||
// 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<Parameter> getParameters(String algorithmId) {
|
||||
// StatisticalManagerFactory factory = getFactory();
|
||||
// SMParameters smParams = factory.getAlgorithmParameters(algorithmId);
|
||||
// List<Parameter> params = new ArrayList<Parameter>();
|
||||
//
|
||||
// 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<Result> 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<String, String> inputData, FileModel element) throws Exception {
|
||||
LinkedHashMap<String, String> 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,11 +1726,14 @@ 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");
|
||||
}
|
||||
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");
|
||||
|
@ -1771,22 +1748,23 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// 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<FileModel> 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,16 +1772,24 @@ 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<FileModel> 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;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
memoryStoreEvictionPolicy="LRU"
|
||||
transactionalMode="off"
|
||||
overflowToDisk="true"
|
||||
diskPersistent="true"
|
||||
diskPersistent="false"
|
||||
>
|
||||
</cache>
|
||||
|
||||
|
|
Loading…
Reference in New Issue