View Javadoc

1   /*
2    * $Id: AbstractActivity.java,v 1.1 2004/12/15 14:18:13 patforna Exp $
3    *
4    * Copyright (c) 2004 Patric Fornasier, Pawel Kowalski
5    * Berne University of Applied Sciences
6    * School of Engineering and Information Technology
7    * All rights reserved.
8    */
9   package bexee.model.activity.impl;
10  
11  import java.util.ArrayList;
12  import java.util.List;
13  
14  import bexee.model.InvalidValueException;
15  import bexee.model.StandardAttributes;
16  import bexee.model.activity.Activity;
17  import bexee.model.elements.Source;
18  import bexee.model.elements.Target;
19  import bexee.model.expression.BooleanExpression;
20  import bexee.model.expression.impl.BooleanExpressionImpl;
21  import bexee.util.BooleanUtils;
22  import bexee.util.StringUtils;
23  
24  /***
25   * This is an abstract class to be used by all BPEL Activity implementations.
26   * 
27   * @version $Revision: 1.1 $, $Date: 2004/12/15 14:18:13 $
28   * @author Patric Fornasier
29   * @author Pawel Kowalski
30   */
31  public abstract class AbstractActivity implements Activity {
32  
33      private String name = null;
34  
35      private BooleanExpression joinExpression = null;
36  
37      private boolean suppressJoinFailure = false;
38  
39      private List targets = null;
40  
41      private List sources = null;
42  
43      private Object accessorElement = null;
44  
45      //***************************************************/
46      // c'tors
47      //***************************************************/
48  
49      /***
50       * Create a new AbstractActivity.
51       *  
52       */
53      public AbstractActivity() {
54          this(null);
55      }
56  
57      /***
58       * Create a new AbstractActivity with the given StandardAttributes.
59       * 
60       * @param standardAttributes
61       */
62      public AbstractActivity(StandardAttributes standardAttributes) {
63          init();
64  
65          if (standardAttributes != null) {
66              name = standardAttributes.getName();
67              joinExpression = new BooleanExpressionImpl(standardAttributes
68                      .getJoinCondition());
69              suppressJoinFailure = getValidValueOrDefault(standardAttributes
70                      .getSuppressJoinFailure(), DEFAULT_SUPPRESS_JOIN_FAILURE);
71          } else {
72              name = "";
73              suppressJoinFailure = DEFAULT_SUPPRESS_JOIN_FAILURE;
74          }
75      }
76  
77      private void init() {
78          targets = new ArrayList();
79          sources = new ArrayList();
80      }
81  
82      //***************************************************/
83      // bexee.model.activity.Activity
84      //***************************************************/
85  
86      public void setName(String name) {
87          this.name = name;
88      }
89  
90      public String getName() {
91          return name;
92      }
93  
94      public void setJoinExpression(BooleanExpression joinExpression) {
95          this.joinExpression = joinExpression;
96      }
97  
98      public BooleanExpression getJoinExpression() {
99          return joinExpression;
100     }
101 
102     public void setSuppressJoinFailure(boolean suppressJoinFailure) {
103         this.suppressJoinFailure = suppressJoinFailure;
104     }
105 
106     public boolean isSuppressJoinFailure() {
107         return suppressJoinFailure;
108     }
109 
110     public void addSource(Source source) {
111         sources.add(source);
112     }
113 
114     public void setSources(List sources) {
115         this.sources = sources;
116     }
117 
118     public List getSources() {
119         return sources;
120     }
121 
122     public void addTarget(Target target) {
123         targets.add(target);
124     }
125 
126     public void setTargets(List targets) {
127         this.targets = targets;
128     }
129 
130     public List getTargets() {
131         return targets;
132     }
133 
134     //***************************************************/
135     // helper methods
136     //***************************************************/
137 
138     protected String getValidValueOrDefault(String value, String defaultValue) {
139         if (StringUtils.isNullOrEmpty(value)) {
140             return defaultValue;
141         } else {
142             return value;
143         }
144     }
145 
146     protected boolean getValidValueOrDefault(String value, boolean defaultValue) {
147         try {
148             return BooleanUtils.strictYesNoToBoolean(value);
149         } catch (InvalidValueException e) {
150             return defaultValue;
151         }
152     }
153 
154 }