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.monitor.MonitorPresenter;
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.shared.data.ScopeData;
import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo;
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;
import java.util.logging.Level;
import java.util.logging.Logger;
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.web.bindery.event.shared.EventBus;
@ -15,23 +18,22 @@ import com.gwtplatform.mvp.client.View;
* @author Giancarlo Panichi
*
*/
public class FilterAreaPresenter
extends PresenterWidget<FilterAreaPresenter.FilterAreaView> implements FilterAreaUiHandlers {
public class FilterAreaPresenter extends PresenterWidget<FilterAreaPresenter.FilterAreaView>
implements FilterAreaUiHandlers {
private static Logger logger = Logger.getLogger("");
interface FilterAreaView extends View, HasUiHandlers<FilterAreaPresenter> {
void displayScopeData(ScopeData scopeData);
}
private EventBus eventBus;
private Controller controller;
@Inject
FilterAreaPresenter(EventBus eventBus, FilterAreaView view,
Controller controller) {
FilterAreaPresenter(EventBus eventBus, FilterAreaView view, Controller controller) {
super(eventBus, view);
this.eventBus = eventBus;
this.controller = controller;
@ -47,11 +49,22 @@ public class FilterAreaPresenter
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
protected void 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.UiField;
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.Widget;
import com.google.gwt.view.client.ListDataProvider;
@ -60,7 +59,8 @@ public class FilterAreaView extends ViewWithUiHandlers<FilterAreaPresenter>
@UiField(provided = true)
CellTree scopeTree;
private ListDataProvider<ScopeData> dataProvider;
@SuppressWarnings("unused")
private AppResources resources;
@Inject
@ -103,30 +103,24 @@ public class FilterAreaView extends ViewWithUiHandlers<FilterAreaPresenter>
monthEnd.addItem(months[i]);
}
ScopeData children1=new ScopeData("1","children1",null);
ScopeData children3=new ScopeData("3","children3",null);
ScopeData children4=new ScopeData("4","children4",null);
dataProvider = new ListDataProvider<ScopeData>();
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);
ScopeTreeResources scopeTreeResources = GWT.create(ScopeTreeResources.class);
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.TreeViewModel;
/**
*
* @author Giancarlo Panichi
*
*/
public class ScopeTreeModel implements TreeViewModel {
private ListDataProvider<ScopeData> dataProvider;
@ -23,6 +29,7 @@ public class ScopeTreeModel implements TreeViewModel {
public ScopeTreeModel(ListDataProvider<ScopeData> dataProvider) {
this.dataProvider=dataProvider;
}
/**

View File

@ -1,5 +1,6 @@
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.session.UserInfo;
@ -23,6 +24,8 @@ public interface AccountingDashboardService extends RemoteService {
*/
public UserInfo hello() throws ServiceException;
public ScopeData getScopeData() throws ServiceException;
}

View File

@ -3,6 +3,7 @@
*/
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 com.google.gwt.core.client.GWT;
@ -20,6 +21,8 @@ public interface AccountingDashboardServiceAsync {
.create(AccountingDashboardService.class);
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 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.shared.data.ScopeData;
import org.gcube.portlets.user.accountingdashboard.shared.exception.ServiceException;
import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo;
import org.slf4j.Logger;
@ -52,11 +55,29 @@ public class AccountingDashboardServiceImpl extends RemoteServiceServlet impleme
throw e;
} catch (Throwable 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;
import java.util.ArrayList;
import org.gcube.data.access.accounting.summary.access.AccountingDao;
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.LoggerFactory;
@ -11,23 +15,68 @@ import org.slf4j.LoggerFactory;
*
*/
public class AccountingService {
private static Logger logger = LoggerFactory.getLogger(AccountingService.class);
private AccountingDao dao;
public AccountingService() {
dao = AccountingDao.get(new PortalContextTreeProvider());
public AccountingService(AccountingServiceType accountingServiceType) throws ServiceException {
try {
if (accountingServiceType == null) {
logger.error("Invalid AccountingServiceType requested: null");
}
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 void getTree() {
public ScopeData getTree() throws ServiceException {
try {
logger.debug("AccountingService GetTree()");
ScopeDescriptor scopeDescriptor = dao.getTree(null);
logger.debug("ScopeDescriptor: "+scopeDescriptor);
} catch (Exception e) {
logger.error("Error retrieving Tree: "+e.getLocalizedMessage(),e);
logger.debug("ScopeDescriptor: " + scopeDescriptor);
ScopeData scopeData = getScopeData(scopeDescriptor);
return scopeData;
} catch (Throwable 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;
import javax.servlet.http.HttpServletRequest;
import org.gcube.data.access.accounting.summary.access.impl.ContextTreeProvider;
import org.gcube.data.access.accounting.summary.access.model.ScopeDescriptor;
import org.gcube.vomanagement.usermanagement.GroupManager;
@ -15,142 +13,156 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class PortalContextTreeProvider implements ContextTreeProvider {
private static GroupManager groupsManager;
static {
groupsManager = new LiferayGroupManager();
}
@Override
public ScopeDescriptor getTree(Object context) throws Exception {
// if(context == null) throw new Exception("Unable to get tree, Request is null.");
// if(!(context instanceof HttpServletRequest)) throw new Exception("Invalid request object : "+context);
// HttpServletRequest request=(HttpServletRequest) context;
// if(context == null) throw new Exception("Unable to get tree, Request
// is null.");
// if(!(context instanceof HttpServletRequest)) throw new
// Exception("Invalid request object : "+context);
// HttpServletRequest request=(HttpServletRequest) context;
// PARSE TREE
GCubeGroup rootGroupVO = groupsManager.getRootVO();
return asScopeDescriptor(rootGroupVO);
}
private ScopeDescriptor asScopeDescriptor(GCubeGroup group) throws UserManagementSystemException, GroupRetrievalFault {
ScopeDescriptor toReturn=new ScopeDescriptor(group.getGroupName(),groupsManager.getInfrastructureScope(group.getGroupId()));
for(GCubeGroup child:group.getChildren()) {
toReturn.getChildren().add(asScopeDescriptor(child));
private ScopeDescriptor asScopeDescriptor(GCubeGroup group)
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()) {
toReturn.getChildren().add(asScopeDescriptor(child));
}
}
return toReturn;
}
//
//
// /**
// *
// * @return the Virtual groups with their VREs in the order estabilished in the LR Control Panel
// * @throws SystemException
// * @throws PortalException
// */
// private LinkedHashMap<VRECategory, ArrayList<VRE>> getPortalSitesMappedToVRE(HttpServletRequest request) throws Exception {
//
// Group site=getSiteFromServletRequest(request);
//
// ScopeDescriptor root=new ScopeDescriptor(site.getDescriptiveName(),site.getUuid());
//
// LinkedList<ScopeDescriptor> groups=new LinkedList<>();
//
// long currentSiteGroupId = site.getGroupId();
//
//// List<VirtualGroup> currentSiteVGroups = groupsManager.getVirtualGroups(currentSiteGroupId);
////
//// for (VirtualGroup vg : currentSiteVGroups) {
//// ScopeDescriptor groupDescriptor=new ScopeDescriptor(vg.getName(),);
//// VRECategory cat = new VRECategory(1L, vg.getName(), vg.getDescription());
//// toReturn.put(cat, toCreate);
//// }
//
// GCubeGroup rootGroupVO = groupsManager.getRootVO();
////
//// try {
//// log.debug("root: " + rootGroupVO.getGroupName() );
//// } 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");
//// return toReturn;
//// }
//// PortalContext pContext = PortalContext.getConfiguration();
////
//// List<GCubeGroup> currUserGroups = new ArrayList<GCubeGroup>();
//// GCubeUser currUser = pContext.getCurrentUser(request);
//// if (currUser != null) {
//// currUserGroups = groupsManager.listGroupsByUser(currUser.getUserId());
//// }
//
// //for each root sub organizations (VO)
// for (GCubeGroup vOrg : rootGroupVO.getChildren()) {
// for (GCubeGroup vreSite : vOrg.getChildren()) {
// long vreID = vreSite.getGroupId();
// String vreName = vreSite.getGroupName();
// String vreDescription = vreSite.getDescription();
//
// String groupName = groupsManager.getInfrastructureScope(vreSite.getGroupId());
//
// List<VirtualGroup> vreGroups = groupsManager.getVirtualGroups(vreID);
// for (VirtualGroup vreGroup : vreGroups) {
// for (VRECategory vre : toReturn.keySet()) {
// if (vre.getName().compareTo(vreGroup.getName())==0) {
// ArrayList<VRE> toUpdate = toReturn.get(vre);
// UserBelonging belongs = UserBelonging.NOT_BELONGING;
// VRE toAdd = new VRE(vreID,vreName, vreDescription, vreLogoURL, groupName, friendlyURL, belongs, getVREMembershipType(vreSite.getMembershipType()));
//// if (GroupLocalServiceUtil.getGroup(vreID).getPublicLayoutsPageCount() > 0) {
//// String publicURL = PREFIX_PUBLIC_URL+vreSite.getFriendlyURL();
//// toAdd.setPublicURL(publicURL);
//// }
//// if (currUser != null) {
//// //check if the user belongs to it
//// if (currUserGroups.contains(vreSite)) {
//// toAdd.setUserBelonging(UserBelonging.BELONGING);
//// }
//// else if (checkPending(currUser.getUsername(), vreSite.getGroupId()))
//// toAdd.setUserBelonging(UserBelonging.PENDING);
//// }
// toUpdate.add(toAdd);
// }
// }
// }
// }
// }
//
// //sort the vres in the groups
// for (VRECategory cat : toReturn.keySet()) {
// ArrayList<VRE> toSort = toReturn.get(cat);
// Collections.sort(toSort);
// }
// return toReturn;
// }
//
//
//
//
//
// private Group getSiteFromServletRequest(final HttpServletRequest request) throws PortalException, SystemException {
// String serverName = request.getServerName();
// log.debug("currentHost is " + serverName);
// Group site = null;
// List<VirtualHost> vHosts = VirtualHostLocalServiceUtil.getVirtualHosts(0, VirtualHostLocalServiceUtil.getVirtualHostsCount());
// for (VirtualHost virtualHost : vHosts) {
// log.debug("Found " + virtualHost.getHostname());
// if (virtualHost.getHostname().compareTo("localhost") != 0 &&
// virtualHost.getLayoutSetId() != 0 &&
// virtualHost.getHostname().compareTo(serverName) == 0) {
// long layoutSetId = virtualHost.getLayoutSetId();
// site = LayoutSetLocalServiceUtil.getLayoutSet(layoutSetId).getGroup();
// log.debug("Found match! Your site is " + site.getName());
// return site;
// }
// }
// return null;
// }
//
//
// /**
// *
// * @return the Virtual groups with their VREs in the order estabilished in
// the LR Control Panel
// * @throws SystemException
// * @throws PortalException
// */
// private LinkedHashMap<VRECategory, ArrayList<VRE>>
// getPortalSitesMappedToVRE(HttpServletRequest request) throws Exception {
//
// Group site=getSiteFromServletRequest(request);
//
// ScopeDescriptor root=new
// ScopeDescriptor(site.getDescriptiveName(),site.getUuid());
//
// LinkedList<ScopeDescriptor> groups=new LinkedList<>();
//
// long currentSiteGroupId = site.getGroupId();
//
//// List<VirtualGroup> currentSiteVGroups =
// groupsManager.getVirtualGroups(currentSiteGroupId);
////
//// for (VirtualGroup vg : currentSiteVGroups) {
//// ScopeDescriptor groupDescriptor=new ScopeDescriptor(vg.getName(),);
//// VRECategory cat = new VRECategory(1L, vg.getName(),
// vg.getDescription());
//// toReturn.put(cat, toCreate);
//// }
//
// GCubeGroup rootGroupVO = groupsManager.getRootVO();
////
//// try {
//// log.debug("root: " + rootGroupVO.getGroupName() );
//// } 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");
//// return toReturn;
//// }
//// PortalContext pContext = PortalContext.getConfiguration();
////
//// List<GCubeGroup> currUserGroups = new ArrayList<GCubeGroup>();
//// GCubeUser currUser = pContext.getCurrentUser(request);
//// if (currUser != null) {
//// currUserGroups = groupsManager.listGroupsByUser(currUser.getUserId());
//// }
//
// //for each root sub organizations (VO)
// for (GCubeGroup vOrg : rootGroupVO.getChildren()) {
// for (GCubeGroup vreSite : vOrg.getChildren()) {
// long vreID = vreSite.getGroupId();
// String vreName = vreSite.getGroupName();
// String vreDescription = vreSite.getDescription();
//
// String groupName =
// groupsManager.getInfrastructureScope(vreSite.getGroupId());
//
// List<VirtualGroup> vreGroups = groupsManager.getVirtualGroups(vreID);
// for (VirtualGroup vreGroup : vreGroups) {
// for (VRECategory vre : toReturn.keySet()) {
// if (vre.getName().compareTo(vreGroup.getName())==0) {
// ArrayList<VRE> toUpdate = toReturn.get(vre);
// UserBelonging belongs = UserBelonging.NOT_BELONGING;
// VRE toAdd = new VRE(vreID,vreName, vreDescription, vreLogoURL, groupName,
// friendlyURL, belongs, getVREMembershipType(vreSite.getMembershipType()));
//// if (GroupLocalServiceUtil.getGroup(vreID).getPublicLayoutsPageCount() >
// 0) {
//// String publicURL = PREFIX_PUBLIC_URL+vreSite.getFriendlyURL();
//// toAdd.setPublicURL(publicURL);
//// }
//// if (currUser != null) {
//// //check if the user belongs to it
//// if (currUserGroups.contains(vreSite)) {
//// toAdd.setUserBelonging(UserBelonging.BELONGING);
//// }
//// else if (checkPending(currUser.getUsername(), vreSite.getGroupId()))
//// toAdd.setUserBelonging(UserBelonging.PENDING);
//// }
// toUpdate.add(toAdd);
// }
// }
// }
// }
// }
//
// //sort the vres in the groups
// for (VRECategory cat : toReturn.keySet()) {
// ArrayList<VRE> toSort = toReturn.get(cat);
// Collections.sort(toSort);
// }
// return toReturn;
// }
//
//
//
//
//
// private Group getSiteFromServletRequest(final HttpServletRequest request)
// throws PortalException, SystemException {
// String serverName = request.getServerName();
// log.debug("currentHost is " + serverName);
// Group site = null;
// List<VirtualHost> vHosts = VirtualHostLocalServiceUtil.getVirtualHosts(0,
// VirtualHostLocalServiceUtil.getVirtualHostsCount());
// for (VirtualHost virtualHost : vHosts) {
// log.debug("Found " + virtualHost.getHostname());
// if (virtualHost.getHostname().compareTo("localhost") != 0 &&
// virtualHost.getLayoutSetId() != 0 &&
// virtualHost.getHostname().compareTo(serverName) == 0) {
// long layoutSetId = virtualHost.getLayoutSetId();
// site = LayoutSetLocalServiceUtil.getLayoutSet(layoutSetId).getGroup();
// log.debug("Found match! Your site is " + site.getName());
// return site;
// }
// }
// return null;
// }
}

View File

@ -1,8 +1,11 @@
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.AccountingServiceType;
import org.gcube.portlets.user.accountingdashboard.shared.Constants;
import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -24,7 +27,7 @@ public class AccountingServiceTest extends TestCase {
try {
AuthTest.setToken();
AccountingService accountingService=new AccountingService();
AccountingService accountingService = new AccountingService(AccountingServiceType.CurrentScope);
accountingService.getTree();
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);
}
}
}