diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2012-05-30 08:37:45 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2012-05-30 08:37:45 +0200 |
| commit | b086f57f56bf0eb9dab9cf321a0f69aaaae84347 (patch) | |
| tree | 8e6e26e8b7eed6abad7a17b093bdbb55c5e6b1ba /source/com/c2kernel/events | |
| parent | 22088ae8d2d5ff390518dbe1c4372325ffb3a647 (diff) | |
Initial Maven Conversion
Diffstat (limited to 'source/com/c2kernel/events')
| -rw-r--r-- | source/com/c2kernel/events/Event.java | 276 | ||||
| -rw-r--r-- | source/com/c2kernel/events/History.java | 87 |
2 files changed, 0 insertions, 363 deletions
diff --git a/source/com/c2kernel/events/Event.java b/source/com/c2kernel/events/Event.java deleted file mode 100644 index b52ac7a..0000000 --- a/source/com/c2kernel/events/Event.java +++ /dev/null @@ -1,276 +0,0 @@ -/*
- * $Revision: 1.13 $
- *
- * $Date: 2004/11/22 09:12:28 $
- *
- * Copyright (C) 2001 CERN - European Organization for Nuclear Research
- * All rights reserved.
- */
-
-package com.c2kernel.events;
-
-import java.util.Calendar;
-
-import com.c2kernel.common.GTimeStamp;
-import com.c2kernel.entity.C2KLocalObject;
-import com.c2kernel.persistency.ClusterStorage;
-
-
-/**
- * The data structure of events, which are passed over the event service.
- *
- * Events are incrementaly numbered objects maintained by the History.
- *
- * @version $Revision: 1.13 $ $Date: 2004/11/22 09:12:28 $
- * @author $Author: abranson $
- */
-public class Event implements C2KLocalObject
-{
-
- int mID, mEntitySystemKey, mCurrentState, mTransition;
- String mName, mStepName, mStepPath, mStepType, mAgentName, mAgentRole;
- GTimeStamp mTimeStamp;
-
- public void setID( int id ) {
- mID = id;
- mName = String.valueOf(id);
- }
-
- /**
- */
- public void setEntitySystemKey( int systemKey )
- {
- mEntitySystemKey = systemKey;
- }
-
- /**
- * Set the Event Name, in parameter is a String
- */
- @Override
- public void setName(String name)
- {
- mName = name;
- try {
- mID = Integer.parseInt(name);
- } catch (NumberFormatException ex) {
- mID = -1;
- }
- }
-
- /**
- * Set the StepPath of the Event, in parameter is a String
- */
- public void setStepName(String name)
- {
- mStepName = name;
- }
-
- /**
- * Set the StepPath of the Event, in parameter is a String
- */
- public void setStepPath(String path)
- {
- mStepPath = path;
- }
-
- /**
- * Set the StepType of the Event, in parameter is a String
- */
- public void setStepType(String type)
- {
- mStepType = type;
- }
-
- public void setCurrentState(int state)
- {
- mCurrentState = state;
- }
-
- /**
- * Set the AgentInfo in the Event, in parameter is an AgentInfo
- */
- public void setAgentName(String agentName)
- {
- mAgentName = agentName;
- }
-
- public void setAgentRole(String agentRole)
- {
- mAgentRole = agentRole;
- }
-
- /**
- * Set the TimeStamp in the Event, in parameter is an GTimeStamp
- */
- public void setTimeStamp(GTimeStamp inTimeStamp)
- {
- mTimeStamp = inTimeStamp;
- }
-
-
- /**
- * Return the Event's ID
- */
- public int getID()
- {
- return mID;
- }
-
- /**
- */
- public int getEntitySystemKey()
- {
- return mEntitySystemKey;
- }
-
- /**
- * Return the Event Name
- */
- @Override
- public String getName()
- {
- return mName;
- }
-
- /**
- * Return the StepPath of the Event.
- */
- public String getStepName()
- {
- return mStepName;
- }
-
- /**
- * Return the StepPath of the Event.
- */
- public String getStepPath()
- {
- return mStepPath;
- }
-
- /**
- * Return the StepPath of the Event.
- */
- public String getStepType()
- {
- return mStepType;
- }
-
- public int getCurrentState()
- {
- return mCurrentState;
- }
-
- /**
- * Return the AgentInfo of the Event.
- */
- public String getAgentName()
- {
- return mAgentName;
- }
-
- public String getAgentRole()
- {
- return mAgentRole;
- }
-
- /**
- * Return the Event's TimeStamp.
- */
- public GTimeStamp getTimeStamp()
- {
- return mTimeStamp;
- }
-
- /**
- * Return the TimeStamp in a form that will
- * convert nicely to a String
- * YYYY-MM-DD HH:MI:SS
- */
- public String getTimeString()
- {
- 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();
- }
-
- public void setTimeString(String time) throws Exception
- {
- if (time.length() == 19)
- mTimeStamp = new GTimeStamp(
- Integer.parseInt(time.substring(0,4)),
- Integer.parseInt(time.substring(5,7)),
- Integer.parseInt(time.substring(8,10)),
- Integer.parseInt(time.substring(11,13)),
- Integer.parseInt(time.substring(14,16)),
- Integer.parseInt(time.substring(17,19)),
- Calendar.getInstance().get(Calendar.ZONE_OFFSET));
- else if (time.length() == 14) // support for some sql formats
- mTimeStamp = new GTimeStamp(
- Integer.parseInt(time.substring(0,4)),
- Integer.parseInt(time.substring(4,6)),
- Integer.parseInt(time.substring(6,8)),
- Integer.parseInt(time.substring(8,10)),
- Integer.parseInt(time.substring(10,12)),
- Integer.parseInt(time.substring(12,14)),
- Calendar.getInstance().get(Calendar.ZONE_OFFSET));
- else
- throw new Exception("Unknown time format: "+time);
- }
-
-
-
- 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),
- now.get(Calendar.HOUR_OF_DAY),
- now.get(Calendar.MINUTE),
- now.get(Calendar.SECOND),
- now.get(Calendar.ZONE_OFFSET) );
- }
- /**
- * @see com.c2kernel.entity.C2KLocalObject#getClusterType()
- */
- @Override
- public String getClusterType() {
- return ClusterStorage.HISTORY;
- }
-
- /**
- * @return
- */
- public int getTransition() {
- return mTransition;
- }
-
- /**
- * @param i
- */
- public void setTransition(int i) {
- mTransition = i;
- }
-
-}
diff --git a/source/com/c2kernel/events/History.java b/source/com/c2kernel/events/History.java deleted file mode 100644 index 868eaea..0000000 --- a/source/com/c2kernel/events/History.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.c2kernel.events;
-
-
-import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.persistency.RemoteMap;
-import com.c2kernel.utils.Logger;
-
-/**
- * @author Andrew Branson
- *
- * $Revision: 1.20 $
- * $Date: 2004/07/21 09:55:11 $
- *
- * Copyright (C) 2003 CERN - European Organization for Nuclear Research
- * All rights reserved.
- */
-
-public class History extends RemoteMap<Event> {
-
- int lastID = -1;
-
- public History(int sysKey, Object locker) {
- super(sysKey, ClusterStorage.HISTORY, locker);
- }
-
- public Event addEvent(String agentName, String agentRole,
- int stepTransitionId,
- String stepName,
- String stepPath,
- String stepType,
- int stepCurrentState) {
- Logger.msg(7, "History.addEvent() - creating new event for "+stepTransitionId+" on "+stepName+" in "+mSysKey);
- Event newEvent = new Event();
- newEvent.setEntitySystemKey(mSysKey);
- newEvent.setAgentName(agentName);
- newEvent.setAgentRole(agentRole);
- newEvent.setTransition(stepTransitionId);
- newEvent.setStepName(stepName);
- newEvent.setStepPath(stepPath);
- newEvent.setStepType(stepType);
- newEvent.setCurrentState(stepCurrentState);
- newEvent.setTimeStamp(Event.getGMT());
- return storeNewEvent(newEvent);
- }
-
- public Event addEvent(String agentName, String agentRole,
- int stepTransitionId,
- String stepName,
- String stepPath,
- String stepType,
- int stepCurrentState,
- String timeString) throws Exception {
- Logger.msg(7, "History.addEvent() - creating new event for "+stepTransitionId+" on "+stepName+" in "+mSysKey);
- Event newEvent = new Event();
- newEvent.setEntitySystemKey(mSysKey);
- newEvent.setAgentName(agentName);
- newEvent.setAgentRole(agentRole);
- newEvent.setTransition(stepTransitionId);
- newEvent.setStepName(stepName);
- newEvent.setStepPath(stepPath);
- newEvent.setStepType(stepType);
- newEvent.setCurrentState(stepCurrentState);
- newEvent.setTimeString(timeString);
- return storeNewEvent(newEvent);
- }
-
- private Event storeNewEvent(Event newEvent) {
- synchronized (this) {
- int newEventID = getLastId()+1;
- newEvent.setID(newEventID);
- put(newEvent.getName(), newEvent);
- lastID = newEventID;
- return newEvent;
- }
- }
-
- public Event getEvent(int id) {
- return get(String.valueOf(id));
- }
-
- @Override
- public Event remove(Object key) {
- // forbidden
- return null;
- }
-
-}
|
