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.datadictionarymodel;
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.impl.metabossmodel.ModelElementImpl;
24: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.AbstractDataField;
25: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataType;
26: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.Structure;
27:
28: public abstract class AbstractDataFieldImpl extends ModelElementImpl
29: implements AbstractDataField {
30: // Required constructor
31: protected AbstractDataFieldImpl(StorableObject storable) {
32: super (storable);
33: }
34:
35: // Verify certain constraints
36: protected Collection _verify(Collection pViolations) {
37: // First call superclass
38: Collection lViolations = super ._verify(pViolations);
39:
40: // Constraint #1 - either DataType or StructureType, but not none and not both must be populated
41: {
42: DataType lDataType = getDataType();
43: Structure lStructureType = getStructureType();
44: if (lDataType == null && lStructureType == null)
45: lViolations
46: .add(new ConstraintViolationException(
47: this ,
48: refMetaObject(),
49: "Both dataType and structureType are missing. One or the other must be specified."));
50: else if (lDataType != null && lStructureType != null)
51: lViolations
52: .add(new ConstraintViolationException(
53: this ,
54: refMetaObject(),
55: "Both dataType and structureType are present. One or the other must be specified."));
56: }
57: return lViolations;
58: }
59: }
|