Package org.intermine.dataconversion
Class DataConverter
- java.lang.Object
-
- org.intermine.dataconversion.DataConverter
-
- Direct Known Subclasses:
DBConverter
,DirectoryConverter
,FileConverter
,FullXmlConverter
public abstract class DataConverter extends java.lang.Object
Abstract parent class of all DataConverters- Author:
- Mark Woodbridge
-
-
Constructor Summary
Constructors Constructor Description DataConverter(ItemWriter writer, Model model)
Constructor that should be called by children
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addUniqueItemId(java.lang.String key, java.lang.String refId)
List of unique identifiers and their refIds.protected java.lang.String
alias(java.lang.String className)
Uniquely alias a classNamevoid
close()
Perform any necessary clean-up after processingItem
createItem(java.lang.String className)
Create item for the given class name.ItemWriter
getItemWriter()
Return the ItemWriter that was passed to the constructor.Model
getModel()
Return the data Model that was passed to the constructor.java.lang.String
getUniqueItemId(java.lang.String key)
List of unique identifiers and their refIds.protected java.lang.String
newId(java.lang.String className)
Generate an identifier for an item, assign ids sequentially with a different alias per class, e.g.void
setStoreHook(DataConverterStoreHook dataConverterStoreHook)
Set a hook for this converter that will be called just before each Item is stored.void
store(java.util.Collection<Item> c)
Store a Collection of XMl Itemsvoid
store(Attribute att, java.lang.Integer itemId)
Store a single XML Attributejava.lang.Integer
store(Item item)
Store a single XML Itemvoid
store(ReferenceList referenceList, java.lang.Integer itemId)
Store a single XML ReferenceListvoid
store(Reference reference, java.lang.Integer itemId)
Store a single XML Reference
-
-
-
Constructor Detail
-
DataConverter
public DataConverter(ItemWriter writer, Model model)
Constructor that should be called by children- Parameters:
writer
- an ItemWriter used to handle the resultant Itemsmodel
- the data model
-
-
Method Detail
-
getModel
public Model getModel()
Return the data Model that was passed to the constructor.- Returns:
- the Model
-
getItemWriter
public ItemWriter getItemWriter()
Return the ItemWriter that was passed to the constructor.- Returns:
- the ItemWriter
-
alias
protected java.lang.String alias(java.lang.String className)
Uniquely alias a className- Parameters:
className
- the class name- Returns:
- the alias
-
setStoreHook
public void setStoreHook(DataConverterStoreHook dataConverterStoreHook)
Set a hook for this converter that will be called just before each Item is stored. The processItem() method in DataConverterStoreHook will be passed the Item, which it can modify.- Parameters:
dataConverterStoreHook
- the hook
-
createItem
public Item createItem(java.lang.String className)
Create item for the given class name. Assign a sequential identifier with an alias set for the class, e.g. ClassA: 1_1, 1_2 ClassB: 2_1- Parameters:
className
- unqualified classname to create item for- Returns:
- a new item with an identifier but not fields
-
newId
protected java.lang.String newId(java.lang.String className)
Generate an identifier for an item, assign ids sequentially with a different alias per class, e.g. ClassA: 1_1, 1_2 ClassB: 2_1- Parameters:
className
- the class of the item- Returns:
- a new identifier with the next sequential id for the given class
-
store
public java.lang.Integer store(Item item) throws ObjectStoreException
Store a single XML Item- Parameters:
item
- the Item to store- Returns:
- the database id of the new Item
- Throws:
ObjectStoreException
- if an error occurs in storing
-
store
public void store(ReferenceList referenceList, java.lang.Integer itemId) throws ObjectStoreException
Store a single XML ReferenceList- Parameters:
referenceList
- the list to storeitemId
- the InterMine ID of the Item that holds this ReferenceList- Throws:
ObjectStoreException
- if an error occurs in storing
-
store
public void store(Attribute att, java.lang.Integer itemId) throws ObjectStoreException
Store a single XML Attribute- Parameters:
att
- the list to storeitemId
- the InterMine ID of the Item that holds this att- Throws:
ObjectStoreException
- if an error occurs in storing
-
store
public void store(Reference reference, java.lang.Integer itemId) throws ObjectStoreException
Store a single XML Reference- Parameters:
reference
- the Reference to storeitemId
- the InterMine ID of the Item that holds this Reference- Throws:
ObjectStoreException
- if an error occurs in storing
-
store
public void store(java.util.Collection<Item> c) throws ObjectStoreException
Store a Collection of XMl Items- Parameters:
c
- the Collection to store- Throws:
ObjectStoreException
- if an error occurs in storing
-
getUniqueItemId
public java.lang.String getUniqueItemId(java.lang.String key)
List of unique identifiers and their refIds. this is needed to keep the SOterms unique between the converter and the biostorehook.- Parameters:
key
- value of key field, eg. SO:001- Returns:
- ref id representing the unique object or NULL if this object isn't in map
-
addUniqueItemId
public void addUniqueItemId(java.lang.String key, java.lang.String refId)
List of unique identifiers and their refIds. this is needed to keep the SOterms unique between the converter and the biostorehook.- Parameters:
key
- value of key field, eg. SO:001refId
- id representing the unique Object
-
close
public void close() throws java.lang.Exception
Perform any necessary clean-up after processing- Throws:
java.lang.Exception
- if an error occurs
-
-