コード例 #1
0
  @Check(CheckType.FAST)
  public void transitionsWithNoTrigger(Transition trans) {
    if (trans.getSource() instanceof Entry
        || trans.getSource() instanceof Choice
        || trans.getSource() instanceof Synchronization) {
      return;
    }
    if (trans.getSource() instanceof org.yakindu.sct.model.sgraph.State) {
      org.yakindu.sct.model.sgraph.State state =
          (org.yakindu.sct.model.sgraph.State) trans.getSource();
      if (state.isComposite()) {
        for (Region r : state.getRegions()) {
          for (Vertex v : r.getVertices()) {
            if (v instanceof Exit) {
              return;
            }
          }
        }
      }
    }

    if (!STextValidationModelUtils.getExitPointSpecs(trans.getProperties()).isEmpty()) {
      return;
    }

    if (trans.getTrigger() == null) {
      warning(ISSUE_TRANSITION_WITHOUT_TRIGGER, trans, null, -1);
    }
  }
コード例 #2
0
 private ICommand createCompositeStateCommand(ConfigureRequest req) {
   Region region = SGraphFactory.eINSTANCE.createRegion();
   region.setName("r1");
   return new SetValueCommand(
       new SetRequest(
           req.getElementToConfigure(), SGraphPackage.Literals.STATE__SUB_REGIONS, region));
 }
コード例 #3
0
 private ICommand createOrthogonalState(ConfigureRequest req) {
   Region region = SGraphFactory.eINSTANCE.createRegion();
   region.setName("r1");
   Region region2 = SGraphFactory.eINSTANCE.createRegion();
   region2.setName("r2");
   return new SetValueCommand(
       new SetRequest(
           req.getElementToConfigure(),
           SGraphPackage.Literals.STATE__SUB_REGIONS,
           com.google.common.collect.Lists.newArrayList(region, region2)));
 }
コード例 #4
0
 public Entry entry(final Region r) {
   EList<Vertex> _vertices = r.getVertices();
   final Function1<Vertex, Boolean> _function =
       new Function1<Vertex, Boolean>() {
         public Boolean apply(final Vertex v) {
           boolean _and = false;
           if (!(v instanceof Entry)) {
             _and = false;
           } else {
             boolean _or = false;
             boolean _or_1 = false;
             String _name = v.getName();
             boolean _equals = Objects.equal(_name, null);
             if (_equals) {
               _or_1 = true;
             } else {
               String _name_1 = v.getName();
               boolean _equals_1 = "".equals(_name_1);
               _or_1 = (_equals || _equals_1);
             }
             if (_or_1) {
               _or = true;
             } else {
               String _name_2 = v.getName();
               boolean _equals_2 = Objects.equal(_name_2, "default");
               _or = (_or_1 || _equals_2);
             }
             _and = ((v instanceof Entry) && _or);
           }
           return Boolean.valueOf(_and);
         }
       };
   Vertex _findFirst = IterableExtensions.<Vertex>findFirst(_vertices, _function);
   return ((Entry) _findFirst);
 }
コード例 #5
0
 public static Entry _createEntry(EntryKind kind, String name, Region r) {
   Entry entry = SGraphFactory.eINSTANCE.createEntry();
   if (kind != null) entry.setKind(kind);
   else entry.setKind(EntryKind.INITIAL);
   entry.setName(name);
   if (r != null) r.getVertices().add(entry);
   return entry;
 }
コード例 #6
0
 public List<RegularState> collectLeafStates(
     final Region region, final List<RegularState> leafStates) {
   EList<Vertex> _vertices = region.getVertices();
   for (final Vertex v : _vertices) {
     if ((v instanceof RegularState)) {
       this.collectLeafStates(((RegularState) v), leafStates);
     }
   }
   return leafStates;
 }
コード例 #7
0
  /**
   * Checks if all composite states that are siblings of a shallow history can enter their regions.
   *
   * @param e
   */
  @Check(CheckType.FAST)
  public void regionCantBeEnteredUsingShallowHistory(Entry e) {

    if (e.getKind() == EntryKind.SHALLOW_HISTORY) {

      // get all regions off all sibling states
      List<Region> regions = new ArrayList<Region>();
      for (Vertex v : e.getParentRegion().getVertices()) {
        if (v instanceof org.yakindu.sct.model.sgraph.State) {
          org.yakindu.sct.model.sgraph.State state = (org.yakindu.sct.model.sgraph.State) v;
          regions.addAll(state.getRegions());
        }
      }

      // check each region
      for (Region r : regions) {

        // first determine if the region contains a default entry
        Entry defaultEntry = null;
        for (Vertex v : r.getVertices()) {
          if (v instanceof Entry) {
            String name = v.getName().trim().toLowerCase();
            if (name != null || "".equals(name) || "default".equals(name)) {
              defaultEntry = (Entry) v;
              break;
            }
          }
        }

        // now check error conditions
        if (defaultEntry == null) {
          error(ISSUE_REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NO_DEFAULT_ENTRY, r, null, -1);
        } else if (defaultEntry.getOutgoingTransitions().size() != 1) {
          error(
              ISSUE_REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY,
              r,
              null,
              -1);
        }
      }
    }
  }
コード例 #8
0
 public List<RegularState> collectLeafStates(
     final RegularState state, final List<RegularState> leafStates) {
   boolean _isLeaf = this.isLeaf(state);
   if (_isLeaf) {
     leafStates.add(state);
   } else {
     if ((state instanceof State)) {
       final State s = ((State) state);
       EList<Region> _regions = s.getRegions();
       for (final Region r : _regions) {
         EList<Vertex> _vertices = r.getVertices();
         for (final Vertex v : _vertices) {
           if ((v instanceof RegularState)) {
             this.collectLeafStates(((RegularState) v), leafStates);
           }
         }
       }
     }
   }
   return leafStates;
 }
コード例 #9
0
  private Exit createSemanticExitPoint(Transition transition) {
    Region exitPointContainer = getExitPointContainer(transition);
    String name = getExitPointName(transition);

    Exit exitPoint = null;
    Iterator<Vertex> iterator = exitPointContainer.getVertices().iterator();
    while (iterator.hasNext()) {
      Vertex next = iterator.next();
      if (next instanceof Exit) {
        Exit current = (Exit) next;
        if (name.equals(current.getName())) {
          // Do nothing, there already exists an entry point
          return current;
        }
      }
    }

    exitPoint = SGraphFactory.eINSTANCE.createExit();
    exitPoint.setName(name);
    exitPointContainer.getVertices().add(exitPoint);

    return exitPoint;
  }
コード例 #10
0
 public boolean requireShallowHistory(final Region r) {
   EList<Vertex> _vertices = r.getVertices();
   Iterable<Entry> _filter = Iterables.<Entry>filter(_vertices, Entry.class);
   final Function1<Entry, Boolean> _function =
       new Function1<Entry, Boolean>() {
         public Boolean apply(final Entry v) {
           EntryKind _kind = v.getKind();
           boolean _equals = Objects.equal(_kind, EntryKind.SHALLOW_HISTORY);
           return Boolean.valueOf(_equals);
         }
       };
   boolean _exists = IterableExtensions.<Entry>exists(_filter, _function);
   return _exists;
 }
コード例 #11
0
  protected Entry createSemanticEntryPoint(Transition transition) {
    Region entryPointTarget = getEntryPointContainer(transition);
    String name = getEntryPointName(transition);
    Entry entryPoint = null;
    Iterator<Vertex> iterator = entryPointTarget.getVertices().iterator();
    while (iterator.hasNext()) {
      Vertex next = iterator.next();
      if (next instanceof Entry) {
        Entry current = (Entry) next;
        if (name.equals(current.getName())) {
          // Do nothing, there already exists an entry point
          return current;
        }
      }
    }
    entryPoint = SGraphFactory.eINSTANCE.createEntry();
    entryPoint.setName(name);
    entryPointTarget.getVertices().add(entryPoint);
    Transition entryPointTransition = SGraphFactory.eINSTANCE.createTransition();
    entryPointTransition.setSource(entryPoint);
    entryPointTransition.setTarget(transition.getTarget());

    return entryPoint;
  }
コード例 #12
0
 public static FinalState _createFinalState(Region r) {
   FinalState state = SGraphFactory.eINSTANCE.createFinalState();
   if (r != null) r.getVertices().add(state);
   return state;
 }
コード例 #13
0
 public static State _createState(String name, Region r) {
   State state = SGraphFactory.eINSTANCE.createState();
   state.setName(name);
   if (r != null) r.getVertices().add(state);
   return state;
 }
コード例 #14
0
 public static Region _createRegion(String name, State state) {
   Region region = SGraphFactory.eINSTANCE.createRegion();
   region.setName(name);
   if (state != null) state.getRegions().add(region);
   return region;
 }
コード例 #15
0
 public Iterable<Entry> collectEntries(final Region r) {
   EList<Vertex> _vertices = r.getVertices();
   Iterable<Entry> _filter = Iterables.<Entry>filter(_vertices, Entry.class);
   return _filter;
 }