001: /*
002: * $Id: AbstractActivity.java,v 1.10 2004/12/09 12:34:21 kowap Exp $
003: *
004: * Copyright (c) 2004 Patric Fornasier, Pawel Kowalski
005: * Berne University of Applied Sciences
006: * School of Engineering and Information Technology
007: * All rights reserved.
008: */
009: package bexee.model.activity.impl;
010:
011: import java.util.ArrayList;
012: import java.util.List;
013:
014: import bexee.model.InvalidValueException;
015: import bexee.model.StandardAttributes;
016: import bexee.model.activity.Activity;
017: import bexee.model.elements.Source;
018: import bexee.model.elements.Target;
019: import bexee.model.expression.BooleanExpression;
020: import bexee.model.expression.impl.BooleanExpressionImpl;
021: import bexee.util.BooleanUtils;
022: import bexee.util.StringUtils;
023:
024: /**
025: * This is an abstract class to be used by all BPEL Activity implementations.
026: *
027: * @version $Revision: 1.10 $, $Date: 2004/12/09 12:34:21 $
028: * @author Patric Fornasier
029: * @author Pawel Kowalski
030: */
031: public abstract class AbstractActivity implements Activity {
032:
033: private String name = null;
034:
035: private BooleanExpression joinExpression = null;
036:
037: private boolean suppressJoinFailure = false;
038:
039: private List targets = null;
040:
041: private List sources = null;
042:
043: private Object accessorElement = null;
044:
045: //**************************************************/
046: // c'tors
047: //**************************************************/
048:
049: /**
050: * Create a new AbstractActivity.
051: *
052: */
053: public AbstractActivity() {
054: this (null);
055: }
056:
057: /**
058: * Create a new AbstractActivity with the given StandardAttributes.
059: *
060: * @param standardAttributes
061: */
062: public AbstractActivity(StandardAttributes standardAttributes) {
063: init();
064:
065: if (standardAttributes != null) {
066: name = standardAttributes.getName();
067: joinExpression = new BooleanExpressionImpl(
068: standardAttributes.getJoinCondition());
069: suppressJoinFailure = getValidValueOrDefault(
070: standardAttributes.getSuppressJoinFailure(),
071: DEFAULT_SUPPRESS_JOIN_FAILURE);
072: } else {
073: name = "";
074: suppressJoinFailure = DEFAULT_SUPPRESS_JOIN_FAILURE;
075: }
076: }
077:
078: private void init() {
079: targets = new ArrayList();
080: sources = new ArrayList();
081: }
082:
083: //**************************************************/
084: // bexee.model.activity.Activity
085: //**************************************************/
086:
087: public void setName(String name) {
088: this .name = name;
089: }
090:
091: public String getName() {
092: return name;
093: }
094:
095: public void setJoinExpression(BooleanExpression joinExpression) {
096: this .joinExpression = joinExpression;
097: }
098:
099: public BooleanExpression getJoinExpression() {
100: return joinExpression;
101: }
102:
103: public void setSuppressJoinFailure(boolean suppressJoinFailure) {
104: this .suppressJoinFailure = suppressJoinFailure;
105: }
106:
107: public boolean isSuppressJoinFailure() {
108: return suppressJoinFailure;
109: }
110:
111: public void addSource(Source source) {
112: sources.add(source);
113: }
114:
115: public void setSources(List sources) {
116: this .sources = sources;
117: }
118:
119: public List getSources() {
120: return sources;
121: }
122:
123: public void addTarget(Target target) {
124: targets.add(target);
125: }
126:
127: public void setTargets(List targets) {
128: this .targets = targets;
129: }
130:
131: public List getTargets() {
132: return targets;
133: }
134:
135: //**************************************************/
136: // helper methods
137: //**************************************************/
138:
139: protected String getValidValueOrDefault(String value,
140: String defaultValue) {
141: if (StringUtils.isNullOrEmpty(value)) {
142: return defaultValue;
143: } else {
144: return value;
145: }
146: }
147:
148: protected boolean getValidValueOrDefault(String value,
149: boolean defaultValue) {
150: try {
151: return BooleanUtils.strictYesNoToBoolean(value);
152: } catch (InvalidValueException e) {
153: return defaultValue;
154: }
155: }
156:
157: }
|