FrontEndActionLogic.java
// license-header java merge-point
//
// Attention: generated code (by MetafacadeLogic.vsl) - do not modify!
//
package org.andromda.metafacades.emf.uml22;
import java.util.Collection;
import java.util.List;
import org.andromda.core.metafacade.MetafacadeBase;
import org.andromda.core.metafacade.ModelValidationMessage;
import org.andromda.metafacades.uml.FrontEndAction;
import org.andromda.metafacades.uml.FrontEndActionState;
import org.andromda.metafacades.uml.FrontEndController;
import org.andromda.metafacades.uml.FrontEndControllerOperation;
import org.andromda.metafacades.uml.FrontEndForward;
import org.andromda.metafacades.uml.FrontEndParameter;
import org.andromda.metafacades.uml.FrontEndView;
import org.andromda.metafacades.uml.ParameterFacade;
import org.andromda.metafacades.uml.StateVertexFacade;
import org.andromda.translation.ocl.validation.OCLCollections;
import org.andromda.translation.ocl.validation.OCLIntrospector;
import org.andromda.translation.ocl.validation.OCLResultEnsurer;
import org.apache.commons.collections.Transformer;
import org.apache.log4j.Logger;
/**
* Represents a "front-end" action. An action is some action that is taken when a front-end even
* occurs.
* MetafacadeLogic for FrontEndAction
*
* @see FrontEndAction
*/
public abstract class FrontEndActionLogic
extends FrontEndForwardLogicImpl
implements FrontEndAction
{
/**
* The underlying UML object
* @see Object
*/
protected Object metaObject;
/** Create Metafacade implementation instance using the MetafacadeFactory from the context
* @param metaObjectIn
* @param context
*/
protected FrontEndActionLogic(Object metaObjectIn, String context)
{
super(metaObjectIn, getContext(context));
this.metaObject = metaObjectIn;
}
/**
* The logger instance.
*/
private static final Logger logger = Logger.getLogger(FrontEndActionLogic.class);
/**
* Gets the context for this metafacade logic instance.
* @param context String. Set to FrontEndAction if null
* @return context String
*/
private static String getContext(String context)
{
if (context == null)
{
context = "org.andromda.metafacades.uml.FrontEndAction";
}
return context;
}
/** Reset context only for non-root metafacades
* @param context
*/
@Override
public void resetMetafacadeContext(String context)
{
if (!this.contextRoot) // reset context only for non-root metafacades
{
context = getContext(context); // to have same value as in original constructor call
setMetafacadeContext (context);
}
}
/**
* @return boolean true always
* @see FrontEndAction
*/
public boolean isFrontEndActionMetaType()
{
return true;
}
// --------------- attributes ---------------------
/**
* @see FrontEndAction#isUseCaseStart()
* @return boolean
*/
protected abstract boolean handleIsUseCaseStart();
private boolean __useCaseStart1a;
private boolean __useCaseStart1aSet = false;
/**
* Indicates if this action represents the beginning of the front-end use case or not.
* @return (boolean)handleIsUseCaseStart()
*/
public final boolean isUseCaseStart()
{
boolean useCaseStart1a = this.__useCaseStart1a;
if (!this.__useCaseStart1aSet)
{
// useCaseStart has no pre constraints
useCaseStart1a = handleIsUseCaseStart();
// useCaseStart has no post constraints
this.__useCaseStart1a = useCaseStart1a;
if (isMetafacadePropertyCachingEnabled())
{
this.__useCaseStart1aSet = true;
}
}
return useCaseStart1a;
}
// ---------------- business methods ----------------------
/**
* Method to be implemented in descendants
* Finds the parameter on this action having the given name, if no parameter is found, null is
* returned instead.
* @param name
* @return ParameterFacade
*/
protected abstract ParameterFacade handleFindParameter(String name);
/**
* Finds the parameter on this action having the given name, if no parameter is found, null is
* returned instead.
* @param name String
* The name of the parameter to find on the owner action.
* @return handleFindParameter(name)
*/
public ParameterFacade findParameter(String name)
{
// findParameter has no pre constraints
ParameterFacade returnValue = handleFindParameter(name);
// findParameter has no post constraints
return returnValue;
}
// ------------- associations ------------------
private List<FrontEndForward> __getDecisionTransitions1r;
private boolean __getDecisionTransitions1rSet = false;
/**
* Represents a "front-end" action. An action is some action that is taken when a front-end even
* occurs.
* @return (List<FrontEndForward>)handleGetDecisionTransitions()
*/
public final List<FrontEndForward> getDecisionTransitions()
{
List<FrontEndForward> getDecisionTransitions1r = this.__getDecisionTransitions1r;
if (!this.__getDecisionTransitions1rSet)
{
// frontEndAction has no pre constraints
List result = handleGetDecisionTransitions();
List shieldedResult = this.shieldedElements(result);
try
{
getDecisionTransitions1r = (List<FrontEndForward>)shieldedResult;
}
catch (ClassCastException ex)
{
// Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getDecisionTransitions List<FrontEndForward> " + result + ": " + shieldedResult);
}
// frontEndAction has no post constraints
this.__getDecisionTransitions1r = getDecisionTransitions1r;
if (isMetafacadePropertyCachingEnabled())
{
this.__getDecisionTransitions1rSet = true;
}
}
return getDecisionTransitions1r;
}
/**
* UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
* @return List
*/
protected abstract List handleGetDecisionTransitions();
private List<FrontEndForward> __getActionForwards2r;
private boolean __getActionForwards2rSet = false;
/**
* Represents a "front-end" action. An action is some action that is taken when a front-end even
* occurs.
* @return (List<FrontEndForward>)handleGetActionForwards()
*/
public final List<FrontEndForward> getActionForwards()
{
List<FrontEndForward> getActionForwards2r = this.__getActionForwards2r;
if (!this.__getActionForwards2rSet)
{
// frontEndAction has no pre constraints
List result = handleGetActionForwards();
List shieldedResult = this.shieldedElements(result);
try
{
getActionForwards2r = (List<FrontEndForward>)shieldedResult;
}
catch (ClassCastException ex)
{
// Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getActionForwards List<FrontEndForward> " + result + ": " + shieldedResult);
}
// frontEndAction has no post constraints
this.__getActionForwards2r = getActionForwards2r;
if (isMetafacadePropertyCachingEnabled())
{
this.__getActionForwards2rSet = true;
}
}
return getActionForwards2r;
}
/**
* UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
* @return List
*/
protected abstract List handleGetActionForwards();
private List<FrontEndForward> __getTransitions3r;
private boolean __getTransitions3rSet = false;
/**
* The front-end actions directly containing this front-end forward.
* @return (List<FrontEndForward>)handleGetTransitions()
*/
public final List<FrontEndForward> getTransitions()
{
List<FrontEndForward> getTransitions3r = this.__getTransitions3r;
if (!this.__getTransitions3rSet)
{
// actions has no pre constraints
List result = handleGetTransitions();
List shieldedResult = this.shieldedElements(result);
try
{
getTransitions3r = (List<FrontEndForward>)shieldedResult;
}
catch (ClassCastException ex)
{
// Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getTransitions List<FrontEndForward> " + result + ": " + shieldedResult);
}
// actions has no post constraints
this.__getTransitions3r = getTransitions3r;
if (isMetafacadePropertyCachingEnabled())
{
this.__getTransitions3rSet = true;
}
}
return getTransitions3r;
}
/**
* UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
* @return List
*/
protected abstract List handleGetTransitions();
private FrontEndController __getController4r;
private boolean __getController4rSet = false;
/**
* All actions that defer to at least one operation of this controller.
* @return (FrontEndController)handleGetController()
*/
public final FrontEndController getController()
{
FrontEndController getController4r = this.__getController4r;
if (!this.__getController4rSet)
{
// deferringActions has no pre constraints
Object result = handleGetController();
MetafacadeBase shieldedResult = this.shieldedElement(result);
try
{
getController4r = (FrontEndController)shieldedResult;
}
catch (ClassCastException ex)
{
// Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getController FrontEndController " + result + ": " + shieldedResult);
}
// deferringActions has no post constraints
this.__getController4r = getController4r;
if (isMetafacadePropertyCachingEnabled())
{
this.__getController4rSet = true;
}
}
return getController4r;
}
/**
* UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
* @return Object
*/
protected abstract Object handleGetController();
private List<FrontEndParameter> __getParameters5r;
private boolean __getParameters5rSet = false;
/**
* The action to which this parameter belongs (if it belongs to an action), otherwise it returns
* null.
* @return (List<FrontEndParameter>)handleGetParameters()
*/
public final List<FrontEndParameter> getParameters()
{
List<FrontEndParameter> getParameters5r = this.__getParameters5r;
if (!this.__getParameters5rSet)
{
// action has no pre constraints
List result = handleGetParameters();
List shieldedResult = this.shieldedElements(result);
try
{
getParameters5r = (List<FrontEndParameter>)shieldedResult;
}
catch (ClassCastException ex)
{
// Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getParameters List<FrontEndParameter> " + result + ": " + shieldedResult);
}
// action has no post constraints
this.__getParameters5r = getParameters5r;
if (isMetafacadePropertyCachingEnabled())
{
this.__getParameters5rSet = true;
}
}
return getParameters5r;
}
/**
* UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
* @return List
*/
protected abstract List handleGetParameters();
private List<FrontEndActionState> __getActionStates6r;
private boolean __getActionStates6rSet = false;
/**
* The actions that pass through this action state.
* @return (List<FrontEndActionState>)handleGetActionStates()
*/
public final List<FrontEndActionState> getActionStates()
{
List<FrontEndActionState> getActionStates6r = this.__getActionStates6r;
if (!this.__getActionStates6rSet)
{
// containerActions has no pre constraints
List result = handleGetActionStates();
List shieldedResult = this.shieldedElements(result);
try
{
getActionStates6r = (List<FrontEndActionState>)shieldedResult;
}
catch (ClassCastException ex)
{
// Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getActionStates List<FrontEndActionState> " + result + ": " + shieldedResult);
}
// containerActions has no post constraints
this.__getActionStates6r = getActionStates6r;
if (isMetafacadePropertyCachingEnabled())
{
this.__getActionStates6rSet = true;
}
}
return getActionStates6r;
}
/**
* UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
* @return List
*/
protected abstract List handleGetActionStates();
private List<FrontEndParameter> __getFormFields7r;
private boolean __getFormFields7rSet = false;
/**
* Represents a "front-end" action. An action is some action that is taken when a front-end even
* occurs.
* @return (List<FrontEndParameter>)handleGetFormFields()
*/
public final List<FrontEndParameter> getFormFields()
{
List<FrontEndParameter> getFormFields7r = this.__getFormFields7r;
if (!this.__getFormFields7rSet)
{
// frontEndAction has no pre constraints
List result = handleGetFormFields();
List shieldedResult = this.shieldedElements(result);
try
{
getFormFields7r = (List<FrontEndParameter>)shieldedResult;
}
catch (ClassCastException ex)
{
// Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getFormFields List<FrontEndParameter> " + result + ": " + shieldedResult);
}
// frontEndAction has no post constraints
this.__getFormFields7r = getFormFields7r;
if (isMetafacadePropertyCachingEnabled())
{
this.__getFormFields7rSet = true;
}
}
return getFormFields7r;
}
/**
* UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
* @return List
*/
protected abstract List handleGetFormFields();
private List<FrontEndView> __getTargetViews8r;
private boolean __getTargetViews8rSet = false;
/**
* Represents a "front-end" action. An action is some action that is taken when a front-end even
* occurs.
* @return (List<FrontEndView>)handleGetTargetViews()
*/
public final List<FrontEndView> getTargetViews()
{
List<FrontEndView> getTargetViews8r = this.__getTargetViews8r;
if (!this.__getTargetViews8rSet)
{
// frontEndAction has no pre constraints
List result = handleGetTargetViews();
List shieldedResult = this.shieldedElements(result);
try
{
getTargetViews8r = (List<FrontEndView>)shieldedResult;
}
catch (ClassCastException ex)
{
// Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getTargetViews List<FrontEndView> " + result + ": " + shieldedResult);
}
// frontEndAction has no post constraints
this.__getTargetViews8r = getTargetViews8r;
if (isMetafacadePropertyCachingEnabled())
{
this.__getTargetViews8rSet = true;
}
}
return getTargetViews8r;
}
/**
* UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
* @return List
*/
protected abstract List handleGetTargetViews();
private List<FrontEndControllerOperation> __getDeferredOperations9r;
private boolean __getDeferredOperations9rSet = false;
/**
* All those actions that contain at least one front-end action state that is deferring to this
* operation.
* @return (List<FrontEndControllerOperation>)handleGetDeferredOperations()
*/
public final List<FrontEndControllerOperation> getDeferredOperations()
{
List<FrontEndControllerOperation> getDeferredOperations9r = this.__getDeferredOperations9r;
if (!this.__getDeferredOperations9rSet)
{
// deferringActions has no pre constraints
List result = handleGetDeferredOperations();
List shieldedResult = this.shieldedElements(result);
try
{
getDeferredOperations9r = (List<FrontEndControllerOperation>)shieldedResult;
}
catch (ClassCastException ex)
{
// Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getDeferredOperations List<FrontEndControllerOperation> " + result + ": " + shieldedResult);
}
// deferringActions has no post constraints
this.__getDeferredOperations9r = getDeferredOperations9r;
if (isMetafacadePropertyCachingEnabled())
{
this.__getDeferredOperations9rSet = true;
}
}
return getDeferredOperations9r;
}
/**
* UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
* @return List
*/
protected abstract List handleGetDeferredOperations();
/**
* Represents a "front-end" action. An action is some action that is taken when a front-end even
* occurs.
* @return (StateVertexFacade)handleGetInput()
*/
public final StateVertexFacade getInput()
{
StateVertexFacade getInput10r = null;
// frontEndAction has no pre constraints
Object result = handleGetInput();
MetafacadeBase shieldedResult = this.shieldedElement(result);
try
{
getInput10r = (StateVertexFacade)shieldedResult;
}
catch (ClassCastException ex)
{
// Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getInput StateVertexFacade " + result + ": " + shieldedResult);
}
// frontEndAction has no post constraints
return getInput10r;
}
/**
* UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
* @return Object
*/
protected abstract Object handleGetInput();
/**
* <p><b>Constraint:</b> org::andromda::metafacades::uml::FrontEndAction::parameters must be unique</p>
* <p><b>Error:</b> Each front-end action parameter must have a unique name.</p>
* <p><b>OCL:</b> context FrontEndAction
inv : parameters -> isUnique(name)</p>
* <p><b>Constraint:</b> org::andromda::metafacades::uml::FrontEndAction::each action must carry a trigger</p>
* <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>
* <p><b>OCL:</b> context FrontEndAction inv: exitingView implies triggerPresent</p>
* @param validationMessages Collection<ModelValidationMessage>
* @see FrontEndForwardLogicImpl#validateInvariants(Collection validationMessages)
*/
@Override
public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
{
super.validateInvariants(validationMessages);
try
{
final Object contextElement = this.THIS();
boolean constraintValid = OCLResultEnsurer.ensure(OCLCollections.isUnique(OCLIntrospector.invoke(contextElement,"parameters"),new Transformer(){public Object transform(Object object){return OCLIntrospector.invoke(object,"name");}}));
if (!constraintValid)
{
validationMessages.add(
new ModelValidationMessage(
(MetafacadeBase)contextElement ,
"org::andromda::metafacades::uml::FrontEndAction::parameters must be unique",
"Each front-end action parameter must have a unique name."));
}
}
catch (Throwable th)
{
Throwable cause = th.getCause();
int depth = 0; // Some throwables have infinite recursion
while (cause != null && depth < 7)
{
th = cause;
depth++;
}
logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndAction::parameters must be unique' ON "
+ this.THIS().toString() + ": " + th.getMessage(), th);
}
try
{
final Object contextElement = this.THIS();
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));
if (!constraintValid)
{
validationMessages.add(
new ModelValidationMessage(
(MetafacadeBase)contextElement ,
"org::andromda::metafacades::uml::FrontEndAction::each action must carry a trigger",
"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'."));
}
}
catch (Throwable th)
{
Throwable cause = th.getCause();
int depth = 0; // Some throwables have infinite recursion
while (cause != null && depth < 7)
{
th = cause;
depth++;
}
logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndAction::each action must carry a trigger' ON "
+ this.THIS().toString() + ": " + th.getMessage(), th);
}
}
}