- constants listResources, resource, database, schema added in class ConstantsPortlet

- logger debug added in class GWTdbManagerServiceImpl.
- classes loadingTreeFinishedEvent, LoadingTreeFinishedEventHandler, RefreshDataFinishedEvent, RefreshDataFinishedEventHandler deleted

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@100621 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Loredana Liccardo 2014-10-10 16:38:39 +00:00
parent 9b569d41a3
commit c141548ceb
3 changed files with 67 additions and 63 deletions

View File

@ -722,16 +722,16 @@ public class GxtTreePanel extends LayoutContainer {
String value;
if (Depth == 1) { // root tree
elementType = "listResources";
value = "listResources";
elementType = ConstantsPortlet.RESOURCESLIST;
value = ConstantsPortlet.RESOURCESLIST;
inputData.put(value, value);
} else if (Depth == 2) { // resource
elementType = "resource";
elementType = ConstantsPortlet.RESOURCE;
value = selectedItem.getName();
inputData.put("ResourceName", value);
} else if (Depth == 3) { // database
elementType = "database";
elementType = ConstantsPortlet.DATABASE;
String database = selectedItem.getName();
// get the database type
// String dbType = selectedItem.getDatabaseType();
@ -762,7 +762,7 @@ public class GxtTreePanel extends LayoutContainer {
} else if (Depth == 4) { // Schema. Refresh tables list, query executed
// and samplings
elementType = "schema";
elementType = ConstantsPortlet.SCHEMA;
String schema = selectedItem.getName();
FileModel db = store.getParent(selectedItem);
String database = db.getName();
@ -812,7 +812,7 @@ public class GxtTreePanel extends LayoutContainer {
removeChildren(selectedItem);
tree.layout(true);
if (elemType.equals("listResources")) {
if (elemType.equals(ConstantsPortlet.RESOURCESLIST)) {
List<FileModel> output = new ArrayList<FileModel>();
output = result.getListOutput();
@ -828,7 +828,7 @@ public class GxtTreePanel extends LayoutContainer {
selectedItem.setIsLoaded(true);
} else if (elemType.equals("resource")) {
} else if (elemType.equals(ConstantsPortlet.RESOURCE)) {
LinkedHashMap<String, FileModel> output = new LinkedHashMap<String, FileModel>();
output = result.getMapOutput();
@ -971,7 +971,7 @@ public class GxtTreePanel extends LayoutContainer {
selectedItem.setIsLoaded(true);
} else if (elemType.equals("database")) {
} else if (elemType.equals(ConstantsPortlet.DATABASE)) {
List<FileModel> output = new ArrayList<FileModel>();
output = result.getListOutput();

View File

@ -21,8 +21,8 @@ public class ConstantsPortlet {
public static final String NONE = "NONE";
//element types
public static final String DATABASE="Database";
public static final String SCHEMA="Schema";
// public static final String DATABASE="Database";
// public static final String SCHEMA="Schema";
//algorithmID
public static final String ALGID_GETRESOURCE="LISTDBNAMES";
@ -36,6 +36,8 @@ public class ConstantsPortlet {
public static final String ALGID_RANDOMSAMPLEONTABLE="RANDOMSAMPLEONTABLE";
//elements type
public static final String RESOURCESLIST="RESOURCESLIST";
public static final String RESOURCE="RESOURCE";
public static final String RESOURCESLIST="ResourcesList";
public static final String RESOURCE="resource";
public static final String DATABASE="database";
public static final String SCHEMA="schema";
}

View File

@ -25,11 +25,7 @@ import net.sf.ehcache.CacheManager;
import net.sf.ehcache.config.CacheConfiguration;
import net.sf.ehcache.config.MemoryUnit;
import net.sf.ehcache.store.MemoryStoreEvictionPolicy;
import opennlp.tools.parser.Cons;
import org.apache.regexp.RE;
import org.apache.xpath.operations.Bool;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.contentmanager.storageclient.model.protocol.smp.SMPURLConnection;
@ -70,12 +66,9 @@ import org.gcube.portlets.user.databasesmanager.server.util.DataExchangedThrough
import org.gcube.portlets.user.databasesmanager.server.util.SessionUtil;
import org.gcube.portlets.user.databasesmanager.shared.SessionExpiredException;
import org.gcube.portlets.user.databasesmanager.shared.StatisticalManagerException;
import org.hibernate.engine.JoinSequence.Join;
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;
@ -528,6 +521,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
try {
logger.info("Submit Query Request received. Starting to manage the request.");
ASLSession session = SessionUtil.getAslSession(this
.getThreadLocalRequest().getSession());
// get scope
@ -771,7 +765,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
throw new SessionExpiredException();
try {
logger.info("dbmanager-> Sampling on table Request received. Starting to manage the request.");
ASLSession session = SessionUtil.getAslSession(this
.getThreadLocalRequest().getSession());
// get scope
@ -926,6 +920,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
throw new SessionExpiredException();
try {
logger.info("dbmanager-> Smart Sampling on table Request received. Starting to manage the request.");
ASLSession session = SessionUtil.getAslSession(this
.getThreadLocalRequest().getSession());
// get scope
@ -1078,6 +1073,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
throw new SessionExpiredException();
try {
logger.info("dbmanager-> Random Sampling on table Request received. Starting to manage the request.");
ASLSession session = SessionUtil.getAslSession(this
.getThreadLocalRequest().getSession());
// get scope
@ -1200,6 +1196,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
throw new SessionExpiredException();
try {
logger.info("dbmanager-> Table Details Recovery Request received. Starting to manage the request.");
ASLSession session = SessionUtil.getAslSession(this
.getThreadLocalRequest().getSession());
// get scope
@ -2077,7 +2074,9 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
public GeneralOutputFromServlet refreshDataTree(String ElementType,
LinkedHashMap<String, String> inputData, FileModel element)
throws Exception {
logger.info("dbmanager-> Refresh data request received. Starting to manage the request.");
// session check
if (isSessionExpired())
throw new SessionExpiredException();
@ -2108,17 +2107,17 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
if (!ElementType.equals("")) {
// build key
switch (ElementType) {
case "listResources":
key = scope + inputData.get("listResources");
case ConstantsPortlet.RESOURCESLIST:
key = scope + inputData.get(ConstantsPortlet.RESOURCESLIST);
dataQueue = new DataExchangedThroughQueue(scope);
break;
case "resource":
case ConstantsPortlet.RESOURCE:
key = scope + inputData.get("ResourceName");
dataQueue = new DataExchangedThroughQueue(scope,
"resource", inputData.get("ResourceName"),
ConstantsPortlet.RESOURCE, inputData.get("ResourceName"),
null, null, null);
break;
case "database":
case ConstantsPortlet.DATABASE:
if (element.getDatabaseType().equals(
ConstantsPortlet.POSTGRES)) { // refresh schema
// list
@ -2138,7 +2137,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// inputData, ConstantsPortlet.POSTGRES);
dataQueue = new DataExchangedThroughQueue(scope,
"database", inputData.get("ResourceName"),
ConstantsPortlet.DATABASE, inputData.get("ResourceName"),
inputData.get("DatabaseName"), null,
element.getDatabaseType());
key = scope + key;
@ -2176,14 +2175,14 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// element.getDatabaseType());
dataQueue = new DataExchangedThroughQueue(scope,
"database", inputData.get("ResourceName"),
ConstantsPortlet.DATABASE, inputData.get("ResourceName"),
inputData.get("DatabaseName"),
inputData.get("SchemaName"),
element.getDatabaseType());
}
break;
case "schema":
case ConstantsPortlet.SCHEMA:
key = inputData.get("ResourceName")
+ inputData.get("DatabaseName")
@ -2210,7 +2209,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// inputData, ConstantsPortlet.POSTGRES);
dataQueue = new DataExchangedThroughQueue(scope,
"schema", inputData.get("ResourceName"),
ConstantsPortlet.SCHEMA, inputData.get("ResourceName"),
inputData.get("DatabaseName"),
inputData.get("SchemaName"),
element.getDatabaseType());
@ -2218,12 +2217,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
}
}
// TODO ***DATA NULL IN CACHE MANAGEMENT
logger.trace("Check if data of the node is present in cache with key: : " + key);
logger.trace("dbmanager-> Check if data of the node is present in cache with key: : " + key);
net.sf.ehcache.Element dataFromCache = getDataFromCache(key);
if (dataFromCache != null) {
logger.trace("data of the node is in cache");
logger.trace("dbmanager-> Data of the node is in cache");
logger.info("dbmanager-> Starting the data removing process in cache from the node");
@ -2234,17 +2232,17 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// recover the refresh data of the item selected
if (!ElementType.equals("")) {
switch (ElementType) {
case "listResources":
case ConstantsPortlet.RESOURCESLIST:
List<FileModel> output1 = getResource();
result = new GeneralOutputFromServlet(output1);
// System.out.println("server-> output generated");
break;
case "resource":
case ConstantsPortlet.RESOURCE:
resourceName = inputData.get("ResourceName");
LinkedHashMap<String, FileModel> output2 = getDBInfo(resourceName);
result = new GeneralOutputFromServlet(output2);
break;
case "database":
case ConstantsPortlet.DATABASE:
if (element.getDatabaseType() != null
&& (element.getDatabaseType()
.equals(ConstantsPortlet.POSTGRES))) { // refresh
@ -2260,7 +2258,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
}
break;
case "schema":
case ConstantsPortlet.SCHEMA:
getTables(inputData, ConstantsPortlet.SCHEMA);
break;
}
@ -2283,6 +2281,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
logger.info("dbmanager-> The Thread DataLoader is already running");
queue.offer(dataQueue);
}
}else{
logger.trace("dbmanager-> Data of the node is not in cache");
}
}
return result;
@ -2315,26 +2315,26 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
if (value != null) {
if (!ElementType.equals("")) {
switch (ElementType) {
case "listResources":
case ConstantsPortlet.RESOURCESLIST:
// refresh resources
List<FileModel> resources = (List<FileModel>) value;
// refresh cache
refreshCache(key);
logger.trace("element: " + ElementType
logger.trace("dbmanager-> element: " + ElementType
+ " with key: " + key + " removed in cache");
// apply the refresh on children
for (int i = 0; i < resources.size(); i++) {
key = scope + resources.get(i).getName();
refreshDataInCache(element, "resource", null,
refreshDataInCache(element, ConstantsPortlet.RESOURCE, null,
key, null);
}
break;
case "resource":
case ConstantsPortlet.RESOURCE:
// refresh databases
LinkedHashMap<String, FileModel> DBdata = (LinkedHashMap<String, FileModel>) value;
// refresh cache
refreshCache(key);
logger.trace("element " + ElementType
logger.trace("dbmanager-> element " + ElementType
+ " with key: " + key + " removed in cache");
// apply the refresh on children
HashMap<String, String> DBlist = new HashMap<String, String>();
@ -2391,13 +2391,13 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// if (databaseType
// .equals(ConstantsPortlet.POSTGRES)) {
String newkey = key + array[i].toString();
refreshDataInCache(element, "database", null,
refreshDataInCache(element, ConstantsPortlet.DATABASE, null,
newkey, databaseType);
// }
}
break;
case "database":
case ConstantsPortlet.DATABASE:
if (DBType == null) {
DBType = element.getDatabaseType();
}
@ -2405,14 +2405,14 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
List<FileModel> schemaList = (List<FileModel>) value;
refreshCache(key); // refresh schema
logger.trace("element " + ElementType
logger.trace("dbmanager-> element " + ElementType
+ " with key: " + key + " removed in cache");
if (DBType.equals(ConstantsPortlet.POSTGRES)) {
// SCHEMA
for (int i = 0; i < schemaList.size(); i++) {
String newkey = key
+ schemaList.get(i).getName();
refreshDataInCache(element, "schema", null,
refreshDataInCache(element, ConstantsPortlet.SCHEMA, null,
newkey, null);
}
}
@ -2421,16 +2421,16 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// refresh tables
key = key + "";
refreshCache(key); // refresh tables
logger.trace("element " + ElementType
logger.trace("dbmanager-> element " + ElementType
+ " with key: " + key
+ " removed in cache");
}
break;
case "schema":
case ConstantsPortlet.SCHEMA:
// refresh tables (db postgres)
refreshCache(key);
logger.trace("element " + ElementType
logger.trace("dbmanager-> element " + ElementType
+ " with key: " + key + " removed in cache");
break;
}
@ -2593,7 +2593,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
private List<FileModel> recoverResources(String scope) throws Exception {
try {
logger.info("dbmanager-> Resources Recovery Request received. Starting to manage the request.");
// data input
List<Parameter> inputParameters = new ArrayList<Parameter>();
// data output
@ -2612,10 +2612,9 @@ 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";
String key = scope + ConstantsPortlet.RESOURCESLIST;
net.sf.ehcache.Element dataFromCache = getDataFromCache(key);
logger.trace("element added in cache with key: " + key);
Object value = null;
if (dataFromCache != null) {
value = dataFromCache.getObjectValue();
@ -2655,6 +2654,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
key, outputParameters);
insertDataIntoCache(dataToCache);
logger.trace("dbmanager-> element added in cache with key: " + key);
}
}
return outputParameters;
@ -2674,6 +2674,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
private LinkedHashMap<String, FileModel> recoverDatabases(String scope,
String resourceName) throws Exception {
try {
logger.info("dbmanager-> Databases Recovery Request received. Starting to manage the request.");
// data input
List<Parameter> inputParameters = new ArrayList<Parameter>();
// data output
@ -2696,8 +2697,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// check if data exist considering as key the input parameters
String key = scope + inputParameters.get(0).getValue();
net.sf.ehcache.Element dataFromCache = getDataFromCache(key);
logger.trace("element added in cache with key: " + key);
Object value = null;
if (dataFromCache != null) {
value = dataFromCache.getObjectValue();
@ -2747,6 +2747,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
key, outputParameters);
insertDataIntoCache(dataToCache);
logger.trace("dbmanager-> element added in cache with key: " + key);
}
}
return outputParameters;
@ -2768,7 +2769,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
LinkedHashMap<String, String> dataInput) throws Exception {
try {
logger.info("dbmanager-> Schema Recovery Request received. Starting to manage the request.");
// data input
List<Parameter> inputParameters = new ArrayList<Parameter>();
// data output
@ -2808,8 +2809,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
String key = scope + inputParameters.get(0).getValue()
+ inputParameters.get(1).getValue();
net.sf.ehcache.Element dataFromCache = getDataFromCache(key);
logger.trace("element put in cache with key: " + key);
Object value = null;
if (dataFromCache != null) {
value = dataFromCache.getObjectValue();
@ -2853,6 +2853,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
key, outputParameters);
insertDataIntoCache(dataToCache);
logger.trace("dbmanager-> element added in cache with key: " + key);
// DBCache.put(dataToCache);
}
}
@ -2875,6 +2876,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
throws Exception {
try {
logger.info("dbmanager-> Tables Recovery Request received. Starting to manage the request.");
// data input
List<Parameter> inputParameters = new ArrayList<Parameter>();
// data output
@ -2931,8 +2933,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
+ inputParameters.get(1).getValue()
+ inputParameters.get(2).getValue();
net.sf.ehcache.Element dataFromCache = getDataFromCache(key);
logger.trace("element put in cache with key: " + key);
Object value = null;
if (dataFromCache != null) {
value = dataFromCache.getObjectValue();
@ -2974,6 +2975,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
key, outputParameters);
insertDataIntoCache(dataToCache);
logger.trace("dbmanager-> element added in cache with key: " + key);
}
}
@ -3038,10 +3040,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
logger.info("dbmanager-> Starting the node refreshing process");
switch (elementType) {
case "resource":
case ConstantsPortlet.RESOURCE:
getDatabase(scope, resource);
break;
case "database":
case ConstantsPortlet.DATABASE:
String DBType = node.DBType();
String database = node.database();
if (DBType
@ -3055,7 +3057,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
ConstantsPortlet.DATABASE);
}
break;
case "schema":
case ConstantsPortlet.SCHEMA:
String db = node.database();
String schema = node.schema();
getTables(scope, resource, db, schema,