001// license-header java merge-point 002// 003// Attention: generated code (by MetafacadeLogic.vsl) - do not modify! 004// 005package org.andromda.metafacades.uml14; 006 007import java.util.Collection; 008import java.util.List; 009import org.andromda.core.metafacade.MetafacadeBase; 010import org.andromda.core.metafacade.ModelValidationMessage; 011import org.andromda.metafacades.uml.FrontEndAction; 012import org.andromda.metafacades.uml.FrontEndActivityGraph; 013import org.andromda.metafacades.uml.FrontEndControllerOperation; 014import org.andromda.metafacades.uml.FrontEndParameter; 015import org.andromda.translation.ocl.validation.OCLExpressions; 016import org.andromda.translation.ocl.validation.OCLIntrospector; 017import org.andromda.translation.ocl.validation.OCLResultEnsurer; 018import org.apache.log4j.Logger; 019import org.omg.uml.foundation.core.Operation; 020 021/** 022 * Represents an operation modeled on a controller. 023 * MetafacadeLogic for FrontEndControllerOperation 024 * 025 * @see FrontEndControllerOperation 026 */ 027public abstract class FrontEndControllerOperationLogic 028 extends OperationFacadeLogicImpl 029 implements FrontEndControllerOperation 030{ 031 /** 032 * The underlying UML object 033 * @see Object 034 */ 035 protected Object metaObject; 036 037 /** Create Metafacade implementation instance using the MetafacadeFactory from the context 038 * @param metaObjectIn 039 * @param context 040 */ 041 protected FrontEndControllerOperationLogic(Object metaObjectIn, String context) 042 { 043 super((Operation)metaObjectIn, getContext(context)); 044 this.metaObject = metaObjectIn; 045 } 046 047 /** 048 * The logger instance. 049 */ 050 private static final Logger logger = Logger.getLogger(FrontEndControllerOperationLogic.class); 051 052 /** 053 * Gets the context for this metafacade logic instance. 054 * @param context String. Set to FrontEndControllerOperation if null 055 * @return context String 056 */ 057 private static String getContext(String context) 058 { 059 if (context == null) 060 { 061 context = "org.andromda.metafacades.uml.FrontEndControllerOperation"; 062 } 063 return context; 064 } 065 066 /** Reset context only for non-root metafacades 067 * @param context 068 */ 069 @Override 070 public void resetMetafacadeContext(String context) 071 { 072 if (!this.contextRoot) // reset context only for non-root metafacades 073 { 074 context = getContext(context); // to have same value as in original constructor call 075 setMetafacadeContext (context); 076 } 077 } 078 079 /** 080 * @return boolean true always 081 * @see FrontEndControllerOperation 082 */ 083 public boolean isFrontEndControllerOperationMetaType() 084 { 085 return true; 086 } 087 088 // --------------- attributes --------------------- 089 090 /** 091 * @see FrontEndControllerOperation#isOwnerIsController() 092 * @return boolean 093 */ 094 protected abstract boolean handleIsOwnerIsController(); 095 096 private boolean __ownerIsController1a; 097 private boolean __ownerIsController1aSet = false; 098 099 /** 100 * Indicates if the owner of this operation is a controller. 101 * @return (boolean)handleIsOwnerIsController() 102 */ 103 public final boolean isOwnerIsController() 104 { 105 boolean ownerIsController1a = this.__ownerIsController1a; 106 if (!this.__ownerIsController1aSet) 107 { 108 // ownerIsController has no pre constraints 109 ownerIsController1a = handleIsOwnerIsController(); 110 // ownerIsController has no post constraints 111 this.__ownerIsController1a = ownerIsController1a; 112 if (isMetafacadePropertyCachingEnabled()) 113 { 114 this.__ownerIsController1aSet = true; 115 } 116 } 117 return ownerIsController1a; 118 } 119 120 /** 121 * @see FrontEndControllerOperation#isAllArgumentsHaveFormFields() 122 * @return boolean 123 */ 124 protected abstract boolean handleIsAllArgumentsHaveFormFields(); 125 126 private boolean __allArgumentsHaveFormFields2a; 127 private boolean __allArgumentsHaveFormFields2aSet = false; 128 129 /** 130 * For each front-end controller operation argument there must exist a form field for each 131 * action deferring to that operation. This form field must carry the same name and must be of 132 * the same type. True if this is the case, false otherwise. 133 * @return (boolean)handleIsAllArgumentsHaveFormFields() 134 */ 135 public final boolean isAllArgumentsHaveFormFields() 136 { 137 boolean allArgumentsHaveFormFields2a = this.__allArgumentsHaveFormFields2a; 138 if (!this.__allArgumentsHaveFormFields2aSet) 139 { 140 // allArgumentsHaveFormFields has no pre constraints 141 allArgumentsHaveFormFields2a = handleIsAllArgumentsHaveFormFields(); 142 // allArgumentsHaveFormFields has no post constraints 143 this.__allArgumentsHaveFormFields2a = allArgumentsHaveFormFields2a; 144 if (isMetafacadePropertyCachingEnabled()) 145 { 146 this.__allArgumentsHaveFormFields2aSet = true; 147 } 148 } 149 return allArgumentsHaveFormFields2a; 150 } 151 152 // ------------- associations ------------------ 153 154 private FrontEndActivityGraph __getActivityGraph1r; 155 private boolean __getActivityGraph1rSet = false; 156 157 /** 158 * Represents an operation modeled on a controller. 159 * @return (FrontEndActivityGraph)handleGetActivityGraph() 160 */ 161 public final FrontEndActivityGraph getActivityGraph() 162 { 163 FrontEndActivityGraph getActivityGraph1r = this.__getActivityGraph1r; 164 if (!this.__getActivityGraph1rSet) 165 { 166 // frontEndControllerOperation has no pre constraints 167 Object result = handleGetActivityGraph(); 168 MetafacadeBase shieldedResult = this.shieldedElement(result); 169 try 170 { 171 getActivityGraph1r = (FrontEndActivityGraph)shieldedResult; 172 } 173 catch (ClassCastException ex) 174 { 175 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 176 FrontEndControllerOperationLogic.logger.warn("incorrect metafacade cast for FrontEndControllerOperationLogic.getActivityGraph FrontEndActivityGraph " + result + ": " + shieldedResult); 177 } 178 // frontEndControllerOperation has no post constraints 179 this.__getActivityGraph1r = getActivityGraph1r; 180 if (isMetafacadePropertyCachingEnabled()) 181 { 182 this.__getActivityGraph1rSet = true; 183 } 184 } 185 return getActivityGraph1r; 186 } 187 188 /** 189 * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type 190 * @return Object 191 */ 192 protected abstract Object handleGetActivityGraph(); 193 194 private List<FrontEndParameter> __getFormFields2r; 195 private boolean __getFormFields2rSet = false; 196 197 /** 198 * Gets the controller operation to which this parameter belongs. 199 * @return (List<FrontEndParameter>)handleGetFormFields() 200 */ 201 public final List<FrontEndParameter> getFormFields() 202 { 203 List<FrontEndParameter> getFormFields2r = this.__getFormFields2r; 204 if (!this.__getFormFields2rSet) 205 { 206 // controllerOperation has no pre constraints 207 List result = handleGetFormFields(); 208 List shieldedResult = this.shieldedElements(result); 209 try 210 { 211 getFormFields2r = (List<FrontEndParameter>)shieldedResult; 212 } 213 catch (ClassCastException ex) 214 { 215 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 216 FrontEndControllerOperationLogic.logger.warn("incorrect metafacade cast for FrontEndControllerOperationLogic.getFormFields List<FrontEndParameter> " + result + ": " + shieldedResult); 217 } 218 // controllerOperation has no post constraints 219 this.__getFormFields2r = getFormFields2r; 220 if (isMetafacadePropertyCachingEnabled()) 221 { 222 this.__getFormFields2rSet = true; 223 } 224 } 225 return getFormFields2r; 226 } 227 228 /** 229 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type 230 * @return List 231 */ 232 protected abstract List handleGetFormFields(); 233 234 private List<FrontEndAction> __getDeferringActions3r; 235 private boolean __getDeferringActions3rSet = false; 236 237 /** 238 * The controller operations to which this action defers, the order is preserved. 239 * @return (List<FrontEndAction>)handleGetDeferringActions() 240 */ 241 public final List<FrontEndAction> getDeferringActions() 242 { 243 List<FrontEndAction> getDeferringActions3r = this.__getDeferringActions3r; 244 if (!this.__getDeferringActions3rSet) 245 { 246 // deferredOperations has no pre constraints 247 List result = handleGetDeferringActions(); 248 List shieldedResult = this.shieldedElements(result); 249 try 250 { 251 getDeferringActions3r = (List<FrontEndAction>)shieldedResult; 252 } 253 catch (ClassCastException ex) 254 { 255 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 256 FrontEndControllerOperationLogic.logger.warn("incorrect metafacade cast for FrontEndControllerOperationLogic.getDeferringActions List<FrontEndAction> " + result + ": " + shieldedResult); 257 } 258 // deferredOperations has no post constraints 259 this.__getDeferringActions3r = getDeferringActions3r; 260 if (isMetafacadePropertyCachingEnabled()) 261 { 262 this.__getDeferringActions3rSet = true; 263 } 264 } 265 return getDeferringActions3r; 266 } 267 268 /** 269 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type 270 * @return List 271 */ 272 protected abstract List handleGetDeferringActions(); 273 274 /** 275 * <p><b>Constraint:</b> org::andromda::metafacades::uml::FrontEndControllerOperation::all arguments need an event parameter</p> 276 * <p><b>Error:</b> For each controller operation argument there must exist a parameter for each action deferring to that operation. This parameter must carry the same name and must be of the same type.</p> 277 * <p><b>OCL:</b> context FrontEndControllerOperation inv: allArgumentsHaveFormFields</p> 278 * <p><b>Constraint:</b> org::andromda::metafacades::uml::FrontEndControllerOperation::the operation name may not be the same as the use-case name</p> 279 * <p><b>Error:</b> It is not allowed to give a controller operation the same name as the use-case for which it is defined, please either rename your operation or your use-case.</p> 280 * <p><b>OCL:</b> context FrontEndControllerOperation inv: name <> owner.useCase.name</p> 281 * @param validationMessages Collection<ModelValidationMessage> 282 * @see OperationFacadeLogicImpl#validateInvariants(Collection validationMessages) 283 */ 284 @Override 285 public void validateInvariants(Collection<ModelValidationMessage> validationMessages) 286 { 287 super.validateInvariants(validationMessages); 288 try 289 { 290 final Object contextElement = this.THIS(); 291 boolean constraintValid = OCLResultEnsurer.ensure(OCLIntrospector.invoke(contextElement,"allArgumentsHaveFormFields")); 292 if (!constraintValid) 293 { 294 validationMessages.add( 295 new ModelValidationMessage( 296 (MetafacadeBase)contextElement , 297 "org::andromda::metafacades::uml::FrontEndControllerOperation::all arguments need an event parameter", 298 "For each controller operation argument there must exist a parameter for each action deferring to that operation. This parameter must carry the same name and must be of the same type.")); 299 } 300 } 301 catch (Throwable th) 302 { 303 Throwable cause = th.getCause(); 304 int depth = 0; // Some throwables have infinite recursion 305 while (cause != null && depth < 7) 306 { 307 th = cause; 308 depth++; 309 } 310 logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndControllerOperation::all arguments need an event parameter' ON " 311 + this.THIS().toString() + ": " + th.getMessage(), th); 312 } 313 try 314 { 315 final Object contextElement = this.THIS(); 316 boolean constraintValid = OCLResultEnsurer.ensure(OCLExpressions.notEqual(OCLIntrospector.invoke(contextElement,"name"),OCLIntrospector.invoke(contextElement,"owner.useCase.name"))); 317 if (!constraintValid) 318 { 319 validationMessages.add( 320 new ModelValidationMessage( 321 (MetafacadeBase)contextElement , 322 "org::andromda::metafacades::uml::FrontEndControllerOperation::the operation name may not be the same as the use-case name", 323 "It is not allowed to give a controller operation the same name as the use-case for which it is defined, please either rename your operation or your use-case.")); 324 } 325 } 326 catch (Throwable th) 327 { 328 Throwable cause = th.getCause(); 329 int depth = 0; // Some throwables have infinite recursion 330 while (cause != null && depth < 7) 331 { 332 th = cause; 333 depth++; 334 } 335 logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndControllerOperation::the operation name may not be the same as the use-case name' ON " 336 + this.THIS().toString() + ": " + th.getMessage(), th); 337 } 338 } 339}