Class FallbackIdMethod
java.lang.Object
net.sf.basedb.plugins.batchimport.FallbackIdMethod
- All Implemented Interfaces:
IdMethod
public class FallbackIdMethod extends Object implements IdMethod
Identification method implementation that first tries a parent id
method, and, if no item is found and the identifier is a number,
tries to load the item by id.
- Version:
- 2.8
- Author:
- nicklas
- Last modified
- $Date: 2019-02-27 14:18:43 +0100 (ons, 27 feb. 2019) $
-
Field Summary
Fields Modifier and Type Field Description private String
method
static FallbackIdMethod
NAME_OR_BARCODE_OR_ID
static FallbackIdMethod
NAME_OR_EXTERNALID_OR_ID
static FallbackIdMethod
NAME_OR_ID
Use the name for finding items.static FallbackIdMethod
NAME_OR_SYSTEMID_OR_ID
Use the name or system ID for finding items.static FallbackIdMethod
NAME_OR_UNITSYMBOL_OR_ID
ID method that can be used for units.private IdMethod
parent
private String
title
-
Constructor Summary
Constructors Constructor Description FallbackIdMethod(String method, String title, IdMethod parent)
Create a new id method. -
Method Summary
Modifier and Type Method Description <I extends BasicItem>
List<I>find(DbControl dc, ItemQuery<I> query, String identifier)
First, find items using the parent id method.String
getColumnMappingParameterName()
String
getMethod()
The name of this method, which should be unique among the methods that can be used at a given time.String
getTitle()
The display title of the method.boolean
isTrulyUnique()
If the identification method is truly unique or not.<I extends BasicItem>
ItemQuery<I>prepareQuery(DbControl dc, ItemQuery<I> query)
Adds a restriction to the query:property = :identifier
String
toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.sf.basedb.plugins.batchimport.IdMethod
setIdentifierOnNewItem
-
Field Details
-
NAME_OR_ID
Use the name for finding items. If no item is found and the identifier is numerical, try loading it by ID. -
NAME_OR_EXTERNALID_OR_ID
-
NAME_OR_BARCODE_OR_ID
-
NAME_OR_SYSTEMID_OR_ID
Use the name or system ID for finding items. If no item is found and the identifier is numerical, try loading it by ID.- Since:
- 3.0
-
NAME_OR_UNITSYMBOL_OR_ID
ID method that can be used for units. Use the name or unit symbol for finding items. If no item is found and the identifier is numerical, try loading it by ID.- Since:
- 3.8
-
method
-
title
-
parent
-
-
Constructor Details
-
FallbackIdMethod
Create a new id method.- Parameters:
method
- The method name, which should be unique among all methodstitle
- The title to use for display purposesparent
- The parent id method, which will be tried first
-
-
Method Details
-
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. -
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
-
getColumnMappingParameterName
- Specified by:
getColumnMappingParameterName
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
First, find items using the parent id method. If no items is found with this, try to convert the identifier to a number and usegetById()
to load the item.- 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
-
toString
-