/* * @(#) Equipment_Type 0_97_0 08/07/2009 * * see Annex C of the SOPES IEDM Specification * Equipment_Type 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; /** * * Equipment_Type * @author ASMG * @version 0_97_0 08/07/2009 */ public class Equipment_Type { public Equipment_Type ( String identifier, Data data ) { m_data = data; Collection nextIdentifiers = new ArrayList(); nextIdentifiers.add(identifier); Collection col; Collection startPointCol = buildEquipmentType( nextIdentifiers ); // Identifier always mandatory if ( startPointCol.isEmpty() ) { throw new IllegalArgumentException(); } m_step0.addAll( startPointCol ); includeTargetIdentifiers(nextIdentifiers); EquipmentType equipmentType = (EquipmentType)startPointCol.iterator().next(); if ( equipmentType.getAttributeValue("equipment-type-category-code").equalsIgnoreCase("VESSEL") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), VesselType.getEntityIdentifier() ); col = buildVessel_Type( 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; } nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), MaterielType.getEntityIdentifier() ); col = buildMaterielType( nextIdentifiers ); if ( col.size() < m_multiplicity2.getMin() || col.size() > m_multiplicity2.getMax() ) { throw new IllegalArgumentException(); } m_step2.addAll( col ); includeTargetIdentifiers(nextIdentifiers); nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), ObjectType.getEntityIdentifier() ); col = buildObjectType( nextIdentifiers ); if ( col.size() < m_multiplicity3.getMin() || col.size() > m_multiplicity3.getMax() ) { throw new IllegalArgumentException(); } m_step3.addAll( col ); includeTargetIdentifiers(nextIdentifiers); if ( equipmentType.getAttributeValue("equipment-type-category-code").equalsIgnoreCase("ENGEQ") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), EngineeringEquipmentType.getEntityIdentifier() ); col = buildEngineeringEquipmentType( 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; } if ( equipmentType.getAttributeValue("equipment-type-category-code").equalsIgnoreCase("ELCTRN") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), ElectronicEquipmentType.getEntityIdentifier() ); col = buildElectronicEquipmentType( nextIdentifiers ); if ( col.size() < m_multiplicity5.getMin() || col.size() > m_multiplicity5.getMax() ) { throw new IllegalArgumentException(); } m_step5.addAll( col ); includeTargetIdentifiers(nextIdentifiers); } else { m_step5 = null; } if ( equipmentType.getAttributeValue("equipment-type-category-code").equalsIgnoreCase("ELCTRN") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), TransmissionCapability.getEntityIdentifier() ); col = buildTransmissionCapability( nextIdentifiers ); if ( col.size() < m_multiplicity6.getMin() || col.size() > m_multiplicity6.getMax() ) { throw new IllegalArgumentException(); } m_step6.addAll( col ); includeTargetIdentifiers(nextIdentifiers); } else { m_step6 = null; } if ( equipmentType.getAttributeValue("equipment-type-category-code").equalsIgnoreCase("ELCTRN") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Capability.getEntityIdentifier() ); col = buildCapability( nextIdentifiers ); if ( col.size() < m_multiplicity7.getMin() || col.size() > m_multiplicity7.getMax() ) { throw new IllegalArgumentException(); } m_step7.addAll( col ); includeTargetIdentifiers(nextIdentifiers); } else { m_step7 = null; } if ( equipmentType.getAttributeValue("equipment-type-category-code").equalsIgnoreCase("CBRNEQ") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), CbrnEquipmentType.getEntityIdentifier() ); col = buildCbrnEquipmentType( nextIdentifiers ); if ( col.size() < m_multiplicity8.getMin() || col.size() > m_multiplicity8.getMax() ) { throw new IllegalArgumentException(); } m_step8.addAll( col ); includeTargetIdentifiers(nextIdentifiers); } else { m_step8 = null; } if ( equipmentType.getAttributeValue("equipment-type-category-code").equalsIgnoreCase("AIRCFT") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), AircraftType.getEntityIdentifier() ); col = buildAircraftType( nextIdentifiers ); if ( col.size() < m_multiplicity9.getMin() || col.size() > m_multiplicity9.getMax() ) { throw new IllegalArgumentException(); } m_step9.addAll( col ); includeTargetIdentifiers(nextIdentifiers); } else { m_step9 = null; } if ( equipmentType.getAttributeValue("equipment-type-category-code").equalsIgnoreCase("WEPTYP") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), WeaponType.getEntityIdentifier() ); col = buildWeaponType( nextIdentifiers ); if ( col.size() < m_multiplicity10.getMin() || col.size() > m_multiplicity10.getMax() ) { throw new IllegalArgumentException(); } m_step10.addAll( col ); includeTargetIdentifiers(nextIdentifiers); } else { m_step10 = null; } if ( equipmentType.getAttributeValue("equipment-type-category-code").equalsIgnoreCase("RAIL") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), RailcarType.getEntityIdentifier() ); col = buildRailcarType( nextIdentifiers ); if ( col.size() < m_multiplicity11.getMin() || col.size() > m_multiplicity11.getMax() ) { throw new IllegalArgumentException(); } m_step11.addAll( col ); includeTargetIdentifiers(nextIdentifiers); } else { m_step11 = null; } if ( equipmentType.getAttributeValue("equipment-type-category-code").equalsIgnoreCase("VEHCLE") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), VehicleType.getEntityIdentifier() ); col = buildVehicleType( nextIdentifiers ); if ( col.size() < m_multiplicity12.getMin() || col.size() > m_multiplicity12.getMax() ) { throw new IllegalArgumentException(); } m_step12.addAll( col ); includeTargetIdentifiers(nextIdentifiers); } else { m_step12 = null; } if ( equipmentType.getAttributeValue("equipment-type-category-code").equalsIgnoreCase("MISCEQ") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), MiscellaneousEquipmentType.getEntityIdentifier() ); col = buildMiscellaneousEquipmentType( nextIdentifiers ); if ( col.size() < m_multiplicity13.getMin() || col.size() > m_multiplicity13.getMax() ) { throw new IllegalArgumentException(); } m_step13.addAll( col ); includeTargetIdentifiers(nextIdentifiers); } else { m_step13 = null; } if ( equipmentType.getAttributeValue("equipment-type-category-code").equalsIgnoreCase("MRTMEQ") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), MaritimeEquipmentType.getEntityIdentifier() ); col = buildMaritimeEquipmentType( nextIdentifiers ); if ( col.size() < m_multiplicity14.getMin() || col.size() > m_multiplicity14.getMax() ) { throw new IllegalArgumentException(); } m_step14.addAll( col ); includeTargetIdentifiers(nextIdentifiers); } else { m_step14 = null; } } /* * Multiplicity min: 1 max : 1 */ private Collection buildEquipmentType( 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( EquipmentType.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new EquipmentType(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildVessel_Type(Collection identifiers ) { Collection col = new ArrayList(); Iterator sit = identifiers.iterator(); String identifier; Collection rows = new ArrayList(); while( sit.hasNext() ) { identifier = sit.next(); try { Vessel_Type vessel_Type = new Vessel_Type( identifier, m_data ); col.add(vessel_Type); } catch( IllegalArgumentException ie ) { /* implementation based response */ } } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildMaterielType( 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( MaterielType.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new MaterielType(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildObjectType( 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( ObjectType.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new ObjectType(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildEngineeringEquipmentType( 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( EngineeringEquipmentType.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new EngineeringEquipmentType(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildElectronicEquipmentType( 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( ElectronicEquipmentType.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new ElectronicEquipmentType(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildTransmissionCapability( 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( TransmissionCapability.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new TransmissionCapability(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildCapability( 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( Capability.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Capability(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildCbrnEquipmentType( 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( CbrnEquipmentType.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new CbrnEquipmentType(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildAircraftType( 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( AircraftType.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new AircraftType(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildWeaponType( 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( WeaponType.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new WeaponType(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildRailcarType( 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( RailcarType.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new RailcarType(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildVehicleType( 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( VehicleType.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new VehicleType(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildMiscellaneousEquipmentType( 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( MiscellaneousEquipmentType.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new MiscellaneousEquipmentType(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildMaritimeEquipmentType( 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( MaritimeEquipmentType.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new MaritimeEquipmentType(it.next()) ); } return col; } private Collection getSourceIdentifiers(){ /* no implement see Annex C Equipment_Type 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 = false; 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 Multiplicity m_multiplicity5 = new Multiplicity(1, 1); private Multiplicity m_multiplicity6 = new Multiplicity(1, 1); private Multiplicity m_multiplicity7 = new Multiplicity(1, 1); private Multiplicity m_multiplicity8 = new Multiplicity(1, 1); private Multiplicity m_multiplicity9 = new Multiplicity(1, 1); private Multiplicity m_multiplicity10 = new Multiplicity(1, 1); private Multiplicity m_multiplicity11 = new Multiplicity(1, 1); private Multiplicity m_multiplicity12 = new Multiplicity(1, 1); private Multiplicity m_multiplicity13 = new Multiplicity(1, 1); private Multiplicity m_multiplicity14 = 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(); private Set m_step5 = new HashSet(); private Set m_step6 = new HashSet(); private Set m_step7 = new HashSet(); private Set m_step8 = new HashSet(); private Set m_step9 = new HashSet(); private Set m_step10 = new HashSet(); private Set m_step11 = new HashSet(); private Set m_step12 = new HashSet(); private Set m_step13 = new HashSet(); private Set m_step14 = new HashSet(); }