Using the DatabaseExporter API

These APIs are used to transfer data records from one table of the database into an output stream or a file stored on the server. These APIs also provide the option to export the document files stored in the afm_docs and afm_docvers tables and save them into specified server folders.

1.1. This DatabaseExporter API is designed to be used by other application level or core JAVA code.

Retrieves the records from the specifying table in the database and writes to an output stream.

public java.io.OutputStream exportData(java.lang.String tableName,
java.util.List<java.lang.String> fieldNames,
java.util.List<com.archibus.db.RestrictionSqlBase.Immutable> restrictions,
java.lang.String title,
com.archibus.ext.report.xls.XlsBuilder.FileFormatType format,
boolean exportDocuments
) throws com.archibus.utility.ExceptionBase

PARAMETERS:

tableName : String. The table name to export the records from.

If the table name is empty or it does not exist in Archibus schema, an exception will be thrown.

fieldNames : A list of field names to export. When the list is empty or NULL, all fields in the specifying table will be exported.

If one or more field names do not exist in Archibus schema, an exception will be thrown.

restrictions : A list of restrictions to limit the exporting records from the specifying table. Default to NULL, which means that all records from the specified table will be exported.

Specify the restrictions for the records to be exported.

For example:

List<RestrictionSqlBase.Immutable> restrictions = new
ArrayList<RestrictionSqlBase.Immutable>();
RestrictionParsedImpl rest = new RestrictionParsedImpl();
rest.addClause(TestTransferField.tableName, TestTransferField.acIdFieldName,
"PROPERTIES WW INC. - 001");
restrictions.add(rest);

The restriction should be applicable to the corresponding tableName , otherwise an exception will be thrown.

title : String. The title for the output Excel or CSV file.

format : The format of output stream, either Excel (.xls) or Text (.csv).

exportDocuments : Boolean.

True if you need to export the content of document fields into the designated server folder. False if otherwise. Defaults to FALSE.

1.2. This DatabaseExporter API is designed to be called by other workflow rules for basic Data Transfer action.

Retrieves the records from the specified table in the database and exports them to a file on the server.

public void exportData(java.lang.String filePath,
java.lang.String tableName,
java.util.List<java.lang.String> fieldNames,
java.util.List<com.archibus.db.RestrictionSqlBase.Immutable> restrictions,
java.lang.String title,
boolean exportDocuments) throws com.archibus.utility.ExceptionBase

PARAMETERS:

filePath : String.

Specify the file name that the output content will be saved to. If the file does not exist or the file extension is not .csv or .xls, an exception will be thrown.

tableName : String. Specify the table to export.

If the table name is empty or it does not exist in Archibus schema, an exception will be thrown.

fieldNames : A list of field names to export.

When the list is empty or NULL, all fields in the specifying table will be exported. If one or more field names do not exist in Archibus schema, an exception will be thrown.

restrictions : A list of restrictions to limit the exporting records from the specifying table. Defaults to NULL, which means that all records from the specified table will be exported.

Specify the restrictions for the records to be exported.

For example:

List<RestrictionSqlBase.Immutable> restrictions = new
ArrayList<RestrictionSqlBase.Immutable>();
RestrictionParsedImpl rest = new RestrictionParsedImpl();
rest.addClause(TestTransferField.tableName, TestTransferField.acIdFieldName,
"PROPERTIES WW INC. - 001");
restrictions.add(rest);

The restriction should be applicable to the corresponding tableName, otherwise an exception will be thrown.

title : String. The title for the output Excel or CSV file.

exportDocuments : Boolean.

True if you need to export the content of document fields into the designated server folder. false if otherwise. Defaults to false.

1.3. This function is used to set the protected fields in the output file so the values in the columns are read-only.

void setProtectedFields (java.util.List<java.lang.String> protectedFields)

PARAMETERS:

protectedFields : A list of protected field names.

1.4. This function is used to retrieve the number of records that have been exported.

long nRecordsExported()

PARAMETERS:

@return counter: long. The number of records exported.

1.5. This function is used to reset the number of records that have been exported.

long resetCounters()