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.FrontEndActionState; 013import org.andromda.metafacades.uml.FrontEndController; 014import org.andromda.metafacades.uml.FrontEndControllerOperation; 015import org.andromda.metafacades.uml.FrontEndForward; 016import org.andromda.metafacades.uml.FrontEndParameter; 017import org.andromda.metafacades.uml.FrontEndView; 018import org.andromda.metafacades.uml.ParameterFacade; 019import org.andromda.metafacades.uml.StateVertexFacade; 020import org.andromda.translation.ocl.validation.OCLCollections; 021import org.andromda.translation.ocl.validation.OCLIntrospector; 022import org.andromda.translation.ocl.validation.OCLResultEnsurer; 023import org.apache.commons.collections.Transformer; 024import org.apache.log4j.Logger; 025 026/** 027 * Represents a "front-end" action. An action is some action that is taken when a front-end even 028 * occurs. 029 * MetafacadeLogic for FrontEndAction 030 * 031 * @see FrontEndAction 032 */ 033public abstract class FrontEndActionLogic 034 extends FrontEndForwardLogicImpl 035 implements FrontEndAction 036{ 037 /** 038 * The underlying UML object 039 * @see Object 040 */ 041 protected Object metaObject; 042 043 /** Create Metafacade implementation instance using the MetafacadeFactory from the context 044 * @param metaObjectIn 045 * @param context 046 */ 047 protected FrontEndActionLogic(Object metaObjectIn, String context) 048 { 049 super(metaObjectIn, getContext(context)); 050 this.metaObject = metaObjectIn; 051 } 052 053 /** 054 * The logger instance. 055 */ 056 private static final Logger logger = Logger.getLogger(FrontEndActionLogic.class); 057 058 /** 059 * Gets the context for this metafacade logic instance. 060 * @param context String. Set to FrontEndAction if null 061 * @return context String 062 */ 063 private static String getContext(String context) 064 { 065 if (context == null) 066 { 067 context = "org.andromda.metafacades.uml.FrontEndAction"; 068 } 069 return context; 070 } 071 072 /** Reset context only for non-root metafacades 073 * @param context 074 */ 075 @Override 076 public void resetMetafacadeContext(String context) 077 { 078 if (!this.contextRoot) // reset context only for non-root metafacades 079 { 080 context = getContext(context); // to have same value as in original constructor call 081 setMetafacadeContext (context); 082 } 083 } 084 085 /** 086 * @return boolean true always 087 * @see FrontEndAction 088 */ 089 public boolean isFrontEndActionMetaType() 090 { 091 return true; 092 } 093 094 // --------------- attributes --------------------- 095 096 /** 097 * @see FrontEndAction#isUseCaseStart() 098 * @return boolean 099 */ 100 protected abstract boolean handleIsUseCaseStart(); 101 102 private boolean __useCaseStart1a; 103 private boolean __useCaseStart1aSet = false; 104 105 /** 106 * Indicates if this action represents the beginning of the front-end use case or not. 107 * @return (boolean)handleIsUseCaseStart() 108 */ 109 public final boolean isUseCaseStart() 110 { 111 boolean useCaseStart1a = this.__useCaseStart1a; 112 if (!this.__useCaseStart1aSet) 113 { 114 // useCaseStart has no pre constraints 115 useCaseStart1a = handleIsUseCaseStart(); 116 // useCaseStart has no post constraints 117 this.__useCaseStart1a = useCaseStart1a; 118 if (isMetafacadePropertyCachingEnabled()) 119 { 120 this.__useCaseStart1aSet = true; 121 } 122 } 123 return useCaseStart1a; 124 } 125 126 // ---------------- business methods ---------------------- 127 128 /** 129 * Method to be implemented in descendants 130 * Finds the parameter on this action having the given name, if no parameter is found, null is 131 * returned instead. 132 * @param name 133 * @return ParameterFacade 134 */ 135 protected abstract ParameterFacade handleFindParameter(String name); 136 137 /** 138 * Finds the parameter on this action having the given name, if no parameter is found, null is 139 * returned instead. 140 * @param name String 141 * The name of the parameter to find on the owner action. 142 * @return handleFindParameter(name) 143 */ 144 public ParameterFacade findParameter(String name) 145 { 146 // findParameter has no pre constraints 147 ParameterFacade returnValue = handleFindParameter(name); 148 // findParameter has no post constraints 149 return returnValue; 150 } 151 152 // ------------- associations ------------------ 153 154 private List<FrontEndForward> __getDecisionTransitions1r; 155 private boolean __getDecisionTransitions1rSet = false; 156 157 /** 158 * Represents a "front-end" action. An action is some action that is taken when a front-end even 159 * occurs. 160 * @return (List<FrontEndForward>)handleGetDecisionTransitions() 161 */ 162 public final List<FrontEndForward> getDecisionTransitions() 163 { 164 List<FrontEndForward> getDecisionTransitions1r = this.__getDecisionTransitions1r; 165 if (!this.__getDecisionTransitions1rSet) 166 { 167 // frontEndAction has no pre constraints 168 List result = handleGetDecisionTransitions(); 169 List shieldedResult = this.shieldedElements(result); 170 try 171 { 172 getDecisionTransitions1r = (List<FrontEndForward>)shieldedResult; 173 } 174 catch (ClassCastException ex) 175 { 176 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 177 FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getDecisionTransitions List<FrontEndForward> " + result + ": " + shieldedResult); 178 } 179 // frontEndAction has no post constraints 180 this.__getDecisionTransitions1r = getDecisionTransitions1r; 181 if (isMetafacadePropertyCachingEnabled()) 182 { 183 this.__getDecisionTransitions1rSet = true; 184 } 185 } 186 return getDecisionTransitions1r; 187 } 188 189 /** 190 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type 191 * @return List 192 */ 193 protected abstract List handleGetDecisionTransitions(); 194 195 private List<FrontEndForward> __getActionForwards2r; 196 private boolean __getActionForwards2rSet = false; 197 198 /** 199 * Represents a "front-end" action. An action is some action that is taken when a front-end even 200 * occurs. 201 * @return (List<FrontEndForward>)handleGetActionForwards() 202 */ 203 public final List<FrontEndForward> getActionForwards() 204 { 205 List<FrontEndForward> getActionForwards2r = this.__getActionForwards2r; 206 if (!this.__getActionForwards2rSet) 207 { 208 // frontEndAction has no pre constraints 209 List result = handleGetActionForwards(); 210 List shieldedResult = this.shieldedElements(result); 211 try 212 { 213 getActionForwards2r = (List<FrontEndForward>)shieldedResult; 214 } 215 catch (ClassCastException ex) 216 { 217 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 218 FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getActionForwards List<FrontEndForward> " + result + ": " + shieldedResult); 219 } 220 // frontEndAction has no post constraints 221 this.__getActionForwards2r = getActionForwards2r; 222 if (isMetafacadePropertyCachingEnabled()) 223 { 224 this.__getActionForwards2rSet = true; 225 } 226 } 227 return getActionForwards2r; 228 } 229 230 /** 231 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type 232 * @return List 233 */ 234 protected abstract List handleGetActionForwards(); 235 236 private List<FrontEndForward> __getTransitions3r; 237 private boolean __getTransitions3rSet = false; 238 239 /** 240 * The front-end actions directly containing this front-end forward. 241 * @return (List<FrontEndForward>)handleGetTransitions() 242 */ 243 public final List<FrontEndForward> getTransitions() 244 { 245 List<FrontEndForward> getTransitions3r = this.__getTransitions3r; 246 if (!this.__getTransitions3rSet) 247 { 248 // actions has no pre constraints 249 List result = handleGetTransitions(); 250 List shieldedResult = this.shieldedElements(result); 251 try 252 { 253 getTransitions3r = (List<FrontEndForward>)shieldedResult; 254 } 255 catch (ClassCastException ex) 256 { 257 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 258 FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getTransitions List<FrontEndForward> " + result + ": " + shieldedResult); 259 } 260 // actions has no post constraints 261 this.__getTransitions3r = getTransitions3r; 262 if (isMetafacadePropertyCachingEnabled()) 263 { 264 this.__getTransitions3rSet = true; 265 } 266 } 267 return getTransitions3r; 268 } 269 270 /** 271 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type 272 * @return List 273 */ 274 protected abstract List handleGetTransitions(); 275 276 private FrontEndController __getController4r; 277 private boolean __getController4rSet = false; 278 279 /** 280 * All actions that defer to at least one operation of this controller. 281 * @return (FrontEndController)handleGetController() 282 */ 283 public final FrontEndController getController() 284 { 285 FrontEndController getController4r = this.__getController4r; 286 if (!this.__getController4rSet) 287 { 288 // deferringActions has no pre constraints 289 Object result = handleGetController(); 290 MetafacadeBase shieldedResult = this.shieldedElement(result); 291 try 292 { 293 getController4r = (FrontEndController)shieldedResult; 294 } 295 catch (ClassCastException ex) 296 { 297 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 298 FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getController FrontEndController " + result + ": " + shieldedResult); 299 } 300 // deferringActions has no post constraints 301 this.__getController4r = getController4r; 302 if (isMetafacadePropertyCachingEnabled()) 303 { 304 this.__getController4rSet = true; 305 } 306 } 307 return getController4r; 308 } 309 310 /** 311 * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type 312 * @return Object 313 */ 314 protected abstract Object handleGetController(); 315 316 private List<FrontEndParameter> __getParameters5r; 317 private boolean __getParameters5rSet = false; 318 319 /** 320 * The action to which this parameter belongs (if it belongs to an action), otherwise it returns 321 * null. 322 * @return (List<FrontEndParameter>)handleGetParameters() 323 */ 324 public final List<FrontEndParameter> getParameters() 325 { 326 List<FrontEndParameter> getParameters5r = this.__getParameters5r; 327 if (!this.__getParameters5rSet) 328 { 329 // action has no pre constraints 330 List result = handleGetParameters(); 331 List shieldedResult = this.shieldedElements(result); 332 try 333 { 334 getParameters5r = (List<FrontEndParameter>)shieldedResult; 335 } 336 catch (ClassCastException ex) 337 { 338 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 339 FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getParameters List<FrontEndParameter> " + result + ": " + shieldedResult); 340 } 341 // action has no post constraints 342 this.__getParameters5r = getParameters5r; 343 if (isMetafacadePropertyCachingEnabled()) 344 { 345 this.__getParameters5rSet = true; 346 } 347 } 348 return getParameters5r; 349 } 350 351 /** 352 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type 353 * @return List 354 */ 355 protected abstract List handleGetParameters(); 356 357 private List<FrontEndActionState> __getActionStates6r; 358 private boolean __getActionStates6rSet = false; 359 360 /** 361 * The actions that pass through this action state. 362 * @return (List<FrontEndActionState>)handleGetActionStates() 363 */ 364 public final List<FrontEndActionState> getActionStates() 365 { 366 List<FrontEndActionState> getActionStates6r = this.__getActionStates6r; 367 if (!this.__getActionStates6rSet) 368 { 369 // containerActions has no pre constraints 370 List result = handleGetActionStates(); 371 List shieldedResult = this.shieldedElements(result); 372 try 373 { 374 getActionStates6r = (List<FrontEndActionState>)shieldedResult; 375 } 376 catch (ClassCastException ex) 377 { 378 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 379 FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getActionStates List<FrontEndActionState> " + result + ": " + shieldedResult); 380 } 381 // containerActions has no post constraints 382 this.__getActionStates6r = getActionStates6r; 383 if (isMetafacadePropertyCachingEnabled()) 384 { 385 this.__getActionStates6rSet = true; 386 } 387 } 388 return getActionStates6r; 389 } 390 391 /** 392 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type 393 * @return List 394 */ 395 protected abstract List handleGetActionStates(); 396 397 private List<FrontEndParameter> __getFormFields7r; 398 private boolean __getFormFields7rSet = false; 399 400 /** 401 * Represents a "front-end" action. An action is some action that is taken when a front-end even 402 * occurs. 403 * @return (List<FrontEndParameter>)handleGetFormFields() 404 */ 405 public final List<FrontEndParameter> getFormFields() 406 { 407 List<FrontEndParameter> getFormFields7r = this.__getFormFields7r; 408 if (!this.__getFormFields7rSet) 409 { 410 // frontEndAction has no pre constraints 411 List result = handleGetFormFields(); 412 List shieldedResult = this.shieldedElements(result); 413 try 414 { 415 getFormFields7r = (List<FrontEndParameter>)shieldedResult; 416 } 417 catch (ClassCastException ex) 418 { 419 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 420 FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getFormFields List<FrontEndParameter> " + result + ": " + shieldedResult); 421 } 422 // frontEndAction has no post constraints 423 this.__getFormFields7r = getFormFields7r; 424 if (isMetafacadePropertyCachingEnabled()) 425 { 426 this.__getFormFields7rSet = true; 427 } 428 } 429 return getFormFields7r; 430 } 431 432 /** 433 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type 434 * @return List 435 */ 436 protected abstract List handleGetFormFields(); 437 438 private List<FrontEndView> __getTargetViews8r; 439 private boolean __getTargetViews8rSet = false; 440 441 /** 442 * Represents a "front-end" action. An action is some action that is taken when a front-end even 443 * occurs. 444 * @return (List<FrontEndView>)handleGetTargetViews() 445 */ 446 public final List<FrontEndView> getTargetViews() 447 { 448 List<FrontEndView> getTargetViews8r = this.__getTargetViews8r; 449 if (!this.__getTargetViews8rSet) 450 { 451 // frontEndAction has no pre constraints 452 List result = handleGetTargetViews(); 453 List shieldedResult = this.shieldedElements(result); 454 try 455 { 456 getTargetViews8r = (List<FrontEndView>)shieldedResult; 457 } 458 catch (ClassCastException ex) 459 { 460 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 461 FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getTargetViews List<FrontEndView> " + result + ": " + shieldedResult); 462 } 463 // frontEndAction has no post constraints 464 this.__getTargetViews8r = getTargetViews8r; 465 if (isMetafacadePropertyCachingEnabled()) 466 { 467 this.__getTargetViews8rSet = true; 468 } 469 } 470 return getTargetViews8r; 471 } 472 473 /** 474 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type 475 * @return List 476 */ 477 protected abstract List handleGetTargetViews(); 478 479 private List<FrontEndControllerOperation> __getDeferredOperations9r; 480 private boolean __getDeferredOperations9rSet = false; 481 482 /** 483 * All those actions that contain at least one front-end action state that is deferring to this 484 * operation. 485 * @return (List<FrontEndControllerOperation>)handleGetDeferredOperations() 486 */ 487 public final List<FrontEndControllerOperation> getDeferredOperations() 488 { 489 List<FrontEndControllerOperation> getDeferredOperations9r = this.__getDeferredOperations9r; 490 if (!this.__getDeferredOperations9rSet) 491 { 492 // deferringActions has no pre constraints 493 List result = handleGetDeferredOperations(); 494 List shieldedResult = this.shieldedElements(result); 495 try 496 { 497 getDeferredOperations9r = (List<FrontEndControllerOperation>)shieldedResult; 498 } 499 catch (ClassCastException ex) 500 { 501 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 502 FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getDeferredOperations List<FrontEndControllerOperation> " + result + ": " + shieldedResult); 503 } 504 // deferringActions has no post constraints 505 this.__getDeferredOperations9r = getDeferredOperations9r; 506 if (isMetafacadePropertyCachingEnabled()) 507 { 508 this.__getDeferredOperations9rSet = true; 509 } 510 } 511 return getDeferredOperations9r; 512 } 513 514 /** 515 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type 516 * @return List 517 */ 518 protected abstract List handleGetDeferredOperations(); 519 520 /** 521 * Represents a "front-end" action. An action is some action that is taken when a front-end even 522 * occurs. 523 * @return (StateVertexFacade)handleGetInput() 524 */ 525 public final StateVertexFacade getInput() 526 { 527 StateVertexFacade getInput10r = null; 528 // frontEndAction has no pre constraints 529 Object result = handleGetInput(); 530 MetafacadeBase shieldedResult = this.shieldedElement(result); 531 try 532 { 533 getInput10r = (StateVertexFacade)shieldedResult; 534 } 535 catch (ClassCastException ex) 536 { 537 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 538 FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getInput StateVertexFacade " + result + ": " + shieldedResult); 539 } 540 // frontEndAction has no post constraints 541 return getInput10r; 542 } 543 544 /** 545 * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type 546 * @return Object 547 */ 548 protected abstract Object handleGetInput(); 549 550 /** 551 * <p><b>Constraint:</b> org::andromda::metafacades::uml::FrontEndAction::parameters must be unique</p> 552 * <p><b>Error:</b> Each front-end action parameter must have a unique name.</p> 553 * <p><b>OCL:</b> context FrontEndAction 554inv : parameters -> isUnique(name)</p> 555 * <p><b>Constraint:</b> org::andromda::metafacades::uml::FrontEndAction::each action must carry a trigger</p> 556 * <p><b>Error:</b> Each action transition coming out of a view must have a trigger (the name is sufficient), it is recommended to add a trigger of type 'signal'.</p> 557 * <p><b>OCL:</b> context FrontEndAction inv: exitingView implies triggerPresent</p> 558 * @param validationMessages Collection<ModelValidationMessage> 559 * @see FrontEndForwardLogicImpl#validateInvariants(Collection validationMessages) 560 */ 561 @Override 562 public void validateInvariants(Collection<ModelValidationMessage> validationMessages) 563 { 564 super.validateInvariants(validationMessages); 565 try 566 { 567 final Object contextElement = this.THIS(); 568 boolean constraintValid = OCLResultEnsurer.ensure(OCLCollections.isUnique(OCLIntrospector.invoke(contextElement,"parameters"),new Transformer(){public Object transform(Object object){return OCLIntrospector.invoke(object,"name");}})); 569 if (!constraintValid) 570 { 571 validationMessages.add( 572 new ModelValidationMessage( 573 (MetafacadeBase)contextElement , 574 "org::andromda::metafacades::uml::FrontEndAction::parameters must be unique", 575 "Each front-end action parameter must have a unique name.")); 576 } 577 } 578 catch (Throwable th) 579 { 580 Throwable cause = th.getCause(); 581 int depth = 0; // Some throwables have infinite recursion 582 while (cause != null && depth < 7) 583 { 584 th = cause; 585 depth++; 586 } 587 logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndAction::parameters must be unique' ON " 588 + this.THIS().toString() + ": " + th.getMessage(), th); 589 } 590 try 591 { 592 final Object contextElement = this.THIS(); 593 boolean constraintValid = OCLResultEnsurer.ensure((Boolean.valueOf(String.valueOf(Boolean.valueOf(String.valueOf(OCLIntrospector.invoke(contextElement,"exitingView"))).booleanValue())).booleanValue()?Boolean.valueOf(String.valueOf(OCLIntrospector.invoke(contextElement,"triggerPresent"))).booleanValue():true)); 594 if (!constraintValid) 595 { 596 validationMessages.add( 597 new ModelValidationMessage( 598 (MetafacadeBase)contextElement , 599 "org::andromda::metafacades::uml::FrontEndAction::each action must carry a trigger", 600 "Each action transition coming out of a view must have a trigger (the name is sufficient), it is recommended to add a trigger of type 'signal'.")); 601 } 602 } 603 catch (Throwable th) 604 { 605 Throwable cause = th.getCause(); 606 int depth = 0; // Some throwables have infinite recursion 607 while (cause != null && depth < 7) 608 { 609 th = cause; 610 depth++; 611 } 612 logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndAction::each action must carry a trigger' ON " 613 + this.THIS().toString() + ": " + th.getMessage(), th); 614 } 615 } 616}