Commit 2af011e1 by Nilu

Email fetcher for email ingest

parent d705595f
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">tl_attachment</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="attachment_name" type="String" nullable="true" length="100"/>
<column name="attachment_file" type="BLOB" nullable="true"/>
<column name="email_message_id" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_attachment" indexName="idx_tl_attachment_email_message_id" isUnique="false"><column name="email_message_id"/></NODE>
</NODE></OBJECTS>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">tl_email_message</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="message_id" type="String" nullable="true" length="1000"/>
<column name="email_from" type="String" nullable="false" length="500"/>
<column name="email_to" type="String" nullable="false" length="500"/>
<column name="email_cc" type="String" nullable="true" length="500"/>
<column name="subject" type="String" nullable="true" length="1000"/>
<column name="description" type="CLOB" nullable="true"/>
<column name="received_date" type="Date" nullable="false"/>
<column name="job_id" type="Long" length="11" nullable="true"/>
</NODE>
</NODE></OBJECTS>
\ No newline at end of file
-- DROP TABLE tl_attachment;
CREATE TABLE tl_attachment (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
attachment_name varchar(100) NULL,
attachment_file image NULL,
email_message_id numeric(12) NULL
);
ALTER TABLE tl_attachment ADD
CONSTRAINT PK_tl_attachment PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_attachment_email_message_id
ON tl_attachment (email_message_id);
-- DROP TABLE tl_email_message;
CREATE TABLE tl_email_message (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
message_id varchar(1000) NULL,
email_from varchar(500) NOT NULL,
email_to varchar(500) NOT NULL,
email_cc varchar(500) NULL,
subject varchar(1000) NULL,
description text NULL,
received_date datetime NOT NULL,
job_id numeric(12) NULL
);
ALTER TABLE tl_email_message ADD
CONSTRAINT PK_tl_email_message PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- DROP TABLE tl_attachment;
CREATE TABLE tl_attachment (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
attachment_name varchar2(100) NULL,
attachment_file blob NULL,
email_message_id number(12) NULL
);
ALTER TABLE tl_attachment ADD
CONSTRAINT PK_tl_attachment PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_attachment_email_message_id
ON tl_attachment (email_message_id);
-- DROP TABLE tl_email_message;
CREATE TABLE tl_email_message (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
message_id varchar2(1000) NULL,
email_from varchar2(500) NOT NULL,
email_to varchar2(500) NOT NULL,
email_cc varchar2(500) NULL,
subject varchar2(1000) NULL,
description clob NULL,
received_date date NOT NULL,
job_id number(12) NULL
);
ALTER TABLE tl_email_message ADD
CONSTRAINT PK_tl_email_message PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- @AutoRun
-- drop table tl_attachment;
CREATE TABLE tl_attachment (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
attachment_name varchar(100) NULL,
attachment_file bytea NULL,
email_message_id numeric(12) NULL
);
ALTER TABLE tl_attachment ADD
CONSTRAINT pk_tl_attachment PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_attachment_email_message_id
ON tl_attachment (email_message_id);
-- @AutoRun
-- drop table tl_email_message;
CREATE TABLE tl_email_message (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
message_id varchar(1000) NULL,
email_from varchar(500) NOT NULL,
email_to varchar(500) NOT NULL,
email_cc varchar(500) NULL,
subject varchar(1000) NULL,
description text NULL,
received_date timestamp NOT NULL,
job_id numeric(12) NULL
);
ALTER TABLE tl_email_message ADD
CONSTRAINT pk_tl_email_message PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
package performa.form;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import oneit.logging.LogLevel;
import oneit.logging.LogMgr;
import oneit.objstore.ObjectTransaction;
import oneit.objstore.StorageException;
import oneit.servlets.forms.RedisplayResult;
import oneit.servlets.forms.SubmissionDetails;
import oneit.servlets.forms.SuccessfulResult;
import oneit.servlets.objstore.ORMFormProcessor;
import oneit.utils.BusinessException;
import performa.utils.PerformaEmailFetcher;
public class RunEmailFetcherFP extends ORMFormProcessor
{
@Override
public SuccessfulResult processForm(ObjectTransaction objTran, SubmissionDetails submission, Map params) throws BusinessException, StorageException
{
LogMgr.log(PerformaEmailFetcher.LOG, LogLevel.PROCESSING1, "RunEmailFetcherFP called");
List<String> visitedNodes = new ArrayList<>();
PerformaEmailFetcher.runEmailFetcher(visitedNodes);
submission.getRequest().setAttribute("VisitedNodes", visitedNodes);
return RedisplayResult.getInstance();
}
}
\ No newline at end of file
package performa.orm;
public class Attachment extends BaseAttachment
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public Attachment ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.oneit.com.au/schemas/5.2/BusinessObject.xsd'>
<BUSINESSCLASS name="Attachment" package="performa.orm">
<TABLE name="tl_attachment" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="AttachmentName" type="String" dbcol="attachment_name" length="100" />
<ATTRIB name="AttachmentFile" type="BinaryContent" dbcol="attachment_file" attribHelper="BLOBAttributeHelper" attribHelperInstance="BLOBAttributeHelper.INSTANCE" binaryHandler="loggedin"/>
<SINGLEREFERENCE name="EmailMessage" type="EmailMessage" dbcol="email_message_id" backreferenceName="Attachments"/>
</TABLE>
</BUSINESSCLASS>
</ROOT>
\ No newline at end of file
package performa.orm;
import java.io.*;
import java.util.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.rdbms.*;
import oneit.objstore.utils.*;
import oneit.sql.*;
import oneit.utils.resource.*;
import oneit.utils.*;
import oneit.utils.threading.*;
/**
* IMPORTANT!!!! Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2[oneit.objstore.PersistenceMgrTemplate.xsl]
*/
public class AttachmentPersistenceMgr extends ObjectPersistenceMgr
{
private static final LoggingArea AttachmentPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "Attachment");
// Private attributes corresponding to business object data
private String dummyAttachmentName;
private BinaryContent dummyAttachmentFile;
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_AttachmentName = DefaultAttributeHelper.INSTANCE;
private static final BLOBAttributeHelper HELPER_AttachmentFile = BLOBAttributeHelper.INSTANCE;
public AttachmentPersistenceMgr ()
{
dummyAttachmentName = (String)(HELPER_AttachmentName.initialise (dummyAttachmentName));
dummyAttachmentFile = (BinaryContent)(HELPER_AttachmentFile.initialise (dummyAttachmentFile));
}
private String SELECT_COLUMNS = "{PREFIX}tl_attachment.object_id as id, {PREFIX}tl_attachment.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_attachment.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_attachment.attachment_name, {PREFIX}tl_attachment.attachment_file, {PREFIX}tl_attachment.email_message_id, 1 AS commasafe ";
private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
Set<BaseBusinessClass> resultByIDs = fetchByIDs(Collections.singleton (id), allPSets, context, sqlMgr);
if (resultByIDs.isEmpty ())
{
return null;
}
else if (resultByIDs.size () > 1)
{
throw new StorageException ("Multiple results for id:" + id);
}
else
{
return resultByIDs.iterator ().next ();
}
}
public Set<BaseBusinessClass> fetchByIDs(Set<ObjectID> ids, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
Set<BaseBusinessClass> results = new HashSet ();
Set<Long> idsToFetch = new HashSet ();
for (ObjectID id : ids)
{
if (context.containsObject(id)) // Check for cached version
{
BaseBusinessClass objectToReturn = context.getObjectToReplace(id, Attachment.REFERENCE_Attachment);
if (objectToReturn instanceof Attachment)
{
LogMgr.log (AttachmentPersistence, LogLevel.TRACE, "Cache hit for id:", id);
results.add (objectToReturn);
}
else
{
throw new StorageException ("Cache collision for id:" + id + " with object " + objectToReturn + "while fetching a Attachment");
}
}
PersistentSet tl_attachmentPSet = allPSets.getPersistentSet(id, "tl_attachment", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched
if (false || !tl_attachmentPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!tl_attachmentPSet.containsAttrib(Attachment.FIELD_AttachmentName)||
!tl_attachmentPSet.containsAttrib(Attachment.FIELD_AttachmentFile)||
!tl_attachmentPSet.containsAttrib(Attachment.SINGLEREFERENCE_EmailMessage))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (AttachmentPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Non Polymorphic */
Attachment result = new Attachment ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_attachment " +
"WHERE " + SELECT_JOINS + "{PREFIX}tl_attachment.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
for (BaseBusinessClass objFetched : resultsFetched)
{
results.add (objFetched);
}
}
return results;
}
public BaseBusinessClass[] getReferencedObjects(ObjectID _objectID, String refName, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
if (false)
{
throw new RuntimeException ();
}
else if (refName.equals (Attachment.SINGLEREFERENCE_EmailMessage))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_attachment " +
"WHERE " + SELECT_JOINS + "email_message_id = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results;
}
else
{
throw new IllegalArgumentException ("Illegal reference type:" + refName);
}
}
public void update(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{
EqualityResult test = EqualityResult.compare (obj, obj.getBackup ());
ObjectID objectID = obj.getID ();
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{
PersistentSet tl_attachmentPSet = allPSets.getPersistentSet(objectID, "tl_attachment");
if (tl_attachmentPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_attachmentPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_attachment " +
"SET attachment_name = ?, attachment_file = ?, email_message_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_attachment.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_AttachmentName.getForSQL(dummyAttachmentName, tl_attachmentPSet.getAttrib (Attachment.FIELD_AttachmentName))).listEntry (HELPER_AttachmentFile.getForSQL(dummyAttachmentFile, tl_attachmentPSet.getAttrib (Attachment.FIELD_AttachmentFile))).listEntry (SQLManager.CheckNull((Long)(tl_attachmentPSet.getAttrib (Attachment.SINGLEREFERENCE_EmailMessage)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1)
{
// Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr,
"SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}tl_attachment WHERE object_id = ?",
new Object[] { objectID.longID () });
if (r.next ())
{
Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "tl_attachment", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (AttachmentPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "tl_attachment");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:tl_attachment for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (AttachmentPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_attachmentPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (AttachmentPersistence, LogLevel.DEBUG1, "Skipping update since no attribs or simple assocs changed on ", objectID);
}
}
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet tl_attachmentPSet = allPSets.getPersistentSet(objectID, "tl_attachment");
LogMgr.log (AttachmentPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (tl_attachmentPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_attachmentPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}tl_attachment " +
"WHERE tl_attachment.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1)
{
// Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}tl_attachment WHERE object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "tl_attachment");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:tl_attachment for row:" + objectID;
LogMgr.log (AttachmentPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_attachmentPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
public BaseBusinessClass[] loadQuery (PersistentSetCollection allPSets, SQLManager sqlMgr, RDBMSPersistenceContext context, String query, Object[] params, Integer maxRows, boolean truncateExtra) throws SQLException, StorageException
{
LinkedHashMap<ObjectID, Attachment> results = new LinkedHashMap ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (Attachment.REFERENCE_Attachment.getObjectIDSpace (), r.getLong ("id"));
Attachment resultElement;
if (maxRows != null && !results.containsKey (objectID) && results.size () >= maxRows)
{
if (truncateExtra)
{
break;
}
else
{
throw new SearchRowsExceededException ("Maximum rows exceeded:" + maxRows);
}
}
if (context.containsObject(objectID))
{
BaseBusinessClass cachedElement = context.getObjectToReplace(objectID, Attachment.REFERENCE_Attachment);
if (cachedElement instanceof Attachment)
{
LogMgr.log (AttachmentPersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (Attachment)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a Attachment");
}
}
else
{
PersistentSet tl_attachmentPSet = allPSets.getPersistentSet(objectID, "tl_attachment", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
resultElement = new Attachment ();
resultElement.setFromPersistentSets(objectID, allPSets);
context.addRetrievedObject(resultElement);
}
results.put (objectID, resultElement);
}
BaseBusinessClass[] resultsArr = new BaseBusinessClass[results.size ()];
return results.values ().toArray (resultsArr);
}
public BaseBusinessClass[] find(String searchType, PersistentSetCollection allPSets, Hashtable criteria, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
LogMgr.log (AttachmentPersistence, LogLevel.DEBUG2, "Search executing:", searchType, " criteria:", criteria);
String customParamFilter = (String)criteria.get (SEARCH_CustomFilter);
String customOrderBy = (String)criteria.get (SEARCH_OrderBy);
String customTables = (String)criteria.get (SEARCH_CustomExtraTables);
Boolean noCommaBeforeCustomExtraTables = (Boolean)criteria.get (SEARCH_CustomExtraTablesNoComma);
if (searchType.equals (SEARCH_CustomSQL))
{
Set<ObjectID> processedIDs = new HashSet();
SearchParamTransform tx = new SearchParamTransform (criteria);
Object[] searchParams;
customParamFilter = StringUtils.replaceParams (customParamFilter, tx);
searchParams = tx.getParamsArray();
if (customOrderBy != null)
{
customOrderBy = " ORDER BY " + customOrderBy;
}
else
{
customOrderBy = "";
}
ResultSet r;
String concatCustomTableWith = CollectionUtils.equals(noCommaBeforeCustomExtraTables, true) ? " " : ", ";
String tables = StringUtils.subBlanks(customTables) == null ? " " : concatCustomTableWith + customTables + " ";
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_attachment " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else
{
throw new IllegalArgumentException ("Illegal search type:" + searchType);
}
}
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{
PersistentSet tl_attachmentPSet = allPSets.getPersistentSet(objectID, "tl_attachment", PersistentSetStatus.FETCHED);
// Object Modified
tl_attachmentPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
tl_attachmentPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
tl_attachmentPSet.setAttrib(Attachment.FIELD_AttachmentName, HELPER_AttachmentName.getFromRS(dummyAttachmentName, r, "attachment_name"));
tl_attachmentPSet.setAttrib(Attachment.FIELD_AttachmentFile, HELPER_AttachmentFile.getFromRS(dummyAttachmentFile, r, "attachment_file"));
tl_attachmentPSet.setAttrib(Attachment.SINGLEREFERENCE_EmailMessage, r.getObject ("email_message_id"));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet tl_attachmentPSet = allPSets.getPersistentSet(objectID, "tl_attachment");
if (tl_attachmentPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_attachmentPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_attachment " +
" (attachment_name, attachment_file, email_message_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" (?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_AttachmentName.getForSQL(dummyAttachmentName, tl_attachmentPSet.getAttrib (Attachment.FIELD_AttachmentName))).listEntry (HELPER_AttachmentFile.getForSQL(dummyAttachmentFile, tl_attachmentPSet.getAttrib (Attachment.FIELD_AttachmentFile))) .listEntry (SQLManager.CheckNull((Long)(tl_attachmentPSet.getAttrib (Attachment.SINGLEREFERENCE_EmailMessage)))) .listEntry (objectID.longID ()).toList().toArray());
tl_attachmentPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
/*
* IMPORTANT!!!! XSL Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2 rev3 [oneit.objstore.BusinessObjectTemplate.xsl]
*
* Version: 1.0
* Vendor: Apache Software Foundation (Xalan XSLTC)
* Vendor URL: http://xml.apache.org/xalan-j
*/
package performa.orm;
import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.attributes.*;
import oneit.objstore.rdbms.filters.*;
import oneit.objstore.parser.*;
import oneit.objstore.validator.*;
import oneit.objstore.utils.*;
import oneit.utils.*;
import oneit.utils.filter.Filter;
import oneit.utils.transform.*;
import oneit.utils.parsers.FieldException;
public abstract class BaseAttachment extends BaseBusinessClass
{
// Reference instance for the object
public static final Attachment REFERENCE_Attachment = new Attachment ();
// Reference instance for the object
public static final Attachment DUMMY_Attachment = new DummyAttachment ();
// Static constants corresponding to field names
public static final String FIELD_AttachmentName = "AttachmentName";
public static final String FIELD_AttachmentFile = "AttachmentFile";
public static final String SINGLEREFERENCE_EmailMessage = "EmailMessage";
public static final String BACKREF_EmailMessage = "";
// Static constants corresponding to searches
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<Attachment> HELPER_AttachmentName = DefaultAttributeHelper.INSTANCE;
private static final BLOBAttributeHelper HELPER_AttachmentFile = BLOBAttributeHelper.INSTANCE;
// Private attributes corresponding to business object data
private String _AttachmentName;
private BinaryContent _AttachmentFile;
// Private attributes corresponding to single references
private SingleAssociation<Attachment, EmailMessage> _EmailMessage;
// Private attributes corresponding to multiple references
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_Attachment = new HashMap ();
// Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_AttachmentName_Validators;
private static final AttributeValidator[] FIELD_AttachmentFile_Validators;
// Arrays of behaviour decorators
private static final AttachmentBehaviourDecorator[] Attachment_BehaviourDecorators;
static
{
try
{
String tmp_EmailMessage = EmailMessage.BACKREF_Attachments;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_EmailMessage();
FIELD_AttachmentName_Validators = (AttributeValidator[])setupAttribMetaData_AttachmentName(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_AttachmentFile_Validators = (AttributeValidator[])setupAttribMetaData_AttachmentFile(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_Attachment.initialiseReference ();
DUMMY_Attachment.initialiseReference ();
Attachment_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(Attachment.class).toArray(new AttachmentBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
throw e;
}
}
// Meta Info setup
private static void setupAssocMetaData_EmailMessage()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Attachments");
metaInfo.put ("dbcol", "email_message_id");
metaInfo.put ("name", "EmailMessage");
metaInfo.put ("type", "EmailMessage");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Attachment.EmailMessage:", metaInfo);
ATTRIBUTES_METADATA_Attachment.put (SINGLEREFERENCE_EmailMessage, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_AttachmentName(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "attachment_name");
metaInfo.put ("length", "100");
metaInfo.put ("name", "AttachmentName");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Attachment.AttachmentName:", metaInfo);
ATTRIBUTES_METADATA_Attachment.put (FIELD_AttachmentName, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Attachment.class, "AttachmentName", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Attachment.AttachmentName:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_AttachmentFile(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("attribHelper", "BLOBAttributeHelper");
metaInfo.put ("attribHelperInstance", "BLOBAttributeHelper.INSTANCE");
metaInfo.put ("binaryHandler", "loggedin");
metaInfo.put ("dbcol", "attachment_file");
metaInfo.put ("name", "AttachmentFile");
metaInfo.put ("type", "BinaryContent");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Attachment.AttachmentFile:", metaInfo);
ATTRIBUTES_METADATA_Attachment.put (FIELD_AttachmentFile, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Attachment.class, "AttachmentFile", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Attachment.AttachmentFile:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION
// This constructor should not be called
protected BaseAttachment ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return Attachment_BehaviourDecorators;
}
// Initialise the attributes
protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
{
super._initialiseNewObjAttributes (transaction);
_AttachmentName = (String)(HELPER_AttachmentName.initialise (_AttachmentName));
_AttachmentFile = (BinaryContent)(HELPER_AttachmentFile.initialise (_AttachmentFile));
}
// Initialise the associations
protected void _initialiseAssociations ()
{
super._initialiseAssociations ();
_EmailMessage = new SingleAssociation<Attachment, EmailMessage> (this, SINGLEREFERENCE_EmailMessage, EmailMessage.MULTIPLEREFERENCE_Attachments, EmailMessage.REFERENCE_EmailMessage, "tl_attachment");
}
// Initialise the associations
protected BaseBusinessClass initialiseReference ()
{
super.initialiseReference ();
_EmailMessage = new SingleAssociation<Attachment, EmailMessage> (this, SINGLEREFERENCE_EmailMessage, EmailMessage.MULTIPLEREFERENCE_Attachments, EmailMessage.REFERENCE_EmailMessage, "tl_attachment");
return this;
}
/**
* Get the attribute AttachmentName
*/
public String getAttachmentName ()
{
assertValid();
String valToReturn = _AttachmentName;
for (AttachmentBehaviourDecorator bhd : Attachment_BehaviourDecorators)
{
valToReturn = bhd.getAttachmentName ((Attachment)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preAttachmentNameChange (String newAttachmentName) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postAttachmentNameChange () throws FieldException
{
}
public FieldWriteability getWriteability_AttachmentName ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute AttachmentName. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setAttachmentName (String newAttachmentName) throws FieldException
{
boolean oldAndNewIdentical = HELPER_AttachmentName.compare (_AttachmentName, newAttachmentName);
try
{
for (AttachmentBehaviourDecorator bhd : Attachment_BehaviourDecorators)
{
newAttachmentName = bhd.setAttachmentName ((Attachment)this, newAttachmentName);
oldAndNewIdentical = HELPER_AttachmentName.compare (_AttachmentName, newAttachmentName);
}
if (FIELD_AttachmentName_Validators.length > 0)
{
Object newAttachmentNameObj = HELPER_AttachmentName.toObject (newAttachmentName);
if (newAttachmentNameObj != null)
{
int loopMax = FIELD_AttachmentName_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Attachment.get (FIELD_AttachmentName);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_AttachmentName_Validators[v].checkAttribute (this, FIELD_AttachmentName, metadata, newAttachmentNameObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_AttachmentName () != FieldWriteability.FALSE, "Field AttachmentName is not writeable");
preAttachmentNameChange (newAttachmentName);
markFieldChange (FIELD_AttachmentName);
_AttachmentName = newAttachmentName;
postFieldChange (FIELD_AttachmentName);
postAttachmentNameChange ();
}
}
/**
* Get the attribute AttachmentFile
*/
public BinaryContent getAttachmentFile ()
{
assertValid();
BinaryContent valToReturn = _AttachmentFile;
for (AttachmentBehaviourDecorator bhd : Attachment_BehaviourDecorators)
{
valToReturn = bhd.getAttachmentFile ((Attachment)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preAttachmentFileChange (BinaryContent newAttachmentFile) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postAttachmentFileChange () throws FieldException
{
}
public FieldWriteability getWriteability_AttachmentFile ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute AttachmentFile. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setAttachmentFile (BinaryContent newAttachmentFile) throws FieldException
{
boolean oldAndNewIdentical = HELPER_AttachmentFile.compare (_AttachmentFile, newAttachmentFile);
try
{
for (AttachmentBehaviourDecorator bhd : Attachment_BehaviourDecorators)
{
newAttachmentFile = bhd.setAttachmentFile ((Attachment)this, newAttachmentFile);
oldAndNewIdentical = HELPER_AttachmentFile.compare (_AttachmentFile, newAttachmentFile);
}
if (FIELD_AttachmentFile_Validators.length > 0)
{
Object newAttachmentFileObj = HELPER_AttachmentFile.toObject (newAttachmentFile);
if (newAttachmentFileObj != null)
{
int loopMax = FIELD_AttachmentFile_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Attachment.get (FIELD_AttachmentFile);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_AttachmentFile_Validators[v].checkAttribute (this, FIELD_AttachmentFile, metadata, newAttachmentFileObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_AttachmentFile () != FieldWriteability.FALSE, "Field AttachmentFile is not writeable");
preAttachmentFileChange (newAttachmentFile);
markFieldChange (FIELD_AttachmentFile);
_AttachmentFile = newAttachmentFile;
postFieldChange (FIELD_AttachmentFile);
postAttachmentFileChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getSingleAssocs()
{
List result = super.getSingleAssocs ();
result.add("EmailMessage");
return result;
}
public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_EmailMessage))
{
return _EmailMessage.getReferencedType ();
}
else
{
return super.getSingleAssocReferenceInstance (assocName);
}
}
public String getSingleAssocBackReference(String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_EmailMessage))
{
return EmailMessage.MULTIPLEREFERENCE_Attachments ;
}
else
{
return super.getSingleAssocBackReference (assocName);
}
}
public BaseBusinessClass getSingleAssoc (String assocName) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_EmailMessage))
{
return getEmailMessage ();
}
else
{
return super.getSingleAssoc (assocName);
}
}
public BaseBusinessClass getSingleAssoc (String assocName, Get getType) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_EmailMessage))
{
return getEmailMessage (getType);
}
else
{
return super.getSingleAssoc (assocName, getType);
}
}
public Long getSingleAssocID (String assocName) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_EmailMessage))
{
return getEmailMessageID ();
}
else
{
return super.getSingleAssocID (assocName);
}
}
public void setSingleAssoc (String assocName, BaseBusinessClass newValue) throws StorageException, FieldException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_EmailMessage))
{
setEmailMessage ((EmailMessage)(newValue));
}
else
{
super.setSingleAssoc (assocName, newValue);
}
}
/**
* Get the reference EmailMessage
*/
public EmailMessage getEmailMessage () throws StorageException
{
assertValid();
try
{
return (EmailMessage)(_EmailMessage.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in Attachment:", this.getObjectID (), ", was trying to get EmailMessage:", getEmailMessageID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _EmailMessage.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public EmailMessage getEmailMessage (Get getType) throws StorageException
{
assertValid();
return _EmailMessage.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getEmailMessageID ()
{
assertValid();
if (_EmailMessage == null)
{
return null;
}
else
{
return _EmailMessage.getID ();
}
}
/**
* Called prior to the assoc changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preEmailMessageChange (EmailMessage newEmailMessage) throws FieldException
{
}
/**
* Called after the assoc changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postEmailMessageChange () throws FieldException
{
}
public FieldWriteability getWriteability_EmailMessage ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference EmailMessage. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setEmailMessage (EmailMessage newEmailMessage) throws StorageException, FieldException
{
if (_EmailMessage.wouldReferencedChange (newEmailMessage))
{
assertValid();
Debug.assertion (getWriteability_EmailMessage () != FieldWriteability.FALSE, "Assoc EmailMessage is not writeable");
preEmailMessageChange (newEmailMessage);
EmailMessage oldEmailMessage = getEmailMessage ();
if (oldEmailMessage != null)
{
// This is to stop validation from triggering when we are removed
_EmailMessage.set (null);
oldEmailMessage.removeFromAttachments ((Attachment)(this));
}
_EmailMessage.set (newEmailMessage);
if (newEmailMessage != null)
{
newEmailMessage.addToAttachments ((Attachment)(this));
}
postEmailMessageChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getMultiAssocs()
{
List result = super.getMultiAssocs ();
return result;
}
/**
* Get the reference instance for the multi assoc name.
*/
public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
{
return super.getMultiAssocReferenceInstance(attribName);
}
public String getMultiAssocBackReference(String attribName)
{
return super.getMultiAssocBackReference(attribName);
}
/**
* Get the assoc count for the multi assoc name.
*/
public int getMultiAssocCount(String attribName) throws StorageException
{
return super.getMultiAssocCount(attribName);
}
/**
* Get the assoc at a particular index
*/
public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
{
return super.getMultiAssocAt(attribName, index);
}
/**
* Add to a multi assoc by attribute name
*/
public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException
{
super.addToMultiAssoc(attribName, newElement);
}
/**
* Remove from a multi assoc by attribute name
*/
public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException
{
super.removeFromMultiAssoc(attribName, oldElement);
}
protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
{
super.__loadMultiAssoc(attribName, elements);
}
protected boolean __isMultiAssocLoaded (String attribName)
{
return super.__isMultiAssocLoaded(attribName);
}
public void onDelete ()
{
try
{
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_EmailMessage.isLoaded () || getTransaction ().isObjectLoaded (_EmailMessage.getReferencedType (), getEmailMessageID ()))
{
EmailMessage referenced = getEmailMessage ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Attachments from ", getObjectID (), " to ", referenced.getObjectID ());
_EmailMessage.set (null);
referenced.removeFromAttachments ((Attachment)this);
}
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
super.onDelete ();
}
public Attachment newInstance ()
{
return new Attachment ();
}
public Attachment referenceInstance ()
{
return REFERENCE_Attachment;
}
public Attachment getInTransaction (ObjectTransaction t) throws StorageException
{
return getAttachmentByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_Attachment;
}
public String getBaseSetName ()
{
return "tl_attachment";
}
/**
* This is where an object returns the Persistent sets that will
* store it into the database.
* The should be entered into allSets
*/
public void getPersistentSets (PersistentSetCollection allSets)
{
ObjectStatus myStatus = getStatus ();
PersistentSetStatus myPSetStatus = myStatus.getPSetStatus();
ObjectID myID = getID();
super.getPersistentSets (allSets);
PersistentSet tl_attachmentPSet = allSets.getPersistentSet (myID, "tl_attachment", myPSetStatus);
tl_attachmentPSet.setAttrib (FIELD_ObjectID, myID);
tl_attachmentPSet.setAttrib (FIELD_AttachmentName, HELPER_AttachmentName.toObject (_AttachmentName)); //
tl_attachmentPSet.setAttrib (FIELD_AttachmentFile, HELPER_AttachmentFile.toObject (_AttachmentFile)); //
_EmailMessage.getPersistentSets (allSets);
}
/**
* Sets the objects state based on Persistent sets.
*/
public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
{
super.setFromPersistentSets (objectID, allSets);
PersistentSet tl_attachmentPSet = allSets.getPersistentSet (objectID, "tl_attachment");
_AttachmentName = (String)(HELPER_AttachmentName.fromObject (_AttachmentName, tl_attachmentPSet.getAttrib (FIELD_AttachmentName))); //
_AttachmentFile = (BinaryContent)(HELPER_AttachmentFile.fromObject (_AttachmentFile, tl_attachmentPSet.getAttrib (FIELD_AttachmentFile))); //
_EmailMessage.setFromPersistentSets (objectID, allSets);
}
public void setAttributesFrom (BaseBusinessClass other, MultiException e)
{
super.setAttributesFrom (other, e);
if (other instanceof Attachment)
{
Attachment otherAttachment = (Attachment)other;
try
{
setAttachmentName (otherAttachment.getAttachmentName ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setAttachmentFile (otherAttachment.getAttachmentFile ());
}
catch (FieldException ex)
{
e.addException (ex);
}
}
}
/**
* Set the attributes in this to copies of the attributes in source.
*/
public void copyAttributesFrom (BaseBusinessClass source)
{
super.copyAttributesFrom (source);
if (source instanceof BaseAttachment)
{
BaseAttachment sourceAttachment = (BaseAttachment)(source);
_AttachmentName = sourceAttachment._AttachmentName;
_AttachmentFile = sourceAttachment._AttachmentFile;
}
}
/**
* Set the associations in this to copies of the attributes in source.
*/
public void copySingleAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
{
super.copySingleAssociationsFrom (source, linkToGhosts);
if (source instanceof BaseAttachment)
{
BaseAttachment sourceAttachment = (BaseAttachment)(source);
_EmailMessage.copyFrom (sourceAttachment._EmailMessage, linkToGhosts);
}
}
/**
* Set the associations in this to copies of the attributes in source.
*/
public void copyAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
{
super.copyAssociationsFrom (source, linkToGhosts);
if (source instanceof BaseAttachment)
{
BaseAttachment sourceAttachment = (BaseAttachment)(source);
}
}
public void validate (ValidationContext context)
{
super.validate (context);
}
/**
* Subclasses must override this to read in their attributes
*/
protected void readExternalData(Map<String, Object> vals) throws IOException, ClassNotFoundException
{
super.readExternalData(vals);
_AttachmentName = (String)(HELPER_AttachmentName.readExternal (_AttachmentName, vals.get(FIELD_AttachmentName))); //
_AttachmentFile = (BinaryContent)(HELPER_AttachmentFile.readExternal (_AttachmentFile, vals.get(FIELD_AttachmentFile))); //
_EmailMessage.readExternalData(vals.get(SINGLEREFERENCE_EmailMessage));
}
/**
* Subclasses must override this to write out their attributes
*/
protected void writeExternalData(Map<String, Object> vals) throws IOException
{
super.writeExternalData(vals);
vals.put (FIELD_AttachmentName, HELPER_AttachmentName.writeExternal (_AttachmentName));
vals.put (FIELD_AttachmentFile, HELPER_AttachmentFile.writeExternal (_AttachmentFile));
vals.put (SINGLEREFERENCE_EmailMessage, _EmailMessage.writeExternalData());
}
public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
{
super.compare (other, listener);
if (other instanceof BaseAttachment)
{
BaseAttachment otherAttachment = (BaseAttachment)(other);
if (!HELPER_AttachmentName.compare(this._AttachmentName, otherAttachment._AttachmentName))
{
listener.notifyFieldChange(this, other, FIELD_AttachmentName, HELPER_AttachmentName.toObject(this._AttachmentName), HELPER_AttachmentName.toObject(otherAttachment._AttachmentName));
}
if (!HELPER_AttachmentFile.compare(this._AttachmentFile, otherAttachment._AttachmentFile))
{
listener.notifyFieldChange(this, other, FIELD_AttachmentFile, HELPER_AttachmentFile.toObject(this._AttachmentFile), HELPER_AttachmentFile.toObject(otherAttachment._AttachmentFile));
}
// Compare single assocs
_EmailMessage.compare (otherAttachment._EmailMessage, listener);
// Compare multiple assocs
}
}
public void visitTransients (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
}
public void visitAttributes (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
visitor.visitField(this, FIELD_AttachmentName, HELPER_AttachmentName.toObject(getAttachmentName()));
visitor.visitField(this, FIELD_AttachmentFile, HELPER_AttachmentFile.toObject(getAttachmentFile()));
visitor.visitAssociation (_EmailMessage);
}
public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
{
super.visitAssociations (visitor, scope);
if (scope.includes (_EmailMessage))
{
visitor.visit (_EmailMessage);
}
}
public static Attachment createAttachment (ObjectTransaction transaction) throws StorageException
{
Attachment result = new Attachment ();
result.initialiseNewObject (transaction);
return result;
}
public static Attachment getAttachmentByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (Attachment)(transaction.getObjectByID (REFERENCE_Attachment, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_AttachmentName))
{
return filter.matches (getAttachmentName ());
}
else if (attribName.equals (FIELD_AttachmentFile))
{
return filter.matches (getAttachmentFile ());
}
else if (attribName.equals (SINGLEREFERENCE_EmailMessage))
{
return filter.matches (getEmailMessage ());
}
else
{
return super.testFilter (attribName, filter);
}
}
public Object getAttribute (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_AttachmentName))
{
return HELPER_AttachmentName.toObject (getAttachmentName ());
}
else if (attribName.equals (FIELD_AttachmentFile))
{
return HELPER_AttachmentFile.toObject (getAttachmentFile ());
}
else
{
return super.getAttribute (attribName);
}
}
public AttributeHelper getAttributeHelper (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_AttachmentName))
{
return HELPER_AttachmentName;
}
else if (attribName.equals (FIELD_AttachmentFile))
{
return HELPER_AttachmentFile;
}
else
{
return super.getAttributeHelper (attribName);
}
}
public void setAttribute (String attribName, Object attribValue) throws FieldException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_AttachmentName))
{
setAttachmentName ((String)(HELPER_AttachmentName.fromObject (_AttachmentName, attribValue)));
}
else if (attribName.equals (FIELD_AttachmentFile))
{
setAttachmentFile ((BinaryContent)(HELPER_AttachmentFile.fromObject (_AttachmentFile, attribValue)));
}
else
{
super.setAttribute (attribName, attribValue);
}
}
public boolean isWriteable (String fieldName)
{
return getWriteable (fieldName) == FieldWriteability.TRUE;
}
public FieldWriteability getWriteable (String fieldName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (fieldName.equals (FIELD_AttachmentName))
{
return getWriteability_AttachmentName ();
}
else if (fieldName.equals (FIELD_AttachmentFile))
{
return getWriteability_AttachmentFile ();
}
else if (fieldName.equals (SINGLEREFERENCE_EmailMessage))
{
return getWriteability_EmailMessage ();
}
else
{
return super.getWriteable (fieldName);
}
}
public void putUnwriteable (Set<String> fields)
{
if (getWriteability_AttachmentName () != FieldWriteability.TRUE)
{
fields.add (FIELD_AttachmentName);
}
if (getWriteability_AttachmentFile () != FieldWriteability.TRUE)
{
fields.add (FIELD_AttachmentFile);
}
super.putUnwriteable (fields);
}
public List<AbstractAttribute> getAttributes ()
{
List result = super.getAttributes ();
result.add(HELPER_AttachmentName.getAttribObject (getClass (), _AttachmentName, false, FIELD_AttachmentName));
result.add(HELPER_AttachmentFile.getAttribObject (getClass (), _AttachmentFile, false, FIELD_AttachmentFile));
return result;
}
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_Attachment.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_Attachment.get (attribute);
}
else
{
return super.getAttributeMetadata (attribute);
}
}
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_Attachment.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_Attachment.get (attribute)).get(metadata);
}
else
{
return super.getAttributeMetadata (attribute, metadata);
}
}
public void preCommit (boolean willBeStored) throws Exception
{
super.preCommit(willBeStored);
if(willBeStored)
{
{
oneit.servlets.objstore.binary.BinaryContentHandler bchandler = oneit.servlets.objstore.binary.BinaryContentServlet.getHandler("loggedin");
if(bchandler != null)
{
bchandler.preCommit(willBeStored, this, "AttachmentFile");
}
else
{
LogMgr.log(BUSINESS_OBJECTS, LogLevel.SYSTEMWARNING, "Unknown BinaryContentHandler loggedin on attribute AttachmentFile");
}
}
}
}
public oneit.servlets.objstore.binary.BinaryContentHandler getBinaryContentHandler(String attribName)
{
if(CollectionUtils.equals(attribName, "AttachmentFile"))
{
return oneit.servlets.objstore.binary.BinaryContentServlet.getHandler("loggedin");
}
return super.getBinaryContentHandler(attribName);
}
public static class AttachmentBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<Attachment>
{
/**
* Get the attribute AttachmentName
*/
public String getAttachmentName (Attachment obj, String original)
{
return original;
}
/**
* Change the value set for attribute AttachmentName.
* May modify the field beforehand
* Occurs before validation.
*/
public String setAttachmentName (Attachment obj, String newAttachmentName) throws FieldException
{
return newAttachmentName;
}
/**
* Get the attribute AttachmentFile
*/
public BinaryContent getAttachmentFile (Attachment obj, BinaryContent original)
{
return original;
}
/**
* Change the value set for attribute AttachmentFile.
* May modify the field beforehand
* Occurs before validation.
*/
public BinaryContent setAttachmentFile (Attachment obj, BinaryContent newAttachmentFile) throws FieldException
{
return newAttachmentFile;
}
}
public ORMPipeLine pipes()
{
return new AttachmentPipeLineFactory<Attachment, Attachment> ((Attachment)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public AttachmentPipeLineFactory<Attachment, Attachment> pipelineAttachment()
{
return (AttachmentPipeLineFactory<Attachment, Attachment>) pipes();
}
public static AttachmentPipeLineFactory<Attachment, Attachment> pipesAttachment(Collection<Attachment> items)
{
return REFERENCE_Attachment.new AttachmentPipeLineFactory<Attachment, Attachment> (items);
}
public static AttachmentPipeLineFactory<Attachment, Attachment> pipesAttachment(Attachment[] _items)
{
return pipesAttachment(Arrays.asList (_items));
}
public static AttachmentPipeLineFactory<Attachment, Attachment> pipesAttachment()
{
return pipesAttachment((Collection)null);
}
public class AttachmentPipeLineFactory<From extends BaseBusinessClass, Me extends Attachment> extends BaseBusinessClass.ORMPipeLine<From, Me>
{
public <Prev> AttachmentPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public AttachmentPipeLineFactory (From seed)
{
super(seed);
}
public AttachmentPipeLineFactory (Collection<From> seed)
{
super(seed);
}
public PipeLine<From, ? extends Object> to(String name)
{
if (name.equals ("AttachmentName"))
{
return toAttachmentName ();
}
if (name.equals ("AttachmentFile"))
{
return toAttachmentFile ();
}
if (name.equals ("EmailMessage"))
{
return toEmailMessage ();
}
return super.to(name);
}
public PipeLine<From, String> toAttachmentName () { return pipe(new ORMAttributePipe<Me, String>(FIELD_AttachmentName)); }
public PipeLine<From, BinaryContent> toAttachmentFile () { return pipe(new ORMAttributePipe<Me, BinaryContent>(FIELD_AttachmentFile)); }
public EmailMessage.EmailMessagePipeLineFactory<From, EmailMessage> toEmailMessage () { return toEmailMessage (Filter.ALL); }
public EmailMessage.EmailMessagePipeLineFactory<From, EmailMessage> toEmailMessage (Filter<EmailMessage> filter)
{
return EmailMessage.REFERENCE_EmailMessage.new EmailMessagePipeLineFactory<From, EmailMessage> (this, new ORMSingleAssocPipe<Me, EmailMessage>(SINGLEREFERENCE_EmailMessage, filter));
}
}
public boolean isTransientAttrib(String attribName)
{
return super.isTransientAttrib(attribName);
}
public boolean isTransientSingleReference(String assocName)
{
return super.isTransientSingleReference(assocName);
}
}
class DummyAttachment extends Attachment
{
// Default constructor primarily to support Externalisable
public DummyAttachment()
{
super();
}
public void assertValid ()
{
}
public EmailMessage getEmailMessage () throws StorageException
{
return (EmailMessage)(EmailMessage.DUMMY_EmailMessage);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getEmailMessageID ()
{
return EmailMessage.DUMMY_EmailMessage.getObjectID();
}
}
/*
* IMPORTANT!!!! XSL Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2 rev3 [oneit.objstore.BusinessObjectTemplate.xsl]
*
* Version: 1.0
* Vendor: Apache Software Foundation (Xalan XSLTC)
* Vendor URL: http://xml.apache.org/xalan-j
*/
package performa.orm;
import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.attributes.*;
import oneit.objstore.rdbms.filters.*;
import oneit.objstore.parser.*;
import oneit.objstore.validator.*;
import oneit.objstore.utils.*;
import oneit.utils.*;
import oneit.utils.filter.Filter;
import oneit.utils.transform.*;
import oneit.utils.parsers.FieldException;
public abstract class BaseEmailMessage extends BaseBusinessClass
{
// Reference instance for the object
public static final EmailMessage REFERENCE_EmailMessage = new EmailMessage ();
// Reference instance for the object
public static final EmailMessage DUMMY_EmailMessage = new DummyEmailMessage ();
// Static constants corresponding to field names
public static final String FIELD_MessageId = "MessageId";
public static final String FIELD_EmailFrom = "EmailFrom";
public static final String FIELD_EmailTo = "EmailTo";
public static final String FIELD_EmailCC = "EmailCC";
public static final String FIELD_Subject = "Subject";
public static final String FIELD_Description = "Description";
public static final String FIELD_ReceivedDate = "ReceivedDate";
public static final String SINGLEREFERENCE_Job = "Job";
public static final String MULTIPLEREFERENCE_Attachments = "Attachments";
public static final String BACKREF_Attachments = "";
// Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<EmailMessage> HELPER_MessageId = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<EmailMessage> HELPER_EmailFrom = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<EmailMessage> HELPER_EmailTo = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<EmailMessage> HELPER_EmailCC = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<EmailMessage> HELPER_Subject = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<EmailMessage> HELPER_Description = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<EmailMessage> HELPER_ReceivedDate = DefaultAttributeHelper.INSTANCE;
// Private attributes corresponding to business object data
private String _MessageId;
private String _EmailFrom;
private String _EmailTo;
private String _EmailCC;
private String _Subject;
private String _Description;
private Date _ReceivedDate;
// Private attributes corresponding to single references
private SingleAssociation<EmailMessage, Job> _Job;
// Private attributes corresponding to multiple references
private MultipleAssociation<EmailMessage, Attachment> _Attachments;
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_EmailMessage = new HashMap ();
// Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_MessageId_Validators;
private static final AttributeValidator[] FIELD_EmailFrom_Validators;
private static final AttributeValidator[] FIELD_EmailTo_Validators;
private static final AttributeValidator[] FIELD_EmailCC_Validators;
private static final AttributeValidator[] FIELD_Subject_Validators;
private static final AttributeValidator[] FIELD_Description_Validators;
private static final AttributeValidator[] FIELD_ReceivedDate_Validators;
// Arrays of behaviour decorators
private static final EmailMessageBehaviourDecorator[] EmailMessage_BehaviourDecorators;
static
{
try
{
String tmp_Attachments = Attachment.BACKREF_EmailMessage;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_Attachments();
setupAssocMetaData_Job();
FIELD_MessageId_Validators = (AttributeValidator[])setupAttribMetaData_MessageId(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_EmailFrom_Validators = (AttributeValidator[])setupAttribMetaData_EmailFrom(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_EmailTo_Validators = (AttributeValidator[])setupAttribMetaData_EmailTo(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_EmailCC_Validators = (AttributeValidator[])setupAttribMetaData_EmailCC(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_Subject_Validators = (AttributeValidator[])setupAttribMetaData_Subject(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_Description_Validators = (AttributeValidator[])setupAttribMetaData_Description(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_ReceivedDate_Validators = (AttributeValidator[])setupAttribMetaData_ReceivedDate(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_EmailMessage.initialiseReference ();
DUMMY_EmailMessage.initialiseReference ();
EmailMessage_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(EmailMessage.class).toArray(new EmailMessageBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
throw e;
}
}
// Meta Info setup
private static void setupAssocMetaData_Attachments()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "EmailMessage");
metaInfo.put ("name", "Attachments");
metaInfo.put ("type", "Attachment");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for EmailMessage.Attachments:", metaInfo);
ATTRIBUTES_METADATA_EmailMessage.put (MULTIPLEREFERENCE_Attachments, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_Job()
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "job_id");
metaInfo.put ("name", "Job");
metaInfo.put ("type", "Job");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for EmailMessage.Job:", metaInfo);
ATTRIBUTES_METADATA_EmailMessage.put (SINGLEREFERENCE_Job, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_MessageId(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "message_id");
metaInfo.put ("length", "1000");
metaInfo.put ("name", "MessageId");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for EmailMessage.MessageId:", metaInfo);
ATTRIBUTES_METADATA_EmailMessage.put (FIELD_MessageId, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(EmailMessage.class, "MessageId", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for EmailMessage.MessageId:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_EmailFrom(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "email_from");
metaInfo.put ("length", "500");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "EmailFrom");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for EmailMessage.EmailFrom:", metaInfo);
ATTRIBUTES_METADATA_EmailMessage.put (FIELD_EmailFrom, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(EmailMessage.class, "EmailFrom", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for EmailMessage.EmailFrom:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_EmailTo(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "email_to");
metaInfo.put ("length", "500");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "EmailTo");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for EmailMessage.EmailTo:", metaInfo);
ATTRIBUTES_METADATA_EmailMessage.put (FIELD_EmailTo, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(EmailMessage.class, "EmailTo", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for EmailMessage.EmailTo:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_EmailCC(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "email_cc");
metaInfo.put ("length", "500");
metaInfo.put ("name", "EmailCC");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for EmailMessage.EmailCC:", metaInfo);
ATTRIBUTES_METADATA_EmailMessage.put (FIELD_EmailCC, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(EmailMessage.class, "EmailCC", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for EmailMessage.EmailCC:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_Subject(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "subject");
metaInfo.put ("length", "1000");
metaInfo.put ("name", "Subject");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for EmailMessage.Subject:", metaInfo);
ATTRIBUTES_METADATA_EmailMessage.put (FIELD_Subject, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(EmailMessage.class, "Subject", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for EmailMessage.Subject:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_Description(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "description");
metaInfo.put ("name", "Description");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for EmailMessage.Description:", metaInfo);
ATTRIBUTES_METADATA_EmailMessage.put (FIELD_Description, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(EmailMessage.class, "Description", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for EmailMessage.Description:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_ReceivedDate(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "received_date");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "ReceivedDate");
metaInfo.put ("type", "Date");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for EmailMessage.ReceivedDate:", metaInfo);
ATTRIBUTES_METADATA_EmailMessage.put (FIELD_ReceivedDate, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(EmailMessage.class, "ReceivedDate", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for EmailMessage.ReceivedDate:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION
// This constructor should not be called
protected BaseEmailMessage ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return EmailMessage_BehaviourDecorators;
}
// Initialise the attributes
protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
{
super._initialiseNewObjAttributes (transaction);
_MessageId = (String)(HELPER_MessageId.initialise (_MessageId));
_EmailFrom = (String)(HELPER_EmailFrom.initialise (_EmailFrom));
_EmailTo = (String)(HELPER_EmailTo.initialise (_EmailTo));
_EmailCC = (String)(HELPER_EmailCC.initialise (_EmailCC));
_Subject = (String)(HELPER_Subject.initialise (_Subject));
_Description = (String)(HELPER_Description.initialise (_Description));
_ReceivedDate = (Date)(HELPER_ReceivedDate.initialise (_ReceivedDate));
}
// Initialise the associations
protected void _initialiseAssociations ()
{
super._initialiseAssociations ();
_Job = new SingleAssociation<EmailMessage, Job> (this, SINGLEREFERENCE_Job, null, Job.REFERENCE_Job, "tl_email_message");
_Attachments = new MultipleAssociation<EmailMessage, Attachment> (this, MULTIPLEREFERENCE_Attachments, Attachment.SINGLEREFERENCE_EmailMessage, Attachment.REFERENCE_Attachment);
}
// Initialise the associations
protected BaseBusinessClass initialiseReference ()
{
super.initialiseReference ();
_Job = new SingleAssociation<EmailMessage, Job> (this, SINGLEREFERENCE_Job, null, Job.REFERENCE_Job, "tl_email_message");
_Attachments = new MultipleAssociation<EmailMessage, Attachment> (this, MULTIPLEREFERENCE_Attachments, Attachment.SINGLEREFERENCE_EmailMessage, Attachment.REFERENCE_Attachment);
return this;
}
/**
* Get the attribute MessageId
*/
public String getMessageId ()
{
assertValid();
String valToReturn = _MessageId;
for (EmailMessageBehaviourDecorator bhd : EmailMessage_BehaviourDecorators)
{
valToReturn = bhd.getMessageId ((EmailMessage)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preMessageIdChange (String newMessageId) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postMessageIdChange () throws FieldException
{
}
public FieldWriteability getWriteability_MessageId ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute MessageId. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setMessageId (String newMessageId) throws FieldException
{
boolean oldAndNewIdentical = HELPER_MessageId.compare (_MessageId, newMessageId);
try
{
for (EmailMessageBehaviourDecorator bhd : EmailMessage_BehaviourDecorators)
{
newMessageId = bhd.setMessageId ((EmailMessage)this, newMessageId);
oldAndNewIdentical = HELPER_MessageId.compare (_MessageId, newMessageId);
}
if (FIELD_MessageId_Validators.length > 0)
{
Object newMessageIdObj = HELPER_MessageId.toObject (newMessageId);
if (newMessageIdObj != null)
{
int loopMax = FIELD_MessageId_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_EmailMessage.get (FIELD_MessageId);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_MessageId_Validators[v].checkAttribute (this, FIELD_MessageId, metadata, newMessageIdObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_MessageId () != FieldWriteability.FALSE, "Field MessageId is not writeable");
preMessageIdChange (newMessageId);
markFieldChange (FIELD_MessageId);
_MessageId = newMessageId;
postFieldChange (FIELD_MessageId);
postMessageIdChange ();
}
}
/**
* Get the attribute EmailFrom
*/
public String getEmailFrom ()
{
assertValid();
String valToReturn = _EmailFrom;
for (EmailMessageBehaviourDecorator bhd : EmailMessage_BehaviourDecorators)
{
valToReturn = bhd.getEmailFrom ((EmailMessage)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preEmailFromChange (String newEmailFrom) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postEmailFromChange () throws FieldException
{
}
public FieldWriteability getWriteability_EmailFrom ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute EmailFrom. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setEmailFrom (String newEmailFrom) throws FieldException
{
boolean oldAndNewIdentical = HELPER_EmailFrom.compare (_EmailFrom, newEmailFrom);
try
{
for (EmailMessageBehaviourDecorator bhd : EmailMessage_BehaviourDecorators)
{
newEmailFrom = bhd.setEmailFrom ((EmailMessage)this, newEmailFrom);
oldAndNewIdentical = HELPER_EmailFrom.compare (_EmailFrom, newEmailFrom);
}
BusinessObjectParser.assertFieldCondition (newEmailFrom != null, this, FIELD_EmailFrom, "mandatory");
if (FIELD_EmailFrom_Validators.length > 0)
{
Object newEmailFromObj = HELPER_EmailFrom.toObject (newEmailFrom);
if (newEmailFromObj != null)
{
int loopMax = FIELD_EmailFrom_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_EmailMessage.get (FIELD_EmailFrom);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_EmailFrom_Validators[v].checkAttribute (this, FIELD_EmailFrom, metadata, newEmailFromObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_EmailFrom () != FieldWriteability.FALSE, "Field EmailFrom is not writeable");
preEmailFromChange (newEmailFrom);
markFieldChange (FIELD_EmailFrom);
_EmailFrom = newEmailFrom;
postFieldChange (FIELD_EmailFrom);
postEmailFromChange ();
}
}
/**
* Get the attribute EmailTo
*/
public String getEmailTo ()
{
assertValid();
String valToReturn = _EmailTo;
for (EmailMessageBehaviourDecorator bhd : EmailMessage_BehaviourDecorators)
{
valToReturn = bhd.getEmailTo ((EmailMessage)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preEmailToChange (String newEmailTo) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postEmailToChange () throws FieldException
{
}
public FieldWriteability getWriteability_EmailTo ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute EmailTo. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setEmailTo (String newEmailTo) throws FieldException
{
boolean oldAndNewIdentical = HELPER_EmailTo.compare (_EmailTo, newEmailTo);
try
{
for (EmailMessageBehaviourDecorator bhd : EmailMessage_BehaviourDecorators)
{
newEmailTo = bhd.setEmailTo ((EmailMessage)this, newEmailTo);
oldAndNewIdentical = HELPER_EmailTo.compare (_EmailTo, newEmailTo);
}
BusinessObjectParser.assertFieldCondition (newEmailTo != null, this, FIELD_EmailTo, "mandatory");
if (FIELD_EmailTo_Validators.length > 0)
{
Object newEmailToObj = HELPER_EmailTo.toObject (newEmailTo);
if (newEmailToObj != null)
{
int loopMax = FIELD_EmailTo_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_EmailMessage.get (FIELD_EmailTo);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_EmailTo_Validators[v].checkAttribute (this, FIELD_EmailTo, metadata, newEmailToObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_EmailTo () != FieldWriteability.FALSE, "Field EmailTo is not writeable");
preEmailToChange (newEmailTo);
markFieldChange (FIELD_EmailTo);
_EmailTo = newEmailTo;
postFieldChange (FIELD_EmailTo);
postEmailToChange ();
}
}
/**
* Get the attribute EmailCC
*/
public String getEmailCC ()
{
assertValid();
String valToReturn = _EmailCC;
for (EmailMessageBehaviourDecorator bhd : EmailMessage_BehaviourDecorators)
{
valToReturn = bhd.getEmailCC ((EmailMessage)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preEmailCCChange (String newEmailCC) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postEmailCCChange () throws FieldException
{
}
public FieldWriteability getWriteability_EmailCC ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute EmailCC. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setEmailCC (String newEmailCC) throws FieldException
{
boolean oldAndNewIdentical = HELPER_EmailCC.compare (_EmailCC, newEmailCC);
try
{
for (EmailMessageBehaviourDecorator bhd : EmailMessage_BehaviourDecorators)
{
newEmailCC = bhd.setEmailCC ((EmailMessage)this, newEmailCC);
oldAndNewIdentical = HELPER_EmailCC.compare (_EmailCC, newEmailCC);
}
if (FIELD_EmailCC_Validators.length > 0)
{
Object newEmailCCObj = HELPER_EmailCC.toObject (newEmailCC);
if (newEmailCCObj != null)
{
int loopMax = FIELD_EmailCC_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_EmailMessage.get (FIELD_EmailCC);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_EmailCC_Validators[v].checkAttribute (this, FIELD_EmailCC, metadata, newEmailCCObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_EmailCC () != FieldWriteability.FALSE, "Field EmailCC is not writeable");
preEmailCCChange (newEmailCC);
markFieldChange (FIELD_EmailCC);
_EmailCC = newEmailCC;
postFieldChange (FIELD_EmailCC);
postEmailCCChange ();
}
}
/**
* Get the attribute Subject
*/
public String getSubject ()
{
assertValid();
String valToReturn = _Subject;
for (EmailMessageBehaviourDecorator bhd : EmailMessage_BehaviourDecorators)
{
valToReturn = bhd.getSubject ((EmailMessage)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preSubjectChange (String newSubject) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postSubjectChange () throws FieldException
{
}
public FieldWriteability getWriteability_Subject ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Subject. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setSubject (String newSubject) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Subject.compare (_Subject, newSubject);
try
{
for (EmailMessageBehaviourDecorator bhd : EmailMessage_BehaviourDecorators)
{
newSubject = bhd.setSubject ((EmailMessage)this, newSubject);
oldAndNewIdentical = HELPER_Subject.compare (_Subject, newSubject);
}
if (FIELD_Subject_Validators.length > 0)
{
Object newSubjectObj = HELPER_Subject.toObject (newSubject);
if (newSubjectObj != null)
{
int loopMax = FIELD_Subject_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_EmailMessage.get (FIELD_Subject);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Subject_Validators[v].checkAttribute (this, FIELD_Subject, metadata, newSubjectObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Subject () != FieldWriteability.FALSE, "Field Subject is not writeable");
preSubjectChange (newSubject);
markFieldChange (FIELD_Subject);
_Subject = newSubject;
postFieldChange (FIELD_Subject);
postSubjectChange ();
}
}
/**
* Get the attribute Description
*/
public String getDescription ()
{
assertValid();
String valToReturn = _Description;
for (EmailMessageBehaviourDecorator bhd : EmailMessage_BehaviourDecorators)
{
valToReturn = bhd.getDescription ((EmailMessage)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preDescriptionChange (String newDescription) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postDescriptionChange () throws FieldException
{
}
public FieldWriteability getWriteability_Description ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Description. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setDescription (String newDescription) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Description.compare (_Description, newDescription);
try
{
for (EmailMessageBehaviourDecorator bhd : EmailMessage_BehaviourDecorators)
{
newDescription = bhd.setDescription ((EmailMessage)this, newDescription);
oldAndNewIdentical = HELPER_Description.compare (_Description, newDescription);
}
if (FIELD_Description_Validators.length > 0)
{
Object newDescriptionObj = HELPER_Description.toObject (newDescription);
if (newDescriptionObj != null)
{
int loopMax = FIELD_Description_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_EmailMessage.get (FIELD_Description);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Description_Validators[v].checkAttribute (this, FIELD_Description, metadata, newDescriptionObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Description () != FieldWriteability.FALSE, "Field Description is not writeable");
preDescriptionChange (newDescription);
markFieldChange (FIELD_Description);
_Description = newDescription;
postFieldChange (FIELD_Description);
postDescriptionChange ();
}
}
/**
* Get the attribute ReceivedDate
*/
public Date getReceivedDate ()
{
assertValid();
Date valToReturn = _ReceivedDate;
for (EmailMessageBehaviourDecorator bhd : EmailMessage_BehaviourDecorators)
{
valToReturn = bhd.getReceivedDate ((EmailMessage)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preReceivedDateChange (Date newReceivedDate) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postReceivedDateChange () throws FieldException
{
}
public FieldWriteability getWriteability_ReceivedDate ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute ReceivedDate. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setReceivedDate (Date newReceivedDate) throws FieldException
{
boolean oldAndNewIdentical = HELPER_ReceivedDate.compare (_ReceivedDate, newReceivedDate);
try
{
for (EmailMessageBehaviourDecorator bhd : EmailMessage_BehaviourDecorators)
{
newReceivedDate = bhd.setReceivedDate ((EmailMessage)this, newReceivedDate);
oldAndNewIdentical = HELPER_ReceivedDate.compare (_ReceivedDate, newReceivedDate);
}
BusinessObjectParser.assertFieldCondition (newReceivedDate != null, this, FIELD_ReceivedDate, "mandatory");
if (FIELD_ReceivedDate_Validators.length > 0)
{
Object newReceivedDateObj = HELPER_ReceivedDate.toObject (newReceivedDate);
if (newReceivedDateObj != null)
{
int loopMax = FIELD_ReceivedDate_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_EmailMessage.get (FIELD_ReceivedDate);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_ReceivedDate_Validators[v].checkAttribute (this, FIELD_ReceivedDate, metadata, newReceivedDateObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_ReceivedDate () != FieldWriteability.FALSE, "Field ReceivedDate is not writeable");
preReceivedDateChange (newReceivedDate);
markFieldChange (FIELD_ReceivedDate);
_ReceivedDate = newReceivedDate;
postFieldChange (FIELD_ReceivedDate);
postReceivedDateChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getSingleAssocs()
{
List result = super.getSingleAssocs ();
result.add("Job");
return result;
}
public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Job))
{
return _Job.getReferencedType ();
}
else
{
return super.getSingleAssocReferenceInstance (assocName);
}
}
public String getSingleAssocBackReference(String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Job))
{
return null ;
}
else
{
return super.getSingleAssocBackReference (assocName);
}
}
public BaseBusinessClass getSingleAssoc (String assocName) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Job))
{
return getJob ();
}
else
{
return super.getSingleAssoc (assocName);
}
}
public BaseBusinessClass getSingleAssoc (String assocName, Get getType) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Job))
{
return getJob (getType);
}
else
{
return super.getSingleAssoc (assocName, getType);
}
}
public Long getSingleAssocID (String assocName) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Job))
{
return getJobID ();
}
else
{
return super.getSingleAssocID (assocName);
}
}
public void setSingleAssoc (String assocName, BaseBusinessClass newValue) throws StorageException, FieldException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Job))
{
setJob ((Job)(newValue));
}
else
{
super.setSingleAssoc (assocName, newValue);
}
}
/**
* Get the reference Job
*/
public Job getJob () throws StorageException
{
assertValid();
try
{
return (Job)(_Job.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in EmailMessage:", this.getObjectID (), ", was trying to get Job:", getJobID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _Job.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Job getJob (Get getType) throws StorageException
{
assertValid();
return _Job.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getJobID ()
{
assertValid();
if (_Job == null)
{
return null;
}
else
{
return _Job.getID ();
}
}
/**
* Called prior to the assoc changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preJobChange (Job newJob) throws FieldException
{
}
/**
* Called after the assoc changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postJobChange () throws FieldException
{
}
public FieldWriteability getWriteability_Job ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference Job. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setJob (Job newJob) throws StorageException, FieldException
{
if (_Job.wouldReferencedChange (newJob))
{
assertValid();
Debug.assertion (getWriteability_Job () != FieldWriteability.FALSE, "Assoc Job is not writeable");
preJobChange (newJob);
_Job.set (newJob);
postJobChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getMultiAssocs()
{
List result = super.getMultiAssocs ();
result.add("Attachments");
return result;
}
/**
* Get the reference instance for the multi assoc name.
*/
public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
{
if (MULTIPLEREFERENCE_Attachments.equals(attribName))
{
return Attachment.REFERENCE_Attachment ;
}
return super.getMultiAssocReferenceInstance(attribName);
}
public String getMultiAssocBackReference(String attribName)
{
if (MULTIPLEREFERENCE_Attachments.equals(attribName))
{
return Attachment.SINGLEREFERENCE_EmailMessage ;
}
return super.getMultiAssocBackReference(attribName);
}
/**
* Get the assoc count for the multi assoc name.
*/
public int getMultiAssocCount(String attribName) throws StorageException
{
if (MULTIPLEREFERENCE_Attachments.equals(attribName))
{
return this.getAttachmentsCount();
}
return super.getMultiAssocCount(attribName);
}
/**
* Get the assoc at a particular index
*/
public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
{
if (MULTIPLEREFERENCE_Attachments.equals(attribName))
{
return this.getAttachmentsAt(index);
}
return super.getMultiAssocAt(attribName, index);
}
/**
* Add to a multi assoc by attribute name
*/
public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException
{
if (MULTIPLEREFERENCE_Attachments.equals(attribName))
{
addToAttachments((Attachment)newElement);
return;
}
super.addToMultiAssoc(attribName, newElement);
}
/**
* Remove from a multi assoc by attribute name
*/
public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException
{
if (MULTIPLEREFERENCE_Attachments.equals(attribName))
{
removeFromAttachments((Attachment)oldElement);
return;
}
super.removeFromMultiAssoc(attribName, oldElement);
}
protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
{
if (MULTIPLEREFERENCE_Attachments.equals(attribName))
{
_Attachments.__loadAssociation (elements);
return;
}
super.__loadMultiAssoc(attribName, elements);
}
protected boolean __isMultiAssocLoaded (String attribName)
{
if (MULTIPLEREFERENCE_Attachments.equals(attribName))
{
return _Attachments.isLoaded ();
}
return super.__isMultiAssocLoaded(attribName);
}
public FieldWriteability getWriteability_Attachments ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getAttachmentsCount () throws StorageException
{
assertValid();
return _Attachments.getReferencedObjectsCount ();
}
public void addToAttachments (Attachment newElement) throws StorageException
{
if (_Attachments.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_Attachments () != FieldWriteability.FALSE, "MultiAssoc Attachments is not writeable (add)");
_Attachments.appendElement (newElement);
try
{
if (newElement.getEmailMessage () != this)
{
newElement.setEmailMessage ((EmailMessage)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromAttachments (Attachment elementToRemove) throws StorageException
{
if (_Attachments.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_Attachments () != FieldWriteability.FALSE, "MultiAssoc Attachments is not writeable (remove)");
_Attachments.removeElement (elementToRemove);
try
{
if (elementToRemove.getEmailMessage () != null)
{
elementToRemove.setEmailMessage (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public Attachment getAttachmentsAt (int index) throws StorageException
{
return (Attachment)(_Attachments.getElementAt (index));
}
public SortedSet<Attachment> getAttachmentsSet () throws StorageException
{
return _Attachments.getSet ();
}
public void onDelete ()
{
try
{
for(Attachment referenced : CollectionUtils.reverse(getAttachmentsSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null EmailMessage from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setEmailMessage(null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
super.onDelete ();
}
public EmailMessage newInstance ()
{
return new EmailMessage ();
}
public EmailMessage referenceInstance ()
{
return REFERENCE_EmailMessage;
}
public EmailMessage getInTransaction (ObjectTransaction t) throws StorageException
{
return getEmailMessageByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_EmailMessage;
}
public String getBaseSetName ()
{
return "tl_email_message";
}
/**
* This is where an object returns the Persistent sets that will
* store it into the database.
* The should be entered into allSets
*/
public void getPersistentSets (PersistentSetCollection allSets)
{
ObjectStatus myStatus = getStatus ();
PersistentSetStatus myPSetStatus = myStatus.getPSetStatus();
ObjectID myID = getID();
super.getPersistentSets (allSets);
PersistentSet tl_email_messagePSet = allSets.getPersistentSet (myID, "tl_email_message", myPSetStatus);
tl_email_messagePSet.setAttrib (FIELD_ObjectID, myID);
tl_email_messagePSet.setAttrib (FIELD_MessageId, HELPER_MessageId.toObject (_MessageId)); //
tl_email_messagePSet.setAttrib (FIELD_EmailFrom, HELPER_EmailFrom.toObject (_EmailFrom)); //
tl_email_messagePSet.setAttrib (FIELD_EmailTo, HELPER_EmailTo.toObject (_EmailTo)); //
tl_email_messagePSet.setAttrib (FIELD_EmailCC, HELPER_EmailCC.toObject (_EmailCC)); //
tl_email_messagePSet.setAttrib (FIELD_Subject, HELPER_Subject.toObject (_Subject)); //
tl_email_messagePSet.setAttrib (FIELD_Description, HELPER_Description.toObject (_Description)); //
tl_email_messagePSet.setAttrib (FIELD_ReceivedDate, HELPER_ReceivedDate.toObject (_ReceivedDate)); //
_Job.getPersistentSets (allSets);
}
/**
* Sets the objects state based on Persistent sets.
*/
public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
{
super.setFromPersistentSets (objectID, allSets);
PersistentSet tl_email_messagePSet = allSets.getPersistentSet (objectID, "tl_email_message");
_MessageId = (String)(HELPER_MessageId.fromObject (_MessageId, tl_email_messagePSet.getAttrib (FIELD_MessageId))); //
_EmailFrom = (String)(HELPER_EmailFrom.fromObject (_EmailFrom, tl_email_messagePSet.getAttrib (FIELD_EmailFrom))); //
_EmailTo = (String)(HELPER_EmailTo.fromObject (_EmailTo, tl_email_messagePSet.getAttrib (FIELD_EmailTo))); //
_EmailCC = (String)(HELPER_EmailCC.fromObject (_EmailCC, tl_email_messagePSet.getAttrib (FIELD_EmailCC))); //
_Subject = (String)(HELPER_Subject.fromObject (_Subject, tl_email_messagePSet.getAttrib (FIELD_Subject))); //
_Description = (String)(HELPER_Description.fromObject (_Description, tl_email_messagePSet.getAttrib (FIELD_Description))); //
_ReceivedDate = (Date)(HELPER_ReceivedDate.fromObject (_ReceivedDate, tl_email_messagePSet.getAttrib (FIELD_ReceivedDate))); //
_Job.setFromPersistentSets (objectID, allSets);
}
public void setAttributesFrom (BaseBusinessClass other, MultiException e)
{
super.setAttributesFrom (other, e);
if (other instanceof EmailMessage)
{
EmailMessage otherEmailMessage = (EmailMessage)other;
try
{
setMessageId (otherEmailMessage.getMessageId ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setEmailFrom (otherEmailMessage.getEmailFrom ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setEmailTo (otherEmailMessage.getEmailTo ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setEmailCC (otherEmailMessage.getEmailCC ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setSubject (otherEmailMessage.getSubject ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setDescription (otherEmailMessage.getDescription ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setReceivedDate (otherEmailMessage.getReceivedDate ());
}
catch (FieldException ex)
{
e.addException (ex);
}
}
}
/**
* Set the attributes in this to copies of the attributes in source.
*/
public void copyAttributesFrom (BaseBusinessClass source)
{
super.copyAttributesFrom (source);
if (source instanceof BaseEmailMessage)
{
BaseEmailMessage sourceEmailMessage = (BaseEmailMessage)(source);
_MessageId = sourceEmailMessage._MessageId;
_EmailFrom = sourceEmailMessage._EmailFrom;
_EmailTo = sourceEmailMessage._EmailTo;
_EmailCC = sourceEmailMessage._EmailCC;
_Subject = sourceEmailMessage._Subject;
_Description = sourceEmailMessage._Description;
_ReceivedDate = sourceEmailMessage._ReceivedDate;
}
}
/**
* Set the associations in this to copies of the attributes in source.
*/
public void copySingleAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
{
super.copySingleAssociationsFrom (source, linkToGhosts);
if (source instanceof BaseEmailMessage)
{
BaseEmailMessage sourceEmailMessage = (BaseEmailMessage)(source);
_Job.copyFrom (sourceEmailMessage._Job, linkToGhosts);
}
}
/**
* Set the associations in this to copies of the attributes in source.
*/
public void copyAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
{
super.copyAssociationsFrom (source, linkToGhosts);
if (source instanceof BaseEmailMessage)
{
BaseEmailMessage sourceEmailMessage = (BaseEmailMessage)(source);
_Attachments.copyFrom (sourceEmailMessage._Attachments, linkToGhosts);
}
}
public void validate (ValidationContext context)
{
super.validate (context);
}
/**
* Subclasses must override this to read in their attributes
*/
protected void readExternalData(Map<String, Object> vals) throws IOException, ClassNotFoundException
{
super.readExternalData(vals);
_MessageId = (String)(HELPER_MessageId.readExternal (_MessageId, vals.get(FIELD_MessageId))); //
_EmailFrom = (String)(HELPER_EmailFrom.readExternal (_EmailFrom, vals.get(FIELD_EmailFrom))); //
_EmailTo = (String)(HELPER_EmailTo.readExternal (_EmailTo, vals.get(FIELD_EmailTo))); //
_EmailCC = (String)(HELPER_EmailCC.readExternal (_EmailCC, vals.get(FIELD_EmailCC))); //
_Subject = (String)(HELPER_Subject.readExternal (_Subject, vals.get(FIELD_Subject))); //
_Description = (String)(HELPER_Description.readExternal (_Description, vals.get(FIELD_Description))); //
_ReceivedDate = (Date)(HELPER_ReceivedDate.readExternal (_ReceivedDate, vals.get(FIELD_ReceivedDate))); //
_Job.readExternalData(vals.get(SINGLEREFERENCE_Job));
_Attachments.readExternalData(vals.get(MULTIPLEREFERENCE_Attachments));
}
/**
* Subclasses must override this to write out their attributes
*/
protected void writeExternalData(Map<String, Object> vals) throws IOException
{
super.writeExternalData(vals);
vals.put (FIELD_MessageId, HELPER_MessageId.writeExternal (_MessageId));
vals.put (FIELD_EmailFrom, HELPER_EmailFrom.writeExternal (_EmailFrom));
vals.put (FIELD_EmailTo, HELPER_EmailTo.writeExternal (_EmailTo));
vals.put (FIELD_EmailCC, HELPER_EmailCC.writeExternal (_EmailCC));
vals.put (FIELD_Subject, HELPER_Subject.writeExternal (_Subject));
vals.put (FIELD_Description, HELPER_Description.writeExternal (_Description));
vals.put (FIELD_ReceivedDate, HELPER_ReceivedDate.writeExternal (_ReceivedDate));
vals.put (SINGLEREFERENCE_Job, _Job.writeExternalData());
vals.put (MULTIPLEREFERENCE_Attachments, _Attachments.writeExternalData());
}
public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
{
super.compare (other, listener);
if (other instanceof BaseEmailMessage)
{
BaseEmailMessage otherEmailMessage = (BaseEmailMessage)(other);
if (!HELPER_MessageId.compare(this._MessageId, otherEmailMessage._MessageId))
{
listener.notifyFieldChange(this, other, FIELD_MessageId, HELPER_MessageId.toObject(this._MessageId), HELPER_MessageId.toObject(otherEmailMessage._MessageId));
}
if (!HELPER_EmailFrom.compare(this._EmailFrom, otherEmailMessage._EmailFrom))
{
listener.notifyFieldChange(this, other, FIELD_EmailFrom, HELPER_EmailFrom.toObject(this._EmailFrom), HELPER_EmailFrom.toObject(otherEmailMessage._EmailFrom));
}
if (!HELPER_EmailTo.compare(this._EmailTo, otherEmailMessage._EmailTo))
{
listener.notifyFieldChange(this, other, FIELD_EmailTo, HELPER_EmailTo.toObject(this._EmailTo), HELPER_EmailTo.toObject(otherEmailMessage._EmailTo));
}
if (!HELPER_EmailCC.compare(this._EmailCC, otherEmailMessage._EmailCC))
{
listener.notifyFieldChange(this, other, FIELD_EmailCC, HELPER_EmailCC.toObject(this._EmailCC), HELPER_EmailCC.toObject(otherEmailMessage._EmailCC));
}
if (!HELPER_Subject.compare(this._Subject, otherEmailMessage._Subject))
{
listener.notifyFieldChange(this, other, FIELD_Subject, HELPER_Subject.toObject(this._Subject), HELPER_Subject.toObject(otherEmailMessage._Subject));
}
if (!HELPER_Description.compare(this._Description, otherEmailMessage._Description))
{
listener.notifyFieldChange(this, other, FIELD_Description, HELPER_Description.toObject(this._Description), HELPER_Description.toObject(otherEmailMessage._Description));
}
if (!HELPER_ReceivedDate.compare(this._ReceivedDate, otherEmailMessage._ReceivedDate))
{
listener.notifyFieldChange(this, other, FIELD_ReceivedDate, HELPER_ReceivedDate.toObject(this._ReceivedDate), HELPER_ReceivedDate.toObject(otherEmailMessage._ReceivedDate));
}
// Compare single assocs
_Job.compare (otherEmailMessage._Job, listener);
// Compare multiple assocs
_Attachments.compare (otherEmailMessage._Attachments, listener);
}
}
public void visitTransients (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
}
public void visitAttributes (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
visitor.visitField(this, FIELD_MessageId, HELPER_MessageId.toObject(getMessageId()));
visitor.visitField(this, FIELD_EmailFrom, HELPER_EmailFrom.toObject(getEmailFrom()));
visitor.visitField(this, FIELD_EmailTo, HELPER_EmailTo.toObject(getEmailTo()));
visitor.visitField(this, FIELD_EmailCC, HELPER_EmailCC.toObject(getEmailCC()));
visitor.visitField(this, FIELD_Subject, HELPER_Subject.toObject(getSubject()));
visitor.visitField(this, FIELD_Description, HELPER_Description.toObject(getDescription()));
visitor.visitField(this, FIELD_ReceivedDate, HELPER_ReceivedDate.toObject(getReceivedDate()));
visitor.visitAssociation (_Job);
visitor.visitAssociation (_Attachments);
}
public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
{
super.visitAssociations (visitor, scope);
if (scope.includes (_Job))
{
visitor.visit (_Job);
}
if (scope.includes (_Attachments))
{
visitor.visit (_Attachments);
}
}
public static EmailMessage createEmailMessage (ObjectTransaction transaction) throws StorageException
{
EmailMessage result = new EmailMessage ();
result.initialiseNewObject (transaction);
return result;
}
public static EmailMessage getEmailMessageByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (EmailMessage)(transaction.getObjectByID (REFERENCE_EmailMessage, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_MessageId))
{
return filter.matches (getMessageId ());
}
else if (attribName.equals (FIELD_EmailFrom))
{
return filter.matches (getEmailFrom ());
}
else if (attribName.equals (FIELD_EmailTo))
{
return filter.matches (getEmailTo ());
}
else if (attribName.equals (FIELD_EmailCC))
{
return filter.matches (getEmailCC ());
}
else if (attribName.equals (FIELD_Subject))
{
return filter.matches (getSubject ());
}
else if (attribName.equals (FIELD_Description))
{
return filter.matches (getDescription ());
}
else if (attribName.equals (FIELD_ReceivedDate))
{
return filter.matches (getReceivedDate ());
}
else if (attribName.equals (SINGLEREFERENCE_Job))
{
return filter.matches (getJob ());
}
else
{
return super.testFilter (attribName, filter);
}
}
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<EmailMessage>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "tl_email_message.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_email_message.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_email_message.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andMessageId (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_email_message.message_id", "MessageId");
return this;
}
public SearchAll andEmailFrom (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_email_message.email_from", "EmailFrom");
return this;
}
public SearchAll andEmailTo (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_email_message.email_to", "EmailTo");
return this;
}
public SearchAll andEmailCC (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_email_message.email_cc", "EmailCC");
return this;
}
public SearchAll andSubject (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_email_message.subject", "Subject");
return this;
}
public SearchAll andDescription (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_email_message.description", "Description");
return this;
}
public SearchAll andReceivedDate (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_email_message.received_date", "ReceivedDate");
return this;
}
public SearchAll andJob (QueryFilter<Job> filter)
{
filter.addFilter (context, "tl_email_message.job_id", "Job");
return this;
}
public EmailMessage[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_EmailMessage, SEARCH_All, criteria);
Set<EmailMessage> typedResults = new LinkedHashSet <EmailMessage> ();
for (BaseBusinessClass bbcResult : results)
{
EmailMessage aResult = (EmailMessage)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new EmailMessage[0]);
}
}
public static EmailMessage[]
searchAll (ObjectTransaction transaction) throws StorageException
{
return SearchByAll ()
.search (transaction);
}
public Object getAttribute (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_MessageId))
{
return HELPER_MessageId.toObject (getMessageId ());
}
else if (attribName.equals (FIELD_EmailFrom))
{
return HELPER_EmailFrom.toObject (getEmailFrom ());
}
else if (attribName.equals (FIELD_EmailTo))
{
return HELPER_EmailTo.toObject (getEmailTo ());
}
else if (attribName.equals (FIELD_EmailCC))
{
return HELPER_EmailCC.toObject (getEmailCC ());
}
else if (attribName.equals (FIELD_Subject))
{
return HELPER_Subject.toObject (getSubject ());
}
else if (attribName.equals (FIELD_Description))
{
return HELPER_Description.toObject (getDescription ());
}
else if (attribName.equals (FIELD_ReceivedDate))
{
return HELPER_ReceivedDate.toObject (getReceivedDate ());
}
else
{
return super.getAttribute (attribName);
}
}
public AttributeHelper getAttributeHelper (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_MessageId))
{
return HELPER_MessageId;
}
else if (attribName.equals (FIELD_EmailFrom))
{
return HELPER_EmailFrom;
}
else if (attribName.equals (FIELD_EmailTo))
{
return HELPER_EmailTo;
}
else if (attribName.equals (FIELD_EmailCC))
{
return HELPER_EmailCC;
}
else if (attribName.equals (FIELD_Subject))
{
return HELPER_Subject;
}
else if (attribName.equals (FIELD_Description))
{
return HELPER_Description;
}
else if (attribName.equals (FIELD_ReceivedDate))
{
return HELPER_ReceivedDate;
}
else
{
return super.getAttributeHelper (attribName);
}
}
public void setAttribute (String attribName, Object attribValue) throws FieldException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_MessageId))
{
setMessageId ((String)(HELPER_MessageId.fromObject (_MessageId, attribValue)));
}
else if (attribName.equals (FIELD_EmailFrom))
{
setEmailFrom ((String)(HELPER_EmailFrom.fromObject (_EmailFrom, attribValue)));
}
else if (attribName.equals (FIELD_EmailTo))
{
setEmailTo ((String)(HELPER_EmailTo.fromObject (_EmailTo, attribValue)));
}
else if (attribName.equals (FIELD_EmailCC))
{
setEmailCC ((String)(HELPER_EmailCC.fromObject (_EmailCC, attribValue)));
}
else if (attribName.equals (FIELD_Subject))
{
setSubject ((String)(HELPER_Subject.fromObject (_Subject, attribValue)));
}
else if (attribName.equals (FIELD_Description))
{
setDescription ((String)(HELPER_Description.fromObject (_Description, attribValue)));
}
else if (attribName.equals (FIELD_ReceivedDate))
{
setReceivedDate ((Date)(HELPER_ReceivedDate.fromObject (_ReceivedDate, attribValue)));
}
else
{
super.setAttribute (attribName, attribValue);
}
}
public boolean isWriteable (String fieldName)
{
return getWriteable (fieldName) == FieldWriteability.TRUE;
}
public FieldWriteability getWriteable (String fieldName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (fieldName.equals (FIELD_MessageId))
{
return getWriteability_MessageId ();
}
else if (fieldName.equals (FIELD_EmailFrom))
{
return getWriteability_EmailFrom ();
}
else if (fieldName.equals (FIELD_EmailTo))
{
return getWriteability_EmailTo ();
}
else if (fieldName.equals (FIELD_EmailCC))
{
return getWriteability_EmailCC ();
}
else if (fieldName.equals (FIELD_Subject))
{
return getWriteability_Subject ();
}
else if (fieldName.equals (FIELD_Description))
{
return getWriteability_Description ();
}
else if (fieldName.equals (FIELD_ReceivedDate))
{
return getWriteability_ReceivedDate ();
}
else if (fieldName.equals (MULTIPLEREFERENCE_Attachments))
{
return getWriteability_Attachments ();
}
else if (fieldName.equals (SINGLEREFERENCE_Job))
{
return getWriteability_Job ();
}
else
{
return super.getWriteable (fieldName);
}
}
public void putUnwriteable (Set<String> fields)
{
if (getWriteability_MessageId () != FieldWriteability.TRUE)
{
fields.add (FIELD_MessageId);
}
if (getWriteability_EmailFrom () != FieldWriteability.TRUE)
{
fields.add (FIELD_EmailFrom);
}
if (getWriteability_EmailTo () != FieldWriteability.TRUE)
{
fields.add (FIELD_EmailTo);
}
if (getWriteability_EmailCC () != FieldWriteability.TRUE)
{
fields.add (FIELD_EmailCC);
}
if (getWriteability_Subject () != FieldWriteability.TRUE)
{
fields.add (FIELD_Subject);
}
if (getWriteability_Description () != FieldWriteability.TRUE)
{
fields.add (FIELD_Description);
}
if (getWriteability_ReceivedDate () != FieldWriteability.TRUE)
{
fields.add (FIELD_ReceivedDate);
}
super.putUnwriteable (fields);
}
public List<AbstractAttribute> getAttributes ()
{
List result = super.getAttributes ();
result.add(HELPER_MessageId.getAttribObject (getClass (), _MessageId, false, FIELD_MessageId));
result.add(HELPER_EmailFrom.getAttribObject (getClass (), _EmailFrom, true, FIELD_EmailFrom));
result.add(HELPER_EmailTo.getAttribObject (getClass (), _EmailTo, true, FIELD_EmailTo));
result.add(HELPER_EmailCC.getAttribObject (getClass (), _EmailCC, false, FIELD_EmailCC));
result.add(HELPER_Subject.getAttribObject (getClass (), _Subject, false, FIELD_Subject));
result.add(HELPER_Description.getAttribObject (getClass (), _Description, false, FIELD_Description));
result.add(HELPER_ReceivedDate.getAttribObject (getClass (), _ReceivedDate, true, FIELD_ReceivedDate));
return result;
}
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_EmailMessage.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_EmailMessage.get (attribute);
}
else
{
return super.getAttributeMetadata (attribute);
}
}
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_EmailMessage.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_EmailMessage.get (attribute)).get(metadata);
}
else
{
return super.getAttributeMetadata (attribute, metadata);
}
}
public void preCommit (boolean willBeStored) throws Exception
{
super.preCommit(willBeStored);
if(willBeStored)
{
}
}
public oneit.servlets.objstore.binary.BinaryContentHandler getBinaryContentHandler(String attribName)
{
return super.getBinaryContentHandler(attribName);
}
public static class EmailMessageBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<EmailMessage>
{
/**
* Get the attribute MessageId
*/
public String getMessageId (EmailMessage obj, String original)
{
return original;
}
/**
* Change the value set for attribute MessageId.
* May modify the field beforehand
* Occurs before validation.
*/
public String setMessageId (EmailMessage obj, String newMessageId) throws FieldException
{
return newMessageId;
}
/**
* Get the attribute EmailFrom
*/
public String getEmailFrom (EmailMessage obj, String original)
{
return original;
}
/**
* Change the value set for attribute EmailFrom.
* May modify the field beforehand
* Occurs before validation.
*/
public String setEmailFrom (EmailMessage obj, String newEmailFrom) throws FieldException
{
return newEmailFrom;
}
/**
* Get the attribute EmailTo
*/
public String getEmailTo (EmailMessage obj, String original)
{
return original;
}
/**
* Change the value set for attribute EmailTo.
* May modify the field beforehand
* Occurs before validation.
*/
public String setEmailTo (EmailMessage obj, String newEmailTo) throws FieldException
{
return newEmailTo;
}
/**
* Get the attribute EmailCC
*/
public String getEmailCC (EmailMessage obj, String original)
{
return original;
}
/**
* Change the value set for attribute EmailCC.
* May modify the field beforehand
* Occurs before validation.
*/
public String setEmailCC (EmailMessage obj, String newEmailCC) throws FieldException
{
return newEmailCC;
}
/**
* Get the attribute Subject
*/
public String getSubject (EmailMessage obj, String original)
{
return original;
}
/**
* Change the value set for attribute Subject.
* May modify the field beforehand
* Occurs before validation.
*/
public String setSubject (EmailMessage obj, String newSubject) throws FieldException
{
return newSubject;
}
/**
* Get the attribute Description
*/
public String getDescription (EmailMessage obj, String original)
{
return original;
}
/**
* Change the value set for attribute Description.
* May modify the field beforehand
* Occurs before validation.
*/
public String setDescription (EmailMessage obj, String newDescription) throws FieldException
{
return newDescription;
}
/**
* Get the attribute ReceivedDate
*/
public Date getReceivedDate (EmailMessage obj, Date original)
{
return original;
}
/**
* Change the value set for attribute ReceivedDate.
* May modify the field beforehand
* Occurs before validation.
*/
public Date setReceivedDate (EmailMessage obj, Date newReceivedDate) throws FieldException
{
return newReceivedDate;
}
}
public ORMPipeLine pipes()
{
return new EmailMessagePipeLineFactory<EmailMessage, EmailMessage> ((EmailMessage)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public EmailMessagePipeLineFactory<EmailMessage, EmailMessage> pipelineEmailMessage()
{
return (EmailMessagePipeLineFactory<EmailMessage, EmailMessage>) pipes();
}
public static EmailMessagePipeLineFactory<EmailMessage, EmailMessage> pipesEmailMessage(Collection<EmailMessage> items)
{
return REFERENCE_EmailMessage.new EmailMessagePipeLineFactory<EmailMessage, EmailMessage> (items);
}
public static EmailMessagePipeLineFactory<EmailMessage, EmailMessage> pipesEmailMessage(EmailMessage[] _items)
{
return pipesEmailMessage(Arrays.asList (_items));
}
public static EmailMessagePipeLineFactory<EmailMessage, EmailMessage> pipesEmailMessage()
{
return pipesEmailMessage((Collection)null);
}
public class EmailMessagePipeLineFactory<From extends BaseBusinessClass, Me extends EmailMessage> extends BaseBusinessClass.ORMPipeLine<From, Me>
{
public <Prev> EmailMessagePipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public EmailMessagePipeLineFactory (From seed)
{
super(seed);
}
public EmailMessagePipeLineFactory (Collection<From> seed)
{
super(seed);
}
public PipeLine<From, ? extends Object> to(String name)
{
if (name.equals ("Attachments"))
{
return toAttachments ();
}
if (name.equals ("MessageId"))
{
return toMessageId ();
}
if (name.equals ("EmailFrom"))
{
return toEmailFrom ();
}
if (name.equals ("EmailTo"))
{
return toEmailTo ();
}
if (name.equals ("EmailCC"))
{
return toEmailCC ();
}
if (name.equals ("Subject"))
{
return toSubject ();
}
if (name.equals ("Description"))
{
return toDescription ();
}
if (name.equals ("ReceivedDate"))
{
return toReceivedDate ();
}
if (name.equals ("Job"))
{
return toJob ();
}
return super.to(name);
}
public PipeLine<From, String> toMessageId () { return pipe(new ORMAttributePipe<Me, String>(FIELD_MessageId)); }
public PipeLine<From, String> toEmailFrom () { return pipe(new ORMAttributePipe<Me, String>(FIELD_EmailFrom)); }
public PipeLine<From, String> toEmailTo () { return pipe(new ORMAttributePipe<Me, String>(FIELD_EmailTo)); }
public PipeLine<From, String> toEmailCC () { return pipe(new ORMAttributePipe<Me, String>(FIELD_EmailCC)); }
public PipeLine<From, String> toSubject () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Subject)); }
public PipeLine<From, String> toDescription () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Description)); }
public PipeLine<From, Date> toReceivedDate () { return pipe(new ORMAttributePipe<Me, Date>(FIELD_ReceivedDate)); }
public Job.JobPipeLineFactory<From, Job> toJob () { return toJob (Filter.ALL); }
public Job.JobPipeLineFactory<From, Job> toJob (Filter<Job> filter)
{
return Job.REFERENCE_Job.new JobPipeLineFactory<From, Job> (this, new ORMSingleAssocPipe<Me, Job>(SINGLEREFERENCE_Job, filter));
}
public Attachment.AttachmentPipeLineFactory<From, Attachment> toAttachments () { return toAttachments(Filter.ALL); }
public Attachment.AttachmentPipeLineFactory<From, Attachment> toAttachments (Filter<Attachment> filter)
{
return Attachment.REFERENCE_Attachment.new AttachmentPipeLineFactory<From, Attachment> (this, new ORMMultiAssocPipe<Me, Attachment>(MULTIPLEREFERENCE_Attachments, filter));
}
}
public boolean isTransientAttrib(String attribName)
{
return super.isTransientAttrib(attribName);
}
public boolean isTransientSingleReference(String assocName)
{
return super.isTransientSingleReference(assocName);
}
}
class DummyEmailMessage extends EmailMessage
{
// Default constructor primarily to support Externalisable
public DummyEmailMessage()
{
super();
}
public void assertValid ()
{
}
public Job getJob () throws StorageException
{
return (Job)(Job.DUMMY_Job);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getJobID ()
{
return Job.DUMMY_Job.getObjectID();
}
public int getAttachmentsCount () throws StorageException
{
return 0;
}
public Attachment getAttachmentsAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association Attachments");
}
public SortedSet getAttachmentsSet () throws StorageException
{
return new TreeSet();
}
}
package performa.orm;
public class EmailMessage extends BaseEmailMessage
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public EmailMessage ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.oneit.com.au/schemas/5.2/BusinessObject.xsd'>
<BUSINESSCLASS name="EmailMessage" package="performa.orm">
<MULTIPLEREFERENCE name="Attachments" type="Attachment" backreferenceName="EmailMessage"/>
<TABLE name="tl_email_message" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="MessageId" type="String" dbcol="message_id" length="1000" />
<ATTRIB name="EmailFrom" type="String" dbcol="email_from" length="500" mandatory="true"/>
<ATTRIB name="EmailTo" type="String" dbcol="email_to" length="500" mandatory="true"/>
<ATTRIB name="EmailCC" type="String" dbcol="email_cc" length="500" />
<ATTRIB name="Subject" type="String" dbcol="subject" length="1000" />
<ATTRIB name="Description" type="String" dbcol="description" />
<ATTRIB name="ReceivedDate" type="Date" dbcol="received_date" mandatory="true"/>
<SINGLEREFERENCE name="Job" type="Job" dbcol="job_id" />
</TABLE>
<SEARCH type="All" paramFilter="tl_email_message.object_id is not null"/>
</BUSINESSCLASS>
</ROOT>
\ No newline at end of file
package performa.orm;
import java.io.*;
import java.util.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.rdbms.*;
import oneit.objstore.utils.*;
import oneit.sql.*;
import oneit.utils.resource.*;
import oneit.utils.*;
import oneit.utils.threading.*;
/**
* IMPORTANT!!!! Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2[oneit.objstore.PersistenceMgrTemplate.xsl]
*/
public class EmailMessagePersistenceMgr extends ObjectPersistenceMgr
{
private static final LoggingArea EmailMessagePersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "EmailMessage");
// Private attributes corresponding to business object data
private String dummyMessageId;
private String dummyEmailFrom;
private String dummyEmailTo;
private String dummyEmailCC;
private String dummySubject;
private String dummyDescription;
private Date dummyReceivedDate;
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_MessageId = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_EmailFrom = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_EmailTo = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_EmailCC = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_Subject = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_Description = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_ReceivedDate = DefaultAttributeHelper.INSTANCE;
public EmailMessagePersistenceMgr ()
{
dummyMessageId = (String)(HELPER_MessageId.initialise (dummyMessageId));
dummyEmailFrom = (String)(HELPER_EmailFrom.initialise (dummyEmailFrom));
dummyEmailTo = (String)(HELPER_EmailTo.initialise (dummyEmailTo));
dummyEmailCC = (String)(HELPER_EmailCC.initialise (dummyEmailCC));
dummySubject = (String)(HELPER_Subject.initialise (dummySubject));
dummyDescription = (String)(HELPER_Description.initialise (dummyDescription));
dummyReceivedDate = (Date)(HELPER_ReceivedDate.initialise (dummyReceivedDate));
}
private String SELECT_COLUMNS = "{PREFIX}tl_email_message.object_id as id, {PREFIX}tl_email_message.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_email_message.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_email_message.message_id, {PREFIX}tl_email_message.email_from, {PREFIX}tl_email_message.email_to, {PREFIX}tl_email_message.email_cc, {PREFIX}tl_email_message.subject, {PREFIX}tl_email_message.description, {PREFIX}tl_email_message.received_date, {PREFIX}tl_email_message.job_id, 1 AS commasafe ";
private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
Set<BaseBusinessClass> resultByIDs = fetchByIDs(Collections.singleton (id), allPSets, context, sqlMgr);
if (resultByIDs.isEmpty ())
{
return null;
}
else if (resultByIDs.size () > 1)
{
throw new StorageException ("Multiple results for id:" + id);
}
else
{
return resultByIDs.iterator ().next ();
}
}
public Set<BaseBusinessClass> fetchByIDs(Set<ObjectID> ids, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
Set<BaseBusinessClass> results = new HashSet ();
Set<Long> idsToFetch = new HashSet ();
for (ObjectID id : ids)
{
if (context.containsObject(id)) // Check for cached version
{
BaseBusinessClass objectToReturn = context.getObjectToReplace(id, EmailMessage.REFERENCE_EmailMessage);
if (objectToReturn instanceof EmailMessage)
{
LogMgr.log (EmailMessagePersistence, LogLevel.TRACE, "Cache hit for id:", id);
results.add (objectToReturn);
}
else
{
throw new StorageException ("Cache collision for id:" + id + " with object " + objectToReturn + "while fetching a EmailMessage");
}
}
PersistentSet tl_email_messagePSet = allPSets.getPersistentSet(id, "tl_email_message", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched
if (false || !tl_email_messagePSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!tl_email_messagePSet.containsAttrib(EmailMessage.FIELD_MessageId)||
!tl_email_messagePSet.containsAttrib(EmailMessage.FIELD_EmailFrom)||
!tl_email_messagePSet.containsAttrib(EmailMessage.FIELD_EmailTo)||
!tl_email_messagePSet.containsAttrib(EmailMessage.FIELD_EmailCC)||
!tl_email_messagePSet.containsAttrib(EmailMessage.FIELD_Subject)||
!tl_email_messagePSet.containsAttrib(EmailMessage.FIELD_Description)||
!tl_email_messagePSet.containsAttrib(EmailMessage.FIELD_ReceivedDate)||
!tl_email_messagePSet.containsAttrib(EmailMessage.SINGLEREFERENCE_Job))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (EmailMessagePersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Non Polymorphic */
EmailMessage result = new EmailMessage ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_email_message " +
"WHERE " + SELECT_JOINS + "{PREFIX}tl_email_message.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
for (BaseBusinessClass objFetched : resultsFetched)
{
results.add (objFetched);
}
}
return results;
}
public BaseBusinessClass[] getReferencedObjects(ObjectID _objectID, String refName, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
if (false)
{
throw new RuntimeException ();
}
else
{
throw new IllegalArgumentException ("Illegal reference type:" + refName);
}
}
public void update(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{
EqualityResult test = EqualityResult.compare (obj, obj.getBackup ());
ObjectID objectID = obj.getID ();
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{
PersistentSet tl_email_messagePSet = allPSets.getPersistentSet(objectID, "tl_email_message");
if (tl_email_messagePSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_email_messagePSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_email_message " +
"SET message_id = ?, email_from = ?, email_to = ?, email_cc = ?, subject = ?, description = ?, received_date = ?, job_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_email_message.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_MessageId.getForSQL(dummyMessageId, tl_email_messagePSet.getAttrib (EmailMessage.FIELD_MessageId))).listEntry (HELPER_EmailFrom.getForSQL(dummyEmailFrom, tl_email_messagePSet.getAttrib (EmailMessage.FIELD_EmailFrom))).listEntry (HELPER_EmailTo.getForSQL(dummyEmailTo, tl_email_messagePSet.getAttrib (EmailMessage.FIELD_EmailTo))).listEntry (HELPER_EmailCC.getForSQL(dummyEmailCC, tl_email_messagePSet.getAttrib (EmailMessage.FIELD_EmailCC))).listEntry (HELPER_Subject.getForSQL(dummySubject, tl_email_messagePSet.getAttrib (EmailMessage.FIELD_Subject))).listEntry (HELPER_Description.getForSQL(dummyDescription, tl_email_messagePSet.getAttrib (EmailMessage.FIELD_Description))).listEntry (HELPER_ReceivedDate.getForSQL(dummyReceivedDate, tl_email_messagePSet.getAttrib (EmailMessage.FIELD_ReceivedDate))).listEntry (SQLManager.CheckNull((Long)(tl_email_messagePSet.getAttrib (EmailMessage.SINGLEREFERENCE_Job)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1)
{
// Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr,
"SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}tl_email_message WHERE object_id = ?",
new Object[] { objectID.longID () });
if (r.next ())
{
Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "tl_email_message", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (EmailMessagePersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "tl_email_message");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:tl_email_message for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (EmailMessagePersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_email_messagePSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (EmailMessagePersistence, LogLevel.DEBUG1, "Skipping update since no attribs or simple assocs changed on ", objectID);
}
}
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet tl_email_messagePSet = allPSets.getPersistentSet(objectID, "tl_email_message");
LogMgr.log (EmailMessagePersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (tl_email_messagePSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_email_messagePSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}tl_email_message " +
"WHERE tl_email_message.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1)
{
// Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}tl_email_message WHERE object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "tl_email_message");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:tl_email_message for row:" + objectID;
LogMgr.log (EmailMessagePersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_email_messagePSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
public ResultSet executeSearchQueryAll (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
}
public BaseBusinessClass[] loadQuery (PersistentSetCollection allPSets, SQLManager sqlMgr, RDBMSPersistenceContext context, String query, Object[] params, Integer maxRows, boolean truncateExtra) throws SQLException, StorageException
{
LinkedHashMap<ObjectID, EmailMessage> results = new LinkedHashMap ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (EmailMessage.REFERENCE_EmailMessage.getObjectIDSpace (), r.getLong ("id"));
EmailMessage resultElement;
if (maxRows != null && !results.containsKey (objectID) && results.size () >= maxRows)
{
if (truncateExtra)
{
break;
}
else
{
throw new SearchRowsExceededException ("Maximum rows exceeded:" + maxRows);
}
}
if (context.containsObject(objectID))
{
BaseBusinessClass cachedElement = context.getObjectToReplace(objectID, EmailMessage.REFERENCE_EmailMessage);
if (cachedElement instanceof EmailMessage)
{
LogMgr.log (EmailMessagePersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (EmailMessage)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a EmailMessage");
}
}
else
{
PersistentSet tl_email_messagePSet = allPSets.getPersistentSet(objectID, "tl_email_message", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
resultElement = new EmailMessage ();
resultElement.setFromPersistentSets(objectID, allPSets);
context.addRetrievedObject(resultElement);
}
results.put (objectID, resultElement);
}
BaseBusinessClass[] resultsArr = new BaseBusinessClass[results.size ()];
return results.values ().toArray (resultsArr);
}
public BaseBusinessClass[] find(String searchType, PersistentSetCollection allPSets, Hashtable criteria, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
LogMgr.log (EmailMessagePersistence, LogLevel.DEBUG2, "Search executing:", searchType, " criteria:", criteria);
String customParamFilter = (String)criteria.get (SEARCH_CustomFilter);
String customOrderBy = (String)criteria.get (SEARCH_OrderBy);
String customTables = (String)criteria.get (SEARCH_CustomExtraTables);
Boolean noCommaBeforeCustomExtraTables = (Boolean)criteria.get (SEARCH_CustomExtraTablesNoComma);
if (searchType.equals (SEARCH_CustomSQL))
{
Set<ObjectID> processedIDs = new HashSet();
SearchParamTransform tx = new SearchParamTransform (criteria);
Object[] searchParams;
customParamFilter = StringUtils.replaceParams (customParamFilter, tx);
searchParams = tx.getParamsArray();
if (customOrderBy != null)
{
customOrderBy = " ORDER BY " + customOrderBy;
}
else
{
customOrderBy = "";
}
ResultSet r;
String concatCustomTableWith = CollectionUtils.equals(noCommaBeforeCustomExtraTables, true) ? " " : ", ";
String tables = StringUtils.subBlanks(customTables) == null ? " " : concatCustomTableWith + customTables + " ";
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_email_message " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else if (searchType.equals (EmailMessage.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: tl_email_message.object_id is not null
String preFilter = "(tl_email_message.object_id is not null)"
+ " ";
preFilter += context.getLoadingAttributes ().getCustomSQL() ;
SearchParamTransform tx = new SearchParamTransform (criteria);
filter = StringUtils.replaceParams (preFilter, tx);
searchParams = tx.getParamsArray();
Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_email_message " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else
{
throw new IllegalArgumentException ("Illegal search type:" + searchType);
}
}
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{
PersistentSet tl_email_messagePSet = allPSets.getPersistentSet(objectID, "tl_email_message", PersistentSetStatus.FETCHED);
// Object Modified
tl_email_messagePSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
tl_email_messagePSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
tl_email_messagePSet.setAttrib(EmailMessage.FIELD_MessageId, HELPER_MessageId.getFromRS(dummyMessageId, r, "message_id"));
tl_email_messagePSet.setAttrib(EmailMessage.FIELD_EmailFrom, HELPER_EmailFrom.getFromRS(dummyEmailFrom, r, "email_from"));
tl_email_messagePSet.setAttrib(EmailMessage.FIELD_EmailTo, HELPER_EmailTo.getFromRS(dummyEmailTo, r, "email_to"));
tl_email_messagePSet.setAttrib(EmailMessage.FIELD_EmailCC, HELPER_EmailCC.getFromRS(dummyEmailCC, r, "email_cc"));
tl_email_messagePSet.setAttrib(EmailMessage.FIELD_Subject, HELPER_Subject.getFromRS(dummySubject, r, "subject"));
tl_email_messagePSet.setAttrib(EmailMessage.FIELD_Description, HELPER_Description.getFromRS(dummyDescription, r, "description"));
tl_email_messagePSet.setAttrib(EmailMessage.FIELD_ReceivedDate, HELPER_ReceivedDate.getFromRS(dummyReceivedDate, r, "received_date"));
tl_email_messagePSet.setAttrib(EmailMessage.SINGLEREFERENCE_Job, r.getObject ("job_id"));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet tl_email_messagePSet = allPSets.getPersistentSet(objectID, "tl_email_message");
if (tl_email_messagePSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_email_messagePSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_email_message " +
" (message_id, email_from, email_to, email_cc, subject, description, received_date, job_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" (?, ?, ?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_MessageId.getForSQL(dummyMessageId, tl_email_messagePSet.getAttrib (EmailMessage.FIELD_MessageId))).listEntry (HELPER_EmailFrom.getForSQL(dummyEmailFrom, tl_email_messagePSet.getAttrib (EmailMessage.FIELD_EmailFrom))).listEntry (HELPER_EmailTo.getForSQL(dummyEmailTo, tl_email_messagePSet.getAttrib (EmailMessage.FIELD_EmailTo))).listEntry (HELPER_EmailCC.getForSQL(dummyEmailCC, tl_email_messagePSet.getAttrib (EmailMessage.FIELD_EmailCC))).listEntry (HELPER_Subject.getForSQL(dummySubject, tl_email_messagePSet.getAttrib (EmailMessage.FIELD_Subject))).listEntry (HELPER_Description.getForSQL(dummyDescription, tl_email_messagePSet.getAttrib (EmailMessage.FIELD_Description))).listEntry (HELPER_ReceivedDate.getForSQL(dummyReceivedDate, tl_email_messagePSet.getAttrib (EmailMessage.FIELD_ReceivedDate))) .listEntry (SQLManager.CheckNull((Long)(tl_email_messagePSet.getAttrib (EmailMessage.SINGLEREFERENCE_Job)))) .listEntry (objectID.longID ()).toList().toArray());
tl_email_messagePSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
package performa.utils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import javax.mail.BodyPart;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Part;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.UIDFolder;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.search.AndTerm;
import javax.mail.search.ComparisonTerm;
import javax.mail.search.ReceivedDateTerm;
import javax.mail.search.SearchTerm;
import javax.mail.search.SentDateTerm;
import oneit.appservices.config.ConfigMgr;
import oneit.components.InitialisationParticipant;
import oneit.components.ParticipantInitialisationContext;
import oneit.email.EmailFetcher;
import oneit.logging.LogLevel;
import oneit.logging.LogMgr;
import oneit.logging.LoggingArea;
import oneit.objstore.FileBinaryContent;
import oneit.objstore.ObjectTransaction;
import oneit.objstore.StorageException;
import oneit.objstore.services.TransactionServices;
import oneit.objstore.services.TransactionTask;
import oneit.utils.DateDiff;
import oneit.utils.IOUtils;
import oneit.utils.InitialisationException;
import oneit.utils.NestedException;
import oneit.utils.StringUtils;
import oneit.utils.parsers.FieldException;
import performa.orm.Attachment;
import performa.orm.EmailMessage;
import performa.orm.Job;
public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
{
private static final String SERVER_NAME = ConfigMgr.getKeyfileString("imap.server.name");
private static final String SERVER_PORT = ConfigMgr.getKeyfileString("imap.server.port");
private static final String SERVER_PROTOCOL = ConfigMgr.getKeyfileString("imap.server.protocol", "imap");
private static final String ACC_USER_NAME = ConfigMgr.getKeyfileString("imap.email.acc.username");
private static final String ACC_PASSWORD = ConfigMgr.getKeyfileString("imap.email.acc.password");
private static final boolean SYNC_ALL_EXISTING_EMAILS = ConfigMgr.getKeyfileBoolean("sync.all.existing.emails", false);
private static final Integer SYNC_EMAILS_SINCE_MINUTES = ConfigMgr.getKeyfileInt("sync.emails.since.minutes", 90); //Applicable only when SYNC_ALL_EXISTING_EMAILS is false.
public static final LoggingArea LOG = LoggingArea.createLoggingArea("PerformaEmailFetcher");
@Override
public void run()
{
LogMgr.log(LOG, LogLevel.PROCESSING1, "Inside Run of PerformaEmailFetcher");
List<String> visitedNodes = new ArrayList<>();
runEmailFetcher(visitedNodes);
}
public static void runEmailFetcher(List<String> visitedNodes)
{
LogMgr.log(LOG, LogLevel.PROCESSING1, "Executing email fetcher Name:", SERVER_NAME, " Port:"+ SERVER_PORT, " Protocol:"+ SERVER_PROTOCOL, " UserName:", ACC_USER_NAME);
LogMgr.log(LOG, LogLevel.PROCESSING1, "Email syncing details:: Sync All:", SYNC_ALL_EXISTING_EMAILS, " Sync from last:"+ SYNC_EMAILS_SINCE_MINUTES);
if(StringUtils.subBlanks(SERVER_NAME) != null && StringUtils.subBlanks(SERVER_PORT) != null &&
StringUtils.subBlanks(ACC_USER_NAME) != null && StringUtils.subBlanks(ACC_PASSWORD) != null)
{
final Object[] dummyContainer = new Object[1];
Store store = null;
try
{
TransactionServices.run(new TransactionTask()
{
@Override
public void run(ObjectTransaction objTran) throws FieldException, StorageException
{
EmailMessage[] emailMessages = EmailMessage.searchAll(objTran);
dummyContainer[0] = EmailMessage.pipesEmailMessage(emailMessages).toMessageId().uniqueVals();
}
});
Set<String> messageIDs = new HashSet();
if(dummyContainer[0] != null)
{
messageIDs = (Set<String>)dummyContainer[0];
}
Session session = Session.getInstance(getEMailProperties());
store = session.getStore(SERVER_PROTOCOL);
store.connect(SERVER_NAME, ACC_USER_NAME, ACC_PASSWORD);
LogMgr.log(LOG, LogLevel.PROCESSING1, "Mail connection done successfully");
Folder[] folders = store.getDefaultFolder().list("*");
for (Folder folder : folders)
{
if ((folder.getType() & Folder.HOLDS_MESSAGES) != 0)
{
LogMgr.log(LOG, LogLevel.PROCESSING1, "Processing folder " + folder.getFullName());
visitedNodes.add(folder.getFullName());
processFolder(folder, messageIDs, visitedNodes);
}
else
{
LogMgr.log(LOG, LogLevel.PROCESSING1, "Skipping folder " + folder.getFullName());
}
}
LogMgr.log(LOG, LogLevel.PROCESSING1, "Email fetcher batch completed successfully.");
}
catch (Exception e)
{
LogMgr.log(LOG, LogLevel.SYSTEMERROR1, e, "Email Fetcher : error occurred");
}
finally
{
try
{
if (store != null)
{
store.close();
}
}
catch (Exception e2)
{
LogMgr.log(LOG, LogLevel.BUSINESS2, "Email Fetcher : Problem closing email store", e2);
}
}
}
else
{
LogMgr.log(LOG, LogLevel.PROCESSING1, "Email fetcher batch skipped as server propertied not defined.");
}
}
private static Properties getEMailProperties()
{
Properties properties = System.getProperties();
// Mail-server-properties will be configured based on given emailServerProtocol i.e. imap(s) or pop3(s)
properties.put("mail.store.protocol", SERVER_PROTOCOL);
properties.put("mail." + SERVER_PROTOCOL +".host", SERVER_NAME);
properties.put("mail." + SERVER_PROTOCOL +".port", SERVER_PORT);
properties.put("mail." + SERVER_PROTOCOL +".starttls.enable", "true");
return properties;
}
private static void processFolder(Folder folder, Set<String> messageIDs, List<String> visitedNodes) throws Exception
{
LogMgr.log(LOG, LogLevel.PROCESSING1, "processFolder called for ", folder != null ? folder.getName() : "");
if(folder != null)
{
try
{
readMessagesInFolder(folder, messageIDs);
for(Folder subfolder : folder.list())
{
visitedNodes.add(subfolder.getFullName());
processFolder(subfolder, messageIDs, visitedNodes);
}
}
catch (Exception e)
{
LogMgr.log(LOG, LogLevel.SYSTEMERROR1, e, "Email Fetcher : error occurred");
throw e;
}
finally
{
try
{
folder.close(true);
}
catch (Exception ex2)
{
LogMgr.log(LOG, LogLevel.BUSINESS2, "Email Fetcher : Problem closing email store", ex2);
}
}
}
LogMgr.log(LOG, LogLevel.PROCESSING1, "processFolder completed for ", folder != null ? folder.getName() : "");
}
private static void readMessagesInFolder(Folder folder, Set<String> messageIDs) throws MessagingException
{
LogMgr.log(LOG, LogLevel.PROCESSING1, "readMessagesInFolder called for ", folder.getName());
UIDFolder uidFolder = (UIDFolder)folder;
try
{
folder.open(Folder.READ_ONLY);
}
catch(Exception ex)
{
LogMgr.log(LOG, LogLevel.PROCESSING1, "Skipping messages for folder ", folder.getName(), " as unable to open same.");
return;
}
Message[] messages;
SearchTerm searchTerm = getSearchTerm();
if(searchTerm == null)
{
messages = folder.getMessages();
}
else
{
messages = folder.search(searchTerm);
}
LogMgr.log(LOG, LogLevel.PROCESSING1, "Number of messages to be processed in ", folder.getName(), ": ", messages.length);
for(Message message : messages)
{
processMessage(message, uidFolder, messageIDs);
}
LogMgr.log(LOG, LogLevel.PROCESSING1, "readMessagesInFolder completed for ", folder.getName());
}
private static SearchTerm getSearchTerm ()
{
if(!SYNC_ALL_EXISTING_EMAILS)
{
SearchTerm receivedFrom = new ReceivedDateTerm(ComparisonTerm.GE, getSyncingFromDate());
SearchTerm sentFrom = new SentDateTerm(ComparisonTerm.GE, getSyncingFromDate());
return new AndTerm(receivedFrom, sentFrom);
}
return null;
}
public static void processMessage(Message message, UIDFolder uidFolder, final Set<String> messageIDs)
{
LogMgr.log(LOG, LogLevel.PROCESSING2 , "processMessage called");
String tmpFromAdress = null;
String tmpEmailText;
String tmpSubject;
Date tmpSentDate;
String tmpRecipient = null;
String tmpJobId = null;
String tmpMessageID = null;
List<FileBinaryContent> tmpContents;
final String fromAddress;
final String recipient;
final String subject;
final Date sentDate;
final String emailText;
final String jobIdentifier;
final String messageID;
final List<FileBinaryContent> contents;
try
{
if(message.getFrom() != null && message.getFrom().length > 0)
{
tmpFromAdress = ((InternetAddress) message.getFrom()[0]).getAddress();
}
tmpSubject = message.getSubject();
tmpSentDate = message.getReceivedDate();
tmpMessageID = ((MimeMessage)message).getMessageID();
LogMgr.log(LOG, LogLevel.PROCESSING2 , "Mail Subject:" + tmpSubject, " Address:", tmpFromAdress, " MessageId:", tmpMessageID);
LogMgr.log(LOG, LogLevel.PROCESSING2 , "Mail Details: Received ", message.getReceivedDate(), " Sent:", message.getSentDate());
if(message.getAllRecipients() != null && message.getAllRecipients().length > 0)
{
tmpRecipient = ((InternetAddress) message.getAllRecipients()[0]).getAddress();
}
if(StringUtils.subBlanks(tmpRecipient) != null)
{
tmpJobId = getJobIdentifierFromEmail(tmpRecipient);
}
tmpEmailText = EmailFetcher.getText(message, new ArrayList<>());
tmpContents = getAttachments(message);
}
catch (MessagingException | IOException ex)
{
LogMgr.log(LOG, LogLevel.PROCESSING2 , "Batch Email Fetcher : Mail message composing error", ex);
throw new NestedException(ex);
}
fromAddress = tmpFromAdress;
subject = tmpSubject;
sentDate = tmpSentDate;
jobIdentifier = tmpJobId;
recipient = tmpRecipient;
contents = tmpContents;
emailText = tmpEmailText;
messageID = tmpMessageID;
try
{
if(!messageIDs.contains(messageID))
{
TransactionServices.run(new TransactionTask()
{
@Override
public void run(ObjectTransaction objTran) throws FieldException, StorageException
{
if (jobIdentifier != null && !jobIdentifier.isEmpty())
{
Job job = Job.getJobByID(objTran, Long.parseLong(jobIdentifier));
if (job != null)
{
EmailMessage emailMessage = EmailMessage.createEmailMessage(objTran);
emailMessage.setMessageId(messageID);
emailMessage.setEmailFrom(fromAddress);
emailMessage.setEmailTo(recipient);
emailMessage.setSubject(subject);
emailMessage.setDescription(emailText);
emailMessage.setReceivedDate(sentDate);
emailMessage.setJob(job);
for (FileBinaryContent content : contents)
{
Attachment attachment = Attachment.createAttachment(objTran);
attachment.setAttachmentFile(content);
emailMessage.addToAttachments(attachment);
}
}
}
}
});
LogMgr.log(LOG, LogLevel.PROCESSING2 , "processMessage completed successfully");
messageIDs.add(messageID);
}
else
{
LogMgr.log(LOG, LogLevel.PROCESSING2 , "Message already synced or doesnt have valid sent time ", sentDate);
}
}
catch (Exception e)
{
LogMgr.log(LOG, LogLevel.PROCESSING2 , e, "Batch Email Fetcher : Error in creating the email message ");
}
}
public static String getJobIdentifierFromEmail(String strReceipient)
{
int index = strReceipient.indexOf('@');
return strReceipient.substring(0, index);
}
private static List<FileBinaryContent> getAttachments(Message message) throws IOException, MessagingException
{
List<FileBinaryContent> contents = new ArrayList<>();
if(message.getContentType() != null && message.getContentType().contains("multipart"))
{
Multipart multipart = (Multipart)message.getContent();
byte[] bytes = null;
for (int j = 0; j < multipart.getCount(); j++)
{
BodyPart bodyPart = multipart.getBodyPart(j);
if(Part.ATTACHMENT.equalsIgnoreCase(bodyPart.getDisposition()))
{
bytes = IOUtils.readInputStreamToBytes(bodyPart.getInputStream());
FileBinaryContent binaryContent = new FileBinaryContent(bodyPart.getContentType(), bytes, bodyPart.getFileName());
contents.add(binaryContent);
}
}
}
return contents;
}
private static Date getSyncingFromDate()
{
return DateDiff.before(new Date(), SYNC_EMAILS_SINCE_MINUTES, Calendar.MINUTE);
}
@Override
public void init(ParticipantInitialisationContext pic) throws InitialisationException
{
throw new UnsupportedOperationException("Not supported yet.");
}
}
......@@ -28,4 +28,9 @@
<INHERITS factory="Named" nodename="CoreORMAdmin"/>
</NODE>
<NODE name="test_imap_jsp" factory="Participant">
<INHERITS factory="Named" nodename="CoreORMAdmin"/>
<FORM name="*.runEmailFetcher" factory="Participant" class="performa.form.RunEmailFetcherFP"/>
</NODE>
</OBJECTS>
\ No newline at end of file
......@@ -31,4 +31,16 @@
<NODE name="DashboardTypes::Performa">
<MAP value="HOME_TL" description="HomePage" JSP="/extensions/performa/editor/additionalHomePage.jsp" />
</NODE>
<NODE name="WEB_BATCH::Email">
<TASK factory="Participant" class="oneit.appservices.batch.DefaultTask">
<RUN class="performa.utils.PerformaEmailFetcher" factory="Participant" />
<WHEN factory="MetaComponent" component="BatchSchedule" selector="performa.runbatch">
<NODE name="schedule" class="oneit.appservices.batch.QuickSchedule">
<NODE name="period" factory="Integer" value="5"/>
</NODE>
</WHEN>
</TASK>
</NODE>
</OBJECTS>
\ No newline at end of file
<%@ page extends="oneit.servlets.jsp.FormJSP" %>
<%@ include file="/setuprequest.jsp" %>
<%@ include file="inc/stdimports.jsp" %>
<%@ include file="../../../editor/stdimports.jsp" %>
<%! protected String getName (ServletConfig config) { return "test_imap_jsp"; } %>
<%
ORMProcessState process = (ORMProcessState) ProcessDecorator.getDefaultProcess(request);
ObjectTransaction objTran = process.getTransaction ();
request.setAttribute("oneit.pageFormDetails", CollectionUtils.mapEntry("name", "test_imap").mapEntry("enctype", "multipart/form-data").toMap());
request.setAttribute("oneit.pageHeaderTitle", "Test IMAP");
List<String> visitedNodes = (List<String>) request.getAttribute("VisitedNodes");
request.setAttribute("VisitedNodes", null);
%>
<%@include file="/editor/header.jsp" %>
<%
if(visitedNodes != null)
{
%>
<h3>Folders Visited</h3>
<%
for(String node : visitedNodes)
{
%>
<oneit:toString value="<%= node%>" mode="EscapeHTML"/> <br/>
<%
}
}
%>
<div class="bottomButtons" hidden="true">
<oneit:button value="Run" name="runEmailFetcher" cssClass="BUTTON_PRIMARY"
requestAttribs="<%= CollectionUtils.EMPTY_MAP %>"/>
</div>
<%@include file="/editor/footer.jsp" %>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au">
<NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">tl_attachment</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="attachment_name" type="String" nullable="true" length="100"/>
<column name="attachment_file" type="BLOB" nullable="true"/>
<column name="email_message_id" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_attachment" indexName="idx_tl_attachment_email_message_id" isUnique="false">
<column name="email_message_id"/>
</NODE>
</NODE>
</OBJECTS>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au">
<NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">tl_email_message</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="message_id" type="String" nullable="true" length="1000"/>
<column name="email_from" type="String" nullable="false" length="500"/>
<column name="email_to" type="String" nullable="false" length="500"/>
<column name="email_cc" type="String" nullable="true" length="500"/>
<column name="subject" type="String" nullable="true" length="1000"/>
<column name="description" type="CLOB" nullable="true"/>
<column name="received_date" type="Date" nullable="false"/>
<column name="job_id" type="Long" length="11" nullable="true"/>
</NODE>
</NODE>
</OBJECTS>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment