ingo@104: /* ingo@104: * Copyright (c) 2011 by Intevation GmbH ingo@104: * ingo@104: * This program is free software under the LGPL (>=v2.1) ingo@104: * Read the file LGPL.txt coming with the software for details ingo@104: * or visit http://www.gnu.org/licenses/ if it does not exist. ingo@104: */ ingo@104: package de.intevation.artifactdatabase.state; ingo@104: ingo@104: import java.io.Serializable; ingo@210: import java.util.List; ingo@104: import java.util.Map; ingo@104: ingo@104: import org.w3c.dom.Document; ingo@205: import org.w3c.dom.Element; ingo@104: import org.w3c.dom.Node; ingo@104: ingo@244: import de.intevation.artifacts.Artifact; ingo@104: import de.intevation.artifacts.CallContext; ingo@363: import de.intevation.artifacts.CallMeta; ingo@104: ingo@104: import de.intevation.artifactdatabase.data.StateData; ingo@104: ingo@104: ingo@104: /** ingo@104: * This interface describes the basic methods a concrete state class needs to ingo@104: * implement. ingo@104: * ingo@104: * @author Ingo Weinzierl ingo@104: */ ingo@104: public interface State extends Serializable { ingo@104: ingo@104: /** ingo@104: * Return the id of the state. ingo@104: * ingo@104: * @return the id. ingo@104: */ ingo@104: public String getID(); ingo@104: ingo@104: ingo@104: /** ingo@104: * Return the description of the state. ingo@104: * ingo@104: * @return the description of the state. ingo@104: */ ingo@104: public String getDescription(); ingo@104: ingo@104: ingo@104: /** ingo@386: * Returns the help text configured for the state. ingo@386: * ingo@386: * @return the help text configured for the state. ingo@386: */ ingo@386: public String getHelpText(); ingo@386: ingo@386: ingo@386: /** ingo@104: * Returns the data provided by this state. ingo@104: * ingo@104: * @return the data stored in this state. ingo@104: */ ingo@104: public Map getData(); ingo@104: ingo@104: ingo@104: /** ingo@256: * Returns a single desired StateData object based on its name. ingo@256: * ingo@256: * @param name The name of the desired StateData object. ingo@256: * ingo@256: * @return the desired StateData object. ingo@256: */ ingo@256: public StateData getData(String name); ingo@256: ingo@256: ingo@256: /** ingo@110: * This method should be used to add a new {@link StateData} object to the ingo@110: * data pool of the state. ingo@110: * ingo@110: * @param name The name of the data object. ingo@110: * @param data The data object. ingo@110: */ ingo@110: public void addData(String name, StateData data); ingo@110: ingo@110: ingo@110: /** ingo@210: * Returns the list of possible outputs of this state. The list is empty ingo@210: * if no output is available for this state. ingo@210: * ingo@210: * @return a list of possible outputs of this state. ingo@210: */ ingo@210: public List getOutputs(); ingo@210: ingo@210: ingo@210: /** ingo@104: * Initialize the state based on the state node in the configuration. ingo@104: * ingo@104: * @param config The state configuration node. ingo@104: */ ingo@104: public void setup(Node config); ingo@104: ingo@104: ingo@104: /** ingo@363: * Initializes the internal state of this State based on an other State. ingo@363: * ingo@363: * @param orig The owner Artifact or the original State. ingo@365: * @param owner The owner Artifact of this State. ingo@363: * @param context The context object. ingo@363: * @param callMeta The CallMeta of the current call. ingo@363: */ ingo@365: public void initialize( ingo@365: Artifact orig, ingo@365: Artifact owner, ingo@365: Object context, ingo@365: CallMeta callMeta); ingo@363: ingo@363: ingo@363: /** ingo@104: * This method is called when an artifacts retrieves a describe request. It ingo@104: * creates the user interface description of the current state. ingo@104: * ingo@244: * @param artifact A reference to the artifact this state belongs to. ingo@104: * @param document Describe doucment. ingo@104: * @param rootNode Parent node for all new elements. ingo@104: * @param context The CallContext. ingo@104: * @param uuid The uuid of an artifact. ingo@104: */ ingo@205: public Element describe( ingo@244: Artifact artifact, ingo@104: Document document, ingo@104: Node rootNode, ingo@104: CallContext context, ingo@104: String uuid ingo@104: ); ingo@327: ingo@327: ingo@327: /** ingo@327: * This method should be called by an Artifact that removes this State ingo@327: * (current State and previous States). E.g. this might be interesting to ingo@327: * remove generated files or stuff like that. ingo@327: * ingo@327: * @param artifact A parent Artifact. ingo@327: * @param context The CallContext. ingo@327: */ ingo@327: public void endOfLife(Artifact artifact, Object context); ingo@104: } ingo@104: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :