コード例 #1
0
ファイル: BagOrTreeNode.java プロジェクト: DFKIIFS/owlseditor
 public void updateKBAfterMove(OWLSTreeNode node) {
   // OWLIndividual list = getComponents();
   int index = getIndex(node);
   OWLSList olist = new OWLSList(getInstance(), getOWLModel());
   olist.removeAtIndex(index, false);
   // OWLSList olist = new OWLSList(list, type, getOWLModel());
   // OWLIndividual newcell = olist.removeAtIndex(node.getInstance(),
   // index, false);
   // if (index == 0){
   // getInstance().setPropertyValue(components, newcell);
   // }
 }
コード例 #2
0
ファイル: BagOrTreeNode.java プロジェクト: DFKIIFS/owlseditor
 /** Updates the KB after adding a node. */
 public void updateKBAfterInsert(OWLSTreeNode newnode) {
   /*
    * Now we need to put the Instance in the correct place in its
    * ControlConstructBag
    */
   // OWLIndividual list = getComponents();
   int newindex = getIndex(newnode);
   OWLSList olist = new OWLSList(getInstance(), getOWLModel());
   olist.insertAtIndex(newnode.getInstance(), newindex);
   // OWLSList olist = new OWLSList(list, type, getOWLModel());
   // OWLIndividual newcell = olist.insertAtIndex(newnode.getInstance(),
   // newindex);
   /*
    * If we are inserting at the beginning of the bag/list, we need to
    * update the control construct.
    */
   // if (newindex == 0){
   // getInstance().setPropertyValue(components, newcell);
   // }
 }
コード例 #3
0
  /**
   * Creates the tree from a ControlConstruct. It returns the root node created even though the
   * caller already has it, since the method is recursive, and this is needed internally. This
   * method is only called when the user switches to a different composite process, to recreate the
   * whole tree.
   *
   * <p>Note: This method is not used to create RootNode instances - those are created directly
   * (i.e. using new RootNode()).
   *
   * <p>We also generate Vectors of unconditional predecessor Performs, and associate those with the
   * Perform constructs using the PerformTreeMapper class. See that class for more info.
   */
  private OWLSTreeNode createTree(OWLSTreeNodeInfo ni, OWLIndividual cp, Set preds) {
    OWLIndividual inst = ni.getInstance();
    if (inst == null) {
      System.out.println("ERROR! OWLSTreeMapper.createTree(): inst is null!");
      return null;
    }

    OWLSTreeNode newnode = OWLSTreeNodeFactory.createTreeNode(ni);
    // System.out.println("Building tree for " + newnode.toString());

    if (newnode instanceof ProduceNode) {
      // Store the mapping from produce to composite process in the
      // PerformTreeMapper. This will allow us to generate the Produce's
      // parents, which we need for the ProducedBindingWidget.
      OWLIndividual produce = newnode.getInstance();
      PerformTreeMapper mapper = PerformTreeMapper.getInstance();
      mapper.put(produce, cp);
      mapper.addPredecessors(produce, preds);
    } else if (newnode instanceof PerformNode) {
      // Store the mapping from perform to composite process in the
      // PerformTreeMapper. This will allow us to generate the Performs's
      // parents, which we need for the HasDataFromWidget.
      OWLIndividual perform = newnode.getInstance();
      PerformTreeMapper mapper = PerformTreeMapper.getInstance();
      mapper.put(perform, cp);
      mapper.addPredecessors(perform, preds);
      preds.add(perform);
      // mapper.printAll();
    } else if (newnode instanceof SequenceNode) {
      OWLIndividual components = getComponents(inst);
      // OWLSList clist = new OWLSList(components, OWLSList.CC_LIST, okb);
      OWLSList clist = new OWLSList(inst, okb);
      while (clist.hasNext()) {
        OWLIndividual i = (OWLIndividual) clist.next();
        if (i == null) System.out.println("instance in list is null!");
        OWLSTreeNodeInfo newni = new OWLSTreeNodeInfo(i, okb);
        newnode.add(createTree(newni, cp, preds));
      }
    } else if (newnode instanceof SplitNode || newnode instanceof ChoiceNode) {
      OWLIndividual components = getComponents(inst);
      // OWLSList clist = new OWLSList(components, OWLSList.CC_BAG, okb);
      OWLSList clist = new OWLSList(inst, okb);
      while (clist.hasNext()) {
        HashSet mypreds = new HashSet(preds);
        OWLIndividual i = (OWLIndividual) clist.next();
        OWLSTreeNodeInfo newni = new OWLSTreeNodeInfo(i, okb);
        newnode.add(createTree(newni, cp, mypreds));
      }
    } else if (newnode instanceof SplitJoinNode || newnode instanceof AnyOrderNode) {
      OWLIndividual components = getComponents(inst);
      // OWLSList clist = new OWLSList(components, OWLSList.CC_BAG, okb);
      OWLSList clist = new OWLSList(inst, okb);
      HashSet predsIn = new HashSet(preds);
      while (clist.hasNext()) {
        OWLIndividual i = (OWLIndividual) clist.next();
        OWLSTreeNodeInfo newni = new OWLSTreeNodeInfo(i, okb);
        HashSet mypreds = new HashSet(predsIn);
        newnode.add(createTree(newni, cp, mypreds));
        preds.addAll(mypreds);
      }
    }
    // We put the then-node first and the else-node second as a convention
    // This may need to be handled better (marking the nodes somehow).
    else if (newnode instanceof IfThenElseNode) {
      OWLIndividual thenc = (OWLIndividual) OWLUtils.getNamedSlotValue(inst, "process:then", okb);
      OWLSTreeNodeInfo thenni = new OWLSTreeNodeInfo(thenc, okb);
      HashSet mypreds = new HashSet(preds);
      newnode.add(createTree(thenni, cp, mypreds));
      OWLIndividual elsec = (OWLIndividual) OWLUtils.getNamedSlotValue(inst, "process:else", okb);
      OWLSTreeNodeInfo elseni = new OWLSTreeNodeInfo(elsec, okb);
      if (elsec != null) {
        mypreds = new HashSet(preds);
        newnode.add(createTree(elseni, cp, mypreds));
      }
    } else if (newnode instanceof RepeatWhileNode) {
      OWLIndividual whileProcess =
          (OWLIndividual) OWLUtils.getNamedSlotValue(inst, "process:whileProcess", okb);
      OWLSTreeNodeInfo newni = new OWLSTreeNodeInfo(whileProcess, okb);
      HashSet mypreds = new HashSet(preds);
      newnode.add(createTree(newni, cp, mypreds));
    } else if (newnode instanceof RepeatUntilNode) {
      OWLIndividual untilProcess =
          (OWLIndividual) OWLUtils.getNamedSlotValue(inst, "process:untilProcess", okb);
      OWLSTreeNodeInfo newni = new OWLSTreeNodeInfo(untilProcess, okb);
      newnode.add(createTree(newni, cp, preds));
    } else {
      System.out.println("Unsupported control construct");
      return null;
    }
    return newnode;
  }