summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2013-01-31 21:02:47 +0100
committerAndrew Branson <andrew.branson@cern.ch>2013-01-31 21:02:47 +0100
commit9dbce79cb5798feb92c4862e694ceeb8799ba284 (patch)
treec10e8c3fe3c0032051a0810a08eb0a742c0c9889
parent1047226fc3fe1bf42dced7c8afc2ccc6f441657a (diff)
Added ViewName field to Event. Filled in with the Viewpoint name if
specified in the Activity properties, making it possible to derive previous states of the Viewpoint. Closes #96 Cleanup outcome storing code. Throw an exception if SchemaType filled in and outcome is empty.
-rw-r--r--src/main/java/com/c2kernel/events/Event.java18
-rw-r--r--src/main/java/com/c2kernel/events/History.java4
-rw-r--r--src/main/java/com/c2kernel/lifecycle/instance/Activity.java19
-rw-r--r--src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java2
-rw-r--r--src/main/java/com/c2kernel/process/Bootstrap.java2
-rw-r--r--src/main/resources/mapFiles/HistoryMap.xml5
6 files changed, 37 insertions, 13 deletions
diff --git a/src/main/java/com/c2kernel/events/Event.java b/src/main/java/com/c2kernel/events/Event.java
index b52ac7a..9936f49 100644
--- a/src/main/java/com/c2kernel/events/Event.java
+++ b/src/main/java/com/c2kernel/events/Event.java
@@ -27,8 +27,8 @@ import com.c2kernel.persistency.ClusterStorage;
public class Event implements C2KLocalObject
{
- int mID, mEntitySystemKey, mCurrentState, mTransition;
- String mName, mStepName, mStepPath, mStepType, mAgentName, mAgentRole;
+ int mID, mEntitySystemKey, mCurrentState, mTransition;
+ String mName, mStepName, mStepPath, mStepType, mViewName, mAgentName, mAgentRole;
GTimeStamp mTimeStamp;
public void setID( int id ) {
@@ -80,6 +80,13 @@ public class Event implements C2KLocalObject
{
mStepType = type;
}
+
+ /**
+ * @param viewName the viewName to set
+ */
+ public void setViewName(String viewName) {
+ this.mViewName = viewName;
+ }
public void setCurrentState(int state)
{
@@ -155,6 +162,13 @@ public class Event implements C2KLocalObject
{
return mStepType;
}
+
+ /**
+ * @return the mViewName
+ */
+ public String getViewName() {
+ return mViewName;
+ }
public int getCurrentState()
{
diff --git a/src/main/java/com/c2kernel/events/History.java b/src/main/java/com/c2kernel/events/History.java
index 868eaea..88f5460 100644
--- a/src/main/java/com/c2kernel/events/History.java
+++ b/src/main/java/com/c2kernel/events/History.java
@@ -28,6 +28,7 @@ public class History extends RemoteMap<Event> {
String stepName,
String stepPath,
String stepType,
+ String viewName,
int stepCurrentState) {
Logger.msg(7, "History.addEvent() - creating new event for "+stepTransitionId+" on "+stepName+" in "+mSysKey);
Event newEvent = new Event();
@@ -38,6 +39,7 @@ public class History extends RemoteMap<Event> {
newEvent.setStepName(stepName);
newEvent.setStepPath(stepPath);
newEvent.setStepType(stepType);
+ newEvent.setViewName(viewName);
newEvent.setCurrentState(stepCurrentState);
newEvent.setTimeStamp(Event.getGMT());
return storeNewEvent(newEvent);
@@ -48,6 +50,7 @@ public class History extends RemoteMap<Event> {
String stepName,
String stepPath,
String stepType,
+ String viewName,
int stepCurrentState,
String timeString) throws Exception {
Logger.msg(7, "History.addEvent() - creating new event for "+stepTransitionId+" on "+stepName+" in "+mSysKey);
@@ -59,6 +62,7 @@ public class History extends RemoteMap<Event> {
newEvent.setStepName(stepName);
newEvent.setStepPath(stepPath);
newEvent.setStepType(stepType);
+ newEvent.setViewName(viewName);
newEvent.setCurrentState(stepCurrentState);
newEvent.setTimeString(timeString);
return storeNewEvent(newEvent);
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java b/src/main/java/com/c2kernel/lifecycle/instance/Activity.java
index c91a270..38ed626 100644
--- a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java
+++ b/src/main/java/com/c2kernel/lifecycle/instance/Activity.java
@@ -510,21 +510,21 @@ public class Activity extends WfVertex
} // empty joblist then
return jobs;
}
- //
- //methods written by kovax
- //
+
+
/** Adds an event to the AuditTrail of the Item if any */
- private Event auditEvent(int transitionID, AgentPath agent)
+ private Event auditEvent(int transitionID, AgentPath agent, boolean hasOutcome)
{
EntityPath entityPath = getItemEntityPath();
if (entityPath != null)
{
Event event = null;
History hist = null;
+ String viewName = hasOutcome?(String)getProperties().get("Viewpoint"):null;
try
{
hist = (History) Gateway.getStorage().get(entityPath.getSysKey(), ClusterStorage.HISTORY, this);
- event = hist.addEvent(agent.getAgentName(), getCurrentAgentRole(), transitionID, getName(), getPath(), getType(), getCurrentState());
+ event = hist.addEvent(agent.getAgentName(), getCurrentAgentRole(), transitionID, getName(), getPath(), getType(), viewName, getCurrentState());
Logger.msg(7, "Activity::auditEvent() - Event:" + event.getName() + " was added to the AuditTrail");
}
catch (Exception ex)
@@ -542,6 +542,8 @@ public class Activity extends WfVertex
private String storeOutcome(int eventID, String requestData, boolean isError) throws InvalidDataException
{
EntityPath entityPath = getItemEntityPath();
+ if (requestData == null || requestData.length() == 0)
+ throw new InvalidDataException("Empty outcome", "");
if (entityPath != null)
{
String schemaType; int schemaVersion;
@@ -593,11 +595,12 @@ public class Activity extends WfVertex
public void sendEventStoreOutcome(int transitionID, String requestData, AgentPath agent) throws InvalidDataException
{
int eventID = -1;
- Event event = null;
- event = auditEvent(transitionID, agent);
+ String schemaType = (String) getProperties().get("SchemaType");
+ boolean hasOutcome = (transitionID == Transitions.DONE || transitionID == Transitions.COMPLETE || transitionID == Transitions.SUSPEND) && (schemaType != null && schemaType.length() > 0);
+ Event event = auditEvent(transitionID, agent, hasOutcome);
if (event != null)
eventID = event.getID();
- if ((transitionID == Transitions.DONE || transitionID == Transitions.COMPLETE || transitionID == Transitions.SUSPEND) && requestData != null && requestData.length() > 0)
+ if (hasOutcome)
storeOutcome(eventID, requestData, transitionID == Transitions.SUSPEND);
EntityPath entityPath = getItemEntityPath();
TransactionManager storage = Gateway.getStorage();
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java
index caa53e4..3c5a16e 100644
--- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java
+++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java
@@ -92,7 +92,7 @@ public class NewItem extends ModuleImport {
History hist = new History(entPath.getSysKey(), null);
for (Outcome thisOutcome : outcomes) {
- Event newEvent = hist.addEvent("system", "Admin", Transitions.DONE, "Import", "Import", "Import", States.FINISHED);
+ Event newEvent = hist.addEvent("system", "Admin", Transitions.DONE, "Import", "Import", "Import", thisOutcome.viewname.equals("last")?null:thisOutcome.viewname, States.FINISHED);
com.c2kernel.persistency.outcome.Outcome newOutcome = new com.c2kernel.persistency.outcome.Outcome(newEvent.getID(), thisOutcome.getData(ns), thisOutcome.schema, thisOutcome.version);
Viewpoint newLastView = new Viewpoint(entPath.getSysKey(), thisOutcome.schema, thisOutcome.viewname, thisOutcome.version, newEvent.getID());
try {
diff --git a/src/main/java/com/c2kernel/process/Bootstrap.java b/src/main/java/com/c2kernel/process/Bootstrap.java
index ba2280c..0d22cb3 100644
--- a/src/main/java/com/c2kernel/process/Bootstrap.java
+++ b/src/main/java/com/c2kernel/process/Bootstrap.java
@@ -146,7 +146,7 @@ public class Bootstrap
// data was missing or doesn't match
Logger.msg("Bootstrap.verifyResource() - Writing new data to "+getDataType(itemType)+" "+itemName);
History hist = new History(thisProxy.getSystemKey(), thisProxy);
- Event newEvent = hist.addEvent("system", "Admin", Transitions.DONE, "Import", "Import", "Import", States.FINISHED);
+ Event newEvent = hist.addEvent("system", "Admin", Transitions.DONE, "Bootstrap", "Bootstrap", "Bootstrap", null, States.FINISHED);
newOutcome.setID(newEvent.getID());
Viewpoint newLastView = new Viewpoint(thisProxy.getSystemKey(), getDataType(itemType), "last", 0, newEvent.getID());
Viewpoint newZeroView = new Viewpoint(thisProxy.getSystemKey(), getDataType(itemType), "0", 0, newEvent.getID());
diff --git a/src/main/resources/mapFiles/HistoryMap.xml b/src/main/resources/mapFiles/HistoryMap.xml
index 803bf64..7bae1e6 100644
--- a/src/main/resources/mapFiles/HistoryMap.xml
+++ b/src/main/resources/mapFiles/HistoryMap.xml
@@ -17,7 +17,10 @@
</field>
<field name="mStepType" type="string" direct="false" get-method="getStepType" set-method="setStepType">
<bind-xml name="StepType" node="attribute"/>
- </field>
+ </field>
+ <field name="mViewName" type="string" direct="false" get-method="getViewName" set-method="setViewName">
+ <bind-xml name="ViewName" node="attribute"/>
+ </field>
<field name="mCurrentState" type="integer" direct="false" get-method="getCurrentState" set-method="setCurrentState">
<bind-xml name="CurrentState" node="attribute"/>
</field>