View Javadoc
1   package org.andromda.cartridges.webservice.metafacades;
2   
3   import java.util.Collection;
4   import org.andromda.core.metafacade.MetafacadeBase;
5   import org.andromda.core.metafacade.ModelValidationMessage;
6   import org.andromda.translation.ocl.validation.OCLIntrospector;
7   import org.andromda.utils.StringUtilsHelper;
8   
9   /**
10   * MetafacadeLogic implementation for org.andromda.cartridges.webservice.metafacades.WSDLTypeAssociationEnd.
11   *
12   * @see org.andromda.cartridges.webservice.metafacades.WSDLTypeAssociationEnd
13   * @author Bob Fields
14   */
15  public class WSDLTypeAssociationEndLogicImpl
16          extends WSDLTypeAssociationEndLogic
17  {
18      private static final long serialVersionUID = 34L;
19      // ---------------- constructor -------------------------------
20  
21      /**
22       * @param metaObject
23       * @param context
24       */
25      public WSDLTypeAssociationEndLogicImpl(Object metaObject, String context)
26      {
27          super(metaObject, context);
28      }
29  
30      /**
31       * @return !this.isRequired()
32       * @see org.andromda.cartridges.webservice.metafacades.WSDLTypeAssociationEnd#isNillable()
33       */
34      protected boolean handleIsNillable()
35      {
36          return !this.isRequired();
37      }
38  
39      /**
40       * <p><b>Constraint:</b> org::andromda::cartridges::webservice::metafacades::WSDLTypeAssociationEnd::association end must start with a lowercase letter</p>
41       * <p><b>Error:</b> AssociationEnd name must start with a lowercase letter.</p>
42       * @param validationMessages Collection<ModelValidationMessage>
43       * @see org.andromda.core.metafacade.MetafacadeBase#validateInvariants(Collection validationMessages)
44       */
45      @Override
46      public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
47      {
48          super.validateInvariants(validationMessages);
49          try
50          {
51              final Object contextElement = this.THIS();
52              final String name = (String)OCLIntrospector.invoke(contextElement,"name");
53              if (name != null && name.length()>0 && !StringUtilsHelper.startsWithLowercaseLetter(name))
54              {
55                  validationMessages.add(
56                      new ModelValidationMessage(
57                          (MetafacadeBase)contextElement ,
58                          "org::andromda::cartridges::webservice::metafacades::WSDLTypeAssociationEnd::association end must start with a lowercase letter",
59                          "AssociationEnd name must start with a lowercase letter."));
60              }
61          }
62          catch (Throwable th)
63          {
64              Throwable cause = th.getCause();
65              int depth = 0; // Some throwables have infinite recursion
66              while (cause != null && depth < 7)
67              {
68                  th = cause;
69                  depth++;
70              }
71              logger.error("Error validating constraint 'org::andromda::cartridges::webservice::WSDLTypeAssociationEnd::association end must start with a lowercase letter' ON "
72                  + this.THIS().toString() + ": " + th.getMessage(), th);
73          }
74      }
75  }