Package com.storedobject.iot
Class Site
java.lang.Object
com.storedobject.core.StoredObject
com.storedobject.iot.Site
- All Implemented Interfaces:
Displayable
,StringFiller
,HasId
Represents a Site entity that stores detailed information such as name, project affiliation,
time zone, unique code, and its associated attributes.
The Site entity provides methods for handling specific operations related to site management,
timezone handling, and data validation.
- Author:
- Syam
-
Field Summary
Fields inherited from class com.storedobject.core.StoredObject
logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Defines the columns for the Site entity by adding them to the specified `Columns` object.<D extends Date>
Ddate
(D dateGMT) Adjusts the provided date to the local time based on the ZoneId associated with this Site.<D extends Date>
DdateGMT
(D date) Adjusts the given date to Greenwich Mean Time (GMT) by applying the time zone offset of the site.static Site
Retrieves aSite
object based on the provided name.boolean
Retrieves the active status of the site.int
getCode()
Retrieves the unique site code of the Site.Retrieves the name of the image associated with the site.Retrieves the related MessageGroup instance for the current Site.Retrieves the unique identifier for the message group associated with this site.getName()
Retrieves the name of the site.Retrieves the project associated with the site.int
Calculates the time difference between the current date and time in the local time zone and the corresponding date and time in GMT.Retrieves the time zone associated with the site.Generates a unique condition string based on the value of the Name property of the object.static int
hints()
Provides hint value for the type of object, typically used to optimize processing or rendering by indicating the expected size or type of data represented.static void
Defines indices for the Site entity.static ObjectIterator
<Site> Lists all Site objects that match the specified name.Retrieves an iterator over all active blocks associated with this site.Retrieves an iterator over all blocks associated with this site.void
saved()
This method is triggered after the object is saved to the storage.void
setActive
(boolean active) Sets the active status for the site.void
setCode
(int code) Sets the unique code for the site.void
setImageName
(String imageName) Sets the image name for the site.void
setMessageGroup
(Id messageGroupId) Sets the message group identifier for this site.void
setMessageGroup
(MessageGroup messageGroup) Sets the message group associated with this site.void
setMessageGroup
(BigDecimal idValue) Sets the message group for the site using the provided BigDecimal identifier value.void
Sets the name for this instance.void
setProject
(String project) Sets the project associated with the Site instance.void
setTimeZone
(String timeZone) Sets the time zone for the site.Generates a display-friendly string representation of the object, combining the name and a truncated version of the project field, if necessary.toString()
Returns the string representation of the Site object, which is the value of its name field.void
Validates the data fields of the Site object before saving or processing.Methods inherited from class com.storedobject.core.StoredObject
addLink, addLink, addLink, addLink, addLink, addLink, addLink, addLink, checkCurrency, checkCurrency, checkForDuplicate, checkForDuplicate, checkTimeZone, checkTransaction, clearObjectLinks, contemporary, copy, copy, count, count, count, count, count, count, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, create, created, delete, delete, delete, deleted, directUpdate, equals, exists, exists, exists, exists, exists, existsFileData, existsLink, existsLink, existsLink, existsLink, existsLink, existsLink, existsLink, existsLink, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsMaster, existsMaster, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, family, family, family, fill, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, getAttachment, getAttachmentId, getChildren, getDeleted, getDeleted, getExistsCondition, getExistsCondition, getFileData, getFileData, getHistorical, getId, getKeyIndex, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getNotExistsCondition, getNotExistsCondition, getParent, getParent, getParent, getParentId, getParentId, getParentId, getRelated, getRelated, getTransaction, getTransactionId, getTransactionIP, getUnique, hashCode, inserted, isModified, isVirtual, list, list, list, list, list, list, list, list, list, list, list, list, list, listFileData, listFileData, listHistory, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listTree, listTree, listTree, listTree, listViaQuery, listViaQuery, load, load, load, load, loaded, loading, makeNew, makeVirtual, migrate, moduleName, nextVersion, objectLink, objectLink, objectLink, objectLinks, objectLinks, old, person, previousVersion, previousVersion, query, query, query, query, query, query, query, query, query, query, query, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, reload, reload, reloaded, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeReverseLinks, removeReverseLinks, save, save, save, save, save, save, save, save, save, save, save, save, save, save, saving, setMaster, setRawValue, setTransaction, stringify, tableName, timestamp, toCode, transacting, undelete, undelete, undeleted, updated, user, userId, validate, validateChildAttach, validateChildDetach, validateChildUpdate, validateDelete, validateInsert, validateParentAttach, validateParentDetach, validateParentUpdate, validateUndelete, validateUpdate, valueEquals
-
Constructor Details
-
Site
public Site()Constructs a new instance of the Site class. This constructor initializes a Site object with its default values. The Site class represents an entity with attributes such as name, project, timeZone, zoneId, code, and other related properties. An instance of the Site class can also interact with methods for managing its fields, utilizing unique identifiers, handling message groups, and defining specific behaviors upon actions such as saving or data validation. The Site class extends the StoredObject class, which provides a base for its persistence and associated operations.
-
-
Method Details
-
columns
Defines the columns for the Site entity by adding them to the specified `Columns` object.- Parameters:
columns
- The Columns object to which the column definitions are added.
-
indices
Defines indices for the Site entity. The indices are added with specified column names and configurations.- Parameters:
indices
- An object representing the collection of indices to be defined. The method adds two indices: one on the column "lower(Name)" and another composite index on the columns "Code" and "T_Family", both as unique.
-
getUniqueCondition
Generates a unique condition string based on the value of the Name property of the object. The condition is case-insensitive and trims unnecessary spaces, also escaping single quotes to ensure safe usage in database queries.- Overrides:
getUniqueCondition
in classStoredObject
- Returns:
- A unique condition string of the format "lower(Name)='value'", where 'value' is the sanitized and lower-cased representation of the Name property.
-
get
-
list
Lists all Site objects that match the specified name.- Parameters:
name
- the name of the Site to match- Returns:
- an iterator over Site objects matching the specified name
-
toString
Returns the string representation of the Site object, which is the value of its name field.- Overrides:
toString
in classStoredObject
- Returns:
- the name of the site as a string
-
hints
public static int hints()Provides hint value for the type of object, typically used to optimize processing or rendering by indicating the expected size or type of data represented.- Returns:
- An integer representing the hint, where the value corresponds to a predefined
hint constant, such as
ObjectHint.SMALL_LIST
.
-
setName
Sets the name for this instance.- Parameters:
name
- the name to set
-
getName
-
setProject
Sets the project associated with the Site instance.- Parameters:
project
- The name or identifier of the project to associate with the site.
-
getProject
-
getTimeZone
-
setTimeZone
Sets the time zone for the site.- Parameters:
timeZone
- the time zone to be set, represented as a string
-
setCode
public void setCode(int code) Sets the unique code for the site.- Parameters:
code
- The unique code to be assigned to the site.
-
getCode
-
setImageName
Sets the image name for the site.- Parameters:
imageName
- The name of the image to set.
-
getImageName
-
setActive
public void setActive(boolean active) Sets the active status for the site.- Parameters:
active
- A boolean value indicating whether the site is active (true) or inactive (false).
-
getActive
-
setMessageGroup
Sets the message group identifier for this site.- Parameters:
messageGroupId
- The identifier of the message group to be associated with the site.
-
setMessageGroup
Sets the message group for the site using the provided BigDecimal identifier value.- Parameters:
idValue
- The BigDecimal value representing the identifier of the message group to be set.
-
setMessageGroup
Sets the message group associated with this site.- Parameters:
messageGroup
- The message group to associate with the site. If null, the message group association will be removed.
-
getMessageGroupId
-
getMessageGroup
Retrieves the related MessageGroup instance for the current Site.- Returns:
- the associated MessageGroup object.
-
saved
This method is triggered after the object is saved to the storage. It ensures proper functionality by invoking the parent class's `saved()` method for maintaining standard behaviors and then schedules a refresh of associated datasets.- Overrides:
saved
in classStoredObject
- Throws:
Exception
- if any error occurs during the execution of the parent class's `saved()` method or while scheduling a dataset refresh.
-
validateData
Validates the data fields of the Site object before saving or processing.- Overrides:
validateData
in classStoredObject
- Parameters:
tm
- The TransactionManager instance used for performing validation and other related operations.- Throws:
Exception
- if any validation fails, such as an invalid time zone, missing required fields, or an invalid associated message group ID.
-
toDisplay
Generates a display-friendly string representation of the object, combining the name and a truncated version of the project field, if necessary. The project field is truncated to a maximum of 30 characters, appending "..." if truncation occurs.- Specified by:
toDisplay
in interfaceDisplayable
- Overrides:
toDisplay
in classStoredObject
- Returns:
- A string in the format "name (project)", where "project" may be truncated.
-
dateGMT
Adjusts the given date to Greenwich Mean Time (GMT) by applying the time zone offset of the site.- Type Parameters:
D
- The type of the Date object passed to the method.- Parameters:
date
- The date object that needs to be adjusted to GMT.- Returns:
- The date object adjusted to GMT.
-
date
Adjusts the provided date to the local time based on the ZoneId associated with this Site. The adjustment is made by adding the offset in milliseconds to the input date.- Type Parameters:
D
- the specific subclass of java.util.Date- Parameters:
dateGMT
- the date in GMT to be adjusted to the local time- Returns:
- the adjusted date object of the same type as the input
-
getTimeDifference
public int getTimeDifference()Calculates the time difference between the current date and time in the local time zone and the corresponding date and time in GMT.- Returns:
- the time difference, in milliseconds, between the local time and GMT.
-
listBlocks
Retrieves an iterator over all blocks associated with this site.- Returns:
- An ObjectIterator of Block representing all blocks associated with the site.
-
listActiveBlocks
Retrieves an iterator over all active blocks associated with this site.- Returns:
- An ObjectIterator containing all active Block objects linked to this site.
-