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.process;
024:
025: import org.jgraph.graph.DefaultEdge;
026: import org.jgraph.graph.DefaultPort;
027:
028: import biz.hammurapi.web.process.sql.ProcessTransition;
029:
030: public class Transition extends DefaultEdge implements ProcessElement {
031:
032: private ProcessTransition data;
033: private Process owner;
034:
035: public Transition(Process owner, ProcessTransition data) {
036: super (data.getName());
037: this .data = data;
038: this .owner = owner;
039: }
040:
041: private boolean isValid = true;
042:
043: void invalidate() {
044: isValid = false;
045: }
046:
047: public boolean isValid() {
048: return isValid;
049: }
050:
051: public void setUserObject(Object userObject) {
052: setName(userObject.toString());
053: }
054:
055: public Object getUserObject() {
056: return getName();
057: }
058:
059: public String getAction() {
060: return data.getActionCode();
061: }
062:
063: public String getSummary() {
064: return data.getDescription();
065: }
066:
067: public String getGuard() {
068: return data.getConditionCode();
069: }
070:
071: public String getName() {
072: return data.getName();
073: }
074:
075: public Process getProcess() {
076: return owner;
077: }
078:
079: public void setAction(String action) {
080: data.setActionCode(action);
081: }
082:
083: public void setSummary(String summary) {
084: data.setDescription(summary);
085: }
086:
087: public void setGuard(String guard) {
088: data.setConditionCode(guard);
089: }
090:
091: public void setName(String name) {
092: data.setName(name);
093: super .setUserObject(name);
094: }
095:
096: public Task getSourceTask() {
097: return (Task) (getSource() == null ? null
098: : ((DefaultPort) getSource()).getParent());
099: }
100:
101: public Task getTargetTask() {
102: return (Task) (getTarget() == null ? null
103: : ((DefaultPort) getTarget()).getParent());
104: }
105:
106: public ProcessTransition getData() {
107: return data;
108: }
109: }
|