summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/events
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2014-09-09 12:13:21 +0200
committerAndrew Branson <andrew.branson@cern.ch>2014-09-09 12:13:21 +0200
commitda731d2bb81666b9c697d9099da632e7dfcdc0f7 (patch)
tree567693c3c48f3d15ecbb2dac4f9db03bb6e58c72 /src/main/java/com/c2kernel/events
parentae1e79e33fd30e3d8bcedbef8891a14a048276d7 (diff)
Replaced int sysKey Item identifier with UUID, which is now portable.
ItemPath objects are now used to identify Items throughout the kernel, replacing ints and Integers.
Diffstat (limited to 'src/main/java/com/c2kernel/events')
-rw-r--r--src/main/java/com/c2kernel/events/Event.java54
-rw-r--r--src/main/java/com/c2kernel/events/History.java30
2 files changed, 59 insertions, 25 deletions
diff --git a/src/main/java/com/c2kernel/events/Event.java b/src/main/java/com/c2kernel/events/Event.java
index 37c3c58..267f135 100644
--- a/src/main/java/com/c2kernel/events/Event.java
+++ b/src/main/java/com/c2kernel/events/Event.java
@@ -10,11 +10,16 @@
package com.c2kernel.events;
import java.util.Calendar;
+import java.util.UUID;
import com.c2kernel.common.GTimeStamp;
import com.c2kernel.common.InvalidDataException;
import com.c2kernel.entity.C2KLocalObject;
+import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.InvalidAgentPathException;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
+import com.c2kernel.utils.Logger;
/**
@@ -27,10 +32,10 @@ import com.c2kernel.persistency.ClusterStorage;
*/
public class Event implements C2KLocalObject
{
-
- int mEntitySystemKey, mOriginState, mTransition, mTargetState;
+ ItemPath mItemPath; AgentPath mAgentPath;
+ int mOriginState, mTransition, mTargetState;
Integer mID, mSchemaVersion, mStateMachineVersion;
- String mName, mStepName, mStepPath, mStepType, mSchemaName, mStateMachineName, mViewName, mAgentName, mAgentRole;
+ String mName, mStepName, mStepPath, mStepType, mSchemaName, mStateMachineName, mViewName, mAgentRole;
GTimeStamp mTimeStamp;
public int getOriginState() {
@@ -72,11 +77,38 @@ public class Event implements C2KLocalObject
/**
*/
- public void setEntitySystemKey( int systemKey )
+ public void setItemPath( ItemPath itemPath )
+ {
+ mItemPath = itemPath;
+ }
+
+ public void setItemUUID( String uuid )
{
- mEntitySystemKey = systemKey;
+ setItemPath(new ItemPath(UUID.fromString(uuid)));
+ }
+
+ public String getItemUUID() {
+ return getItemPath().getUUID().toString();
}
+ public void setAgentUUID( String uuid )
+ {
+ if (uuid == null) mAgentPath = null;
+ else
+ try {
+ setAgentPath(new AgentPath(UUID.fromString(uuid)));
+ } catch (InvalidAgentPathException e) {
+ Logger.error("Invalid agent path in Event: "+uuid);
+ }
+ }
+
+ public String getAgentUUID() {
+ if (mAgentPath != null)
+ return getAgentPath().getUUID().toString();
+ else
+ return null;
+ }
+
/**
* Set the Event Name, in parameter is a String
*/
@@ -125,9 +157,9 @@ public class Event implements C2KLocalObject
/**
* Set the AgentInfo in the Event, in parameter is an AgentInfo
*/
- public void setAgentName(String agentName)
+ public void setAgentPath(AgentPath agentPath)
{
- mAgentName = agentName;
+ mAgentPath = agentPath;
}
public void setAgentRole(String agentRole)
@@ -154,9 +186,9 @@ public class Event implements C2KLocalObject
/**
*/
- public int getEntitySystemKey()
+ public ItemPath getItemPath()
{
- return mEntitySystemKey;
+ return mItemPath;
}
/**
@@ -202,9 +234,9 @@ public class Event implements C2KLocalObject
/**
* Return the AgentInfo of the Event.
*/
- public String getAgentName()
+ public AgentPath getAgentPath()
{
- return mAgentName;
+ return mAgentPath;
}
public String getAgentRole()
diff --git a/src/main/java/com/c2kernel/events/History.java b/src/main/java/com/c2kernel/events/History.java
index bf77f40..c7e1ede 100644
--- a/src/main/java/com/c2kernel/events/History.java
+++ b/src/main/java/com/c2kernel/events/History.java
@@ -3,6 +3,8 @@ package com.c2kernel.events;
import com.c2kernel.common.InvalidDataException;
import com.c2kernel.lifecycle.instance.stateMachine.Transition;
+import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.persistency.RemoteMap;
import com.c2kernel.utils.Logger;
@@ -21,20 +23,20 @@ public class History extends RemoteMap<Event> {
int lastID = -1;
- public History(int sysKey, Object locker) {
- super(sysKey, ClusterStorage.HISTORY, locker);
+ public History(ItemPath itemPath, Object locker) {
+ super(itemPath, ClusterStorage.HISTORY, locker);
}
- public Event addEvent(String agentName, String agentRole,
+ public Event addEvent(AgentPath agentPath, String agentRole,
String stepName,
String stepPath,
String stepType,
String stateMachineName,
Integer stateMachineVersion,
Transition transition) {
- return addEvent(agentName, agentRole, stepName, stepPath, stepType, null, null, stateMachineName, stateMachineVersion, transition, null);
+ return addEvent(agentPath, agentRole, stepName, stepPath, stepType, null, null, stateMachineName, stateMachineVersion, transition, null);
}
- public Event addEvent(String agentName, String agentRole,
+ public Event addEvent(AgentPath agentPath, String agentRole,
String stepName,
String stepPath,
String stepType,
@@ -44,10 +46,10 @@ public class History extends RemoteMap<Event> {
Integer stateMachineVersion,
Transition transition,
String viewName) {
- Logger.msg(7, "History.addEvent() - creating new event for "+transition.getName()+" on "+stepName+" in "+mSysKey);
+ Logger.msg(7, "History.addEvent() - creating new event for "+transition.getName()+" on "+stepName+" in "+mItemPath);
Event newEvent = new Event();
- newEvent.setEntitySystemKey(mSysKey);
- newEvent.setAgentName(agentName);
+ newEvent.setItemPath(mItemPath);
+ newEvent.setAgentPath(agentPath);
newEvent.setAgentRole(agentRole);
newEvent.setStepName(stepName);
newEvent.setStepPath(stepPath);
@@ -64,7 +66,7 @@ public class History extends RemoteMap<Event> {
return storeNewEvent(newEvent);
}
- public Event addEvent(String agentName, String agentRole,
+ public Event addEvent(AgentPath agentPath, String agentRole,
String stepName,
String stepPath,
String stepType,
@@ -72,10 +74,10 @@ public class History extends RemoteMap<Event> {
Integer stateMachineVersion,
Transition transition,
String timeString) throws InvalidDataException {
- return addEvent(agentName, agentRole, stepName, stepPath, stepType, null, null, stateMachineName, stateMachineVersion, transition, null, timeString);
+ return addEvent(agentPath, agentRole, stepName, stepPath, stepType, null, null, stateMachineName, stateMachineVersion, transition, null, timeString);
}
- public Event addEvent(String agentName, String agentRole,
+ public Event addEvent(AgentPath agentPath, String agentRole,
String stepName,
String stepPath,
String stepType,
@@ -86,10 +88,10 @@ public class History extends RemoteMap<Event> {
Transition transition,
String viewName,
String timeString) throws InvalidDataException {
- Logger.msg(7, "History.addEvent() - creating new event for "+transition.getName()+" on "+stepName+" in "+mSysKey);
+ Logger.msg(7, "History.addEvent() - creating new event for "+transition.getName()+" on "+stepName+" in "+mItemPath);
Event newEvent = new Event();
- newEvent.setEntitySystemKey(mSysKey);
- newEvent.setAgentName(agentName);
+ newEvent.setItemPath(mItemPath);
+ newEvent.setAgentPath(agentPath);
newEvent.setAgentRole(agentRole);
newEvent.setStepName(stepName);
newEvent.setStepPath(stepPath);