Class AnnotationIdMethod
java.lang.Object
net.sf.basedb.plugins.batchimport.AnnotationIdMethod
- All Implemented Interfaces:
IdMethod
Identification method implementation that can use an annotation
for identifying items.
- Since:
- 3.15
- Author:
- nicklas
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionFind all items withproperty = identifier
.getIdMethods
(DbControl dc, Item itemType) Get identification methods that are based on annotations.The name of this method, which should be unique among the methods that can be used at a given time.getTitle()
The display title of the method.boolean
If the identification method is truly unique or not.prepareQuery
(DbControl dc, ItemQuery<I> query) Adds a restriction to the query:property = :identifier
<I extends BasicItem>
booleansetIdentifierOnNewItem
(DbControl dc, I item, String identifier) Set the annotation on a newly created item.toString()
-
Field Details
-
annotationType
-
-
Constructor Details
-
AnnotationIdMethod
Create a new id method.
-
-
Method Details
-
getIdMethods
Get identification methods that are based on annotations. It will make a query for all annotation types that are suitable as identifiers: The value type must be one of STRING, INT or LONG It must not be an enumeration The 'identifier' flag must be set- Parameters:
itemType
- Either a specified item or null to return all possible annotation id methods
-
getMethod
Description copied from interface:IdMethod
The name of this method, which should be unique among the methods that can be used at a given time. -
getTitle
Description copied from interface:IdMethod
The display title of the method. -
getColumnMappingParameterName
- Specified by:
getColumnMappingParameterName
in interfaceIdMethod
-
isTrulyUnique
public boolean isTrulyUnique()Description copied from interface:IdMethod
If the identification method is truly unique or not. If this method returns true, theIdMethod.find(DbControl, ItemQuery, String)
method will never ever return a list with more than one item.- Specified by:
isTrulyUnique
in interfaceIdMethod
-
prepareQuery
Adds a restriction to the query:property = :identifier
- Specified by:
prepareQuery
in interfaceIdMethod
query
- The query to prepare- Returns:
- The query that is used for item lookup
-
find
Find all items withproperty = identifier
.- Specified by:
find
in interfaceIdMethod
query
- The query to use, which should have been prepared usingIdMethod.prepareQuery(DbControl, ItemQuery)
identifier
- The identifier of the item- Returns:
- A list with the found items, if
IdMethod.isTrulyUnique()
return true the list is guaranteed to have at most one item
-
setIdentifierOnNewItem
public <I extends BasicItem> boolean setIdentifierOnNewItem(DbControl dc, I item, String identifier) Set the annotation on a newly created item.- Specified by:
setIdentifierOnNewItem
in interfaceIdMethod
- Returns:
- TRUE if the identifier was set, FALSE if not
-
toString
-