Commit 89868e43 authored by Gianluca Filippone's avatar Gianluca Filippone
Browse files

Changed REST interface and adapted persistence layer to collect choreography events

parent 36c485bc
......@@ -25,38 +25,21 @@ public class ChoreographyInstanceTO extends AbstractBaseBean {
private static final long serialVersionUID = 4829635452545920453L;
private long key;
private Long id;
private String choreographyName;
private long choreographyKey;
private String name;
private String description;
public long getKey() {
return key;
}
public void setKey(final long key) {
this.key = key;
}
public String getChoreographyName() {
return choreographyName;
}
private Long choreographyId;
public void setChoreographyName(final String choreographyName) {
this.choreographyName = choreographyName;
}
public long getChoreographyKey() {
return choreographyKey;
public long getId() {
return id;
}
public void setChoreographyKey(final long choreographyKey) {
this.choreographyKey = choreographyKey;
public void setId(final Long id) {
this.id = id;
}
public String getName() {
......@@ -74,5 +57,13 @@ public class ChoreographyInstanceTO extends AbstractBaseBean {
public void setDescription(final String description) {
this.description = description;
}
public long getChoreographyId() {
return choreographyId;
}
public void setChoreographyId(final Long choreographyId) {
this.choreographyId = choreographyId;
}
}
......@@ -25,18 +25,26 @@ public class ChoreographyTO extends AbstractBaseBean {
private static final long serialVersionUID = 4518569389223742217L;
private long key;
private Long id;
private String name;
private String description;
public long getKey() {
return key;
private byte[] diagram;
private byte[] messageType;
private byte[] image;
private String imageType;
public Long getId() {
return id;
}
public void setKey(final long key) {
this.key = key;
public void setId(final Long id) {
this.id = id;
}
public String getName() {
......@@ -55,4 +63,37 @@ public class ChoreographyTO extends AbstractBaseBean {
this.description = description;
}
public byte[] getDiagram() {
return diagram;
}
public void setDiagram(final byte[] diagram) {
this.diagram = diagram;
}
public byte[] getMessageType() {
return messageType;
}
public void setMessageType(final byte[] messageType) {
this.messageType = messageType;
}
public byte[] getImage() {
return image;
}
public void setImage(final byte[] image) {
this.image = image;
}
public String getImageType() {
return imageType;
}
public void setImageType(final String imageType) {
this.imageType = imageType;
}
}
......@@ -25,14 +25,8 @@ public class CoordinationDelegateTO extends AbstractBaseBean {
private static final long serialVersionUID = -7470302261846306678L;
private long key;
private String name;
private String choreographyInstanceName;
private String choreographyName;
private int executedOperations;
private int sentMessages;
......@@ -41,19 +35,14 @@ public class CoordinationDelegateTO extends AbstractBaseBean {
private long totalOverhead;
private long totalSleepTime;
private long totalWaitTime;
private long startTime;
private long endTime;
public long getKey() {
return key;
}
private Long instanceId;
public void setKey(final long key) {
this.key = key;
}
public String getName() {
return name;
......@@ -63,22 +52,6 @@ public class CoordinationDelegateTO extends AbstractBaseBean {
this.name = name;
}
public String getChoreographyInstanceName() {
return choreographyInstanceName;
}
public void setChoreographyInstanceName(final String choreographyInstanceName) {
this.choreographyInstanceName = choreographyInstanceName;
}
public String getChoreographyName() {
return choreographyName;
}
public void setChoreographyName(final String choreographyName) {
this.choreographyName = choreographyName;
}
public int getExecutedOperations() {
return executedOperations;
}
......@@ -87,14 +60,14 @@ public class CoordinationDelegateTO extends AbstractBaseBean {
this.executedOperations = executedOperations;
}
public void setSentMessages(final int sentMessages) {
this.sentMessages = sentMessages;
}
public int getSentMessages() {
return sentMessages;
}
public void setSentMessages(final int sentMessages) {
this.sentMessages = sentMessages;
}
public long getTotalServiceExecutionTime() {
return totalServiceExecutionTime;
}
......@@ -111,12 +84,12 @@ public class CoordinationDelegateTO extends AbstractBaseBean {
this.totalOverhead = totalOverhead;
}
public long getTotalSleepTime() {
return this.totalSleepTime;
public long getTotalWaitTime() {
return totalWaitTime;
}
public void setTotalSleepTime(final long totalSleepTime) {
this.totalSleepTime = totalSleepTime;
public void setTotalWaitTime(final long totalWaitTime) {
this.totalWaitTime = totalWaitTime;
}
public long getStartTime() {
......@@ -135,4 +108,12 @@ public class CoordinationDelegateTO extends AbstractBaseBean {
this.endTime = endTime;
}
public Long getInstanceId() {
return instanceId;
}
public void setInstanceId(final Long instanceId) {
this.instanceId = instanceId;
}
}
......@@ -40,9 +40,7 @@ public class CDDetailPage extends BaseExtPage {
private final ChoreographyRestClient restClient;
private final String instanceName;
private final String choreographyName;
private final Long instanceId;
private final String cdName;
......@@ -53,13 +51,12 @@ public class CDDetailPage extends BaseExtPage {
restClient = new ChoreographyRestClient();
choreographyName = parameters.get("choreography").toString();
instanceName = parameters.get("instance").toString();
instanceId = parameters.get("instance").toLong();
cdName = parameters.get("cd").toString();
body.add(new Label("header", getString("header_title") + " " + cdName));
List<OperationDataTO> operations = restClient.operationList(choreographyName, instanceName, cdName);
List<OperationDataTO> operations = restClient.operationList(instanceId, cdName);
bundle = new CDStatisticsBundle(operations);
RepeatingView chartList = new RepeatingView("stats");
......@@ -164,12 +161,12 @@ public class CDDetailPage extends BaseExtPage {
for (OperationDataTO current : operations) {
labels.add(current.getName());
overheads.add(current.getOverhead());
sleepTimes.add(current.getSleepTime());
sleepTimes.add(current.getWaitTime());
serviceExecTimes.add(current.getServiceExecTime());
sentMessages.add(current.getMessageNumber());
totalOverhead = totalOverhead + current.getOverhead();
totalSleepTime = totalSleepTime + current.getSleepTime();
totalSleepTime = totalSleepTime + current.getWaitTime();
totalServiceExecTime = totalServiceExecTime + current.getServiceExecTime();
totalSentMessages = totalSentMessages + current.getMessageNumber();
}
......
......@@ -29,13 +29,13 @@ public class InstancePage extends BaseExtPage {
public InstancePage(final PageParameters parameters) {
super(parameters);
//long choreographyId = parameters.get("chor").toLong();
String choreographyName = parameters.get("name").toString();
body.add(new Label("header", getString("header_title") + " of Choreography " + choreographyName));
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(), choreographyName));
content.add(new InstancePanel("instances", getPageReference(), choreographyId));
// Re-enable when entilements for this service will be defined
//MetaDataRoleAuthorizationStrategy.authorize(content, ENABLE, CamelEntitlement.ROUTE_LIST);
......
......@@ -42,9 +42,11 @@ public class InstanceStatsPage extends BaseExtPage {
private final ChoreographyRestClient restClient;
private final String instanceName;
// private final String instanceName;
private final String choreographyName;
// private final String choreographyName;
private final Long instanceId;
private final InstanceStatisticsBundle bundle;
......@@ -53,12 +55,11 @@ public class InstanceStatsPage extends BaseExtPage {
restClient = new ChoreographyRestClient();
choreographyName = parameters.get("choreography").toString();
instanceName = parameters.get("instance").toString();
instanceId = parameters.get("instance").toLong();
body.add(new Label("header", getString("header_title") + " " + instanceName));
body.add(new Label("header", getString("header_title")/* + " " + instanceName*/));
List<CoordinationDelegateTO> cds = restClient.cdList(choreographyName, instanceName);
List<CoordinationDelegateTO> cds = restClient.cdList(instanceId);
bundle = new InstanceStatisticsBundle(cds);
WebMarkupContainer content = new WebMarkupContainer("content");
......@@ -180,7 +181,7 @@ public class InstanceStatsPage extends BaseExtPage {
});
content.add(chartList);
content.add(new CDPanel("cds", getPageReference(), choreographyName, instanceName));
content.add(new CDPanel("cds", getPageReference(), instanceId));
// Re-enable when entilements for this service will be defined
//MetaDataRoleAuthorizationStrategy.authorize(content, ENABLE, CamelEntitlement.ROUTE_LIST);
body.add(content);
......@@ -235,14 +236,14 @@ public class InstanceStatsPage extends BaseExtPage {
labels.add(current.getName());
overheads.add(current.getTotalOverhead());
serviceExecTimes.add(current.getTotalServiceExecutionTime());
sleepTimes.add(current.getTotalSleepTime());
sleepTimes.add(current.getTotalWaitTime());
operations.add(current.getExecutedOperations());
messages.add(current.getSentMessages());
totalMessages = totalMessages + current.getSentMessages();
totalOperations = totalOperations + current.getExecutedOperations();
totalServiceExecution = totalServiceExecution + current.getTotalServiceExecutionTime();
totalOverhead = totalOverhead + current.getTotalOverhead();
totalSleep = totalSleep + current.getTotalSleepTime();
totalSleep = totalSleep + current.getTotalWaitTime();
if (firstStart > current.getStartTime() || firstStart == 0) {
firstStart = current.getStartTime();
......
......@@ -49,12 +49,10 @@ public class CDPanel extends AbstractSearchResultPanel<
private static final long serialVersionUID = 3727444742501082182L;
private String choreographyName;
private String instanceName;
private Long instanceId;
public CDPanel(final String id, final PageReference pageRef,
final String choreographyName, final String instanceName) {
final Long instanceId) {
super(id, new Builder<CoordinationDelegateTO, CoordinationDelegateTO, ChoreographyRestClient>(
new ChoreographyRestClient(), pageRef) {
......@@ -67,8 +65,7 @@ public class CDPanel extends AbstractSearchResultPanel<
}
}.disableCheckBoxes());
this.choreographyName = choreographyName;
this.instanceName = instanceName;
this.instanceId = instanceId;
setFooterVisibility(true);
modal.addSumbitButton();
......@@ -106,7 +103,7 @@ public class CDPanel extends AbstractSearchResultPanel<
"executedOperations"));
columns.add(new PropertyColumn<>(new ResourceModel("sentMessages", "Sent Messages"), "sentMessages"));
columns.add(new PropertyColumn<>(new ResourceModel("totalOverhead", "Overhead (ms)"), "totalOverhead"));
columns.add(new PropertyColumn<>(new ResourceModel("totalSleepTime", "Sleep Time (ms)"), "totalSleepTime"));
columns.add(new PropertyColumn<>(new ResourceModel("totalWaitTime", "Wait Time (ms)"), "totalWaitTime"));
columns.add(new AbstractColumn<CoordinationDelegateTO, String>(new ResourceModel("actions", "")) {
private static final long serialVersionUID = -3503023501954863131L;
......@@ -128,8 +125,7 @@ public class CDPanel extends AbstractSearchResultPanel<
@Override
public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
PageParameters param = new PageParameters();
param.add("choreography", choreographyName);
param.add("instance", instanceName);
param.add("instance", instanceId);
param.add("cd", model.getObject().getName());
setResponsePage(CDDetailPage.class, param);
}
......@@ -155,14 +151,14 @@ public class CDPanel extends AbstractSearchResultPanel<
@Override
public Iterator<CoordinationDelegateTO> iterator(final long first, final long count) {
List<CoordinationDelegateTO> list = restClient.cdList(choreographyName, instanceName);
List<CoordinationDelegateTO> list = restClient.cdList(instanceId);
Collections.sort(list, comparator);
return list.subList((int) first, (int) first + (int) count).iterator();
}
@Override
public long size() {
return restClient.cdList(choreographyName, instanceName).size();
return restClient.cdList(instanceId).size();
}
@Override
......
......@@ -117,8 +117,7 @@ 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("name", model.getObject().getName());
param.add("chor", model.getObject().getId());
setResponsePage(InstancePage.class, param);
}
}, ActionLink.ActionType.SEARCH);
......
......@@ -49,9 +49,9 @@ public class InstancePanel extends AbstractSearchResultPanel<
private static final long serialVersionUID = 3727444742501082182L;
private String choreographyName;
private Long choreographyId;
public InstancePanel(final String id, final PageReference pageRef, final String choreographyName) {
public InstancePanel(final String id, final PageReference pageRef, final Long choreographyId) {
super(id, new Builder<ChoreographyInstanceTO, ChoreographyInstanceTO, ChoreographyRestClient>(
new ChoreographyRestClient(), pageRef) {
......@@ -63,7 +63,7 @@ public class InstancePanel extends AbstractSearchResultPanel<
}
}.disableCheckBoxes());
this.choreographyName = choreographyName;
this.choreographyId = choreographyId;
setFooterVisibility(true);
modal.addSumbitButton();
......@@ -121,8 +121,7 @@ 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());
param.add("instance", model.getObject().getId());
setResponsePage(InstanceStatsPage.class, param);
}
}, ActionLink.ActionType.SEARCH);
......@@ -147,14 +146,14 @@ public class InstancePanel extends AbstractSearchResultPanel<
@Override
public Iterator<ChoreographyInstanceTO> iterator(final long first, final long count) {
List<ChoreographyInstanceTO> list = restClient.instanceList(choreographyName);
List<ChoreographyInstanceTO> list = restClient.instanceList(choreographyId);
Collections.sort(list, comparator);
return list.subList((int) first, (int) first + (int) count).iterator();
}
@Override
public long size() {
return restClient.instanceList(choreographyName).size();
return restClient.instanceList(choreographyId).size();
}
@Override
......
......@@ -32,18 +32,17 @@ public class ChoreographyRestClient extends BaseRestClient {
return getService(ConsoleInterfaceService.class).choreographyList();
}
public List<ChoreographyInstanceTO> instanceList(final String choreographyName) {
return getService(ConsoleInterfaceService.class).instanceList(choreographyName);
public List<ChoreographyInstanceTO> instanceList(final Long choreographyId) {
return getService(ConsoleInterfaceService.class).instanceList(choreographyId);
}
public List<CoordinationDelegateTO> cdList(final String choreographyName, final String instanceName) {
return getService(ConsoleInterfaceService.class).cdList(choreographyName, instanceName);
public List<CoordinationDelegateTO> cdList(final Long instanceId) {
return getService(ConsoleInterfaceService.class).cdList(instanceId);
}
public List<OperationDataTO> operationList(
final String choreographyName,
final String instanceName,
final Long instanceId,
final String cdName) {
return getService(ConsoleInterfaceService.class).operationList(choreographyName, instanceName, cdName);
return getService(ConsoleInterfaceService.class).operationList(instanceId, cdName);
}
}
/*
* 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 eu.chorevolution.idm.common.to;
import org.apache.syncope.common.lib.AbstractBaseBean;
public class ChoreographyDataTO extends AbstractBaseBean {
private static final long serialVersionUID = 3720573261603720603L;
private String choreographyName;
private String instanceName;
private String cdName;
private String operationName;
private long timestamp;
public String getChoreographyName() {
return choreographyName;
}
public void setChoreographyName(final String choreographyName) {
this.choreographyName = choreographyName;
}
public String getInstanceName() {
return instanceName;
}
public void setInstanceName(final String instanceName) {
this.instanceName = instanceName;
}
public String getCdName() {
return cdName;
}
public void setCdName(final String cdName) {
this.cdName = cdName;
}
public String getOperationName() {
return operationName;
}
public void setOperationName(final String operationName) {
this.operationName = operationName;
}
public long getTimestamp() {