Class BTMeasureInsert
- All Implemented Interfaces:
Serializable,Tool,ValidExecution
BOMeasure. When the
MeasureInsertEvent is launched the BT notices the call and
inserts the BOMeasure basing on the event's input. Permissions:
MeasuringElementPermissions.MEASURING_ELEMENTS_VIEWMeasuringElementPermissions.MEASURING_ELEMENTS_EDIT
Error codes:
Codes.PROPERTY_REQUIREDCodes.Measure.PROPERTY_NOT_ALLOWED_FOR_MEASURING_ELEMENTCodes.Measure.CATALOG_CODE_NOT_ALLOWED_FOR_GROUPCodes.Measure.CATALOG_CODE_NOT_ALLOWED_FOR_GROUPCodes.Measure.PROPERTY_NOT_ALLOWEDCodes.Measure.VALUE_CONSTRAINTS_NOT_RESPECTEDCodes.Measure.INVALID_OPERATION_FOR_STATUSCodes.Measure.CONSTRAINT_VALUE_NOT_RESPECTED
- Since:
- 20.0
- See Also:
- GCApi:
- task
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BOCatalogCodeprotected BOMeasuringElementprotected BOMeasureFields inherited from class overit.geocallapp.utilities.core.bl.common.validexecution.ValidPermissionBusinessTask
LOG -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidalignNextMeasure(BOMeasure inputMeasure, PoolKit poolKit) Aligns the next chronological measure after a measure has been updated, specifically for quantitative measures of non-counter measuring elements.protected voidapplyAlignmentValues(BOMeasure measure, MeasureCalculateCounterAlignOutput output) Method that modifies the measure with the new values for the alignment.protected voidcheckCatalogGroupMeasure(BOMeasure measure) Method that checks if the catalog code is allowed for the catalog group.protected voidcheckCharacteristicMeasure(BOMeasure measure) Method that checks if the measure is valid for the characteristic.protected voidcompleteData(BOMeasure inputMeasure) Method that completes the data of the measure.protected voidcompleteMeasureMode(BOMeasure measure) protected voidexecute(MeasureInsertEvent event, PoolKit poolKit) Executes the actual business logic after validation has passed.getIntegrationService(PoolKit poolKit) Return theAssetsEventIntegrationServiceused to access other domains.protected LonginsertMeasure(BOMeasure measure, PoolKit poolKit) Inserts the given measure.booleanDetermines whether the current state is valid for execution.protected BOMeasureloadPreviousMeasure(BOMeasure measure, PoolKit poolKit) Method that loads the previous measure related to the current measuring element and the date on which the current measure was taken.protected voidnotifyInsert(BOMeasure measure, PoolKit poolKit) Notifies the insertion of a new measure.voidsetImpossibleToRead(BOMeasure inputMeasure, PoolKit poolKit) Sets a measure as impossible to read and aligns its values based on measuring element characteristics.protected voidvalidateCounterRotations(BOMeasure inputMeasure, PoolKit poolKit) Validates counter rotations for a measure and applies alignment calculations.protected voidvalidateInput(BOMeasure measure, PoolKit poolKit) Validates theBOMeasureobject data before its insertion.protected voidvalidateMeasureFeatures(BOMeasure inputMeasure, PoolKit poolKit) Method that validates the data related to the measuring features, i.e. the characteristic and the catalog group.protected voidvalidateMeasureValueConstraints(BOMeasure measure, PoolKit poolKit) Validates that measure values comply with characteristic-defined constraints.protected voidvalidateMeasureValues(BOMeasure measure) Validates that either value or deltaValue is present in the measure, but not both.Methods inherited from class overit.geocallapp.utilities.core.bl.common.validexecution.ValidPermissionBusinessTask
checkValidExecution, getException, throwExceptionIfInvalidMethods inherited from class overit.geocallapp.utilities.core.bl.common.validexecution.ValidExecutionBusinessTask
body, getEventMethods inherited from class overit.geocall.bl.BusinessTask
start, start, startAlone, startInBackground
-
Field Details
-
previousMeasure
-
measuringElement
-
catalogCode
-
-
Constructor Details
-
BTMeasureInsert
public BTMeasureInsert()
-
-
Method Details
-
execute
protected void execute(MeasureInsertEvent event, PoolKit poolKit) throws DAException, DAValidateException Description copied from class:ValidExecutionBusinessTaskExecutes the actual business logic after validation has passed.- Specified by:
executein classValidExecutionBusinessTask<MeasureInsertEvent>- Parameters:
event- the input event to processpoolKit- thePoolKit- Throws:
DAException- if a data access error occurs during executionDAValidateException- if validation fails during execution
-
validateInput
protected void validateInput(BOMeasure measure, PoolKit poolKit) throws DAValidateException, DAException Validates theBOMeasureobject data before its insertion.- Parameters:
measure- theBOMeasureobject to be insertedpoolKit- thePoolKitpk- Throws:
DAValidateException- if there is a data validation exceptionDAException- if a genericExceptionobject is thrown
-
loadPreviousMeasure
protected BOMeasure loadPreviousMeasure(BOMeasure measure, PoolKit poolKit) throws DAValidateException, DAException Method that loads the previous measure related to the current measuring element and the date on which the current measure was taken.- Returns:
- the previous measure
- Throws:
DAValidateExceptionDAException
-
alignNextMeasure
protected void alignNextMeasure(BOMeasure inputMeasure, PoolKit poolKit) throws DAValidateException, DAException Aligns the next chronological measure after a measure has been updated, specifically for quantitative measures of non-counter measuring elements.This method identifies and processes the next measure in sequence to ensure data consistency following an update to the current measure. Unlike counter-type measuring elements, which have special handling for rotations and cumulative values, this method focuses on the simpler alignment needs of standard quantitative measurements.
For non-counter quantitative measures, the alignment primarily involves:
- Recalculating delta values between the updated measure and the next measure
- Ensuring proper value propagation in the measurement sequence
- Maintaining the integrity of the measurement chain
This method is called after a measure update operation to ensure that subsequent measures properly reflect the changes made to the current measure.
- Parameters:
inputMeasure- the measure that was just updated and will serve as the reference for finding and aligning the next measurepoolKit- the pool kit providing access to database connections and services- Throws:
DAValidateException- if validation fails during the alignment processDAException- if a data access error occurs during the alignment process
-
setImpossibleToRead
public void setImpossibleToRead(BOMeasure inputMeasure, PoolKit poolKit) throws DAValidateException, DAException Sets a measure as impossible to read and aligns its values based on measuring element characteristics.The method handles the following cases when the measuring element has a characteristic:
- For counter-based measuring elements (with counter direction):
- Sets measure mode to
BOMeasureMode.Values.DIFFERENCE - Sets delta value to 0
- Sets measure mode to
- For non-counter measuring elements:
- If previous measure exists: copies its value
- If no previous measure: sets value to 0
- Parameters:
inputMeasure- the measure to be marked as impossible to readpoolKit- the pool kit for accessing integration services- Throws:
DAValidateException- if validation of measure data failsDAException- if there's an error during measure processing
- For counter-based measuring elements (with counter direction):
-
validateMeasureFeatures
protected void validateMeasureFeatures(BOMeasure inputMeasure, PoolKit poolKit) throws DAException, DAValidateException Method that validates the data related to the measuring features, i.e. the characteristic and the catalog group.
It also checks that if the characteristic is null we can't have the following properties:
- measure mode
- value
- delta value
- rotations
- Parameters:
inputMeasure- the new input measurepoolKit- thePoolKit- Throws:
DAException- thrown if there are data related loading errorsDAValidateException- thrown if the data related to the measuring characteristic are not valid
-
validateCounterRotations
protected void validateCounterRotations(BOMeasure inputMeasure, PoolKit poolKit) throws DAValidateException, DAException Validates counter rotations for a measure and applies alignment calculations.This method:
- Performs counter alignment check
- Validates if rotation input is required
- Applies the calculated alignment values to the measure
- Parameters:
inputMeasure- the measure to validate and alignpoolKit- the pool kit for accessing services- Throws:
DAValidateException- if rotation input is required but not providedDAException- if there's an error during alignment calculation
-
getIntegrationService
Return theAssetsEventIntegrationServiceused to access other domains.- Parameters:
poolKit- thePoolKit- Returns:
- the
AssetsEventIntegrationServiceused to access services and events in other domains - Throws:
DAValidateException- thrown if there are data related loading errors
-
checkCatalogGroupMeasure
Method that checks if the catalog code is allowed for the catalog group.
It also checks that if the catalog group is null we can't have the catalog code.- Parameters:
measure- the new input measure- Throws:
DAValidateException- thrown if the catalog code is not allowed for the catalog group
-
checkCharacteristicMeasure
Method that checks if the measure is valid for the characteristic.
For a characteristic that is not of type meter we also check that the user didn't specify the following properties:
- measure mode
- delta value
- rotations
- cumulative value
- Parameters:
measure- the new input measure- Throws:
DAValidateException- thrown if the measure is not valid for the characteristic
-
completeMeasureMode
-
validateMeasureValues
Validates that either value or deltaValue is present in the measure, but not both.This method enforces the following rules:
- At least one of value or deltaValue must be provided
- Value and deltaValue cannot both be present simultaneously
- Sets the measure mode to DIFFERENCE if deltaValue is provided, ABSOLUTE otherwise
- Parameters:
measure- the measure to validate- Throws:
DAValidateException- if both values are missing or if both values are present
-
applyAlignmentValues
Method that modifies the measure with the new values for the alignment.- Parameters:
measure- the new input measureoutput- the output of the eventMeasureCalculateCounterAlignEvent
-
validateMeasureValueConstraints
protected void validateMeasureValueConstraints(BOMeasure measure, PoolKit poolKit) throws DAValidateException, DAException Validates that measure values comply with characteristic-defined constraints.Performs the following validations:
- Loads the characteristic associated with the measuring element
- Validates numeric constraints (precision, range, etc.) on the measure value
- Parameters:
measure- the measure to validatepoolKit- thePoolKitfor accessing services- Throws:
DAValidateException- if the measure values violate characteristic constraintsDAException- if there are errors loading the characteristic data
-
completeData
Method that completes the data of the measure.- Parameters:
inputMeasure- the new input measure
-
insertMeasure
protected Long insertMeasure(BOMeasure measure, PoolKit poolKit) throws DAValidateException, DAException Inserts the given measure.- Parameters:
measure- the measurepoolKit- thePoolKit- Returns:
- the id of the inserted
BOMeasure - Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
notifyInsert
protected void notifyInsert(BOMeasure measure, PoolKit poolKit) throws DAValidateException, DAException Notifies the insertion of a new measure.- Parameters:
measure- theBOMeasurepoolKit- thePoolKit- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
isValidExecution
public boolean isValidExecution()Description copied from interface:ValidExecutionDetermines whether the current state is valid for execution.- Returns:
- true if execution is valid, false otherwise
-