📄 accounteventprocessor.java
字号:
if (status != STATUS_CONTINUE) {
return status;
}
// Delete related contacts.
status = deleteOneRelated(userInfo, delegator, entityGV, "", "Contact",
originatingEntityName, new ContactEventProcessor());
if (status != STATUS_CONTINUE) {
return status;
}
// Delete related activities.
status = deleteOneRelated(userInfo, delegator, entityGV, "",
"Activity", originatingEntityName, new ActivityEventProcessor());
if (status != STATUS_CONTINUE) {
return status;
}
// Delete related opportunities.
status = deleteOneRelated(userInfo, delegator, entityGV, "", "Deal",
originatingEntityName, new OpportunityEventProcessor());
if (status != STATUS_CONTINUE) {
return status;
}
// Delete related forecasts.
status = deleteOneRelated(userInfo, delegator, entityGV, "",
"Forecast", originatingEntityName, new ForecastEventProcessor());
if (status != STATUS_CONTINUE) {
return status;
}
// Delete related parties.
status = deleteOneRelated(userInfo, delegator, entityGV, "", "Party",
originatingEntityName, new GenericEventProcessor());
if (status != STATUS_CONTINUE) {
return status;
}
// Delete related entity accesses.
status = deleteOneRelated(userInfo, delegator, entityGV, "",
"EntityAccess", originatingEntityName,
new EntityAccessEventProcessor());
if (status != STATUS_CONTINUE) {
return status;
}
// Delete related FileAttachments. (Note: This must happen before the AccountFiles are deleted.)
status = deleteOneRelated(userInfo, delegator, entityGV, "",
"FileAttachment", originatingEntityName,
new AbstractAttachmentEP());
if (status != STATUS_CONTINUE) {
return status;
}
// Delete related AccountFiles. (Note: This must happen after the FileAttachments are deleted.)
status = deleteOneRelated(userInfo, delegator, entityGV, "",
"AccountFile", originatingEntityName,
new GenericEventProcessor());
if (status != STATUS_CONTINUE) {
return status;
}
return STATUS_CONTINUE;
}
/**
* DOCUMENT ME!
*
* @param userInfo
* @param delegator
* @param entityGV
* @param relationTitle
* @param relatedEntityName
*
* @return
*/
public List findOneRelated(UserInfo userInfo, GenericDelegator delegator,
GenericValue entityGV, String relationTitle, String relatedEntityName) {
// Find instances of an entity related to the current entity so the instances
// can be deleted.
if (relatedEntityName.equals("EntityAccess")) {
// Finding related EntityAccess records. Need special processing because
// the relationship cannot be defined in the sfa-config.xml file.
return EntityAccessHelper.findRelated(userInfo, delegator,
entityGV, relationTitle);
} else if (relatedEntityName.equals("FileAttachment")) {
// Finding related FileAttachment records. Need special processing because
// the relationship cannot be defined in the sfa-config.xml file.
// Get all the related AccountFile records using the generic version of findOneRelated.
List accountFileGVL = super.findOneRelated(userInfo, delegator,
entityGV, "", "AccountFile");
// Make a List of FileAttachments tied to the identified AccountFiles.
List fileAttachmenGVL = new LinkedList();
Iterator accountFileGVI = accountFileGVL.iterator();
while (accountFileGVI.hasNext()) {
GenericValue accountFileGV = (GenericValue) accountFileGVI.next();
try {
GenericValue fileAttachmentGV = delegator.getRelatedOne("FileAttachment",
accountFileGV);
if (fileAttachmentGV != null) {
fileAttachmenGVL.add(fileAttachmentGV);
}
} catch (GenericEntityException e) {
Debug.logWarning(
"[AccountEventProcessor.findOneRelated] Error retrieving FileAttachment record: " +
e.getLocalizedMessage(),module);
}
}
return fileAttachmenGVL;
} else {
// Not finding EntityAccess or FileAttachment records. Just use the standard processing using relations.
return super.findOneRelated(userInfo, delegator, entityGV,
relationTitle, relatedEntityName);
}
}
/**
* DOCUMENT ME!
*
* @param mainGV
* @param relatedSearchClause
* @param outGVV
* @param userInfo
* @param delegator
*
* @return
*/
protected GenericValue retrieveOneRelatedGV(GenericValue mainGV,
UIScreenSectionEntity relatedSearchClause, Vector outGVV, UserInfo userInfo,
GenericDelegator delegator) {
String relationRelEntityName = (String) relatedSearchClause.getEntityName();
if (relationRelEntityName.equals("Address")) {
// Special processing for the Address record since it can't be retrieved with a relationship
// defined in the sfa-config.xml file.
// Get account ID from the account record.
String accountId = mainGV.getString("accountId");
HashMap addressFindMap = new HashMap();
addressFindMap.put("addressOwnerId", accountId);
addressFindMap.put("isPrimary", "Y");
GenericValue addressGV = null;
try {
List addressGVL = delegator.findByAnd("Address", addressFindMap);
Iterator addressGVI = addressGVL.iterator();
if (addressGVI.hasNext()) {
// Address record was found.
addressGV = (GenericValue) addressGVI.next();
} else {
// Address record was not found. Allow generic event processor to create an empty one.
}
return addressGV;
} catch (GenericEntityException e) {
Debug.logError(
"[AccountEventProcessor.retrieveOneRelatedGV] An error occurred while searching for " +
"the address record for the account: " +
e.getLocalizedMessage(), module);
return addressGV;
}
} else {
// Retrieve all other related entities the regular way.
return super.retrieveOneRelatedGV(mainGV, relatedSearchClause,
outGVV, userInfo, delegator);
}
}
/**
* Add entity clauses for one related entity. This will join related tables to the query
* during a retrieve so query values can be entered that are in related entities.
* <P>
* This version overrides the ancestor to handle the Account entity, which
* has no relation defined.
*
* @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
*
* @param delegator Reference to the OFBIZ delegator being used to connect to the data base
* @param relationTitle Relation title
* @param relatedEntityName Name of related entity
* @param primaryEntityName Name of the primary entity
* @param primaryME ModelEntity object for the primary entity
* @param queryInfo critera to be used in search.
*/
public void addOneRelationClause(GenericDelegator delegator,
String relationTitle, String relatedAndFields, String relatedEntityName,
String primaryEntityName, ModelEntity primaryME, boolean isOuterJoin, QueryInfo queryInfo)
throws GenericEntityException {
if (relatedEntityName.equals("Address")) {
// Adding entity clauses for the Address entity. Need to build it manually.
// Join the address owner ID field
queryInfo.addJoin("Account", "Address", Boolean.valueOf(isOuterJoin), "accountId", "addressOwnerId");
if ( isOuterJoin )
{
queryInfo.addAlias("Address", "isPrimary", "isPrimary");
queryInfo.addAlias("Address", "addressId", "addressId");
queryInfo.addCondition( new EntityConditionList( UtilMisc.toList( new EntityExpr("isPrimary", EntityOperator.EQUALS, "Y"),
new EntityExpr("addressId", EntityOperator.EQUALS, null)), EntityOperator.OR));
}
else
queryInfo.addCondition("Address", "isPrimary", EntityOperator.EQUALS, "Y");
} else {
// Use the parent script for all other related entities.
super.addOneRelationClause(delegator, relationTitle, relatedAndFields,
relatedEntityName, primaryEntityName, primaryME, isOuterJoin, queryInfo);
}
}
/**
* DOCUMENT ME!
*
* @param userInfo
* @param delegator
*
* @return
*/
public SecurityLinkInfo getSecurityLinkInfo(UserInfo userInfo,
GenericDelegator delegator) {
return new SecurityLinkInfo("Account", "accountId", true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -