/* * @(#) Facility_Item 0_97_0 08/07/2009 * * see Annex C of the SOPES IEDM Specification * Facility_Item 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; /** * * Facility_Item * @author ASMG * @version 0_97_0 08/07/2009 */ public class Facility_Item { public Facility_Item ( String identifier, Data data ) { m_data = data; Collection nextIdentifiers = new ArrayList(); nextIdentifiers.add(identifier); Collection col; Collection startPointCol = buildFacility( nextIdentifiers ); // Identifier always mandatory if ( startPointCol.isEmpty() ) { throw new IllegalArgumentException(); } m_step0.addAll( startPointCol ); includeTargetIdentifiers(nextIdentifiers); Facility facility = (Facility)startPointCol.iterator().next(); if ( facility.getAttributeValue("facility-category-code").equalsIgnoreCase("HARBOR") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Harbour.getEntityIdentifier() ); col = buildHarbour( 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(), ObjectItem.getEntityIdentifier() ); col = buildObjectItem( 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(), ObjectItemAlias.getEntityIdentifier() ); col = buildObjectItemAlias( nextIdentifiers ); if ( col.size() < m_multiplicity3.getMin() || col.size() > m_multiplicity3.getMax() ) { throw new IllegalArgumentException(); } m_step3.addAll( col ); includeTargetIdentifiers(nextIdentifiers); if ( facility.getAttributeValue("facility-category-code").equalsIgnoreCase("DRYDCK") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), DryDock.getEntityIdentifier() ); col = buildDryDock( 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 ( facility.getAttributeValue("facility-category-code").equalsIgnoreCase("SLPWAY") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Slipway.getEntityIdentifier() ); col = buildSlipway( 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 ( facility.getAttributeValue("facility-category-code").equalsIgnoreCase("BRIDGE") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Bridge.getEntityIdentifier() ); col = buildBridge( 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 ( facility.getAttributeValue("facility-category-code").equalsIgnoreCase("BERTH") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Berth.getEntityIdentifier() ); col = buildBerth( 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 ( facility.getAttributeValue("facility-category-code").equalsIgnoreCase("BASIN") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Basin.getEntityIdentifier() ); col = buildBasin( 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 ( facility.getAttributeValue("facility-category-code").equalsIgnoreCase("APRON") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Apron.getEntityIdentifier() ); col = buildApron( 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 ( facility.getAttributeValue("facility-category-code").equalsIgnoreCase("ANCHOR") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Anchorage.getEntityIdentifier() ); col = buildAnchorage( 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 ( facility.getAttributeValue("facility-category-code").equalsIgnoreCase("AIRFLD") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Airfield.getEntityIdentifier() ); col = buildAirfield( 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 ( facility.getAttributeValue("facility-category-code").equalsIgnoreCase("ROAD") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Road.getEntityIdentifier() ); col = buildRoad( 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 ( facility.getAttributeValue("facility-category-code").equalsIgnoreCase("RALWAY") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Railway.getEntityIdentifier() ); col = buildRailway( 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 ( facility.getAttributeValue("facility-category-code").equalsIgnoreCase("QUAY") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Quay.getEntityIdentifier() ); col = buildQuay( 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; } if ( facility.getAttributeValue("facility-category-code").equalsIgnoreCase("JETTY") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Jetty.getEntityIdentifier() ); col = buildJetty( nextIdentifiers ); if ( col.size() < m_multiplicity15.getMin() || col.size() > m_multiplicity15.getMax() ) { throw new IllegalArgumentException(); } m_step15.addAll( col ); includeTargetIdentifiers(nextIdentifiers); } else { m_step15 = null; } } /* * Multiplicity min: 1 max : 1 */ private Collection buildFacility( 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( Facility.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Facility(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildHarbour( 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( Harbour.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Harbour(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildObjectItem( 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( ObjectItem.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new ObjectItem(it.next()) ); } return col; } /* * Multiplicity min: 0 max : 1 */ private Collection buildObjectItemAlias( 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( ObjectItemAlias.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new ObjectItemAlias(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildDryDock( 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( DryDock.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new DryDock(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildSlipway( 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( Slipway.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Slipway(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildBridge( 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( Bridge.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Bridge(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildBerth( 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( Berth.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Berth(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildBasin( 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( Basin.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Basin(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildApron( 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( Apron.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Apron(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildAnchorage( 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( Anchorage.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Anchorage(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildAirfield( 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( Airfield.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Airfield(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildRoad( 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( Road.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Road(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildRailway( 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( Railway.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Railway(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildQuay( 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( Quay.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Quay(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildJetty( 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( Jetty.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Jetty(it.next()) ); } return col; } private Collection getSourceIdentifiers(){ /* no implement see Annex C Facility_Item 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(0, 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 Multiplicity m_multiplicity15 = 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(); private Set m_step15 = new HashSet(); }