public class AnnotationBatcher extends AbstractBatcher
Item
type.
setCurrentItem(Annotatable)
can
only be called once for a given item.
Annotatable.getAnnotationSet()
must not have been called on the item
before using it with this batcher.
setCurrentItem(Annotatable)
. It is not possible
to work with other annotations.
Annotation.Source.PRIMARY
annotations.
setValues(AnnotationType, List, Unit, boolean)
can only be called once
per item and annotation type.
Modifier and Type | Class and Description |
---|---|
static class |
AnnotationBatcher.Change
A flag indicating what type of change that was made to an
annotation as a result of calling
setValues(AnnotationType, List, Unit, boolean) |
static class |
AnnotationBatcher.CurrentAnnotationInfo
Holds information about an annotation for the current item.
|
(package private) static class |
AnnotationBatcher.InsertBatcher
Batcher implementation for inserting into tables.
|
(package private) static class |
AnnotationBatcher.UpdateBatcher
Batcher implementation for updating and deleting from tables.
|
debugSqlEnabled, logSql
Constructor and Description |
---|
AnnotationBatcher(DbControl dc,
Item itemType)
Create a new batcher instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addAnnotationTypes(Collection<AnnotationType> types)
Add annotation types to work with.
|
private AnnotationBatcher.InsertBatcher |
createInsertBatcher(Connection c,
String sql,
int... types) |
private AnnotationBatcher.UpdateBatcher |
createUpdateBatcher(Connection c,
String sql,
int... types) |
void |
flush()
Flush the batchers.
|
private UnitConverter |
getUnitConverter(Unit from,
Unit to)
Get/create a unit converter for converting between two units.
|
protected void |
onBeforeClose()
Let a subclass cleanup itself before the connection to
the database is closed.
|
void |
setCurrentItem(Annotatable item)
Set the current item to work with from now on.
|
AnnotationBatcher.Change |
setValue(AnnotationType annotationType,
Object value,
Unit unit,
boolean merge)
Add, update or delete a single-valued annotation.
|
AnnotationBatcher.Change |
setValues(AnnotationType annotationType,
List<?> values,
Unit unit,
boolean merge)
Add, update or delete annotation values for the current item.
|
analyzeTable, close, getBatchSize, getDbControl, getSessionControl, isClosed, setBatchSize, setDbControl, updateLastAccess
private static final org.slf4j.Logger log
private final boolean isDebugEnabled
private final Item itemType
private final int activeProjectId
private final Date batchDate
private final StatelessSession statelessSession
private final Dialect dialect
private final Cache secondLevelCache
private final LoggingInterceptor loggingInterceptor
private final int[] discriminators
private final Query loadAnnotationInfo
private final Query[] loadAnnotationValues
private final AnnotationBatcher.InsertBatcher insertIntoParameterValues
private final AnnotationBatcher.InsertBatcher insertIntoAnnotations
private final AnnotationBatcher.UpdateBatcher updateAnnotations
private final AnnotationBatcher.UpdateBatcher updateOverrideId
private final AnnotationBatcher.InsertBatcher insertIntoAnnotationSets
private final AnnotationBatcher.UpdateBatcher updateItemTable
private final List<AnnotationBatcher.UpdateBatcher> allUpdateBatchers
private final List<AnnotationBatcher.InsertBatcher> allInsertBatchers
private final AnnotationBatcher.UpdateBatcher deleteFromAnnotations
private final AnnotationBatcher.UpdateBatcher deleteFromParameterValues
private final AnnotationBatcher.UpdateBatcher nullifyClonedReferences
private final AnnotationBatcher.UpdateBatcher deleteInheritedAnnotations
private final AnnotationBatcher.UpdateBatcher[] deleteValues
private final AnnotationBatcher.UpdateBatcher[] insertValues
private int numItems
private Annotatable currentItem
private int currentAnnotationSetId
private boolean deleteSnapshotIfModifed
private boolean evictFromSecondLevelCacheIfModified
private Map<Integer,AnnotationBatcher.CurrentAnnotationInfo> currentInfo
private final Map<String,UnitConverter> unitConvertes
public void flush()
Batcher.close()
protected void onBeforeClose()
AbstractBatcher
AbstractBatcher.close()
method after Batcher.flush()
has been called but before the connection
to the database is lost. Typical use of this method is to update
properties on parent object (for example, spot count) and to close
open SQL statements.onBeforeClose
in class AbstractBatcher
private AnnotationBatcher.InsertBatcher createInsertBatcher(Connection c, String sql, int... types) throws SQLException
SQLException
private AnnotationBatcher.UpdateBatcher createUpdateBatcher(Connection c, String sql, int... types) throws SQLException
SQLException
private UnitConverter getUnitConverter(Unit from, Unit to)
public void addAnnotationTypes(Collection<AnnotationType> types)
setCurrentItem(Annotatable)
is called.
The annotation types must be enabled for use with the item type this batcher
is working with and the current user must have USE permission for all annotation
types.public void setCurrentItem(Annotatable item)
addAnnotationTypes(Collection)
must have specified the annotation
types to work with.
The item must not have been used with this method before and
the Annotatable.getAnnotationSet()
method must not have been
called on the item.
If the item can be used, the batcher will immediately load all existing
annotations and their values and prepare for adding, updating or removing
values.public AnnotationBatcher.Change setValue(AnnotationType annotationType, Object value, Unit unit, boolean merge)
setValues(AnnotationType, List, Unit, boolean)
for
more information.public AnnotationBatcher.Change setValues(AnnotationType annotationType, List<?> values, Unit unit, boolean merge)
annotationType
- The annotation type, which must be one of the annotation types
specified when creating the batchervalues
- The values to set or null/empty to remove valuesunit
- The unit of the values. Ignored if the annotation type doesn't use units.merge
- If TRUE and the annotation type allows an unlimted number
of annotations (multiplicity=0) merges the new values with the existing values.
Ignored if multiplicity > 0.