code cleaned up removing commented lines (modifications on code) in class GWTdbManagerServiceImpl

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@100483 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Loredana Liccardo 2014-10-07 13:20:16 +00:00
parent 92e90ae3f2
commit 4a2a2f2cc3
1 changed files with 48 additions and 565 deletions

View File

@ -89,7 +89,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
private static HashMap<String, Boolean> threadsStarted = new HashMap<String, Boolean>();
private static boolean endThread = false;
public GWTdbManagerServiceImpl() throws Exception {
}
@ -194,21 +193,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// set endThread variable
setEndThreadvariable();
// set endThread variable
// try {
// setEndThreadvariable();
// logger.info("Thread successfully stopped");
//
// } catch (InterruptedException e1) {
// // TODO Auto-generated catch block
// // e1.printStackTrace();
// logger.error("dbmanager-> ", e1);
// } finally{
//
// if(t.interrupted()){
// logger.info("Thread interrupt");
// }
try {
CacheManager cacheManager = CacheManager.getInstance();
@ -240,14 +224,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
}
private void initVariables(ASLSession session) {
// // get scope
// String scope = session.getScope();
//
// ThreadLoaderData loader = new ThreadLoaderData(scope);
// Thread t = new Thread(loader);
// t.start();
// the result generated in the LoadTables method
// List<Result> result = new ArrayList<Result>();
// session.setAttribute("TablesResult", result);
@ -335,89 +311,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
}
// try {
//
// // initialize variables with application startup
// initVariables();
//
// // data input
// List<Parameter> inputParameters = new ArrayList<Parameter>();
// // data output
// List<FileModel> outputParameters = new ArrayList<FileModel>();
//
// // get algorithmId
// String algorithmId = ConstantsPortlet.ALGID_GETRESOURCE;
//
// 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.
//
// // get data from cache
// // check if data exist considering as key the input parameters
// // String key = inputParameters.get(0).getDefaultValue();
// String key = "listResources";
//
// // 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<FileModel>) 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<String, String> mapValues = new LinkedHashMap<String,
// String>();
// 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);
// }
// }
//
// return outputParameters;
//
// } catch (Exception e) {
// // e.printStackTrace();
// // throw new Exception("Failed to load data. " + e);
// logger.error("dbmanager-> ", e);
// if (!(e instanceof StatisticalManagerException)) {
// // GWT can't serialize all exceptions
// throw new Exception(
// "Error in server while loading data. Exception: " + e);
// }
// throw e;
// }
}
// to get information about databases of a resource
@ -441,101 +334,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
throw e;
}
// try {
// // data input
// List<Parameter> inputParameters = new ArrayList<Parameter>();
// // data output
// LinkedHashMap<String, FileModel> outputParameters = new
// LinkedHashMap<String, FileModel>();
//
// String algorithmId = ConstantsPortlet.ALGID_GETDBINFO;
//
// // print check
// logger.info("dbmanager-> ResourceName: " + resourceName);
//
// if ((resourceName == null) || (resourceName.equals(""))) {
// throw new Exception("Unable to load data");
// }
//
// Parameter resource = new Parameter("ResourceName", "", "String", "");
// inputParameters.add(resource);
// inputParameters.get(0).setValue(resourceName);
//
// // 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 = getDataFromCache(key);
//
// Object value = null;
// if (dataFromCache != null) {
// value = dataFromCache.getObjectValue();
// }
// if (value != null) {
// outputParameters = (LinkedHashMap<String, FileModel>) 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<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++) {
// 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);
// }
// }
//
// return outputParameters;
//
// } catch (Exception e) {
// // e.printStackTrace();
// // throw new Exception("Failed to load data " + );
// logger.error("dbmanager-> ", e);
//
// if (!(e instanceof StatisticalManagerException)) {
// // GWT can't serialize all exceptions
// throw new Exception(
// "Error in server while loading data. Exception: " + e);
// }
// throw e;
// }
}
// to get schema for a database
@ -559,113 +357,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
throw e;
}
// try {
//
// // data input
// List<Parameter> inputParameters = new ArrayList<Parameter>();
// // data output
// List<FileModel> outputParameters = new ArrayList<FileModel>();
//
// String algorithmId = ConstantsPortlet.ALGID_GETDBSCHEMA;
// // print check
// String rs = dataInput.get("ResourceName");
// String db = dataInput.get("DatabaseName");
//
// logger.info("dbmanager-> ResourceName: " + rs);
// logger.info("dbmanager-> DatabaseName: " + db);
//
// if ((rs == null) || (rs.equals(""))) {
// throw new Exception("Unable to load data");
// }
// if ((db == null) || (db.equals(""))) {
// throw new Exception("Unable to load data");
// }
//
// // set input parameters
// Parameter resource = new Parameter("ResourceName", "", "String", "");
// Parameter database = new Parameter("DatabaseName", "", "String", "");
// inputParameters.add(resource);
// inputParameters.add(database);
//
// inputParameters.get(0).setValue(rs);
// inputParameters.get(1).setValue(db);
//
// // print check algorithm input parameters
// // for (int i = 0; i < inputParameters.size(); i++) {
// // logger.info(inputParameters.get(i).getName());
// // }
//
// // 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);
// net.sf.ehcache.Element dataFromCache = getDataFromCache(key);
//
// Object value = null;
// if (dataFromCache != null) {
// value = dataFromCache.getObjectValue();
// }
// if (value != null) {
// outputParameters = (List<FileModel>) value;
// } else {
//
// // start the computation
// // create data structure
// ComputationOutput outputData = new ComputationOutput();
// // computation id
// String computationId = startComputation(algorithmId,
// inputParameters, outputData, scope);
//
// // print check
// // retrieve data
// // logger.info("dbmanager-> 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++) {
// 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);
// // DBCache.put(dataToCache);
// }
// }
//
// return outputParameters;
//
// } catch (Exception e) {
// // e.printStackTrace();
// // throw new Exception("Failed to load data. " + e);
// logger.error("dbmanager-> ", e);
// if (!(e instanceof StatisticalManagerException)) {
// // GWT can't serialize all exceptions
// throw new Exception(
// "Error in server while loading data. Exception: " + e);
// }
// throw e;
// }
}
// to get tables
@ -684,130 +375,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
throw e;
}
// try {
//
// // data input
// List<Parameter> inputParameters = new ArrayList<Parameter>();
// // data output
// List<Result> outputParameters = new ArrayList<Result>();
//
// String algorithmId = ConstantsPortlet.ALGID_GETTABLES;
//
// 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);
//
// if ((elementType != null)
// && (elementType.equals(ConstantsPortlet.SCHEMA))) {
// if ((rs == null) || (rs.equals(""))) {
// throw new Exception("Unable to load data");
// }
// if ((db == null) || (db.equals(""))) {
// throw new Exception("Unable to load data");
// }
// if ((scm == null) || (scm.equals(""))) {
// throw new Exception("Unable to load data");
// }
// }
// if ((elementType != null)
// && (elementType.equals(ConstantsPortlet.DATABASE))) {
// if ((rs == null) || (rs.equals(""))) {
// throw new Exception("Unable to load data");
// }
// if ((db == null) || (db.equals(""))) {
// throw new Exception("Unable to load data");
// }
// }
//
// // 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);
//
// // 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<Result>) value;
//
// } else {
//
// // start computation
// // create data structure
// ComputationOutput outputData = new ComputationOutput();
// // computation id
// String computationId = startComputation(algorithmId,
// inputParameters, outputData, scope);
//
// // 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);
// }
//
// // 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);
// }
//
// }
// return outputParameters;
//
// } catch (Exception e) {
// // e.printStackTrace();
// // throw new Exception("Failed to load data. " + e);
// // logger.error("dbmanager-> ", e);
//
// if (!(e instanceof StatisticalManagerException)) {
// // GWT can't serialize all exceptions
// throw new Exception(
// "Error in server while loading data. Exception: " + e);
// }
// throw e;
// }
}
// to load tables
@ -944,7 +511,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
throw new SessionExpiredException();
try {
ASLSession session = SessionUtil.getAslSession(this
.getThreadLocalRequest().getSession());
// get scope
@ -1020,7 +587,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// parse the query in order to remove spaces
String queryParsed = parseQuery(inputParameters.get(5).getValue());
// get data sent to client calling the submitQuery
String keyData = scope+algorithmId + inputParameters.get(0).getValue()
String keyData = scope + algorithmId
+ inputParameters.get(0).getValue()
+ inputParameters.get(1).getValue()
+ inputParameters.get(2).getValue()
+ inputParameters.get(3).getValue()
@ -1186,15 +754,13 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
if (isSessionExpired())
throw new SessionExpiredException();
try {
ASLSession session = SessionUtil.getAslSession(this
.getThreadLocalRequest().getSession());
// get scope
String scope = session.getScope();
// data input
List<Parameter> inputParameters = new ArrayList<Parameter>();
// output sample result
@ -1260,12 +826,13 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// get data from cache
// check if data exist considering as key the input parameters
String key = scope+algorithmId + inputParameters.get(0).getValue()
String key = scope + algorithmId
+ inputParameters.get(0).getValue()
+ inputParameters.get(1).getValue()
+ inputParameters.get(2).getValue()
+ inputParameters.get(3).getValue();
// System.out.println("sampling KEY: " + key);
// System.out.println("sampling KEY: " + key);
net.sf.ehcache.Element dataFromCache = getDataFromCache(key);
Object value = null;
@ -1347,7 +914,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
.getThreadLocalRequest().getSession());
// get scope
String scope = session.getScope();
// data input
List<Parameter> inputParameters = new ArrayList<Parameter>();
// output sample result
@ -1413,7 +980,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// get data from cache
// check if data exist considering as key the input parameters
String key = scope+algorithmId + inputParameters.get(0).getValue()
String key = scope + algorithmId
+ inputParameters.get(0).getValue()
+ inputParameters.get(1).getValue()
+ inputParameters.get(2).getValue()
+ inputParameters.get(3).getValue();
@ -1498,7 +1066,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
.getThreadLocalRequest().getSession());
// get scope
String scope = session.getScope();
// data input
List<Parameter> inputParameters = new ArrayList<Parameter>();
// output sample result
@ -1615,14 +1183,12 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
if (isSessionExpired())
throw new SessionExpiredException();
try {
ASLSession session = SessionUtil.getAslSession(this
.getThreadLocalRequest().getSession());
// get scope
String scope = session.getScope();
// data input
List<Parameter> inputParameters = new ArrayList<Parameter>();
// data ouptut
@ -2420,8 +1986,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
}
if (computationId != null) {
// TODO ******* TO MODIFY
StatisticalManagerFactory factory = getFactory("");
try {
factory.removeComputation(computationId);
@ -2445,16 +2009,12 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// request
// removeSubmitQueryUIDCachedData(uidSubmitQuery);
}
}
return isComputationRemoved;
} catch (Exception e) {
logger.error("dbmanager-> ", e);
throw new Exception(
"Error in server while loading data. Exception: " + e);
}
// finally {
// // remove the element related to the uid submitQuery request
@ -2485,13 +2045,9 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
if (DBCache != null) {
DBCache.put(data);
}
// System.out.println("data inserted");
}
private synchronized net.sf.ehcache.Element getDataFromCache(String key) {
// System.out.println("***get item with KEY: " + key);
net.sf.ehcache.Element data = null;
if (DBCache != null) {
data = DBCache.get(key);
@ -2507,24 +2063,21 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// session check
if (isSessionExpired())
throw new SessionExpiredException();
try {
ASLSession session = SessionUtil.getAslSession(this
.getThreadLocalRequest().getSession());
// get scope
String scope = session.getScope();
// // call the method related to the element selected
//
String resourceName = "";
String databaseName = "";
GeneralOutputFromServlet result = null;
//build key
// build key
if (inputData != null && inputData.size() != 0) {
// System.out.println("server-> input size not null");
String key = "";
@ -2537,10 +2090,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// System.out.println("server-> element type not null");
switch (ElementType) {
case "listResources":
key = scope+inputData.get("listResources");
key = scope + inputData.get("listResources");
break;
case "resource":
key = scope+inputData.get("ResourceName");
key = scope + inputData.get("ResourceName");
break;
case "database":
if (element.getDatabaseType().equals(
@ -2550,8 +2103,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
+ inputData.get("DatabaseName");
// refresh submitted queries
keyUsedForQueryRefresh = scope+ConstantsPortlet.ALGID_SUBMITQUERY
+ key;
keyUsedForQueryRefresh = scope
+ ConstantsPortlet.ALGID_SUBMITQUERY + key;
refreshSubmittedQueryInCache(keyUsedForQueryRefresh);
}
@ -2562,15 +2115,17 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
+ inputData.get("DatabaseName")
+ inputData.get("SchemaName");
keyUsedForQueryRefresh = scope+ConstantsPortlet.ALGID_SUBMITQUERY
+ key;
keyUsedForQueryRefresh = scope
+ ConstantsPortlet.ALGID_SUBMITQUERY + key;
refreshSubmittedQueryInCache(keyUsedForQueryRefresh);
keyUsedForSamplingsRefresh = scope+ConstantsPortlet.ALGID_SAMPLEONTABLE
keyUsedForSamplingsRefresh = scope
+ ConstantsPortlet.ALGID_SAMPLEONTABLE
+ key;
keyUsedForSmartSamplingRefresh = scope+ConstantsPortlet.ALGID_SMARTSAMPLEONTABLE
keyUsedForSmartSamplingRefresh = scope
+ ConstantsPortlet.ALGID_SMARTSAMPLEONTABLE
+ key;
key = scope + key;
refreshSamplingsInCache(keyUsedForSamplingsRefresh,
@ -2585,20 +2140,22 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
+ inputData.get("SchemaName");
// refresh submitted query and samplings and tables list
keyUsedForQueryRefresh = scope+ConstantsPortlet.ALGID_SUBMITQUERY
keyUsedForQueryRefresh = scope
+ ConstantsPortlet.ALGID_SUBMITQUERY
+ inputData.get("ResourceName")
+ inputData.get("DatabaseName");
refreshSubmittedQueryInCache(keyUsedForQueryRefresh);
keyUsedForSamplingsRefresh = scope+ConstantsPortlet.ALGID_SAMPLEONTABLE
keyUsedForSamplingsRefresh = scope
+ ConstantsPortlet.ALGID_SAMPLEONTABLE + key;
keyUsedForSmartSamplingRefresh = scope
+ ConstantsPortlet.ALGID_SMARTSAMPLEONTABLE
+ key;
keyUsedForSmartSamplingRefresh = scope+ConstantsPortlet.ALGID_SMARTSAMPLEONTABLE
+ key;
key = scope+key;
key = scope + key;
refreshSamplingsInCache(keyUsedForSamplingsRefresh,
keyUsedForSmartSamplingRefresh);
break;
}
}
@ -2784,7 +2341,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
private synchronized void setEndThreadvariable() {
endThread = true;
logger.info("dbmanager-> variable EndThread set in order to stop the thread execution");
logger.info("dbmanager-> Variable EndThread set in order to stop the thread execution");
}
@ -2796,9 +2353,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
try {
// initialize variables with application startup
// initVariables();
// data input
List<Parameter> inputParameters = new ArrayList<Parameter>();
// data output
@ -2817,9 +2371,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// get data from cache
// check if data exist considering as key the input parameters
// String key = inputParameters.get(0).getDefaultValue();
String key = scope+"listResources";
// System.out.println("***GetResource KEY: " + key);
String key = scope + "listResources";
net.sf.ehcache.Element dataFromCache = getDataFromCache(key);
Object value = null;
@ -2828,7 +2380,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// System.out.println("***GETTING DATA FROM CACHE");
}
if (value != null) {
// System.out.println("***GETTING DATA FROM CACHE");
// System.out.println("***GETTING DATA FROM CACHE");
outputParameters = (List<FileModel>) value;
} else {
@ -2863,9 +2415,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
insertDataIntoCache(dataToCache);
}
}
return outputParameters;
} catch (Exception e) {
// e.printStackTrace();
// throw new Exception("Failed to load data. " + e);
@ -2902,9 +2452,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// get data from cache
// check if data exist considering as key the input parameters
String key = scope+inputParameters.get(0).getValue();
// System.out.println("***KEY: " + key);
String key = scope + inputParameters.get(0).getValue();
net.sf.ehcache.Element dataFromCache = getDataFromCache(key);
Object value = null;
@ -2952,17 +2500,13 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// 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);
net.sf.ehcache.Element dataToCache = new net.sf.ehcache.Element(
key, outputParameters);
insertDataIntoCache(dataToCache);
}
}
return outputParameters;
} catch (Exception e) {
// e.printStackTrace();
// throw new Exception("Failed to load data " + );
@ -3018,10 +2562,9 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// get data from cache
// check if data exist considering as key the input parameters
String key = scope+inputParameters.get(0).getValue()
String key = scope + inputParameters.get(0).getValue()
+ inputParameters.get(1).getValue();
// System.out.println("key in GETSCHEMA: " + key);
net.sf.ehcache.Element dataFromCache = getDataFromCache(key);
Object value = null;
@ -3062,21 +2605,15 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// 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);
net.sf.ehcache.Element dataToCache = new net.sf.ehcache.Element(
key,outputParameters);
key, outputParameters);
insertDataIntoCache(dataToCache);
// DBCache.put(dataToCache);
}
}
return outputParameters;
} catch (Exception e) {
// e.printStackTrace();
// throw new Exception("Failed to load data. " + e);
@ -3088,7 +2625,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
}
throw e;
}
}
private List<Result> recoverTables(String scope,
@ -3148,11 +2684,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// get data from cache
// check if data exist considering as key the input parameters
String key = scope+inputParameters.get(0).getValue()
String key = scope + 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;
@ -3192,11 +2727,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// 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);
net.sf.ehcache.Element dataToCache = new net.sf.ehcache.Element(
key, outputParameters);
@ -3252,24 +2782,14 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
while ((!getEndThreadvariable()) && (i < resources.size())) {
getDatabase(resources.get(i).getName());
i++;
logger.error("dbmanager-> ***inside the while");
// logger.info("dbmanager-> ***thread inside the root while");
}
logger.error("dbmanager-> ***outside the while");
// logger.info("dbmanager-> ***thread outside the root while");
}
logger.info("dbmanager-> ***Thread execution terminated");
// List<FileModel> resources = recoverResources(scope);
//
// for (int i = 0; i < resources.size(); i++) {
// getDatabase(resources.get(i).getName());
// }
// logger.info("dbmanager-> ***Thread execution terminated");
} catch (Exception e) {
logger.error("dbmanager-> ", e);
}
}
private void getDatabase(String resourceName) {
@ -3286,8 +2806,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
int i = 0;
int j = 0;
for (i = 0; i < numIterations; i++) {
// for (i = 0; i < 1; i++) {
// String DBName = "";
// for (j = (i * 5); j < (i + 1) * 5; j++) {
String DBName = "";
@ -3317,25 +2835,14 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// schemaList.size(); i++) {
String schemaName = schemaList.get(
z).getName();
// System.out.println("SchemaName: "
// + schemaName);
// LinkedHashMap<String, String>
// dataInputForTables = new
// LinkedHashMap<String, String>();
// dataInputForTables.put("ResourceName",
// resourceName);
// dataInputForTables.put("DatabaseName",
// DBName);
// dataInputForTables.put("SchemaName",
// schemaName);
// System.out.println("SchemaName: "
// + schemaName);
getTables(resourceName, DBName,
schemaName,
ConstantsPortlet.SCHEMA);
z++;
}
}
}
if (driver.toUpperCase().contains(
@ -3365,25 +2872,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
dataInputForSchema.put("DatabaseName", databaseName);
schemaList = recoverSchema(scope, dataInputForSchema);
// if (schemaList != null) {
// int i=0;
// while((!getEndThreadvariable())&&( i < schemaList.size())){
// // for (int i = 0; i < schemaList.size(); i++) {
// String schemaName = schemaList.get(i).getName();
// System.out.println("SchemaName: " + schemaName);
//
// LinkedHashMap<String, String> dataInputForTables = new
// LinkedHashMap<String, String>();
// dataInputForTables.put("ResourceName", resourceName);
// dataInputForTables.put("DatabaseName", databaseName);
// dataInputForTables.put("SchemaName", schemaName);
// recoverTables(scope, dataInputForTables,
// ConstantsPortlet.SCHEMA);
// i++;
// }
// }
} catch (Exception e) {
logger.error("dbmanager-> ", e);
}
@ -3393,20 +2881,15 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
public void getTables(String resourceName, String databaseName,
String schemaName, String elementType) {
try {
LinkedHashMap<String, String> dataInputForTables = new LinkedHashMap<String, String>();
dataInputForTables.put("ResourceName", resourceName);
dataInputForTables.put("DatabaseName", databaseName);
dataInputForTables.put("SchemaName", schemaName);
recoverTables(scope, dataInputForTables,
ConstantsPortlet.DATABASE);
} catch (Exception e) {
logger.error("dbmanager-> ", e);
}
}
}
}