コード例 #1
0
ファイル: JiraIssues.java プロジェクト: darkowl91/hotfix
 private Transition find(Iterable<Transition> transitions, String what) {
   for (Transition t : transitions) {
     if (what.equalsIgnoreCase(t.getName())) {
       return t;
     }
   }
   return null;
 }
コード例 #2
0
ファイル: JiraIssues.java プロジェクト: darkowl91/hotfix
 public void updateTickets(JiraTickets tickets) throws ExecutionException, InterruptedException {
   for (JiraTicket t : tickets) {
     Promise<Issue> issuePromise = issueRestClient.getIssue(t.getId());
     Issue i = issuePromise.get();
     // find transition (we need ID)
     Iterable<Transition> transitions =
         issueRestClient.getTransitions(i.getTransitionsUri()).get();
     String tName = "Hotfix Failed";
     if (t.isValid()) {
       tName = "Out On Dev";
     }
     Transition transition = find(transitions, tName);
     if (transition == null) {
       continue;
     }
     // prepare fields
     // List<FieldInput> fields = Arrays.asList(   new FieldInput("resolution",
     // ComplexIssueInputFieldValue.with("name", "RerunPass")));
     Comment comment = Comment.valueOf(StringUtils.join(t.getValidationMessages(), "\n"));
     issueRestClient.transition(i, new TransitionInput(transition.getId(), comment));
   }
 }
コード例 #3
0
ファイル: Node.java プロジェクト: BackupTheBerlios/xds
 /**
  * Vraci kolekci vsech nodu dostupnych zadanym znakem a vsech nodu dostupnych z nasledujicich
  * pomoci E prechodu
  *
  * @param znak
  * @return
  */
 public Set getTransition(char znak) {
   HashSet v = new HashSet();
   Transition t;
   for (int i = 0; i < transitions.size(); i++) {
     t = (Transition) transitions.get(i);
     try {
       if (!(t instanceof ETransition)) {
         if (t.getLetter() == znak) {
           Node n = t.getTarget();
           v.add(n);
           n.addETransition(v);
           // Pridat stavy dosazitelne pomoci E z Nodu n
           // v.addAll(c);
           // Pridat samotny nod n
         }
       }
     } catch (AutomatException e) {
       continue;
     }
   }
   return v;
 }
コード例 #4
0
ファイル: ListArea.java プロジェクト: luwrain/luwrain
 protected boolean onTransition(Transition.Type type, int hint, boolean briefAnnouncement) {
   NullCheck.notNull(type, "type");
   //	NullCheck.notNull(hint, "hint");
   if (noContent()) return true;
   final int index = selectedIndex();
   final int count = model.getItemCount();
   final int emptyCountTop = flags.contains(Flags.EMPTY_LINE_TOP) ? 1 : 0;
   final Transition.State current;
   if (index >= 0) current = new Transition.State(index);
   else if (flags.contains(Flags.EMPTY_LINE_TOP) && hotPointY == 0)
     current = new Transition.State(Transition.State.Type.EMPTY_LINE_TOP);
   else if (flags.contains(Flags.EMPTY_LINE_BOTTOM) && hotPointY == count + emptyCountTop)
     current = new Transition.State(Transition.State.Type.EMPTY_LINE_BOTTOM);
   else return false;
   final Transition.State newState =
       transition.transition(
           type,
           current,
           count,
           flags.contains(Flags.EMPTY_LINE_TOP),
           flags.contains(Flags.EMPTY_LINE_BOTTOM));
   NullCheck.notNull(newState, "newState");
   Log.debug("list", "newState=" + newState.type);
   switch (newState.type) {
     case NO_TRANSITION:
       environment.hint(hint);
       return true;
     case EMPTY_LINE_TOP:
       if (!flags.contains(Flags.EMPTY_LINE_TOP)) return false;
       hotPointY = 0;
       break;
     case EMPTY_LINE_BOTTOM:
       if (!flags.contains(Flags.EMPTY_LINE_BOTTOM)) return false;
       hotPointY = count + emptyCountTop;
       break;
     case ITEM_INDEX:
       if (newState.itemIndex < 0 || newState.itemIndex >= count) return false;
       hotPointY = newState.itemIndex + emptyCountTop;
       break;
     default:
       return false;
   }
   onNewHotPointY(briefAnnouncement);
   return true;
 }
コード例 #5
0
ファイル: AMLtoPNML.java プロジェクト: CaoAo/BeehiveZ
  public static PetriNet convert(ConfigurableEPC baseEPC) {
    HashMap<EPCFunction, Transition> functionActivityMapping;
    HashMap<EPCConnector, Place> xorconnectorChoiceMapping;

    // HV: Initialize the mappings.
    functionActivityMapping = new HashMap<EPCFunction, Transition>();
    xorconnectorChoiceMapping = new HashMap<EPCConnector, Place>();

    // Check to use the weights if necessary
    // HV: Add both mappings. On completion, these will be filledd.
    PetriNet petrinet =
        EPCToPetriNetConverter.convert(
            baseEPC, new HashMap(), functionActivityMapping, xorconnectorChoiceMapping);

    HashSet visible = new HashSet();

    // HV: The next block is taken care of by the functionActivityMapping
    // below.
    /*
     * Iterator it = petrinet.getTransitions().iterator(); while
     * (it.hasNext()) { Transition t = (Transition) it.next(); if (t.object
     * instanceof EPCFunction) { // if (t.getLogEvent() != null) { // Add
     * transitions with LogEvent (i.e. referring to functions)
     * visible.add(t); } }
     */

    // HV: Prevent the places mapped onto from being reduced.
    visible.addAll(functionActivityMapping.values());
    visible.addAll(xorconnectorChoiceMapping.values());
    Message.add(visible.toString(), Message.DEBUG);

    Iterator it = petrinet.getPlaces().iterator();
    while (it.hasNext()) {
      Place p = (Place) it.next();
      if (p.inDegree() * p.outDegree() == 0) {
        // Add Initial and final places to visible, i.e. places that
        // refer to in and output events
        visible.add(p);
      }
    }

    // Reduce the PetriNet with Murata rules, while keeping the visible ones
    PetriNetReduction pnred = new PetriNetReduction();
    pnred.setNonReducableNodes(visible);

    HashMap pnMap = new HashMap(); // Used to map pre-reduction nodes to
    // post-reduction nodes.
    PetriNet reduced = pnred.reduce(petrinet, pnMap);

    if (reduced != petrinet) {
      // Update both mappings from pre-reduction nodes to post-reduction
      // nodes.
      HashMap<EPCFunction, Transition> newFunctionActivityMapping =
          new HashMap<EPCFunction, Transition>();
      for (EPCFunction function : functionActivityMapping.keySet()) {
        Transition transition = (Transition) functionActivityMapping.get(function);
        if (pnMap.keySet().contains(transition)) {
          newFunctionActivityMapping.put(function, (Transition) pnMap.get(transition));
        }
      }
      functionActivityMapping = newFunctionActivityMapping;
      HashMap<EPCConnector, Place> newXorconnectorChoiceMapping =
          new HashMap<EPCConnector, Place>();
      for (EPCConnector connector : xorconnectorChoiceMapping.keySet()) {
        Place place = (Place) xorconnectorChoiceMapping.get(connector);
        if (pnMap.keySet().contains(place)) {
          newXorconnectorChoiceMapping.put(connector, (Place) pnMap.get(place));
        }
      }
      xorconnectorChoiceMapping = newXorconnectorChoiceMapping;
    }
    reduced.makeClusters();

    // filter the \nunknown:normal
    ArrayList<Transition> alTrans = reduced.getVisibleTasks();
    for (int i = 0; i < alTrans.size(); i++) {
      Transition t = alTrans.get(i);
      String id = t.getIdentifier();
      int idx = id.indexOf("\\nunknown:normal");
      if (idx > 0) {
        id = id.substring(0, idx);
      }
      // �˴������ֵ��ѯ�滻���е�label
      String mappedId = htDict.get(id);
      if (mappedId != null) {
        t.setIdentifier(mappedId);
      } else {
        t.setIdentifier(id);
      }
    }

    return reduced;
  }
コード例 #6
0
  /** Construct the parallel composition of two PTAs. */
  public PTA compose(PTA pta1, PTA pta2) {
    Set<String> alpha1, alpha2, alpha1only, alpha2only, sync;
    Transition transition;
    Edge edge;
    double prob;
    IndexPair state;
    int src, dest;

    // Store PTAs locally and create new one to store parallel composition
    this.pta1 = pta1;
    this.pta2 = pta2;
    par = new PTA();

    // New set of clocks is union of sets for two PTAs
    for (String s : pta1.clockNames) {
      par.getOrAddClock(s);
    }
    for (String s : pta2.clockNames) {
      par.getOrAddClock(s);
    }

    // Get alphabets, compute intersection etc.
    alpha1 = pta1.getAlphabet();
    alpha2 = pta2.getAlphabet();
    // System.out.println("alpha1: " + alpha1);
    // System.out.println("alpha2: " + alpha2);
    sync = new LinkedHashSet<String>();
    alpha1only = new LinkedHashSet<String>();
    alpha2only = new LinkedHashSet<String>();
    for (String a : alpha1) {
      if (!("".equals(a)) && alpha2.contains(a)) {
        sync.add(a);
      } else {
        alpha1only.add(a);
      }
    }
    for (String a : alpha2) {
      if (!alpha1.contains(a)) {
        alpha2only.add(a);
      }
    }
    // Explicitly add tau to action lists
    alpha1only.add("");
    alpha2only.add("");
    // System.out.println("alpha1only: " + alpha1only);
    // System.out.println("alpha2only: " + alpha2only);
    // System.out.println("sync: " + sync);

    // Initialise states storage
    states = new IndexedSet<IndexPair>();
    explore = new LinkedList<IndexPair>();
    // Add initial location
    addState(0, 0);
    src = -1;
    while (!explore.isEmpty()) {
      // Pick next state to explore
      // (they are stored in order found so know index is src+1)
      state = explore.removeFirst();
      src++;
      // Go through asynchronous transitions of PTA 1
      for (String a : alpha1only) {
        for (Transition transition1 : pta1.getTransitionsByAction(state.i1, a)) {
          // Create new transition
          transition = par.addTransition(src, a);
          // Copy guard
          for (Constraint c : transition1.getGuardConstraints())
            transition.addGuardConstraint(c.deepCopy().renameClocks(pta1, par));
          // Combine edges
          for (Edge edge1 : transition1.getEdges()) {
            prob = edge1.getProbability();
            dest = addState(edge1.getDestination(), state.i2);
            edge = transition.addEdge(prob, dest);
            // Copy resets
            for (Map.Entry<Integer, Integer> e : edge1.getResets()) {
              edge.addReset(PTA.renameClock(pta1, par, e.getKey()), e.getValue());
            }
          }
        }
      }
      // Go through asynchronous transitions of PTA 2
      for (String a : alpha2only) {
        for (Transition transition2 : pta2.getTransitionsByAction(state.i2, a)) {
          // Create new transition
          transition = par.addTransition(src, a);
          // Copy guard
          for (Constraint c : transition2.getGuardConstraints())
            transition.addGuardConstraint(c.deepCopy().renameClocks(pta2, par));
          // Combine edges
          for (Edge edge2 : transition2.getEdges()) {
            prob = edge2.getProbability();
            dest = addState(state.i1, edge2.getDestination());
            edge = transition.addEdge(prob, dest);
            // Copy resets
            for (Map.Entry<Integer, Integer> e : edge2.getResets()) {
              edge.addReset(PTA.renameClock(pta2, par, e.getKey()), e.getValue());
            }
          }
        }
      }
      // Go through synchronous transitions
      for (String a : sync) {
        for (Transition transition1 : pta1.getTransitionsByAction(state.i1, a)) {
          for (Transition transition2 : pta2.getTransitionsByAction(state.i2, a)) {
            // Create new transition
            transition = par.addTransition(src, a);
            // Guard is conjunction of guards
            for (Constraint c : transition1.getGuardConstraints())
              transition.addGuardConstraint(c.deepCopy().renameClocks(pta1, par));
            for (Constraint c : transition2.getGuardConstraints())
              transition.addGuardConstraint(c.deepCopy().renameClocks(pta2, par));
            // Combine edges
            for (Edge edge1 : transition1.getEdges()) {
              for (Edge edge2 : transition2.getEdges()) {
                prob = edge1.getProbability() * edge2.getProbability();
                dest = addState(edge1.getDestination(), edge2.getDestination());
                edge = transition.addEdge(prob, dest);
                // Reset set is union of reset sets
                for (Map.Entry<Integer, Integer> e : edge1.getResets()) {
                  edge.addReset(PTA.renameClock(pta1, par, e.getKey()), e.getValue());
                }
                for (Map.Entry<Integer, Integer> e : edge2.getResets()) {
                  edge.addReset(PTA.renameClock(pta2, par, e.getKey()), e.getValue());
                }
              }
            }
          }
        }
      }
    }

    return par;
  }
コード例 #7
0
  /** Build a time bounded reachability query into a PTA; return the new target location set. */
  private BitSet buildTimeBoundIntoPta(
      PTA pta, BitSet targetLocs, int timeBound, boolean timeBoundStrict) {
    String timerClock = null;
    int timerClockIndex, numLocs, newTargetLoc;
    String newTargetLocString;
    List<Transition> trNewList;
    Transition trNew;
    BitSet targetLocsNew;
    boolean toTarget;
    int i;

    // Add a timer clock
    timerClock = "time";
    while (pta.getClockIndex(timerClock) != -1) timerClock += "_";
    timerClockIndex = pta.addClock(timerClock);
    // Add a new target location
    numLocs = pta.getNumLocations();
    newTargetLocString = "target";
    while (pta.getLocationIndex(newTargetLocString) != -1) newTargetLocString += "_";
    newTargetLoc = pta.addLocation(newTargetLocString);
    // Go through old (on-target) locations
    for (i = 0; i < numLocs; i++) {
      trNewList = new ArrayList<Transition>();
      for (Transition tr : pta.getTransitions(i)) {
        // See if the transition can go to a target location
        toTarget = false;
        for (Edge e : tr.getEdges()) {
          if (targetLocs.get(e.getDestination())) {
            toTarget = true;
            break;
          }
        }
        // Copy transition, modify edges going to target and add guard
        if (toTarget) {
          trNew = new Transition(tr);
          for (Edge e : trNew.getEdges()) {
            if (targetLocs.get(e.getDestination())) {
              e.setDestination(newTargetLoc);
            }
          }
          if (timeBoundStrict)
            trNew.addGuardConstraint(Constraint.buildLt(timerClockIndex, timeBound));
          else trNew.addGuardConstraint(Constraint.buildLeq(timerClockIndex, timeBound));
          trNewList.add(trNew);
          // Modify guard of copied transition
          if (timeBoundStrict)
            tr.addGuardConstraint(Constraint.buildGeq(timerClockIndex, timeBound));
          else tr.addGuardConstraint(Constraint.buildGt(timerClockIndex, timeBound));
        }
      }
      // Add new transitions to PTA
      for (Transition tr : trNewList) {
        pta.addTransition(tr);
      }
    }
    // Re-generate set of target locations
    targetLocsNew = new BitSet(pta.getNumLocations());
    targetLocsNew.set(newTargetLoc);

    return targetLocsNew;
  }
コード例 #8
0
ファイル: Optimizer.java プロジェクト: MaurizioPz/CC_SMC
 private void addTransitionsForState() {
   Transition transition = new Transition();
   transition.currentState = currentState.name;
   addSubTransitions(transition);
   optimizedStateMachine.transitions.add(transition);
 }