ref 12119:AccountingDashboard - Create a new Accounting Dashboard

https://support.d4science.org/issues/12119

Updated Tree

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/accounting-dashboard@169705 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2018-07-06 15:48:46 +00:00
parent 5c49bc0dfc
commit cf23291ed6
12 changed files with 396 additions and 166 deletions

View File

@ -7,7 +7,9 @@ import org.gcube.portlets.user.accountingdashboard.client.application.dialog.err
import org.gcube.portlets.user.accountingdashboard.client.application.dialog.info.InfoPresenter; import org.gcube.portlets.user.accountingdashboard.client.application.dialog.info.InfoPresenter;
import org.gcube.portlets.user.accountingdashboard.client.application.dialog.monitor.MonitorPresenter; import org.gcube.portlets.user.accountingdashboard.client.application.dialog.monitor.MonitorPresenter;
import org.gcube.portlets.user.accountingdashboard.client.application.event.HelloEvent; import org.gcube.portlets.user.accountingdashboard.client.application.event.HelloEvent;
import org.gcube.portlets.user.accountingdashboard.client.application.event.ScopeDataEvent;
import org.gcube.portlets.user.accountingdashboard.client.rpc.AccountingDashboardServiceAsync; import org.gcube.portlets.user.accountingdashboard.client.rpc.AccountingDashboardServiceAsync;
import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData;
import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo; import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo;
import com.google.gwt.event.shared.EventBus; import com.google.gwt.event.shared.EventBus;
@ -84,5 +86,28 @@ public class Controller {
} }
public void getTree() {
service.getScopeData(new AsyncCallback<ScopeData>() {
@Override
public void onFailure(Throwable caught) {
logger.log(Level.FINE, "Error in Hello(): ", caught);
errorPresenter.errorMessage(caught.getLocalizedMessage());
}
@Override
public void onSuccess(ScopeData scopeData) {
logger.log(Level.FINE, "ScopeData: " + scopeData);
ScopeDataEvent event = new ScopeDataEvent(scopeData);
eventBus.fireEvent(event);
}
});
}
} }

View File

@ -0,0 +1,51 @@
package org.gcube.portlets.user.accountingdashboard.client.application.event;
import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HasHandlers;
/**
*
* @author Giancarlo Panichi
*
*/
public class ScopeDataEvent extends GwtEvent<ScopeDataEvent.ScopeDataEventHandler> {
private ScopeData scopeData;
public interface ScopeDataEventHandler extends EventHandler {
void onData(ScopeDataEvent event);
}
public static final Type<ScopeDataEventHandler> TYPE = new Type<>();
public ScopeDataEvent(ScopeData scopeData) {
this.scopeData = scopeData;
}
public static void fire(HasHandlers source, ScopeDataEvent event) {
source.fireEvent(event);
}
@Override
public Type<ScopeDataEventHandler> getAssociatedType() {
return TYPE;
}
@Override
protected void dispatch(ScopeDataEventHandler handler) {
handler.onData(this);
}
public ScopeData getScopeData() {
return scopeData;
}
@Override
public String toString() {
return "ScopeDataEvent [scopeData=" + scopeData + "]";
}
}

View File

@ -1,8 +1,11 @@
package org.gcube.portlets.user.accountingdashboard.client.application.mainarea.filter; package org.gcube.portlets.user.accountingdashboard.client.application.mainarea.filter;
import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.gcube.portlets.user.accountingdashboard.client.application.controller.Controller; import org.gcube.portlets.user.accountingdashboard.client.application.controller.Controller;
import org.gcube.portlets.user.accountingdashboard.client.application.event.ScopeDataEvent;
import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.web.bindery.event.shared.EventBus; import com.google.web.bindery.event.shared.EventBus;
@ -15,23 +18,22 @@ import com.gwtplatform.mvp.client.View;
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
*/ */
public class FilterAreaPresenter public class FilterAreaPresenter extends PresenterWidget<FilterAreaPresenter.FilterAreaView>
extends PresenterWidget<FilterAreaPresenter.FilterAreaView> implements FilterAreaUiHandlers { implements FilterAreaUiHandlers {
private static Logger logger = Logger.getLogger(""); private static Logger logger = Logger.getLogger("");
interface FilterAreaView extends View, HasUiHandlers<FilterAreaPresenter> { interface FilterAreaView extends View, HasUiHandlers<FilterAreaPresenter> {
void displayScopeData(ScopeData scopeData);
} }
private EventBus eventBus; private EventBus eventBus;
private Controller controller; private Controller controller;
@Inject @Inject
FilterAreaPresenter(EventBus eventBus, FilterAreaView view, FilterAreaPresenter(EventBus eventBus, FilterAreaView view, Controller controller) {
Controller controller) {
super(eventBus, view); super(eventBus, view);
this.eventBus = eventBus; this.eventBus = eventBus;
this.controller = controller; this.controller = controller;
@ -47,11 +49,22 @@ public class FilterAreaPresenter
private void bindToEvent() { private void bindToEvent() {
controller.getEventBus().addHandler(ScopeDataEvent.TYPE, new ScopeDataEvent.ScopeDataEventHandler() {
@Override
public void onData(ScopeDataEvent event) {
logger.log(Level.FINE, "ScopeDataEvent received");
getView().displayScopeData(event.getScopeData());
}
});
} }
@Override @Override
protected void onBind() { protected void onBind() {
super.onBind(); super.onBind();
controller.getTree();
} }
} }

View File

@ -20,7 +20,6 @@ import com.google.gwt.i18n.client.LocaleInfo;
import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.cellview.client.CellTree; import com.google.gwt.user.cellview.client.CellTree;
import com.google.gwt.user.cellview.client.CellTree.Resources;
import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.view.client.ListDataProvider; import com.google.gwt.view.client.ListDataProvider;
@ -60,7 +59,8 @@ public class FilterAreaView extends ViewWithUiHandlers<FilterAreaPresenter>
@UiField(provided = true) @UiField(provided = true)
CellTree scopeTree; CellTree scopeTree;
private ListDataProvider<ScopeData> dataProvider;
@SuppressWarnings("unused")
private AppResources resources; private AppResources resources;
@Inject @Inject
@ -103,30 +103,24 @@ public class FilterAreaView extends ViewWithUiHandlers<FilterAreaPresenter>
monthEnd.addItem(months[i]); monthEnd.addItem(months[i]);
} }
ScopeData children1=new ScopeData("1","children1",null); dataProvider = new ListDataProvider<ScopeData>();
ScopeData children3=new ScopeData("3","children3",null);
ScopeData children4=new ScopeData("4","children4",null);
ArrayList<ScopeData> children2List=new ArrayList<>();
children2List.add(children3);
children2List.add(children4);
ScopeData children2=new ScopeData("2","children2",children2List);
ArrayList<ScopeData> rootList=new ArrayList<>();
rootList.add(children1);
rootList.add(children2);
ScopeData root=new ScopeData("0","root",rootList);
ArrayList<ScopeData> scopeDataList=new ArrayList<>();
scopeDataList.add(root);
ListDataProvider<ScopeData> dataProvider = new ListDataProvider<ScopeData>(scopeDataList);
ScopeTreeModel scopeTreeModel=new ScopeTreeModel(dataProvider); ScopeTreeModel scopeTreeModel=new ScopeTreeModel(dataProvider);
ScopeTreeResources scopeTreeResources = GWT.create(ScopeTreeResources.class); ScopeTreeResources scopeTreeResources = GWT.create(ScopeTreeResources.class);
scopeTree=new CellTree(scopeTreeModel, null,scopeTreeResources); scopeTree=new CellTree(scopeTreeModel, null,scopeTreeResources);
} }
@Override
public void displayScopeData(ScopeData scopeData) {
ArrayList<ScopeData> scopeDataList=new ArrayList<>();
scopeDataList.add(scopeData);
dataProvider.setList(scopeDataList);
dataProvider.refresh();
dataProvider.flush();
}
} }

View File

@ -10,6 +10,12 @@ import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.view.client.ListDataProvider; import com.google.gwt.view.client.ListDataProvider;
import com.google.gwt.view.client.TreeViewModel; import com.google.gwt.view.client.TreeViewModel;
/**
*
* @author Giancarlo Panichi
*
*/
public class ScopeTreeModel implements TreeViewModel { public class ScopeTreeModel implements TreeViewModel {
private ListDataProvider<ScopeData> dataProvider; private ListDataProvider<ScopeData> dataProvider;
@ -23,6 +29,7 @@ public class ScopeTreeModel implements TreeViewModel {
public ScopeTreeModel(ListDataProvider<ScopeData> dataProvider) { public ScopeTreeModel(ListDataProvider<ScopeData> dataProvider) {
this.dataProvider=dataProvider; this.dataProvider=dataProvider;
} }
/** /**

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.user.accountingdashboard.client.rpc; package org.gcube.portlets.user.accountingdashboard.client.rpc;
import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData;
import org.gcube.portlets.user.accountingdashboard.shared.exception.ServiceException; import org.gcube.portlets.user.accountingdashboard.shared.exception.ServiceException;
import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo; import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo;
@ -23,6 +24,8 @@ public interface AccountingDashboardService extends RemoteService {
*/ */
public UserInfo hello() throws ServiceException; public UserInfo hello() throws ServiceException;
public ScopeData getScopeData() throws ServiceException;
} }

View File

@ -3,6 +3,7 @@
*/ */
package org.gcube.portlets.user.accountingdashboard.client.rpc; package org.gcube.portlets.user.accountingdashboard.client.rpc;
import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData;
import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo; import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
@ -21,6 +22,8 @@ public interface AccountingDashboardServiceAsync {
void hello(AsyncCallback<UserInfo> callback); void hello(AsyncCallback<UserInfo> callback);
void getScopeData(AsyncCallback<ScopeData> callback);
} }

View File

@ -3,7 +3,10 @@ package org.gcube.portlets.user.accountingdashboard.server;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import org.gcube.portlets.user.accountingdashboard.client.rpc.AccountingDashboardService; import org.gcube.portlets.user.accountingdashboard.client.rpc.AccountingDashboardService;
import org.gcube.portlets.user.accountingdashboard.server.accounting.AccountingService;
import org.gcube.portlets.user.accountingdashboard.server.accounting.AccountingServiceType;
import org.gcube.portlets.user.accountingdashboard.server.util.ServiceCredentials; import org.gcube.portlets.user.accountingdashboard.server.util.ServiceCredentials;
import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData;
import org.gcube.portlets.user.accountingdashboard.shared.exception.ServiceException; import org.gcube.portlets.user.accountingdashboard.shared.exception.ServiceException;
import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo; import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -52,11 +55,29 @@ public class AccountingDashboardServiceImpl extends RemoteServiceServlet impleme
throw e; throw e;
} catch (Throwable e) { } catch (Throwable e) {
logger.error("Hello(): " + e.getLocalizedMessage(), e); logger.error("Hello(): " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e); throw new ServiceException("Error retrivieving user credentials: " + e.getLocalizedMessage(), e);
} }
} }
@Override
public ScopeData getScopeData() throws ServiceException {
try {
logger.debug("AccountingDashboardServiceImpl getScopeData()");
@SuppressWarnings("unused")
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
AccountingService as = new AccountingService(AccountingServiceType.PortalContex);
ScopeData scopeData = as.getTree();
return scopeData;
} catch (ServiceException e) {
logger.error(e.getLocalizedMessage(), e);
throw e;
} catch (Throwable e) {
logger.error("GetScopeData(): " + e.getLocalizedMessage(), e);
throw new ServiceException("Error retrieving scope info: "+e.getLocalizedMessage(), e);
}
}
} }

View File

@ -1,7 +1,11 @@
package org.gcube.portlets.user.accountingdashboard.server.accounting; package org.gcube.portlets.user.accountingdashboard.server.accounting;
import java.util.ArrayList;
import org.gcube.data.access.accounting.summary.access.AccountingDao; import org.gcube.data.access.accounting.summary.access.AccountingDao;
import org.gcube.data.access.accounting.summary.access.model.ScopeDescriptor; import org.gcube.data.access.accounting.summary.access.model.ScopeDescriptor;
import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData;
import org.gcube.portlets.user.accountingdashboard.shared.exception.ServiceException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -16,18 +20,63 @@ public class AccountingService {
private AccountingDao dao; private AccountingDao dao;
public AccountingService() { public AccountingService(AccountingServiceType accountingServiceType) throws ServiceException {
dao = AccountingDao.get(new PortalContextTreeProvider()); try {
if (accountingServiceType == null) {
logger.error("Invalid AccountingServiceType requested: null");
} }
public void getTree() { switch (accountingServiceType) {
case CurrentScope:
logger.debug("AccountingService: CurrentScope");
dao = AccountingDao.get();
break;
case PortalContex:
logger.debug("AccountingService: PortalContext");
dao = AccountingDao.get(new PortalContextTreeProvider());
break;
default:
logger.debug("AccountingService: CurrentScope");
dao = AccountingDao.get();
break;
}
} catch (Throwable e) {
logger.error("Error retrieving Tree: " + e.getLocalizedMessage(), e);
throw new ServiceException("Error retrieving Tree: " + e.getLocalizedMessage(), e);
}
}
public ScopeData getTree() throws ServiceException {
try { try {
logger.debug("AccountingService GetTree()"); logger.debug("AccountingService GetTree()");
ScopeDescriptor scopeDescriptor = dao.getTree(null); ScopeDescriptor scopeDescriptor = dao.getTree(null);
logger.debug("ScopeDescriptor: " + scopeDescriptor); logger.debug("ScopeDescriptor: " + scopeDescriptor);
ScopeData scopeData = getScopeData(scopeDescriptor);
return scopeData;
} catch (Exception e) { } catch (Throwable e) {
logger.error("Error retrieving Tree: " + e.getLocalizedMessage(), e); logger.error("Error retrieving Tree: " + e.getLocalizedMessage(), e);
throw new ServiceException("Error retrieving Tree: " + e.getLocalizedMessage(), e);
} }
} }
private ScopeData getScopeData(ScopeDescriptor scopeDescriptor) {
ScopeData scopeData = null;
if (scopeDescriptor != null) {
if (scopeDescriptor.hasChildren()) {
ArrayList<ScopeData> childs = new ArrayList<>();
for (ScopeDescriptor sd : scopeDescriptor.getChildren()) {
childs.add(getScopeData(sd));
}
scopeData = new ScopeData(scopeDescriptor.getId(), scopeDescriptor.getName(), childs);
} else {
scopeData = new ScopeData(scopeDescriptor.getId(), scopeDescriptor.getName(), null);
}
}
return scopeData;
}
} }

View File

@ -0,0 +1,12 @@
package org.gcube.portlets.user.accountingdashboard.server.accounting;
/**
*
* @author Giancarlo Panichi
*
*/
public enum AccountingServiceType {
PortalContex, CurrentScope;
}

View File

@ -1,7 +1,5 @@
package org.gcube.portlets.user.accountingdashboard.server.accounting; package org.gcube.portlets.user.accountingdashboard.server.accounting;
import javax.servlet.http.HttpServletRequest;
import org.gcube.data.access.accounting.summary.access.impl.ContextTreeProvider; import org.gcube.data.access.accounting.summary.access.impl.ContextTreeProvider;
import org.gcube.data.access.accounting.summary.access.model.ScopeDescriptor; import org.gcube.data.access.accounting.summary.access.model.ScopeDescriptor;
import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.GroupManager;
@ -15,20 +13,18 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
public class PortalContextTreeProvider implements ContextTreeProvider { public class PortalContextTreeProvider implements ContextTreeProvider {
private static GroupManager groupsManager; private static GroupManager groupsManager;
static { static {
groupsManager = new LiferayGroupManager(); groupsManager = new LiferayGroupManager();
} }
@Override @Override
public ScopeDescriptor getTree(Object context) throws Exception { public ScopeDescriptor getTree(Object context) throws Exception {
// if(context == null) throw new Exception("Unable to get tree, Request is null."); // if(context == null) throw new Exception("Unable to get tree, Request
// if(!(context instanceof HttpServletRequest)) throw new Exception("Invalid request object : "+context); // is null.");
// if(!(context instanceof HttpServletRequest)) throw new
// Exception("Invalid request object : "+context);
// HttpServletRequest request=(HttpServletRequest) context; // HttpServletRequest request=(HttpServletRequest) context;
// PARSE TREE // PARSE TREE
@ -38,11 +34,15 @@ public class PortalContextTreeProvider implements ContextTreeProvider {
return asScopeDescriptor(rootGroupVO); return asScopeDescriptor(rootGroupVO);
} }
private ScopeDescriptor asScopeDescriptor(GCubeGroup group) throws UserManagementSystemException, GroupRetrievalFault { private ScopeDescriptor asScopeDescriptor(GCubeGroup group)
ScopeDescriptor toReturn=new ScopeDescriptor(group.getGroupName(),groupsManager.getInfrastructureScope(group.getGroupId())); throws UserManagementSystemException, GroupRetrievalFault {
ScopeDescriptor toReturn = new ScopeDescriptor(group.getGroupName(),
groupsManager.getInfrastructureScope(group.getGroupId()));
if (group.getChildren() != null && !group.getChildren().isEmpty()) {
for (GCubeGroup child : group.getChildren()) { for (GCubeGroup child : group.getChildren()) {
toReturn.getChildren().add(asScopeDescriptor(child)); toReturn.getChildren().add(asScopeDescriptor(child));
} }
}
return toReturn; return toReturn;
} }
@ -50,25 +50,30 @@ public class PortalContextTreeProvider implements ContextTreeProvider {
// //
// /** // /**
// * // *
// * @return the Virtual groups with their VREs in the order estabilished in the LR Control Panel // * @return the Virtual groups with their VREs in the order estabilished in
// the LR Control Panel
// * @throws SystemException // * @throws SystemException
// * @throws PortalException // * @throws PortalException
// */ // */
// private LinkedHashMap<VRECategory, ArrayList<VRE>> getPortalSitesMappedToVRE(HttpServletRequest request) throws Exception { // private LinkedHashMap<VRECategory, ArrayList<VRE>>
// getPortalSitesMappedToVRE(HttpServletRequest request) throws Exception {
// //
// Group site=getSiteFromServletRequest(request); // Group site=getSiteFromServletRequest(request);
// //
// ScopeDescriptor root=new ScopeDescriptor(site.getDescriptiveName(),site.getUuid()); // ScopeDescriptor root=new
// ScopeDescriptor(site.getDescriptiveName(),site.getUuid());
// //
// LinkedList<ScopeDescriptor> groups=new LinkedList<>(); // LinkedList<ScopeDescriptor> groups=new LinkedList<>();
// //
// long currentSiteGroupId = site.getGroupId(); // long currentSiteGroupId = site.getGroupId();
// //
//// List<VirtualGroup> currentSiteVGroups = groupsManager.getVirtualGroups(currentSiteGroupId); //// List<VirtualGroup> currentSiteVGroups =
// groupsManager.getVirtualGroups(currentSiteGroupId);
//// ////
//// for (VirtualGroup vg : currentSiteVGroups) { //// for (VirtualGroup vg : currentSiteVGroups) {
//// ScopeDescriptor groupDescriptor=new ScopeDescriptor(vg.getName(),); //// ScopeDescriptor groupDescriptor=new ScopeDescriptor(vg.getName(),);
//// VRECategory cat = new VRECategory(1L, vg.getName(), vg.getDescription()); //// VRECategory cat = new VRECategory(1L, vg.getName(),
// vg.getDescription());
//// toReturn.put(cat, toCreate); //// toReturn.put(cat, toCreate);
//// } //// }
// //
@ -77,7 +82,9 @@ public class PortalContextTreeProvider implements ContextTreeProvider {
//// try { //// try {
//// log.debug("root: " + rootGroupVO.getGroupName() ); //// log.debug("root: " + rootGroupVO.getGroupName() );
//// } catch (NullPointerException e) { //// } catch (NullPointerException e) {
//// log.error("Cannot find root organziation, please check gcube-data.properties file in $CATALINA_HOME/conf folder, unless your installing the Bundle"); //// log.error("Cannot find root organziation, please check
// gcube-data.properties file in $CATALINA_HOME/conf folder, unless your
// installing the Bundle");
//// return toReturn; //// return toReturn;
//// } //// }
//// PortalContext pContext = PortalContext.getConfiguration(); //// PortalContext pContext = PortalContext.getConfiguration();
@ -95,7 +102,8 @@ public class PortalContextTreeProvider implements ContextTreeProvider {
// String vreName = vreSite.getGroupName(); // String vreName = vreSite.getGroupName();
// String vreDescription = vreSite.getDescription(); // String vreDescription = vreSite.getDescription();
// //
// String groupName = groupsManager.getInfrastructureScope(vreSite.getGroupId()); // String groupName =
// groupsManager.getInfrastructureScope(vreSite.getGroupId());
// //
// List<VirtualGroup> vreGroups = groupsManager.getVirtualGroups(vreID); // List<VirtualGroup> vreGroups = groupsManager.getVirtualGroups(vreID);
// for (VirtualGroup vreGroup : vreGroups) { // for (VirtualGroup vreGroup : vreGroups) {
@ -103,8 +111,10 @@ public class PortalContextTreeProvider implements ContextTreeProvider {
// if (vre.getName().compareTo(vreGroup.getName())==0) { // if (vre.getName().compareTo(vreGroup.getName())==0) {
// ArrayList<VRE> toUpdate = toReturn.get(vre); // ArrayList<VRE> toUpdate = toReturn.get(vre);
// UserBelonging belongs = UserBelonging.NOT_BELONGING; // UserBelonging belongs = UserBelonging.NOT_BELONGING;
// VRE toAdd = new VRE(vreID,vreName, vreDescription, vreLogoURL, groupName, friendlyURL, belongs, getVREMembershipType(vreSite.getMembershipType())); // VRE toAdd = new VRE(vreID,vreName, vreDescription, vreLogoURL, groupName,
//// if (GroupLocalServiceUtil.getGroup(vreID).getPublicLayoutsPageCount() > 0) { // friendlyURL, belongs, getVREMembershipType(vreSite.getMembershipType()));
//// if (GroupLocalServiceUtil.getGroup(vreID).getPublicLayoutsPageCount() >
// 0) {
//// String publicURL = PREFIX_PUBLIC_URL+vreSite.getFriendlyURL(); //// String publicURL = PREFIX_PUBLIC_URL+vreSite.getFriendlyURL();
//// toAdd.setPublicURL(publicURL); //// toAdd.setPublicURL(publicURL);
//// } //// }
@ -135,11 +145,13 @@ public class PortalContextTreeProvider implements ContextTreeProvider {
// //
// //
// //
// private Group getSiteFromServletRequest(final HttpServletRequest request) throws PortalException, SystemException { // private Group getSiteFromServletRequest(final HttpServletRequest request)
// throws PortalException, SystemException {
// String serverName = request.getServerName(); // String serverName = request.getServerName();
// log.debug("currentHost is " + serverName); // log.debug("currentHost is " + serverName);
// Group site = null; // Group site = null;
// List<VirtualHost> vHosts = VirtualHostLocalServiceUtil.getVirtualHosts(0, VirtualHostLocalServiceUtil.getVirtualHostsCount()); // List<VirtualHost> vHosts = VirtualHostLocalServiceUtil.getVirtualHosts(0,
// VirtualHostLocalServiceUtil.getVirtualHostsCount());
// for (VirtualHost virtualHost : vHosts) { // for (VirtualHost virtualHost : vHosts) {
// log.debug("Found " + virtualHost.getHostname()); // log.debug("Found " + virtualHost.getHostname());
// if (virtualHost.getHostname().compareTo("localhost") != 0 && // if (virtualHost.getHostname().compareTo("localhost") != 0 &&

View File

@ -1,8 +1,11 @@
package org.gcube.portlets.user.accountingdashboard; package org.gcube.portlets.user.accountingdashboard;
import java.util.ArrayList;
import org.gcube.portlets.user.accountingdashboard.server.accounting.AccountingService; import org.gcube.portlets.user.accountingdashboard.server.accounting.AccountingService;
import org.gcube.portlets.user.accountingdashboard.server.accounting.AccountingServiceType;
import org.gcube.portlets.user.accountingdashboard.shared.Constants; import org.gcube.portlets.user.accountingdashboard.shared.Constants;
import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -24,7 +27,7 @@ public class AccountingServiceTest extends TestCase {
try { try {
AuthTest.setToken(); AuthTest.setToken();
AccountingService accountingService=new AccountingService(); AccountingService accountingService = new AccountingService(AccountingServiceType.CurrentScope);
accountingService.getTree(); accountingService.getTree();
assertTrue("Success", true); assertTrue("Success", true);
@ -39,5 +42,42 @@ public class AccountingServiceTest extends TestCase {
} }
} }
@Test
public void testData() {
if (Constants.TEST_ENABLE) {
try {
ScopeData children1 = new ScopeData("1", "children1", null);
ScopeData children3 = new ScopeData("3", "children3", null);
ScopeData children4 = new ScopeData("4", "children4", null);
ArrayList<ScopeData> children2List = new ArrayList<>();
children2List.add(children3);
children2List.add(children4);
ScopeData children2 = new ScopeData("2", "children2", children2List);
ArrayList<ScopeData> rootList = new ArrayList<>();
rootList.add(children1);
rootList.add(children2);
ScopeData root = new ScopeData("0", "root", rootList);
ArrayList<ScopeData> scopeDataList = new ArrayList<>();
scopeDataList.add(root);
logger.debug("Data example: "+scopeDataList);
assertTrue("Success", true);
} catch (Throwable e) {
logger.error(e.getLocalizedMessage(), e);
fail("Error:" + e.getLocalizedMessage());
}
} else {
assertTrue("Success", true);
}
}
} }