コード例 #1
0
        /// <param name="dataset"> StateMod dataset object. </param>
        /// <returns> validation results. </returns>
        public virtual StateMod_ComponentValidation validateComponent(StateMod_DataSet dataset)
        {
            StateMod_ComponentValidation validation = new StateMod_ComponentValidation();
            string id      = getID();
            string name    = getName();
            string riverID = getCgoto();
            string dailyID = getCrunidy();

            // Make sure that basic information is not empty
            if (StateMod_Util.isMissing(id))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Stream estimate identifier is blank.", "Specify a station identifier."));
            }
            if (StateMod_Util.isMissing(name))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Stream estimate \"" + id + "\" name is blank.", "Specify a station name to clarify data."));
            }
            if (StateMod_Util.isMissing(riverID))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Stream estimate \"" + id + "\" river ID is blank.", "Specify a river ID to associate the station with a river network node."));
            }
            else
            {
                // Verify that the river node is in the data set, if the network is available
                if (dataset != null)
                {
                    DataSetComponent comp = dataset.getComponentForComponentType(StateMod_DataSet.COMP_RIVER_NETWORK);
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_RiverNetworkNode> rinList = (java.util.List<StateMod_RiverNetworkNode>)comp.getData();
                    IList <StateMod_RiverNetworkNode> rinList = (IList <StateMod_RiverNetworkNode>)comp.getData();
                    if ((rinList != null) && (rinList.Count > 0))
                    {
                        if (StateMod_Util.IndexOf(rinList, riverID) < 0)
                        {
                            validation.add(new StateMod_ComponentValidationProblem(this, "Stream estimate \"" + id + "\" river network ID (" + riverID + ") is not found in the list of river network nodes.", "Specify a valid river network ID to associate the station with a river network node."));
                        }
                    }
                }
            }
            // Verify that the daily ID is in the data set
            if (!StateMod_Util.isMissing(dailyID))
            {
                if (dataset != null)
                {
                    DataSetComponent comp = dataset.getComponentForComponentType(StateMod_DataSet.COMP_STREAMGAGE_STATIONS);
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_StreamGage> risList = (java.util.List<StateMod_StreamGage>)comp.getData();
                    IList <StateMod_StreamGage> risList = (IList <StateMod_StreamGage>)comp.getData();
                    if ((risList != null) && (risList.Count > 0))
                    {
                        if (!dailyID.Equals("0") && !dailyID.Equals("3") && !dailyID.Equals("4") && (StateMod_Util.IndexOf(risList, dailyID) < 0))
                        {
                            validation.add(new StateMod_ComponentValidationProblem(this, "Stream estimate \"" + id + "\" daily ID (" + dailyID + ") is not 0, 3, or 4 and is not found in the list of stream gages.", "Specify the daily ID as 0, 3, 4, or that matches a stream gage ID."));
                        }
                    }
                }
            }
            return(validation);
        }
コード例 #2
0
        /// <param name="dataset"> StateMod dataset object. </param>
        /// <returns> validation results. </returns>
        public virtual StateMod_ComponentValidation validateComponent(StateMod_DataSet dataset)
        {
            StateMod_ComponentValidation validation = new StateMod_ComponentValidation();
            string id     = getID();
            string name   = getName();
            string cgoto  = getCgoto();
            string irtem  = getIrtem();
            double dcrifr = getDcrifr();

            // Make sure that basic information is not empty
            if (StateMod_Util.isMissing(id))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow right identifier is blank.", "Specify a instream flow right identifier."));
            }
            if (StateMod_Util.isMissing(name))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow right \"" + id + "\" name is blank.", "Specify an instream flow right name to clarify data."));
            }
            if (StateMod_Util.isMissing(cgoto))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow right \"" + id + "\" station ID is blank.", "Specify an instream flow station to associate with the instream flow right."));
            }
            else
            {
                // Verify that the instream flow station is in the data set, if the network is available
                DataSetComponent         comp2   = dataset.getComponentForComponentType(StateMod_DataSet.COMP_INSTREAM_STATIONS);
                System.Collections.IList ifsList = (System.Collections.IList)comp2.getData();
                if ((ifsList != null) && (ifsList.Count > 0))
                {
                    if (StateMod_Util.IndexOf(ifsList, cgoto) < 0)
                    {
                        validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow right \"" + id + "\" associated instream flow (" + cgoto + ") is not found in the list of instream flow stations.", "Specify a valid instream flow station ID to associate with the instream flow right."));
                    }
                }
            }
            if (StateMod_Util.isMissing(irtem))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow right \"" + id + "\" administration number is blank.", "Specify an administration number NNNNN.NNNNN."));
            }
            else if (!StringUtil.isDouble(irtem))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow right \"" + id + "\" administration number (" + irtem + ") is invalid.", "Specify an administration number NNNNN.NNNNN."));
            }
            else
            {
                double irtemd = double.Parse(irtem);
                if (irtemd < 0)
                {
                    validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow right \"" + id + "\" administration number (" + irtem + ") is invalid.", "Specify an administration number NNNNN.NNNNN."));
                }
            }
            if (!(dcrifr >= 0.0))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow right \"" + id + "\" decree (" + StringUtil.formatString(dcrifr, "%.2f") + ") is invalid.", "Specify the decree as a number >= 0."));
            }
            return(validation);
        }
コード例 #3
0
        /// <param name="dataset"> StateMod dataset object. </param>
        /// <returns> validation results. </returns>
        public virtual StateMod_ComponentValidation validateComponent(StateMod_DataSet dataset)
        {
            StateMod_ComponentValidation validation = new StateMod_ComponentValidation();
            string id      = getID();
            string name    = getName();
            string riverID = getCgoto();
            string dailyID = getCrunidy();

            // Make sure that basic information is not empty
            if (StateMod_Util.isMissing(id))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Stream gage identifier is blank.", "Specify a station identifier."));
            }
            if (StateMod_Util.isMissing(name))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Stream gage \"" + id + "\" name is blank.", "Specify a station name to clarify data."));
            }
            if (StateMod_Util.isMissing(riverID))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Stream gage \"" + id + "\" river ID is blank.", "Specify a river ID to associate the station with a river network node."));
            }
            else
            {
                // Verify that the river node is in the data set, if the network is available
                if (dataset != null)
                {
                    DataSetComponent         comp    = dataset.getComponentForComponentType(StateMod_DataSet.COMP_RIVER_NETWORK);
                    System.Collections.IList rinList = (System.Collections.IList)comp.getData();
                    if ((rinList != null) && (rinList.Count > 0))
                    {
                        if (StateMod_Util.IndexOf(rinList, riverID) < 0)
                        {
                            validation.add(new StateMod_ComponentValidationProblem(this, "Stream gage \"" + id + "\" river network ID (" + riverID + ") is not found in the list of river network nodes.", "Specify a valid river network ID to associate the station with a river network node."));
                        }
                    }
                }
            }
            // Verify that the daily ID is in the data set
            if (!StateMod_Util.isMissing(dailyID))
            {
                if (dataset != null)
                {
                    DataSetComponent         comp    = dataset.getComponentForComponentType(StateMod_DataSet.COMP_STREAMGAGE_STATIONS);
                    System.Collections.IList risList = (System.Collections.IList)comp.getData();
                    if ((risList != null) && (risList.Count > 0))
                    {
                        if (!dailyID.Equals("0") && !dailyID.Equals("3") && !dailyID.Equals("4") && (StateMod_Util.IndexOf(risList, dailyID) < 0))
                        {
                            validation.add(new StateMod_ComponentValidationProblem(this, "Stream gage \"" + id + "\" daily ID (" + dailyID + ") is not 0, 3, or 4 and is not found in the list of stream gages.", "Specify the daily ID as 0, 3, 4, or that matches a stream gage ID."));
                        }
                    }
                }
            }
            return(validation);
        }
コード例 #4
0
        /// <param name="dataset"> StateMod dataset object. </param>
        /// <returns> Validation results. </returns>
        public virtual StateMod_ComponentValidation validateComponent(StateMod_DataSet dataset)
        {
            StateMod_ComponentValidation validation = new StateMod_ComponentValidation();
            string id   = getID();
            string name = getName();
            string downstreamRiverID = getCstadn();
            double gwmaxr            = getGwmaxr();

            // Make sure that basic information is not empty
            if (StateMod_Util.isMissing(id))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "River node identifier is blank.", "Specify a river node identifier."));
            }
            if (StateMod_Util.isMissing(name))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "River node \"" + id + "\" name is blank.", "Specify a river node name to clarify data."));
            }
            // Get the network list if available for checks below
            DataSetComponent comp = null;

            System.Collections.IList rinList = null;
            if (dataset != null)
            {
                comp    = dataset.getComponentForComponentType(StateMod_DataSet.COMP_RIVER_NETWORK);
                rinList = (System.Collections.IList)comp.getData();
                if ((rinList != null) && (rinList.Count == 0))
                {
                    // Set to null to simplify checks below
                    rinList = null;
                }
            }
            if (StateMod_Util.isMissing(downstreamRiverID) && !name.Equals("END", StringComparison.OrdinalIgnoreCase) && !name.EndsWith("_END", StringComparison.Ordinal))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "River node \"" + id + "\" downstream node ID is blank.", "Specify a downstream node ID."));
            }
            else
            {
                // Verify that the downstream river node is in the data set, if the network is available - skip this
                // check for the end node.
                if ((rinList != null) && !name.Equals("END", StringComparison.OrdinalIgnoreCase) && !name.EndsWith("_END", StringComparison.Ordinal))
                {
                    if (StateMod_Util.IndexOf(rinList, downstreamRiverID) < 0)
                    {
                        validation.add(new StateMod_ComponentValidationProblem(this, "River node \"" + id + "\" downstream node ID (" + downstreamRiverID + ") is not found in the list of river network nodes.", "Specify a valid river network ID for the downstream node."));
                    }
                }
            }
            if (!StateMod_Util.isMissing(gwmaxr) && !(gwmaxr >= 0.0))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "River node \"" + id + "\" maximum groundwater recharge (" + StringUtil.formatString(gwmaxr, "%.2f") + ") is invalid.", "Specify the maximum groundwater recharge as a number >= 0."));
            }
            return(validation);
        }
コード例 #5
0
        /// <summary>
        /// Performs specific data checks for a component.  The
        /// intelligence and checks are stored in the component itself. </summary>
        /// <param name="data"> List of data objects to check. </param>
        /// <returns> List of data that failed the data checks. </returns>
        private System.Collections.IList doSpecificDataChecks(System.Collections.IList data, PropList props)
        {
            System.Collections.IList checks = new List <object>();
            if (data == null)
            {
                return(checks);
            }
            // Check each component object by calling the
            // checkComponentData() method.  Each component
            // needs to implement this method and extend from
            // the StateMod_Component interface.
            StateMod_ComponentValidator comp = null;

            for (int i = 0; i < data.Count; i++)
            {
                comp = (StateMod_ComponentValidator)data[i];
                StateMod_ComponentValidation validation = comp.validateComponent(__dataset);
                if (validation.size() > 0)
                {
                    checks.AddRange(validation.getAll());
                }
            }
            return(checks);
        }
コード例 #6
0
        /// <param name="dataset"> StateMod dataset object. </param>
        /// <returns> List of data that failed specific checks. </returns>
        public virtual StateMod_ComponentValidation validateComponent(StateMod_DataSet dataset)
        {
            StateMod_ComponentValidation validation = new StateMod_ComponentValidation();
            string id                = getID();
            string name              = getName();
            string riverID           = getCgoto();
            string downstreamRiverID = getIfrrdn();
            string dailyID           = getCifridy();
            int    iifcom            = getIifcom();

            // Make sure that basic information is not empty
            if (StateMod_Util.isMissing(id))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow station identifier is blank.", "Specify a station identifier."));
            }
            if (StateMod_Util.isMissing(name))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow station \"" + id + "\" name is blank.", "Specify an instream flow station name to clarify data."));
            }
            // Get the network list if available for checks below
            DataSetComponent comp = null;

            System.Collections.IList rinList = null;
            if (dataset != null)
            {
                comp    = dataset.getComponentForComponentType(StateMod_DataSet.COMP_RIVER_NETWORK);
                rinList = (System.Collections.IList)comp.getData();
                if ((rinList != null) && (rinList.Count == 0))
                {
                    // Set to null to simplify checks below
                    rinList = null;
                }
            }
            if (StateMod_Util.isMissing(riverID))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow station \"" + id + "\" river node ID is blank.", "Specify a river node ID to associate the instream flow station with a river network node."));
            }
            else
            {
                // Verify that the river node is in the data set, if the network is available
                if (rinList != null)
                {
                    if (StateMod_Util.IndexOf(rinList, riverID) < 0)
                    {
                        validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow station \"" + id + "\" river network ID (" + riverID + ") is not found in the list of river network nodes.", "Specify a valid river network ID to associate the instream flow station."));
                    }
                }
            }
            if (StateMod_Util.isMissing(downstreamRiverID))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow station \"" + id + "\" downstream river node ID is blank.", "Specify a downstream river node ID to associate the instream flow station with a river network node."));
            }
            else
            {
                // Verify that the river node is in the data set, if the network is available
                if (rinList != null)
                {
                    if (StateMod_Util.IndexOf(rinList, downstreamRiverID) < 0)
                    {
                        validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow station \"" + id + "\" downstream river network ID (" + riverID + ") is not found in the list of river network nodes.", "Specify a valid river network ID to associate the instream flow station downstream node."));
                    }
                }
            }
            // Verify that the daily ID is in the data set (daily ID is allowed to be missing)
            if ((dataset != null) && !StateMod_Util.isMissing(dailyID))
            {
                DataSetComponent         comp2   = dataset.getComponentForComponentType(StateMod_DataSet.COMP_INSTREAM_STATIONS);
                System.Collections.IList ifsList = (System.Collections.IList)comp2.getData();
                if (dailyID.Equals("0") || dailyID.Equals("3") || dailyID.Equals("4"))
                {
                    // OK
                }
                else if ((ifsList != null) && (ifsList.Count > 0))
                {
                    // Check the instream flow station list
                    if (StateMod_Util.IndexOf(ifsList, dailyID) < 0)
                    {
                        validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow station \"" + id + "\" daily ID (" + dailyID + ") is not 0, 3, or 4 and is not found in the list of instream flow stations.", "Specify the daily ID as 0, 3, 4, or a matching instream flow station ID."));
                    }
                }
            }
            IList <string> choices = getIifcomChoices(false);

            if (StringUtil.indexOfIgnoreCase(choices, "" + iifcom) < 0)
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow station \"" + id + "\" data type (" + iifcom + ") is invalid.", "Specify the data type as one of " + choices));
            }
            // TODO SAM 2009-06-01) evaluate how to check rights (with getRights() or checking the rights data
            // set component).
            return(validation);
        }
コード例 #7
0
        /// <param name="dataset"> StateMod dataset object. </param>
        /// <returns> validation results. </returns>
        public virtual StateMod_ComponentValidation validateComponent(StateMod_DataSet dataset)
        {
            StateMod_ComponentValidation validation = new StateMod_ComponentValidation();
            string id     = getID();
            string name   = getName();
            string cgoto  = getCgoto();
            string irtem  = getRtem();
            double dcrres = getDcrres();
            int    iresco = getIresco();
            int    ityrsr = getItyrstr();
            int    n2fill = getN2fill();
            string copid  = getCopid();

            // Make sure that basic information is not empty
            if (StateMod_Util.isMissing(id))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir right identifier is blank.", "Specify a reservoir right identifier."));
            }
            if (StateMod_Util.isMissing(name))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir right \"" + id + "\" name is blank.", "Specify a reservoir right name to clarify data."));
            }
            if (StateMod_Util.isMissing(cgoto))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir right \"" + id + "\" reservoir station ID is blank.", "Specify a reservoir station to associate with the reservoir right."));
            }
            else
            {
                // Verify that the reservoir station is in the data set, if the network is available
                DataSetComponent         comp2   = dataset.getComponentForComponentType(StateMod_DataSet.COMP_RESERVOIR_STATIONS);
                System.Collections.IList resList = (System.Collections.IList)comp2.getData();
                if ((resList != null) && (resList.Count > 0))
                {
                    if (StateMod_Util.IndexOf(resList, cgoto) < 0)
                    {
                        validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir right \"" + id + "\" associated reservoir (" + cgoto + ") is not found in the list of reservoir stations.", "Specify a valid reservoir station ID to associate with the reservoir right."));
                    }
                }
            }
            if (StateMod_Util.isMissing(irtem))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir right \"" + id + "\" administration number is blank.", "Specify an administration number NNNNN.NNNNN."));
            }
            else if (!StringUtil.isDouble(irtem))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir right \"" + id + "\" administration number (" + irtem + ") is invalid.", "Specify an administration number NNNNN.NNNNN."));
            }
            else
            {
                double irtemd = double.Parse(irtem);
                if (irtemd < 0)
                {
                    validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir right \"" + id + "\" administration number (" + irtem + ") is invalid.", "Specify an administration number NNNNN.NNNNN."));
                }
            }
            if (!(dcrres >= 0.0))
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir right \"" + id + "\" decree (" + StringUtil.formatString(dcrres, "%.2f") + ") is invalid.", "Specify the decree as a number >= 0."));
            }
            IList <string> choices = getIrescoChoices(false);

            if (StringUtil.indexOfIgnoreCase(choices, "" + iresco) < 0)
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir \"" + id + "\" ownership code (" + iresco + ") is invalid.", "Specify the ownership code as one of " + choices));
            }
            choices = getItyrsrChoices(false);
            if (StringUtil.indexOfIgnoreCase(choices, "" + ityrsr) < 0)
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir \"" + id + "\" right type (" + ityrsr + ") is invalid.", "Specify the right type as one of " + choices));
            }
            choices = getN2fillChoices(false);
            if (StringUtil.indexOfIgnoreCase(choices, "" + n2fill) < 0)
            {
                validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir \"" + id + "\" first fill type (" + n2fill + ") is invalid.", "Specify the first fill type as one of " + choices));
            }
            if (ityrsr == -1)
            {
                if (StateMod_Util.isMissing(copid))
                {
                    validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir right out-of-priority associated operational right identifier is blank.", "Specify an operational right identifier."));
                }
            }
            return(validation);
        }