📄 issueeventprocessor.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.issue;
import java.sql.Timestamp;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericValue;
import com.sourcetap.sfa.event.DataMatrix;
import com.sourcetap.sfa.event.GenericEventProcessor;
import com.sourcetap.sfa.replication.GenericReplicator;
import com.sourcetap.sfa.util.UserInfo;
/**
* DOCUMENT ME!
*
*/
public class IssueEventProcessor extends GenericEventProcessor {
public static final String module = IssueEventProcessor.class.getName();
/**
* DOCUMENT ME!
*
* @param userInfo
* @param delegator
* @param dataMatrix
*
* @return
*/
protected int preUpdate(UserInfo userInfo, GenericDelegator delegator,
DataMatrix dataMatrix) {
// Just process the first row for now.
GenericValue itIssueGV = dataMatrix.getCurrentBuffer().getGenericValue(0,
0);
Timestamp now = new Timestamp(new java.util.Date().getTime());
// Store the current user ID in the "modified by" field.
String userPartyId = userInfo.getPartyId();
String issueId = itIssueGV.getString("issueId");
itIssueGV.set("issueId", issueId);
itIssueGV.set("modifiedBy", userPartyId);
itIssueGV.set("modifiedDate", now);
//Store the issue information in the history table
GenericValue itIssueHistoryGV = new GenericValue(delegator.getModelEntity(
"ItIssueHistory"));
itIssueHistoryGV.setDelegator(delegator);
String historyId = GenericReplicator.getNextSeqId("ItIssueHistory",
delegator);
GenericValue largeDataGV = new GenericValue(delegator.getModelEntity(
"LargeData"));
largeDataGV.setDelegator(delegator);
String dataId = GenericReplicator.getNextSeqId("LargeData", delegator);
itIssueHistoryGV.set("historyId", historyId);
itIssueHistoryGV.set("dataId", dataId);
itIssueHistoryGV.set("issueId", itIssueGV.getString("issueId"));
itIssueHistoryGV.set("statusId", itIssueGV.getString("statusId"));
itIssueHistoryGV.set("assignedTo", itIssueGV.getString("assignedTo"));
itIssueHistoryGV.set("priorityId", itIssueGV.getString("priorityId"));
itIssueHistoryGV.set("shortName", itIssueGV.getString("shortName"));
itIssueHistoryGV.set("createdBy", userPartyId);
itIssueHistoryGV.set("createdDate", now);
itIssueHistoryGV.set("modifiedBy", userPartyId);
itIssueHistoryGV.set("modifiedDate", now);
String notes = itIssueGV.getString("notes");
largeDataGV.set("dataId", dataId);
largeDataGV.set("dataValue", notes);
//clear the issues notes field (it will be stored in the Large Data table )
itIssueGV.set("notes", "");
// Add the IT Issue History to the data matrix so it will be saved.
dataMatrix.addEntity("ItIssueHistory", false, true);
dataMatrix.getCurrentBuffer().getContentsRow(0).add(itIssueHistoryGV);
// Add the Large Data (note) to the data matrix so it will be saved.
dataMatrix.addEntity("LargeData", false, true);
dataMatrix.getCurrentBuffer().getContentsRow(0).add(largeDataGV);
return STATUS_CONTINUE;
}
/**
* DOCUMENT ME!
*
* @param userInfo
* @param delegator
* @param dataMatrix
*
* @return
*/
protected int preInsert(UserInfo userInfo, GenericDelegator delegator,
DataMatrix dataMatrix) {
// Just process the issue...
GenericValue itIssueGV = dataMatrix.getCurrentBuffer().getGenericValue(0,
0);
Timestamp now = new Timestamp(new java.util.Date().getTime());
// Store the current user ID in the "modified by" field.
String userPartyId = userInfo.getPartyId();
String issueId = GenericReplicator.getNextSeqId("ItIssue", delegator);
itIssueGV.set("issueId", issueId);
itIssueGV.set("modifiedBy", userPartyId);
itIssueGV.set("modifiedDate", now);
itIssueGV.set("createdBy", userPartyId);
itIssueGV.set("createdDate", now);
//Store the issue information in the history table
GenericValue itIssueHistoryGV = new GenericValue(delegator.getModelEntity(
"ItIssueHistory"));
itIssueHistoryGV.setDelegator(delegator);
String historyId = GenericReplicator.getNextSeqId("ItIssueHistory",
delegator);
GenericValue largeDataGV = new GenericValue(delegator.getModelEntity(
"LargeData"));
largeDataGV.setDelegator(delegator);
String dataId = GenericReplicator.getNextSeqId("LargeData", delegator);
itIssueHistoryGV.set("historyId", historyId);
itIssueHistoryGV.set("dataId", dataId);
itIssueHistoryGV.set("issueId", itIssueGV.getString("issueId"));
itIssueHistoryGV.set("statusId", itIssueGV.getString("statusId"));
itIssueHistoryGV.set("assignedTo", itIssueGV.getString("assignedTo"));
itIssueHistoryGV.set("priorityId", itIssueGV.getString("priorityId"));
itIssueHistoryGV.set("shortName", itIssueGV.getString("shortName"));
itIssueHistoryGV.set("modifiedBy", userPartyId);
itIssueHistoryGV.set("modifiedDate", now);
String notes = itIssueGV.getString("notes");
largeDataGV.set("dataId", dataId);
largeDataGV.set("dataValue", notes);
//clear the issues notes field (it will be stored in the Large Data table )
itIssueGV.set("notes", "");
//show what we have
// Add the IT Issue History to the data matrix so it will be saved.
dataMatrix.addEntity("ItIssueHistory", false, true);
dataMatrix.getCurrentBuffer().getContentsRow(0).add(itIssueHistoryGV);
// Add the Large Data (note) to the data matrix so it will be saved.
dataMatrix.addEntity("LargeData", false, true);
dataMatrix.getCurrentBuffer().getContentsRow(0).add(largeDataGV);
return STATUS_CONTINUE;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -