Using the DatabaseImporter API
Using the DatabaseImporter API
These APIs are used to import records into the database from an input stream or a file stored on the server. These APIs also provide the option to import the document files stored on the server folders into the afm_docs and afm_docvers tables. These APIs will also allow you to generate comparison reports, which will store records into the corresponding add, update, delete or error log files in Excel or CSV format.
Similar to DatabaseExporter APIs, there are also two types of DatabaseImporter APIs that serve different purposes.
Called by Project Update Wizard (PUW)
Imports data into the database given an input stream and its format.
public void importData(java.io.InputStream inputStream,
com.archibus.ext.report.xls.XlsBuilder.FileFormatType format,
boolean importDocuments,
java.lang.String docPath,
boolean generateLogs,
java.lang.String logPath,
boolean continueIfErrorExists
) throws com.archibus.utility.ExceptionBase
PARAMETERS:
inputStream : InputStream.
The input stream to read the content from.
format : Excel (XLS) or Text format (CSV) for input stream.
importDocuments : Boolean.
True if the related documents will be imported from the server, false otherwise.
docPath : String.
The root path where the importing documents can be found.
generateLogs : Boolean.
True if the comparison add, update and delete logs will be generated, false otherwise.
logPath : String.
The root path where the log files will be saved to.
continueIfErrorExists : Boolean.
True if we continue the importing process when there is any error, false if we throw an exception instead.
Called by other application level or core JAVA code
Imports data into the database given the import file name and path on the server.
public void importData(java.lang.String filePath,
boolean importDocuments,
java.lang.String docPath,
boolean generateLogs,
String logPath,
boolean continueIfErrorExists
) throws com.archibus.utility.ExceptionBase
PARAMETERS:
filePath : String.
Absolute file name and path of the importing file.
importDocuments : Boolean.
True if the related documents will be imported from the server, false otherwise.
docPath : String.
The root path where the importing documents can be found.
generateLogs : Boolean.
True if the comparison add, update and delete logs will be generated, false otherwise.
logPath : String.
The root path where the log files will be saved to.
continueIfErrorExists : Boolean.
True if we continue the importing process when there is any error, false if we throw an exception instead.
Retrieving the number of records that have been imported, including updated, inserted and records with errors
long nRecordsImported()
PARAMETERS:
@return counter: long. The number of records imported.
Retrieving the number of records that have been inserted into the database successfully during importing.
It is only used for a job that keeps the insert log on the server ('generateLogs' parameter is true)
long nRecordsInserted()
PARAMETERS:
@return counter: long. The number of records inserted into database.
Retrieving the number of records that have been updated successfully in the database during importing.
It is only used for a job that keeps the update log on the server ('generateLogs' parameter is true).
long nRecordsUpdated()
PARAMETERS:
@return counter: long. The number of records updated in the database.
Retrieving the number of records that have errors when importing.
long nRecordsWithErrors()
PARAMETERS:
@return counter: long. The number of records that have errors.
Resetting the number of records that have been inserted, updated or imported with errors.
long resetCounters()
;
Enabling/disabling the checking the primary keys, foreign keys and enumeration values
Enables and disables the checking the primary keys, foreign keys and enumeration values to the DatabaseImporter class.
The default value is true.
void setCheckKeysAndEnum (final boolean checkKeysAndEnum);
If user wants to skip validation of primary keys, foreign keys and enumeration value, they can use this API to disable the checking.
For example:
DatabaseImporter dtInManager =
(DatabaseImporter) ContextStore.get().getBean(
DatabaseImporterImpl.DATABASEIMPORTOR_BEAN);
dtInManager.setCheckKeysAndEnum(false);