psdi.app.meter

Class DeployedMeter

  • java.lang.Object
    • Field Detail

      • isReadingUpdate

        protected boolean isReadingUpdate
        used when rolling a meter reading down and/or forward. When true, there are no new readings being entered. That is, the transaction is a pure update of an already-existing meter reading, and the subsequent rolling follows from this update. When false, a new reading has been entered, other new readings may be created when the new reading is rolled down.
      • origMRUpdate

        protected Mbo origMRUpdate
        when performing a meter history update, this is the meter reading MBO that is at the beginning of the rollforward and at the top of the rolldown. If the update is occurring through a user interface, this would be the reading that is being updated directly by the user.
      • deployKey

        protected java.lang.String deployKey
        key for the subclass of this DeployedMeter. For example, the key for AssetMeter would be "assetnum".
      • readingTable

        protected java.lang.String readingTable
        table that holds the meter reading history for the subclass of this DeployedMeter. For example, the meter reading history table for AssetMeter would be "MeterReading".
      • avgCalcKey

        protected java.lang.String avgCalcKey
        key to be used in the average meter reading calculation for the subclass of this DeployedMeter. The average calculation key for AssetMeter is "assetid", and the average calculation key for LocationMeter is "location".
      • woForWOMeter

        protected MboRemote woForWOMeter
        work order from which this DeployedMeter was instantiated. This work order is the owner of this DeployedMeter's owner. This work order is needed to add the WOMeter and set its work order-originated attributes in its add() method.
      • woMeter_IdAttribute

        protected java.lang.String woMeter_IdAttribute
        WOMETER.MeterReadingId or WOMETER.LocMeterReadingId depending on whether the WOMeter is for an AssetMeter or LocationMeter. This pertains only to meters of type CONTINUOUS. WOMeter.MeasurementId is set explicitly when the meter type is GAUGE or CHARACTERISTIC.
      • supressUniquenessError

        protected boolean supressUniquenessError
        if DeployedMeter is being added from MeterInGroup via the PropagateMeterGroupMod functionality, or if DeployedMeter is being added as a result of the DeployedMeter's parent's GroupName attribute being modified, this flag is used by MeterService's meterUniqueToSet() method to supress the system's duplicatekey error. This flag is set to true in meterInGroupToAssetMeter(MeterInGroupRemote meter,boolean supressUniquenessError). If true, error will not be thrown if a duplicate DeployedMeter addition is attempted. Instead, it will be quietly removed from the set of DeployedMeters to be added.
      • enteringReplacementReading

        protected boolean enteringReplacementReading
        is this DeployedMeter in the process of adding a replacement meterreading? A replacement reading always has a delta of 0.
      • app

        protected java.lang.String app
        used in determining signature security for entering and modifying meter readings.
        See Also:
        DeployedMeter.getApp()
    • Constructor Detail

      • DeployedMeter

        public DeployedMeter(MboSet ms)
                      throws MXException,
                             java.rmi.RemoteException
        Constructs the DeployedMeter object.

        Throws:
        MXException
        java.rmi.RemoteException
    • Method Detail

      • modify

        public void modify()
                    throws MXException,
                           java.rmi.RemoteException
        called whenever a field is modified to update the changedate and changeby attributes
        Overrides:
        modify in class Mbo
        Throws:
        MXException
        java.rmi.RemoteException
      • addModifiedReadingsForAvgCalc

        public void addModifiedReadingsForAvgCalc(MboRemote reading)
                                           throws MXException,
                                                  java.rmi.RemoteException
        adds modified readings to be used to refresh the average reading for the DeployedMeter following a new meter reading or meter reading update. This is necessary because the average calculation takes place by querying the database before the modified readings have been saved to the database. Subsequently, when the average calculation is taking place, the modifiedReadings Hashtable is first checked for each Reading object. If modifiedReadings contains a Reading's meterreading, it is used in the calculation instead of the "dirty" Reading just queried from the database. This method also sets earliestModifiedReading equal to the new reading, if earliestModifiedReading is null or has a readingdate later than the new reading's readigdate.
        Specified by:
        addModifiedReadingsForAvgCalc in interface DeployedMeterRemote
        Parameters:
        rollId - key for a new entry in the adjustedDeltas hashtable.
        value - adjusted delta value for a new entry in the adjustedDeltas hashtable.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        DeployedMeter.addModifiedReadingsForAvgCalc(MboRemote reading)
      • rolloverIsInProgress

        protected void rolloverIsInProgress()
                                     throws MXException,
                                            java.rmi.RemoteException
        controls the MXApplicationYesNoCancelException used to get user input re: whether or not a rollover is occurring; sets DoRollover attribute to be true when a reading for this DeployedMeter is being processed as a rollover
        Throws:
        MXApplicationYesNoCancelException("DeployedMeter.rolloverIsInProgress()","meter","didRollOver") - when there is no user input registered to the Bulletin Board for this exception
        MXException
        java.rmi.RemoteException
        See Also:
        DeployedMeter.appValidate(), Reading.appValidate()
      • isEnteringReplacementReading

        protected boolean isEnteringReplacementReading()
                                                throws MXException,
                                                       java.rmi.RemoteException
        is reading for this DeployedMeter a reset of the meter due to meter replacement?
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        Reading.add()
      • setOrigMRUpdate

        public void setOrigMRUpdate(Mbo origMRUpdate)
                             throws MXException,
                                    java.rmi.RemoteException
        sets origMRUpdate with the meter reading whose update began 'Update Meter History' processing
        Specified by:
        setOrigMRUpdate in interface DeployedMeterRemote
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.asset.MeterReading.save(), psdi.app.location.LocMeterReading.save()
      • returnDeploymentInfo

        public java.lang.Object[] returnDeploymentInfo()
                                                throws MXException,
                                                       java.rmi.RemoteException
        returns key value and meter reading table name information for the DeployedMeter's instanciated subclass, for example, an AssetMeter ("assetnum" and "meterreading") or LocationMeter ("location" and "locmeterreading").
        Specified by:
        returnDeploymentInfo in interface DeployedMeterRemote
        Returns:
        Object[] holding the keyvalue in Object[0] and meter reading table name in Object[1] for the instanciated subclass of this DeployedMeter
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        DeployedMeter.getDeploymentInfo()
      • isReadingMostRecentReading

        public boolean isReadingMostRecentReading(java.util.Date readingDate)
                                           throws MXException,
                                                  java.rmi.RemoteException
        determines whether this DeployedMeter's LastReading and LastReadingDate attributes need to be updated. If the reading being added is more recent or the reading being modified is the same reading as the LastReading, then the updates will occur. In the case of an update, just the LastReading attribute will be modified.
        Specified by:
        isReadingMostRecentReading in interface DeployedMeterRemote
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        DeployedMeter.isReadingMostRecentReading(Date readingDate)
      • setIsReadingUpdate

        public void setIsReadingUpdate(boolean isUpdate)
                                throws MXException,
                                       java.rmi.RemoteException
        sets to true the yes/no flag that tells whether this DeployedMeter been instanciated while rolling a reading update down the hierarchy and forward through each DeployedMeter's meter reading history. This method should not be called for updates resulting from a new reading - it is specifically for rolling a pure update to an already-existing Reading.
        Specified by:
        setIsReadingUpdate in interface DeployedMeterRemote
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        DeployedMeter.setIsReadingUpdate(boolean isUpdate)
      • getSupressUniquenessErrorFlag

        public boolean getSupressUniquenessErrorFlag()
                                              throws MXException,
                                                     java.rmi.RemoteException
        returns the supressUniquenessError flag
        Specified by:
        getSupressUniquenessErrorFlag in interface DeployedMeterRemote
        Returns:
        supressUniquenessError if true, system duplicatekey error will not be thrown as new DeployedMeters are being generated behind the scenes after adding a new Meter to a MeterGroup, or after modifying a DeployedMeter's owner's GroupName attribute.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        MeterService's meterUniqueToSet(), meterInGroupToAssetMeter(MeterInGroupRemote meter,boolean supressUniquenessError).
      • validateReading

        protected void validateReading(MboRemote readingMbo)
                                throws MXException,
                                       java.rmi.RemoteException
        validates readings for DeployedMeter.NewReading and Reading.ModifiedReading
        Parameters:
        readingMbo -
        Throws:
        MXApplicationException("meter","bePositive") - when a negative value is entered.
        MXApplicationException("meter","cantExceedRollover") - when a reading exceeds the rollover value.
        MXApplicationException("meter","lowReading") - when a reading is less than the previous reading and it is neither a delta reading nor a rolled over reading.
        MXException
        java.rmi.RemoteException
      • getNextMeterReading

        public MboRemote getNextMeterReading(java.util.Date followingDate)
                                      throws MXException,
                                             java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • add

        public void add()
                 throws MXException,
                        java.rmi.RemoteException
        adds a new DeployedMeter object and sets field defaults.
        Specified by:
        add in interface MboRemote
        Overrides:
        add in class Mbo
        Throws:
        MXException
        java.rmi.RemoteException
      • hasDeployedMeterApprReadingDeletion

        protected boolean hasDeployedMeterApprReadingDeletion()
                                                       throws MXException,
                                                              java.rmi.RemoteException
        used by Reading object to determine whether this owning DeployedMeter object has determined that it is OK to delete the owner's ReadingSet.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        Reading.canDelete()
      • canDelete

        public void canDelete()
                       throws MXException,
                              java.rmi.RemoteException
        This DeployedMeter can be deleted if it does not exist in any of the following objects:

        • MeterReading (for AssetMeter)
        • LocMeterReading (for LocationMeter)
        • MeasurePoint
        Overrides:
        canDelete in class Mbo
        Throws:
        MXApplicationException - ("meter","existsintable") when referenced by another object.
        MXException
        java.rmi.RemoteException
      • canDeleteForecast

        public boolean canDeleteForecast(java.lang.String message)
                                  throws MXException,
                                         java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • delete

        public void delete(long accessModifier)
                    throws MXException,
                           java.rmi.RemoteException
        Description copied from class: Mbo
        Mark the object to be deleted depending on the access modifier. This will usually be overridden in the subclass of Mbo as there may be application specific rules as to if and when an object can be deleted. Object is not actually deleted in the database until save() is called. This method will also mark all associated Long Description and Translation Mbos for deletion.
        Specified by:
        delete in interface MboRemote
        Overrides:
        delete in class Mbo
        Parameters:
        accessModifier - The bitwise flag specified to determine if certain normal security checks are to be bypassed for this delete request. For example: if the accessModifer is NOACCESSCHECK, then the check for the object's NODELETE flag and the call to the object's canDelete() method will not be performed. If the accessModifer is NONE, then all the access checks are performed before this object is marked delete.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        Mbo.delete(long)
      • undelete

        public void undelete()
                      throws MXException,
                             java.rmi.RemoteException
        Description copied from class: Mbo
        Unmark the Mbo for deletion. Can only be called after a delete() and before the save() has been performed. This method will also unmark associated Long Description and Translation Mbos.
        Specified by:
        undelete in interface MboRemote
        Overrides:
        undelete in class Mbo
        Throws:
        MXException
        java.rmi.RemoteException
      • meterInGroupToDeployedMeter

        public void meterInGroupToDeployedMeter(MeterInGroupRemote meter,
                                                boolean supressUniquenessError,
                                                boolean supressDupSeqNumWarning)
                                         throws MXException,
                                                java.rmi.RemoteException
        sets meter-specific attributes for this DeployedMeter object from the passed in meter
        Specified by:
        meterInGroupToDeployedMeter in interface DeployedMeterRemote
        Parameters:
        meter - MeterInGroupRemote object used to set meter-specific attributes
        supressUniquenessError - if DeployedMeter is being added from MeterInGroup via the PropagateMeterGroupMod functionality, or if DeployedMeter is being added as a result of the DeployedMeter's parent's GroupName attribute getting a value, supress the system's duplicatekey error
        supressDupSeqNumWarning - user has chosen to add a new meter to a group with a duplicate sequence. Assume that it is OK to duplicate the sequence number on assets and locations that have this meter group.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        DeployedMeter.meterInGroupToDeployedMeter(MeterInGroupRemote meter,boolean supressUniquenessError,boolean supressDupSeqNumWarning)
      • init

        public void init()
                  throws MXException
        initialization routine for this object. In addition to setting field flags, DeployedMeter's init sets the information needed from the last reading, and calculates the non-persistent AvgMeterUnits value.
        Overrides:
        init in class Mbo
        Throws:
        MXException
      • getTheMeter

        public MeterRemote getTheMeter()
                                throws MXException,
                                       java.rmi.RemoteException
        Specified by:
        getTheMeter in interface DeployedMeterRemote
        Returns:
        the Meter object associated with this DeployedMeter
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.meter.DeployedMeter#isAReadingUpdate()
      • getDeploymentInfo

        protected abstract java.lang.Object[] getDeploymentInfo()
                                                         throws MXException,
                                                                java.rmi.RemoteException
        provides key value and meter reading table name information for the DeployedMeter's instanciated subclass, for example, an AssetMeter ("assetnum" and "meterreading") or LocationMeter ("location" and "locmeterreading").
        Returns:
        Object[] holding the keyvalue in Object[0] and meter reading table name in Object[1] for the instanciated subclass of this DeployedMeter
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        DeployedMeter.init(), getReadings()
      • processContinuousReadings

        protected abstract void processContinuousReadings()
                                                   throws MXException,
                                                          java.rmi.RemoteException
        processes the new or adjusted reading for the DeployedMeter
        Throws:
        MXException
        java.rmi.RemoteException
      • refreshAverage

        protected void refreshAverage()
                               throws MXException,
                                      java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • refreshPreviousReadingInfo

        public void refreshPreviousReadingInfo(java.util.Date previousToDate)
                                        throws MXException,
                                               java.rmi.RemoteException
        gets the previous meter reading and uses it to set the following non-persistent attributes:
        • PreviousReading
        • PreviousReadingDate
        • PreviousReadingInspector

        Also, if NewReadingDate has been set, then method checks to see if the new reading is a new historic reading.

        Specified by:
        refreshPreviousReadingInfo in interface DeployedMeterRemote
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        DeployedMeter.refreshPreviousReadingInfo(Date)
      • getPreviousMeterReading

        public MboRemote getPreviousMeterReading(java.util.Date previousToDate)
                                          throws MXException,
                                                 java.rmi.RemoteException
        gets the meter reading (for a DeployedMeter whose meter is of type CONTINUOUS) or measurement (for a DeployedMeter whose meter is of type CHARACTERISTIC or GAUGE) that immediately precedes one of the following:
        • meter reading/measurement being entered or updated for the DeployedMeter if meterreading activity is taking place
        • current date/time, to get the last, that is, most recent reading taken for the DeployedMeter.
        Specified by:
        getPreviousMeterReading in interface DeployedMeterRemote
        Parameters:
        previousToDate - date used to find the previous reading (that is,the reading that is older than but closest to the date)
        Returns:
        reading MBO
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        DeployedMeter.refreshPreviousReadingInfo(Date previousToDate)
      • getSkipDateUniquenessCheck

        protected boolean getSkipDateUniquenessCheck()
                                              throws MXException,
                                                     java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • isMeterReadingDateUnique

        protected void isMeterReadingDateUnique()
                                         throws MXException,
                                                java.rmi.RemoteException
        makes sure that a reading has not already been entered for the exact same reading date to the millisecond. Reading dates can be duplicated when the date is modified in the ui. If the seconds portion of the date/time is not displayed and the seconds are not explicitly set, the seconds portion resets to 00.0. As a result, entering two readings and setting the day to 2 days ago within the same clock minute will lead to this error.
        Throws:
        MXApplicationException("meter","duplicateReadingDate",param) - when duplicate dates are provided for continuous meter readings.
        MXApplicationException("meter","duplicateMeasurementDate",param) - when duplicate dates are provided for gauge or characteristic meter readings.
        MXException
        java.rmi.RemoteException
      • setPreviousReadingInfoOnInit

        public void setPreviousReadingInfoOnInit()
                                          throws MXException,
                                                 java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • getValidateOrder

        public java.lang.String[] getValidateOrder()
        Validation Order for DeployedMeter attributes. Those listed here will have precedence over those not listed here. The order of precedence goes from first in the list (highest precedence among listed attributes) to last (lowest precedence among listed attributes)
        The list is:
        1. METERNAME
        Overrides:
        getValidateOrder in class Mbo
      • appValidate

        public void appValidate()
                         throws MXException,
                                java.rmi.RemoteException
        validates context-sensitive attributes AvgCalcInfo and AvgCalcMethod. When AvgCalcMethod is not equal to ALL and the meter type is CONTINUOUS, then AvgCalcInfo is required.
        Overrides:
        appValidate in class Mbo
        Throws:
        MXApplicationException - ("asset", "multiplier_null")
        MXApplicationException - ("asset", "value_null")
        MXException
        java.rmi.RemoteException
      • returnReadingForWOMeterProcessing

        public MboRemote returnReadingForWOMeterProcessing()
                                                    throws MXException,
                                                           java.rmi.RemoteException
        returns reading to use for creation of a WOMeter when processing a WOMeter. This reading will be a Measurement if the meter is of type GAUGE or CHARACTERISTIC. This reading will be a MeterReading (for an AssetMeter) or a LocMeterReading (for a LocationMeter) if the meter is of type CONTINUOUS. If the measurement/reading has already been added, the reading is not added again. Only a WOMeter is created based on the already-entered reading. If the measurement/reading has not already been added, then this will return null and a new Measurement, MeterReading or LocMeterReading will be added before adding the new WOMeter.
        Specified by:
        returnReadingForWOMeterProcessing in interface DeployedMeterRemote
        Returns:
        MboRemote Measurement,MeterReading or LocMeterReading that is being added by a work order. Returns null if the measurement/reading has not already been added (that is, a reading with the same date and value). The null return signals to the DeployedMeter that a new measurement/ reading needs to be added.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        AssetMeter.save(), LocationMeter.save()
      • handleAssetMeterLocMeterForWOEnterMeterReading

        protected void handleAssetMeterLocMeterForWOEnterMeterReading()
                                                               throws MXException,
                                                                      java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • save

        public void save()
                  throws MXException,
                         java.rmi.RemoteException
        begins the process of entering a new meterreading object and/or rolling updates to an existing meterreading object down the hierarchy to LocationMeters that belong to children asset of this LocationMeter's asset and forward to other subsequent readings already recorded for this LocationMeter. LocationMeter cumulative attributes are then updated. These attributes are:
        • SINCELASTREPAIR
        • SINCELASTOVERHAUL
        • SINCELASTINSPECT
        • SINCEINSTALL
        • LIFETODATE
        Overrides:
        save in class Mbo
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        enterNewReading, updateCumulatives
      • enterReadingOnMaterialIssue

        public boolean enterReadingOnMaterialIssue()
                                            throws MXException,
                                                   java.rmi.RemoteException
        called from an owning and new MatUseTrans object of IssueType ISSUE to record a meter reading when the item being issued is NOT rotating, has a metername and is being issued to an Asset or Location, and the Asset or Location has an AssetMeter or LocationMeter with a metername that corresponds to the issued item's metername.
        Specified by:
        enterReadingOnMaterialIssue in interface DeployedMeterRemote
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        DeployedMeter.enterReadingOnMaterialIssue()
      • validateALNEnteredDecimalValue

        public void validateALNEnteredDecimalValue(java.lang.String readingAttribute)
                                            throws MXException,
                                                   java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • getNumerator

        protected double getNumerator()
                               throws MXException,
                                      java.rmi.RemoteException
        Gets the numerator. Implemented to help override logic by TR IS
        Returns:
        the numerator
        Throws:
        MXException - the mX exception
        java.rmi.RemoteException - the remote exception
      • getDenominator

        protected double getDenominator(java.util.Date earliest,
                                        java.util.Date recent)
                                 throws MXException,
                                        java.rmi.RemoteException
        Gets the denominator. Refactoring to help TR IS override calculations.
        Parameters:
        earliest - the earliest date
        recent - the recent date
        Returns:
        the denominator
        Throws:
        MXException - the mX exception
        java.rmi.RemoteException - the remote exception
      • pmForecastExistsForMeterOnPM

        public boolean pmForecastExistsForMeterOnPM()
                                             throws MXException,
                                                    java.rmi.RemoteException
        Determines if this asset meter is used on a PM that has a forecast.
        Throws:
        MXException
        java.rmi.RemoteException