Commit 1cef98de authored by Gianluca Filippone's avatar Gianluca Filippone
Browse files

Added code for logic functions implementation

parent 00dc34d0
......@@ -15,7 +15,6 @@
*/
package eu.chorevolution.idm.common.to;
import javax.ws.rs.PathParam;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.apache.syncope.common.lib.AbstractBaseBean;
......@@ -28,6 +27,8 @@ public class ChoreographyInstanceTO extends AbstractBaseBean {
private long key;
private String choreographyName;
private long choreographyKey;
private String name;
......@@ -38,11 +39,18 @@ public class ChoreographyInstanceTO extends AbstractBaseBean {
return key;
}
@PathParam("key")
public void setKey(final long key) {
this.key = key;
}
public String getChoreographyName() {
return choreographyName;
}
public void setChoreographyName(final String choreographyName) {
this.choreographyName = choreographyName;
}
public long getChoreographyKey() {
return choreographyKey;
}
......
......@@ -15,7 +15,6 @@
*/
package eu.chorevolution.idm.common.to;
import javax.ws.rs.PathParam;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.apache.syncope.common.lib.AbstractBaseBean;
......@@ -36,7 +35,6 @@ public class ChoreographyTO extends AbstractBaseBean {
return key;
}
@PathParam("key")
public void setKey(final long key) {
this.key = key;
}
......
......@@ -15,7 +15,6 @@
*/
package eu.chorevolution.idm.common.to;
import javax.ws.rs.PathParam;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.apache.syncope.common.lib.AbstractBaseBean;
......@@ -32,6 +31,8 @@ public class CoordinationDelegateTO extends AbstractBaseBean {
private String choreographyInstanceName;
private String choreographyName;
private int executedOperations;
private int sentMessages;
......@@ -40,7 +41,6 @@ public class CoordinationDelegateTO extends AbstractBaseBean {
private long totalOverhead;
@PathParam("key")
public long getKey() {
return key;
}
......@@ -65,6 +65,14 @@ public class CoordinationDelegateTO extends AbstractBaseBean {
this.choreographyInstanceName = choreographyInstanceName;
}
public String getChoreographyName() {
return choreographyName;
}
public void setChoreographyName(final String choreographyName) {
this.choreographyName = choreographyName;
}
public int getExecutedOperations() {
return executedOperations;
}
......
......@@ -29,13 +29,13 @@ public class InstancePage extends BaseExtPage {
public InstancePage(final PageParameters parameters) {
super(parameters);
long choreographyId = parameters.get("chor").toLong();
//long choreographyId = parameters.get("chor").toLong();
String choreographyName = parameters.get("name").toString();
body.add(new Label("header", getString("header_title") + " of Choreography " + choreographyName));
WebMarkupContainer content = new WebMarkupContainer("content");
content.setOutputMarkupId(true);
content.add(new InstancePanel("instances", getPageReference(), choreographyId));
content.add(new InstancePanel("instances", getPageReference(), choreographyName));
// Re-enable when entilements for this service will be defined
//MetaDataRoleAuthorizationStrategy.authorize(content, ENABLE, CamelEntitlement.ROUTE_LIST);
......
......@@ -42,6 +42,8 @@ public class InstanceStatsPage extends BaseExtPage {
private final String instanceName;
private final String choreographyName;
private final StatisticBundle bundle;
public InstanceStatsPage(final PageParameters parameters) {
......@@ -49,10 +51,12 @@ public class InstanceStatsPage extends BaseExtPage {
restClient = new ChoreographyRestClient();
choreographyName = parameters.get("choreography").toString();
instanceName = parameters.get("instance").toString();
body.add(new Label("header", getString("header_title") + " " + instanceName));
List<CoordinationDelegateTO> cds = restClient.cdList(instanceName);
List<CoordinationDelegateTO> cds = restClient.cdList(choreographyName, instanceName);
bundle = new StatisticBundle(cds);
RepeatingView chartList = new RepeatingView("stats");
......@@ -77,7 +81,8 @@ public class InstanceStatsPage extends BaseExtPage {
bar.getData().getDatasets().add(overheadDataSet);
bar.getData().getDatasets().add(new BarDataSet(bundle.meanExecTimes));
add(new BarChartPanel("chart", Model.of(bar)));
add(new Label("title", getString("cd_overhead_title")));
add(new Label("title", getString("chart_cd_overhead_title")));
add(new Label("caption", getString("chart_cd_overhead_caption")));
}
});
//Operations executed and sent messages per CD
......@@ -102,7 +107,8 @@ public class InstanceStatsPage extends BaseExtPage {
bar.getData().getDatasets().add(new BarDataSet(bundle.messages));
add(new BarChartPanel("chart", Model.of(bar)));
add(new Label("title", getString("cd_operations_title")));
add(new Label("title", getString("chart_cd_operations_title")));
add(new Label("caption", getString("chart_cd_operations_caption")));
}
});
//Total task execution time and total overhead
......@@ -128,7 +134,8 @@ public class InstanceStatsPage extends BaseExtPage {
(int) overhead, "#F7464A", getString("overhead") + ": " + overhead
));
add(new DoughnutChartPanel("chart", Model.of(doughnut)));
add(new Label("title", getString("overhead_title")));
add(new Label("title", getString("chart_total_overhead_title")));
add(new Label("caption", getString("chart_total_overhead_title")));
}
});
//Total executed operations and sent messages
......@@ -155,7 +162,8 @@ public class InstanceStatsPage extends BaseExtPage {
getString("executed_operations") + ": " + bundle.totalOperations
));
add(new DoughnutChartPanel("chart", Model.of(doughnut)));
add(new Label("title", getString("message_op_title")));
add(new Label("title", getString("chart_total_operations_title")));
add(new Label("caption", getString("chart_total_operations_title")));
}
});
body.add(chartList);
......
......@@ -92,7 +92,7 @@ public class ChoreographyPanel extends AbstractSearchResultPanel<
@Override
protected List<IColumn<ChoreographyTO, String>> getColumns() {
final List<IColumn<ChoreographyTO, String>> columns = new ArrayList<>();
columns.add(new PropertyColumn<>(new ResourceModel("key"), "key", "key"));
//columns.add(new PropertyColumn<>(new ResourceModel("key"), "key", "key"));
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", "")) {
......@@ -117,27 +117,11 @@ public class ChoreographyPanel extends AbstractSearchResultPanel<
@Override
public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
PageParameters param = new PageParameters();
param.add("chor", model.getObject().getKey());
//param.add("chor", model.getObject().getKey());
param.add("name", model.getObject().getName());
setResponsePage(InstancePage.class, param);
}
}, ActionLink.ActionType.SEARCH);
actionLinks.add(new ActionLink<Serializable>() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
}
}, ActionLink.ActionType.EDIT);
actionLinks.add(new ActionLink<Serializable>() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
}
}, ActionLink.ActionType.EXECUTE);
item.add(actionLinks.build(componentId));
}
});
......
......@@ -49,9 +49,9 @@ public class InstancePanel extends AbstractSearchResultPanel<
private static final long serialVersionUID = 3727444742501082182L;
private long choreographyId;
private String choreographyName;
public InstancePanel(final String id, final PageReference pageRef, final long choreographyId) {
public InstancePanel(final String id, final PageReference pageRef, final String choreographyName) {
super(id, new Builder<ChoreographyInstanceTO, ChoreographyInstanceTO, ChoreographyRestClient>(
new ChoreographyRestClient(), pageRef) {
......@@ -63,7 +63,7 @@ public class InstancePanel extends AbstractSearchResultPanel<
}
}.disableCheckBoxes());
this.choreographyId = choreographyId;
this.choreographyName = choreographyName;
setFooterVisibility(true);
modal.addSumbitButton();
......@@ -96,7 +96,7 @@ public class InstancePanel extends AbstractSearchResultPanel<
@Override
protected List<IColumn<ChoreographyInstanceTO, String>> getColumns() {
final List<IColumn<ChoreographyInstanceTO, String>> columns = new ArrayList<>();
columns.add(new PropertyColumn<>(new ResourceModel("key"), "key", "key"));
//columns.add(new PropertyColumn<>(new ResourceModel("key"), "key", "key"));
// columns.add(new PropertyColumn<>(new ResourceModel("choreographyKey", "Choreography Id"), "choreographyKey"));
columns.add(new PropertyColumn<>(new ResourceModel("name"), "name", "name"));
columns.add(new PropertyColumn<>(new ResourceModel("description"), "description", "description"));
......@@ -121,18 +121,11 @@ public class InstancePanel extends AbstractSearchResultPanel<
@Override
public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
PageParameters param = new PageParameters();
param.add("choreography", choreographyName);
param.add("instance", model.getObject().getName());
setResponsePage(InstanceStatsPage.class, param);
}
}, ActionLink.ActionType.SEARCH);
actionLinks.add(new ActionLink<Serializable>() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
}
}, ActionLink.ActionType.EDIT);
item.add(actionLinks.build(componentId));
}
});
......@@ -154,14 +147,14 @@ public class InstancePanel extends AbstractSearchResultPanel<
@Override
public Iterator<ChoreographyInstanceTO> iterator(final long first, final long count) {
List<ChoreographyInstanceTO> list = restClient.instanceList(choreographyId);
List<ChoreographyInstanceTO> list = restClient.instanceList(choreographyName);
Collections.sort(list, comparator);
return list.subList((int) first, (int) first + (int) count).iterator();
}
@Override
public long size() {
return restClient.instanceList(choreographyId).size();
return restClient.instanceList(choreographyName).size();
}
@Override
......
......@@ -31,11 +31,11 @@ public class ChoreographyRestClient extends BaseRestClient {
return getService(ConsoleInterfaceService.class).choreographyList();
}
public List<ChoreographyInstanceTO> instanceList(final long choreographyKey) {
return getService(ConsoleInterfaceService.class).instanceList(choreographyKey);
public List<ChoreographyInstanceTO> instanceList(final String choreographyName) {
return getService(ConsoleInterfaceService.class).instanceList(choreographyName);
}
public List<CoordinationDelegateTO> cdList(final String instanceName) {
return getService(ConsoleInterfaceService.class).cdList(instanceName);
public List<CoordinationDelegateTO> cdList(final String choreographyName, final String instanceName) {
return getService(ConsoleInterfaceService.class).cdList(choreographyName, instanceName);
}
}
......@@ -25,6 +25,7 @@ limitations under the License.
</div>
<div class="box-body">
<div class="chart" wicket:id="chart"/>
<div class="col-md-12" wicket:id="caption"/>
</div>
</div>
</wicket:panel>
......
......@@ -14,12 +14,19 @@
# limitations under the License.
#
title=Chart title
message_op_title=Executed operations & sent messages
executed_operations=Exectued operations
sent_messages=Sent messages
cd_overhead_title=Mean overhead & execution time per CD (in ms)
overhead_title=Total overhead & execution time (in ms)
cd_operations_title=Operations executed & sent messages per CD
execution_time=Execution time
overhead=Overhead
computation_time=Computation time
chart_total_operations_title=Executed operations & sent messages
chart_cd_overhead_title=Mean overhead & execution time per CD (in ms)
chart_total_overhead_title=Total overhead & execution time (in ms)
chart_cd_operations_title=Operations executed & sent messages per CD
chart_total_operations_caption=Executed operations & sent messages
chart_cd_overhead_caption=Mean overhead & execution time per CD (in ms)
chart_total_overhead_caption=Total overhead & execution time (in ms)
chart_cd_operations_caption=Operations executed & sent messages per CD
......@@ -14,12 +14,19 @@
# limitations under the License.
#
title=Titolo del grafico
message_op_title=Operazioni eseguite e messaggi inviati
executed_operations=Operazioni eseguite
sent_messages=Messaggi inviati
cd_overhead_title=Overhead e tempo d'esecuzione medi per CD (in ms)
overhead_title=Overhead e tempo di esecuzione totali (in ms)
cd_operations_title=Operazioni eseguite e messaggi scambiati per CD
execution_time=Tempo di esecuzione
overhead=Overhead
computation_time=Tempo di esecuzione
chart_total_operations_title=Operazioni eseguite e messaggi inviati
chart_cd_overhead_title=Overhead e tempo d'esecuzione medi per CD (in ms)
chart_total_overhead_title=Overhead e tempo di esecuzione totali (in ms)
chart_cd_operations_title=Operazioni eseguite e messaggi scambiati per CD
chart_total_operations_caption=Operazioni eseguite e messaggi inviati
chart_cd_overhead_caption=Overhead e tempo d'esecuzione medi per CD (in ms)
chart_total_overhead_caption=Overhead e tempo di esecuzione totali (in ms)
chart_cd_operations_caption=Operazioni eseguite e messaggi scambiati per CD
......@@ -14,12 +14,19 @@
# limitations under the License.
#
title=T\u00edtulo do gr\u00e1fico
message_op_title=Opera\u00e7\u00f5es executadas e mensagens enviadas
executed_operations=Opera\u00e7\u00f5es executadas
sent_messages=Mensagens enviadas
cd_overhead_title=Overhead e vesez de execu\u00e7\u00e3o m\u00e9dia para CD (em ms)
overhead_title=Overhead e vesez de execu\u00e7\u00e3o total (in ms)
cd_operations_title=Opera\u00e7\u00f5es executadas e mensagens enviadas para CD
execution_time=Vesez de execu\u00e7\u00e3o
overhead=Overhead
computation_time=Vesez de execu\u00e7\u00e3o
chart_total_operations_title=Opera\u00e7\u00f5es executadas e mensagens enviadas
chart_cd_overhead_title=Overhead e vesez de execu\u00e7\u00e3o m\u00e9dia para CD (em ms)
chart_total_overhead_title=Overhead e vesez de execu\u00e7\u00e3o total (in ms)
chart_cd_operations_title=Opera\u00e7\u00f5es executadas e mensagens enviadas para CD
chart_total_operations_caption=Opera\u00e7\u00f5es executadas e mensagens enviadas
chart_cd_overhead_caption=Overhead e vesez de execu\u00e7\u00e3o m\u00e9dia para CD (em ms)
chart_total_overhead_caption=Overhead e vesez de execu\u00e7\u00e3o total (in ms)
chart_cd_operations_caption=Opera\u00e7\u00f5es executadas e mensagens enviadas para CD
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.syncope.common.lib.to;
package eu.choreovolution.idm.common.to;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.syncope.common.lib.to;
package eu.choreovolution.idm.common.to;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.syncope.common.lib.to;
package eu.choreovolution.idm.common.to;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.syncope.common.lib.to;
package eu.choreovolution.idm.common.to;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.syncope.common.lib.to;
package eu.choreovolution.idm.common.to;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
......
......@@ -40,12 +40,23 @@ limitations under the License.
<artifactId>syncope-core-logic</artifactId>
<version>${syncope.version}</version>
</dependency>
<dependency>
<groupId>eu.chorevolution.idm</groupId>
<artifactId>common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>eu.chorevolution.idm.ext.choreography</groupId>
<artifactId>syncope-ext-choreography-common-lib</artifactId>
<version>${project.version}</version>
</dependency>
<!--<dependency>
<groupId>org.apache.syncope.ext.choreography</groupId>
<artifactId>syncope-ext-choreography-persistence-jpa</artifactId>
<version>${project.version}</version>
</dependency>-->
</dependencies>
<build>
......
......@@ -18,10 +18,34 @@ package org.apache.syncope.core.logic;
import eu.chorevolution.idm.common.to.ChoreographyInstanceTO;
import eu.chorevolution.idm.common.to.ChoreographyTO;
import eu.chorevolution.idm.common.to.CoordinationDelegateTO;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import org.apache.syncope.common.lib.AbstractBaseBean;
/*
import eu.choreovolution.idm.common.to.EndRequestTO;
import eu.choreovolution.idm.common.to.ForwardRequestTO;
import eu.choreovolution.idm.common.to.ForwardResponseTO;
import eu.choreovolution.idm.common.to.NumberCoordMessageTO;
import eu.choreovolution.idm.common.to.StartRequestTO;
import org.apache.syncope.core.persistence.api.dao.EndRequestDAO;
import org.apache.syncope.core.persistence.api.dao.ForwardRequestDAO;
import org.apache.syncope.core.persistence.api.dao.ForwardResponseDAO;
import org.apache.syncope.core.persistence.api.dao.NumberCoordMessageDAO;
import org.apache.syncope.core.persistence.api.dao.StartRequestDAO;
import org.apache.syncope.core.persistence.api.entity.NumberCoordMessage;
import org.apache.syncope.core.persistence.api.entity.TimeData;
import org.apache.syncope.core.persistence.jpa.dao.JPAEndRequestDAO;
import org.apache.syncope.core.persistence.jpa.dao.JPAForwardRequestDAO;
import org.apache.syncope.core.persistence.jpa.dao.JPAForwardResponseDAO;
import org.apache.syncope.core.persistence.jpa.dao.JPANumberCoordMessageDAO;
import org.apache.syncope.core.persistence.jpa.dao.JPAStartRequestDAO;
import org.apache.syncope.core.persistence.jpa.entity.JPAEndRequest;
import org.apache.syncope.core.persistence.jpa.entity.JPAForwardRequest;
import org.apache.syncope.core.persistence.jpa.entity.JPAForwardResponse;
import org.apache.syncope.core.persistence.jpa.entity.JPANumberCoordMessage;
import org.apache.syncope.core.persistence.jpa.entity.JPAStartRequest;*/
import org.springframework.stereotype.Component;
@Component
......@@ -38,141 +62,94 @@ public class MonitorLogic extends AbstractTransactionalLogic<AbstractBaseBean> {
List<ChoreographyTO> result = new ArrayList<>();
ChoreographyTO to = new ChoreographyTO();
to.setKey(1);
/*
* Logic for retreive list of choreographies from DB
StartRequestDAO dao = new JPAStartRequestDAO();
List<String> availableRequests = dao.findChoreographiesNames();
List<ChoreographyTO> availableChoreographies = new ArrayList<>();
for (String currentName: availableRequests) {
to.setName(currentName);
to.setDescription("No description available");
availableChoreographies.add(to);
}
return availableChoreographies;
*/
//to.setKey(1);
to.setDescription("Description of choreography 1");
to.setName("Choreography 1");
result.add(to);
to = new ChoreographyTO();
to.setKey(2);
//to.setKey(2);
to.setDescription("Description of choreography 2");
to.setName("Choreography 2");
result.add(to);
to = new ChoreographyTO();
to.setKey(3);
//to.setKey(3);
to.setDescription("Description of choreography 3");
to.setName("Choreography 3");
result.add(to);
to = new ChoreographyTO();
to.setKey(4);
//to.setKey(4);
to.setDescription("Description of choreography 4");
to.setName("Choreography 4");
result.add(to);
return result;
return result;
}
/**
* This method returns a list of all instances of given choreography
*
* @param choreographyName
* @param chor
* @return List<ChoreographyInstanceTO>
*/
public List<ChoreographyInstanceTO> instanceList(final long chor) {
public List<ChoreographyInstanceTO> instanceList(final String choreographyName) {
List<ChoreographyInstanceTO> result = new ArrayList<>();
List<ChoreographyInstanceTO> generated = instanceGenerator();
for (ChoreographyInstanceTO current: generated) {
if (current.getChoreographyKey() == chor) {
result.add(current);
}
}
return result;
}
// This is a temporary method, it simulates the recovering of all running instances from db
public List<ChoreographyInstanceTO> instanceGenerator() {
List<ChoreographyInstanceTO> result = new ArrayList<>();