/* * @(#) Action_Resource_Employment 0_97_0 08/07/2009 * * see Annex C of the SOPES IEDM Specification * Action_Resource_Employment oclConstructionSequence for the key mapping across steps * for this Transactional Artifact */ package org.omg.sopes0_97_0.PSM.Transactional; import org.omg.sopes0_97_0.PSM.Tuple; import org.omg.sopes0_97_0.PSM.Data; import org.omg.sopes0_97_0.PSM.Multiplicity; import org.omg.sopes0_97_0.PSM.Wrapper.*; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.Set; /** * * Action_Resource_Employment * @author ASMG * @version 0_97_0 08/07/2009 */ public class Action_Resource_Employment { public Action_Resource_Employment ( String identifier, Data data ) { m_data = data; Collection nextIdentifiers = new ArrayList(); nextIdentifiers.add(identifier); Collection col; Collection startPointCol = buildActionResourceEmployment( nextIdentifiers ); // Identifier always mandatory if ( startPointCol.isEmpty() ) { throw new IllegalArgumentException(); } m_step0.addAll( startPointCol ); includeTargetIdentifiers(nextIdentifiers); ActionResourceEmployment actionResourceEmployment = (ActionResourceEmployment)startPointCol.iterator().next(); if ( actionResourceEmployment.getAttributeValue("action-resource-employment-category-code").equalsIgnoreCase("MAREMP") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), ActionMaritimeEmployment.getEntityIdentifier() ); col = buildAction_Resource_Employment_Maritime( nextIdentifiers ); if ( col.size() < m_multiplicity1.getMin() || col.size() > m_multiplicity1.getMax() ) { throw new IllegalArgumentException(); } m_step1.addAll( col ); includeTargetIdentifiers(nextIdentifiers); } else { m_step1 = null; } if ( actionResourceEmployment.getAttributeValue("action-resource-employment-category-code").equalsIgnoreCase("AIREMP") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), ActionAircraftEmployment.getEntityIdentifier() ); col = buildAction_Resource_Employment_Aircraft( nextIdentifiers ); if ( col.size() < m_multiplicity2.getMin() || col.size() > m_multiplicity2.getMax() ) { throw new IllegalArgumentException(); } m_step2.addAll( col ); includeTargetIdentifiers(nextIdentifiers); } else { m_step2 = null; } if ( actionResourceEmployment.getAttributeValue("action-resource-employment-category-code").equalsIgnoreCase("ELCEMP") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), ActionElectronicWarfareEmployment.getEntityIdentifier() ); col = buildAction_Resource_Employment_Electronic_Warfare( nextIdentifiers ); if ( col.size() < m_multiplicity3.getMin() || col.size() > m_multiplicity3.getMax() ) { throw new IllegalArgumentException(); } m_step3.addAll( col ); includeTargetIdentifiers(nextIdentifiers); } else { m_step3 = null; } if ( actionResourceEmployment.getAttributeValue("action-resource-employment-category-code").equalsIgnoreCase("RECEMP") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), ActionReconnaissanceEmployment.getEntityIdentifier() ); col = buildAction_Resource_Employment_Reconnaissance( nextIdentifiers ); if ( col.size() < m_multiplicity4.getMin() || col.size() > m_multiplicity4.getMax() ) { throw new IllegalArgumentException(); } m_step4.addAll( col ); includeTargetIdentifiers(nextIdentifiers); } else { m_step4 = null; } } /* * Multiplicity min: 1 max : 1 */ private Collection buildActionResourceEmployment( Collection identifiers ) { Collection col = new ArrayList(); Iterator sit = identifiers.iterator(); String identifier; Collection rows = new ArrayList(); while( sit.hasNext() ) { identifier = sit.next(); rows.addAll(m_data.extractRows( ActionResourceEmployment.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new ActionResourceEmployment(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildAction_Resource_Employment_Maritime(Collection identifiers ) { Collection col = new ArrayList(); Iterator sit = identifiers.iterator(); String identifier; Collection rows = new ArrayList(); while( sit.hasNext() ) { identifier = sit.next(); try { Action_Resource_Employment_Maritime action_Resource_Employment_Maritime = new Action_Resource_Employment_Maritime( identifier, m_data ); col.add(action_Resource_Employment_Maritime); } catch( IllegalArgumentException ie ) { /* implementation based response */ } } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildAction_Resource_Employment_Aircraft(Collection identifiers ) { Collection col = new ArrayList(); Iterator sit = identifiers.iterator(); String identifier; Collection rows = new ArrayList(); while( sit.hasNext() ) { identifier = sit.next(); try { Action_Resource_Employment_Aircraft action_Resource_Employment_Aircraft = new Action_Resource_Employment_Aircraft( identifier, m_data ); col.add(action_Resource_Employment_Aircraft); } catch( IllegalArgumentException ie ) { /* implementation based response */ } } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildAction_Resource_Employment_Electronic_Warfare(Collection identifiers ) { Collection col = new ArrayList(); Iterator sit = identifiers.iterator(); String identifier; Collection rows = new ArrayList(); while( sit.hasNext() ) { identifier = sit.next(); try { Action_Resource_Employment_Electronic_Warfare action_Resource_Employment_Electronic_Warfare = new Action_Resource_Employment_Electronic_Warfare( identifier, m_data ); col.add(action_Resource_Employment_Electronic_Warfare); } catch( IllegalArgumentException ie ) { /* implementation based response */ } } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildAction_Resource_Employment_Reconnaissance(Collection identifiers ) { Collection col = new ArrayList(); Iterator sit = identifiers.iterator(); String identifier; Collection rows = new ArrayList(); while( sit.hasNext() ) { identifier = sit.next(); try { Action_Resource_Employment_Reconnaissance action_Resource_Employment_Reconnaissance = new Action_Resource_Employment_Reconnaissance( identifier, m_data ); col.add(action_Resource_Employment_Reconnaissance); } catch( IllegalArgumentException ie ) { /* implementation based response */ } } return col; } private Collection getSourceIdentifiers(){ /* no implement see Annex C Action_Resource_Employment oclConstructionSequence for further information */ return null; } private void includeTargetIdentifiers(Collection nextIdentifiers){ /* no implement Record the variable for potential use by the method getSourceIdentifiers() */ } public boolean isWatchpoint(){ return m_isWatchpoint; } private Data m_data = null; private final boolean m_isWatchpoint = true; private Multiplicity m_multiplicity0 = new Multiplicity(1, 1); private Multiplicity m_multiplicity1 = new Multiplicity(1, 1); private Multiplicity m_multiplicity2 = new Multiplicity(1, 1); private Multiplicity m_multiplicity3 = new Multiplicity(1, 1); private Multiplicity m_multiplicity4 = new Multiplicity(1, 1); private Set m_step0 = new HashSet(); private Set m_step1 = new HashSet(); private Set m_step2 = new HashSet(); private Set m_step3 = new HashSet(); private Set m_step4 = new HashSet(); }