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

[CRV-212] Implemented choreography instances remove from action button

parent 943aea91
......@@ -24,13 +24,18 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Comparator;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.client.console.SyncopeConsoleSession;
import org.apache.syncope.client.console.commons.Constants;
import org.apache.syncope.client.console.commons.DirectoryDataProvider;
import org.apache.syncope.client.console.pages.BasePage;
import org.apache.syncope.client.console.pages.ChoreographyDetailPage;
import org.apache.syncope.client.console.pages.InstanceStatsPage;
import org.apache.syncope.client.console.panels.InstanceDirectoryPanel.InstanceProvider;
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.syncope.common.lib.SyncopeClientException;
import org.apache.wicket.PageReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink;
......@@ -135,7 +140,16 @@ public class InstanceDirectoryPanel extends DirectoryPanel<
@Override
public void onClick(final AjaxRequestTarget target) {
// No actions
try {
restClient.deleteInstance(model.getObject().getId());
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (SyncopeClientException e) {
LOG.error("While deleting object {}", model.getObject().getId(), 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);
......
......@@ -81,4 +81,12 @@ public class ChoreographyRestClient extends BaseRestClient {
final String cdName) {
return getService(ConsoleInterfaceService.class).averageOperationList(choreographyId, cdName);
}
public void deleteChoreography(final String choreographyId) {
getService(ConsoleInterfaceService.class).deleteChoreography(choreographyId);
}
public void deleteInstance(final String choreographyInstancePK) {
getService(ConsoleInterfaceService.class).deleteInstance(choreographyInstancePK);
}
}
......@@ -688,4 +688,26 @@ public class MonitorLogic extends AbstractTransactionalLogic<AbstractBaseBean> {
}
return aVGOperationDataTOs;
}
public void deleteChoreography(final String choreographyId) {
List<ChoreographyInstance> choreographyInstances = choreographyInstanceDAO.findByChoreographyId(choreographyId);
for (ChoreographyInstance choreographyInstance : choreographyInstances) {
deleteInstance(choreographyInstance);
}
}
public void deleteInstance(final ChoreographyInstance choreographyInstance) {
if (choreographyInstance != null) {
List<Event> events = eventDAO.findByChoreographyInstancePK(choreographyInstance.getKey());
for (Event event : events) {
eventDAO.delete(event);
}
choreographyInstanceDAO.delete(choreographyInstance);
}
}
public void deleteInstance(final String choreographyInstancePK) {
deleteInstance(choreographyInstanceDAO.findById(choreographyInstancePK));
}
}
......@@ -24,6 +24,7 @@ import eu.chorevolution.idm.common.to.CoordinationDelegateTO;
import eu.chorevolution.idm.common.to.OperationDataTO;
import eu.chorevolution.idm.common.to.ServiceTO;
import java.util.List;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
......@@ -140,4 +141,12 @@ public interface ConsoleInterfaceService extends JAXRSService {
List<AVGOperationDataTO> averageOperationList(
@PathParam("choreographyId") String choreographyId,
@PathParam("cdName") String cdName);
@Path("choreography/{choreographyId}")
@DELETE
void deleteChoreography(@PathParam("choreographyId") String choreographyId);
@Path("instance/{choreographyInstancePK}")
@DELETE
void deleteInstance(@PathParam("choreographyInstancePK") String choreographyInstancePK);
}
......@@ -103,4 +103,14 @@ public class ConsoleInterfaceServiceImpl extends AbstractServiceImpl implements
return logic.averageOperationList(choreographyId, cdName);
}
@Override
public void deleteChoreography(final String choreographyId) {
logic.deleteChoreography(choreographyId);
}
@Override
public void deleteInstance(final String choreographyInstancePK) {
logic.deleteInstance(choreographyInstancePK);
}
}
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