2.17.2: 2011-06-17

net.sf.basedb.plugins.batchimport
Class PropertyIdMethod

java.lang.Object
  extended by net.sf.basedb.plugins.batchimport.PropertyIdMethod
All Implemented Interfaces:
IdMethod

public class PropertyIdMethod
extends Object
implements IdMethod

Identification method implementation that can use a single property (eg, name, id, externalId, etc.) for identifying items.

Version:
2.8
Author:
nicklas
Last modified
$Date: 2010-08-13 10:50:27 +0200 (Fri, 13 Aug 2010) $

Field Summary
static PropertyIdMethod BARCODE
          Use the barcode for finding items.
private  String columnMappingParameterName
           
static IdMethod[] DEFAULT_METHODS
          Deprecated. In 2.16, due to possible problems with circular class initialization with the FallbackIdMethod class. This array is now empty.
static PropertyIdMethod EXTERNAL_ID
          Use the external ID for finding items.
private  String method
           
static PropertyIdMethod NAME
          Use the name for finding items.
private  String property
           
private  String title
           
private  boolean unique
           
private  Type valueType
           
 
Constructor Summary
PropertyIdMethod(String method, String title, String property, String columnMappingParameterName, boolean unique, Type valueType)
          Create a new id method.
 
Method Summary
<I extends BasicItem>
List<I>
find(DbControl dc, ItemQuery<I> query, String identifier)
          Find all items with property = identifier.
 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 getProperty()
           
 String getTitle()
          The display title of the method.
 Type getValueType()
           
 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
 

Field Detail

NAME

public static final PropertyIdMethod NAME
Use the name for finding items.


EXTERNAL_ID

public static final PropertyIdMethod EXTERNAL_ID
Use the external ID for finding items.


BARCODE

public static final PropertyIdMethod BARCODE
Use the barcode for finding items.


DEFAULT_METHODS

@Deprecated
public static final IdMethod[] DEFAULT_METHODS
Deprecated. In 2.16, due to possible problems with circular class initialization with the FallbackIdMethod class. This array is now empty.

method

private final String method

property

private final String property

columnMappingParameterName

private final String columnMappingParameterName

title

private final String title

unique

private final boolean unique

valueType

private final Type valueType
Constructor Detail

PropertyIdMethod

public PropertyIdMethod(String method,
                        String title,
                        String property,
                        String columnMappingParameterName,
                        boolean unique,
                        Type valueType)
Create a new id method.

Parameters:
method - The method name, which should be unique among all methods
title - The title to use for display purposes
property - The name of the property to filter on when using this id method
unique - If this property is guaranteed to be unique or not
valueType - The type of values
Method Detail

getMethod

public String 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.

Specified by:
getMethod in interface IdMethod
Returns:
The method name

getTitle

public String getTitle()
Description copied from interface: IdMethod
The display title of the method.

Specified by:
getTitle in interface IdMethod

getColumnMappingParameterName

public String getColumnMappingParameterName()
Specified by:
getColumnMappingParameterName in interface IdMethod

isTrulyUnique

public boolean isTrulyUnique()
Description copied from interface: IdMethod
If the identification method is truly unique or not. If this method returns true, the IdMethod.find(DbControl, ItemQuery, String) method will never ever return a list with more than one item.

Specified by:
isTrulyUnique in interface IdMethod

prepareQuery

public <I extends BasicItem> ItemQuery<I> prepareQuery(DbControl dc,
                                                       ItemQuery<I> query)
Adds a restriction to the query: property = :identifier

Specified by:
prepareQuery in interface IdMethod
query - The query to prepare
Returns:
The query that is used for item lookup

find

public <I extends BasicItem> List<I> find(DbControl dc,
                                          ItemQuery<I> query,
                                          String identifier)
Find all items with property = identifier.

Specified by:
find in interface IdMethod
query - The query to use, which should have been prepared using IdMethod.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

public String toString()
Overrides:
toString in class Object

getProperty

public String getProperty()

getValueType

public Type getValueType()

2.17.2: 2011-06-17