Giter Club home page Giter Club logo

Comments (6)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 21, 2024
i'll take a few days to test this bug report and possibly commit a bug fix.
feel free to send a patch if you fix the problem before me.
thanks

Original comment by fmorbini on 3 Dec 2011 at 9:32

from scxmlgui.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 21, 2024
Hi,

I'm implementing SCXML, not the GUI, but I can give you my code where I do
this validation so you can use it on yours.

For each state in parallel states check the LCA from transitions and, if
the LCA is the parallel state itself then... validation error...
private void validateNoTransitionBetweenParallelSiblings(ParallelState
parallelState)throws ParallelSiblingTransactionException {

List<State> stateList=stateToList(parallelState);
for(State state:stateList){
for(Transition transition:state.getTransitions()){
if(searchLCA(transition).equals(parallelState)){
throw new ParallelSiblingTransactionException();
}
}
}
 }

To calculate the LCA I calculate first the breadcrumb of each state and
compare until one state is different... the last common state in the
breadcrumb is the LCA.
In my case null is the scxml itself (it depends on how you calculate the
breadcrumb).

protected State searchLCA(Transition transition) {
State[] states = new State[] { transition.getSourceState(),
transition.getTargetState() };
return searchLCA(states);
}

protected State searchLCA(State[] states) {
State LCA= ROOT_STATE;
Iterator<State>[] breadcrumbs = new Iterator[states.length];

// get all the breadcrumbs
for (int i = 0; i < states.length; i++) {
breadcrumbs[i] = states[i].getBreadCrumb().iterator();
i++;
}

 State candidate;
State other;
boolean foundLCA = false;

while (!foundLCA) {
//take the first state from breadcrumbs
candidate=breadcrumbs[0].hasNext()?breadcrumbs[0].next():null;
if(candidate!=null){
//and compare with all the other states
for (int i = 1; i < states.length&&!foundLCA; i++) {
other=breadcrumbs[i].hasNext()?breadcrumbs[0].next():null;
if(other==null||other.equals(candidate)){
foundLCA=true;
 }
}
//if no other states is different from candidate
if(!foundLCA){
//put candidate to LCA
LCA=candidate;
}
 }else{
//there is no candidate so... LCA has been found
foundLCA=true;
}
}
 return LCA;
}


And last, to calculate the breadcrumb (this could be cached to improve
performance):
@Override
public List<State> getBreadCrumb() {
List<State> breadcrumb = new ArrayList<State>();
calculateBreadCrumb(breadcrumb);

return breadcrumb;
}
protected void calculateBreadCrumb(List<State> breadcrumb) {
BasicState aux = (BasicState) parent;
if (aux != null) {
aux.calculateBreadCrumb(breadcrumb);
breadcrumb.add(aux);
}

}

I hope this code could help you!!

Regards.

Original comment by [email protected] on 5 Dec 2011 at 10:47

from scxmlgui.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 21, 2024
Have you found this useful?

Original comment by [email protected] on 9 Dec 2011 at 10:14

from scxmlgui.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 21, 2024
sorry, haven't looked at this yet. I may take an additional couple of weeks 
before i'll be able to check this out.

Original comment by fmorbini on 10 Dec 2011 at 2:17

from scxmlgui.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 21, 2024
fixed in revision 140.

Original comment by fmorbini on 3 Jan 2012 at 6:34

  • Changed state: Fixed

from scxmlgui.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 21, 2024
Thanks!

Original comment by [email protected] on 25 Jan 2012 at 3:42

from scxmlgui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.