0

在尝试在 BPM 上创建用户休假规则时,我编写了一个方法(可以在下面看到截图)但是当 jaxb 对象实例创建时发生异常。

ruleInfoType.setCreatedDate(DateUtility.getCalendarInTimeZone(DateUtility.TIMEZONE_TR));

java.lang.NullPointerException
at oracle.xml.jaxb.JaxbNode.getOwnerDocument(JaxbNode.java:244)
at oracle.xml.jaxb.JaxbNode.setJaxbElement(JaxbNode.java:789)
at oracle.bpel.services.workflow.user.model.RuleInfoTypeImpl.setCreatedDate(RuleInfoTypeImpl.java:181)
at com.arsivist.structure.integration.bpm.BPMProcessUtility.createVacationRule(BPMProcessUtility.java:488)
at com.arsivist.structure.integration.bpm.BPMRoleManagementService.main(BPMRoleManagementService.java:101)

.

import com.arsivist.structure.integration.bpm.vo.DefaultColumnList;
import com.arsivist.structure.util.DateUtility;

import java.lang.reflect.Method;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import oracle.bpel.services.bpm.common.IBPMContext;
import oracle.bpel.services.common.util.XMLUtil;
import oracle.bpel.services.workflow.WorkflowException;
import oracle.bpel.services.workflow.client.IWorkflowServiceClient;
import oracle.bpel.services.workflow.client.config.ClientConfigurationUtil;
import oracle.bpel.services.workflow.client.config.WorkflowServicesClientConfigurationType;
import oracle.bpel.services.workflow.common.model.PrincipleRefType;
import oracle.bpel.services.workflow.common.model.PrincipleRefTypeImpl;
import oracle.bpel.services.workflow.query.ITaskQueryService;
import oracle.bpel.services.workflow.repos.Column;
import oracle.bpel.services.workflow.repos.Predicate;
import oracle.bpel.services.workflow.repos.TableConstants;
import oracle.bpel.services.workflow.runtimeconfig.model.AttributeLabelType;
import oracle.bpel.services.workflow.runtimeconfig.model.PayloadMappingType;
import oracle.bpel.services.workflow.task.model.ProcessType;
import oracle.bpel.services.workflow.task.model.Task;
import oracle.bpel.services.workflow.user.IUserMetadataService;
import oracle.bpel.services.workflow.user.model.RuleActionType;
import oracle.bpel.services.workflow.user.model.RuleActionTypeImpl;
import oracle.bpel.services.workflow.user.model.RuleAssignmentType;
import oracle.bpel.services.workflow.user.model.RuleAssignmentTypeImpl;
import oracle.bpel.services.workflow.user.model.RuleDetail;
import oracle.bpel.services.workflow.user.model.RuleDetailType;
import oracle.bpel.services.workflow.user.model.RuleDetailTypeImpl;
import oracle.bpel.services.workflow.user.model.RuleInfoType;
import oracle.bpel.services.workflow.user.model.RuleInfoTypeImpl;
import oracle.bpel.services.workflow.verification.IWorkflowContext;

import oracle.bpm.client.BPMServiceClientFactory;
import oracle.bpm.services.client.IBPMServiceClient;
import oracle.bpm.services.instancemanagement.model.IProcessFlexAttributes;
import oracle.bpm.services.instancemanagement.model.IProcessInstance;
import oracle.bpm.services.instancequery.IInstanceQueryService;
import oracle.bpm.services.processmetadata.IProcessMetadataService;
import oracle.bpm.services.processmetadata.ProcessMetadataSummary;
import oracle.bpm.services.processmetadata.StatusEnum;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
// ACTIVE/RETIRED/DELETED
/**
* Utility class with example usage of the BPM and HWF APIs
*/
public class BPMProcessUtility
{

public final static String PAYLOAD_ELEMENT = "payload";
public final static String TASK_NS = "http://www.acme.com.tr";
public final static String INIT_TASK_SUBMIT_OUTCOME = "SUBMIT";

private IBPMServiceClient bpmSvcClient_;
private IWorkflowServiceClient wfSvcClient_;
private Map<Column, Method> protectedFlexFieldMapping_;

public BPMProcessUtility(BPMServiceClientFactory clientFactory)
{
bpmSvcClient_ = clientFactory.getBPMServiceClient();
wfSvcClient_ = clientFactory.getWorkflowServiceClient();
protectedFlexFieldMapping_ = initializeFlexFieldMethodMapping("getProtected");
}

public void createVacationRule(IWorkflowContext ctx, String userNameOfRuleOwner, String targetUserName, Date beginDate, Date endDate,
oracle.bpm.services.organization.model.ObjectFactory objectFactory) throws Exception
{
IUserMetadataService iUserMetadataService = wfSvcClient_.getUserMetadataService();
RuleInfoType ruleInfoType = new RuleInfoTypeImpl();
RuleDetailType ruleDetail = new RuleDetailTypeImpl();
RuleActionType action = new RuleActionTypeImpl();
RuleAssignmentType ruleAssignment = new RuleAssignmentTypeImpl();

//prepare ruleinfotype instance
ruleInfoType.setCreatedDate(DateUtility.getCalendarInTimeZone(DateUtility.TIMEZONE_TR));
ruleInfoType.setDescription(userNameOfRuleOwner + "_" + DateUtility.convertDateToString(DateUtility.getToday(), "dd.MM.yyyy HH:mi"));
ruleInfoType.setStartDate(DateUtility.getCalendarOfDate(beginDate));
ruleInfoType.setEndDate(DateUtility.getCalendarOfDate(endDate));
ruleInfoType.setRuleName(userNameOfRuleOwner + "_" + DateUtility.convertDateToString(DateUtility.getToday(), "dd.MM.yyyy HH:mi"));

//prepare owneruser principalref
PrincipleRefType userOfRuleOwner = new PrincipleRefTypeImpl();
userOfRuleOwner.setRealm("jazn.com");
userOfRuleOwner.setName(userNameOfRuleOwner);

//set owner user to ruleInfoType
ruleInfoType.setOwner(userOfRuleOwner);
ruleDetail.setGeneralInfo(ruleInfoType);

//prepare targetuser principalref
PrincipleRefType targetUser = new PrincipleRefTypeImpl();
targetUser.setRealm("jazn.com");
targetUser.setName(targetUserName);

//set target user to reassigne user
ruleAssignment.setAssignee(targetUser);

action.setReassign(ruleAssignment);

iUserMetadataService.createRule(ctx, (RuleDetail)ruleDetail);
}  

有人知道创建实例的正确方法吗?

4

1 回答 1

0

设置 BPM API 对象时出现的问题是关于不使用 objectFactory。我使用了 oracle.bpel.services.workflow.user.model.ObjectFactory 并且它有效,希望下面的代码片段有所帮助。

    public static void createVacationRule(String userNameOfRuleOwner, String targetUserName, Date beginDate, Date endDate) throws WorkflowException
    {
        IUserMetadataService iUserMetadataService = serviceClientFactory.getWorkflowServiceClient().getUserMetadataService();
        oracle.bpel.services.workflow.user.model.ObjectFactory userObjectFactory = new oracle.bpel.services.workflow.user.model.ObjectFactory();
        RuleInfoType ruleInfoType = userObjectFactory.createRuleInfoType();
        //RuleDetailType ruleDetailType = objectFactory.createRuleDetailType();
        RuleDetail ruleDetail = userObjectFactory.createRuleDetail();
        RuleActionType ruleActionType = userObjectFactory.createRuleActionType();
        RuleAssignmentType ruleAssignment = userObjectFactory.createRuleAssignmentType();

        StringBuilder ruleName = new StringBuilder("VekaletApp_");
        StringBuilder ruleDesc = new StringBuilder(userNameOfRuleOwner);

        //prepere ruleName Str
        ruleName.append(userNameOfRuleOwner);
        ruleName.append("_");
        ruleName.append(targetUserName);
        ruleName.append("_");
        ruleName.append(DateUtility.convertDateToString(beginDate, "dd.MM.yyyy"));
        ruleName.append("_");
        ruleName.append(DateUtility.convertDateToString(endDate, "dd.MM.yyyy"));

        //prepere ruleDesc Str
        ruleDesc.append("'s reassignment rule between ");
        ruleDesc.append(DateUtility.convertDateToString(beginDate, "dd.MM.yyyy HH:mm"));
        ruleDesc.append(" and ");
        ruleDesc.append(DateUtility.convertDateToString(endDate, "dd.MM.yyyy HH:mm"));

        //prepare ruleinfotype instance
        ruleInfoType.setRuleName(ruleName.toString());
        ruleInfoType.setDescription(ruleDesc.toString());
        ruleInfoType.setCreatedDate(DateUtility.getCalendarInTimeZone(DateUtility.TIMEZONE_TR));
        ruleInfoType.setStartDate(DateUtility.getCalendarOfDate(beginDate));
        ruleInfoType.setEndDate(DateUtility.getCalendarOfDate(endDate));

        //prepare owneruser principalref
        oracle.bpel.services.workflow.common.model.PrincipleRefType userOfRuleOwner = userObjectFactory.createViewGranteeType();
        userOfRuleOwner.setRealm("jazn.com");
        userOfRuleOwner.setType("USER");
        userOfRuleOwner.setName(userNameOfRuleOwner);

        //set owner user to ruleInfoType
        ruleInfoType.setOwner(userOfRuleOwner);

        //prepare targetuser principalref
        oracle.bpel.services.workflow.common.model.PrincipleRefType targetUser = userObjectFactory.createViewGranteeType();
        targetUser.setRealm("jazn.com");
        targetUser.setType("USER");
        targetUser.setName(targetUserName);

        //set target user to reassigne user
        ruleAssignment.setAssignee(targetUser);
}

    ruleActionType.setReassign(ruleAssignment);
    ruleActionType.setActionType(IUserMetadataService.RULE_ACTION_REASSIGN);

    ruleDetail.setAction(ruleActionType);
    ruleDetail.setGeneralInfo(ruleInfoType);

    iUserMetadataService.createRule(iWorkFlowContext, ruleDetail);
于 2013-06-10T09:40:36.753 回答