diff options
Diffstat (limited to 'src/main/java/com/c2kernel/persistency/outcome')
6 files changed, 0 insertions, 845 deletions
diff --git a/src/main/java/com/c2kernel/persistency/outcome/Outcome.java b/src/main/java/com/c2kernel/persistency/outcome/Outcome.java deleted file mode 100644 index a8683ab..0000000 --- a/src/main/java/com/c2kernel/persistency/outcome/Outcome.java +++ /dev/null @@ -1,290 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.persistency.outcome;
-import java.io.StringReader;
-import java.util.StringTokenizer;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpression;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.w3c.dom.bootstrap.DOMImplementationRegistry;
-import org.w3c.dom.ls.DOMImplementationLS;
-import org.w3c.dom.ls.LSSerializer;
-import org.xml.sax.InputSource;
-
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.entity.C2KLocalObject;
-import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.utils.LocalObjectLoader;
-import com.c2kernel.utils.Logger;
-
-public class Outcome implements C2KLocalObject {
- Integer mID;
- String mData;
- String mSchemaType;
- int mSchemaVersion;
- Document dom;
- static DocumentBuilder parser;
- static DOMImplementationLS impl;
- static XPath xpath;
-
- static {
- // Set up parser
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- dbf.setValidating(false);
- dbf.setNamespaceAware(false);
- try {
- parser = dbf.newDocumentBuilder();
- } catch (ParserConfigurationException e) {
- Logger.error(e);
- Logger.die("Cannot function without XML parser");
- }
-
- // Set up serialiser
- try {
- DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
- impl = (DOMImplementationLS)registry.getDOMImplementation("LS");
- } catch (Exception e) {
- Logger.error(e);
- Logger.die("Cannot function without XML serialiser");
- }
-
- XPathFactory xPathFactory = XPathFactory.newInstance();
- xpath = xPathFactory.newXPath();
- }
-
- //id is the eventID
- public Outcome(int id, String data, String schemaType, int schemaVersion) {
- mID = id;
- mData = data;
- mSchemaType = schemaType;
- mSchemaVersion = schemaVersion;
- }
-
- public Outcome(String path, String data) throws PersistencyException {
- // derive all the meta data from the path
- StringTokenizer tok = new StringTokenizer(path,"/");
- if (tok.countTokens() != 3 && !(tok.nextToken().equals(ClusterStorage.OUTCOME)))
- throw new PersistencyException("Outcome() - Outcome path must have three components: "+path);
- mSchemaType = tok.nextToken();
- String verstring = tok.nextToken();
- String objId = tok.nextToken();
- try {
- mSchemaVersion = Integer.parseInt(verstring);
- } catch (NumberFormatException ex) {
- throw new PersistencyException("Outcome() - Outcome version was an invalid number: "+verstring);
- }
- try {
- mID = Integer.valueOf(objId);
- } catch (NumberFormatException ex) {
- mID = null;
- }
- mData = data;
- }
-
- public void setID(Integer ID) {
- mID = ID;
- }
-
- public Integer getID() {
- return mID;
- }
-
- @Override
- public void setName(String name) {
- try {
- mID = Integer.valueOf(name);
- } catch (NumberFormatException e) {
- Logger.error("Invalid id set on Outcome:"+name);
- }
- }
-
- @Override
- public String getName() {
- return mID.toString();
- }
-
- public void setData(String data) {
- mData = data;
- dom = null;
- }
-
- public void setData(Document data) {
- dom = data;
- mData = null;
- }
-
- public String getFieldByXPath(String xpath) throws XPathExpressionException, InvalidDataException {
- Node field = getNodeByXPath(xpath);
- if (field == null)
- throw new InvalidDataException(xpath);
-
- else if (field.getNodeType()==Node.TEXT_NODE || field.getNodeType()==Node.CDATA_SECTION_NODE)
- return field.getNodeValue();
-
- else if (field.getNodeType()==Node.ELEMENT_NODE) {
- NodeList fieldChildren = field.getChildNodes();
- if (fieldChildren.getLength() == 0)
- throw new InvalidDataException("No child node for element");
-
- else if (fieldChildren.getLength() == 1) {
- Node child = fieldChildren.item(0);
- if (child.getNodeType()==Node.TEXT_NODE || child.getNodeType()==Node.CDATA_SECTION_NODE)
- return child.getNodeValue();
- else
- throw new InvalidDataException("Can't get data from child node of type "+child.getNodeName());
- }
- else
- throw new InvalidDataException("Element "+xpath+" has too many children");
- }
- else if (field.getNodeType()==Node.ATTRIBUTE_NODE)
- return field.getNodeValue();
- else
- throw new InvalidDataException("Don't know what to do with node "+field.getNodeName());
- }
-
- public void setFieldByXPath(String xpath, String data) throws XPathExpressionException, InvalidDataException {
- Node field = getNodeByXPath(xpath);
- if (field == null)
- throw new InvalidDataException(xpath);
-
- else if (field.getNodeType()==Node.ELEMENT_NODE) {
- NodeList fieldChildren = field.getChildNodes();
- if (fieldChildren.getLength() == 0) {
- field.appendChild(dom.createTextNode(data));
- }
- else if (fieldChildren.getLength() == 1) {
- Node child = fieldChildren.item(0);
- switch (child.getNodeType()) {
- case Node.TEXT_NODE:
- case Node.CDATA_SECTION_NODE:
- child.setNodeValue(data);
- break;
- default:
- throw new InvalidDataException("Can't set child node of type "+child.getNodeName());
- }
- }
- else
- throw new InvalidDataException("Element "+xpath+" has too many children");
- }
- else if (field.getNodeType()==Node.ATTRIBUTE_NODE)
- field.setNodeValue(data);
- else
- throw new InvalidDataException("Don't know what to do with node "+field.getNodeName());
- }
-
-
- public String getData() {
- if (mData == null && dom != null) {
- mData = serialize(dom, false);
- }
- return mData;
- }
-
- public Schema getSchema() throws ObjectNotFoundException {
- return LocalObjectLoader.getSchema(mSchemaType, mSchemaVersion);
- }
-
- public void setSchemaType(String schemaType) {
- mSchemaType = schemaType;
- }
-
- public String getSchemaType() {
- return mSchemaType;
- }
-
- public int getSchemaVersion() {
- return mSchemaVersion;
- }
-
- public void setSchemaVersion(int schVer) {
- mSchemaVersion = schVer;
- }
-
- @Override
- public String getClusterType() {
- return ClusterStorage.OUTCOME;
- }
-
- // special script API methods
-
- /**
- * Parses the outcome into a DOM tree
- * @return a DOM Document
- */
- public Document getDOM() {
- if (dom == null)
- try {
- synchronized (parser) {
- if (mData!=null)
- dom = parser.parse(new InputSource(new StringReader(mData)));
- else
- dom = parser.newDocument();
- }
- } catch (Exception e) {
- Logger.error(e);
- return null;
- }
- return dom;
- }
-
- public String getField(String name) {
- NodeList elements = getDOM().getDocumentElement().getElementsByTagName(name);
- if (elements.getLength() == 1 && elements.item(0).hasChildNodes() && elements.item(0).getFirstChild() instanceof Text)
- return ((Text)elements.item(0).getFirstChild()).getData();
- else
- return null;
- }
-
- public NodeList getNodesByXPath(String xpathExpr) throws XPathExpressionException {
-
- XPathExpression expr = xpath.compile(xpathExpr);
- return (NodeList)expr.evaluate(getDOM(), XPathConstants.NODESET);
-
- }
-
- public Node getNodeByXPath(String xpathExpr) throws XPathExpressionException {
-
- XPathExpression expr = xpath.compile(xpathExpr);
- return (Node)expr.evaluate(getDOM(), XPathConstants.NODE);
-
- }
-
- static public String serialize(Document doc, boolean prettyPrint)
- {
- LSSerializer writer = impl.createLSSerializer();
- writer.getDomConfig().setParameter("format-pretty-print", prettyPrint);
- writer.getDomConfig().setParameter("xml-declaration", false);
- return writer.writeToString(doc);
- }
-}
diff --git a/src/main/java/com/c2kernel/persistency/outcome/OutcomeInitiator.java b/src/main/java/com/c2kernel/persistency/outcome/OutcomeInitiator.java deleted file mode 100644 index e152df9..0000000 --- a/src/main/java/com/c2kernel/persistency/outcome/OutcomeInitiator.java +++ /dev/null @@ -1,30 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.persistency.outcome;
-
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.entity.agent.Job;
-
-public interface OutcomeInitiator {
-
- public String initOutcome(Job job) throws InvalidDataException;
-
-}
diff --git a/src/main/java/com/c2kernel/persistency/outcome/OutcomeValidator.java b/src/main/java/com/c2kernel/persistency/outcome/OutcomeValidator.java deleted file mode 100644 index 80af535..0000000 --- a/src/main/java/com/c2kernel/persistency/outcome/OutcomeValidator.java +++ /dev/null @@ -1,207 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.persistency.outcome;
-
-import java.io.IOException;
-import java.io.StringReader;
-
-import org.apache.xerces.parsers.DOMParser;
-import org.apache.xerces.parsers.IntegratedParserConfiguration;
-import org.apache.xerces.parsers.XMLGrammarPreparser;
-import org.apache.xerces.util.SymbolTable;
-import org.apache.xerces.util.XMLGrammarPoolImpl;
-import org.apache.xerces.xni.XNIException;
-import org.apache.xerces.xni.grammars.XMLGrammarDescription;
-import org.apache.xerces.xni.parser.XMLErrorHandler;
-import org.apache.xerces.xni.parser.XMLInputSource;
-import org.apache.xerces.xni.parser.XMLParseException;
-import org.apache.xerces.xni.parser.XMLParserConfiguration;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.utils.Logger;
-
-/**************************************************************************
- *
- * $Revision: 1.24 $
- * $Date: 2005/06/09 13:50:10 $
- *
- * Copyright (C) 2003 CERN - European Organization for Nuclear Research
- * All rights reserved.
- **************************************************************************/
-
-
-public class OutcomeValidator implements ErrorHandler, XMLErrorHandler {
-
- protected static final String NAMESPACES_FEATURE_ID = "http://xml.org/sax/features/namespaces";
- /** Validation feature id (http://xml.org/sax/features/validation). */
- protected static final String VALIDATION_FEATURE_ID = "http://xml.org/sax/features/validation";
- /** Schema validation feature id (http://apache.org/xml/features/validation/schema). */
- protected static final String SCHEMA_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/schema";
- /** Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking). */
- protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID = "http://apache.org/xml/features/validation/schema-full-checking";
- public static final String GRAMMAR_POOL = "http://apache.org/xml/properties/internal/grammar-pool";
-
- static SchemaValidator schemaValid = new SchemaValidator();
-
- Schema schema;
- protected StringBuffer errors = null;
- XMLGrammarPoolImpl schemaGrammarPool = new XMLGrammarPoolImpl(1);
- SymbolTable sym = new SymbolTable();
-
- public static OutcomeValidator getValidator(Schema schema) throws InvalidDataException {
-
- if (schema.docType.equals("Schema") &&
- schema.docVersion==0)
- return schemaValid;
-
- return new OutcomeValidator(schema);
- }
-
- protected OutcomeValidator() {
- errors = new StringBuffer();
- }
-
- public OutcomeValidator(Schema schema) throws InvalidDataException {
- this.schema = schema;
-
- if (schema.docType.equals("Schema"))
- throw new InvalidDataException("Use SchemaValidator to validate schema");
-
- errors = new StringBuffer();
- Logger.msg(5, "Parsing "+schema.docType+" version "+schema.docVersion+". "+schema.schema.length()+" chars");
-
- XMLGrammarPreparser preparser = new XMLGrammarPreparser(sym);
- preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null);
- preparser.setProperty(GRAMMAR_POOL, schemaGrammarPool);
-
- preparser.setFeature(NAMESPACES_FEATURE_ID, true);
- preparser.setFeature(VALIDATION_FEATURE_ID, true);
- preparser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);
- preparser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true);
- preparser.setErrorHandler(this);
- try {
- preparser.preparseGrammar(XMLGrammarDescription.XML_SCHEMA, new XMLInputSource(null, null, null, new StringReader(schema.schema), null));
- } catch (IOException ex) {
- throw new InvalidDataException("Error parsing schema: "+ex.getMessage());
- }
-
- if (errors.length() > 0) {
- throw new InvalidDataException("Schema error: \n"+errors.toString());
- }
-
- }
-
- public synchronized String validate(Outcome outcome) {
- if (outcome == null) return "Outcome object was null";
- Logger.msg(5, "Validating outcome no "+outcome.getID()+" as "+schema.docType+" v"+schema.docVersion);
- if (outcome.getSchemaType().equals(schema.docType)
- && outcome.getSchemaVersion() == schema.docVersion) {
- return validate(outcome.getData());
- }
- else
- return "Outcome type and version did not match schema "+schema.docType;
- }
-
- public synchronized String validate(String outcome) {
- if (outcome == null) return "Outcome String was null";
- errors = new StringBuffer();
- try {
- XMLParserConfiguration parserConfiguration = new IntegratedParserConfiguration(sym, schemaGrammarPool);
- parserConfiguration.setFeature(NAMESPACES_FEATURE_ID, true);
- parserConfiguration.setFeature(VALIDATION_FEATURE_ID, true);
- // now we can still do schema features just in case,
- // so long as it's our configuraiton......
- parserConfiguration.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);
- parserConfiguration.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true);
- DOMParser parser = new DOMParser(parserConfiguration);
- parser.setErrorHandler(this);
-
- parser.parse(new XMLInputSource(null, null, null, new StringReader(outcome), null));
- } catch (Exception e) {
- return e.getMessage();
- }
- return errors.toString();
- }
-
- private void appendError(String level, Exception ex) {
- errors.append(level);
- String message = ex.getMessage();
- if (message == null || message.length()==0)
- message = ex.getClass().getName();
- errors.append(message);
- errors.append("\n");
- }
-
- /**
- * ErrorHandler for instances
- */
- @Override
- public void error(SAXParseException ex) throws SAXException {
- appendError("ERROR: ", ex);
- }
-
- /**
- *
- */
- @Override
- public void fatalError(SAXParseException ex) throws SAXException {
- appendError("FATAL: ", ex);
- }
-
- /**
- *
- */
- @Override
- public void warning(SAXParseException ex) throws SAXException {
- appendError("WARNING: ", ex);
- }
-
- /**
- * XMLErrorHandler for schema
- */
- @Override
- public void error(String domain, String key, XMLParseException ex)
- throws XNIException {
- appendError("ERROR: ", ex);
- }
-
- /**
- *
- */
- @Override
- public void fatalError(String domain, String key, XMLParseException ex)
- throws XNIException {
- appendError("FATAL: ", ex);
- }
-
- /**
- *
- */
- @Override
- public void warning(String domain, String key, XMLParseException ex)
- throws XNIException {
- appendError("WARNING: ", ex);
- }
-
-}
diff --git a/src/main/java/com/c2kernel/persistency/outcome/Schema.java b/src/main/java/com/c2kernel/persistency/outcome/Schema.java deleted file mode 100644 index 21426a2..0000000 --- a/src/main/java/com/c2kernel/persistency/outcome/Schema.java +++ /dev/null @@ -1,73 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.persistency.outcome;
-
-import java.io.IOException;
-import java.io.StringReader;
-
-import org.exolab.castor.xml.schema.reader.SchemaReader;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.InputSource;
-
-/**
- * @author Andrew Branson
- *
- * $Revision: 1.3 $
- * $Date: 2006/09/14 14:13:26 $
- *
- * Copyright (C) 2003 CERN - European Organization for Nuclear Research
- * All rights reserved.
- */
-
-public class Schema {
- public String docType;
- public int docVersion;
- public String schema;
- public org.exolab.castor.xml.schema.Schema som;
-
- /**
- * @param docType
- * @param docVersion
- * @param schema
- */
- public Schema(String docType, int docVersion, String schema) {
- super();
- this.docType = docType;
- this.docVersion = docVersion;
- this.schema = schema;
- }
-
- public Schema(String schema) {
- this.schema = schema;
- }
-
- public org.exolab.castor.xml.schema.Schema parse(ErrorHandler errorHandler) throws IOException {
- InputSource schemaSource = new InputSource(new StringReader(schema));
- SchemaReader mySchemaReader = new SchemaReader(schemaSource);
- if (errorHandler!= null) {
- mySchemaReader.setErrorHandler(errorHandler);
- mySchemaReader.setValidation(true);
- }
- som = mySchemaReader.read();
- return som;
- }
-
-}
diff --git a/src/main/java/com/c2kernel/persistency/outcome/SchemaValidator.java b/src/main/java/com/c2kernel/persistency/outcome/SchemaValidator.java deleted file mode 100644 index fce463b..0000000 --- a/src/main/java/com/c2kernel/persistency/outcome/SchemaValidator.java +++ /dev/null @@ -1,55 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.persistency.outcome;
-
-import java.io.IOException;
-
-
-/**************************************************************************
- *
- * $Revision: 1.2 $
- * $Date: 2005/04/26 06:48:13 $
- *
- * Copyright (C) 2003 CERN - European Organization for Nuclear Research
- * All rights reserved.
- **************************************************************************/
-
-
-
-public class SchemaValidator extends OutcomeValidator {
-
- public SchemaValidator() {
-
- }
-
- @Override
- public synchronized String validate(String outcome) {
- errors = new StringBuffer();
- Schema schema = new Schema(outcome);
- try {
- schema.parse(this);
- } catch (IOException e) {
- errors.append(e.getMessage());
- }
- return errors.toString();
- }
-
-}
diff --git a/src/main/java/com/c2kernel/persistency/outcome/Viewpoint.java b/src/main/java/com/c2kernel/persistency/outcome/Viewpoint.java deleted file mode 100644 index e35b6b6..0000000 --- a/src/main/java/com/c2kernel/persistency/outcome/Viewpoint.java +++ /dev/null @@ -1,190 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.persistency.outcome;
-
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.entity.C2KLocalObject;
-import com.c2kernel.events.Event;
-import com.c2kernel.lookup.InvalidItemPathException;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.persistency.ClusterStorage;
-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 class Viewpoint implements C2KLocalObject {
-
- // db fields
- ItemPath itemPath;
- String schemaName;
- String name;
- int schemaVersion;
- int eventId;
- public static final int NONE = -1;
-
- public Viewpoint() {
- eventId = NONE;
- itemPath = null;
- schemaVersion = NONE;
- schemaName = null;
- name = null;
- }
-
- public Viewpoint(ItemPath itemPath, String schemaName, String name, int schemaVersion, int eventId) {
- this.itemPath = itemPath;
- this.schemaName = schemaName;
- this.name = name;
- this.schemaVersion = schemaVersion;
- this.eventId = eventId;
- }
-
- public Outcome getOutcome() throws ObjectNotFoundException, PersistencyException {
- if (eventId == NONE) throw new ObjectNotFoundException("No last eventId defined");
- Outcome retVal = (Outcome)Gateway.getStorage().get(itemPath, ClusterStorage.OUTCOME+"/"+schemaName+"/"+schemaVersion+"/"+eventId, null);
- return retVal;
- }
-
- @Override
- public String getClusterType() {
- return ClusterStorage.VIEWPOINT;
- }
-
-
- /**
- * Returns the eventId.
- * @return int
- */
- public int getEventId() {
- return eventId;
- }
-
- /**
- * Returns the name.
- * @return String
- */
- @Override
- 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 ItemPath getItemPath() {
- return itemPath;
- }
-
- /**
- * Sets the eventId.
- * @param eventId The eventId to set
- */
- public void setEventId(int eventId) {
- this.eventId = eventId;
- }
-
- /**
- * Sets the name.
- * @param name The name to set
- */
- @Override
- 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 setItemPath(ItemPath itemPath) {
- this.itemPath = itemPath;
- }
-
- public void setItemUUID( String uuid ) throws InvalidItemPathException
- {
- setItemPath(new ItemPath(uuid));
- }
-
- public String getItemUUID() {
- return getItemPath().getUUID().toString();
- }
-
- /**
- * Method getEvent.
- * @return GDataRecord
- */
- public Event getEvent()
- throws InvalidDataException, PersistencyException, ObjectNotFoundException
- {
- if (eventId == NONE)
- throw new InvalidDataException("No last eventId defined");
-
- return (Event)Gateway.getStorage().get(itemPath, ClusterStorage.HISTORY+"/"+eventId, null);
- }
-
- @Override
- public String toString() {
- return name;
- }
-
-}
|
