Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2013 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.opensource.org/licenses/ecl2.php Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.kuali.rice.kew.engine.node;
 
 import java.util.List;
 
 
Represents a materialized instance of a RouteNode definition on a DocumentRouteHeaderValue. Node instances are generated by the engine using the RouteNode as a prototype and connected as a Directed Acyclic Graph.

Author(s):
Kuali Rice Team (rice.collab@kuali.org)
 
 @Table(name="KREW_RTE_NODE_INSTN_T")
 //@Sequence(name="KREW_RTE_NODE_S",property="routeNodeInstanceId")
 	@NamedQuery(name="RouteNodeInstance.FindByRouteNodeInstanceId",query="select r from RouteNodeInstance r where r.routeNodeInstanceId = :routeNodeInstanceId"),
 	@NamedQuery(name="RouteNodeInstance.FindActiveNodeInstances",query="select r from RouteNodeInstance r where r.documentId = :documentId and r.active = true"),
 	@NamedQuery(name="RouteNodeInstance.FindTerminalNodeInstances",query="select r from RouteNodeInstance r where r.documentId = :documentId and r.active = false and r.complete = true"),
 	@NamedQuery(name="RouteNodeInstance.FindInitialNodeInstances",query="select d.initialRouteNodeInstances from DocumentRouteHeaderValue d where d.documentId = :documentId"),
 	@NamedQuery(name="RouteNodeInstance.FindProcessNodeInstances", query="select r from RouteNodeInstance r where r.process.routeNodeInstanceId = :processId"),
 	@NamedQuery(name="RouteNodeInstance.FindRouteNodeInstances", query="select r from RouteNodeInstance r where r.documentId = :documentId")
 })
 public class RouteNodeInstance implements Serializable {
     
 	private static final long serialVersionUID = 7183670062805580420L;
 	
 	@Id
 	@GeneratedValue(generator="KREW_RTE_NODE_S")
 	@GenericGenerator(name="KREW_RTE_NODE_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={
 			@Parameter(name="sequence_name",value="KREW_RTE_NODE_S"),
 			@Parameter(name="value_column",value="id")
 	})
 	@Column(name="RTE_NODE_INSTN_ID")
     @Column(name="DOC_HDR_ID")
 	private String documentId;
 	@JoinColumn(name="BRCH_ID")
 	private Branch branch;
     @OneToOne(fetch=.)
 	@JoinColumn(name="RTE_NODE_ID")
     private RouteNode routeNode;
     @Column(name="ACTV_IND")
     private boolean active = false;
     @Column(name="CMPLT_IND")
     private boolean complete = false;
     @Column(name="INIT_IND")
     private boolean initial = true;
 	@JoinColumn(name="PROC_RTE_NODE_INSTN_ID")
     
    @JoinTable(name = "KREW_RTE_NODE_INSTN_LNK_T", joinColumns = @JoinColumn(name = "FROM_RTE_NODE_INSTN_ID"), inverseJoinColumns = @JoinColumn(name = "TO_RTE_NODE_INSTN_ID"))
    @Fetch(value = .)
    
    @ManyToMany(fetch=., mappedBy="nextNodeInstances")
    @Fetch(value = .)
    //@JoinTable(name = "KREW_RTE_NODE_INSTN_LNK_T", joinColumns = @JoinColumn(name = "TO_RTE_NODE_INSTN_ID"), inverseJoinColumns = @JoinColumn(name = "FROM_RTE_NODE_INSTN_ID"))
    @OneToMany(fetch=.,cascade={...}, mappedBy="nodeInstance", orphanRemoval=true)    
    @Fetch(value = .)
    private List<NodeStatestate = new ArrayList<NodeState>();
    	
    @Version
	@Column(name="VER_NBR")
    
    public boolean isActive() {
        return ;
    }
    public void setActive(boolean active) {
        this. = active;
    }
    
    public boolean isComplete() {
        return ;
    }
    public void setComplete(boolean complete) {
        this. = complete;
    }
    public Branch getBranch() {
        return ;
    }
    public void setBranch(Branch branch) {
        this. = branch;
    }
    public RouteNode getRouteNode() {
        return ;
    }
    public void setRouteNode(RouteNode node) {
        this. = node;
    }
    public String getRouteNodeInstanceId() {
        return ;
    }
    public void setRouteNodeInstanceId(String routeNodeInstanceId) {
        this. = routeNodeInstanceId;
    }
    public String getDocumentId() {
        return ;
    }
    public void setDocumentId(String documentId) {
        this. = documentId;
    }
        return ;
    }
    public RouteNodeInstance getNextNodeInstance(int index) {
    	while (getNextNodeInstances().size() <= index) {
    	}
    	return (RouteNodeInstancegetNextNodeInstances().get(index);
    }
    public void setNextNodeInstances(List<RouteNodeInstancenextNodeInstances) {
        this. = nextNodeInstances;
    }
        return ;
    }
    public RouteNodeInstance getPreviousNodeInstance(int index) {
    	while (.size() <= index) {
    	}
    	return (RouteNodeInstancegetPreviousNodeInstances().get(index);
    }
    public void setPreviousNodeInstances(List<RouteNodeInstancepreviousNodeInstances) {
        this. = previousNodeInstances;
    }
    public boolean isInitial() {
        return ;
    }
    public void setInitial(boolean initial) {
        this. = initial;
    }
    public List<NodeStategetState() {
        return ;
    }
    public void setState(List<NodeStatestate) {
        this..clear();
    	this..addAll(state);
        //this.state = state;
    }
    public RouteNodeInstance getProcess() {
		return ;
	}
	public void setProcess(RouteNodeInstance process) {
		this. = process;
	}
	public Integer getLockVerNbr() {
        return ;
    }
    public void setLockVerNbr(Integer lockVerNbr) {
        this. = lockVerNbr;
    }
    
    public NodeState getNodeState(String key) {
        for (Iterator iter = getState().iterator(); iter.hasNext();) {
            NodeState nodeState = (NodeStateiter.next();
            if (nodeState.getKey().equals(key)) {
                return nodeState;
            }
        }
        return null;
    }
    
    public void addNodeState(NodeState state) {
        this..add(state);
        state.setNodeInstance(this);
    }
    
    public void removeNodeState(String key) {
        for (Iterator iter = getState().iterator(); iter.hasNext();) {
            NodeState nodeState = (NodeStateiter.next();
            if (nodeState.getKey().equals(key)) {
                iter.remove();
                break;
            }
        }
    }
    
    public void addNextNodeInstance(RouteNodeInstance nextNodeInstance) {
        .add(nextNodeInstance);
        nextNodeInstance.getPreviousNodeInstances().add(this);
    }
    
    public void removeNextNodeInstance(RouteNodeInstance nextNodeInstance) {
        .remove(nextNodeInstance);
        nextNodeInstance.getPreviousNodeInstances().remove(this);
    }
    
    public void clearNextNodeInstances() {
        for (Iterator iterator = .iterator(); iterator.hasNext();) {
            RouteNodeInstance nextNodeInstance = (RouteNodeInstanceiterator.next();
            iterator.remove();
            nextNodeInstance.getPreviousNodeInstances().remove(this);
        }
    }
    
    public String getName() {
        return (getRouteNode() == null ? null : getRouteNode().getRouteNodeName());
    }
    
    public boolean isInProcess() {
        return getProcess() != null;
    }
    
    public DocumentType getDocumentType() {
        return KEWServiceLocator.getDocumentTypeService().findByDocumentId(getDocumentId());
    }
    
    /*
     * methods used to display route node instances' data on documentoperation.jsp
     */
    
    public NodeState getNodeStateByIndex(int index){
    	while (.size() <= index) {
            .add(new NodeState());
        }
        return (NodeStategetState().get(index);
    }   
    public void populateState(List<NodeStatestate) {
        this..addAll(state);
     }
        return ;
    }
    public void setInitialDocumentRouteHeaderValues(List<DocumentRouteHeaderValueinitialDocumentRouteHeaderValues) {
        this. = initialDocumentRouteHeaderValues;
    }
    
    public String toString() {
        return new ToStringBuilder(this)
            .append("routeNodeInstanceId")
            .append("documentId")
            .append("branch" == null ? null : .getBranchId())
            .append("routeNode" == null ? null : .getRouteNodeName())
            .append("active")
            .append("complete")
            .append("initial")
            .append("process")
            .append("state" == null ? null : .size())
            .toString();
    }
    
	//@PrePersist
	public void beforeInsert(){
	}
	public static org.kuali.rice.kew.api.document.node.RouteNodeInstance to(RouteNodeInstance routeNodeInstance) {
		if (routeNodeInstance == null) {
			return null;
		}
		org.kuali.rice.kew.api.document.node.RouteNodeInstance.Builder builder = org.kuali.rice.kew.api.document.node
                .RouteNodeInstance.Builder.create();
		builder.setActive(routeNodeInstance.isActive());
		builder.setBranchId(routeNodeInstance.getBranch().getBranchId());
		builder.setComplete(routeNodeInstance.isComplete());
		builder.setDocumentId(routeNodeInstance.getDocumentId());
		builder.setId(routeNodeInstance.getRouteNodeInstanceId());
		builder.setInitial(routeNodeInstance.isInitial());
		builder.setName(routeNodeInstance.getName());
		if (routeNodeInstance.getProcess() != null) {
			builder.setProcessId(routeNodeInstance.getProcess().getRouteNodeInstanceId());
		}
		builder.setRouteNodeId(routeNodeInstance.getRouteNode().getRouteNodeId());
		for (NodeState stateBo : routeNodeInstance.getState()) {
			RouteNodeInstanceState.Builder stateBuilder = RouteNodeInstanceState.Builder.create();
			stateBuilder.setId(stateBo.getStateId());
			stateBuilder.setKey(stateBo.getKey());
			stateBuilder.setValue(stateBo.getValue());
			states.add(stateBuilder);
		}
		builder.setState(states);
        if (routeNodeInstance.getNextNodeInstances() != null) {
            for (RouteNodeInstance next : routeNodeInstance.getNextNodeInstances()) {
                // KULRICE-8152 - During load testing, sometimes routeNodeInstance.getNextNodeInstances() returns an
                // arraylist with size = 1 but all elements are null, which causes a "contract was null" error when the
                // create is called.  This check to see if next is not null prevents the error from occurring.
                if (next != null) {
                    // will this make things blow up?
                    nextNodes.add(org.kuali.rice.kew.api.document.node.RouteNodeInstance.Builder.create(RouteNodeInstance.to(next)));
                }
            }
        }
        builder.setNextNodeInstances(nextNodes);
		return builder.build();
	}
    
New to GrepCode? Check out our FAQ X