Commit c51e78b0 authored by fabio martelli's avatar fabio martelli
Browse files

[CRV-194] includes choreography status, delete button and bulk action...

[CRV-194] includes choreography status, delete button and bulk action management + choreography directory panel refactoring
parent 4c4ca677
......@@ -184,6 +184,11 @@ public class GroupDirectoryPanel extends AnyDirectoryPanel<GroupTO, GroupRestCli
return Constants.PREF_GROUP_PAGINATOR_ROWS;
}
/**
* CHOReVOLUTION overriding to hide choreographies from group list.
*
* @return CHOReVOLUTION groups data provider.
*/
@Override
protected AnyDataProvider<GroupTO> dataProvider() {
final GroupDataProvider dp = new GroupDataProvider(restClient, rows, filtered, realm, type);
......
......@@ -525,6 +525,11 @@ we are happy to inform you that the password request was execute successfully fo
<PlainSchema id="id" mandatoryCondition="true"
multivalue="0" readonly="0" type="String" uniqueConstraint="1" anyTypeClass_id="Choreography"/>
<SyncopeSchema id="status"/>
<PlainSchema id="status" mandatoryCondition="true" mimeType="application/xml"
multivalue="0" readonly="0" type="Enum" uniqueConstraint="0" enumerationValues="STARTED;FROZEN;STOPPED"
anyTypeClass_id="Choreography"/>
<SyncopeSchema id="description"/>
<PlainSchema id="description" mandatoryCondition="false"
multivalue="0" readonly="0" type="String" uniqueConstraint="0" anyTypeClass_id="Choreography"/>
......
......@@ -526,6 +526,11 @@ we are happy to inform you that the password request was execute successfully fo
<PlainSchema id="id" mandatoryCondition="true"
multivalue="0" readonly="0" type="String" uniqueConstraint="1" anyTypeClass_id="Choreography"/>
 
<SyncopeSchema id="status"/>
<PlainSchema id="status" mandatoryCondition="true" mimeType="application/xml"
multivalue="0" readonly="0" type="Enum" uniqueConstraint="0" enumerationValues="STARTED;FROZEN;STOPPED"
anyTypeClass_id="Choreography"/>
<SyncopeSchema id="description"/>
<PlainSchema id="description" mandatoryCondition="false"
multivalue="0" readonly="0" type="String" uniqueConstraint="0" anyTypeClass_id="Choreography"/>
......@@ -593,6 +598,9 @@ we are happy to inform you that the password request was execute successfully fo
 
<GPlainAttr id="f82fc61f-8e74-4a4b-9f9e-b8a41f38aad9" owner_id="80b8ba87-842d-481a-b8ba-87842d681a70" schema_id="description"/>
<GPlainAttrValue attribute_id="f82fc61f-8e74-4a4b-9f9e-b8a41f38aad9" id="49f35879-2510-4f11-a901-24152f753538" stringValue="WP7 choreography"/>
<GPlainAttr id="f82fc61f-8e74-4a4b-9f9e-b8a41f3833d9" owner_id="80b8ba87-842d-481a-b8ba-87842d681a70" schema_id="status"/>
<GPlainAttrValue attribute_id="f82fc61f-8e74-4a4b-9f9e-b8a41f3833d9" id="49f35879-2510-4f11-a901-24152f753534" stringValue="STARTED"/>
 
<GPlainAttr id="9d0d9e40-1b18-488e-9482-37dab82163c9" owner_id="80b8ba87-842d-481a-b8ba-87842d681a70" schema_id="image"/>
<GPlainAttrValue id="7034de3b-3687-4db5-8454-363468f1a9de" attribute_id="9d0d9e40-1b18-488e-9482-37dab82163c9"
/*
* 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.commons;
import org.apache.cxf.common.util.StringUtils;
import org.apache.syncope.client.console.rest.AbstractAnyRestClient;
import org.apache.syncope.common.lib.to.GroupTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ChoreographyDataProvider extends AnyDataProvider<GroupTO> {
private static final long serialVersionUID = 3628773545540989992L;
protected static final Logger LOG = LoggerFactory.getLogger(ChoreographyDataProvider.class);
public ChoreographyDataProvider(
final AbstractAnyRestClient<GroupTO, ?> restClient,
final int paginatorRows,
final boolean filtered,
final String realm,
final String type) {
super(restClient, paginatorRows, filtered, realm, type);
}
@Override
public AnyDataProvider<GroupTO> setFIQL(final String fiql) {
this.fiql = StringUtils.isEmpty(fiql)
? "isChoreography!=$null;isChoreography==true"
: "(" + fiql + ");(isChoreography!=$null;isChoreography==true)";
LOG.info("Set group search query to '{}'", this.fiql);
return this;
}
}
......@@ -19,7 +19,7 @@ import eu.chorevolution.idm.common.ChorevolutionEntitlement;
import org.apache.syncope.client.console.BookmarkablePageLinkBuilder;
import org.apache.syncope.client.console.annotations.ExtPage;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.syncope.client.console.panels.ChoreographyPanel;
import org.apache.syncope.client.console.panels.ChoreographyDirectoryPanel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
@ExtPage(label = "Choreographies", icon = "fa-bar-chart",
......@@ -37,7 +37,8 @@ public class ChoreographyPage extends BaseExtPage {
WebMarkupContainer content = new WebMarkupContainer("content");
content.setOutputMarkupId(true);
content.add(new ChoreographyPanel("choreographies", getPageReference()));
content.add(new ChoreographyDirectoryPanel("choreographies", getPageReference()));
// Re-enable when entilements for this service will be defined
//MetaDataRoleAuthorizationStrategy.authorize(content, ENABLE, CamelEntitlement.ROUTE_LIST);
......
......@@ -15,6 +15,8 @@
*/
package org.apache.syncope.client.console.panels;
import org.apache.syncope.client.console.wicket.markup.html.form.IndicatingOnConfirmAjaxLink;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.html.panel.Panel;
......@@ -32,6 +34,7 @@ public class ChoreographyActionsPanel extends Panel {
super.add(new Fragment("startPanel", "emptyFragment", this));
super.add(new Fragment("pausePanel", "emptyFragment", this));
super.add(new Fragment("stopPanel", "emptyFragment", this));
super.add(new Fragment("deletePanel", "emptyFragment", this));
}
public ChoreographyActionsPanel addAction(
......@@ -43,28 +46,38 @@ public class ChoreographyActionsPanel extends Panel {
switch (choreographyActionType) {
case SHOW:
fragment = new Fragment("detailsPanel", "detailsFragment", this);
fragment.addOrReplace(link.setVisible(true));
break;
case START:
fragment = new Fragment("startPanel", "startFragment", this);
fragment.addOrReplace(link.setVisible(true));
break;
case PAUSE:
fragment = new Fragment("pausePanel", "pauseFragment", this);
fragment.addOrReplace(link.setVisible(true));
break;
case STOP:
fragment = new Fragment("stopPanel", "stopFragment", this);
fragment.addOrReplace(link.setVisible(true));
break;
case DELETE:
fragment = new Fragment("deletePanel", "deleteFragment", this);
fragment.addOrReplace(new IndicatingOnConfirmAjaxLink<Void>("link", true) {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target) {
link.onClick(target);
}
});
break;
default:
// No action
// No action
}
if (fragment != null) {
super.addOrReplace(fragment);
......@@ -76,6 +89,8 @@ public class ChoreographyActionsPanel extends Panel {
SHOW,
START,
PAUSE,
STOP
STOP,
DELETE
}
}
......@@ -15,22 +15,25 @@
*/
package org.apache.syncope.client.console.panels;
import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
import eu.chorevolution.idm.common.to.ChoreographyTO;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Comparator;
import org.apache.syncope.client.console.commons.DirectoryDataProvider;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.client.console.SyncopeConsoleSession;
import org.apache.syncope.client.console.commons.AnyDataProvider;
import org.apache.syncope.client.console.commons.ChoreographyDataProvider;
import org.apache.syncope.client.console.commons.Constants;
import org.apache.syncope.client.console.pages.BasePage;
import org.apache.syncope.client.console.pages.ChoreographyPage;
import org.apache.syncope.client.console.pages.ChoreographyDetailPage;
import org.apache.syncope.client.console.panels.ChoreographyPanel.ChoreographyProvider;
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.rest.AnyTypeClassRestClient;
import org.apache.syncope.client.console.rest.AnyTypeRestClient;
import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.AttrColumn;
import org.apache.syncope.common.lib.SyncopeClientException;
import org.apache.syncope.common.lib.to.GroupTO;
import org.apache.syncope.client.console.wizards.WizardMgtPanel;
import org.apache.syncope.client.console.wizards.any.AnyWrapper;
import org.apache.syncope.common.lib.types.AnyTypeKind;
import org.apache.syncope.common.lib.types.SchemaType;
import org.apache.wicket.PageReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink;
......@@ -39,44 +42,22 @@ import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColu
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.markup.repeater.Item;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.ResourceModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
public class ChoreographyPanel extends DirectoryPanel<
ChoreographyTO, ChoreographyTO, ChoreographyProvider, ChoreographyRestClient> {
public class ChoreographyDirectoryPanel extends GroupDirectoryPanel {
private static final long serialVersionUID = 3727444742501082182L;
public ChoreographyPanel(final String id, final PageReference pageRef) {
super(id, new Builder<ChoreographyTO, ChoreographyTO, ChoreographyRestClient>(
new ChoreographyRestClient(), pageRef) {
private static final long serialVersionUID = 8769126634538601689L;
@Override
protected WizardMgtPanel<ChoreographyTO> newInstance(final String id, final boolean wizardInModal) {
return new ChoreographyPanel(id, this);
}
}.disableCheckBoxes());
setFooterVisibility(true);
modal.addSubmitButton();
modal.size(Modal.Size.Large);
initResultTable();
}
private ChoreographyPanel(
final String id,
final Builder<ChoreographyTO, ChoreographyTO, ChoreographyRestClient> builder) {
super(id, builder);
public ChoreographyDirectoryPanel(final String id, final PageReference pageRef) {
super(id, new Builder(AnyTypeKind.GROUP.name(), pageRef), false);
}
@Override
protected ChoreographyProvider dataProvider() {
return new ChoreographyProvider(rows);
protected AnyDataProvider<GroupTO> dataProvider() {
final ChoreographyDataProvider dp = new ChoreographyDataProvider(restClient, rows, filtered, realm, type);
return dp.setFIQL(this.fiql);
}
@Override
......@@ -85,16 +66,15 @@ public class ChoreographyPanel extends DirectoryPanel<
}
@Override
protected Collection<ActionLink.ActionType> getBulkActions() {
return Collections.<ActionLink.ActionType>emptyList();
}
protected List<IColumn<GroupTO, String>> getColumns() {
final List<IColumn<GroupTO, String>> columns = new ArrayList<>();
@Override
protected List<IColumn<ChoreographyTO, String>> getColumns() {
final List<IColumn<ChoreographyTO, String>> columns = new ArrayList<>();
columns.add(new PropertyColumn<>(new ResourceModel("name"), "Name", "name"));
columns.add(new PropertyColumn<>(new ResourceModel("description", "Description"), "description"));
columns.add(new AbstractColumn<ChoreographyTO, String>(new ResourceModel("actions", "")) {
columns.add(new AttrColumn<>("id", SchemaType.PLAIN));
columns.add(new PropertyColumn<>(new ResourceModel("name", "Name"), "name"));
columns.add(new AttrColumn<>("description", SchemaType.PLAIN));
columns.add(new AttrColumn<>("status", SchemaType.PLAIN));
columns.add(new AbstractColumn<GroupTO, String>(new ResourceModel("actions", "")) {
private static final long serialVersionUID = -3503023501954863131L;
......@@ -104,8 +84,8 @@ public class ChoreographyPanel extends DirectoryPanel<
}
@Override
public void populateItem(final Item<ICellPopulator<ChoreographyTO>> item, final String componentId,
final IModel<ChoreographyTO> model) {
public void populateItem(
final Item<ICellPopulator<GroupTO>> item, final String componentId, final IModel<GroupTO> model) {
ChoreographyActionsPanel choreographyActionsPanel = new ChoreographyActionsPanel(componentId);
......@@ -116,7 +96,7 @@ public class ChoreographyPanel extends DirectoryPanel<
@Override
public void onClick(final AjaxRequestTarget target) {
PageParameters param = new PageParameters();
param.add("chor", model.getObject().getId());
param.add("chor", model.getObject().getPlainAttrMap().get("id").getValues().iterator().next());
setResponsePage(ChoreographyDetailPage.class, param);
}
}, ChoreographyActionsPanel.ChoreographyActionType.SHOW);
......@@ -147,6 +127,24 @@ public class ChoreographyPanel extends DirectoryPanel<
// No actions
}
}, ChoreographyActionsPanel.ChoreographyActionType.STOP);
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
restClient.delete(model.getObject().getETagValue(), model.getObject().getKey());
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (SyncopeClientException e) {
LOG.error("While deleting object {}", model.getObject().getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ChoreographyActionsPanel.ChoreographyActionType.DELETE);
item.add(choreographyActionsPanel);
}
});
......@@ -154,42 +152,29 @@ public class ChoreographyPanel extends DirectoryPanel<
return columns;
}
protected final class ChoreographyProvider extends DirectoryDataProvider<ChoreographyTO> {
public static class Builder extends GroupDirectoryPanel.Builder {
private static final long serialVersionUID = -185944053385660794L;
private static final long serialVersionUID = 8769126634538601689L;
private final Comparator<ChoreographyTO> comparator;
private final AnyTypeRestClient anyTypeRestClient = new AnyTypeRestClient();
private ChoreographyProvider(final int paginatorRows) {
super(paginatorRows);
comparator = new ChoreographyComparator();
}
private final AnyTypeClassRestClient anyTypeClassRestClient = new AnyTypeClassRestClient();
@Override
public Iterator<ChoreographyTO> iterator(final long first, final long count) {
List<ChoreographyTO> choreographyList = restClient.choreographyList();
Collections.sort(choreographyList, comparator);
return choreographyList.subList((int) first, (int) first + (int) count).iterator();
}
public Builder(final String type, final PageReference pageRef) {
super(new ArrayList<>(), type, pageRef);
@Override
public long size() {
return restClient.choreographyList().size();
}
@Override
public IModel<ChoreographyTO> model(final ChoreographyTO object) {
return new CompoundPropertyModel<>(object);
}
}
getAnyTypeClassTOs().addAll(
anyTypeClassRestClient.list(anyTypeRestClient.read(AnyTypeKind.GROUP.name()).getClasses()));
protected static class ChoreographyComparator implements Comparator<ChoreographyTO>, Serializable {
setRealm("/");
setFiltered(true);
private static final long serialVersionUID = -5499388798554495465L;
setShowResultPage(true);
}
@Override
public int compare(final ChoreographyTO o1, final ChoreographyTO o2) {
return o1.getName().compareTo(o2.getName());
protected WizardMgtPanel<AnyWrapper<GroupTO>> newInstance(final String id, final boolean wizardInModal) {
return new ChoreographyDirectoryPanel(id, pageRef);
}
}
}
......@@ -30,10 +30,6 @@ public class ChoreographyRestClient extends BaseRestClient {
private static final long serialVersionUID = -2018208424159468912L;
public List<ChoreographyTO> choreographyList() {
return getService(ConsoleInterfaceService.class).choreographyList();
}
public List<ChoreographyInstanceTO> instanceList(final String choreographyId) {
return getService(ConsoleInterfaceService.class).instanceList(choreographyId);
}
......
......@@ -15,29 +15,34 @@ See the License for the specific language governing permissions and
limitations under the License.
-->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<span wicket:id="detailsPanel"></span>
<span wicket:id="startPanel"></span>
<span wicket:id="pausePanel"></span>
<span wicket:id="stopPanel"></span>
<wicket:fragment wicket:id="detailsFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-search" alt="show details" title="Show Details"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="startFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-play" alt="start" title="Start"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="pauseFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-pause" alt="pause" title="Pause"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="stopFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-stop" alt="stop" title="Stop"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="emptyFragment">
</wicket:fragment>
</wicket:panel>
<wicket:panel>
<span wicket:id="detailsPanel"></span>
<span wicket:id="startPanel"></span>
<span wicket:id="pausePanel"></span>
<span wicket:id="stopPanel"></span>
<span wicket:id="deletePanel"></span>
<wicket:fragment wicket:id="detailsFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-search" alt="show details" title="Show Details"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="startFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-play" alt="start" title="Start"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="pauseFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-pause" alt="pause" title="Pause"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="stopFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-stop" alt="stop" title="Stop"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="deleteFragment">
<a href="#" wicket:id="link" class="btn"><i class="glyphicon glyphicon-minus" alt="delete icon" title="Delete"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="emptyFragment">
</wicket:fragment>
</wicket:panel>
</html>
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