001: /*
002: * argun 1.0
003: * Web 2.0 delivery framework
004: * Copyright (C) 2007 Hammurapi Group
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2 of the License, or (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: * URL: http://www.hammurapi.biz
021: * e-Mail: support@hammurapi.biz
022: */
023: package biz.hammurapi.web.interaction;
024:
025: import org.jgraph.graph.DefaultEdge;
026: import org.jgraph.graph.DefaultPort;
027:
028: import biz.hammurapi.web.interaction.sql.InteractionTransition;
029:
030: public class Transition extends DefaultEdge implements
031: InteractionElement {
032:
033: private InteractionTransition data;
034: private Interaction owner;
035:
036: public Transition(Interaction owner, InteractionTransition data) {
037: super (data.getName());
038: this .data = data;
039: this .owner = owner;
040: }
041:
042: private boolean isValid = true;
043:
044: void invalidate() {
045: isValid = false;
046: }
047:
048: public boolean isValid() {
049: return isValid;
050: }
051:
052: public void setUserObject(Object userObject) {
053: setName(userObject.toString());
054: }
055:
056: public Object getUserObject() {
057: return getName();
058: }
059:
060: public String getAction() {
061: return data.getActionCode();
062: }
063:
064: public String getDescription() {
065: return data.getDescription();
066: }
067:
068: public String getGuard() {
069: return data.getConditionCode();
070: }
071:
072: public String getName() {
073: return data.getName();
074: }
075:
076: public Interaction getInteraction() {
077: return owner;
078: }
079:
080: public void setAction(String action) {
081: data.setActionCode(action);
082: }
083:
084: public void setDescription(String description) {
085: data.setDescription(description);
086: }
087:
088: public void setGuard(String guard) {
089: data.setConditionCode(guard);
090: }
091:
092: public void setName(String name) {
093: data.setName(name);
094: super .setUserObject(name);
095: }
096:
097: public Step getSourceStep() {
098: return (Step) (getSource() == null ? null
099: : ((DefaultPort) getSource()).getParent());
100: }
101:
102: public Step getTargetStep() {
103: return (Step) (getTarget() == null ? null
104: : ((DefaultPort) getTarget()).getParent());
105: }
106:
107: public InteractionTransition getData() {
108: return data;
109: }
110: }
|