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.enterprisemodel.systemimplementationmodel;
16:
17: import java.util.Collection;
18:
19: import javax.jmi.reflect.ConstraintViolationException;
20:
21: import org.apache.commons.logging.Log;
22: import org.apache.commons.logging.LogFactory;
23: import org.netbeans.mdr.storagemodel.StorableObject;
24:
25: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Attribute;
26: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.AttributeStereotype;
27: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.AttributeStereotypeEnum;
28: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Entity;
29:
30: public abstract class AttributeImpl extends PrimaryKeyElementImpl
31: implements Attribute {
32: // Commons Logging instance.
33: private static final Log sLogger = LogFactory
34: .getLog(AttributeImpl.class);
35:
36: // Required constructor
37: protected AttributeImpl(StorableObject storable) {
38: super (storable);
39: }
40:
41: // Verify certain constraints
42: protected Collection _verify(Collection pViolations) {
43: // First call superclass
44: Collection lViolations = super ._verify(pViolations);
45:
46: // Constraint #1 - If attribute has a stereotype UpdateStamp the entity it is in must be modifiable
47: AttributeStereotype lStereotype = getStereotype();
48: if (lStereotype != null
49: && lStereotype
50: .equals(AttributeStereotypeEnum.UPDATE_STAMP)) {
51: Entity lEntity = getEntity();
52: if (lEntity != null && lEntity.isModifiable() == false) {
53: lViolations
54: .add(new ConstraintViolationException(
55: this ,
56: refMetaObject(),
57: "Attribute with stereotype '"
58: + AttributeStereotypeEnum.UPDATE_STAMP
59: + "' must be owned by modifiable entity."));
60: }
61: }
62: return lViolations;
63: }
64:
65: // Returns true if this attribute has optional stereotype
66: public boolean isOptional() {
67: AttributeStereotype lStereotype = getStereotype();
68: return lStereotype != null
69: && lStereotype.equals(AttributeStereotypeEnum.OPTIONAL);
70: }
71: }
|