summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/events
diff options
context:
space:
mode:
Diffstat (limited to 'source/com/c2kernel/events')
-rw-r--r--[-rwxr-xr-x]source/com/c2kernel/events/Event.java37
-rw-r--r--[-rwxr-xr-x]source/com/c2kernel/events/History.java32
2 files changed, 35 insertions, 34 deletions
diff --git a/source/com/c2kernel/events/Event.java b/source/com/c2kernel/events/Event.java
index e3ab8b3..18310ce 100755..100644
--- a/source/com/c2kernel/events/Event.java
+++ b/source/com/c2kernel/events/Event.java
@@ -54,13 +54,14 @@ public class Event implements C2KLocalObject
/**
* Set the Event Name, in parameter is a String
*/
- public void setName(String name)
+ @Override
+ public void setName(String name)
{
mName = name;
try {
mID = Integer.parseInt(name);
} catch (NumberFormatException ex) {
- mID = -1;
+ mID = -1;
}
}
@@ -87,7 +88,7 @@ public class Event implements C2KLocalObject
{
mStepType = type;
}
-
+
public void setCurrentState(int state)
{
mCurrentState = state;
@@ -100,7 +101,7 @@ public class Event implements C2KLocalObject
{
mAgentName = agentName;
}
-
+
public void setAgentCentre(String agentCentre)
{
mAgentCentre = agentCentre;
@@ -146,7 +147,8 @@ public class Event implements C2KLocalObject
/**
* Return the Event Name
*/
- public String getName()
+ @Override
+ public String getName()
{
return mName;
}
@@ -174,7 +176,7 @@ public class Event implements C2KLocalObject
{
return mStepType;
}
-
+
public int getCurrentState()
{
return mCurrentState;
@@ -189,7 +191,7 @@ public class Event implements C2KLocalObject
return mAgentCentre+"/"+mAgentName;
return mAgentName;
}
-
+
public String getAgentRole()
{
return mAgentRole;
@@ -212,26 +214,26 @@ public class Event implements C2KLocalObject
{
return Event.timeToString(mTimeStamp);
}
-
+
public static String timeToString(GTimeStamp timeStamp) {
StringBuffer time = new StringBuffer().append(timeStamp.mYear).append("-");
-
+
if (timeStamp.mMonth<10) time.append("0");
time.append(timeStamp.mMonth).append("-");
-
+
if (timeStamp.mDay<10) time.append("0");
time.append(timeStamp.mDay).append(" ");
-
+
if (timeStamp.mHour<10) time.append("0");
time.append(timeStamp.mHour).append(":");
-
+
if (timeStamp.mMinute<10) time.append("0");
time.append(timeStamp.mMinute).append(":");
-
+
if (timeStamp.mSecond<10) time.append("0");
time.append(timeStamp.mSecond);
-
- return time.toString();
+
+ return time.toString();
}
public void setTimeString(String time) throws Exception
@@ -259,11 +261,11 @@ public class Event implements C2KLocalObject
}
-
+
static public GTimeStamp getGMT()
{
java.util.Calendar now = Calendar.getInstance();
-
+
return new GTimeStamp( now.get(Calendar.YEAR),
now.get(Calendar.MONTH)+1,
now.get(Calendar.DAY_OF_MONTH),
@@ -275,6 +277,7 @@ public class Event implements C2KLocalObject
/**
* @see com.c2kernel.entity.C2KLocalObject#getClusterType()
*/
+ @Override
public String getClusterType() {
return ClusterStorage.HISTORY;
}
diff --git a/source/com/c2kernel/events/History.java b/source/com/c2kernel/events/History.java
index bc806dd..a964a72 100755..100644
--- a/source/com/c2kernel/events/History.java
+++ b/source/com/c2kernel/events/History.java
@@ -1,8 +1,6 @@
package com.c2kernel.events;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.lookup.InvalidEntityPathException;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.persistency.RemoteMap;
import com.c2kernel.utils.Logger;
@@ -14,19 +12,18 @@ import com.c2kernel.utils.Logger;
* $Date: 2004/07/21 09:55:11 $
*
* Copyright (C) 2003 CERN - European Organization for Nuclear Research
- * All rights reserved.
+ * All rights reserved.
*/
-public class History extends RemoteMap {
-
+public class History extends RemoteMap<Event> {
+
int lastID = -1;
- public History(int sysKey, Object locker)
- throws ObjectNotFoundException, InvalidEntityPathException {
+ public History(int sysKey, Object locker) {
super(sysKey, ClusterStorage.HISTORY, locker);
}
- public Event addEvent(String agentName, String agentRole,
+ public Event addEvent(String agentName, String agentRole,
int stepTransitionId,
String stepName,
String stepPath,
@@ -45,8 +42,8 @@ public class History extends RemoteMap {
newEvent.setTimeStamp(Event.getGMT());
return storeNewEvent(newEvent);
}
-
- public Event addEvent(String agentName, String agentRole,
+
+ public Event addEvent(String agentName, String agentRole,
int stepTransitionId,
String stepName,
String stepPath,
@@ -66,27 +63,28 @@ public class History extends RemoteMap {
newEvent.setTimeString(timeString);
return storeNewEvent(newEvent);
}
-
+
private Event storeNewEvent(Event newEvent) {
synchronized (this) {
int newEventID = getLastId()+1;
newEvent.setID(newEventID);
if (put(newEvent.getName(), newEvent) != null) {
lastID = newEventID;
- return newEvent;
+ return newEvent;
}
else {
Logger.error("History.addEvent() - Event storage failed!");
return null;
}
- }
+ }
}
-
+
public Event getEvent(int id) {
- return (Event)get(String.valueOf(id));
+ return get(String.valueOf(id));
}
-
- public Object remove(Object key) {
+
+ @Override
+ public Event remove(Object key) {
// forbidden
return null;
}