001package org.andromda.metafacades.uml14; 002 003import java.util.Collection; 004import java.util.Iterator; 005import org.omg.uml.behavioralelements.activitygraphs.ActivityGraph; 006import org.omg.uml.behavioralelements.activitygraphs.Partition; 007import org.omg.uml.behavioralelements.statemachines.CompositeState; 008import org.omg.uml.behavioralelements.statemachines.StateMachine; 009import org.omg.uml.behavioralelements.statemachines.StateVertex; 010 011/** 012 * MetafacadeLogic implementation. 013 * 014 * @see org.andromda.metafacades.uml.StateVertexFacade 015 * @author Bob Fields 016 */ 017public class StateVertexFacadeLogicImpl 018 extends StateVertexFacadeLogic 019{ 020 private static final long serialVersionUID = 34L; 021 /** 022 * @param metaObject 023 * @param context 024 */ 025 public StateVertexFacadeLogicImpl(StateVertex metaObject, 026 String context) 027 { 028 super(metaObject, context); 029 } 030 031 /** 032 * @see org.andromda.metafacades.uml14.StateVertexFacadeLogic#handleGetStateMachine() 033 */ 034 protected StateMachine handleGetStateMachine() 035 { 036 // throws NullPointer if metaObject has no Container... Need to check for null on return. 037 if (metaObject.getContainer()==null) 038 { 039 return null; 040 } 041 return metaObject.getContainer().getStateMachine(); 042 } 043 044 /** 045 * @see org.andromda.metafacades.uml14.StateVertexFacadeLogic#handleGetContainer() 046 */ 047 protected CompositeState handleGetContainer() 048 { 049 return metaObject.getContainer(); 050 } 051 052 /** 053 * @see org.andromda.metafacades.uml14.StateVertexFacadeLogic#handleGetIncomings() 054 */ 055 protected Collection handleGetIncomings() 056 { 057 return metaObject.getIncoming(); 058 } 059 060 /** 061 * @see org.andromda.metafacades.uml14.StateVertexFacadeLogic#handleGetOutgoings() 062 */ 063 protected Collection handleGetOutgoings() 064 { 065 return metaObject.getOutgoing(); 066 } 067 068 /** 069 * @return getStateMachine 070 */ 071 public Object handleGetValidationOwner() 072 { 073 return getStateMachine(); 074 } 075 076 /** 077 * @see org.andromda.metafacades.uml14.StateVertexFacadeLogic#handleGetPartition() 078 */ 079 protected Partition handleGetPartition() 080 { 081 Partition thePartition = null; 082 083 final StateMachine stateMachine = metaObject.getContainer().getStateMachine(); 084 if (stateMachine instanceof ActivityGraph) 085 { 086 final ActivityGraph activityGraph = (ActivityGraph)stateMachine; 087 final Collection<Partition> partitions = activityGraph.getPartition(); 088 for (final Iterator<Partition> partitionIterator = partitions.iterator(); partitionIterator.hasNext() && thePartition == null;) 089 { 090 final Partition partition = partitionIterator.next(); 091 if (partition.getContents().contains(metaObject)) 092 { 093 thePartition = partition; 094 } 095 } 096 } 097 098 return thePartition; 099 } 100}