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

Working on EE extension

parent 3619f002
/*
* 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.syncope.client.console.rest.AbstractAnyRestClient;
import org.apache.syncope.common.lib.to.AnyObjectTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class EnactmentEngineDataProvider extends AnyDataProvider<AnyObjectTO> {
private static final long serialVersionUID = 3628773545540989992L;
protected static final Logger LOG = LoggerFactory.getLogger(EnactmentEngineDataProvider.class);
public EnactmentEngineDataProvider(
final AbstractAnyRestClient<AnyObjectTO, ?> restClient,
final int paginatorRows,
final boolean filtered,
final String realm,
final String type) {
super(restClient, paginatorRows, filtered, realm, type);
}
@Override
public AnyDataProvider<AnyObjectTO> setFIQL(final String fiql) {
this.fiql = fiql;
LOG.info("Set anyObject search query to '{}'", this.fiql);
return this;
}
}
/*
* 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 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;
public class EnactmentEngineActionsPanel extends Panel {
private static final long serialVersionUID = 1939501639210931637L;
public EnactmentEngineActionsPanel(final String componentId) {
super(componentId);
setOutputMarkupId(true);
super.add(new Fragment("detailsPanel", "emptyFragment", this));
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("freezePanel", "emptyFragment", this));
super.add(new Fragment("unfreezePanel", "emptyFragment", this));
super.add(new Fragment("resizePanel", "emptyFragment", this));
super.add(new Fragment("deletePanel", "emptyFragment", this));
}
public EnactmentEngineActionsPanel addAction(
final IndicatingAjaxLink<Void> link,
final EnactmentEngineActionType choreographyActionType) {
Fragment fragment = null;
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 FREEZE:
fragment = new Fragment("freezePanel", "freezeFragment", this);
fragment.addOrReplace(link.setVisible(true));
break;
case UNFREEZE:
fragment = new Fragment("unfreezePanel", "unfreezeFragment", this);
fragment.addOrReplace(link.setVisible(true));
break;
case RESIZE:
fragment = new Fragment("resizePanel", "resizeFragment", 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
}
if (fragment != null) {
super.addOrReplace(fragment);
}
return this;
}
public enum EnactmentEngineActionType {
SHOW,
START,
PAUSE,
STOP,
FREEZE,
UNFREEZE,
RESIZE,
DELETE
}
}
......@@ -16,14 +16,27 @@
package org.apache.syncope.client.console.panels;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.syncope.client.console.commons.AnyDataProvider;
import org.apache.syncope.client.console.commons.Constants;
import org.apache.syncope.client.console.commons.EnactmentEngineDataProvider;
import org.apache.syncope.client.console.pages.EnactmentEnginePage;
import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.AttrColumn;
import org.apache.syncope.common.lib.search.AnyObjectFiqlSearchConditionBuilder;
import org.apache.syncope.common.lib.to.AnyObjectTO;
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;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.ResourceModel;
import org.springframework.util.ReflectionUtils;
public class EnactmentEngineDirectoryPanel extends AnyObjectDirectoryPanel {
......@@ -31,8 +44,6 @@ public class EnactmentEngineDirectoryPanel extends AnyObjectDirectoryPanel {
public EnactmentEngineDirectoryPanel(final String id, final PageReference pageRef) {
super(id, new Builder(AnyTypeKind.ANY_OBJECT.name(), pageRef), false);
this.fiql = new AnyObjectFiqlSearchConditionBuilder("ENACTMENT ENGINE").query();
dataProvider.setFIQL(fiql);
}
@Override
......@@ -40,9 +51,77 @@ public class EnactmentEngineDirectoryPanel extends AnyObjectDirectoryPanel {
return EnactmentEnginePage.PREF_EE_PAGINATOR_ROWS;
}
@Override
protected AnyDataProvider<AnyObjectTO> dataProvider() {
final EnactmentEngineDataProvider dp = new EnactmentEngineDataProvider(restClient, rows, filtered, realm, type);
return dp.setFIQL(new AnyObjectFiqlSearchConditionBuilder("ENACTMENT ENGINE").query());
}
@Override
protected List<IColumn<AnyObjectTO, String>> getColumns() {
return super.getColumns();
final List<IColumn<AnyObjectTO, String>> columns = new ArrayList<>();
//Same implementation of AnyObjectDirectoryPanel
for (String name : prefMan.getList(
getRequest(), String.format(Constants.PREF_ANY_OBJECT_DETAILS_VIEW, type))) {
addPropertyColumn(name, ReflectionUtils.findField(AnyObjectTO.class, name), columns);
}
for (String name : prefMan.getList(
getRequest(), String.format(Constants.PREF_ANY_OBJECT_PLAIN_ATTRS_VIEW, type))) {
if (pSchemaNames.contains(name)) {
columns.add(new AttrColumn<AnyObjectTO>(name, SchemaType.PLAIN));
}
}
for (String name : prefMan.getList(
getRequest(), String.format(Constants.PREF_ANY_OBJECT_DER_ATTRS_VIEW, type))) {
if (dSchemaNames.contains(name)) {
columns.add(new AttrColumn<AnyObjectTO>(name, SchemaType.DERIVED));
}
}
// Add defaults in case of no selection
if (columns.isEmpty()) {
for (String name : AnyObjectDisplayAttributesModalPanel.DEFAULT_SELECTION) {
addPropertyColumn(name, ReflectionUtils.findField(AnyObjectTO.class, name), columns);
}
prefMan.setList(getRequest(), getResponse(),
String.format(Constants.PREF_ANY_OBJECT_DETAILS_VIEW, type),
Arrays.asList(AnyObjectDisplayAttributesModalPanel.DEFAULT_SELECTION));
}
columns.add(new AbstractColumn<AnyObjectTO, String>(new ResourceModel("actions", "")) {
private static final long serialVersionUID = -5137819175810948915L;
@Override
public String getCssClass() {
return "action";
}
@Override
public void populateItem(
final Item<ICellPopulator<AnyObjectTO>> item,
final String componentId,
final IModel<AnyObjectTO> model) {
EnactmentEngineActionsPanel enactmentEngineActionsPanel = new EnactmentEngineActionsPanel(componentId);
enactmentEngineActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
@Override
public void onClick(final AjaxRequestTarget art) {
//Define action!
}
}, EnactmentEngineActionsPanel.EnactmentEngineActionType.SHOW);
item.add(enactmentEngineActionsPanel);
}
});
return columns;
}
public static class Builder extends AnyObjectDirectoryPanel.Builder {
......
<!DOCTYPE html>
<!--
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.
-->
<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>
<span wicket:id="freezePanel"></span>
<span wicket:id="unfreezePanel"></span>
<span wicket:id="resizePanel"></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="freezeFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-pause" alt="freeze icon" title="Freeze"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="unfreezeFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-bolt" alt="unfreeze icon" title="Unfreeze"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="resizeFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-arrows" alt="resize icon" title="Resize"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="deleteFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-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