01: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: // POSSIBILITY OF SUCH DAMAGE.
13: //
14: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package com.metaboss.sdlctools.models.impl.metabossmodel;
16:
17: import java.util.Collection;
18:
19: import javax.jmi.reflect.ConstraintViolationException;
20:
21: import org.netbeans.mdr.storagemodel.StorableObject;
22:
23: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
24: import com.metaboss.sdlctools.models.metabossmodel.ModelElementConstraint;
25:
26: public abstract class ModelElementConstraintImpl extends
27: ModelElementImpl implements ModelElementConstraint {
28: // Required constructor
29: protected ModelElementConstraintImpl(StorableObject storable) {
30: super (storable);
31: }
32:
33: // Verify certain constraints
34: protected Collection _verify(Collection pViolations) {
35: // First call superclass
36: Collection lViolations = super ._verify(pViolations);
37:
38: // Ensure that the expression is there
39: String lExpressionString = getOclExpression();
40: if (lExpressionString == null
41: || lExpressionString.trim().length() == 0)
42: lViolations
43: .add(new ConstraintViolationException(this ,
44: refMetaObject(),
45: "Ocl Expression can not be empty in the Constraint"));
46:
47: // Ensure that the default error text is there
48: String lDefaultErrorText = getDefaultErrorText();
49: if (lDefaultErrorText == null
50: || lDefaultErrorText.trim().length() == 0)
51: lViolations
52: .add(new ConstraintViolationException(this ,
53: refMetaObject(),
54: "Default Error Text can not be empty in the Constraint"));
55:
56: return lViolations;
57: }
58:
59: /** Returns context element for this constraint */
60: public ModelElement getContextElement() {
61: return (ModelElement) this.refImmediateComposite();
62: }
63: }
|