From 254ee6f47eebfc00462c10756a92066e82cc1a96 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Tue, 21 Jun 2011 15:46:02 +0200 Subject: Initial commit --- .../c2kernel/persistency/outcome/Viewpoint.java | 176 +++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100755 source/com/c2kernel/persistency/outcome/Viewpoint.java (limited to 'source/com/c2kernel/persistency/outcome/Viewpoint.java') diff --git a/source/com/c2kernel/persistency/outcome/Viewpoint.java b/source/com/c2kernel/persistency/outcome/Viewpoint.java new file mode 100755 index 0000000..7fc2aa5 --- /dev/null +++ b/source/com/c2kernel/persistency/outcome/Viewpoint.java @@ -0,0 +1,176 @@ +package com.c2kernel.persistency.outcome; + +import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.entity.C2KLocalObject; +import com.c2kernel.events.Event; +import com.c2kernel.lookup.Path; +import com.c2kernel.persistency.ClusterStorage; +import com.c2kernel.persistency.ClusterStorageException; +import com.c2kernel.process.Gateway; + +/** + * @author Andrew Branson + * + * $Revision: 1.10 $ + * $Date: 2005/10/05 07:39:36 $ + * + * Copyright (C) 2003 CERN - European Organization for Nuclear Research + * All rights reserved. + */ + +// public static final String codeRevision = +// "$Revision: 1.10 $ $Date: 2005/10/05 07:39:36 $ $Author: abranson $"; +public class Viewpoint implements C2KLocalObject { + + int ID = -1; // not really used in this + + // db fields + int sysKey; + String schemaName; + String name; + int schemaVersion; + int eventId; + public static final int NONE = -1; + + public Viewpoint() { + eventId = NONE; + sysKey = Path.INVALID; + schemaVersion = NONE; + schemaName = null; + name = null; + } + + public Viewpoint(int sysKey, String schemaName, String name, int schemaVersion, int eventId) { + this.sysKey = sysKey; + this.schemaName = schemaName; + this.name = name; + this.schemaVersion = schemaVersion; + this.eventId = eventId; + } + + public Outcome getOutcome() throws ObjectNotFoundException, ClusterStorageException { + if (eventId == NONE) throw new ObjectNotFoundException("No last eventId defined", ""); + Outcome retVal = (Outcome)Gateway.getStorage().get(sysKey, ClusterStorage.OUTCOME+"/"+schemaName+"/"+schemaVersion+"/"+eventId, null); + return retVal; + } + + public String getClusterType() { + return ClusterStorage.VIEWPOINT; + } + + + /** + * Returns the eventId. + * @return int + */ + public int getEventId() { + return eventId; + } + + /** + * Returns the iD. + * @return int + */ + public int getID() { + return ID; + } + + /** + * Returns the name. + * @return String + */ + public String getName() { + return name; + } + + /** + * Returns the schemaName. + * @return String + */ + public String getSchemaName() { + return schemaName; + } + + /** + * Returns the schemaVersion. + * @return int + */ + public int getSchemaVersion() { + return schemaVersion; + } + + /** + * Returns the sysKey. + * @return int + */ + public int getSysKey() { + return sysKey; + } + + /** + * Sets the eventId. + * @param eventId The eventId to set + */ + public void setEventId(int eventId) { + this.eventId = eventId; + } + + /** + * Sets the iD. + * @param iD The iD to set + */ + public void setID(int iD) { + ID = iD; + } + + /** + * Sets the name. + * @param name The name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * Sets the schemaName. + * @param schemaName The schemaName to set + */ + public void setSchemaName(String schemaName) { + this.schemaName = schemaName; + } + + /** + * Sets the schemaVersion. + * @param schemaVersion The schemaVersion to set + */ + public void setSchemaVersion(int schemaVersion) { + this.schemaVersion = schemaVersion; + } + + /** + * Sets the sysKey. + * @param sysKey The sysKey to set + */ + public void setSysKey(int sysKey) { + this.sysKey = sysKey; + } + + /** + * Method getEvent. + * @return GDataRecord + */ + public Event getEvent() + throws InvalidDataException, ClusterStorageException, ObjectNotFoundException + { + if (eventId == NONE) + throw new InvalidDataException("No last eventId defined", ""); + + return (Event)Gateway.getStorage().get(sysKey, ClusterStorage.HISTORY+"/"+eventId, null); + } + + public String toString() { + return name; + } + +} -- cgit v1.2.3