public class ReporterBatcher extends BasicBatcher<ReporterData>
Modifier and Type | Field and Description |
---|---|
private java.util.Set<java.lang.String> |
batchedExternalIds
A set containing all batched but not yet flushed
external reporter id:s.
|
private java.util.Date |
entryDate
Date to to give new reporters.
|
private java.util.List<ExtendedProperty> |
extendedProperties
The extended properties for reporters
|
private org.hibernate.query.Query<ReporterData> |
findReporter
A query to find reporters by the external id.
|
private java.lang.String |
updateSource
A string to hold the name of the source,
used to update the reporters.
|
debugEnabled, logParam
debugSqlEnabled, logSql
Constructor and Description |
---|
ReporterBatcher(DbControl dc) |
Modifier and Type | Method and Description |
---|---|
boolean |
exists(java.lang.String externalId,
boolean checkInsertQueue,
boolean checkDb)
Check if a reporter with a given external id exists in the database or
has been added to the batch queue of insertion.
|
void |
flushInsert()
Flush and clear the internal cache of external reporter id:s.
|
ReporterData |
getByExternalId(java.lang.String externalId)
Get a reporter when you know the external id.
|
ReporterData |
getByExternalId(java.lang.String externalId,
boolean errorIfNotFound)
Get a reporter when you know the external id.
|
static ReporterBatcher |
getNew(DbControl dc)
Create a new batcher for reporters.
|
Item |
getType()
Get the type of item supported by the batcher.
|
void |
insert(ReporterData data)
Insert and add the external reporter id to the internal cache.
|
boolean |
isInInsertQueue(java.lang.String externalId) |
(package private) void |
onBeforeCommit(ReporterData data,
Transactional.Action action)
Set the last update date to today's date and
change the last source of update.
|
void |
setUpdateSource(java.lang.String source)
Set the source that was used when updating the reporters.
|
void |
validate(ReporterData data)
Validate all properties for the reporter object:
The data object is not null
The name or external id is not null or too long
The description or symbol is not too long
All of the extendable properties using the
ExtendedProperty.validateValue(Object)
method
|
checkPermission, delete, delete, flush, flushDelete, flushUpdate, getPermissions, getPluginPermissions, getPropertyValue, getTotalInsertCount, hasPermission, initPermissions, onBeforeClose, setPropertyValue, update
analyzeTable, close, getBatchSize, getDbControl, getSessionControl, isClosed, setBatchSize, setDbControl, updateLastAccess
private java.lang.String updateSource
private final java.util.Date entryDate
private final java.util.List<ExtendedProperty> extendedProperties
ExtendedProperties
private final java.util.Set<java.lang.String> batchedExternalIds
private org.hibernate.query.Query<ReporterData> findReporter
ReporterBatcher(DbControl dc) throws BaseException
BaseException
public static ReporterBatcher getNew(DbControl dc) throws BaseException
dc
- The DbControl to use for database access and
permission checkingBaseException
- If there is an errorpublic Item getType()
BasicBatcher
Item
enumeration.getType
in class BasicBatcher<ReporterData>
Item
public void insert(ReporterData data) throws BaseException
insert
in class BasicBatcher<ReporterData>
data
- Data object to be insertedInvalidDataException
- If the data is null or it doesn't validate
against the BasicBatcher.validate(BatchableData)
methodPermissionDeniedException
- If the logged in user doesn't
have create permissionBaseException
- If there is another errorpublic void flushInsert() throws DatabaseException
flushInsert
in class BasicBatcher<ReporterData>
DatabaseException
public void validate(ReporterData data) throws InvalidDataException, InvalidUseOfNullException
ExtendedProperty.validateValue(Object)
method
validate
in class BasicBatcher<ReporterData>
data
- Data object to validateInvalidDataException
- If the data object is invalidInvalidUseOfNullException
void onBeforeCommit(ReporterData data, Transactional.Action action) throws BaseException
onBeforeCommit
in class BasicBatcher<ReporterData>
data
- Object to updateaction
- The actionBaseException
public boolean exists(java.lang.String externalId, boolean checkInsertQueue, boolean checkDb) throws BaseException
externalId
- The external id of the reportercheckInsertQueue
- If the insert queue should be checked or notcheckDb
- If the database should be checked or notBaseException
- If there is an errorpublic boolean isInInsertQueue(java.lang.String externalId)
public ReporterData getByExternalId(java.lang.String externalId) throws ItemNotFoundException, BaseException
exists(String, boolean, boolean)
method returns true, but this method throws an ItemNotFoundException
.externalId
- The external id of the reporterReporterData
objectItemNotFoundException
- If a reporter with the given id
isn't foundBaseException
- If there is another errorpublic ReporterData getByExternalId(java.lang.String externalId, boolean errorIfNotFound)
exists(String, boolean, boolean)
method returns true, but this method throws an ItemNotFoundException
.externalId
- The external id of the reportererrorIfNotFound
- If an ItemNotFoundException should be thrown if the
reporter isn't foundReporterData
object, or null if not foundItemNotFoundException
- If a reporter with the given id
isn't found and the errorIfNotFound parameter is trueBaseException
- If there is another errorpublic void setUpdateSource(java.lang.String source)
source
- The source to be set. The format of the source string
should be like: "[item_type]:[item_name]"StringTooLongException
- If the source is longer that
ReporterData.MAX_LAST_SOURCE_LENGTH