hasAccountInfo = true;
if ( hasAccountInfo )
{
DataInfo dataInfo = (DataInfo) dataMatrixMap.get("ACCOUNT.AccountHeader");
GenericEventProcessor eventProcessor = new AccountEventProcessor();
if ( (accountId != null) && ( accountId.length() > 0) )
{
dataInfo.retrieveFromDB(userInfo, eventProcessor, new GenericPK( delegator.getModelEntity("Account"), UtilMisc.toMap("accountId", accountId)));
dataInfo.processUpdate( userInfo, delegator, eventProcessor );
}
else
{
dataInfo.loadData(userInfo, eventProcessor);
dataInfo.processInsert( userInfo, delegator, eventProcessor );
}
GenericValue accountGV = dataInfo.dataMatrix.getCurrentBuffer().getGenericValue(0, "Account", false);
accountId = accountGV.getString("accountId");
accountName = accountGV.getString("accountName");
}
if ( getCreateContact())
{
DataInfo dataInfo = (DataInfo) dataMatrixMap.get("CONTACT.ContactHeader");
GenericEventProcessor eventProcessor = new ContactEventProcessor();
if ( (contactId != null) && (contactId.length() > 0))
{
dataInfo.retrieveFromDB(userInfo, eventProcessor, new GenericPK( delegator.getModelEntity("Contact"), UtilMisc.toMap("contactId", contactId)));
if ( hasAccountInfo )
{
GenericValue contactGV = dataInfo.dataMatrix.getCurrentBuffer().getGenericValue(0, "Contact", false);
String accountIdOrig = contactGV.getString("accountId");
if ( ( accountIdOrig == null ) || ( accountIdOrig.length() < 1) )
contactGV.set("accountId", accountId);
}
dataInfo.processUpdate( userInfo, delegator, eventProcessor );
}
else
{
dataInfo.loadData(userInfo, eventProcessor);
if ( hasAccountInfo )
dataInfo.dataMatrix.getCurrentBuffer().getGenericValue(0, "Contact", false).set("accountId", accountId);
dataInfo.processInsert( userInfo, delegator, eventProcessor );
}
GenericValue contactGV = dataInfo.dataMatrix.getCurrentBuffer().getGenericValue(0, "Contact", false);
contactId = contactGV.getString("contactId");
// Add ContactEmploymentInfo if there is an account tied to this record
if ( ( accountId != null) && ( accountId.length() > 0) )
{
GenericValue employmentGV = delegator.findByPrimaryKey("ContactEmployment", UtilMisc.toMap("contactEmploymentId", contactId + "-E"));
if ( employmentGV == null )
{
employmentGV = new GenericValue( delegator.getModelEntity("ContactEmployment"));
employmentGV.setDelegator(delegator);
employmentGV.set("contactEmploymentId", contactId + "-E");
employmentGV.set("contactId", contactId);
employmentGV.set("title", leadGV.getString("title"));
employmentGV.set("companyName", accountName);
if ( addressGV != null )
{
employmentGV.set("mailingAddress", addressGV.getString("mailingAddress"));
employmentGV.set("city", addressGV.getString("city"));
employmentGV.set("state", addressGV.getString("state"));
employmentGV.set("zip", addressGV.getString("zip"));
}
employmentGV.create();
}
}
}
if ( getCreateOpportunity() && hasAccountInfo)
{
DataInfo dataInfo = (DataInfo) dataMatrixMap.get("OPPORTUNITIES.OpportunityHeader");
GenericEventProcessor eventProcessor = new OpportunityEventProcessor();
DataMatrix dataMatrix = dataInfo.loadData(userInfo, eventProcessor);
GenericValue dealGV = dataMatrix.getCurrentBuffer().getGenericValue(0, "Deal", false);
dealGV.set("accountId", accountId);
if ( opportunityName != null)