Package org.openbravo.dal.xml
Class BaseXMLEntityConverter
- java.lang.Object
-
- org.openbravo.dal.xml.BaseXMLEntityConverter
-
- All Implemented Interfaces:
OBNotSingleton
,OBProvidable
- Direct Known Subclasses:
StaxXMLEntityConverter
,XMLEntityConverter
public class BaseXMLEntityConverter extends Object implements OBNotSingleton
Contains logic and attributes which are common for both the Dom and Stax based converters implemented in the subclasses.- Author:
- mtaal
-
-
Constructor Summary
Constructors Constructor Description BaseXMLEntityConverter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addToInsertOrUpdateLists(String id, BaseOBObject bob, boolean writable, boolean updated, boolean hasReferenceAttribute, boolean preventRealUpdate)
protected void
checkClientOrganizationSet(BaseOBObject bob)
protected void
checkDanglingObjects()
Checks for objects which were not found in the database but are neither defined in the imported xml.protected void
clear()
protected void
error(String msg)
Client
getClient()
EntityResolver
getEntityResolver()
String
getErrorMessages()
The error messages logged during the import process.EntityXMLProcessor
getImportProcessor()
String
getLogMessages()
The standard log messages logged during the import process.Organization
getOrganization()
List<BaseOBObject>
getToInsert()
Returns the list of objects which should be inserted in the databaseList<BaseOBObject>
getToUpdate()
Returns the objects which exist in the database and will be updated.String
getWarningMessages()
The warning messages logged during the import process.protected boolean
hasErrorOccured()
boolean
isOptionClientImport()
Determines if this a client import.boolean
isOptionImportAuditInfo()
protected void
log(String msg)
static BaseXMLEntityConverter
newInstance()
protected void
repairReferences()
protected BaseOBObject
replaceByUniqueObject(BaseOBObject bob)
protected Object
replaceValue(BaseOBObject owner, Property property, Object newValue)
protected BaseOBObject
resolve(String entityName, String id, boolean reference)
protected BaseOBObject
resolve(String entityName, String id, boolean reference, boolean filterOrganizations)
void
setClient(Client client)
void
setEntityResolver(EntityResolver entityResolver)
void
setImportProcessor(EntityXMLProcessor importProcessor)
void
setOptionClientImport(boolean optionClientImport)
Determines if this a client import.void
setOptionImportAuditInfo(boolean optionImportAuditInfo)
void
setOrganization(Organization organization)
protected void
warn(String msg)
protected void
warnDifferentClientOrg(BaseOBObject bob, String prefix)
-
-
-
Method Detail
-
newInstance
public static BaseXMLEntityConverter newInstance()
-
clear
protected void clear()
-
addToInsertOrUpdateLists
protected void addToInsertOrUpdateLists(String id, BaseOBObject bob, boolean writable, boolean updated, boolean hasReferenceAttribute, boolean preventRealUpdate)
-
replaceByUniqueObject
protected BaseOBObject replaceByUniqueObject(BaseOBObject bob)
-
repairReferences
protected void repairReferences()
-
replaceValue
protected Object replaceValue(BaseOBObject owner, Property property, Object newValue)
-
checkClientOrganizationSet
protected void checkClientOrganizationSet(BaseOBObject bob)
-
warnDifferentClientOrg
protected void warnDifferentClientOrg(BaseOBObject bob, String prefix)
-
checkDanglingObjects
protected void checkDanglingObjects()
Checks for objects which were not found in the database but are neither defined in the imported xml. This is not allowed and can result in strange errors. If a dangling object is found then the error message is added to the list of error messages.
-
warn
protected void warn(String msg)
-
log
protected void log(String msg)
-
hasErrorOccured
protected boolean hasErrorOccured()
-
error
protected void error(String msg)
-
resolve
protected BaseOBObject resolve(String entityName, String id, boolean reference)
-
resolve
protected BaseOBObject resolve(String entityName, String id, boolean reference, boolean filterOrganizations)
-
getClient
public Client getClient()
-
setClient
public void setClient(Client client)
-
getOrganization
public Organization getOrganization()
-
setOrganization
public void setOrganization(Organization organization)
-
getToUpdate
public List<BaseOBObject> getToUpdate()
Returns the objects which exist in the database and will be updated.- Returns:
- list of objects which will be updated in the database.
-
getToInsert
public List<BaseOBObject> getToInsert()
Returns the list of objects which should be inserted in the database- Returns:
- the list of new BaseOBObjects which should be inserted in the database
-
getErrorMessages
public String getErrorMessages()
The error messages logged during the import process. If no error message exist then null is returned. If error messages exist then the user of this class should not update the database and do a rollback.- Returns:
- the logged error messages, null if no error messages are present
-
getWarningMessages
public String getWarningMessages()
The warning messages logged during the import process. Warning messages are non-failing messages. The database can be updated if there are warning messages. If no warning message exist then null is returned.- Returns:
- the logged warning messages, null if no warning messages are present
-
getLogMessages
public String getLogMessages()
The standard log messages logged during the import process. If no log message exist then null is returned.- Returns:
- the logged messages, null if no messages are present
-
getEntityResolver
public EntityResolver getEntityResolver()
- Returns:
- the EntityResolver used by this Converter.
-
isOptionClientImport
public boolean isOptionClientImport()
Determines if this a client import. A client import differs from a standard import because it is assumed that all Client/Organization level information is present in the xml and only System objects should be retrieved from the database.- Returns:
- the value of the client import option (default is false)
-
setOptionClientImport
public void setOptionClientImport(boolean optionClientImport)
Determines if this a client import. A client import differs from a standard import because it is assumed that all Client/Organization level information is present in the xml and only System objects should be retrieved from the database.- Parameters:
optionClientImport
- sets the value of the client import option (default is false)
-
getImportProcessor
public EntityXMLProcessor getImportProcessor()
-
setImportProcessor
public void setImportProcessor(EntityXMLProcessor importProcessor)
-
setEntityResolver
public void setEntityResolver(EntityResolver entityResolver)
-
isOptionImportAuditInfo
public boolean isOptionImportAuditInfo()
-
setOptionImportAuditInfo
public void setOptionImportAuditInfo(boolean optionImportAuditInfo)
-
-