/* * @(#) MeteorologicalFeature_Item 0_97_0 08/07/2009 * * see Annex C of the SOPES IEDM Specification * MeteorologicalFeature_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; /** * * MeteorologicalFeature_Item * @author ASMG * @version 0_97_0 08/07/2009 */ public class MeteorologicalFeature_Item { public MeteorologicalFeature_Item ( String identifier, Data data ) { m_data = data; Collection nextIdentifiers = new ArrayList(); nextIdentifiers.add(identifier); Collection col; Collection startPointCol = buildMeteorologicFeature( nextIdentifiers ); // Identifier always mandatory if ( startPointCol.isEmpty() ) { throw new IllegalArgumentException(); } m_step0.addAll( startPointCol ); includeTargetIdentifiers(nextIdentifiers); MeteorologicFeature meteorologicFeature = (MeteorologicFeature)startPointCol.iterator().next(); if ( meteorologicFeature.getAttributeValue("meteorologic-feature-category-code").equalsIgnoreCase("COVER") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), CloudCover.getEntityIdentifier() ); col = buildCloudCover( 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 ( meteorologicFeature.getAttributeValue("meteorologic-feature-category-code").equalsIgnoreCase("ATMOS") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Atmosphere.getEntityIdentifier() ); col = buildAtmosphere( 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 ( meteorologicFeature.getAttributeValue("meteorologic-feature-category-code").equalsIgnoreCase("VISIB") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Visibility.getEntityIdentifier() ); col = buildVisibility( 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 ( meteorologicFeature.getAttributeValue("meteorologic-feature-category-code").equalsIgnoreCase("PRECIP") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Precipitation.getEntityIdentifier() ); col = buildPrecipitation( 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; } nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Feature.getEntityIdentifier() ); col = buildFeature( nextIdentifiers ); if ( col.size() < m_multiplicity5.getMin() || col.size() > m_multiplicity5.getMax() ) { throw new IllegalArgumentException(); } m_step5.addAll( col ); includeTargetIdentifiers(nextIdentifiers); nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), ObjectItem.getEntityIdentifier() ); col = buildObjectItem( nextIdentifiers ); if ( col.size() < m_multiplicity6.getMin() || col.size() > m_multiplicity6.getMax() ) { throw new IllegalArgumentException(); } m_step6.addAll( col ); includeTargetIdentifiers(nextIdentifiers); nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), ObjectItemAlias.getEntityIdentifier() ); col = buildObjectItemAlias( nextIdentifiers ); if ( col.size() < m_multiplicity7.getMin() || col.size() > m_multiplicity7.getMax() ) { throw new IllegalArgumentException(); } m_step7.addAll( col ); includeTargetIdentifiers(nextIdentifiers); if ( meteorologicFeature.getAttributeValue("meteorologic-feature-category-code").equalsIgnoreCase("WIND") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Wind.getEntityIdentifier() ); col = buildWind( 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 ( meteorologicFeature.getAttributeValue("meteorologic-feature-category-code").equalsIgnoreCase("LIGHT") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Light.getEntityIdentifier() ); col = buildLight( 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 ( meteorologicFeature.getAttributeValue("meteorologic-feature-category-code").equalsIgnoreCase("ICING") ) { nextIdentifiers = m_data.getTargetIdentifiers( getSourceIdentifiers(), Icing.getEntityIdentifier() ); col = buildIcing( 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; } } /* * Multiplicity min: 1 max : 1 */ private Collection buildMeteorologicFeature( 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( MeteorologicFeature.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new MeteorologicFeature(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildCloudCover( 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( CloudCover.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new CloudCover(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildAtmosphere( 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( Atmosphere.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Atmosphere(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildVisibility( 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( Visibility.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Visibility(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildPrecipitation( 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( Precipitation.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Precipitation(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildFeature( 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( Feature.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Feature(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: 1 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 buildWind( 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( Wind.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Wind(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildLight( 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( Light.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Light(it.next()) ); } return col; } /* * Multiplicity min: 1 max : 1 */ private Collection buildIcing( 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( Icing.getEntityIdentifier(), identifier ) ); } Iterator it = rows.iterator(); while(it.hasNext()) { col.add(new Icing(it.next()) ); } return col; } private Collection getSourceIdentifiers(){ /* no implement see Annex C MeteorologicalFeature_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 Multiplicity m_multiplicity9 = new Multiplicity(1, 1); private Multiplicity m_multiplicity10 = 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(); }