⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 creationcontext.java

📁 用JGraph编的软件
💻 JAVA
字号:
package org.jgpd.io.jbpm.definition.impl;

import java.util.*;

public class CreationContext{

  public CreationContext(ProcessDefinitionImpl processDefinition, Map entries) {
    this.processDefinition = processDefinition;
    this.processBlock = processDefinition;
    this.entries = entries;
  }

  public ProcessDefinitionImpl getProcessDefinition() { return this.processDefinition; }

  public ProcessBlockImpl getProcessBlock() { return this.processBlock; }
  public void setProcessBlock(ProcessBlockImpl processBlock) { this.processBlock = processBlock; }

  public ProcessBlockImpl getTransitionDestinationScope() { return this.transitionDestinationScope; }
  public void setTransitionDestinationScope(ProcessBlockImpl transitionDestinationScope) { this.transitionDestinationScope = transitionDestinationScope; }

  public DefinitionObjectImpl getDefinitionObject() { return this.definitionObject; }
  public void setDefinitionObject(DefinitionObjectImpl definitionObject) { this.definitionObject = definitionObject; }

  public StateImpl getState() { return this.state; }
  public void setState(StateImpl state) { this.state = state; }

  public NodeImpl getNode() { return this.node; }
  public void setNode(NodeImpl node) { this.node = node; }

  public Object getDelegatingObject() { return this.delegatingObject; }
  public void setDelegatingObject(Object delegatingObject) { this.delegatingObject = delegatingObject; }

  public int getIndex() { return this.index; }
  public void setIndex(int index) { this.index = index; }
  public void incrementIndex() { this.index++; }

  public Map getEntries() { return entries; }

  public void addUnresolvedReference( Object referencingObject, String destinationName, ProcessBlockImpl destinationScope, String property, Class destinationType ) {
    unresolvedReferences.add( new UnresolvedReference( referencingObject, destinationName, destinationScope, property, destinationType ) );
  }

  public void addReferencableObject( String name, ProcessBlockImpl scope, Class type, Object referencableObject ) {
    List referenceType = new ArrayList(2);
    referenceType.add( scope );
    referenceType.add( type );
    Map referencables = (Map) referencableObjects.get( referenceType );
    if ( referencables == null ) {
      referencables = new HashMap();
      referencableObjects.put( referenceType, referencables );
    }
    referencables.put( name, referencableObject );
  }

  public void resolveReferences() {
    Iterator iter = unresolvedReferences.iterator();
    while (iter.hasNext()) {
      UnresolvedReference unresolvedReference = (UnresolvedReference) iter.next();

      Object referencingObject = unresolvedReference.getReferencingObject();
      String referenceDestinationName = unresolvedReference.getDestinationName();
      ProcessBlockImpl scope = unresolvedReference.getDestinationScope();
      String property = unresolvedReference.getProperty();

      Object referencedObject = findInScope( unresolvedReference, unresolvedReference.getDestinationScope() );
      if ( referencedObject == null ) {
//        addError( "failed to deploy process archive : couldn't resolve " + property + "=\"" + referenceDestinationName + "\" from " + referencingObject + " in scope " + scope );
      } else {
        if ( referencingObject instanceof TransitionImpl ) {
          if ( property.equals( "to" ) ) {
            TransitionImpl transition = (TransitionImpl) referencingObject;
            transition.setTo( (NodeImpl) referencedObject );
          }
        }
        if ( referencingObject instanceof FieldImpl ) {
          if ( property.equals( "attribute" ) ) {
            FieldImpl field = (FieldImpl) referencingObject;
            field.setAttribute( (AttributeImpl) referencedObject );
          }
        }
      }
    }
  }

  private Object findInScope(UnresolvedReference unresolvedReference, ProcessBlockImpl scope) {
    Object referencedObject = null;

    if ( scope != null ) {
      List referenceType = (List) new ArrayList(2);
      referenceType.add( scope );
      referenceType.add( unresolvedReference.getDestinationType() );

      Map referencables = (Map) referencableObjects.get( referenceType );
      if ( referencables.containsKey( unresolvedReference.getDestinationName() ) ) {
        referencedObject = referencables.get( unresolvedReference.getDestinationName() );
      } else {
        referencedObject = findInScope( unresolvedReference, scope.getParentBlock() );
      }
    }

    return referencedObject;
  }

  // invariable members
  private ProcessDefinitionImpl processDefinition = null;
  private Map entries = null;

  // context members
  private ProcessBlockImpl processBlock = null;
  private ProcessBlockImpl transitionDestinationScope = null;
  private DefinitionObjectImpl definitionObject = null;
  private StateImpl state = null;
  private NodeImpl node = null;
  private Object delegatingObject = null;
  private int index = -1;

  // members for resolving references
  private Map referencableObjects = new HashMap();
  private Collection unresolvedReferences = new ArrayList();

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -