Package com.apgar.common.lib.rules
Class CommonRules
java.lang.Object
com.apgar.common.lib.rules.CommonRules
This class allows to define common rules of the project.
It includes methods commonly used in triggers and in the implementation of business rules. These include:
- Setting a record's meta data information
- Setting a field's time and date
- Getting the foreign key label for a record
- Getting a path relative to its root
- Author:
- APGAR Consulting
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanChecks whether the Active Indicator needs to be set.static StringgetFkLabel(Adaptation currRecord, Path currPath, Session session) Gets foreign key label from record and path.static PathgetRelativeParent(Path pathInAdaptation) Retrieves the relative parent path of the given path.static PathgetRelativePathToRoot(ValueContext pContext) Gets Relative Path To Root.static StringgetUserWithSalutation(Repository repository, UserReference userReference, Locale locale) Gets the user with the salutation.static booleanisActive(Adaptation record) Checks if Active Indicator is Active.static voidSets the Active Indicator field.static voidsetCurrentDateTime(ValueContextForUpdate pValue, Path pPath) Sets the date and current hour, minute, and seconds.static voidsetCurrentTime(ValueContextForUpdate pValue, Path pPath) Sets the date of the day.static DatesetMillisecondsToZero(Date date) Sets the milliseconds to zero for a given date.static DatesetTimeToZero(Date date) Sets the time to zero for a given date.static AdaptationsetTrackingMetaDataInformations(Adaptation record, ProcedureContext procedureContext, Session session, Path pathToParentSdlId, boolean isCreation) Allows setting the Meta Data Information in the Tracking tab depending on the type of flow.
-
Method Details
-
setTrackingMetaDataInformations
public static Adaptation setTrackingMetaDataInformations(Adaptation record, ProcedureContext procedureContext, Session session, Path pathToParentSdlId, boolean isCreation) throws OperationException Allows setting the Meta Data Information in the Tracking tab depending on the type of flow.- Parameters:
record- Record updatedprocedureContext- ProcedureContextsession- SessionpathToParentSdlId- PathisCreation- True if record is being created- Returns:
- Adaptation modified record
- Throws:
OperationException- Exception
-
getUserWithSalutation
public static String getUserWithSalutation(Repository repository, UserReference userReference, Locale locale) Gets the user with the salutation.- Parameters:
repository- RepositoryuserReference- UserReferencelocale- Locale- Returns:
- String User ID
-
setCurrentTime
Sets the date of the day.- Parameters:
pValue- ValueContextForUpdatepPath- Path the date will be set to
-
setCurrentDateTime
Sets the date and current hour, minute, and seconds.- Parameters:
pValue- ValueContextForUpdatepPath- Path the date will be set to
-
doesActiveIndicatorHaveToBeSet
Checks whether the Active Indicator needs to be set.- Parameters:
context- TriggerSetupContext- Returns:
- boolean True if field needs to be set
-
setActiveIndicator
Sets the Active Indicator field.- Parameters:
vcfu- ValueContextForUpdate of the record the indicator will be set for
-
setTimeToZero
Sets the time to zero for a given date.- Parameters:
date- Date where the time will be set to 0- Returns:
- Date modified date
-
setMillisecondsToZero
Sets the milliseconds to zero for a given date.- Parameters:
date- Date where the milliseconds will be set to 0- Returns:
- Date modified date
-
isActive
Checks if Active Indicator is Active.- Parameters:
record- Adaptation- Returns:
- true if Active Indicator is Active
-
getRelativePathToRoot
Gets Relative Path To Root.- Parameters:
pContext- ValueContext- Returns:
- Path the path relative to root
-
getRelativeParent
Retrieves the relative parent path of the given path. TODO: check it and check previous method for differences- Parameters:
pathInAdaptation- the path to determine the parent for.- Returns:
- the relative parent path.
-
getFkLabel
Gets foreign key label from record and path.- Parameters:
currRecord- Current RecordcurrPath- Current Pathsession- Session- Returns:
- String FK Label as a String
-