We If given an a state of A, there

We have two state models, A and B. Model B belongs to the
PSM, so is an implementation of Model A, which belongs to the PIM. Model A will
describe the application states and model B describe technically how to use the
available services provided in order to achieve some functionality. An example
of model A is the behaviour model developed for the financial system
application in Figure 4  State Machine
Behavior.

Assume, as in the case studies, that there are fewer states
in model A than in model B, and that every state in model B corresponds to
exactly one state in model A. This means that we can divide the states in model
B into groups, indexed by the state of model A they correspond to. If a is a
state of A, then the states of B corresponding to a form an equivalence class.
Let’s call that B(a).

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!


order now

Model transformations of behavior models represented as UML
state machine in this research can be classified into five categories: 1.
Single State to Single State Transformation If given an a state of A, there is
one state in B(a), then call that state b, and the PIM/PSM mapping maps a into
b.

2. Single State to More Than One State Transformation If
given an a state of A, there are several states in B(a), then map a to those
states if possible. The mapping is one state to many.

3. Single State to part of a composite state Transformation

4. Orphan State Transformation Assuming that every state of
A corresponds to at least one state of B. Otherwise, the orphan state of A
cannot be implemented. This could form part of an evaluation of the suitability
of a PSM for implementing a given PIM.

5. Forbidden  State
Transformation What happens if there are states in B that don’t correspond to
some state in A? Let’s call them forbidden states. Whether this is a problem
would depend on whether the transitions mapped from A ever take a state in B to
the forbidden state. Table 5. Issues and Behavioral Mapping Decisions
summarized Type ( state/transition) Mapping Single state to single state Direct
mapping Single state to multiple states Create 
a new  composite state with name=the
PIM single state name, Create a new region with name=PIM state
name+”Region” and  add to the
newly created composite state the PSM equivalence class states as sub states
Orphan State Ignored, in the case study, 
this type of states are handled implicitly by the PSM , so ignoring them
is not going to create problems in the application logic. Forbidden State This
type of states are important to complete the PSM logic, they are created in the
resulting model. Single transition to single transition Direct mapping Single
transition to multiple transitions Map the transitions ( create the PSM
transitions) and check the target states of each transition for equivalence
with

PIM. Orphan transition Ignored Forbidden transition Created
in the resulting model

 the same process was
done to the guards, actions, Initial node , Final node,  Fork node , Merge node with decision node ,
are mapped to the equivalent.

Models To Text and The Application Execution

Overview The mapping of PIM behavior model- state Machine – to
the PSM behavior model yield a behavior model expressed as PSM constructs
(state machine). The generated state machine models are highly reusable since
they are expressed in UML. The models then can be transformed into other forms
to enable complementing the class model and provide the big picture as a
complete application with class and behavior instances both available to be
executed.

Model transformations of behavior models represented as UML
state machine in this research can be classified into five categories: Single
State to Single State, Single State to more than one  State, Single State to part of a composite
state, orphan state and forbidden state transformations.

 If the PSM has a
forbidden state which can be entered for a given PIM, and the forbidden state
has actions that involved changes to any PIM class instances, then the PIM must
be enhanced to take account that PSM behaviour, otherwise a PIM state can map
to a composite PSM state including the forbidden state. A test for this kind of
situation would be valuable. Some observations are following:

a. A forbidden state with no guard predicate will generally
do something necessary for the operation of the PSM which is not visible in the
PIM, so the mapping is to a composite state.

b. A forbidden state with a guard predicate. A PIM may be
constrained in such a way that the PSM guard predicate will always evaluate to
true, in which case situation a above is 
obtained, or always false, in which case the forbidden state can never
occur.

c. In fact, if a forbidden state has no action with an
effect on the PIM database (PIM Classes model instances), then what it does
would appear to be irrelevant to the PIM.

d. In the case where a forbidden state has a guard predicate
which may evaluate to either true or false (this requires that the guard
predicate include terms which involve mapped PIM class model instances), and
the forbidden state has actions which change PIM class model instances, then
the PSM behaviour is richer than the PIM, and the PIM needs to be enhanced to
make the necessary specifications.

Another aspect in the state machine models is the
constraints in various forms. A constraint is formulated on the level of
classes, but its semantics is applied on the level of objects. a. In the state
models of both the PIM and PSM  the
predicates can take different forms. b. PSM class may have more attributes than
PIM class, if such attributes existed in the constraint they need a decision.
If the PSM attributes are left in the expression as specified by the PSM, then
we have to note that  the values are PSM
specific and are not specified by the PIM instance model. c. PSM specific
classes that are not part of the PIM classes may also have their own
constraints. These classes may be part of an equivalence class too. d. The
relation between the attributes used in the guard expression involves the
mapping of PIM class model to the PSM class model first in order to map the
attributes values of instances accordingly.

e. The guard predicate in the PSM may be manually edited to
find the corresponding semantically equal behavior as specified by the PIM.

Discussion

Forbidden States Mapping The fifth  type of transformation identified is the
“forbidden state” transformations where the PIM state model has no equivalent
for the PSM state.

Figure 7: Forbidden state C targeted by transition T1 Figure
7 : Forbidden state C targeted by transition T1 shows state B which is
equivalent to state A from the PIM state machine model. State B links to state
C  with the transition T1.

The mapping decisions can be as follows:

Non guarded Transitions from B to C:

When T1 has no guard condition:

• Safely ignore state C 
and do not include it in the PSM.

In this case the PIM is followed strictly. The PSM contains
more functionality specified by the more states it has. In order for a PSM to
implement a PIM , its state should be superset of the PIM states. The forbidden
states can be used to enhance the PIM and alter its specification by mapping
back from the PSM states to the PIM states. • Consider state C in the
equivalence class of the PSM In this case the logic is to be completed by
visiting the forbidden state C from state B, since the transition T1 has no
condition. o The equivalence class would be A= { B, C }.  It can be mapped as a composite state, or
another new region containing both state B and C. o An example to this
situation is the printing of a receipt in the first case study. The PIM doesn’t
express explicitly that the successful completion of a transaction would result
in a print of a receipt describing the transaction. By mapping the constraints
, the states and transitions ends up in the idle state of the PIM state
machine, while it continues to print and release the card in the PSM. In this
situation it is recommended to map the additional PSM states to the PIM one in
order to complete the application logic. o Another example is the cleanUp
forbidden state in the second case study. The PIM transitions to the end state
when finished sending or receiving. The PSM cleans up the resources such as
closing the connection object before ending. The cleanUp state is required in
the PSM so it is mapped and added to the equivalence class.

Guarded Transitions from B to C:

Figure 7 : Forbidden state C targeted by a guarded
transition T1

In a state machine model, a guard condition is a boolean
condition that is evaluated when the transition is initiated. The transition to
the target state occurs when the guard condition is evaluated to true. In the
UML notation, guard conditions are shown in square brackets.

It is possible that in an implementation of a particular PIM
that the guard for a forbidden transition is always false. In this case, a

forbidden state can safely be ignored as it can never be
reached in that application.

UML Constraints Mapping

Invariant

Assuming the following invariant as follows:

context Card inv: : expirationDate.isAfter(today) 1.
Determine the context of the constraint in the PSM class model, let us call it
PSMContext 2. Determine the PIM class that is equivalent to the PSM class
denoted by the , let us call it PIMContext. 3. Map the
attributes of the PIMContext to the 
PSMContext 4. Check the OCL expression 5. For each attribute in the
constraint expression, map the equivalent attribute from the PIMContext class.
6. Assess the OCL functions used ( involves checking the semantic of the
constraint) According to the class model mapping of the PIM to PSM, the ATMCard
is mapped to a Card class in the PSM. Since the Card is the context of the constraint,
then we are going to map the equivalent class attribute value for each object
of type ATMCard from  the instances model
into the PSM instance model. Note that the name of both attributes need not be
the same.

Figure 7 PIM  ATMCard
Class

Figure 7 PSM Card Class

Observations: 1. PSM class may have more attributes than PIM
class, if such attributes existed in the constraint they need a decision. If
the PSM attributes are left in the expression as specified by the PSM, then we
have to note that  the values are PSM
specific and are not specified by the PIM instance model. 2. PSM specific
classes that are not part of the PIM classes may also have their own
constraints. These classes may be part of an equivalence class too.

Pre and Postcondition

context ATM::dispence(amount : Integer)

pre: self.inState=performingTransaction

or

pre: oclInState(performingTransaction);

The pre condition specifies that the state machine that is
owned by the context object- ATM object – is in a specific state in order to
enable the execution of the operation dispense. In this case the mapping should
check that the state specified is equivalent to some state in the PIM and if
there is no constraint , a decision has to be made. Because the PSM constraints
are stronger than PIM ones, the decision here can be to keep the constraint as
it is in the PSM.

State Machine Constraint

A Constraint may be applied to a State machine in the same
way as for a Class to specify an invariant of the State machine. The guard
condition of a State machine transition may be specified by associating a
constraint with a transition

Figure 7 Part of the PSM ATM states model In Figure 7  Part of the PSM ATM states modelFigure 7  Part of the PSM ATM states model  above the transition from Idle state to
Verifying state is constrained with a guard condition that checks the boolean
property “cardInserted” in the PSM Card class. The navigation from
the ATM

context – who owns the states – to the class Card is done
through the userCard association end that associated with the ATMUserSession
class. The “fundingNeeded” is a property of the class BankCustomer in
the PIM. BankCustomer is mapped to ATMUserSession in the class model mapping .
Each ATMUserSession  is associated with a
user card of Card class. So the relation between the attributes used in the
constraint expression involves the mapping of PIM class model to the PSM class
model first in order to map the attributes values of instances accordingly.
Example 2 In the state models of both the PIM and PSM  the predicates can take different forms. For
example the PIMClient class  in the
messaging case study has an attribute newsCount that specify the number of
messages generated and sent , with a default 
value set to 3, while the PSM Client class has a guard predicate again?
which is true if we want to stop message generation and sending. The guard
predicate in the PSM may be edited to find the corresponding semantically equal
behavior as specified by the PIM.

Figure 7 PIMClient and the sending state

Figure 7 Client class and send state A mapping solution can
be as follows: The specification  body of
the PSM constrain  has to include the
check expressed by the PIM constraint.

count=0

Beside that a new attribute or a complete data structure to
hold the attributes and values from the PIM should be invented and attached to
the PSM in order to preserve the semantic specified in the PIM.A semi manual
approach is needed.