/* * @(#) Surface_Item 0_97_0 08/07/2009 * * see Annex C of the SOPES IEDM Specification * Surface_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; /** * * Surface_Item * @author ASMG * @version 0_97_0 08/07/2009 */ public class Surface_Item { public Surface_Item ( String identifier, Data data ) { m_data = data; Collection nextIdentifiers = new ArrayList(); nextIdentifiers.add(identifier); Collection col; Collection startPointCol = buildSurface( nextIdentifiers ); // Identifier always mandatory if ( startPointCol.isEmpty() ) { throw new IllegalArgumentException(); } m_step0.addAll( startPointCol ); includeTargetIdentifiers(nextIdentifiers); Surface surface = (Surface)startPointCol.iterator().next(); if ( surface.getAttributeValue("surface-category-code").equalsIgnoreCase("TRCKAR") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), TrackArea.getEntityIdentifier() ); col = buildTrackArea_Surface( 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 ( surface.getAttributeValue("surface-category-code").equalsIgnoreCase("PLYAAR") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), PolyarcArea.getEntityIdentifier() ); col = buildPolyarcArea_Surface( 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 ( surface.getAttributeValue("surface-category-code").equalsIgnoreCase("PLYGAR") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), PolygonArea.getEntityIdentifier() ); col = buildPolygonArea_Surface( 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 ( surface.getAttributeValue("surface-category-code").equalsIgnoreCase("ORBTAR") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), OrbitArea.getEntityIdentifier() ); col = buildOrbitArea_Surface( 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 ( surface.getAttributeValue("surface-category-code").equalsIgnoreCase("FA") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), FanArea.getEntityIdentifier() ); col = buildFanArea_Surface( 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 ( surface.getAttributeValue("surface-category-code").equalsIgnoreCase("ELLPSE") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Ellipse.getEntityIdentifier() ); col = buildEllipse_Surface( 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 ( surface.getAttributeValue("surface-category-code").equalsIgnoreCase("CORDAR") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), CorridorArea.getEntityIdentifier() ); col = buildCorridorArea_Surface( 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; } nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Location.getEntityIdentifier() ); col = buildLocation( nextIdentifiers ); if ( col.size() < m_multiplicity8.getMin() || col.size() > m_multiplicity8.getMax() ) { throw new IllegalArgumentException(); } m_step8.addAll( col ); includeTargetIdentifiers(nextIdentifiers); } /* * Multiplicity min: 1 max : 1 */ private Collection buildSurface( 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( Surface.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Surface(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildTrackArea_Surface(Collection identifiers ) { Collection col = new ArrayList(); Iterator sit = identifiers.iterator(); String identifier; Collection rows = new ArrayList(); while( sit.hasNext() ) { identifier = sit.next(); try { TrackArea_Surface trackArea_Surface = new TrackArea_Surface( identifier, m_data ); col.add(trackArea_Surface); } catch( IllegalArgumentException ie ) { /* implementation based response */ } } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildPolyarcArea_Surface(Collection identifiers ) { Collection col = new ArrayList(); Iterator sit = identifiers.iterator(); String identifier; Collection rows = new ArrayList(); while( sit.hasNext() ) { identifier = sit.next(); try { PolyarcArea_Surface polyarcArea_Surface = new PolyarcArea_Surface( identifier, m_data ); col.add(polyarcArea_Surface); } catch( IllegalArgumentException ie ) { /* implementation based response */ } } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildPolygonArea_Surface(Collection identifiers ) { Collection col = new ArrayList(); Iterator sit = identifiers.iterator(); String identifier; Collection rows = new ArrayList(); while( sit.hasNext() ) { identifier = sit.next(); try { PolygonArea_Surface polygonArea_Surface = new PolygonArea_Surface( identifier, m_data ); col.add(polygonArea_Surface); } catch( IllegalArgumentException ie ) { /* implementation based response */ } } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildOrbitArea_Surface(Collection identifiers ) { Collection col = new ArrayList(); Iterator sit = identifiers.iterator(); String identifier; Collection rows = new ArrayList(); while( sit.hasNext() ) { identifier = sit.next(); try { OrbitArea_Surface orbitArea_Surface = new OrbitArea_Surface( identifier, m_data ); col.add(orbitArea_Surface); } catch( IllegalArgumentException ie ) { /* implementation based response */ } } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildFanArea_Surface(Collection identifiers ) { Collection col = new ArrayList(); Iterator sit = identifiers.iterator(); String identifier; Collection rows = new ArrayList(); while( sit.hasNext() ) { identifier = sit.next(); try { FanArea_Surface fanArea_Surface = new FanArea_Surface( identifier, m_data ); col.add(fanArea_Surface); } catch( IllegalArgumentException ie ) { /* implementation based response */ } } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildEllipse_Surface(Collection identifiers ) { Collection col = new ArrayList(); Iterator sit = identifiers.iterator(); String identifier; Collection rows = new ArrayList(); while( sit.hasNext() ) { identifier = sit.next(); try { Ellipse_Surface ellipse_Surface = new Ellipse_Surface( identifier, m_data ); col.add(ellipse_Surface); } catch( IllegalArgumentException ie ) { /* implementation based response */ } } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildCorridorArea_Surface(Collection identifiers ) { Collection col = new ArrayList(); Iterator sit = identifiers.iterator(); String identifier; Collection rows = new ArrayList(); while( sit.hasNext() ) { identifier = sit.next(); try { CorridorArea_Surface corridorArea_Surface = new CorridorArea_Surface( identifier, m_data ); col.add(corridorArea_Surface); } catch( IllegalArgumentException ie ) { /* implementation based response */ } } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildLocation( 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( Location.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Location(it.next()) ); } return col; } private Collection getSourceIdentifiers(){ /* no implement see Annex C Surface_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(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 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(); }