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.FrontEndParameter; 013import org.andromda.metafacades.uml.FrontEndUseCase; 014import org.andromda.metafacades.uml.FrontEndView; 015import org.andromda.translation.ocl.validation.OCLCollections; 016import org.andromda.translation.ocl.validation.OCLExpressions; 017import org.andromda.translation.ocl.validation.OCLIntrospector; 018import org.andromda.translation.ocl.validation.OCLResultEnsurer; 019import org.apache.commons.collections.Transformer; 020import org.apache.log4j.Logger; 021 022/** 023 * Represents a view within a front end application. 024 * MetafacadeLogic for FrontEndView 025 * 026 * @see FrontEndView 027 */ 028public abstract class FrontEndViewLogic 029 extends FrontEndActionStateLogicImpl 030 implements FrontEndView 031{ 032 /** 033 * The underlying UML object 034 * @see Object 035 */ 036 protected Object metaObject; 037 038 /** Create Metafacade implementation instance using the MetafacadeFactory from the context 039 * @param metaObjectIn 040 * @param context 041 */ 042 protected FrontEndViewLogic(Object metaObjectIn, String context) 043 { 044 super(metaObjectIn, getContext(context)); 045 this.metaObject = metaObjectIn; 046 } 047 048 /** 049 * The logger instance. 050 */ 051 private static final Logger logger = Logger.getLogger(FrontEndViewLogic.class); 052 053 /** 054 * Gets the context for this metafacade logic instance. 055 * @param context String. Set to FrontEndView if null 056 * @return context String 057 */ 058 private static String getContext(String context) 059 { 060 if (context == null) 061 { 062 context = "org.andromda.metafacades.uml.FrontEndView"; 063 } 064 return context; 065 } 066 067 /** Reset context only for non-root metafacades 068 * @param context 069 */ 070 @Override 071 public void resetMetafacadeContext(String context) 072 { 073 if (!this.contextRoot) // reset context only for non-root metafacades 074 { 075 context = getContext(context); // to have same value as in original constructor call 076 setMetafacadeContext (context); 077 } 078 } 079 080 /** 081 * @return boolean true always 082 * @see FrontEndView 083 */ 084 public boolean isFrontEndViewMetaType() 085 { 086 return true; 087 } 088 089 // --------------- attributes --------------------- 090 091 /** 092 * @see FrontEndView#isFrontEndView() 093 * @return boolean 094 */ 095 protected abstract boolean handleIsFrontEndView(); 096 097 private boolean __frontEndView1a; 098 private boolean __frontEndView1aSet = false; 099 100 /** 101 * True if this element carries the FrontEndView stereotype. 102 * @return (boolean)handleIsFrontEndView() 103 */ 104 public final boolean isFrontEndView() 105 { 106 boolean frontEndView1a = this.__frontEndView1a; 107 if (!this.__frontEndView1aSet) 108 { 109 // frontEndView has no pre constraints 110 frontEndView1a = handleIsFrontEndView(); 111 // frontEndView has no post constraints 112 this.__frontEndView1a = frontEndView1a; 113 if (isMetafacadePropertyCachingEnabled()) 114 { 115 this.__frontEndView1aSet = true; 116 } 117 } 118 return frontEndView1a; 119 } 120 121 // ------------- associations ------------------ 122 123 private List<FrontEndParameter> __getAllActionParameters1r; 124 private boolean __getAllActionParameters1rSet = false; 125 126 /** 127 * Represents a view within a front end application. 128 * @return (List<FrontEndParameter>)handleGetAllActionParameters() 129 */ 130 public final List<FrontEndParameter> getAllActionParameters() 131 { 132 List<FrontEndParameter> getAllActionParameters1r = this.__getAllActionParameters1r; 133 if (!this.__getAllActionParameters1rSet) 134 { 135 // frontEndView has no pre constraints 136 List result = handleGetAllActionParameters(); 137 List shieldedResult = this.shieldedElements(result); 138 try 139 { 140 getAllActionParameters1r = (List<FrontEndParameter>)shieldedResult; 141 } 142 catch (ClassCastException ex) 143 { 144 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 145 FrontEndViewLogic.logger.warn("incorrect metafacade cast for FrontEndViewLogic.getAllActionParameters List<FrontEndParameter> " + result + ": " + shieldedResult); 146 } 147 // frontEndView has no post constraints 148 this.__getAllActionParameters1r = getAllActionParameters1r; 149 if (isMetafacadePropertyCachingEnabled()) 150 { 151 this.__getAllActionParameters1rSet = true; 152 } 153 } 154 return getAllActionParameters1r; 155 } 156 157 /** 158 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type 159 * @return List 160 */ 161 protected abstract List handleGetAllActionParameters(); 162 163 private List<FrontEndParameter> __getAllFormFields2r; 164 private boolean __getAllFormFields2rSet = false; 165 166 /** 167 * Represents a view within a front end application. 168 * @return (List<FrontEndParameter>)handleGetAllFormFields() 169 */ 170 public final List<FrontEndParameter> getAllFormFields() 171 { 172 List<FrontEndParameter> getAllFormFields2r = this.__getAllFormFields2r; 173 if (!this.__getAllFormFields2rSet) 174 { 175 // frontEndView has no pre constraints 176 List result = handleGetAllFormFields(); 177 List shieldedResult = this.shieldedElements(result); 178 try 179 { 180 getAllFormFields2r = (List<FrontEndParameter>)shieldedResult; 181 } 182 catch (ClassCastException ex) 183 { 184 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 185 FrontEndViewLogic.logger.warn("incorrect metafacade cast for FrontEndViewLogic.getAllFormFields List<FrontEndParameter> " + result + ": " + shieldedResult); 186 } 187 // frontEndView has no post constraints 188 this.__getAllFormFields2r = getAllFormFields2r; 189 if (isMetafacadePropertyCachingEnabled()) 190 { 191 this.__getAllFormFields2rSet = true; 192 } 193 } 194 return getAllFormFields2r; 195 } 196 197 /** 198 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type 199 * @return List 200 */ 201 protected abstract List handleGetAllFormFields(); 202 203 private List<FrontEndParameter> __getVariables3r; 204 private boolean __getVariables3rSet = false; 205 206 /** 207 * Represents the view in which this parameter will be used. 208 * @return (List<FrontEndParameter>)handleGetVariables() 209 */ 210 public final List<FrontEndParameter> getVariables() 211 { 212 List<FrontEndParameter> getVariables3r = this.__getVariables3r; 213 if (!this.__getVariables3rSet) 214 { 215 // view has no pre constraints 216 List result = handleGetVariables(); 217 List shieldedResult = this.shieldedElements(result); 218 try 219 { 220 getVariables3r = (List<FrontEndParameter>)shieldedResult; 221 } 222 catch (ClassCastException ex) 223 { 224 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 225 FrontEndViewLogic.logger.warn("incorrect metafacade cast for FrontEndViewLogic.getVariables List<FrontEndParameter> " + result + ": " + shieldedResult); 226 } 227 // view has no post constraints 228 this.__getVariables3r = getVariables3r; 229 if (isMetafacadePropertyCachingEnabled()) 230 { 231 this.__getVariables3rSet = true; 232 } 233 } 234 return getVariables3r; 235 } 236 237 /** 238 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type 239 * @return List 240 */ 241 protected abstract List handleGetVariables(); 242 243 private FrontEndUseCase __getUseCase4r; 244 private boolean __getUseCase4rSet = false; 245 246 /** 247 * All views that are part of this use case. 248 * @return (FrontEndUseCase)handleGetUseCase() 249 */ 250 public final FrontEndUseCase getUseCase() 251 { 252 FrontEndUseCase getUseCase4r = this.__getUseCase4r; 253 if (!this.__getUseCase4rSet) 254 { 255 // views has no pre constraints 256 Object result = handleGetUseCase(); 257 MetafacadeBase shieldedResult = this.shieldedElement(result); 258 try 259 { 260 getUseCase4r = (FrontEndUseCase)shieldedResult; 261 } 262 catch (ClassCastException ex) 263 { 264 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 265 FrontEndViewLogic.logger.warn("incorrect metafacade cast for FrontEndViewLogic.getUseCase FrontEndUseCase " + result + ": " + shieldedResult); 266 } 267 // views has no post constraints 268 this.__getUseCase4r = getUseCase4r; 269 if (isMetafacadePropertyCachingEnabled()) 270 { 271 this.__getUseCase4rSet = true; 272 } 273 } 274 return getUseCase4r; 275 } 276 277 /** 278 * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type 279 * @return Object 280 */ 281 protected abstract Object handleGetUseCase(); 282 283 private List<FrontEndParameter> __getTables5r; 284 private boolean __getTables5rSet = false; 285 286 /** 287 * Represents a view within a front end application. 288 * @return (List<FrontEndParameter>)handleGetTables() 289 */ 290 public final List<FrontEndParameter> getTables() 291 { 292 List<FrontEndParameter> getTables5r = this.__getTables5r; 293 if (!this.__getTables5rSet) 294 { 295 // frontEndView has no pre constraints 296 List result = handleGetTables(); 297 List shieldedResult = this.shieldedElements(result); 298 try 299 { 300 getTables5r = (List<FrontEndParameter>)shieldedResult; 301 } 302 catch (ClassCastException ex) 303 { 304 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 305 FrontEndViewLogic.logger.warn("incorrect metafacade cast for FrontEndViewLogic.getTables List<FrontEndParameter> " + result + ": " + shieldedResult); 306 } 307 // frontEndView has no post constraints 308 this.__getTables5r = getTables5r; 309 if (isMetafacadePropertyCachingEnabled()) 310 { 311 this.__getTables5rSet = true; 312 } 313 } 314 return getTables5r; 315 } 316 317 /** 318 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type 319 * @return List 320 */ 321 protected abstract List handleGetTables(); 322 323 private List<FrontEndAction> __getActions6r; 324 private boolean __getActions6rSet = false; 325 326 /** 327 * The StateVertex (FrontEndView or PseudostateFacade) on which this action can be triggered. 328 * @return (List<FrontEndAction>)handleGetActions() 329 */ 330 public final List<FrontEndAction> getActions() 331 { 332 List<FrontEndAction> getActions6r = this.__getActions6r; 333 if (!this.__getActions6rSet) 334 { 335 // input has no pre constraints 336 List result = handleGetActions(); 337 List shieldedResult = this.shieldedElements(result); 338 try 339 { 340 getActions6r = (List<FrontEndAction>)shieldedResult; 341 } 342 catch (ClassCastException ex) 343 { 344 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 345 FrontEndViewLogic.logger.warn("incorrect metafacade cast for FrontEndViewLogic.getActions List<FrontEndAction> " + result + ": " + shieldedResult); 346 } 347 // input has no post constraints 348 this.__getActions6r = getActions6r; 349 if (isMetafacadePropertyCachingEnabled()) 350 { 351 this.__getActions6rSet = true; 352 } 353 } 354 return getActions6r; 355 } 356 357 /** 358 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type 359 * @return List 360 */ 361 protected abstract List handleGetActions(); 362 363 /** 364 * <p><b>Constraint:</b> org::andromda::metafacades::uml::FrontEndView::unique view name per usecase</p> 365 * <p><b>Error:</b> Each name of a view action state must be unique in the namespace of a front-end use-case.</p> 366 * <p><b>OCL:</b> context FrontEndView inv: useCase.views->isUnique(name)</p> 367 * <p><b>Constraint:</b> org::andromda::metafacades::uml::FrontEndView::view variables must have unique names</p> 368 * <p><b>Error:</b> Each view-variable should have a unique name within the context of a view.</p> 369 * <p><b>OCL:</b> context FrontEndView inv : variables->isUnique(name)</p> 370 * <p><b>Constraint:</b> org::andromda::metafacades::uml::FrontEndView::front-end views cannot defer operations</p> 371 * <p><b>Error:</b> Views cannot defer to operations. All deferrable events modeled on a front-end view will be ignored.</p> 372 * <p><b>OCL:</b> context FrontEndView inv: controllerCalls->size() = 0</p> 373 * <p><b>Constraint:</b> org::andromda::metafacades::uml::FrontEndView::each action going out of a front-end view must be unique</p> 374 * <p><b>Error:</b> Each view must contain actions which each have a unique name, this view has actions with duplicate names.</p> 375 * <p><b>OCL:</b> context FrontEndView inv: actions->isUnique(name)</p> 376 * @param validationMessages Collection<ModelValidationMessage> 377 * @see FrontEndActionStateLogicImpl#validateInvariants(Collection validationMessages) 378 */ 379 @Override 380 public void validateInvariants(Collection<ModelValidationMessage> validationMessages) 381 { 382 super.validateInvariants(validationMessages); 383 try 384 { 385 final Object contextElement = this.THIS(); 386 boolean constraintValid = OCLResultEnsurer.ensure(OCLCollections.isUnique(OCLIntrospector.invoke(contextElement,"useCase.views"),new Transformer(){public Object transform(Object object){return OCLIntrospector.invoke(object,"name");}})); 387 if (!constraintValid) 388 { 389 validationMessages.add( 390 new ModelValidationMessage( 391 (MetafacadeBase)contextElement , 392 "org::andromda::metafacades::uml::FrontEndView::unique view name per usecase", 393 "Each name of a view action state must be unique in the namespace of a front-end use-case.")); 394 } 395 } 396 catch (Throwable th) 397 { 398 Throwable cause = th.getCause(); 399 int depth = 0; // Some throwables have infinite recursion 400 while (cause != null && depth < 7) 401 { 402 th = cause; 403 depth++; 404 } 405 logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndView::unique view name per usecase' ON " 406 + this.THIS().toString() + ": " + th.getMessage(), th); 407 } 408 try 409 { 410 final Object contextElement = this.THIS(); 411 boolean constraintValid = OCLResultEnsurer.ensure(OCLCollections.isUnique(OCLIntrospector.invoke(contextElement,"variables"),new Transformer(){public Object transform(Object object){return OCLIntrospector.invoke(object,"name");}})); 412 if (!constraintValid) 413 { 414 validationMessages.add( 415 new ModelValidationMessage( 416 (MetafacadeBase)contextElement , 417 "org::andromda::metafacades::uml::FrontEndView::view variables must have unique names", 418 "Each view-variable should have a unique name within the context of a view.")); 419 } 420 } 421 catch (Throwable th) 422 { 423 Throwable cause = th.getCause(); 424 int depth = 0; // Some throwables have infinite recursion 425 while (cause != null && depth < 7) 426 { 427 th = cause; 428 depth++; 429 } 430 logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndView::view variables must have unique names' ON " 431 + this.THIS().toString() + ": " + th.getMessage(), th); 432 } 433 try 434 { 435 final Object contextElement = this.THIS(); 436 boolean constraintValid = OCLResultEnsurer.ensure(OCLExpressions.equal(OCLCollections.size(OCLIntrospector.invoke(contextElement,"controllerCalls")),0)); 437 if (!constraintValid) 438 { 439 validationMessages.add( 440 new ModelValidationMessage( 441 (MetafacadeBase)contextElement , 442 "org::andromda::metafacades::uml::FrontEndView::front-end views cannot defer operations", 443 "Views cannot defer to operations. All deferrable events modeled on a front-end view will be ignored.")); 444 } 445 } 446 catch (Throwable th) 447 { 448 Throwable cause = th.getCause(); 449 int depth = 0; // Some throwables have infinite recursion 450 while (cause != null && depth < 7) 451 { 452 th = cause; 453 depth++; 454 } 455 logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndView::front-end views cannot defer operations' ON " 456 + this.THIS().toString() + ": " + th.getMessage(), th); 457 } 458 try 459 { 460 final Object contextElement = this.THIS(); 461 boolean constraintValid = OCLResultEnsurer.ensure(OCLCollections.isUnique(OCLIntrospector.invoke(contextElement,"actions"),new Transformer(){public Object transform(Object object){return OCLIntrospector.invoke(object,"name");}})); 462 if (!constraintValid) 463 { 464 validationMessages.add( 465 new ModelValidationMessage( 466 (MetafacadeBase)contextElement , 467 "org::andromda::metafacades::uml::FrontEndView::each action going out of a front-end view must be unique", 468 "Each view must contain actions which each have a unique name, this view has actions with duplicate names.")); 469 } 470 } 471 catch (Throwable th) 472 { 473 Throwable cause = th.getCause(); 474 int depth = 0; // Some throwables have infinite recursion 475 while (cause != null && depth < 7) 476 { 477 th = cause; 478 depth++; 479 } 480 logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndView::each action going out of a front-end view must be unique' ON " 481 + this.THIS().toString() + ": " + th.getMessage(), th); 482 } 483 } 484}