Commit ab1c0123 authored by Gianluca Filippone's avatar Gianluca Filippone
Browse files

Added list of services in choreography detail page

parent 7c223b8c
......@@ -21,13 +21,13 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.syncope.client.console.BookmarkablePageLinkBuilder;
import org.apache.syncope.client.console.panels.ChoreographyOverviewPanel;
import org.apache.syncope.client.console.panels.ChoreographyServiceDirectoryPanel;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.syncope.client.console.panels.InstancesOverviewPanel;
import org.apache.syncope.client.console.rest.ChoreographyRestClient;
import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;
import org.apache.wicket.extensions.markup.html.tabs.ITab;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.EmptyPanel;
import org.apache.wicket.model.ResourceModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
......@@ -37,6 +37,8 @@ public class ChoreographyDetailPage extends BaseExtPage {
public static final String PREF_INSTANCE_PAGINATOR_ROWS = "instances.paginator.rows";
public static final String PREF_SERVICE_PAGINATOR_ROWS = "services.paginator.rows";
private final ChoreographyRestClient restClient;
private final String choreographyId;
......@@ -89,7 +91,7 @@ public class ChoreographyDetailPage extends BaseExtPage {
tabs.add(new AbstractTab(new ResourceModel("services")) {
@Override
public WebMarkupContainer getPanel(final String panelId) {
return new EmptyPanel(panelId);
return new ChoreographyServiceDirectoryPanel(panelId, getPageReference(), choreographyId);
}
});
......
......@@ -30,7 +30,7 @@ import org.apache.syncope.client.console.BookmarkablePageLinkBuilder;
import org.apache.syncope.client.console.panels.CDDirectoryPanel;
import org.apache.syncope.client.console.panels.ChartsLegendPanel;
import org.apache.syncope.client.console.panels.ChoreographyActionsPanel;
import org.apache.syncope.client.console.panels.ServiceDirectoryPanel;
import org.apache.syncope.client.console.panels.InstanceServiceDirectoryPanel;
import org.apache.syncope.client.console.rest.ChoreographyRestClient;
import org.apache.syncope.client.console.widget.StatsWidget;
import org.apache.syncope.client.console.widgets.LabeledBarDataSet;
......@@ -282,7 +282,7 @@ public class InstanceStatsPage extends BaseExtPage {
@Override
public Panel getPanel(final String panelId) {
return new ServiceDirectoryPanel(panelId, getPageReference(), instanceId);
return new InstanceServiceDirectoryPanel(panelId, getPageReference(), instanceId);
}
});
......
/*
* Copyright 2016 The CHOReVOLUTION project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.syncope.client.console.panels;
import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
import eu.chorevolution.idm.common.to.ServiceTO;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import org.apache.syncope.client.console.commons.DirectoryDataProvider;
import org.apache.syncope.client.console.pages.ChoreographyDetailPage;
import org.apache.syncope.client.console.panels.ChoreographyServiceDirectoryPanel.ServiceProvider;
import org.apache.syncope.client.console.rest.ChoreographyRestClient;
import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
import org.apache.syncope.client.console.wizards.WizardMgtPanel;
import org.apache.wicket.PageReference;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.ResourceModel;
public class ChoreographyServiceDirectoryPanel extends DirectoryPanel<
ServiceTO, ServiceTO, ServiceProvider, ChoreographyRestClient> {
private static final long serialVersionUID = 3727444742501082182L;
private String choreographyId;
public ChoreographyServiceDirectoryPanel(final String id,
final PageReference pageRef,
final String choreographyId) {
super(id, new DirectoryPanel.Builder<ServiceTO, ServiceTO, ChoreographyRestClient>(
new ChoreographyRestClient(), pageRef) {
private static final long serialVersionUID = 8769126634538601689L;
@Override
protected WizardMgtPanel<ServiceTO> newInstance(final String id, final boolean wizardInModal) {
return new ChoreographyServiceDirectoryPanel(id, this);
}
}.disableCheckBoxes());
this.choreographyId = choreographyId;
setFooterVisibility(true);
modal.addSubmitButton();
modal.size(Modal.Size.Large);
initResultTable();
}
private ChoreographyServiceDirectoryPanel(
final String id,
final DirectoryPanel.Builder<ServiceTO, ServiceTO, ChoreographyRestClient> builder) {
super(id, builder);
}
@Override
protected ServiceProvider dataProvider() {
return new ServiceProvider(rows);
}
@Override
protected String paginatorRowsKey() {
return ChoreographyDetailPage.PREF_SERVICE_PAGINATOR_ROWS;
}
@Override
protected Collection<ActionLink.ActionType> getBulkActions() {
return Collections.<ActionLink.ActionType>emptyList();
}
@Override
protected List<IColumn<ServiceTO, String>> getColumns() {
final List<IColumn<ServiceTO, String>> columns = new ArrayList<>();
columns.add(new PropertyColumn<>(new ResourceModel("name", "Name"), "Name", "name"));
return columns;
}
protected final class ServiceComparator implements Comparator<ServiceTO>, Serializable {
private static final long serialVersionUID = -1843653604375242876L;
@Override
public int compare(final ServiceTO o1, final ServiceTO o2) {
return o1.getName().compareTo(o2.getName());
}
}
protected final class ServiceProvider extends DirectoryDataProvider<ServiceTO> {
private static final long serialVersionUID = -8754548053385660794L;
private final Comparator<ServiceTO> comparator = new ServiceComparator();
private ServiceProvider(final int paginatorRows) {
super(paginatorRows);
}
@Override
public Iterator<ServiceTO> iterator(final long first, final long count) {
List<ServiceTO> list = restClient.choreographyServiceList(choreographyId);
Collections.sort(list, comparator);
return list.subList((int) first, (int) first + (int) count).iterator();
}
@Override
public long size() {
return restClient.choreographyServiceList(choreographyId).size();
}
@Override
public IModel<ServiceTO> model(final ServiceTO object) {
return new CompoundPropertyModel<>(object);
}
}
}
......@@ -27,7 +27,7 @@ import java.util.List;
import org.apache.syncope.client.console.commons.DirectoryDataProvider;
import org.apache.syncope.client.console.pages.InstanceStatsPage;
import org.apache.syncope.client.console.pages.ServiceDetailPage;
import org.apache.syncope.client.console.panels.ServiceDirectoryPanel.ServiceProvider;
import org.apache.syncope.client.console.panels.InstanceServiceDirectoryPanel.ServiceProvider;
import org.apache.syncope.client.console.rest.ChoreographyRestClient;
import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
import org.apache.syncope.client.console.wizards.WizardMgtPanel;
......@@ -44,14 +44,14 @@ import org.apache.wicket.model.IModel;
import org.apache.wicket.model.ResourceModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
public class ServiceDirectoryPanel extends DirectoryPanel<
public class InstanceServiceDirectoryPanel extends DirectoryPanel<
ServiceTO, ServiceTO, ServiceProvider, ChoreographyRestClient> {
private static final long serialVersionUID = 3727444742501082182L;
private String instanceId;
public ServiceDirectoryPanel(final String id, final PageReference pageRef, final String instanceId) {
public InstanceServiceDirectoryPanel(final String id, final PageReference pageRef, final String instanceId) {
super(id, new DirectoryPanel.Builder<ServiceTO, ServiceTO, ChoreographyRestClient>(
new ChoreographyRestClient(), pageRef) {
......@@ -60,7 +60,7 @@ public class ServiceDirectoryPanel extends DirectoryPanel<
@Override
protected WizardMgtPanel<ServiceTO> newInstance(final String id, final boolean wizardInModal) {
return new ServiceDirectoryPanel(id, this);
return new InstanceServiceDirectoryPanel(id, this);
}
}.disableCheckBoxes());
......@@ -72,7 +72,7 @@ public class ServiceDirectoryPanel extends DirectoryPanel<
initResultTable();
}
private ServiceDirectoryPanel(
private InstanceServiceDirectoryPanel(
final String id,
final DirectoryPanel.Builder<ServiceTO, ServiceTO, ChoreographyRestClient> builder) {
......@@ -114,21 +114,6 @@ public class ServiceDirectoryPanel extends DirectoryPanel<
@Override
public void populateItem(final Item<ICellPopulator<ServiceTO>> item, final String componentId,
final IModel<ServiceTO> model) {
/* ActionLinksPanel.Builder<Serializable> actionLinks = ActionLinksPanel.builder();
* actionLinks.setDisableIndicator(true);
* actionLinks.add(new ActionLink<Serializable>() {
*
* private static final long serialVersionUID = -3722207913631435501L;
*
* @Override
* public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
* PageParameters param = new PageParameters();
* param.add("instance", instanceId);
* param.add("service", model.getObject().getName());
* setResponsePage(ServiceDetailPage.class, param);
* }
* }, ActionLink.ActionType.SEARCH);
* item.add(actionLinks.build(componentId)); */
ChoreographyActionsPanel choreographyActionsPanel = new ChoreographyActionsPanel(componentId);
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
......@@ -172,14 +157,14 @@ public class ServiceDirectoryPanel extends DirectoryPanel<
@Override
public Iterator<ServiceTO> iterator(final long first, final long count) {
List<ServiceTO> list = restClient.serviceList(instanceId);
List<ServiceTO> list = restClient.instanceServiceList(instanceId);
Collections.sort(list, comparator);
return list.subList((int) first, (int) first + (int) count).iterator();
}
@Override
public long size() {
return restClient.serviceList(instanceId).size();
return restClient.instanceServiceList(instanceId).size();
}
@Override
......
......@@ -38,8 +38,12 @@ public class ChoreographyRestClient extends BaseRestClient {
return getService(ConsoleInterfaceService.class).cdList(instanceId);
}
public List<ServiceTO> serviceList(final String instanceId) {
return getService(ConsoleInterfaceService.class).serviceList(instanceId);
public List<ServiceTO> instanceServiceList(final String instanceId) {
return getService(ConsoleInterfaceService.class).instanceServiceList(instanceId);
}
public List<ServiceTO> choreographyServiceList(final String choreographyId) {
return getService(ConsoleInterfaceService.class).choreographyServiceList(choreographyId);
}
public List<OperationDataTO> operationList(
......
......@@ -16,14 +16,10 @@ limitations under the License.
-->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div class="box">
<div class="box-body" wicket:id="instances"/>
<div class="box-body">
<h4>
<span wicket:id="avg_instances"></span>
<span wicket:id="avg_details"></span>
</h4>
</div>
</div>
<div wicket:id="instances"/>
<h4>
<span wicket:id="avg_instances"></span>
<span wicket:id="avg_details"></span>
</h4>
</wicket:panel>
</html>
\ No newline at end of file
......@@ -215,7 +215,7 @@ public class MonitorLogic extends AbstractTransactionalLogic<AbstractBaseBean> {
return coordinationDelegateTO;
}
public List<ServiceTO> serviceList(final String choreographyInstancePK) {
public List<ServiceTO> instanceServiceList(final String choreographyInstancePK) {
List<ServiceTO> serviceTOs = new LinkedList<>();
List<String> serviceNames = getServiceNames(choreographyInstancePK);
......@@ -226,6 +226,20 @@ public class MonitorLogic extends AbstractTransactionalLogic<AbstractBaseBean> {
return serviceTOs;
}
public List<ServiceTO> choreographyServiceList(final String choreographyId) {
List<ServiceTO> serviceTOs = new LinkedList<>();
List<String> serviceNames = eventDAO.findServicesByChoreography(choreographyId);
// SENDS ONLY SERVICE NAME, WITH NO MORE INFORMATIONS!
for (String serviceName : serviceNames) {
ServiceTO currentService = new ServiceTO();
currentService.setName(serviceName);
serviceTOs.add(currentService);
}
return serviceTOs;
}
public ServiceTO getService(final String choreographyInstancePK, final String serviceName) {
ServiceTO serviceTO = new ServiceTO();
serviceTO.setName(serviceName);
......
......@@ -60,13 +60,17 @@ public interface ConsoleInterfaceService extends JAXRSService {
* @param choreographyInstancePK
* @return all CDs of selected choreography instance
*/
@Path("/{choreographyInstancePK}/cds")
@Path("instance/{choreographyInstancePK}/cds")
@GET
List<CoordinationDelegateTO> cdList(@PathParam("choreographyInstancePK") String choreographyInstancePK);
@Path("/{choreographyInstancePK}/serviceList")
@Path("instance/{choreographyInstancePK}/serviceList")
@GET
List<ServiceTO> serviceList(@PathParam("choreographyInstancePK") String choreographyInstancePK);
List<ServiceTO> instanceServiceList(@PathParam("choreographyInstancePK") String choreographyInstancePK);
@Path("{choreographyId}/serviceList")
@GET
List<ServiceTO> choreographyServiceList(@PathParam("choreographyId") String choreographyId);
/**
*
......@@ -74,7 +78,7 @@ public interface ConsoleInterfaceService extends JAXRSService {
* @param cdName
* @return all operations performed by selected CD
*/
@Path("/{choreographyInstancePK}/{cdname}/operations")
@Path("instance/{choreographyInstancePK}/{cdname}/operations")
@GET
List<OperationDataTO> operationList(
@PathParam("choreographyInstancePK") String choreographyInstancePK,
......
......@@ -59,8 +59,13 @@ public class ConsoleInterfaceServiceImpl extends AbstractServiceImpl implements
}
@Override
public List<ServiceTO> serviceList(final String choreographyInstancePK) {
return logic.serviceList(choreographyInstancePK);
public List<ServiceTO> instanceServiceList(final String choreographyInstancePK) {
return logic.instanceServiceList(choreographyInstancePK);
}
@Override
public List<ServiceTO> choreographyServiceList(final String choreographyId) {
return logic.choreographyServiceList(choreographyId);
}
@Override
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment