📄 abstractnotewep.java
字号:
/*
*
* Copyright (c) 2004 SourceTap - www.sourcetap.com
*
* The contents of this file are subject to the SourceTap Public License
* ("License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
*/
package com.sourcetap.sfa.note;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.condition.EntityOperator;
import com.sourcetap.sfa.event.DataMatrix;
import com.sourcetap.sfa.event.GenericEventProcessor;
import com.sourcetap.sfa.event.GenericWebEventProcessor;
import com.sourcetap.sfa.replication.GenericReplicator;
import com.sourcetap.sfa.ui.UICache;
import com.sourcetap.sfa.ui.UIWebScreenSection;
import com.sourcetap.sfa.util.QueryInfo;
import com.sourcetap.sfa.util.UserInfo;
/**
* DOCUMENT ME!
*
*/
public class AbstractNoteWEP extends GenericWebEventProcessor {
public static final String module = AbstractNoteWEP.class.getName();
// overide the default. Link Contact and Deal via the OpportunityContact entity
protected void addUseQueryParameterClauses(
UIWebScreenSection uiWebScreenSection, QueryInfo queryInfo,
List relatedSearchClauses, String primaryEntityName,
HttpServletRequest request) {
String[] linkParams = {
"accountId", "contactId", "dealId", "activityId", "productId",
"leadId"
};
String[] linkEntities = {
"Account", "Contact", "Deal", "Activity",
"Product", "Lead"
};
for (int i = 0; i < linkParams.length; i++) {
String linkValue = request.getParameter(linkParams[i]);
if ((linkValue != null) && (linkValue.length() > 0)) {
queryInfo.addJoin("NoteAttachment", "NoteLink", Boolean.FALSE, "noteId", "noteId");
queryInfo.addCondition("NoteLink", "noteLinkType", EntityOperator.EQUALS, linkEntities[i]);
queryInfo.addCondition( "NoteLink", "noteLinkId", EntityOperator.EQUALS, linkValue);
}
}
}
protected int preInsert(UserInfo userInfo,
UIWebScreenSection uiWebScreenSection, HttpServletRequest request,
HttpServletResponse response, GenericDelegator delegator,
GenericEventProcessor eventProcessor, DataMatrix dataMatrix,
UICache uiCache)
{
GenericValue noteGV = dataMatrix.getCurrentBuffer().getGenericValue(0,
0);
String noteId = noteGV.getString("noteId");
if ((noteId == null) || (noteId.equals(""))) {
noteId = GenericReplicator.getNextSeqId("NoteAttachment", delegator);
}
noteGV.set("noteId", noteId);
String linkId = "";
String userPartyId = userInfo.getPartyId();
// Set the time stamps.
Timestamp currentTime = new Timestamp(Calendar.getInstance().getTime().getTime());
String[] linkParams = { "accountId", "contactId", "dealId", "activityId", "productId", "leadId" };
String[] linkEntities = { "Account", "Contact", "Deal", "Activity","Product", "Lead" };
for (int i = 0; i < linkParams.length; i++) {
String linkValue = request.getParameter(linkParams[i]);
if ((linkValue != null) && (linkValue.length() > 0)) {
// Add the owner to the participants list.
GenericValue noteLinkGV = new GenericValue(delegator.getModelEntity("NoteLink"));
noteLinkGV.setDelegator(delegator);
noteLinkGV.set("noteId", noteId);
noteLinkGV.set("noteLinkType", linkEntities[i]);
noteLinkGV.set("noteLinkId", linkValue);
noteLinkGV.set("createdBy", userPartyId);
noteLinkGV.set("createdDate", currentTime);
noteLinkGV.set("modifiedBy", userPartyId);
noteLinkGV.set("modifiedDate", currentTime);
// Add the Activity Contact to the data matrix so it will be saved.
dataMatrix.addEntity("NoteLink", false, true);
dataMatrix.getCurrentBuffer().getContentsRow(0).add(noteLinkGV);
break;
}
}
return STATUS_CONTINUE;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -