Commit 160a67a0 authored by Gianluca Filippone's avatar Gianluca Filippone
Browse files

[CRV-228] Added console support for start, stop, freeze and unfreeze of a choreography

parent 72523eba
......@@ -34,6 +34,9 @@ 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("freezePanel", "emptyFragment", this));
super.add(new Fragment("unfreezePanel", "emptyFragment", this));
super.add(new Fragment("resizePanel", "emptyFragment", this));
super.add(new Fragment("deletePanel", "emptyFragment", this));
}
......@@ -64,6 +67,21 @@ public class ChoreographyActionsPanel extends Panel {
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) {
......@@ -90,7 +108,9 @@ public class ChoreographyActionsPanel extends Panel {
START,
PAUSE,
STOP,
FREEZE,
UNFREEZE,
RESIZE,
DELETE
}
}
......@@ -25,6 +25,7 @@ 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 static org.apache.syncope.client.console.panels.DirectoryPanel.LOG;
import org.apache.syncope.client.console.rest.AnyTypeClassRestClient;
import org.apache.syncope.client.console.rest.AnyTypeRestClient;
import org.apache.syncope.client.console.rest.ChoreographyRestClient;
......@@ -105,6 +106,96 @@ public class ChoreographyDirectoryPanel extends GroupDirectoryPanel {
setResponsePage(ChoreographyDetailPage.class, param);
}
}, ChoreographyActionsPanel.ChoreographyActionType.SHOW);
if (model.getObject().getPlainAttrMap().get("status").getValues().iterator().next().equals("STARTED")) {
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = 3104631231085231035L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
choreographyRestClient.stopChoreography(
model.getObject().getPlainAttrMap().get("id").getValues().iterator().next(),
"Default");
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (SyncopeClientException e) {
LOG.error("While sopping choreography {}", model.getObject().getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ChoreographyActionsPanel.ChoreographyActionType.STOP);
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = 3104631231085231035L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
choreographyRestClient.freezeChoreography(
model.getObject().getPlainAttrMap().get("id").getValues().iterator().next(),
"Default");
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (SyncopeClientException e) {
LOG.error("While freezing choreography {}", model.getObject().getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ChoreographyActionsPanel.ChoreographyActionType.FREEZE);
}
if (model.getObject().getPlainAttrMap().get("status").getValues().iterator().next().equals("STOPPED")) {
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = 3104631231085231035L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
choreographyRestClient.startChoreography(
model.getObject().getPlainAttrMap().get("id").getValues().iterator().next(),
"Default");
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (SyncopeClientException e) {
LOG.error("While starting choreography {}", model.getObject().getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ChoreographyActionsPanel.ChoreographyActionType.START);
}
if (model.getObject().getPlainAttrMap().get("status").getValues().iterator().next().equals("FREEZED")) {
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = 3104631231085231035L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
choreographyRestClient.unfreezeChoreography(
model.getObject().getPlainAttrMap().get("id").getValues().iterator().next(),
"Default");
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (SyncopeClientException e) {
LOG.error("While unfreexing choreography {}", model.getObject().getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ChoreographyActionsPanel.ChoreographyActionType.UNFREEZE);
}
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = -7978723352517770644L;
......@@ -125,6 +216,15 @@ public class ChoreographyDirectoryPanel extends GroupDirectoryPanel {
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ChoreographyActionsPanel.ChoreographyActionType.DELETE);
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = 3104631231085231035L;
@Override
public void onClick(final AjaxRequestTarget target) {
//Need to open a modal panel
}
}, ChoreographyActionsPanel.ChoreographyActionType.RESIZE);
item.add(choreographyActionsPanel);
}
});
......
......@@ -23,6 +23,7 @@ import eu.chorevolution.idm.common.to.ChoreographyInstanceTO;
import eu.chorevolution.idm.common.to.ChoreographyTO;
import eu.chorevolution.idm.common.to.CoordinationDelegateTO;
import eu.chorevolution.idm.common.to.ServiceTO;
import eu.chorevolution.idm.common.types.ChoreographyAction;
import java.util.List;
import org.apache.syncope.common.rest.api.service.ChoreographyService;
import org.apache.syncope.common.rest.api.service.ConsoleInterfaceService;
......@@ -94,4 +95,29 @@ public class ChoreographyRestClient extends BaseRestClient {
public void deleteInstance(final String choreographyInstancePK) {
getService(ConsoleInterfaceService.class).deleteInstance(choreographyInstancePK);
}
public void startChoreography(final String choreographyId, final String enactmentEngine) {
getService(ChoreographyService.class)
.onChoreography(choreographyId, enactmentEngine, ChoreographyAction.START, null);
}
public void stopChoreography(final String choreographyId, final String enactmentEngine) {
getService(ChoreographyService.class)
.onChoreography(choreographyId, enactmentEngine, ChoreographyAction.STOP, null);
}
public void freezeChoreography(final String choreographyId, final String enactmentEngine) {
getService(ChoreographyService.class)
.onChoreography(choreographyId, enactmentEngine, ChoreographyAction.FREEZE, null);
}
public void unfreezeChoreography(final String choreographyId, final String enactmentEngine) {
getService(ChoreographyService.class)
.onChoreography(choreographyId, enactmentEngine, ChoreographyAction.UNFREEZE, null);
}
public void resizeChoreography(final String choreographyId, final String enactmentEngine, final Integer size) {
getService(ChoreographyService.class)
.onChoreography(choreographyId, enactmentEngine, ChoreographyAction.RESIZE, size);
}
}
......@@ -20,8 +20,12 @@ limitations under the License.
<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>
......@@ -38,8 +42,20 @@ limitations under the License.
<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="glyphicon glyphicon-minus" alt="delete icon" title="Delete"></i></a>
<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">
......
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