Changeset 1146


Ignore:
Timestamp:
04/04/13 16:06:07 (12 years ago)
Author:
pharms
Message:
  • complete refactoring of task tree model with a separation of task models and task instances
  • appropriate adaptation of task tree generation process
  • appropriate adaptation of commands and task tree visualization
Location:
trunk
Files:
15 added
25 deleted
29 edited
21 copied
12 moved

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-tasktrees-test/.classpath

    r920 r1146  
    11<?xml version="1.0" encoding="UTF-8"?> 
    22<classpath> 
    3         <classpathentry kind="src" output="target/test-classes" path="src/test/java"> 
     3        <classpathentry excluding="de/ugoe/cs/autoquest/tasktrees/temporalrelation/copy/" kind="src" output="target/test-classes" path="src/test/java"> 
    44                <attributes> 
    55                        <attribute name="optional" value="true"/> 
  • trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/manager/TaskTreeManagerTest.java

    r1132 r1146  
    2929import de.ugoe.cs.autoquest.test.DummyGUIElement; 
    3030import de.ugoe.cs.autoquest.test.DummyInteraction; 
     31import de.ugoe.cs.util.console.Console; 
    3132import de.ugoe.cs.util.console.TextConsole; 
    3233 
     
    4748    @Before 
    4849    public void setUp() { 
     50        Console.reset(); 
    4951        new TextConsole(Level.FINEST); 
    5052        manager = new TaskTreeManager(); 
     
    6668    public void testOneEventOnOneElement() { 
    6769        simulateEvent(new DummyInteraction("bla", 1), new DummyGUIElement("elem1")); 
    68         new TaskTreeChecker().assertTaskTree 
    69             ("Sequence root {" + 
    70              "  Sequence session {" + 
    71              "    Event bla {}" + 
    72              "  }" + 
    73              "}", manager.getTaskTree()); 
     70        new TaskTreeChecker().assertTaskInstanceList 
     71            ("UserSession session {" + 
     72             "  Event bla {}" + 
     73             "}", manager.getTaskModel().getUserSessions().get(0)); 
    7474    } 
    7575 
     
    8484        simulateEvent(new DummyInteraction("blo", 1), eventTarget); 
    8585        simulateEvent(new DummyInteraction("blu", 1), eventTarget); 
    86         simulateEvent(new DummyInteraction("bla", 1), eventTarget); 
    87  
    88         new TaskTreeChecker().assertTaskTree 
    89             ("Sequence root {" + 
    90              "  Sequence session {" + 
    91              "    Event bla {}" + 
    92              "    Event bli {}" + 
    93              "    Event blo {}" + 
    94              "    Event blu {}" + 
    95              "    Event bla {}" + 
    96              "  }" + 
    97              "}", manager.getTaskTree()); 
     86        simulateEvent(new DummyInteraction("ble", 1), eventTarget); 
     87 
     88        new TaskTreeChecker().assertTaskInstanceList 
     89            ("UserSession session {" + 
     90             "  Event bla {}" + 
     91             "  Event bli {}" + 
     92             "  Event blo {}" + 
     93             "  Event blu {}" + 
     94             "  Event ble {}" + 
     95             "}", manager.getTaskModel().getUserSessions().get(0)); 
    9896    } 
    9997 
     
    111109        simulateEvent(new DummyInteraction("bla", 1), eventTarget1); 
    112110        simulateEvent(new DummyInteraction("bli", 1), eventTarget2); 
    113         simulateEvent(new DummyInteraction("bla", 1), eventTarget3); 
    114         simulateEvent(new DummyInteraction("bli", 1), eventTarget4); 
    115         simulateEvent(new DummyInteraction("blo", 1), eventTarget5); 
    116         simulateEvent(new DummyInteraction("bla", 1), eventTarget6); 
    117  
    118         new TaskTreeChecker().assertTaskTree 
    119             ("Sequence root {" + 
    120              "  Sequence session {" + 
    121              "    Event bla {}" + 
    122              "    Event bli {}" + 
    123              "    Event bla {}" + 
    124              "    Event bli {}" + 
    125              "    Event blo {}" + 
    126              "    Event bla {}" + 
    127              "  }" + 
    128              "}", manager.getTaskTree()); 
     111        simulateEvent(new DummyInteraction("blo", 1), eventTarget3); 
     112        simulateEvent(new DummyInteraction("blu", 1), eventTarget4); 
     113        simulateEvent(new DummyInteraction("ble", 1), eventTarget5); 
     114        simulateEvent(new DummyInteraction("blum", 1), eventTarget6); 
     115 
     116        new TaskTreeChecker(true).assertTaskInstanceList 
     117            ("UserSession session {" + 
     118             "  Event bla {}" + 
     119             "  Event bli {}" + 
     120             "  Event blo {}" + 
     121             "  Event blu {}" + 
     122             "  Event ble {}" + 
     123             "  Event blum {}" + 
     124             "}", manager.getTaskModel().getUserSessions().get(0)); 
    129125    } 
    130126 
     
    142138        simulateEvent(new DummyInteraction("bla", 1), eventTarget1); 
    143139        simulateEvent(new DummyInteraction("bli", 1), eventTarget1); 
    144         simulateEvent(new DummyInteraction("bla", 1), eventTarget1); 
    145         simulateEvent(new DummyInteraction("bli", 1), eventTarget2); 
     140        simulateEvent(new DummyInteraction("blup", 1), eventTarget1); 
     141        simulateEvent(new DummyInteraction("ble", 1), eventTarget2); 
    146142        simulateEvent(new DummyInteraction("blo", 1), eventTarget2); 
    147         simulateEvent(new DummyInteraction("bla", 1), eventTarget3); 
    148         simulateEvent(new DummyInteraction("bli", 1), eventTarget4); 
    149         simulateEvent(new DummyInteraction("bla", 1), eventTarget4); 
    150         simulateEvent(new DummyInteraction("bli", 1), eventTarget4); 
    151         simulateEvent(new DummyInteraction("blo", 1), eventTarget4); 
    152         simulateEvent(new DummyInteraction("bla", 1), eventTarget5); 
    153         simulateEvent(new DummyInteraction("bli", 1), eventTarget6); 
    154         simulateEvent(new DummyInteraction("bla", 1), eventTarget6); 
    155         simulateEvent(new DummyInteraction("bli", 1), eventTarget6); 
    156         simulateEvent(new DummyInteraction("blo", 1), eventTarget6); 
    157  
    158         new TaskTreeChecker().assertTaskTree 
    159             ("Sequence root {" + 
    160              "  Sequence session {" + 
    161              "    Event bla {}" + 
    162              "    Event bli {}" + 
    163              "    Event bla {}" + 
    164              "    Event bli {}" + 
    165              "    Event blo {}" + 
    166              "    Event bla {}" + 
    167              "    Event bli {}" + 
    168              "    Event bla {}" + 
    169              "    Event bli {}" + 
    170              "    Event blo {}" + 
    171              "    Event bla {}" + 
    172              "    Event bli {}" + 
    173              "    Event bla {}" + 
    174              "    Event bli {}" + 
    175              "    Event blo {}" + 
    176              "  }" + 
    177              "}", manager.getTaskTree()); 
     143        simulateEvent(new DummyInteraction("blau", 1), eventTarget3); 
     144        simulateEvent(new DummyInteraction("blass", 1), eventTarget4); 
     145        simulateEvent(new DummyInteraction("blum", 1), eventTarget4); 
     146        simulateEvent(new DummyInteraction("blim", 1), eventTarget4); 
     147        simulateEvent(new DummyInteraction("blom", 1), eventTarget4); 
     148        simulateEvent(new DummyInteraction("blam", 1), eventTarget5); 
     149        simulateEvent(new DummyInteraction("blip", 1), eventTarget6); 
     150        simulateEvent(new DummyInteraction("blap", 1), eventTarget6); 
     151        simulateEvent(new DummyInteraction("blep", 1), eventTarget6); 
     152        simulateEvent(new DummyInteraction("blop", 1), eventTarget6); 
     153 
     154        new TaskTreeChecker().assertTaskInstanceList 
     155            ("UserSession session {" + 
     156             "  Event bla {}" + 
     157             "  Event bli {}" + 
     158             "  Event blup {}" + 
     159             "  Event ble {}" + 
     160             "  Event blo {}" + 
     161             "  Event blau {}" + 
     162             "  Event blass {}" + 
     163             "  Event blum {}" + 
     164             "  Event blim {}" + 
     165             "  Event blom {}" + 
     166             "  Event blam {}" + 
     167             "  Event blip {}" + 
     168             "  Event blap {}" + 
     169             "  Event blep {}" + 
     170             "  Event blop {}" + 
     171             "}", manager.getTaskModel().getUserSessions().get(0)); 
    178172    } 
    179173 
     
    187181        simulateEvent(event1, eventTarget1); 
    188182        simulateEvent(event1, eventTarget1); 
    189         new TaskTreeChecker().assertTaskTree 
    190             ("Sequence root {" + 
    191              "  Sequence session {" + 
    192              "    Iteration iteration1 {" + 
    193              "      Event bla {}" + 
    194              "    }" + 
     183        new TaskTreeChecker().assertTaskInstanceList 
     184            ("UserSession session {" + 
     185             "  Iteration iteration1 {" + 
     186             "    Event bla {}" + 
     187             "    Event bla {}" + 
    195188             "  }" + 
    196              "}", manager.getTaskTree()); 
     189             "}", manager.getTaskModel().getUserSessions().get(0)); 
    197190    } 
    198191 
     
    208201        } 
    209202 
    210         new TaskTreeChecker().assertTaskTree 
    211             ("Sequence root {" + 
    212              "  Sequence session {" + 
    213              "    Iteration iteration1 {" + 
    214              "      Event bla {}" + 
    215              "    }" + 
     203        new TaskTreeChecker().assertTaskInstanceList 
     204            ("UserSession session {" + 
     205             "  Iteration iteration1 {" + 
     206             "    Event bla {}" + 
     207             "    Event bla {}" + 
     208             "    Event bla {}" + 
     209             "    Event bla {}" + 
     210             "    Event bla {}" + 
     211             "    Event bla {}" + 
     212             "    Event bla {}" + 
     213             "    Event bla {}" + 
     214             "    Event bla {}" + 
     215             "    Event bla {}" + 
    216216             "  }" + 
    217              "}", manager.getTaskTree()); 
     217             "}", manager.getTaskModel().getUserSessions().get(0)); 
    218218    } 
    219219 
     
    229229        IEventType event2 = new DummyInteraction("bli", 1); 
    230230        IEventType event3 = new DummyInteraction("blup", 1); 
     231        IEventType event4 = new DummyInteraction("ble", 1); 
     232        IEventType event5 = new DummyInteraction("blo", 1); 
    231233 
    232234        simulateEvent(event2, eventTarget1); 
     
    235237            simulateEvent(event1, eventTarget1); 
    236238        } 
    237         simulateEvent(event3, eventTarget1); 
    238         simulateEvent(event2, eventTarget1); 
    239  
    240         new TaskTreeChecker().assertTaskTree 
    241             ("Sequence root {" + 
    242              "  Sequence session {" + 
    243              "    Event bli {}" + 
    244              "    Event blup {}" + 
    245              "    Iteration iteration2 {" + 
    246              "      Event bla {}" + 
    247              "    }" + 
    248              "    Event blup {}" + 
    249              "    Event bli {}" + 
     239        simulateEvent(event4, eventTarget1); 
     240        simulateEvent(event5, eventTarget1); 
     241 
     242        new TaskTreeChecker().assertTaskInstanceList 
     243            ("UserSession session {" + 
     244             "  Event bli {}" + 
     245             "  Event blup {}" + 
     246             "  Iteration iteration2 {" + 
     247             "    Event bla {}" + 
     248             "    Event bla {}" + 
     249             "    Event bla {}" + 
     250             "    Event bla {}" + 
     251             "    Event bla {}" + 
     252             "    Event bla {}" + 
     253             "    Event bla {}" + 
     254             "    Event bla {}" + 
     255             "    Event bla {}" + 
     256             "    Event bla {}" + 
    250257             "  }" + 
    251              "}", manager.getTaskTree()); 
     258             "  Event ble {}" + 
     259             "  Event blo {}" + 
     260             "}", manager.getTaskModel().getUserSessions().get(0)); 
    252261 
    253262    } 
     
    264273 
    265274        // now test with iterations of iterations 
    266         for (int i = 0; i < 10; i++) { 
     275        for (int i = 0; i < 5; i++) { 
    267276            for (int j = 0; j < 5; j++) { 
    268277                simulateEvent(event1, eventTarget1); 
     
    276285        } 
    277286 
    278         new TaskTreeChecker().assertTaskTree 
    279             ("Sequence root {" + 
    280              "  Sequence session {" + 
    281              "    Iteration iteration2 {" + 
    282              "      Sequence sequence1 {" + 
    283              "        Iteration iteration3 {" + 
    284              "          Event bla {}" + 
    285              "        }" + 
    286              "        Iteration iteration4 {" + 
    287              "          Event bli {}" + 
    288              "        }" + 
    289              "        Iteration iteration5 {" + 
    290              "          Event blup {}" + 
    291              "        }" + 
     287        new TaskTreeChecker().assertTaskInstanceList 
     288            ("UserSession session {" + 
     289             "  Iteration iteration2 {" + 
     290             "    Sequence sequence1 {" + 
     291             "      Iteration iteration3 {" + 
     292             "        Event bla {}" + 
     293             "        Event bla {}" + 
     294             "        Event bla {}" + 
     295             "        Event bla {}" + 
     296             "        Event bla {}" + 
     297             "      }" + 
     298             "      Iteration iteration4 {" + 
     299             "        Event bli {}" + 
     300             "        Event bli {}" + 
     301             "        Event bli {}" + 
     302             "        Event bli {}" + 
     303             "        Event bli {}" + 
     304             "      }" + 
     305             "      Iteration iteration5 {" + 
     306             "        Event blup {}" + 
     307             "        Event blup {}" + 
     308             "        Event blup {}" + 
     309             "        Event blup {}" + 
     310             "        Event blup {}" + 
     311             "      }" + 
     312             "    }" + 
     313             "    Sequence sequence1 {" + 
     314             "      Iteration iteration3 {" + 
     315             "        Event bla {}" + 
     316             "        Event bla {}" + 
     317             "        Event bla {}" + 
     318             "        Event bla {}" + 
     319             "        Event bla {}" + 
     320             "      }" + 
     321             "      Iteration iteration4 {" + 
     322             "        Event bli {}" + 
     323             "        Event bli {}" + 
     324             "        Event bli {}" + 
     325             "        Event bli {}" + 
     326             "        Event bli {}" + 
     327             "      }" + 
     328             "      Iteration iteration5 {" + 
     329             "        Event blup {}" + 
     330             "        Event blup {}" + 
     331             "        Event blup {}" + 
     332             "        Event blup {}" + 
     333             "        Event blup {}" + 
     334             "      }" + 
     335             "    }" + 
     336             "    Sequence sequence1 {" + 
     337             "      Iteration iteration3 {" + 
     338             "        Event bla {}" + 
     339             "        Event bla {}" + 
     340             "        Event bla {}" + 
     341             "        Event bla {}" + 
     342             "        Event bla {}" + 
     343             "      }" + 
     344             "      Iteration iteration4 {" + 
     345             "        Event bli {}" + 
     346             "        Event bli {}" + 
     347             "        Event bli {}" + 
     348             "        Event bli {}" + 
     349             "        Event bli {}" + 
     350             "      }" + 
     351             "      Iteration iteration5 {" + 
     352             "        Event blup {}" + 
     353             "        Event blup {}" + 
     354             "        Event blup {}" + 
     355             "        Event blup {}" + 
     356             "        Event blup {}" + 
     357             "      }" + 
     358             "    }" + 
     359             "    Sequence sequence1 {" + 
     360             "      Iteration iteration3 {" + 
     361             "        Event bla {}" + 
     362             "        Event bla {}" + 
     363             "        Event bla {}" + 
     364             "        Event bla {}" + 
     365             "        Event bla {}" + 
     366             "      }" + 
     367             "      Iteration iteration4 {" + 
     368             "        Event bli {}" + 
     369             "        Event bli {}" + 
     370             "        Event bli {}" + 
     371             "        Event bli {}" + 
     372             "        Event bli {}" + 
     373             "      }" + 
     374             "      Iteration iteration5 {" + 
     375             "        Event blup {}" + 
     376             "        Event blup {}" + 
     377             "        Event blup {}" + 
     378             "        Event blup {}" + 
     379             "        Event blup {}" + 
     380             "      }" + 
     381             "    }" + 
     382             "    Sequence sequence1 {" + 
     383             "      Iteration iteration3 {" + 
     384             "        Event bla {}" + 
     385             "        Event bla {}" + 
     386             "        Event bla {}" + 
     387             "        Event bla {}" + 
     388             "        Event bla {}" + 
     389             "      }" + 
     390             "      Iteration iteration4 {" + 
     391             "        Event bli {}" + 
     392             "        Event bli {}" + 
     393             "        Event bli {}" + 
     394             "        Event bli {}" + 
     395             "        Event bli {}" + 
     396             "      }" + 
     397             "      Iteration iteration5 {" + 
     398             "        Event blup {}" + 
     399             "        Event blup {}" + 
     400             "        Event blup {}" + 
     401             "        Event blup {}" + 
     402             "        Event blup {}" + 
    292403             "      }" + 
    293404             "    }" + 
    294405             "  }" + 
    295              "}", manager.getTaskTree()); 
     406             "}", manager.getTaskModel().getUserSessions().get(0)); 
    296407 
    297408    } 
     
    315426        simulateEvent(event3, eventTarget1); 
    316427         
    317         new TaskTreeChecker().assertTaskTree 
    318             ("Sequence root {" + 
    319              "  Sequence session {" + 
    320              "    Iteration iteration1 {" + 
    321              "      Sequence sequence2 {" + 
    322              "        Event bla {}" + 
    323              "        Event bli {}" + 
    324              "        Event blup {}" + 
    325              "      }" + 
     428        new TaskTreeChecker().assertTaskInstanceList 
     429            ("UserSession session {" + 
     430             "  Iteration iteration1 {" + 
     431             "    Sequence sequence2 {" + 
     432             "      Event bla {}" + 
     433             "      Event bli {}" + 
     434             "      Event blup {}" + 
     435             "    }" + 
     436             "    Sequence sequence2 {" + 
     437             "      Event bla {}" + 
     438             "      Event bli {}" + 
     439             "      Event blup {}" + 
    326440             "    }" + 
    327441             "  }" + 
    328              "}", manager.getTaskTree()); 
     442             "}", manager.getTaskModel().getUserSessions().get(0)); 
    329443    } 
    330444 
     
    345459        } 
    346460 
    347         new TaskTreeChecker().assertTaskTree 
    348             ("Sequence root {" + 
    349              "  Sequence session {" + 
    350              "    Iteration iteration1 {" + 
    351              "      Sequence sequence2 {" + 
    352              "        Event bla {}" + 
    353              "        Event bli {}" + 
    354              "        Event blup {}" + 
    355              "      }" + 
     461        new TaskTreeChecker().assertTaskInstanceList 
     462            ("UserSession session {" + 
     463             "  Iteration iteration1 {" + 
     464             "    Sequence sequence2 {" + 
     465             "      Event bla {}" + 
     466             "      Event bli {}" + 
     467             "      Event blup {}" + 
     468             "    }" + 
     469             "    Sequence sequence2 {" + 
     470             "      Event bla {}" + 
     471             "      Event bli {}" + 
     472             "      Event blup {}" + 
     473             "    }" + 
     474             "    Sequence sequence2 {" + 
     475             "      Event bla {}" + 
     476             "      Event bli {}" + 
     477             "      Event blup {}" + 
     478             "    }" + 
     479             "    Sequence sequence2 {" + 
     480             "      Event bla {}" + 
     481             "      Event bli {}" + 
     482             "      Event blup {}" + 
     483             "    }" + 
     484             "    Sequence sequence2 {" + 
     485             "      Event bla {}" + 
     486             "      Event bli {}" + 
     487             "      Event blup {}" + 
     488             "    }" + 
     489             "    Sequence sequence2 {" + 
     490             "      Event bla {}" + 
     491             "      Event bli {}" + 
     492             "      Event blup {}" + 
     493             "    }" + 
     494             "    Sequence sequence2 {" + 
     495             "      Event bla {}" + 
     496             "      Event bli {}" + 
     497             "      Event blup {}" + 
     498             "    }" + 
     499             "    Sequence sequence2 {" + 
     500             "      Event bla {}" + 
     501             "      Event bli {}" + 
     502             "      Event blup {}" + 
     503             "    }" + 
     504             "    Sequence sequence2 {" + 
     505             "      Event bla {}" + 
     506             "      Event bli {}" + 
     507             "      Event blup {}" + 
     508             "    }" + 
     509             "    Sequence sequence2 {" + 
     510             "      Event bla {}" + 
     511             "      Event bli {}" + 
     512             "      Event blup {}" + 
    356513             "    }" + 
    357514             "  }" + 
    358              "}", manager.getTaskTree()); 
     515             "}", manager.getTaskModel().getUserSessions().get(0)); 
    359516    } 
    360517 
     
    375532         
    376533        simulateEvent(event4, eventTarget1); 
    377         simulateEvent(event5, eventTarget1); 
    378         simulateEvent(event6, eventTarget1); 
    379         for (int i = 0; i < 10; i++) { 
     534        for (int i = 0; i < 5; i++) { 
    380535            simulateEvent(event1, eventTarget1); 
    381536            simulateEvent(event2, eventTarget1); 
    382537            simulateEvent(event3, eventTarget1); 
    383538        } 
     539        simulateEvent(event5, eventTarget1); 
    384540        simulateEvent(event6, eventTarget1); 
    385         simulateEvent(event5, eventTarget1); 
    386         simulateEvent(event4, eventTarget1); 
    387  
    388         new TaskTreeChecker().assertTaskTree 
    389             ("Sequence root {" + 
    390              "  Sequence session {" + 
    391              "    Event ble {}" + 
    392              "    Event blo {}" + 
    393              "    Event blu {}" + 
    394              "    Iteration iteration2 {" + 
    395              "      Sequence sequence3 {" + 
    396              "        Event bla {}" + 
    397              "        Event bli {}" + 
    398              "        Event blup {}" + 
    399              "      }" + 
    400              "    }" + 
    401              "    Event blu {}" + 
    402              "    Event blo {}" + 
    403              "    Event ble {}" + 
     541 
     542        new TaskTreeChecker().assertTaskInstanceList 
     543            ("UserSession session {" + 
     544             "  Event ble {}" + 
     545             "  Iteration iteration2 {" + 
     546             "    Sequence sequence3 {" + 
     547             "      Event bla {}" + 
     548             "      Event bli {}" + 
     549             "      Event blup {}" + 
     550             "    }" + 
     551             "    Sequence sequence3 {" + 
     552             "      Event bla {}" + 
     553             "      Event bli {}" + 
     554             "      Event blup {}" + 
     555             "    }" + 
     556             "    Sequence sequence3 {" + 
     557             "      Event bla {}" + 
     558             "      Event bli {}" + 
     559             "      Event blup {}" + 
     560             "    }" + 
     561             "    Sequence sequence3 {" + 
     562             "      Event bla {}" + 
     563             "      Event bli {}" + 
     564             "      Event blup {}" + 
     565             "    }" + 
     566             "    Sequence sequence3 {" + 
     567             "      Event bla {}" + 
     568             "      Event bli {}" + 
     569             "      Event blup {}" + 
     570             "    }" + 
    404571             "  }" + 
    405              "}", manager.getTaskTree()); 
     572             "  Event blo {}" + 
     573             "  Event blu {}" + 
     574             "}", manager.getTaskModel().getUserSessions().get(0)); 
    406575    } 
    407576 
     
    418587        IEventType event5 = new DummyInteraction("blau", 1); 
    419588        IEventType event6 = new DummyInteraction("blass", 1); 
     589        IEventType event7 = new DummyInteraction("ble", 1); 
     590        IEventType event8 = new DummyInteraction("blum", 1); 
     591        IEventType event9 = new DummyInteraction("blop", 1); 
    420592 
    421593        // now test with iterations of iterations 
    422         for (int i = 0; i < 10; i++) { 
     594        for (int i = 0; i < 5; i++) { 
    423595            for (int j = 0; j < 5; j++) { 
    424596                simulateEvent(event1, eventTarget1); 
     
    432604            } 
    433605            for (int j = 0; j < 5; j++) { 
    434                 simulateEvent(event1, eventTarget1); 
    435                 simulateEvent(event3, eventTarget1); 
    436                 simulateEvent(event5, eventTarget1); 
     606                simulateEvent(event7, eventTarget1); 
     607                simulateEvent(event8, eventTarget1); 
     608                simulateEvent(event9, eventTarget1); 
    437609            } 
    438610        } 
    439611 
    440         new TaskTreeChecker().assertTaskTree 
    441             ("Sequence root {" + 
    442              "  Sequence session {" + 
    443              "    Iteration iteration3 {" + 
    444              "      Sequence sequence4 {" + 
    445              "        Iteration iteration4 {" + 
    446              "          Sequence sequence4 {" + 
    447              "            Event bla {}" + 
    448              "            Event bli {}" + 
    449              "            Event blup {}" + 
    450              "          }" + 
    451              "        }" + 
    452              "        Iteration iteration5 {" + 
    453              "          Sequence sequence5 {" + 
    454              "            Event blo {}" + 
    455              "            Event blau {}" + 
    456              "            Event blass {}" + 
    457              "          }" + 
    458              "        }" + 
    459              "        Iteration iteration6 {" + 
    460              "          Sequence sequence6 {" + 
    461              "            Event bla {}" + 
    462              "            Event blup {}" + 
    463              "            Event blau {}" + 
    464              "          }" + 
     612        new TaskTreeChecker().assertTaskInstanceList 
     613            ("UserSession session {" + 
     614             "  Iteration iteration3 {" + 
     615             "    Sequence sequence1 {" + 
     616             "      Iteration iteration4 {" + 
     617             "        Sequence sequence4 {" + 
     618             "          Event bla {}" + 
     619             "          Event bli {}" + 
     620             "          Event blup {}" + 
     621             "        }" + 
     622             "        Sequence sequence4 {" + 
     623             "          Event bla {}" + 
     624             "          Event bli {}" + 
     625             "          Event blup {}" + 
     626             "        }" + 
     627             "        Sequence sequence4 {" + 
     628             "          Event bla {}" + 
     629             "          Event bli {}" + 
     630             "          Event blup {}" + 
     631             "        }" + 
     632             "        Sequence sequence4 {" + 
     633             "          Event bla {}" + 
     634             "          Event bli {}" + 
     635             "          Event blup {}" + 
     636             "        }" + 
     637             "        Sequence sequence4 {" + 
     638             "          Event bla {}" + 
     639             "          Event bli {}" + 
     640             "          Event blup {}" + 
     641             "        }" + 
     642             "      }" + 
     643             "      Iteration iteration5 {" + 
     644             "        Sequence sequence5 {" + 
     645             "          Event blo {}" + 
     646             "          Event blau {}" + 
     647             "          Event blass {}" + 
     648             "        }" + 
     649             "        Sequence sequence5 {" + 
     650             "          Event blo {}" + 
     651             "          Event blau {}" + 
     652             "          Event blass {}" + 
     653             "        }" + 
     654             "        Sequence sequence5 {" + 
     655             "          Event blo {}" + 
     656             "          Event blau {}" + 
     657             "          Event blass {}" + 
     658             "        }" + 
     659             "        Sequence sequence5 {" + 
     660             "          Event blo {}" + 
     661             "          Event blau {}" + 
     662             "          Event blass {}" + 
     663             "        }" + 
     664             "        Sequence sequence5 {" + 
     665             "          Event blo {}" + 
     666             "          Event blau {}" + 
     667             "          Event blass {}" + 
     668             "        }" + 
     669             "      }" + 
     670             "      Iteration iteration6 {" + 
     671             "        Sequence sequence6 {" + 
     672             "          Event ble {}" + 
     673             "          Event blum {}" + 
     674             "          Event blop {}" + 
     675             "        }" + 
     676             "        Sequence sequence6 {" + 
     677             "          Event ble {}" + 
     678             "          Event blum {}" + 
     679             "          Event blop {}" + 
     680             "        }" + 
     681             "        Sequence sequence6 {" + 
     682             "          Event ble {}" + 
     683             "          Event blum {}" + 
     684             "          Event blop {}" + 
     685             "        }" + 
     686             "        Sequence sequence6 {" + 
     687             "          Event ble {}" + 
     688             "          Event blum {}" + 
     689             "          Event blop {}" + 
     690             "        }" + 
     691             "        Sequence sequence6 {" + 
     692             "          Event ble {}" + 
     693             "          Event blum {}" + 
     694             "          Event blop {}" + 
     695             "        }" + 
     696             "      }" + 
     697             "    }" + 
     698             "    Sequence sequence1 {" + 
     699             "      Iteration iteration4 {" + 
     700             "        Sequence sequence4 {" + 
     701             "          Event bla {}" + 
     702             "          Event bli {}" + 
     703             "          Event blup {}" + 
     704             "        }" + 
     705             "        Sequence sequence4 {" + 
     706             "          Event bla {}" + 
     707             "          Event bli {}" + 
     708             "          Event blup {}" + 
     709             "        }" + 
     710             "        Sequence sequence4 {" + 
     711             "          Event bla {}" + 
     712             "          Event bli {}" + 
     713             "          Event blup {}" + 
     714             "        }" + 
     715             "        Sequence sequence4 {" + 
     716             "          Event bla {}" + 
     717             "          Event bli {}" + 
     718             "          Event blup {}" + 
     719             "        }" + 
     720             "        Sequence sequence4 {" + 
     721             "          Event bla {}" + 
     722             "          Event bli {}" + 
     723             "          Event blup {}" + 
     724             "        }" + 
     725             "      }" + 
     726             "      Iteration iteration5 {" + 
     727             "        Sequence sequence5 {" + 
     728             "          Event blo {}" + 
     729             "          Event blau {}" + 
     730             "          Event blass {}" + 
     731             "        }" + 
     732             "        Sequence sequence5 {" + 
     733             "          Event blo {}" + 
     734             "          Event blau {}" + 
     735             "          Event blass {}" + 
     736             "        }" + 
     737             "        Sequence sequence5 {" + 
     738             "          Event blo {}" + 
     739             "          Event blau {}" + 
     740             "          Event blass {}" + 
     741             "        }" + 
     742             "        Sequence sequence5 {" + 
     743             "          Event blo {}" + 
     744             "          Event blau {}" + 
     745             "          Event blass {}" + 
     746             "        }" + 
     747             "        Sequence sequence5 {" + 
     748             "          Event blo {}" + 
     749             "          Event blau {}" + 
     750             "          Event blass {}" + 
     751             "        }" + 
     752             "      }" + 
     753             "      Iteration iteration6 {" + 
     754             "        Sequence sequence6 {" + 
     755             "          Event ble {}" + 
     756             "          Event blum {}" + 
     757             "          Event blop {}" + 
     758             "        }" + 
     759             "        Sequence sequence6 {" + 
     760             "          Event ble {}" + 
     761             "          Event blum {}" + 
     762             "          Event blop {}" + 
     763             "        }" + 
     764             "        Sequence sequence6 {" + 
     765             "          Event ble {}" + 
     766             "          Event blum {}" + 
     767             "          Event blop {}" + 
     768             "        }" + 
     769             "        Sequence sequence6 {" + 
     770             "          Event ble {}" + 
     771             "          Event blum {}" + 
     772             "          Event blop {}" + 
     773             "        }" + 
     774             "        Sequence sequence6 {" + 
     775             "          Event ble {}" + 
     776             "          Event blum {}" + 
     777             "          Event blop {}" + 
     778             "        }" + 
     779             "      }" + 
     780             "    }" + 
     781             "    Sequence sequence1 {" + 
     782             "      Iteration iteration4 {" + 
     783             "        Sequence sequence4 {" + 
     784             "          Event bla {}" + 
     785             "          Event bli {}" + 
     786             "          Event blup {}" + 
     787             "        }" + 
     788             "        Sequence sequence4 {" + 
     789             "          Event bla {}" + 
     790             "          Event bli {}" + 
     791             "          Event blup {}" + 
     792             "        }" + 
     793             "        Sequence sequence4 {" + 
     794             "          Event bla {}" + 
     795             "          Event bli {}" + 
     796             "          Event blup {}" + 
     797             "        }" + 
     798             "        Sequence sequence4 {" + 
     799             "          Event bla {}" + 
     800             "          Event bli {}" + 
     801             "          Event blup {}" + 
     802             "        }" + 
     803             "        Sequence sequence4 {" + 
     804             "          Event bla {}" + 
     805             "          Event bli {}" + 
     806             "          Event blup {}" + 
     807             "        }" + 
     808             "      }" + 
     809             "      Iteration iteration5 {" + 
     810             "        Sequence sequence5 {" + 
     811             "          Event blo {}" + 
     812             "          Event blau {}" + 
     813             "          Event blass {}" + 
     814             "        }" + 
     815             "        Sequence sequence5 {" + 
     816             "          Event blo {}" + 
     817             "          Event blau {}" + 
     818             "          Event blass {}" + 
     819             "        }" + 
     820             "        Sequence sequence5 {" + 
     821             "          Event blo {}" + 
     822             "          Event blau {}" + 
     823             "          Event blass {}" + 
     824             "        }" + 
     825             "        Sequence sequence5 {" + 
     826             "          Event blo {}" + 
     827             "          Event blau {}" + 
     828             "          Event blass {}" + 
     829             "        }" + 
     830             "        Sequence sequence5 {" + 
     831             "          Event blo {}" + 
     832             "          Event blau {}" + 
     833             "          Event blass {}" + 
     834             "        }" + 
     835             "      }" + 
     836             "      Iteration iteration6 {" + 
     837             "        Sequence sequence6 {" + 
     838             "          Event ble {}" + 
     839             "          Event blum {}" + 
     840             "          Event blop {}" + 
     841             "        }" + 
     842             "        Sequence sequence6 {" + 
     843             "          Event ble {}" + 
     844             "          Event blum {}" + 
     845             "          Event blop {}" + 
     846             "        }" + 
     847             "        Sequence sequence6 {" + 
     848             "          Event ble {}" + 
     849             "          Event blum {}" + 
     850             "          Event blop {}" + 
     851             "        }" + 
     852             "        Sequence sequence6 {" + 
     853             "          Event ble {}" + 
     854             "          Event blum {}" + 
     855             "          Event blop {}" + 
     856             "        }" + 
     857             "        Sequence sequence6 {" + 
     858             "          Event ble {}" + 
     859             "          Event blum {}" + 
     860             "          Event blop {}" + 
     861             "        }" + 
     862             "      }" + 
     863             "    }" + 
     864             "    Sequence sequence1 {" + 
     865             "      Iteration iteration4 {" + 
     866             "        Sequence sequence4 {" + 
     867             "          Event bla {}" + 
     868             "          Event bli {}" + 
     869             "          Event blup {}" + 
     870             "        }" + 
     871             "        Sequence sequence4 {" + 
     872             "          Event bla {}" + 
     873             "          Event bli {}" + 
     874             "          Event blup {}" + 
     875             "        }" + 
     876             "        Sequence sequence4 {" + 
     877             "          Event bla {}" + 
     878             "          Event bli {}" + 
     879             "          Event blup {}" + 
     880             "        }" + 
     881             "        Sequence sequence4 {" + 
     882             "          Event bla {}" + 
     883             "          Event bli {}" + 
     884             "          Event blup {}" + 
     885             "        }" + 
     886             "        Sequence sequence4 {" + 
     887             "          Event bla {}" + 
     888             "          Event bli {}" + 
     889             "          Event blup {}" + 
     890             "        }" + 
     891             "      }" + 
     892             "      Iteration iteration5 {" + 
     893             "        Sequence sequence5 {" + 
     894             "          Event blo {}" + 
     895             "          Event blau {}" + 
     896             "          Event blass {}" + 
     897             "        }" + 
     898             "        Sequence sequence5 {" + 
     899             "          Event blo {}" + 
     900             "          Event blau {}" + 
     901             "          Event blass {}" + 
     902             "        }" + 
     903             "        Sequence sequence5 {" + 
     904             "          Event blo {}" + 
     905             "          Event blau {}" + 
     906             "          Event blass {}" + 
     907             "        }" + 
     908             "        Sequence sequence5 {" + 
     909             "          Event blo {}" + 
     910             "          Event blau {}" + 
     911             "          Event blass {}" + 
     912             "        }" + 
     913             "        Sequence sequence5 {" + 
     914             "          Event blo {}" + 
     915             "          Event blau {}" + 
     916             "          Event blass {}" + 
     917             "        }" + 
     918             "      }" + 
     919             "      Iteration iteration6 {" + 
     920             "        Sequence sequence6 {" + 
     921             "          Event ble {}" + 
     922             "          Event blum {}" + 
     923             "          Event blop {}" + 
     924             "        }" + 
     925             "        Sequence sequence6 {" + 
     926             "          Event ble {}" + 
     927             "          Event blum {}" + 
     928             "          Event blop {}" + 
     929             "        }" + 
     930             "        Sequence sequence6 {" + 
     931             "          Event ble {}" + 
     932             "          Event blum {}" + 
     933             "          Event blop {}" + 
     934             "        }" + 
     935             "        Sequence sequence6 {" + 
     936             "          Event ble {}" + 
     937             "          Event blum {}" + 
     938             "          Event blop {}" + 
     939             "        }" + 
     940             "        Sequence sequence6 {" + 
     941             "          Event ble {}" + 
     942             "          Event blum {}" + 
     943             "          Event blop {}" + 
     944             "        }" + 
     945             "      }" + 
     946             "    }" + 
     947             "    Sequence sequence1 {" + 
     948             "      Iteration iteration4 {" + 
     949             "        Sequence sequence4 {" + 
     950             "          Event bla {}" + 
     951             "          Event bli {}" + 
     952             "          Event blup {}" + 
     953             "        }" + 
     954             "        Sequence sequence4 {" + 
     955             "          Event bla {}" + 
     956             "          Event bli {}" + 
     957             "          Event blup {}" + 
     958             "        }" + 
     959             "        Sequence sequence4 {" + 
     960             "          Event bla {}" + 
     961             "          Event bli {}" + 
     962             "          Event blup {}" + 
     963             "        }" + 
     964             "        Sequence sequence4 {" + 
     965             "          Event bla {}" + 
     966             "          Event bli {}" + 
     967             "          Event blup {}" + 
     968             "        }" + 
     969             "        Sequence sequence4 {" + 
     970             "          Event bla {}" + 
     971             "          Event bli {}" + 
     972             "          Event blup {}" + 
     973             "        }" + 
     974             "      }" + 
     975             "      Iteration iteration5 {" + 
     976             "        Sequence sequence5 {" + 
     977             "          Event blo {}" + 
     978             "          Event blau {}" + 
     979             "          Event blass {}" + 
     980             "        }" + 
     981             "        Sequence sequence5 {" + 
     982             "          Event blo {}" + 
     983             "          Event blau {}" + 
     984             "          Event blass {}" + 
     985             "        }" + 
     986             "        Sequence sequence5 {" + 
     987             "          Event blo {}" + 
     988             "          Event blau {}" + 
     989             "          Event blass {}" + 
     990             "        }" + 
     991             "        Sequence sequence5 {" + 
     992             "          Event blo {}" + 
     993             "          Event blau {}" + 
     994             "          Event blass {}" + 
     995             "        }" + 
     996             "        Sequence sequence5 {" + 
     997             "          Event blo {}" + 
     998             "          Event blau {}" + 
     999             "          Event blass {}" + 
     1000             "        }" + 
     1001             "      }" + 
     1002             "      Iteration iteration6 {" + 
     1003             "        Sequence sequence6 {" + 
     1004             "          Event ble {}" + 
     1005             "          Event blum {}" + 
     1006             "          Event blop {}" + 
     1007             "        }" + 
     1008             "        Sequence sequence6 {" + 
     1009             "          Event ble {}" + 
     1010             "          Event blum {}" + 
     1011             "          Event blop {}" + 
     1012             "        }" + 
     1013             "        Sequence sequence6 {" + 
     1014             "          Event ble {}" + 
     1015             "          Event blum {}" + 
     1016             "          Event blop {}" + 
     1017             "        }" + 
     1018             "        Sequence sequence6 {" + 
     1019             "          Event ble {}" + 
     1020             "          Event blum {}" + 
     1021             "          Event blop {}" + 
     1022             "        }" + 
     1023             "        Sequence sequence6 {" + 
     1024             "          Event ble {}" + 
     1025             "          Event blum {}" + 
     1026             "          Event blop {}" + 
    4651027             "        }" + 
    4661028             "      }" + 
    4671029             "    }" + 
    4681030             "  }" + 
    469              "}", manager.getTaskTree()); 
     1031             "}", manager.getTaskModel().getUserSessions().get(0)); 
    4701032    } 
    4711033 
  • trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/taskequality/EventTaskComparisonRuleTest.java

    r1125 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1616 
    1717import static org.junit.Assert.*; 
     
    2222import de.ugoe.cs.autoquest.eventcore.IEventType; 
    2323import de.ugoe.cs.autoquest.eventcore.StringEventType; 
    24 import de.ugoe.cs.autoquest.tasktrees.nodeequality.EventTaskComparisonRule; 
    25 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEquality; 
    26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; 
    28 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNodeFactory; 
     24import de.ugoe.cs.autoquest.tasktrees.taskequality.EventTaskComparisonRule; 
     25import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 
     26import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     27import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 
     28import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory; 
    2929import de.ugoe.cs.autoquest.test.DummyGUIElement; 
    3030 
     
    3939    @Test 
    4040    public void test_isApplicable_01() { 
    41         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
    42  
    43         EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
    44  
    45         IEventType eventType1 = new StringEventType("eventType1"); 
    46         IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    47         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     41        ITaskFactory taskFactory = new TaskFactory(); 
     42 
     43        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     44 
     45        IEventType eventType1 = new StringEventType("eventType1"); 
     46        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
     47        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    4848 
    4949        assertTrue(rule.isApplicable(task1, task1)); 
     
    5555    @Test 
    5656    public void test_isApplicable_02() { 
    57         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
    58  
    59         EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
    60  
    61         IEventType eventType1 = new StringEventType("eventType1"); 
    62         IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    63         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     57        ITaskFactory taskFactory = new TaskFactory(); 
     58 
     59        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     60 
     61        IEventType eventType1 = new StringEventType("eventType1"); 
     62        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
     63        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    6464 
    6565        IEventType eventType2 = new StringEventType("eventType2"); 
    6666        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    67         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     67        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    6868 
    6969        assertTrue(rule.isApplicable(task1, task2)); 
     
    7676    @Test 
    7777    public void test_isApplicable_03() { 
    78         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
    79  
    80         EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
    81  
    82         IEventType eventType1 = new StringEventType("eventType1"); 
    83         IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    84         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     78        ITaskFactory taskFactory = new TaskFactory(); 
     79 
     80        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     81 
     82        IEventType eventType1 = new StringEventType("eventType1"); 
     83        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
     84        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    8585        
    86         ITaskTreeNode selection = treeNodeFactory.createNewSelection(); 
     86        ITask selection = taskFactory.createNewSelection(); 
    8787 
    8888        assertFalse(rule.isApplicable(task1, selection)); 
     
    9595    @Test 
    9696    public void test_isApplicable_04() { 
    97         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
    98  
    99         EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
    100  
    101         IEventType eventType1 = new StringEventType("eventType1"); 
    102         IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    103         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
    104  
    105         ITaskTreeNode sequence = treeNodeFactory.createNewSequence(); 
     97        ITaskFactory taskFactory = new TaskFactory(); 
     98 
     99        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     100 
     101        IEventType eventType1 = new StringEventType("eventType1"); 
     102        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
     103        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
     104 
     105        ITask sequence = taskFactory.createNewSequence(); 
    106106 
    107107        assertFalse(rule.isApplicable(task1, sequence)); 
     
    114114    @Test 
    115115    public void test_isApplicable_05() { 
    116         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
    117  
    118         EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
    119  
    120         IEventType eventType1 = new StringEventType("eventType1"); 
    121         IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    122         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
    123  
    124         ITaskTreeNode iteration = treeNodeFactory.createNewIteration(); 
     116        ITaskFactory taskFactory = new TaskFactory(); 
     117 
     118        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     119 
     120        IEventType eventType1 = new StringEventType("eventType1"); 
     121        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
     122        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
     123 
     124        ITask iteration = taskFactory.createNewIteration(); 
    125125 
    126126        assertFalse(rule.isApplicable(task1, iteration)); 
     
    133133    @Test 
    134134    public void test_isApplicable_06() { 
    135         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
    136  
    137         EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
    138  
    139         IEventType eventType1 = new StringEventType("eventType1"); 
    140         IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    141         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
    142  
    143         ITaskTreeNode optional = treeNodeFactory.createNewOptional(); 
     135        ITaskFactory taskFactory = new TaskFactory(); 
     136 
     137        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     138 
     139        IEventType eventType1 = new StringEventType("eventType1"); 
     140        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
     141        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
     142 
     143        ITask optional = taskFactory.createNewOptional(); 
    144144 
    145145        assertFalse(rule.isApplicable(task1, optional)); 
     
    152152    @Test 
    153153    public void test_compare_01() { 
    154         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
    155          
    156         EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
    157          
    158         IEventType eventType1 = new StringEventType("eventType1"); 
    159         IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    160         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
    161          
    162         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task1, task1)); 
     154        ITaskFactory taskFactory = new TaskFactory(); 
     155         
     156        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     157         
     158        IEventType eventType1 = new StringEventType("eventType1"); 
     159        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
     160        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
     161         
     162        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task1, task1)); 
    163163        assertTrue(rule.areLexicallyEqual(task1, task1)); 
    164164        assertTrue(rule.areSyntacticallyEqual(task1, task1)); 
     
    171171    @Test 
    172172    public void test_compare_02() { 
    173         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
    174          
    175         EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
    176          
    177         IEventType eventType1 = new StringEventType("eventType1"); 
    178         IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    179         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
    180          
    181         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
    182          
    183         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task1, task2)); 
     173        ITaskFactory taskFactory = new TaskFactory(); 
     174         
     175        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     176         
     177        IEventType eventType1 = new StringEventType("eventType1"); 
     178        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
     179        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
     180         
     181        ITask task2 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
     182         
     183        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task1, task2)); 
    184184        assertTrue(rule.areLexicallyEqual(task1, task2)); 
    185185        assertTrue(rule.areSyntacticallyEqual(task1, task2)); 
    186186        assertTrue(rule.areSemanticallyEqual(task1, task2)); 
    187187 
    188         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task2, task1)); 
     188        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task2, task1)); 
    189189        assertTrue(rule.areLexicallyEqual(task2, task1)); 
    190190        assertTrue(rule.areSyntacticallyEqual(task2, task1)); 
     
    197197    @Test 
    198198    public void test_compare_03() { 
    199         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
    200          
    201         EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
    202          
    203         IEventType eventType1 = new StringEventType("eventType1"); 
    204         IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    205         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     199        ITaskFactory taskFactory = new TaskFactory(); 
     200         
     201        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     202         
     203        IEventType eventType1 = new StringEventType("eventType1"); 
     204        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
     205        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    206206         
    207207        IEventType eventType2 = new StringEventType("eventType2"); 
    208         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
    209  
    210         assertEquals(NodeEquality.UNEQUAL, rule.compare(task1, task2)); 
     208        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
     209 
     210        assertEquals(TaskEquality.UNEQUAL, rule.compare(task1, task2)); 
    211211        assertFalse(rule.areLexicallyEqual(task1, task2)); 
    212212        assertFalse(rule.areSyntacticallyEqual(task1, task2)); 
    213213        assertFalse(rule.areSemanticallyEqual(task1, task2)); 
    214214 
    215         assertEquals(NodeEquality.UNEQUAL, rule.compare(task2, task1)); 
     215        assertEquals(TaskEquality.UNEQUAL, rule.compare(task2, task1)); 
    216216        assertFalse(rule.areLexicallyEqual(task2, task1)); 
    217217        assertFalse(rule.areSyntacticallyEqual(task2, task1)); 
     
    224224    @Test 
    225225    public void test_compare_04() { 
    226         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
    227          
    228         EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
    229          
    230         IEventType eventType1 = new StringEventType("eventType1"); 
    231         IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    232         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     226        ITaskFactory taskFactory = new TaskFactory(); 
     227         
     228        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     229         
     230        IEventType eventType1 = new StringEventType("eventType1"); 
     231        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
     232        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    233233         
    234234        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    235         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType1, eventTarget2); 
    236          
    237         assertEquals(NodeEquality.UNEQUAL, rule.compare(task1, task2)); 
     235        ITask task2 = taskFactory.createNewEventTask(eventType1, eventTarget2); 
     236         
     237        assertEquals(TaskEquality.UNEQUAL, rule.compare(task1, task2)); 
    238238        assertFalse(rule.areLexicallyEqual(task1, task2)); 
    239239        assertFalse(rule.areSyntacticallyEqual(task1, task2)); 
    240240        assertFalse(rule.areSemanticallyEqual(task1, task2)); 
    241241 
    242         assertEquals(NodeEquality.UNEQUAL, rule.compare(task2, task1)); 
     242        assertEquals(TaskEquality.UNEQUAL, rule.compare(task2, task1)); 
    243243        assertFalse(rule.areLexicallyEqual(task2, task1)); 
    244244        assertFalse(rule.areSyntacticallyEqual(task2, task1)); 
     
    252252    @Test 
    253253    public void test_compare_05() { 
    254         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
    255          
    256         EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
    257          
    258         IEventType eventType1 = new StringEventType("eventType1"); 
    259         IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    260         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     254        ITaskFactory taskFactory = new TaskFactory(); 
     255         
     256        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     257         
     258        IEventType eventType1 = new StringEventType("eventType1"); 
     259        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
     260        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    261261         
    262262        IEventType eventType2 = new StringEventType("eventType2"); 
    263263        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    264         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
    265          
    266         assertEquals(NodeEquality.UNEQUAL, rule.compare(task1, task2)); 
     264        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
     265         
     266        assertEquals(TaskEquality.UNEQUAL, rule.compare(task1, task2)); 
    267267        assertFalse(rule.areLexicallyEqual(task1, task2)); 
    268268        assertFalse(rule.areSyntacticallyEqual(task1, task2)); 
    269269        assertFalse(rule.areSemanticallyEqual(task1, task2)); 
    270270 
    271         assertEquals(NodeEquality.UNEQUAL, rule.compare(task2, task1)); 
     271        assertEquals(TaskEquality.UNEQUAL, rule.compare(task2, task1)); 
    272272        assertFalse(rule.areLexicallyEqual(task2, task1)); 
    273273        assertFalse(rule.areSyntacticallyEqual(task2, task1)); 
  • trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/taskequality/GUIEventTaskComparisonRuleTest.java

    r1125 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1616 
    1717import static org.junit.Assert.*; 
     
    4141import de.ugoe.cs.autoquest.eventcore.gui.ValueSelection; 
    4242import de.ugoe.cs.autoquest.keyboardmaps.VirtualKey; 
    43 import de.ugoe.cs.autoquest.tasktrees.nodeequality.GUIEventTaskComparisonRule; 
    44 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEquality; 
    45 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    46 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; 
    47 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNodeFactory; 
     43import de.ugoe.cs.autoquest.tasktrees.taskequality.EventTaskComparisonRule; 
     44import de.ugoe.cs.autoquest.tasktrees.taskequality.GUIEventTaskComparisonRule; 
     45import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 
     46import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     47import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 
     48import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory; 
    4849import de.ugoe.cs.autoquest.test.DummyGUIElement; 
    4950 
     
    5859    @Test 
    5960    public void test_isApplicable_01() { 
    60         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     61        ITaskFactory taskFactory = new TaskFactory(); 
    6162 
    6263        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     
    6465        IEventType eventType1 = new StringEventType("eventType1"); 
    6566        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    66         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     67        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    6768 
    6869        assertTrue(rule.isApplicable(task1, task1)); 
     
    7475    @Test 
    7576    public void test_isApplicable_02() { 
    76         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     77        ITaskFactory taskFactory = new TaskFactory(); 
    7778 
    7879        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     
    8081        IEventType eventType1 = new StringEventType("eventType1"); 
    8182        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    82         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     83        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    8384 
    8485        IEventType eventType2 = new StringEventType("eventType2"); 
    8586        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    86         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     87        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    8788 
    8889        assertTrue(rule.isApplicable(task1, task2)); 
     
    9596    @Test 
    9697    public void test_isApplicable_03() { 
    97         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     98        ITaskFactory taskFactory = new TaskFactory(); 
    9899 
    99100        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     
    101102        IEventType eventType1 = new KeyboardFocusChange(); 
    102103        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    103         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     104        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    104105 
    105106        IEventType eventType2 = new KeyboardFocusChange(); 
    106107        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    107         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     108        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    108109 
    109110        assertTrue(rule.isApplicable(task1, task2)); 
     
    116117    @Test 
    117118    public void test_isApplicable_04() { 
    118         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     119        ITaskFactory taskFactory = new TaskFactory(); 
    119120 
    120121        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     
    122123        IEventType eventType1 = new KeyPressed(VirtualKey.LETTER_A); 
    123124        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    124         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     125        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    125126 
    126127        IEventType eventType2 = new KeyReleased(VirtualKey.LETTER_B); 
    127128        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    128         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     129        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    129130 
    130131        assertTrue(rule.isApplicable(task1, task2)); 
     
    137138    @Test 
    138139    public void test_isApplicable_05() { 
    139         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     140        ITaskFactory taskFactory = new TaskFactory(); 
    140141 
    141142        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     
    143144        IEventType eventType1 = new KeyTyped(VirtualKey.LETTER_C); 
    144145        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    145         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     146        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    146147 
    147148        IEventType eventType2 = new KeyTyped(VirtualKey.LETTER_D); 
    148149        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    149         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     150        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    150151 
    151152        assertTrue(rule.isApplicable(task1, task2)); 
     
    158159    @Test 
    159160    public void test_isApplicable_06() { 
    160         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     161        ITaskFactory taskFactory = new TaskFactory(); 
    161162 
    162163        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     
    164165        IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 5, 6); 
    165166        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    166         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     167        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    167168 
    168169        IEventType eventType2 = new MouseButtonUp(MouseButtonInteraction.Button.MIDDLE, 3, 1); 
    169170        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    170         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     171        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    171172 
    172173        assertTrue(rule.isApplicable(task1, task2)); 
     
    179180    @Test 
    180181    public void test_isApplicable_07() { 
    181         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     182        ITaskFactory taskFactory = new TaskFactory(); 
    182183 
    183184        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     
    185186        IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.RIGHT, 4, 7); 
    186187        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    187         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     188        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    188189 
    189190        IEventType eventType2 = new MouseDoubleClick(MouseButtonInteraction.Button.X, 9, 12); 
    190191        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    191         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     192        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    192193 
    193194        assertTrue(rule.isApplicable(task1, task2)); 
     
    200201    @Test 
    201202    public void test_isApplicable_08() { 
    202         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     203        ITaskFactory taskFactory = new TaskFactory(); 
    203204 
    204205        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     
    206207        IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 
    207208        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    208         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     209        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    209210 
    210211        IEventType eventType2 = new MouseDragAndDrop(5, 6, 7, 8); 
    211212        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    212         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     213        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    213214 
    214215        assertTrue(rule.isApplicable(task1, task2)); 
     
    221222    @Test 
    222223    public void test_isApplicable_09() { 
    223         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     224        ITaskFactory taskFactory = new TaskFactory(); 
    224225 
    225226        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     
    227228        IEventType eventType1 = new Scroll(1, 2); 
    228229        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    229         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     230        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    230231 
    231232        IEventType eventType2 = new Scroll(3, 4); 
    232233        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    233         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     234        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    234235 
    235236        assertTrue(rule.isApplicable(task1, task2)); 
     
    242243    @Test 
    243244    public void test_isApplicable_10() { 
    244         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     245        ITaskFactory taskFactory = new TaskFactory(); 
    245246 
    246247        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     
    249250        IEventType eventType1 = new TextInput("text1", inputEvents); 
    250251        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    251         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     252        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    252253 
    253254        IEventType eventType2 = new TextInput("text2", inputEvents); 
    254255        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    255         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     256        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    256257 
    257258        assertTrue(rule.isApplicable(task1, task2)); 
     
    264265    @Test 
    265266    public void test_isApplicable_11() { 
    266         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     267        ITaskFactory taskFactory = new TaskFactory(); 
    267268 
    268269        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     
    270271        IEventType eventType1 = new TextSelection(); 
    271272        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    272         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     273        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    273274 
    274275        IEventType eventType2 = new ValueSelection<String>("value"); 
    275276        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    276         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     277        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    277278 
    278279        assertTrue(rule.isApplicable(task1, task2)); 
     
    285286    @Test 
    286287    public void test_isApplicable_12() { 
    287         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     288        ITaskFactory taskFactory = new TaskFactory(); 
    288289 
    289290        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     
    291292        IEventType eventType1 = new StringEventType("eventType1"); 
    292293        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    293         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
    294  
    295         ITaskTreeNode selection = treeNodeFactory.createNewSelection(); 
     294        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
     295 
     296        ITask selection = taskFactory.createNewSelection(); 
    296297 
    297298        assertFalse(rule.isApplicable(task1, selection)); 
     
    304305    @Test 
    305306    public void test_isApplicable_13() { 
    306         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     307        ITaskFactory taskFactory = new TaskFactory(); 
    307308 
    308309        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     
    310311        IEventType eventType1 = new StringEventType("eventType1"); 
    311312        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    312         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
    313  
    314         ITaskTreeNode sequence = treeNodeFactory.createNewSequence(); 
     313        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
     314 
     315        ITask sequence = taskFactory.createNewSequence(); 
    315316 
    316317        assertFalse(rule.isApplicable(task1, sequence)); 
     
    323324    @Test 
    324325    public void test_isApplicable_14() { 
    325         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     326        ITaskFactory taskFactory = new TaskFactory(); 
    326327 
    327328        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     
    329330        IEventType eventType1 = new StringEventType("eventType1"); 
    330331        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    331         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
    332  
    333         ITaskTreeNode iteration = treeNodeFactory.createNewIteration(); 
     332        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
     333 
     334        ITask iteration = taskFactory.createNewIteration(); 
    334335 
    335336        assertFalse(rule.isApplicable(task1, iteration)); 
     
    342343    @Test 
    343344    public void test_isApplicable_15() { 
    344         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     345        ITaskFactory taskFactory = new TaskFactory(); 
    345346 
    346347        EventTaskComparisonRule rule = new EventTaskComparisonRule(); 
     
    348349        IEventType eventType1 = new StringEventType("eventType1"); 
    349350        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    350         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
    351  
    352         ITaskTreeNode optional = treeNodeFactory.createNewOptional(); 
     351        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
     352 
     353        ITask optional = taskFactory.createNewOptional(); 
    353354 
    354355        assertFalse(rule.isApplicable(task1, optional)); 
     
    361362    @Test 
    362363    public void test_compare_KeyboardFocusChange_01() { 
    363         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     364        ITaskFactory taskFactory = new TaskFactory(); 
    364365         
    365366        IEventType eventType1 = new KeyboardFocusChange(); 
    366367        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    367         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     368        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    368369         
    369370        assertLexicallyEqual(task1, task1); 
     
    375376    @Test 
    376377    public void test_compare_KeyboardFocusChange_02() { 
    377         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     378        ITaskFactory taskFactory = new TaskFactory(); 
    378379         
    379380        IEventType eventType1 = new KeyboardFocusChange(); 
    380381        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    381         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     382        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    382383 
    383384        IEventType eventType2 = new KeyboardFocusChange(); 
    384         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     385        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    385386         
    386387        assertLexicallyEqual(task1, task2); 
     
    392393    @Test 
    393394    public void test_compare_KeyboardFocusChange_03() { 
    394         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     395        ITaskFactory taskFactory = new TaskFactory(); 
    395396         
    396397        IEventType eventType1 = new KeyboardFocusChange(); 
    397398        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    398         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     399        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    399400 
    400401        IEventType eventType2 = new KeyboardFocusChange(); 
    401402        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    402         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     403        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    403404         
    404405        assertUnequal(task1, task2); 
     
    410411    @Test 
    411412    public void test_compare_KeyPressed_01() { 
    412         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     413        ITaskFactory taskFactory = new TaskFactory(); 
    413414         
    414415        IEventType eventType1 = new KeyPressed(VirtualKey.LETTER_A); 
    415416        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    416         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     417        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    417418         
    418419        assertLexicallyEqual(task1, task1); 
     
    424425    @Test 
    425426    public void test_compare_KeyPressed_02() { 
    426         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     427        ITaskFactory taskFactory = new TaskFactory(); 
    427428         
    428429        IEventType eventType1 = new KeyPressed(VirtualKey.LETTER_A); 
    429430        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    430         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     431        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    431432         
    432433        IEventType eventType2 = new KeyPressed(VirtualKey.LETTER_A); 
    433         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     434        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    434435         
    435436        assertLexicallyEqual(task1, task2); 
     
    441442    @Test 
    442443    public void test_compare_KeyPressed_03() { 
    443         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     444        ITaskFactory taskFactory = new TaskFactory(); 
    444445         
    445446        IEventType eventType1 = new KeyPressed(VirtualKey.LETTER_A); 
    446447        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    447         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     448        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    448449         
    449450        IEventType eventType2 = new KeyPressed(VirtualKey.LETTER_B); 
    450         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     451        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    451452         
    452453        assertSemanticallyEqual(task1, task2); 
     
    458459    @Test 
    459460    public void test_compare_KeyPressed_04() { 
    460         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     461        ITaskFactory taskFactory = new TaskFactory(); 
    461462         
    462463        IEventType eventType1 = new KeyPressed(VirtualKey.LETTER_A); 
    463464        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    464         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     465        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    465466         
    466467        IEventType eventType2 = new KeyPressed(VirtualKey.LETTER_A); 
    467468        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    468         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     469        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    469470         
    470471        assertUnequal(task1, task2); 
     
    476477    @Test 
    477478    public void test_compare_KeyReleased_01() { 
    478         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     479        ITaskFactory taskFactory = new TaskFactory(); 
    479480         
    480481        IEventType eventType1 = new KeyReleased(VirtualKey.LETTER_A); 
    481482        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    482         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     483        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    483484         
    484485        assertLexicallyEqual(task1, task1); 
     
    490491    @Test 
    491492    public void test_compare_KeyReleased_02() { 
    492         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     493        ITaskFactory taskFactory = new TaskFactory(); 
    493494         
    494495        IEventType eventType1 = new KeyReleased(VirtualKey.LETTER_A); 
    495496        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    496         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     497        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    497498         
    498499        IEventType eventType2 = new KeyReleased(VirtualKey.LETTER_A); 
    499         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     500        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    500501         
    501502        assertLexicallyEqual(task1, task2); 
     
    507508    @Test 
    508509    public void test_compare_KeyReleased_03() { 
    509         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     510        ITaskFactory taskFactory = new TaskFactory(); 
    510511         
    511512        IEventType eventType1 = new KeyReleased(VirtualKey.LETTER_A); 
    512513        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    513         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     514        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    514515         
    515516        IEventType eventType2 = new KeyReleased(VirtualKey.LETTER_B); 
    516         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     517        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    517518         
    518519        assertSemanticallyEqual(task1, task2); 
     
    524525    @Test 
    525526    public void test_compare_KeyReleased_04() { 
    526         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     527        ITaskFactory taskFactory = new TaskFactory(); 
    527528         
    528529        IEventType eventType1 = new KeyReleased(VirtualKey.LETTER_A); 
    529530        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    530         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     531        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    531532         
    532533        IEventType eventType2 = new KeyReleased(VirtualKey.LETTER_A); 
    533534        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    534         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     535        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    535536         
    536537        assertUnequal(task1, task2); 
     
    542543    @Test 
    543544    public void test_compare_KeyTyped_01() { 
    544         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     545        ITaskFactory taskFactory = new TaskFactory(); 
    545546         
    546547        IEventType eventType1 = new KeyTyped(VirtualKey.LETTER_A); 
    547548        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    548         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     549        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    549550         
    550551        assertLexicallyEqual(task1, task1); 
     
    556557    @Test 
    557558    public void test_compare_KeyTyped_02() { 
    558         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     559        ITaskFactory taskFactory = new TaskFactory(); 
    559560         
    560561        IEventType eventType1 = new KeyTyped(VirtualKey.LETTER_A); 
    561562        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    562         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     563        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    563564         
    564565        IEventType eventType2 = new KeyTyped(VirtualKey.LETTER_A); 
    565         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     566        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    566567         
    567568        assertLexicallyEqual(task1, task2); 
     
    573574    @Test 
    574575    public void test_compare_KeyTyped_03() { 
    575         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     576        ITaskFactory taskFactory = new TaskFactory(); 
    576577         
    577578        IEventType eventType1 = new KeyTyped(VirtualKey.LETTER_A); 
    578579        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    579         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     580        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    580581         
    581582        IEventType eventType2 = new KeyTyped(VirtualKey.LETTER_B); 
    582         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     583        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    583584         
    584585        assertSemanticallyEqual(task1, task2); 
     
    590591    @Test 
    591592    public void test_compare_KeyTyped_04() { 
    592         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     593        ITaskFactory taskFactory = new TaskFactory(); 
    593594         
    594595        IEventType eventType1 = new KeyTyped(VirtualKey.LETTER_A); 
    595596        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    596         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     597        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    597598         
    598599        IEventType eventType2 = new KeyTyped(VirtualKey.LETTER_A); 
    599600        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    600         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     601        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    601602         
    602603        assertUnequal(task1, task2); 
     
    608609    @Test 
    609610    public void test_compare_MouseButtonDown_01() { 
    610         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     611        ITaskFactory taskFactory = new TaskFactory(); 
    611612         
    612613        IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 
    613614        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    614         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     615        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    615616         
    616617        assertLexicallyEqual(task1, task1); 
     
    622623    @Test 
    623624    public void test_compare_MouseButtonDown_02() { 
    624         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     625        ITaskFactory taskFactory = new TaskFactory(); 
    625626         
    626627        IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 
    627628        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    628         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     629        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    629630         
    630631        IEventType eventType2 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 
    631         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     632        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    632633         
    633634        assertLexicallyEqual(task1, task2); 
     
    639640    @Test 
    640641    public void test_compare_MouseButtonDown_03() { 
    641         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     642        ITaskFactory taskFactory = new TaskFactory(); 
    642643         
    643644        IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 
    644645        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    645         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     646        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    646647         
    647648        IEventType eventType2 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 3); 
    648         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     649        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    649650         
    650651        assertSemanticallyEqual(task1, task2); 
     
    656657    @Test 
    657658    public void test_compare_MouseButtonDown_04() { 
    658         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     659        ITaskFactory taskFactory = new TaskFactory(); 
    659660         
    660661        IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 
    661662        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    662         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     663        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    663664         
    664665        IEventType eventType2 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 3, 2); 
    665         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     666        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    666667         
    667668        assertSemanticallyEqual(task1, task2); 
     
    673674    @Test 
    674675    public void test_compare_MouseButtonDown_05() { 
    675         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     676        ITaskFactory taskFactory = new TaskFactory(); 
    676677         
    677678        IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 
    678679        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    679         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     680        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    680681         
    681682        IEventType eventType2 = new MouseButtonDown(MouseButtonInteraction.Button.RIGHT, 1, 2); 
    682         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     683        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    683684         
    684685        assertUnequal(task1, task2); 
     
    690691    @Test 
    691692    public void test_compare_MouseButtonDown_06() { 
    692         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     693        ITaskFactory taskFactory = new TaskFactory(); 
    693694         
    694695        IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 
    695696        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    696         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     697        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    697698         
    698699        IEventType eventType2 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 
    699700        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    700         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     701        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    701702         
    702703        assertUnequal(task1, task2); 
     
    708709    @Test 
    709710    public void test_compare_MouseButtonUp_01() { 
    710         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     711        ITaskFactory taskFactory = new TaskFactory(); 
    711712         
    712713        IEventType eventType1 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 
    713714        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    714         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     715        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    715716         
    716717        assertLexicallyEqual(task1, task1); 
     
    722723    @Test 
    723724    public void test_compare_MouseButtonUp_02() { 
    724         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     725        ITaskFactory taskFactory = new TaskFactory(); 
    725726         
    726727        IEventType eventType1 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 
    727728        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    728         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     729        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    729730         
    730731        IEventType eventType2 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 
    731         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     732        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    732733         
    733734        assertLexicallyEqual(task1, task2); 
     
    739740    @Test 
    740741    public void test_compare_MouseButtonUp_03() { 
    741         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     742        ITaskFactory taskFactory = new TaskFactory(); 
    742743         
    743744        IEventType eventType1 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 
    744745        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    745         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     746        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    746747         
    747748        IEventType eventType2 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 3); 
    748         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     749        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    749750         
    750751        assertSemanticallyEqual(task1, task2); 
     
    756757    @Test 
    757758    public void test_compare_MouseButtonUp_04() { 
    758         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     759        ITaskFactory taskFactory = new TaskFactory(); 
    759760         
    760761        IEventType eventType1 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 
    761762        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    762         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     763        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    763764         
    764765        IEventType eventType2 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 3, 2); 
    765         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     766        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    766767         
    767768        assertSemanticallyEqual(task1, task2); 
     
    773774    @Test 
    774775    public void test_compare_MouseButtonUp_05() { 
    775         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     776        ITaskFactory taskFactory = new TaskFactory(); 
    776777         
    777778        IEventType eventType1 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 
    778779        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    779         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     780        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    780781         
    781782        IEventType eventType2 = new MouseButtonUp(MouseButtonInteraction.Button.RIGHT, 1, 2); 
    782         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     783        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    783784         
    784785        assertUnequal(task1, task2); 
     
    790791    @Test 
    791792    public void test_compare_MouseButtonUp_06() { 
    792         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     793        ITaskFactory taskFactory = new TaskFactory(); 
    793794         
    794795        IEventType eventType1 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 
    795796        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    796         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     797        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    797798         
    798799        IEventType eventType2 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 
    799800        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    800         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     801        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    801802         
    802803        assertUnequal(task1, task2); 
     
    808809    @Test 
    809810    public void test_compare_MouseClick_01() { 
    810         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     811        ITaskFactory taskFactory = new TaskFactory(); 
    811812         
    812813        IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 
    813814        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    814         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     815        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    815816         
    816817        assertLexicallyEqual(task1, task1); 
     
    822823    @Test 
    823824    public void test_compare_MouseClick_02() { 
    824         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     825        ITaskFactory taskFactory = new TaskFactory(); 
    825826         
    826827        IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 
    827828        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    828         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     829        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    829830         
    830831        IEventType eventType2 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 
    831         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     832        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    832833         
    833834        assertLexicallyEqual(task1, task2); 
     
    839840    @Test 
    840841    public void test_compare_MouseClick_03() { 
    841         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     842        ITaskFactory taskFactory = new TaskFactory(); 
    842843         
    843844        IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 
    844845        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    845         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     846        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    846847         
    847848        IEventType eventType2 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 3); 
    848         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     849        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    849850         
    850851        assertSemanticallyEqual(task1, task2); 
     
    856857    @Test 
    857858    public void test_compare_MouseClick_04() { 
    858         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     859        ITaskFactory taskFactory = new TaskFactory(); 
    859860         
    860861        IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 
    861862        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    862         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     863        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    863864         
    864865        IEventType eventType2 = new MouseClick(MouseButtonInteraction.Button.LEFT, 3, 2); 
    865         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     866        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    866867         
    867868        assertSemanticallyEqual(task1, task2); 
     
    873874    @Test 
    874875    public void test_compare_MouseClick_05() { 
    875         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     876        ITaskFactory taskFactory = new TaskFactory(); 
    876877         
    877878        IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 
    878879        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    879         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     880        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    880881         
    881882        IEventType eventType2 = new MouseClick(MouseButtonInteraction.Button.RIGHT, 1, 2); 
    882         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     883        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    883884         
    884885        assertUnequal(task1, task2); 
     
    890891    @Test 
    891892    public void test_compare_MouseClick_06() { 
    892         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     893        ITaskFactory taskFactory = new TaskFactory(); 
    893894         
    894895        IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 
    895896        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    896         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     897        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    897898         
    898899        IEventType eventType2 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 
    899900        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    900         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     901        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    901902         
    902903        assertUnequal(task1, task2); 
     
    908909    @Test 
    909910    public void test_compare_MouseDoubleClick_01() { 
    910         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     911        ITaskFactory taskFactory = new TaskFactory(); 
    911912         
    912913        IEventType eventType1 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 
    913914        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    914         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     915        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    915916         
    916917        assertLexicallyEqual(task1, task1); 
     
    922923    @Test 
    923924    public void test_compare_MouseDoubleClick_02() { 
    924         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     925        ITaskFactory taskFactory = new TaskFactory(); 
    925926         
    926927        IEventType eventType1 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 
    927928        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    928         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     929        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    929930         
    930931        IEventType eventType2 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 
    931         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     932        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    932933         
    933934        assertLexicallyEqual(task1, task2); 
     
    939940    @Test 
    940941    public void test_compare_MouseDoubleClick_03() { 
    941         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     942        ITaskFactory taskFactory = new TaskFactory(); 
    942943         
    943944        IEventType eventType1 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 
    944945        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    945         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     946        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    946947         
    947948        IEventType eventType2 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 3); 
    948         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     949        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    949950         
    950951        assertSemanticallyEqual(task1, task2); 
     
    956957    @Test 
    957958    public void test_compare_MouseDoubleClick_04() { 
    958         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     959        ITaskFactory taskFactory = new TaskFactory(); 
    959960         
    960961        IEventType eventType1 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 
    961962        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    962         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     963        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    963964         
    964965        IEventType eventType2 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 3, 2); 
    965         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     966        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    966967         
    967968        assertSemanticallyEqual(task1, task2); 
     
    973974    @Test 
    974975    public void test_compare_MouseDoubleClick_05() { 
    975         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     976        ITaskFactory taskFactory = new TaskFactory(); 
    976977         
    977978        IEventType eventType1 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 
    978979        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    979         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     980        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    980981         
    981982        IEventType eventType2 = new MouseDoubleClick(MouseButtonInteraction.Button.RIGHT, 1, 2); 
    982         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     983        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    983984         
    984985        assertUnequal(task1, task2); 
     
    990991    @Test 
    991992    public void test_compare_MouseDoubleClick_06() { 
    992         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     993        ITaskFactory taskFactory = new TaskFactory(); 
    993994         
    994995        IEventType eventType1 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 
    995996        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    996         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     997        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    997998         
    998999        IEventType eventType2 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 
    9991000        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    1000         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     1001        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    10011002         
    10021003        assertUnequal(task1, task2); 
     
    10081009    @Test 
    10091010    public void test_compare_MouseDragAndDrop_01() { 
    1010         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1011        ITaskFactory taskFactory = new TaskFactory(); 
    10111012         
    10121013        IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 
    10131014        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    1014         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1015        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    10151016         
    10161017        assertLexicallyEqual(task1, task1); 
     
    10221023    @Test 
    10231024    public void test_compare_MouseDragAndDrop_02() { 
    1024         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1025        ITaskFactory taskFactory = new TaskFactory(); 
    10251026         
    10261027        IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 
    10271028        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    1028         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1029        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    10291030         
    10301031        IEventType eventType2 = new MouseDragAndDrop(1, 2, 3, 4); 
    1031         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     1032        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    10321033         
    10331034        assertLexicallyEqual(task1, task2); 
     
    10391040    @Test 
    10401041    public void test_compare_MouseDragAndDrop_03() { 
    1041         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1042        ITaskFactory taskFactory = new TaskFactory(); 
    10421043         
    10431044        IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 
    10441045        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    1045         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1046        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    10461047         
    10471048        IEventType eventType2 = new MouseDragAndDrop(5, 2, 3, 4); 
    1048         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     1049        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    10491050         
    10501051        assertSemanticallyEqual(task1, task2); 
     
    10561057    @Test 
    10571058    public void test_compare_MouseDragAndDrop_04() { 
    1058         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1059        ITaskFactory taskFactory = new TaskFactory(); 
    10591060         
    10601061        IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 
    10611062        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    1062         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1063        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    10631064         
    10641065        IEventType eventType2 = new MouseDragAndDrop(1, 5, 3, 4); 
    1065         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     1066        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    10661067         
    10671068        assertSemanticallyEqual(task1, task2); 
     
    10731074    @Test 
    10741075    public void test_compare_MouseDragAndDrop_05() { 
    1075         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1076        ITaskFactory taskFactory = new TaskFactory(); 
    10761077         
    10771078        IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 
    10781079        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    1079         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1080        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    10801081         
    10811082        IEventType eventType2 = new MouseDragAndDrop(1, 2, 5, 4); 
    1082         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     1083        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    10831084         
    10841085        assertSemanticallyEqual(task1, task2); 
     
    10901091    @Test 
    10911092    public void test_compare_MouseDragAndDrop_06() { 
    1092         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1093        ITaskFactory taskFactory = new TaskFactory(); 
    10931094         
    10941095        IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 
    10951096        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    1096         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1097        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    10971098         
    10981099        IEventType eventType2 = new MouseDragAndDrop(1, 2, 3, 5); 
    1099         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     1100        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    11001101         
    11011102        assertSemanticallyEqual(task1, task2); 
     
    11071108    @Test 
    11081109    public void test_compare_MouseDragAndDrop_07() { 
    1109         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1110        ITaskFactory taskFactory = new TaskFactory(); 
    11101111         
    11111112        IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 
    11121113        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    1113         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1114        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    11141115         
    11151116        IEventType eventType2 = new MouseDragAndDrop(1, 2, 3, 4); 
    11161117        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    1117         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     1118        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    11181119         
    11191120        assertUnequal(task1, task2); 
     
    11251126    @Test 
    11261127    public void test_compare_Scroll_01() { 
    1127         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1128        ITaskFactory taskFactory = new TaskFactory(); 
    11281129         
    11291130        IEventType eventType1 = new Scroll(1, 2); 
    11301131        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    1131         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1132        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    11321133         
    11331134        assertLexicallyEqual(task1, task1); 
     
    11391140    @Test 
    11401141    public void test_compare_Scroll_02() { 
    1141         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1142        ITaskFactory taskFactory = new TaskFactory(); 
    11421143         
    11431144        IEventType eventType1 = new Scroll(1, 2); 
    11441145        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    1145         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1146        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    11461147         
    11471148        IEventType eventType2 = new Scroll(1, 2); 
    1148         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     1149        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    11491150         
    11501151        assertLexicallyEqual(task1, task2); 
     
    11561157    @Test 
    11571158    public void test_compare_Scroll_03() { 
    1158         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1159        ITaskFactory taskFactory = new TaskFactory(); 
    11591160         
    11601161        IEventType eventType1 = new Scroll(1, 2); 
    11611162        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    1162         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1163        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    11631164         
    11641165        IEventType eventType2 = new Scroll(3, 2); 
    1165         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     1166        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    11661167         
    11671168        assertSemanticallyEqual(task1, task2); 
     
    11731174    @Test 
    11741175    public void test_compare_Scroll_04() { 
    1175         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1176        ITaskFactory taskFactory = new TaskFactory(); 
    11761177         
    11771178        IEventType eventType1 = new Scroll(1, 2); 
    11781179        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    1179         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1180        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    11801181         
    11811182        IEventType eventType2 = new Scroll(1, 3); 
    1182         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     1183        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    11831184         
    11841185        assertSemanticallyEqual(task1, task2); 
     
    11901191    @Test 
    11911192    public void test_compare_Scroll_05() { 
    1192         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1193        ITaskFactory taskFactory = new TaskFactory(); 
    11931194         
    11941195        IEventType eventType1 = new Scroll(1, 2); 
    11951196        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    1196         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1197        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    11971198         
    11981199        IEventType eventType2 = new Scroll(1, 2); 
    11991200        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    1200         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     1201        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    12011202         
    12021203        assertUnequal(task1, task2); 
     
    12081209    @Test 
    12091210    public void test_compare_TextInput_01() { 
    1210         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1211        ITaskFactory taskFactory = new TaskFactory(); 
    12111212         
    12121213        IEventType eventType1 = new StringEventType("eventType1"); 
     
    12151216        textInputEvents1.add(new Event(eventType1, eventTarget1)); 
    12161217        eventType1 = new TextInput("enteredText1", textInputEvents1); 
    1217         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1218        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    12181219         
    12191220        assertLexicallyEqual(task1, task1); 
     
    12251226    @Test 
    12261227    public void test_compare_TextInput_02() { 
    1227         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1228        ITaskFactory taskFactory = new TaskFactory(); 
    12281229         
    12291230        IEventType eventType1 = new StringEventType("eventType1"); 
     
    12321233        textInputEvents1.add(new Event(eventType1, eventTarget1)); 
    12331234        eventType1 = new TextInput("enteredText1", textInputEvents1); 
    1234         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1235        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    12351236         
    12361237        IEventType eventType2 = new TextInput("enteredText1", textInputEvents1); 
    1237         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     1238        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    12381239 
    12391240        assertLexicallyEqual(task1, task2); 
     
    12451246    @Test 
    12461247    public void test_compare_TextInput_03() { 
    1247         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1248        ITaskFactory taskFactory = new TaskFactory(); 
    12481249         
    12491250        IEventType eventType1 = new StringEventType("eventType1"); 
     
    12521253        textInputEvents1.add(new Event(eventType1, eventTarget1)); 
    12531254        eventType1 = new TextInput("enteredText1", textInputEvents1); 
    1254         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1255        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    12551256         
    12561257        IEventType eventType2 = new StringEventType("eventType2"); 
     
    12581259        textInputEvents2.add(new Event(eventType2, eventTarget1)); 
    12591260        eventType2 = new TextInput("enteredText1", textInputEvents2); 
    1260         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     1261        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    12611262 
    12621263        assertSyntacticallyEqual(task1, task2); 
     
    12681269    @Test 
    12691270    public void test_compare_TextInput_04() { 
    1270         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1271        ITaskFactory taskFactory = new TaskFactory(); 
    12711272         
    12721273        IEventType eventType1 = new StringEventType("eventType1"); 
     
    12751276        textInputEvents1.add(new Event(eventType1, eventTarget1)); 
    12761277        eventType1 = new TextInput("enteredText1", textInputEvents1); 
    1277         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1278        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    12781279         
    12791280        IEventType eventType2 = new StringEventType("eventType2"); 
     
    12811282        textInputEvents2.add(new Event(eventType2, eventTarget1)); 
    12821283        eventType2 = new TextInput("enteredText2", textInputEvents2); 
    1283         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     1284        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    12841285 
    12851286        assertSemanticallyEqual(task1, task2); 
     
    12911292    @Test 
    12921293    public void test_compare_TextInput_05() { 
    1293         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1294        ITaskFactory taskFactory = new TaskFactory(); 
    12941295         
    12951296        IEventType eventType1 = new StringEventType("eventType1"); 
     
    12981299        textInputEvents1.add(new Event(eventType1, eventTarget1)); 
    12991300        eventType1 = new TextInput("enteredText1", textInputEvents1); 
    1300         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
    1301          
    1302         IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    1303         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType1, eventTarget2); 
     1301        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
     1302         
     1303        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
     1304        ITask task2 = taskFactory.createNewEventTask(eventType1, eventTarget2); 
    13041305 
    13051306        assertUnequal(task1, task2); 
     
    13111312    @Test 
    13121313    public void test_compare_TextSelection_01() { 
    1313         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1314        ITaskFactory taskFactory = new TaskFactory(); 
    13141315         
    13151316        IEventType eventType1 = new TextSelection(); 
    13161317        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    1317         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1318        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    13181319         
    13191320        assertLexicallyEqual(task1, task1); 
     
    13251326    @Test 
    13261327    public void test_compare_TextSelection_02() { 
    1327         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1328        ITaskFactory taskFactory = new TaskFactory(); 
    13281329         
    13291330        IEventType eventType1 = new TextSelection(); 
    13301331        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    1331         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1332        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    13321333 
    13331334        IEventType eventType2 = new TextSelection(); 
    1334         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     1335        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    13351336         
    13361337        assertLexicallyEqual(task1, task2); 
     
    13421343    @Test 
    13431344    public void test_compare_TextSelection_03() { 
    1344         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1345        ITaskFactory taskFactory = new TaskFactory(); 
    13451346         
    13461347        IEventType eventType1 = new TextSelection(); 
    13471348        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    1348         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1349        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    13491350 
    13501351        IEventType eventType2 = new TextSelection(); 
    13511352        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    1352         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
     1353        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    13531354         
    13541355        assertUnequal(task1, task2); 
     
    13601361    @Test 
    13611362    public void test_compare_ValueSelection_01() { 
    1362         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1363        ITaskFactory taskFactory = new TaskFactory(); 
    13631364         
    13641365        IEventType eventType1 = new ValueSelection<String>("value1"); 
    13651366        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    1366         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1367        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    13671368         
    13681369        assertLexicallyEqual(task1, task1); 
     
    13741375    @Test 
    13751376    public void test_compare_ValueSelection_02() { 
    1376         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1377        ITaskFactory taskFactory = new TaskFactory(); 
    13771378         
    13781379        IEventType eventType1 = new ValueSelection<String>("value1"); 
    13791380        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    1380         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1381        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    13811382         
    13821383        IEventType eventType2 = new ValueSelection<String>("value1"); 
    1383         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     1384        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    13841385         
    13851386        assertLexicallyEqual(task1, task2); 
     
    13911392    @Test 
    13921393    public void test_compare_ValueSelection_03() { 
    1393         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1394        ITaskFactory taskFactory = new TaskFactory(); 
    13941395         
    13951396        IEventType eventType1 = new ValueSelection<String>("value1"); 
    13961397        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    1397         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1398        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    13981399         
    13991400        IEventType eventType2 = new ValueSelection<String>("value2"); 
    1400         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 
     1401        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); 
    14011402         
    14021403        assertSemanticallyEqual(task1, task2); 
     
    14081409    @Test 
    14091410    public void test_compare_ValueSelection_04() { 
    1410         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
     1411        ITaskFactory taskFactory = new TaskFactory(); 
    14111412         
    14121413        IEventType eventType1 = new ValueSelection<String>("value1"); 
    14131414        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
    1414         ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 
     1415        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    14151416         
    14161417        IEventType eventType2 = new ValueSelection<String>("value1"); 
    14171418        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    1418         ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 
    1419          
    1420         assertUnequal(task1, task2); 
    1421     } 
    1422      
    1423     /** 
    1424      * 
    1425      */ 
    1426     private void assertLexicallyEqual(ITaskTreeNode task1, ITaskTreeNode task2) { 
     1419        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
     1420         
     1421        assertUnequal(task1, task2); 
     1422    } 
     1423     
     1424    /** 
     1425     * 
     1426     */ 
     1427    private void assertLexicallyEqual(ITask task1, ITask task2) { 
    14271428        GUIEventTaskComparisonRule rule = new GUIEventTaskComparisonRule(); 
    14281429         
    1429         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task1, task2)); 
     1430        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task1, task2)); 
    14301431        assertTrue(rule.areLexicallyEqual(task1, task2)); 
    14311432        assertTrue(rule.areSyntacticallyEqual(task1, task2)); 
    14321433        assertTrue(rule.areSemanticallyEqual(task1, task2)); 
    14331434 
    1434         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task2, task1)); 
     1435        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task2, task1)); 
    14351436        assertTrue(rule.areLexicallyEqual(task2, task1)); 
    14361437        assertTrue(rule.areSyntacticallyEqual(task2, task1)); 
     
    14411442     * 
    14421443     */ 
    1443     private void assertSyntacticallyEqual(ITaskTreeNode task1, ITaskTreeNode task2) { 
     1444    private void assertSyntacticallyEqual(ITask task1, ITask task2) { 
    14441445        GUIEventTaskComparisonRule rule = new GUIEventTaskComparisonRule(); 
    14451446         
    1446         assertEquals(NodeEquality.SYNTACTICALLY_EQUAL, rule.compare(task1, task2)); 
     1447        assertEquals(TaskEquality.SYNTACTICALLY_EQUAL, rule.compare(task1, task2)); 
    14471448        assertFalse(rule.areLexicallyEqual(task1, task2)); 
    14481449        assertTrue(rule.areSyntacticallyEqual(task1, task2)); 
    14491450        assertTrue(rule.areSemanticallyEqual(task1, task2)); 
    14501451 
    1451         assertEquals(NodeEquality.SYNTACTICALLY_EQUAL, rule.compare(task2, task1)); 
     1452        assertEquals(TaskEquality.SYNTACTICALLY_EQUAL, rule.compare(task2, task1)); 
    14521453        assertFalse(rule.areLexicallyEqual(task2, task1)); 
    14531454        assertTrue(rule.areSyntacticallyEqual(task2, task1)); 
     
    14581459     * 
    14591460     */ 
    1460     private void assertSemanticallyEqual(ITaskTreeNode task1, ITaskTreeNode task2) { 
     1461    private void assertSemanticallyEqual(ITask task1, ITask task2) { 
    14611462        GUIEventTaskComparisonRule rule = new GUIEventTaskComparisonRule(); 
    14621463         
    1463         assertEquals(NodeEquality.SEMANTICALLY_EQUAL, rule.compare(task1, task2)); 
     1464        assertEquals(TaskEquality.SEMANTICALLY_EQUAL, rule.compare(task1, task2)); 
    14641465        assertFalse(rule.areLexicallyEqual(task1, task2)); 
    14651466        assertFalse(rule.areSyntacticallyEqual(task1, task2)); 
    14661467        assertTrue(rule.areSemanticallyEqual(task1, task2)); 
    14671468 
    1468         assertEquals(NodeEquality.SEMANTICALLY_EQUAL, rule.compare(task2, task1)); 
     1469        assertEquals(TaskEquality.SEMANTICALLY_EQUAL, rule.compare(task2, task1)); 
    14691470        assertFalse(rule.areLexicallyEqual(task2, task1)); 
    14701471        assertFalse(rule.areSyntacticallyEqual(task2, task1)); 
     
    14751476     * 
    14761477     */ 
    1477     private void assertUnequal(ITaskTreeNode task1, ITaskTreeNode task2) { 
     1478    private void assertUnequal(ITask task1, ITask task2) { 
    14781479        GUIEventTaskComparisonRule rule = new GUIEventTaskComparisonRule(); 
    14791480         
    1480         assertEquals(NodeEquality.UNEQUAL, rule.compare(task1, task2)); 
     1481        assertEquals(TaskEquality.UNEQUAL, rule.compare(task1, task2)); 
    14811482        assertFalse(rule.areLexicallyEqual(task1, task2)); 
    14821483        assertFalse(rule.areSyntacticallyEqual(task1, task2)); 
    14831484        assertFalse(rule.areSemanticallyEqual(task1, task2)); 
    14841485 
    1485         assertEquals(NodeEquality.UNEQUAL, rule.compare(task2, task1)); 
     1486        assertEquals(TaskEquality.UNEQUAL, rule.compare(task2, task1)); 
    14861487        assertFalse(rule.areLexicallyEqual(task2, task1)); 
    14871488        assertFalse(rule.areSyntacticallyEqual(task2, task1)); 
  • trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/taskequality/IterationComparisonRuleTest.java

    r1125 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1616 
    1717import static org.junit.Assert.*; 
     
    1919import org.junit.Test; 
    2020 
    21 import de.ugoe.cs.autoquest.tasktrees.nodeequality.IterationComparisonRule; 
    22 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEquality; 
    23 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEqualityRuleManager; 
     21import de.ugoe.cs.autoquest.eventcore.IEventTarget; 
     22import de.ugoe.cs.autoquest.eventcore.IEventType; 
     23import de.ugoe.cs.autoquest.eventcore.StringEventType; 
     24import de.ugoe.cs.autoquest.tasktrees.taskequality.IterationComparisonRule; 
     25import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 
     26import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEqualityRuleManager; 
    2427import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 
    2528import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
    26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder; 
    27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; 
    29 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeBuilder; 
    30 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNode; 
    31 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNodeFactory; 
     29import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; 
     30import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     31import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 
     32import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskBuilder; 
     33import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory; 
     34import de.ugoe.cs.autoquest.test.DummyGUIElement; 
    3235 
    3336/** 
     
    4144    @Test 
    4245    public void test() { 
    43         NodeEqualityRuleManager manager = new NodeEqualityRuleManager(); 
     46        TaskEqualityRuleManager manager = new TaskEqualityRuleManager(); 
    4447        manager.init(); 
    4548         
    46         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
    47         ITaskTreeBuilder treeBuilder = new TaskTreeBuilder(); 
     49        ITaskFactory taskFactory = new TaskFactory(); 
     50        ITaskBuilder treeBuilder = new TaskBuilder(); 
    4851         
    4952        IterationComparisonRule rule = new IterationComparisonRule(manager); 
    5053         
    51         ITaskTreeNode task1 = new TaskTreeNode("task1"); 
    52         ITaskTreeNode task2 = new TaskTreeNode("task2"); 
     54        IEventType eventType1 = new StringEventType("eventType1"); 
     55        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
     56 
     57        IEventType eventType2 = new StringEventType("eventType2"); 
     58        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
     59 
     60        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
     61        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    5362         
    5463        assertFalse(rule.isApplicable(task1, task2)); 
    5564         
    56         IIteration iteration1 = treeNodeFactory.createNewIteration(); 
    57         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration1)); 
     65        IIteration iteration1 = taskFactory.createNewIteration(); 
     66        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration1)); 
    5867 
    59         IIteration iteration2 = treeNodeFactory.createNewIteration(); 
     68        IIteration iteration2 = taskFactory.createNewIteration(); 
    6069         
    61         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); 
    62         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); 
     70        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); 
     71        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); 
    6372         
    64         treeBuilder.setChild(iteration1, task1); 
     73        treeBuilder.setMarkedTask(iteration1, task1); 
    6574         
    66         assertEquals(NodeEquality.UNEQUAL, rule.compare(iteration1, iteration2)); 
    67         assertEquals(NodeEquality.UNEQUAL, rule.compare(iteration2, iteration1)); 
     75        assertEquals(TaskEquality.UNEQUAL, rule.compare(iteration1, iteration2)); 
     76        assertEquals(TaskEquality.UNEQUAL, rule.compare(iteration2, iteration1)); 
    6877         
    69         treeBuilder.setChild(iteration2, task1); 
     78        treeBuilder.setMarkedTask(iteration2, task1); 
    7079         
    71         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); 
    72         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); 
     80        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); 
     81        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); 
    7382         
    74         treeBuilder.setChild(iteration1, task2); 
     83        treeBuilder.setMarkedTask(iteration1, task2); 
    7584         
    76         assertEquals(NodeEquality.UNEQUAL, rule.compare(iteration1, iteration2)); 
    77         assertEquals(NodeEquality.UNEQUAL, rule.compare(iteration2, iteration1)); 
     85        assertEquals(TaskEquality.UNEQUAL, rule.compare(iteration1, iteration2)); 
     86        assertEquals(TaskEquality.UNEQUAL, rule.compare(iteration2, iteration1)); 
    7887         
    79         treeBuilder.setChild(iteration2, task2); 
     88        treeBuilder.setMarkedTask(iteration2, task2); 
    8089         
    81         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); 
    82         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); 
     90        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); 
     91        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); 
    8392         
    84         ISelection selection1 = treeNodeFactory.createNewSelection(); 
     93        ISelection selection1 = taskFactory.createNewSelection(); 
    8594        treeBuilder.addChild(selection1, task2); 
    86         treeBuilder.setChild(iteration1, selection1); 
     95        treeBuilder.setMarkedTask(iteration1, selection1); 
    8796         
    88         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); 
    89         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); 
     97        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); 
     98        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); 
    9099         
    91         ISelection selection2 = treeNodeFactory.createNewSelection(); 
     100        ISelection selection2 = taskFactory.createNewSelection(); 
    92101        treeBuilder.addChild(selection2, task2); 
    93         treeBuilder.setChild(iteration2, selection2); 
     102        treeBuilder.setMarkedTask(iteration2, selection2); 
    94103         
    95         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); 
    96         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); 
     104        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); 
     105        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); 
    97106         
    98107        assertFalse(rule.isApplicable(iteration1, selection1)); 
  • trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/taskequality/SelectionComparisonRuleTest.java

    r1125 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1616 
    1717import static org.junit.Assert.*; 
     
    1919import org.junit.Test; 
    2020 
    21 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEquality; 
    22 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEqualityRuleManager; 
    23 import de.ugoe.cs.autoquest.tasktrees.nodeequality.SelectionComparisonRule; 
     21import de.ugoe.cs.autoquest.eventcore.IEventTarget; 
     22import de.ugoe.cs.autoquest.eventcore.IEventType; 
     23import de.ugoe.cs.autoquest.eventcore.StringEventType; 
     24import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 
     25import de.ugoe.cs.autoquest.tasktrees.taskequality.SelectionComparisonRule; 
     26import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEqualityRuleManager; 
    2427import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
    2528import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 
    26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder; 
    27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; 
    29 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeBuilder; 
    30 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNode; 
    31 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNodeFactory; 
     29import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; 
     30import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     31import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 
     32import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskBuilder; 
     33import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory; 
     34import de.ugoe.cs.autoquest.test.DummyGUIElement; 
    3235 
    3336/** 
     
    4144    @Test 
    4245    public void test() { 
    43         NodeEqualityRuleManager manager = new NodeEqualityRuleManager(); 
     46        TaskEqualityRuleManager manager = new TaskEqualityRuleManager(); 
    4447        manager.init(); 
    4548         
    46         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
    47         ITaskTreeBuilder treeBuilder = new TaskTreeBuilder(); 
     49        ITaskFactory taskFactory = new TaskFactory(); 
     50        ITaskBuilder treeBuilder = new TaskBuilder(); 
    4851         
    4952        SelectionComparisonRule rule = new SelectionComparisonRule(manager); 
    5053         
    51         ITaskTreeNode task1 = new TaskTreeNode("task1"); 
    52         ITaskTreeNode task2 = new TaskTreeNode("task2"); 
     54        IEventType eventType1 = new StringEventType("eventType1"); 
     55        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
     56 
     57        IEventType eventType2 = new StringEventType("eventType2"); 
     58        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
     59 
     60        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
     61        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    5362         
    5463        assertFalse(rule.isApplicable(task1, task2)); 
    5564         
    56         ISelection selection1 = treeNodeFactory.createNewSelection(); 
    57         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection1)); 
     65        ISelection selection1 = taskFactory.createNewSelection(); 
     66        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection1)); 
    5867 
    59         ISelection selection2 = treeNodeFactory.createNewSelection(); 
     68        ISelection selection2 = taskFactory.createNewSelection(); 
    6069         
    61         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection2)); 
    62         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection2, selection1)); 
     70        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection2)); 
     71        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection2, selection1)); 
    6372         
    6473        treeBuilder.addChild(selection1, task1); 
    6574         
    66         assertEquals(NodeEquality.UNEQUAL, rule.compare(selection1, selection2)); 
    67         assertEquals(NodeEquality.UNEQUAL, rule.compare(selection2, selection1)); 
     75        assertEquals(TaskEquality.UNEQUAL, rule.compare(selection1, selection2)); 
     76        assertEquals(TaskEquality.UNEQUAL, rule.compare(selection2, selection1)); 
    6877         
    6978        treeBuilder.addChild(selection2, task1); 
    7079         
    71         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection2)); 
    72         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection2, selection1)); 
     80        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection2)); 
     81        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection2, selection1)); 
    7382         
    7483        treeBuilder.addChild(selection1, task2); 
    7584         
    76         assertEquals(NodeEquality.UNEQUAL, rule.compare(selection1, selection2)); 
    77         assertEquals(NodeEquality.UNEQUAL, rule.compare(selection2, selection1)); 
     85        assertEquals(TaskEquality.UNEQUAL, rule.compare(selection1, selection2)); 
     86        assertEquals(TaskEquality.UNEQUAL, rule.compare(selection2, selection1)); 
    7887         
    7988        treeBuilder.addChild(selection2, task2); 
    8089         
    81         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection2)); 
    82         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection2, selection1)); 
     90        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection2)); 
     91        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection2, selection1)); 
    8392         
    84         ISelection selection3 = treeNodeFactory.createNewSelection(); 
     93        ISelection selection3 = taskFactory.createNewSelection(); 
    8594        treeBuilder.addChild(selection3, task2); 
    8695        treeBuilder.addChild(selection3, task1); 
    8796         
    88         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection3)); 
    89         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection3, selection1)); 
     97        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection3)); 
     98        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection3, selection1)); 
    9099         
    91         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection2, selection3)); 
    92         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection3, selection2)); 
     100        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection2, selection3)); 
     101        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection3, selection2)); 
    93102 
    94         ISequence sequence = treeNodeFactory.createNewSequence(); 
     103        ISequence sequence = taskFactory.createNewSequence(); 
    95104        assertFalse(rule.isApplicable(selection1, sequence)); 
    96105        assertFalse(rule.isApplicable(sequence, selection1)); 
  • trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/taskequality/SequenceComparisonRuleTest.java

    r1125 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1616 
    1717import static org.junit.Assert.*; 
     
    1919import org.junit.Test; 
    2020 
    21 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEquality; 
    22 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEqualityRuleManager; 
    23 import de.ugoe.cs.autoquest.tasktrees.nodeequality.SequenceComparisonRule; 
     21import de.ugoe.cs.autoquest.eventcore.IEventTarget; 
     22import de.ugoe.cs.autoquest.eventcore.IEventType; 
     23import de.ugoe.cs.autoquest.eventcore.StringEventType; 
     24import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 
     25import de.ugoe.cs.autoquest.tasktrees.taskequality.SequenceComparisonRule; 
     26import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEqualityRuleManager; 
    2427import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
    2528import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 
    26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder; 
    27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; 
    29 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeBuilder; 
    30 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNode; 
    31 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNodeFactory; 
     29import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; 
     30import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     31import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 
     32import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskBuilder; 
     33import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory; 
     34import de.ugoe.cs.autoquest.test.DummyGUIElement; 
    3235 
    3336/** 
     
    4144    @Test 
    4245    public void test() { 
    43         NodeEqualityRuleManager manager = new NodeEqualityRuleManager(); 
     46        TaskEqualityRuleManager manager = new TaskEqualityRuleManager(); 
    4447        manager.init(); 
    4548         
    46         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
    47         ITaskTreeBuilder treeBuilder = new TaskTreeBuilder(); 
     49        ITaskFactory taskFactory = new TaskFactory(); 
     50        ITaskBuilder treeBuilder = new TaskBuilder(); 
    4851         
    4952        SequenceComparisonRule rule = new SequenceComparisonRule(manager); 
    5053         
    51         ITaskTreeNode task1 = new TaskTreeNode("task1"); 
    52         ITaskTreeNode task2 = new TaskTreeNode("task2"); 
     54        IEventType eventType1 = new StringEventType("eventType1"); 
     55        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
     56 
     57        IEventType eventType2 = new StringEventType("eventType2"); 
     58        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
     59 
     60        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
     61        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 
    5362         
    5463        assertFalse(rule.isApplicable(task1, task2)); 
    5564         
    56         ISequence sequence1 = treeNodeFactory.createNewSequence(); 
    57         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(sequence1, sequence1)); 
     65        ISequence sequence1 = taskFactory.createNewSequence(); 
     66        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(sequence1, sequence1)); 
    5867 
    59         ISequence sequence2 = treeNodeFactory.createNewSequence(); 
     68        ISequence sequence2 = taskFactory.createNewSequence(); 
    6069         
    61         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(sequence1, sequence2)); 
    62         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(sequence2, sequence1)); 
     70        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(sequence1, sequence2)); 
     71        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(sequence2, sequence1)); 
    6372         
    6473        treeBuilder.addChild(sequence1, task1); 
    6574         
    66         assertEquals(NodeEquality.UNEQUAL, rule.compare(sequence1, sequence2)); 
    67         assertEquals(NodeEquality.UNEQUAL, rule.compare(sequence2, sequence1)); 
     75        assertEquals(TaskEquality.UNEQUAL, rule.compare(sequence1, sequence2)); 
     76        assertEquals(TaskEquality.UNEQUAL, rule.compare(sequence2, sequence1)); 
    6877         
    6978        treeBuilder.addChild(sequence2, task1); 
    7079         
    71         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(sequence1, sequence2)); 
    72         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(sequence2, sequence1)); 
     80        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(sequence1, sequence2)); 
     81        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(sequence2, sequence1)); 
    7382         
    7483        treeBuilder.addChild(sequence1, task2); 
    7584         
    76         assertEquals(NodeEquality.UNEQUAL, rule.compare(sequence1, sequence2)); 
    77         assertEquals(NodeEquality.UNEQUAL, rule.compare(sequence2, sequence1)); 
     85        assertEquals(TaskEquality.UNEQUAL, rule.compare(sequence1, sequence2)); 
     86        assertEquals(TaskEquality.UNEQUAL, rule.compare(sequence2, sequence1)); 
    7887         
    7988        treeBuilder.addChild(sequence2, task2); 
    8089         
    81         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(sequence1, sequence2)); 
    82         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(sequence2, sequence1)); 
     90        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(sequence1, sequence2)); 
     91        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(sequence2, sequence1)); 
    8392         
    84         ISequence sequence3 = treeNodeFactory.createNewSequence(); 
     93        ISequence sequence3 = taskFactory.createNewSequence(); 
    8594        treeBuilder.addChild(sequence3, task2); 
    8695        treeBuilder.addChild(sequence3, task1); 
    8796         
    88         assertEquals(NodeEquality.UNEQUAL, rule.compare(sequence1, sequence3)); 
    89         assertEquals(NodeEquality.UNEQUAL, rule.compare(sequence3, sequence1)); 
    90         assertEquals(NodeEquality.UNEQUAL, rule.compare(sequence2, sequence3)); 
    91         assertEquals(NodeEquality.UNEQUAL, rule.compare(sequence3, sequence2)); 
     97        assertEquals(TaskEquality.UNEQUAL, rule.compare(sequence1, sequence3)); 
     98        assertEquals(TaskEquality.UNEQUAL, rule.compare(sequence3, sequence1)); 
     99        assertEquals(TaskEquality.UNEQUAL, rule.compare(sequence2, sequence3)); 
     100        assertEquals(TaskEquality.UNEQUAL, rule.compare(sequence3, sequence2)); 
    92101 
    93         ISelection selection = treeNodeFactory.createNewSelection(); 
     102        ISelection selection = taskFactory.createNewSelection(); 
    94103        assertFalse(rule.isApplicable(sequence1, selection)); 
    95104        assertFalse(rule.isApplicable(selection, sequence1)); 
  • trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskAndIterationComparisonRuleTest.java

    r927 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1616 
    1717import static org.junit.Assert.*; 
     
    1919import org.junit.Test; 
    2020 
    21 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeAndIterationComparisonRule; 
    22 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEquality; 
    23 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEqualityRuleManager; 
     21import de.ugoe.cs.autoquest.eventcore.IEventTarget; 
     22import de.ugoe.cs.autoquest.eventcore.IEventType; 
     23import de.ugoe.cs.autoquest.eventcore.StringEventType; 
     24import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskAndIterationComparisonRule; 
     25import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 
     26import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEqualityRuleManager; 
    2427import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 
    2528import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
    26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder; 
    27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; 
    29 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeBuilder; 
    30 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNode; 
    31 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNodeFactory; 
     29import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; 
     30import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     31import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 
     32import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskBuilder; 
     33import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory; 
     34import de.ugoe.cs.autoquest.test.DummyGUIElement; 
    3235 
    3336/** 
    3437 * @author Patrick Harms 
    3538 */ 
    36 public class NodeAndIterationComparisonRuleTest { 
     39public class TaskAndIterationComparisonRuleTest { 
    3740 
    3841    /** 
     
    4144    @Test 
    4245    public void test() { 
    43         NodeEqualityRuleManager manager = new NodeEqualityRuleManager(); 
     46        TaskEqualityRuleManager manager = new TaskEqualityRuleManager(); 
    4447        manager.init(); 
    4548         
    46         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
    47         ITaskTreeBuilder treeBuilder = new TaskTreeBuilder(); 
     49        ITaskFactory taskFactory = new TaskFactory(); 
     50        ITaskBuilder treeBuilder = new TaskBuilder(); 
    4851         
    49         NodeAndIterationComparisonRule rule = new NodeAndIterationComparisonRule(manager); 
     52        TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(manager); 
    5053         
    51         ITaskTreeNode task1 = new TaskTreeNode("task1"); 
     54        IEventType eventType1 = new StringEventType("eventType1"); 
     55        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
     56        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    5257         
    5358        assertNull(rule.compare(task1, task1)); 
    5459         
    55         IIteration iteration1 = treeNodeFactory.createNewIteration(); 
     60        IIteration iteration1 = taskFactory.createNewIteration(); 
    5661        assertNull(rule.compare(iteration1, iteration1)); 
    5762        assertNull(rule.compare(task1, iteration1)); 
    5863        assertNull(rule.compare(iteration1, task1)); 
    5964 
    60         treeBuilder.setChild(iteration1, task1); 
     65        treeBuilder.setMarkedTask(iteration1, task1); 
    6166         
    62         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration1, task1)); 
    63         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task1, iteration1)); 
     67        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration1, task1)); 
     68        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task1, iteration1)); 
    6469         
    65         ISelection selection1 = treeNodeFactory.createNewSelection(); 
     70        ISelection selection1 = taskFactory.createNewSelection(); 
    6671        treeBuilder.addChild(selection1, task1); 
    67         treeBuilder.setChild(iteration1, selection1); 
     72        treeBuilder.setMarkedTask(iteration1, selection1); 
    6873         
    69         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration1, task1)); 
    70         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task1, iteration1)); 
     74        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration1, task1)); 
     75        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task1, iteration1)); 
    7176    } 
    7277 
  • trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskAndSelectionComparisonRuleTest.java

    r927 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1616 
    1717import static org.junit.Assert.*; 
     
    1919import org.junit.Test; 
    2020 
    21 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeAndSelectionComparisonRule; 
    22 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEquality; 
    23 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEqualityRuleManager; 
     21import de.ugoe.cs.autoquest.eventcore.IEventTarget; 
     22import de.ugoe.cs.autoquest.eventcore.IEventType; 
     23import de.ugoe.cs.autoquest.eventcore.StringEventType; 
     24import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskAndSelectionComparisonRule; 
     25import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 
     26import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEqualityRuleManager; 
    2427import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
    25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder; 
    26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; 
    28 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeBuilder; 
    29 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNode; 
    30 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNodeFactory; 
     28import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; 
     29import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     30import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 
     31import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskBuilder; 
     32import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory; 
     33import de.ugoe.cs.autoquest.test.DummyGUIElement; 
    3134 
    3235/** 
    3336 * @author Patrick Harms 
    3437 */ 
    35 public class NodeAndSelectionComparisonRuleTest { 
     38public class TaskAndSelectionComparisonRuleTest { 
    3639 
    3740    /** 
     
    4043    @Test 
    4144    public void test() { 
    42         NodeEqualityRuleManager manager = new NodeEqualityRuleManager(); 
     45        TaskEqualityRuleManager manager = new TaskEqualityRuleManager(); 
    4346        manager.init(); 
    4447         
    45         ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 
    46         ITaskTreeBuilder treeBuilder = new TaskTreeBuilder(); 
     48        ITaskFactory taskFactory = new TaskFactory(); 
     49        ITaskBuilder treeBuilder = new TaskBuilder(); 
    4750         
    48         NodeAndSelectionComparisonRule rule = new NodeAndSelectionComparisonRule(manager); 
     51        TaskAndSelectionComparisonRule rule = new TaskAndSelectionComparisonRule(manager); 
    4952         
    50         ITaskTreeNode task1 = new TaskTreeNode("task1"); 
     53        IEventType eventType1 = new StringEventType("eventType1"); 
     54        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
     55        ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 
    5156         
    5257        assertNull(rule.compare(task1, task1)); 
    5358         
    54         ISelection selection1 = treeNodeFactory.createNewSelection(); 
     59        ISelection selection1 = taskFactory.createNewSelection(); 
    5560        assertNull(rule.compare(selection1, selection1)); 
    5661        assertNull(rule.compare(task1, selection1)); 
     
    5964        treeBuilder.addChild(selection1, task1); 
    6065         
    61         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection1, task1)); 
    62         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task1, selection1)); 
     66        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection1, task1)); 
     67        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task1, selection1)); 
    6368         
    64         selection1 = treeNodeFactory.createNewSelection(); 
    65         ISelection selection2 = treeNodeFactory.createNewSelection(); 
     69        selection1 = taskFactory.createNewSelection(); 
     70        ISelection selection2 = taskFactory.createNewSelection(); 
    6671        treeBuilder.addChild(selection2, task1); 
    6772        treeBuilder.addChild(selection1, selection2); 
    6873         
    69         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection1, task1)); 
    70         assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task1, selection1)); 
     74        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection1, task1)); 
     75        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task1, selection1)); 
    7176    } 
    7277 
  • trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskEqualityTest.java

    r927 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1616 
    1717import static org.junit.Assert.*; 
     
    1919import org.junit.Test; 
    2020 
    21 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEquality; 
     21import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 
    2222 
    2323/** 
    2424 * @author Patrick Harms 
    2525 */ 
    26 public class NodeEqualityTest { 
     26public class TaskEqualityTest { 
    2727 
    2828    /** 
     
    3131    @Test 
    3232    public void test() { 
    33         assertTrue(NodeEquality.IDENTICAL.isAtLeast(NodeEquality.IDENTICAL)); 
    34         assertTrue(NodeEquality.IDENTICAL.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 
    35         assertTrue(NodeEquality.IDENTICAL.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 
    36         assertTrue(NodeEquality.IDENTICAL.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 
    37         assertFalse(NodeEquality.IDENTICAL.isAtLeast(NodeEquality.UNEQUAL)); 
     33        assertTrue(TaskEquality.IDENTICAL.isAtLeast(TaskEquality.IDENTICAL)); 
     34        assertTrue(TaskEquality.IDENTICAL.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 
     35        assertTrue(TaskEquality.IDENTICAL.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 
     36        assertTrue(TaskEquality.IDENTICAL.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 
     37        assertFalse(TaskEquality.IDENTICAL.isAtLeast(TaskEquality.UNEQUAL)); 
    3838 
    39         assertFalse(NodeEquality.LEXICALLY_EQUAL.isAtLeast(NodeEquality.IDENTICAL)); 
    40         assertTrue(NodeEquality.LEXICALLY_EQUAL.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 
    41         assertTrue(NodeEquality.LEXICALLY_EQUAL.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 
    42         assertTrue(NodeEquality.LEXICALLY_EQUAL.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 
    43         assertFalse(NodeEquality.LEXICALLY_EQUAL.isAtLeast(NodeEquality.UNEQUAL)); 
     39        assertFalse(TaskEquality.LEXICALLY_EQUAL.isAtLeast(TaskEquality.IDENTICAL)); 
     40        assertTrue(TaskEquality.LEXICALLY_EQUAL.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 
     41        assertTrue(TaskEquality.LEXICALLY_EQUAL.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 
     42        assertTrue(TaskEquality.LEXICALLY_EQUAL.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 
     43        assertFalse(TaskEquality.LEXICALLY_EQUAL.isAtLeast(TaskEquality.UNEQUAL)); 
    4444 
    45         assertFalse(NodeEquality.SYNTACTICALLY_EQUAL.isAtLeast(NodeEquality.IDENTICAL)); 
    46         assertFalse(NodeEquality.SYNTACTICALLY_EQUAL.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 
    47         assertTrue(NodeEquality.SYNTACTICALLY_EQUAL.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 
    48         assertTrue(NodeEquality.SYNTACTICALLY_EQUAL.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 
    49         assertFalse(NodeEquality.SYNTACTICALLY_EQUAL.isAtLeast(NodeEquality.UNEQUAL)); 
     45        assertFalse(TaskEquality.SYNTACTICALLY_EQUAL.isAtLeast(TaskEquality.IDENTICAL)); 
     46        assertFalse(TaskEquality.SYNTACTICALLY_EQUAL.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 
     47        assertTrue(TaskEquality.SYNTACTICALLY_EQUAL.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 
     48        assertTrue(TaskEquality.SYNTACTICALLY_EQUAL.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 
     49        assertFalse(TaskEquality.SYNTACTICALLY_EQUAL.isAtLeast(TaskEquality.UNEQUAL)); 
    5050 
    51         assertFalse(NodeEquality.SEMANTICALLY_EQUAL.isAtLeast(NodeEquality.IDENTICAL)); 
    52         assertFalse(NodeEquality.SEMANTICALLY_EQUAL.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 
    53         assertFalse(NodeEquality.SEMANTICALLY_EQUAL.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 
    54         assertTrue(NodeEquality.SEMANTICALLY_EQUAL.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 
    55         assertFalse(NodeEquality.SEMANTICALLY_EQUAL.isAtLeast(NodeEquality.UNEQUAL)); 
     51        assertFalse(TaskEquality.SEMANTICALLY_EQUAL.isAtLeast(TaskEquality.IDENTICAL)); 
     52        assertFalse(TaskEquality.SEMANTICALLY_EQUAL.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 
     53        assertFalse(TaskEquality.SEMANTICALLY_EQUAL.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 
     54        assertTrue(TaskEquality.SEMANTICALLY_EQUAL.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 
     55        assertFalse(TaskEquality.SEMANTICALLY_EQUAL.isAtLeast(TaskEquality.UNEQUAL)); 
    5656 
    57         assertFalse(NodeEquality.UNEQUAL.isAtLeast(NodeEquality.IDENTICAL)); 
    58         assertFalse(NodeEquality.UNEQUAL.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 
    59         assertFalse(NodeEquality.UNEQUAL.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 
    60         assertFalse(NodeEquality.UNEQUAL.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 
    61         assertTrue(NodeEquality.UNEQUAL.isAtLeast(NodeEquality.UNEQUAL)); 
     57        assertFalse(TaskEquality.UNEQUAL.isAtLeast(TaskEquality.IDENTICAL)); 
     58        assertFalse(TaskEquality.UNEQUAL.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 
     59        assertFalse(TaskEquality.UNEQUAL.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 
     60        assertFalse(TaskEquality.UNEQUAL.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 
     61        assertTrue(TaskEquality.UNEQUAL.isAtLeast(TaskEquality.UNEQUAL)); 
    6262    } 
    6363 
  • trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/AbstractTemporalRelationshipTC.java

    r1132 r1146  
    2121import java.lang.reflect.Constructor; 
    2222import java.lang.reflect.InvocationTargetException; 
    23 import java.util.ArrayList; 
    2423import java.util.LinkedList; 
    2524import java.util.List; 
     
    2928import org.junit.Before; 
    3029 
    31 import de.ugoe.cs.autoquest.eventcore.IEventTarget; 
    32 import de.ugoe.cs.autoquest.eventcore.IEventType; 
    33 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEquality; 
    34 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEqualityRuleManager; 
     30import de.ugoe.cs.autoquest.tasktrees.TaskTreeChecker; 
     31import de.ugoe.cs.autoquest.tasktrees.TaskTreeDecoder; 
     32import de.ugoe.cs.autoquest.tasktrees.TaskTreeEncoder; 
     33import de.ugoe.cs.autoquest.tasktrees.TaskTreeValidator; 
     34import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 
     35import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEqualityRuleManager; 
    3536import de.ugoe.cs.autoquest.tasktrees.testutils.Utilities; 
    36 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 
    37 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 
    38 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree; 
    39 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder; 
    40 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    41 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; 
    42 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeBuilder; 
    43 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNodeFactory; 
     37import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList; 
     38import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; 
     39import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 
     40import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 
     41import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskBuilder; 
     42import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory; 
    4443import de.ugoe.cs.util.console.Console; 
    4544import de.ugoe.cs.util.console.TextConsole; 
     
    5251 
    5352    /** */ 
    54     private List<IEventTask> events; 
    55  
    56     /** */ 
    57     private ITaskTreeBuilder taskTreeBuilder = new TaskTreeBuilder(); 
    58  
    59     /** */ 
    60     private ITaskTreeNodeFactory taskTreeNodeFactory = new TaskTreeNodeFactory(); 
    61  
    62     /** */ 
    63     private NodeEqualityRuleManager nodeEqualityRuleManager = 
    64         Utilities.getNodeEqualityRuleManagerForTests(); 
     53    private ITaskBuilder taskBuilder = new TaskBuilder(); 
     54 
     55    /** */ 
     56    private ITaskFactory taskFactory = new TaskFactory(); 
     57     
     58    /** */ 
     59    private TaskTreeDecoder decoder = null; 
     60 
     61    /** */ 
     62    private TaskTreeEncoder encoder = new TaskTreeEncoder(); 
     63     
     64    /** */ 
     65    private TaskEqualityRuleManager taskEqualityRuleManager = 
     66        Utilities.getTaskEqualityRuleManagerForTests(); 
    6567 
    6668    /** 
     
    6971    @Before 
    7072    public void setUp() { 
     73        Console.reset(); 
    7174        new TextConsole(Level.FINEST); 
    72         events = new ArrayList<IEventTask>(); 
     75         
     76        decoder = new TaskTreeDecoder(taskFactory, taskBuilder); 
    7377    } 
    7478 
     
    7680     * 
    7781     */ 
    78     protected void simulateEvent(IEventType eventType, IEventTarget eventTarget) { 
    79         events.add(taskTreeNodeFactory.createNewEventTask(eventType, eventTarget)); 
    80         Console.reset(); 
     82    protected void applyRule(Class<? extends ITaskInstanceListScopeRule> ruleClass, 
     83                             String                                      inputSpec, 
     84                             String                                      expectedOutputSpec) 
     85    { 
     86        ITaskInstanceListScopeRule rule = null; 
     87         
     88        CONSTRUCTOR_ITERATION: 
     89        for (Constructor<?> constructor : ruleClass.getDeclaredConstructors()) { 
     90            List<Object> parameters = new LinkedList<Object>(); 
     91             
     92            for (Class<?> type : constructor.getParameterTypes()) { 
     93                if (ITaskFactory.class.equals(type)) { 
     94                    parameters.add(taskFactory); 
     95                } 
     96                else if (ITaskBuilder.class.equals(type)) { 
     97                    parameters.add(taskBuilder); 
     98                } 
     99                else if (TaskEqualityRuleManager.class.equals(type)) { 
     100                    parameters.add(taskEqualityRuleManager); 
     101                } 
     102                else if (TaskEquality.class.equals(type)) { 
     103                    parameters.add(TaskEquality.LEXICALLY_EQUAL); 
     104                } 
     105                else { 
     106                    continue CONSTRUCTOR_ITERATION; 
     107                } 
     108            } 
     109             
     110            try { 
     111                rule = (ITaskInstanceListScopeRule) constructor.newInstance(parameters.toArray()); 
     112            } 
     113            catch (IllegalArgumentException e) { 
     114                e.printStackTrace(); 
     115                fail("could not invoke the constructor " + constructor); 
     116            } 
     117            catch (InstantiationException e) { 
     118                e.printStackTrace(); 
     119                fail("could not invoke the constructor " + constructor); 
     120            } 
     121            catch (IllegalAccessException e) { 
     122                e.printStackTrace(); 
     123                fail("could not invoke the constructor " + constructor); 
     124            } 
     125            catch (InvocationTargetException e) { 
     126                e.printStackTrace(); 
     127                fail("could not invoke the constructor " + constructor); 
     128            } 
     129        } 
     130         
     131        if (rule == null) { 
     132            fail("no matching constructor found to instantiate rule " + ruleClass); 
     133        } 
     134         
     135        RuleApplicationResult result; 
     136        RuleApplicationStatus status; 
     137         
     138        ITaskInstanceList inputList = decoder.decode(inputSpec); 
     139         
     140        Stack<ITaskInstanceList> toBeAppliedOn = new Stack<ITaskInstanceList>(); 
     141        toBeAppliedOn.push(inputList); 
     142         
     143        do { 
     144            result = rule.apply(toBeAppliedOn.peek()); 
     145             
     146            if (result != null) { 
     147                status = result.getRuleApplicationStatus(); 
     148                assertNotNull(status); 
     149            } 
     150            else { 
     151                status = RuleApplicationStatus.NOT_APPLIED; 
     152            } 
     153             
     154            assertTrue(status != RuleApplicationStatus.FEASIBLE); 
     155             
     156            if ((result != null) && (result.getNewlyCreatedTaskInstances() != null)) { 
     157                for (int i = result.getNewlyCreatedTaskInstances().size() - 1; i >= 0; i--) { 
     158                    toBeAppliedOn.push(result.getNewlyCreatedTaskInstances().get(i)); 
     159                } 
     160            } 
     161             
     162            if (status == RuleApplicationStatus.NOT_APPLIED) { 
     163                toBeAppliedOn.pop(); 
     164            } 
     165             
     166        } 
     167        while ((!toBeAppliedOn.isEmpty()) || (status == RuleApplicationStatus.FINISHED)); 
     168 
     169        ITaskInstanceList expectedList = decoder.decode(expectedOutputSpec); 
     170         
     171        new TaskTreeChecker().assertTaskInstanceListsEqual(expectedList, inputList); 
    81172    } 
    82173 
     
    84175     * 
    85176     */ 
    86     protected ITaskTree getTaskTree() { 
    87         ISequence sequence = taskTreeNodeFactory.createNewSequence(); 
    88  
    89         for (IEventTask task : events) { 
    90             taskTreeBuilder.addChild(sequence, task); 
    91         } 
    92  
    93         TemporalRelationshipRuleManager ruleManager = new TemporalRelationshipRuleManager 
    94             (nodeEqualityRuleManager, taskTreeNodeFactory, taskTreeBuilder); 
    95  
    96         ruleManager.init(); 
    97         ruleManager.applyRules(sequence); 
    98  
    99         return taskTreeNodeFactory.createTaskTree(sequence); 
    100     } 
    101  
    102     /** 
    103      * 
    104      */ 
    105     protected ITaskTree getTaskTree(Class<? extends TemporalRelationshipRule> ruleClass, 
    106                                     NodeEquality                              nodeEquality) 
     177    protected void applySessionScopeRule(Class<? extends ISessionScopeRule> ruleClass, 
     178                                         String                             inputSpec, 
     179                                         String                             expectedOutputSpec) 
    107180    { 
    108         return getTaskTree(ruleClass, nodeEquality, false); 
    109     } 
    110      
    111     /** 
    112      * 
    113      */ 
    114     protected ITaskTree getTaskTree(Class<? extends TemporalRelationshipRule> ruleClass, 
    115                                     NodeEquality                              nodeEquality, 
    116                                     boolean                                   explicitSessionSeq) 
    117     { 
    118         ISequence sequence = taskTreeNodeFactory.createNewSequence(); 
    119  
    120         for (IEventTask task : events) { 
    121             taskTreeBuilder.addChild(sequence, task); 
    122         } 
    123  
    124         if (explicitSessionSeq) { 
    125             ISequence root = taskTreeNodeFactory.createNewSequence(); 
    126             taskTreeBuilder.addChild(root, sequence); 
    127             sequence = root; 
    128         } 
    129          
    130         TemporalRelationshipRule rule = null; 
     181        ISessionScopeRule rule = null; 
    131182         
    132183        CONSTRUCTOR_ITERATION: 
     
    135186             
    136187            for (Class<?> type : constructor.getParameterTypes()) { 
    137                 if (ITaskTreeNodeFactory.class.equals(type)) { 
    138                     parameters.add(taskTreeNodeFactory); 
    139                 } 
    140                 else if (ITaskTreeBuilder.class.equals(type)) { 
    141                     parameters.add(taskTreeBuilder); 
    142                 } 
    143                 else if (NodeEqualityRuleManager.class.equals(type)) { 
    144                     parameters.add(nodeEqualityRuleManager); 
    145                 } 
    146                 else if (NodeEquality.class.equals(type)) { 
    147                     if (nodeEquality != null) { 
    148                         parameters.add(nodeEquality); 
    149                     } 
    150                     else { 
    151                         parameters.add(NodeEquality.LEXICALLY_EQUAL); 
    152                     } 
     188                if (ITaskFactory.class.equals(type)) { 
     189                    parameters.add(taskFactory); 
     190                } 
     191                else if (ITaskBuilder.class.equals(type)) { 
     192                    parameters.add(taskBuilder); 
     193                } 
     194                else if (TaskEqualityRuleManager.class.equals(type)) { 
     195                    parameters.add(taskEqualityRuleManager); 
     196                } 
     197                else if (TaskEquality.class.equals(type)) { 
     198                    parameters.add(TaskEquality.LEXICALLY_EQUAL); 
    153199                } 
    154200                else { 
     
    158204             
    159205            try { 
    160                 rule = (TemporalRelationshipRule) constructor.newInstance(parameters.toArray()); 
     206                rule = (ISessionScopeRule) constructor.newInstance(parameters.toArray()); 
    161207            } 
    162208            catch (IllegalArgumentException e) { 
     
    182228        } 
    183229         
    184         RuleApplicationResult result; 
    185         RuleApplicationStatus status; 
    186          
    187         Stack<ITaskTreeNode> toBeAppliedOn = new Stack<ITaskTreeNode>(); 
    188         toBeAppliedOn.push(sequence); 
    189          
    190         do { 
    191             result = rule.apply(toBeAppliedOn.peek(), true); 
    192              
    193             if (result != null) { 
    194                 status = result.getRuleApplicationStatus(); 
    195                 assertNotNull(status); 
    196             } 
    197             else { 
    198                 status = RuleApplicationStatus.NOT_APPLIED; 
    199             } 
    200              
    201             assertTrue(status != RuleApplicationStatus.FEASIBLE); 
    202              
    203             if ((result != null) && (result.getNewlyCreatedParentNodes() != null)) { 
    204                 for (int i = result.getNewlyCreatedParentNodes().size() - 1; i >= 0; i--) { 
    205                     toBeAppliedOn.push(result.getNewlyCreatedParentNodes().get(i)); 
    206                 } 
    207             } 
    208              
    209             if (status == RuleApplicationStatus.NOT_APPLIED) { 
    210                 toBeAppliedOn.pop(); 
    211             } 
    212              
    213         } 
    214         while ((!toBeAppliedOn.isEmpty()) || (status == RuleApplicationStatus.FINISHED)); 
    215  
    216         return taskTreeNodeFactory.createTaskTree(sequence); 
     230        ITaskInstanceList inputList = decoder.decode(inputSpec); 
     231         
     232        assertTrue(inputList instanceof IUserSession); 
     233         
     234        List<IUserSession> sessionList = new LinkedList<IUserSession>(); 
     235        sessionList.add((IUserSession) inputList); 
     236         
     237        System.out.println("Input:"); 
     238        encoder.encode(inputList, System.out); 
     239         
     240        RuleApplicationResult result = rule.apply(sessionList); 
     241         
     242        assertNotNull(result); 
     243        assertNotNull(result.getRuleApplicationStatus()); 
     244        assertTrue(result.getRuleApplicationStatus() != RuleApplicationStatus.FEASIBLE); 
     245             
     246        ITaskInstanceList expectedList = decoder.decode(expectedOutputSpec); 
     247         
     248        System.out.println("\nExpected Result:"); 
     249        encoder.encode(expectedList, System.out); 
     250        System.out.println("\nResult:"); 
     251        encoder.encode(inputList, System.out); 
     252 
     253        new TaskTreeChecker().assertTaskInstanceListsEqual(expectedList, inputList); 
     254        new TaskTreeValidator().validate(inputList); 
    217255    } 
    218256 
  • trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRuleTest.java

    r1132 r1146  
    1717import org.junit.Test; 
    1818 
    19 import de.ugoe.cs.autoquest.eventcore.IEventTarget; 
    20 import de.ugoe.cs.autoquest.eventcore.gui.IInteraction; 
    21 import de.ugoe.cs.autoquest.tasktrees.TaskTreeChecker; 
    22 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEquality; 
    23 import de.ugoe.cs.autoquest.test.DummyGUIElement; 
    24 import de.ugoe.cs.autoquest.test.DummyInteraction; 
    25  
    2619/** 
    2720 * TODO comment 
     
    3629     */ 
    3730    @Test 
    38     public void testTaskDetection() throws Exception { 
    39         IEventTarget element1 = new DummyGUIElement("elem1"); 
    40          
    41         IInteraction action1 = new DummyInteraction("action1", 1); 
    42         IInteraction action2 = new DummyInteraction("action2", 1); 
    43         IInteraction action3 = new DummyInteraction("action3", 1); 
    44         IInteraction action4 = new DummyInteraction("action4", 1); 
    45          
    46         simulateEvent(new DummyInteraction("noise0", 1), element1); 
    47         simulateEvent(action1, element1); 
    48         simulateEvent(action2, element1); 
    49         simulateEvent(action3, element1); 
    50         simulateEvent(action4, element1); 
    51         simulateEvent(new DummyInteraction("noise1", 1), element1); 
    52         simulateEvent(new DummyInteraction("noise2", 1), element1); 
    53         simulateEvent(action1, element1); 
    54         simulateEvent(action2, element1); 
    55         simulateEvent(action3, element1); 
    56         simulateEvent(action4, element1); 
    57         simulateEvent(new DummyInteraction("noise3", 1), element1); 
    58         simulateEvent(new DummyInteraction("noise4", 1), element1); 
    59         simulateEvent(new DummyInteraction("noise5", 1), element1); 
    60         simulateEvent(new DummyInteraction("noise6", 1), element1); 
    61         simulateEvent(action1, element1); 
    62         simulateEvent(action2, element1); 
    63         simulateEvent(action3, element1); 
    64         simulateEvent(action4, element1); 
    65         simulateEvent(new DummyInteraction("noise7", 1), element1); 
    66         simulateEvent(new DummyInteraction("noise8", 1), element1); 
    67          
    68         new TaskTreeChecker().assertTaskTree 
    69             ("Sequence root {" + 
    70              "  Sequence session1 {" + 
    71              "    Event noise0 {}" + 
    72              "    Sequence sequence2 {" + 
    73              "      Event action1 {}" + 
    74              "      Event action2 {}" + 
    75              "      Event action3 {}" + 
    76              "      Event action4 {}" + 
    77              "    }" + 
    78              "    Event noise1 {}" + 
    79              "    Event noise2 {}" + 
    80              "    Sequence sequence2 {" + 
    81              "      Event action1 {}" + 
    82              "      Event action2 {}" + 
    83              "      Event action3 {}" + 
    84              "      Event action4 {}" + 
    85              "    }" + 
    86              "    Event noise3 {}" + 
    87              "    Event noise4 {}" + 
    88              "    Event noise5 {}" + 
    89              "    Event noise6 {}" + 
    90              "    Sequence sequence2 {" + 
    91              "      Event action1 {}" + 
    92              "      Event action2 {}" + 
    93              "      Event action3 {}" + 
    94              "      Event action4 {}" + 
    95              "    }" + 
    96              "    Event noise7 {}" + 
    97              "    Event noise8 {}" + 
    98              "  }" + 
    99              "}", getTaskTree(SequenceForTaskDetectionRule.class, NodeEquality.LEXICALLY_EQUAL, true)); 
     31    public void test_TaskDetection_01() throws Exception { 
     32        String input = 
     33            "UserSession {" + 
     34            "  Event noise0 {}" + 
     35            "  Event action1 {}" + 
     36            "  Event action2 {}" + 
     37            "  Event action3 {}" + 
     38            "  Event action4 {}" + 
     39            "  Event noise1 {}" + 
     40            "  Event noise2 {}" + 
     41            "  Event action1 {}" + 
     42            "  Event action2 {}" + 
     43            "  Event action3 {}" + 
     44            "  Event action4 {}" + 
     45            "  Event noise3 {}" + 
     46            "  Event noise4 {}" + 
     47            "  Event noise5 {}" + 
     48            "  Event noise6 {}" + 
     49            "  Event action1 {}" + 
     50            "  Event action2 {}" + 
     51            "  Event action3 {}" + 
     52            "  Event action4 {}" + 
     53            "  Event action1 {}" + 
     54            "  Event action2 {}" + 
     55            "  Event action3 {}" + 
     56            "  Event action4 {}" + 
     57            "  Event noise7 {}" + 
     58            "}"; 
    10059 
     60        String output = 
     61            "UserSession {" + 
     62            "  Event noise0 {}" + 
     63            "  Iteration iteration1 {" + 
     64            "    Sequence sequence1 {" + 
     65            "      Event action1 {}" + 
     66            "      Event action2 {}" + 
     67            "      Event action3 {}" + 
     68            "      Event action4 {}" + 
     69            "    }" + 
     70            "  }" + 
     71            "  Event noise1 {}" + 
     72            "  Event noise2 {}" + 
     73            "  Iteration iteration1 {" + 
     74            "    Sequence sequence1 {" + 
     75            "      Event action1 {}" + 
     76            "      Event action2 {}" + 
     77            "      Event action3 {}" + 
     78            "      Event action4 {}" + 
     79            "    }" + 
     80            "  }" + 
     81            "  Event noise3 {}" + 
     82            "  Event noise4 {}" + 
     83            "  Event noise5 {}" + 
     84            "  Event noise6 {}" + 
     85            "  Iteration iteration1 {" + 
     86            "    Sequence sequence1 {" + 
     87            "      Event action1 {}" + 
     88            "      Event action2 {}" + 
     89            "      Event action3 {}" + 
     90            "      Event action4 {}" + 
     91            "    }" + 
     92            "    Sequence sequence1 {" + 
     93            "      Event action1 {}" + 
     94            "      Event action2 {}" + 
     95            "      Event action3 {}" + 
     96            "      Event action4 {}" + 
     97            "    }" + 
     98            "  }" + 
     99            "  Event noise7 {}" + 
     100            "}"; 
     101 
     102        applySessionScopeRule(SequenceForTaskDetectionRule.class, input, output); 
     103    } 
     104 
     105    /** 
     106     * 
     107     */ 
     108    @Test 
     109    public void test_TaskDetection_02() throws Exception { 
     110        String input = 
     111            "UserSession {" + 
     112            "  Event noise0 {}" + 
     113            "  Event action1 {}" + 
     114            "  Event action2 {}" + 
     115            "  Event noise1 {}" + 
     116            "  Event noise2 {}" + 
     117            "  Event action3 {}" + 
     118            "  Event action1 {}" + 
     119            "  Event action2 {}" + 
     120            "  Event action4 {}" + 
     121            "  Event noise3 {}" + 
     122            "  Event noise4 {}" + 
     123            "  Event noise5 {}" + 
     124            "  Event noise6 {}" + 
     125            "  Event action1 {}" + 
     126            "  Event action2 {}" + 
     127            "  Event action3 {}" + 
     128            "  Event action4 {}" + 
     129            "  Event action1 {}" + 
     130            "  Event action2 {}" + 
     131            "  Event action3 {}" + 
     132            "  Event action4 {}" + 
     133            "  Event noise7 {}" + 
     134            "}"; 
     135 
     136        String output = 
     137            "UserSession {" + 
     138            "  Event noise0 {}" + 
     139            "  Sequence sequence1 {" + 
     140            "    Event action1 {}" + 
     141            "    Event action2 {}" + 
     142            "  }" + 
     143            "  Event noise1 {}" + 
     144            "  Event noise2 {}" + 
     145            "  Event action3 {}" + 
     146            "  Sequence sequence1 {" + 
     147            "    Event action1 {}" + 
     148            "    Event action2 {}" + 
     149            "  }" + 
     150            "  Event action4 {}" + 
     151            "  Event noise3 {}" + 
     152            "  Event noise4 {}" + 
     153            "  Event noise5 {}" + 
     154            "  Event noise6 {}" + 
     155            "  Iteration iteration1 {" + 
     156            "    Sequence sequence3 {" + 
     157            "      Sequence sequence1 {" + 
     158            "        Event action1 {}" + 
     159            "        Event action2 {}" + 
     160            "      }" + 
     161            "      Event action3 {}" + 
     162            "      Event action4 {}" + 
     163            "    }" + 
     164            "    Sequence sequence3 {" + 
     165            "      Sequence sequence1 {" + 
     166            "        Event action1 {}" + 
     167            "        Event action2 {}" + 
     168            "      }" + 
     169            "      Event action3 {}" + 
     170            "      Event action4 {}" + 
     171            "    }" + 
     172            "  }" + 
     173            "  Event noise7 {}" + 
     174            "}"; 
     175 
     176        applySessionScopeRule(SequenceForTaskDetectionRule.class, input, output); 
    101177    } 
    102178 
  • trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/testutils/Utilities.java

    r927 r1146  
    1515package de.ugoe.cs.autoquest.tasktrees.testutils; 
    1616 
    17 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEqualityRuleManager; 
     17import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEqualityRuleManager; 
    1818 
    1919/** 
     
    2626     
    2727    /** */ 
    28     private static final NodeEqualityRuleManager NODE_EQUALITY_RULE_MANAGER = 
    29         new NodeEqualityRuleManager(); 
     28    private static final TaskEqualityRuleManager NODE_EQUALITY_RULE_MANAGER = 
     29        new TaskEqualityRuleManager(); 
    3030 
     31    /** */ 
    3132    static { 
    3233        NODE_EQUALITY_RULE_MANAGER.init(); 
     
    3839     * @return 
    3940     */ 
    40     public static NodeEqualityRuleManager getNodeEqualityRuleManagerForTests() { 
     41    public static TaskEqualityRuleManager getTaskEqualityRuleManagerForTests() { 
    4142        return NODE_EQUALITY_RULE_MANAGER; 
    4243    } 
  • trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskModelTest.java

    r1132 r1146  
    1515package de.ugoe.cs.autoquest.tasktrees.treeimpl; 
    1616 
    17 import static org.junit.Assert.assertEquals; 
    18 import static org.junit.Assert.assertNotNull; 
    19 import static org.junit.Assert.assertNull; 
     17import static org.junit.Assert.*; 
    2018 
    2119import java.util.HashMap; 
     20import java.util.LinkedList; 
     21import java.util.List; 
    2222import java.util.Map; 
    2323 
    2424import org.junit.Test; 
    2525 
     26import de.ugoe.cs.autoquest.eventcore.IEventTarget; 
     27import de.ugoe.cs.autoquest.eventcore.IEventType; 
    2628import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 
    2729import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 
     30import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 
    2831import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
    2932import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 
    30 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree; 
    31 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder; 
    32 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    33 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; 
    34 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeInfo; 
    35 import de.ugoe.cs.autoquest.tasktrees.treeimpl.NodeInfo; 
    36 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeBuilder; 
    37 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNodeFactory; 
     33import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     34import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 
     35import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 
     36import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; 
     37import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 
     38import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInfo; 
     39import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 
     40import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskInfo; 
     41import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskBuilder; 
     42import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory; 
    3843import de.ugoe.cs.autoquest.test.DummyGUIElement; 
    3944import de.ugoe.cs.autoquest.test.DummyInteraction; 
     
    4550 * @author 2012, last modified by $Author: patrick$ 
    4651 */ 
    47 public class TaskTreeImplTest { 
     52public class TaskModelTest { 
    4853     
    4954    /** */ 
     
    5156 
    5257    /** */ 
    53     private ITaskTreeBuilder taskTreeBuilder = new TaskTreeBuilder(); 
     58    private ITaskBuilder taskBuilder = new TaskBuilder(); 
    5459 
    5560    /** */ 
    56     private ITaskTreeNodeFactory taskTreeNodeFactory = new TaskTreeNodeFactory(); 
    57  
    58     /** 
    59      * @throws Exception 
    60      *  
     61    private ITaskFactory taskFactory = new TaskFactory(); 
     62 
     63    /** 
     64     * 
     65     */ 
     66    @Test 
     67    public void test_EventTask_01() throws Exception { 
     68        IEventType eventType = new DummyInteraction("interaction", 1); 
     69        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     70         
     71        IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget); 
     72         
     73        assertNotNull(task); 
     74        assertNotNull(task.getDescription()); 
     75        assertNotNull(task.getId()); 
     76        assertTrue(task.equals(task)); 
     77         
     78        assertEquals(eventType, task.getEventType()); 
     79        assertEquals(eventTarget, task.getEventTarget()); 
     80    } 
     81 
     82    /** 
     83     * 
     84     */ 
     85    @Test 
     86    public void test_EventTask_02() throws Exception { 
     87        IEventType eventType = new DummyInteraction("interaction", 1); 
     88        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     89         
     90        IEventTask task1 = taskFactory.createNewEventTask(eventType, eventTarget); 
     91        IEventTask task2 = taskFactory.createNewEventTask(eventType, eventTarget); 
     92         
     93        // the tasks will not be equal as they should have a different id 
     94        assertFalse(task1.equals(task2)); 
     95    } 
     96 
     97    /** 
     98     * 
     99     */ 
     100    @Test 
     101    public void test_EventTask_03() throws Exception { 
     102        IEventType eventType = new DummyInteraction("interaction", 1); 
     103        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     104         
     105        IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget); 
     106        ITaskInstance taskInstance1 = taskFactory.createNewTaskInstance(task); 
     107        ITaskInstance taskInstance2 = taskFactory.createNewTaskInstance(task); 
     108         
     109        assertFalse(taskInstance1.equals(taskInstance2)); 
     110    } 
     111 
     112    /** 
     113     * 
     114     */ 
     115    @Test 
     116    public void test_Sequence_01() throws Exception { 
     117        ISequence task = taskFactory.createNewSequence(); 
     118         
     119        assertNotNull(task); 
     120        assertNotNull(task.getDescription()); 
     121        assertNotNull(task.getId()); 
     122        assertNotNull(task.getChildren()); 
     123        assertEquals(0, task.getChildren().size()); 
     124        assertTrue(task.equals(task)); 
     125    } 
     126 
     127    /** 
     128     * 
     129     */ 
     130    @Test 
     131    public void test_Sequence_02() throws Exception { 
     132        IEventType eventType = new DummyInteraction("interaction", 1); 
     133        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     134         
     135        IEventTask child = taskFactory.createNewEventTask(eventType, eventTarget); 
     136 
     137        ISequence task = taskFactory.createNewSequence(); 
     138         
     139        taskBuilder.addChild(task, child); 
     140         
     141        assertNotNull(task.getChildren()); 
     142        assertEquals(1, task.getChildren().size()); 
     143        assertEquals(child, task.getChildren().get(0)); 
     144    } 
     145 
     146    /** 
     147     * 
     148     */ 
     149    @Test 
     150    public void test_Sequence_03() throws Exception { 
     151        IEventType eventType = new DummyInteraction("interaction", 1); 
     152        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     153         
     154        IEventTask child1 = taskFactory.createNewEventTask(eventType, eventTarget); 
     155        IEventTask child2 = taskFactory.createNewEventTask(eventType, eventTarget); 
     156        IEventTask child3 = taskFactory.createNewEventTask(eventType, eventTarget); 
     157        IEventTask child4 = taskFactory.createNewEventTask(eventType, eventTarget); 
     158        IEventTask child5 = taskFactory.createNewEventTask(eventType, eventTarget); 
     159 
     160        ISequence task = taskFactory.createNewSequence(); 
     161         
     162        taskBuilder.addChild(task, child1); 
     163        taskBuilder.addChild(task, child2); 
     164        taskBuilder.addChild(task, child3); 
     165        taskBuilder.addChild(task, child4); 
     166        taskBuilder.addChild(task, child5); 
     167         
     168        assertNotNull(task.getChildren()); 
     169        assertEquals(5, task.getChildren().size()); 
     170        assertEquals(child1, task.getChildren().get(0)); 
     171        assertEquals(child2, task.getChildren().get(1)); 
     172        assertEquals(child3, task.getChildren().get(2)); 
     173        assertEquals(child4, task.getChildren().get(3)); 
     174        assertEquals(child5, task.getChildren().get(4)); 
     175    } 
     176 
     177    /** 
     178     * 
     179     */ 
     180    @Test 
     181    public void test_Selection_01() throws Exception { 
     182        ISelection task = taskFactory.createNewSelection(); 
     183         
     184        assertNotNull(task); 
     185        assertNotNull(task.getDescription()); 
     186        assertNotNull(task.getId()); 
     187        assertNotNull(task.getChildren()); 
     188        assertEquals(0, task.getChildren().size()); 
     189        assertTrue(task.equals(task)); 
     190    } 
     191 
     192    /** 
     193     * 
     194     */ 
     195    @Test 
     196    public void test_Selection_02() throws Exception { 
     197        IEventType eventType = new DummyInteraction("interaction", 1); 
     198        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     199         
     200        IEventTask child = taskFactory.createNewEventTask(eventType, eventTarget); 
     201 
     202        ISelection task = taskFactory.createNewSelection(); 
     203         
     204        taskBuilder.addChild(task, child); 
     205         
     206        assertNotNull(task.getChildren()); 
     207        assertEquals(1, task.getChildren().size()); 
     208        assertEquals(child, task.getChildren().get(0)); 
     209    } 
     210 
     211    /** 
     212     * 
     213     */ 
     214    @Test 
     215    public void test_Selection_03() throws Exception { 
     216        IEventType eventType = new DummyInteraction("interaction", 1); 
     217        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     218         
     219        IEventTask child1 = taskFactory.createNewEventTask(eventType, eventTarget); 
     220        IEventTask child2 = taskFactory.createNewEventTask(eventType, eventTarget); 
     221        IEventTask child3 = taskFactory.createNewEventTask(eventType, eventTarget); 
     222        IEventTask child4 = taskFactory.createNewEventTask(eventType, eventTarget); 
     223        IEventTask child5 = taskFactory.createNewEventTask(eventType, eventTarget); 
     224 
     225        ISelection task = taskFactory.createNewSelection(); 
     226         
     227        taskBuilder.addChild(task, child1); 
     228        taskBuilder.addChild(task, child2); 
     229        taskBuilder.addChild(task, child3); 
     230        taskBuilder.addChild(task, child4); 
     231        taskBuilder.addChild(task, child5); 
     232         
     233        assertNotNull(task.getChildren()); 
     234        assertEquals(5, task.getChildren().size()); 
     235        assertEquals(child1, task.getChildren().get(0)); 
     236        assertEquals(child2, task.getChildren().get(1)); 
     237        assertEquals(child3, task.getChildren().get(2)); 
     238        assertEquals(child4, task.getChildren().get(3)); 
     239        assertEquals(child5, task.getChildren().get(4)); 
     240    } 
     241 
     242    /** 
     243     * 
     244     */ 
     245    @Test 
     246    public void test_Iteration_01() throws Exception { 
     247        IIteration task = taskFactory.createNewIteration(); 
     248         
     249        assertNotNull(task); 
     250        assertNotNull(task.getDescription()); 
     251        assertNotNull(task.getId()); 
     252        assertNull(task.getMarkedTask()); 
     253        assertTrue(task.equals(task)); 
     254    } 
     255 
     256    /** 
     257     * 
     258     */ 
     259    @Test 
     260    public void test_Iteration_02() throws Exception { 
     261        IEventType eventType = new DummyInteraction("interaction", 1); 
     262        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     263         
     264        IEventTask child = taskFactory.createNewEventTask(eventType, eventTarget); 
     265 
     266        IIteration task = taskFactory.createNewIteration(); 
     267         
     268        taskBuilder.setMarkedTask(task, child); 
     269         
     270        assertEquals(child, task.getMarkedTask()); 
     271    } 
     272 
     273    /** 
     274     * 
     275     */ 
     276    @Test 
     277    public void test_Iteration_03() throws Exception { 
     278        IEventType eventType = new DummyInteraction("interaction", 1); 
     279        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     280         
     281        IEventTask child1 = taskFactory.createNewEventTask(eventType, eventTarget); 
     282        IEventTask child2 = taskFactory.createNewEventTask(eventType, eventTarget); 
     283 
     284        IIteration task = taskFactory.createNewIteration(); 
     285         
     286        taskBuilder.setMarkedTask(task, child1); 
     287        taskBuilder.setMarkedTask(task, child2); 
     288         
     289        assertEquals(child2, task.getMarkedTask()); 
     290    } 
     291 
     292    /** 
     293     * 
     294     */ 
     295    @Test 
     296    public void test_Optional_01() throws Exception { 
     297        IOptional task = taskFactory.createNewOptional(); 
     298         
     299        assertNotNull(task); 
     300        assertNotNull(task.getDescription()); 
     301        assertNotNull(task.getId()); 
     302        assertNull(task.getMarkedTask()); 
     303        assertTrue(task.equals(task)); 
     304    } 
     305 
     306    /** 
     307     * 
     308     */ 
     309    @Test 
     310    public void test_Optional_02() throws Exception { 
     311        IEventType eventType = new DummyInteraction("interaction", 1); 
     312        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     313         
     314        IEventTask child = taskFactory.createNewEventTask(eventType, eventTarget); 
     315 
     316        IOptional task = taskFactory.createNewOptional(); 
     317         
     318        taskBuilder.setMarkedTask(task, child); 
     319         
     320        assertEquals(child, task.getMarkedTask()); 
     321    } 
     322 
     323    /** 
     324     * 
     325     */ 
     326    @Test 
     327    public void test_Optional_03() throws Exception { 
     328        IEventType eventType = new DummyInteraction("interaction", 1); 
     329        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     330         
     331        IEventTask child1 = taskFactory.createNewEventTask(eventType, eventTarget); 
     332        IEventTask child2 = taskFactory.createNewEventTask(eventType, eventTarget); 
     333 
     334        IOptional task = taskFactory.createNewOptional(); 
     335         
     336        taskBuilder.setMarkedTask(task, child1); 
     337        taskBuilder.setMarkedTask(task, child2); 
     338         
     339        assertEquals(child2, task.getMarkedTask()); 
     340    } 
     341 
     342    /** 
     343     * 
     344     */ 
     345    @Test 
     346    public void test_EventTaskInstance_01() throws Exception { 
     347        IEventType eventType = new DummyInteraction("interaction", 1); 
     348        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     349         
     350        IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget); 
     351         
     352        ITaskInstance taskInstance = taskFactory.createNewTaskInstance(task); 
     353         
     354        assertNotNull(taskInstance); 
     355        assertEquals(task, taskInstance.getTask()); 
     356        assertTrue(taskInstance.equals(taskInstance)); 
     357        assertFalse(taskInstance.equals(task)); 
     358        assertNotNull(taskInstance.getChildren()); 
     359        assertEquals(0, taskInstance.getChildren().size()); 
     360    } 
     361 
     362    /** 
     363     * 
     364     */ 
     365    @Test 
     366    public void test_EventTaskInstance_02() throws Exception { 
     367        IEventType eventType = new DummyInteraction("interaction", 1); 
     368        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     369         
     370        IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget); 
     371         
     372        ITaskInstance taskInstance1 = taskFactory.createNewTaskInstance(task); 
     373        ITaskInstance taskInstance2 = taskFactory.createNewTaskInstance(task); 
     374         
     375        assertFalse(taskInstance1.equals(taskInstance2)); 
     376    } 
     377 
     378    /** 
     379     * 
     380     */ 
     381    @Test(expected=IllegalArgumentException.class) 
     382    public void test_EventTaskInstance_03() throws Exception { 
     383        IEventType eventType = new DummyInteraction("interaction", 1); 
     384        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     385         
     386        IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget); 
     387         
     388        ITaskInstance taskInstance1 = taskFactory.createNewTaskInstance(task); 
     389        ITaskInstance taskInstance2 = taskFactory.createNewTaskInstance(task); 
     390         
     391        taskBuilder.addChild(taskInstance1, taskInstance2); 
     392    } 
     393 
     394    /** 
     395     * 
     396     */ 
     397    @Test(expected=IllegalArgumentException.class) 
     398    public void test_SequenceInstance_01() throws Exception { 
     399        IEventType eventType = new DummyInteraction("interaction", 1); 
     400        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     401         
     402        IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget); 
     403         
     404        ISequence sequence = taskFactory.createNewSequence(); 
     405         
     406        ITaskInstance taskInstance = taskFactory.createNewTaskInstance(task); 
     407        ITaskInstance sequenceInstance = taskFactory.createNewTaskInstance(sequence); 
     408         
     409        taskBuilder.addChild(sequenceInstance, taskInstance); 
     410    } 
     411 
     412    /** 
     413     * 
     414     */ 
     415    @Test 
     416    public void test_SequenceInstance_02() throws Exception { 
     417        IEventType eventType = new DummyInteraction("interaction", 1); 
     418        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     419         
     420        IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget); 
     421         
     422        ISequence sequence = taskFactory.createNewSequence(); 
     423        taskBuilder.addChild(sequence, task); 
     424         
     425        ITaskInstance taskInstance = taskFactory.createNewTaskInstance(task); 
     426        ITaskInstance sequenceInstance = taskFactory.createNewTaskInstance(sequence); 
     427         
     428        taskBuilder.addChild(sequenceInstance, taskInstance); 
     429         
     430        assertNotNull(sequenceInstance.getChildren()); 
     431        assertEquals(1, sequenceInstance.getChildren().size()); 
     432        assertEquals(taskInstance, sequenceInstance.getChildren().get(0)); 
     433    } 
     434 
     435    /** 
     436     * 
     437     */ 
     438    @Test 
     439    public void test_SequenceInstance_03() throws Exception { 
     440        IEventType eventType = new DummyInteraction("interaction", 1); 
     441        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     442         
     443        IEventTask task1 = taskFactory.createNewEventTask(eventType, eventTarget); 
     444        IEventTask task2 = taskFactory.createNewEventTask(eventType, eventTarget); 
     445        IEventTask task3 = taskFactory.createNewEventTask(eventType, eventTarget); 
     446        IEventTask task4 = taskFactory.createNewEventTask(eventType, eventTarget); 
     447        IEventTask task5 = taskFactory.createNewEventTask(eventType, eventTarget); 
     448         
     449        ISequence sequence = taskFactory.createNewSequence(); 
     450        taskBuilder.addChild(sequence, task1); 
     451        taskBuilder.addChild(sequence, task2); 
     452        taskBuilder.addChild(sequence, task3); 
     453        taskBuilder.addChild(sequence, task4); 
     454        taskBuilder.addChild(sequence, task5); 
     455         
     456        ITaskInstance taskInstance1 = taskFactory.createNewTaskInstance(task1); 
     457        ITaskInstance taskInstance2 = taskFactory.createNewTaskInstance(task2); 
     458        ITaskInstance taskInstance3 = taskFactory.createNewTaskInstance(task3); 
     459        ITaskInstance taskInstance4 = taskFactory.createNewTaskInstance(task4); 
     460        ITaskInstance taskInstance5 = taskFactory.createNewTaskInstance(task5); 
     461        ITaskInstance sequenceInstance = taskFactory.createNewTaskInstance(sequence); 
     462         
     463        taskBuilder.addChild(sequenceInstance, taskInstance1); 
     464        taskBuilder.addChild(sequenceInstance, taskInstance2); 
     465        taskBuilder.addChild(sequenceInstance, taskInstance3); 
     466        taskBuilder.addChild(sequenceInstance, taskInstance4); 
     467        taskBuilder.addChild(sequenceInstance, taskInstance5); 
     468         
     469        assertNotNull(sequenceInstance.getChildren()); 
     470        assertEquals(5, sequenceInstance.getChildren().size()); 
     471        assertEquals(taskInstance1, sequenceInstance.getChildren().get(0)); 
     472        assertEquals(taskInstance2, sequenceInstance.getChildren().get(1)); 
     473        assertEquals(taskInstance3, sequenceInstance.getChildren().get(2)); 
     474        assertEquals(taskInstance4, sequenceInstance.getChildren().get(3)); 
     475        assertEquals(taskInstance5, sequenceInstance.getChildren().get(4)); 
     476    } 
     477 
     478    /** 
     479     * 
     480     */ 
     481    @Test(expected=IllegalArgumentException.class) 
     482    public void test_SelectionInstance_01() throws Exception { 
     483        IEventType eventType = new DummyInteraction("interaction", 1); 
     484        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     485         
     486        IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget); 
     487         
     488        ISelection selection = taskFactory.createNewSelection(); 
     489         
     490        ITaskInstance taskInstance = taskFactory.createNewTaskInstance(task); 
     491        ITaskInstance selectionInstance = taskFactory.createNewTaskInstance(selection); 
     492         
     493        taskBuilder.addChild(selectionInstance, taskInstance); 
     494    } 
     495 
     496    /** 
     497     * 
     498     */ 
     499    @Test 
     500    public void test_SelectionInstance_02() throws Exception { 
     501        IEventType eventType = new DummyInteraction("interaction", 1); 
     502        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     503         
     504        IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget); 
     505         
     506        ISelection selection = taskFactory.createNewSelection(); 
     507        taskBuilder.addChild(selection, task); 
     508         
     509        ITaskInstance taskInstance = taskFactory.createNewTaskInstance(task); 
     510        ITaskInstance selectionInstance = taskFactory.createNewTaskInstance(selection); 
     511         
     512        taskBuilder.addChild(selectionInstance, taskInstance); 
     513         
     514        assertNotNull(selectionInstance.getChildren()); 
     515        assertEquals(1, selectionInstance.getChildren().size()); 
     516        assertEquals(taskInstance, selectionInstance.getChildren().get(0)); 
     517    } 
     518 
     519    /** 
     520     * 
     521     */ 
     522    @Test(expected=IllegalArgumentException.class) 
     523    public void test_SelectionInstance_03() throws Exception { 
     524        IEventType eventType = new DummyInteraction("interaction", 1); 
     525        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     526         
     527        IEventTask task1 = taskFactory.createNewEventTask(eventType, eventTarget); 
     528        IEventTask task2 = taskFactory.createNewEventTask(eventType, eventTarget); 
     529        IEventTask task3 = taskFactory.createNewEventTask(eventType, eventTarget); 
     530        IEventTask task4 = taskFactory.createNewEventTask(eventType, eventTarget); 
     531        IEventTask task5 = taskFactory.createNewEventTask(eventType, eventTarget); 
     532         
     533        ISelection selection = taskFactory.createNewSelection(); 
     534        taskBuilder.addChild(selection, task1); 
     535        taskBuilder.addChild(selection, task2); 
     536        taskBuilder.addChild(selection, task3); 
     537        taskBuilder.addChild(selection, task4); 
     538        taskBuilder.addChild(selection, task5); 
     539         
     540        ITaskInstance taskInstance1 = taskFactory.createNewTaskInstance(task1); 
     541        ITaskInstance taskInstance2 = taskFactory.createNewTaskInstance(task2); 
     542        ITaskInstance selectionInstance = taskFactory.createNewTaskInstance(selection); 
     543         
     544        taskBuilder.addChild(selectionInstance, taskInstance1); 
     545        taskBuilder.addChild(selectionInstance, taskInstance2); 
     546    } 
     547 
     548    /** 
     549     * 
     550     */ 
     551    @Test(expected=IllegalArgumentException.class) 
     552    public void test_IterationInstance_01() throws Exception { 
     553        IEventType eventType = new DummyInteraction("interaction", 1); 
     554        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     555         
     556        IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget); 
     557         
     558        IIteration iteration = taskFactory.createNewIteration(); 
     559         
     560        ITaskInstance taskInstance = taskFactory.createNewTaskInstance(task); 
     561        ITaskInstance iterationInstance = taskFactory.createNewTaskInstance(iteration); 
     562         
     563        taskBuilder.addChild(iterationInstance, taskInstance); 
     564    } 
     565 
     566    /** 
     567     * 
     568     */ 
     569    @Test 
     570    public void test_IterationInstance_02() throws Exception { 
     571        IEventType eventType = new DummyInteraction("interaction", 1); 
     572        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     573         
     574        IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget); 
     575         
     576        IIteration iteration = taskFactory.createNewIteration(); 
     577        taskBuilder.setMarkedTask(iteration, task); 
     578         
     579        ITaskInstance taskInstance = taskFactory.createNewTaskInstance(task); 
     580        ITaskInstance iterationInstance = taskFactory.createNewTaskInstance(iteration); 
     581         
     582        taskBuilder.addChild(iterationInstance, taskInstance); 
     583         
     584        assertNotNull(iterationInstance.getChildren()); 
     585        assertEquals(1, iterationInstance.getChildren().size()); 
     586        assertEquals(taskInstance, iterationInstance.getChildren().get(0)); 
     587    } 
     588 
     589    /** 
     590     * 
     591     */ 
     592    @Test(expected=IllegalArgumentException.class) 
     593    public void test_IterationInstance_03() throws Exception { 
     594        IEventType eventType = new DummyInteraction("interaction", 1); 
     595        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     596         
     597        IEventTask task1 = taskFactory.createNewEventTask(eventType, eventTarget); 
     598        IEventTask task2 = taskFactory.createNewEventTask(eventType, eventTarget); 
     599         
     600        IIteration iteration = taskFactory.createNewIteration(); 
     601        taskBuilder.setMarkedTask(iteration, task1); 
     602        taskBuilder.setMarkedTask(iteration, task2); 
     603         
     604        ITaskInstance taskInstance1 = taskFactory.createNewTaskInstance(task1); 
     605        ITaskInstance iterationInstance = taskFactory.createNewTaskInstance(iteration); 
     606         
     607        taskBuilder.addChild(iterationInstance, taskInstance1); 
     608    } 
     609 
     610    /** 
     611     * 
     612     */ 
     613    @Test 
     614    public void test_IterationInstance_04() throws Exception { 
     615        IEventType eventType = new DummyInteraction("interaction", 1); 
     616        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     617         
     618        IEventTask task1 = taskFactory.createNewEventTask(eventType, eventTarget); 
     619        IEventTask task2 = taskFactory.createNewEventTask(eventType, eventTarget); 
     620         
     621        IIteration iteration = taskFactory.createNewIteration(); 
     622        taskBuilder.setMarkedTask(iteration, task1); 
     623        taskBuilder.setMarkedTask(iteration, task2); 
     624         
     625        ITaskInstance taskInstance2 = taskFactory.createNewTaskInstance(task2); 
     626        ITaskInstance iterationInstance = taskFactory.createNewTaskInstance(iteration); 
     627         
     628        taskBuilder.addChild(iterationInstance, taskInstance2); 
     629         
     630        assertNotNull(iterationInstance.getChildren()); 
     631        assertEquals(1, iterationInstance.getChildren().size()); 
     632        assertEquals(taskInstance2, iterationInstance.getChildren().get(0)); 
     633    } 
     634 
     635    /** 
     636     * 
     637     */ 
     638    @Test(expected=IllegalArgumentException.class) 
     639    public void test_OptionalInstance_01() throws Exception { 
     640        IEventType eventType = new DummyInteraction("interaction", 1); 
     641        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     642         
     643        IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget); 
     644         
     645        IOptional optional = taskFactory.createNewOptional(); 
     646         
     647        ITaskInstance taskInstance = taskFactory.createNewTaskInstance(task); 
     648        ITaskInstance optionalInstance = taskFactory.createNewTaskInstance(optional); 
     649         
     650        taskBuilder.addChild(optionalInstance, taskInstance); 
     651    } 
     652 
     653    /** 
     654     * 
     655     */ 
     656    @Test 
     657    public void test_OptionalInstance_02() throws Exception { 
     658        IEventType eventType = new DummyInteraction("interaction", 1); 
     659        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     660         
     661        IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget); 
     662         
     663        IOptional optional = taskFactory.createNewOptional(); 
     664        taskBuilder.setMarkedTask(optional, task); 
     665         
     666        ITaskInstance taskInstance = taskFactory.createNewTaskInstance(task); 
     667        ITaskInstance optionalInstance = taskFactory.createNewTaskInstance(optional); 
     668         
     669        taskBuilder.addChild(optionalInstance, taskInstance); 
     670         
     671        assertNotNull(optionalInstance.getChildren()); 
     672        assertEquals(1, optionalInstance.getChildren().size()); 
     673        assertEquals(taskInstance, optionalInstance.getChildren().get(0)); 
     674    } 
     675 
     676    /** 
     677     * 
     678     */ 
     679    @Test(expected=IllegalArgumentException.class) 
     680    public void test_OptionalInstance_03() throws Exception { 
     681        IEventType eventType = new DummyInteraction("interaction", 1); 
     682        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     683         
     684        IEventTask task1 = taskFactory.createNewEventTask(eventType, eventTarget); 
     685        IEventTask task2 = taskFactory.createNewEventTask(eventType, eventTarget); 
     686         
     687        IOptional optional = taskFactory.createNewOptional(); 
     688        taskBuilder.setMarkedTask(optional, task1); 
     689        taskBuilder.setMarkedTask(optional, task2); 
     690         
     691        ITaskInstance taskInstance1 = taskFactory.createNewTaskInstance(task1); 
     692        ITaskInstance optionalInstance = taskFactory.createNewTaskInstance(optional); 
     693         
     694        taskBuilder.addChild(optionalInstance, taskInstance1); 
     695    } 
     696 
     697    /** 
     698     * 
     699     */ 
     700    @Test 
     701    public void test_OptionalInstance_04() throws Exception { 
     702        IEventType eventType = new DummyInteraction("interaction", 1); 
     703        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     704         
     705        IEventTask task1 = taskFactory.createNewEventTask(eventType, eventTarget); 
     706        IEventTask task2 = taskFactory.createNewEventTask(eventType, eventTarget); 
     707         
     708        IOptional optional = taskFactory.createNewOptional(); 
     709        taskBuilder.setMarkedTask(optional, task1); 
     710        taskBuilder.setMarkedTask(optional, task2); 
     711         
     712        ITaskInstance taskInstance2 = taskFactory.createNewTaskInstance(task2); 
     713        ITaskInstance optionalInstance = taskFactory.createNewTaskInstance(optional); 
     714         
     715        taskBuilder.addChild(optionalInstance, taskInstance2); 
     716         
     717        assertNotNull(optionalInstance.getChildren()); 
     718        assertEquals(1, optionalInstance.getChildren().size()); 
     719        assertEquals(taskInstance2, optionalInstance.getChildren().get(0)); 
     720    } 
     721 
     722    /** 
     723     * 
     724     */ 
     725    @Test 
     726    public void test_UserSession_01() throws Exception { 
     727        IUserSession userSession = taskFactory.createUserSession(); 
     728         
     729        assertNotNull(userSession); 
     730        assertNotNull(userSession.getExecutedTasks()); 
     731        assertEquals(0, userSession.getExecutedTasks().size()); 
     732    } 
     733 
     734    /** 
     735     * 
     736     */ 
     737    @Test 
     738    public void test_UserSession_02() throws Exception { 
     739        IEventType eventType = new DummyInteraction("interaction", 1); 
     740        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     741         
     742        IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget); 
     743         
     744        IUserSession userSession = taskFactory.createUserSession(); 
     745         
     746        ITaskInstance taskInstance = taskFactory.createNewTaskInstance(task); 
     747         
     748        taskBuilder.addExecutedTask(userSession, taskInstance); 
     749         
     750        assertNotNull(userSession.getExecutedTasks()); 
     751        assertEquals(1, userSession.getExecutedTasks().size()); 
     752        assertEquals(taskInstance, userSession.getExecutedTasks().get(0)); 
     753    } 
     754 
     755    /** 
     756     * 
     757     */ 
     758    @Test 
     759    public void test_UserSession_03() throws Exception { 
     760        IEventType eventType = new DummyInteraction("interaction", 1); 
     761        IEventTarget eventTarget = new DummyGUIElement("elem"); 
     762         
     763        IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget); 
     764        ISequence sequence = taskFactory.createNewSequence(); 
     765        ISelection selection = taskFactory.createNewSelection(); 
     766        IIteration iteration = taskFactory.createNewIteration(); 
     767        IOptional optional = taskFactory.createNewOptional(); 
     768         
     769        taskBuilder.addChild(sequence, task); 
     770        taskBuilder.addChild(selection, task); 
     771        taskBuilder.setMarkedTask(iteration, task); 
     772        taskBuilder.setMarkedTask(optional, task); 
     773         
     774        ITaskInstance taskInstance = taskFactory.createNewTaskInstance(task); 
     775        ITaskInstance sequenceInstance = taskFactory.createNewTaskInstance(sequence); 
     776        ITaskInstance selectionInstance = taskFactory.createNewTaskInstance(selection); 
     777        ITaskInstance iterationInstance = taskFactory.createNewTaskInstance(iteration); 
     778        ITaskInstance optionalInstance = taskFactory.createNewTaskInstance(optional); 
     779         
     780        taskBuilder.addChild(sequenceInstance, taskFactory.createNewTaskInstance(task)); 
     781        taskBuilder.addChild(selectionInstance, taskFactory.createNewTaskInstance(task)); 
     782        taskBuilder.addChild(iterationInstance, taskFactory.createNewTaskInstance(task)); 
     783        taskBuilder.addChild(optionalInstance, taskFactory.createNewTaskInstance(task)); 
     784         
     785        IUserSession userSession = taskFactory.createUserSession(); 
     786         
     787        taskBuilder.addExecutedTask(userSession, taskInstance); 
     788        taskBuilder.addExecutedTask(userSession, sequenceInstance); 
     789        taskBuilder.addExecutedTask(userSession, selectionInstance); 
     790        taskBuilder.addExecutedTask(userSession, iterationInstance); 
     791        taskBuilder.addExecutedTask(userSession, optionalInstance); 
     792         
     793        assertNotNull(userSession.getExecutedTasks()); 
     794        assertEquals(5, userSession.getExecutedTasks().size()); 
     795        assertEquals(taskInstance, userSession.getExecutedTasks().get(0)); 
     796        assertEquals(sequenceInstance, userSession.getExecutedTasks().get(1)); 
     797        assertEquals(selectionInstance, userSession.getExecutedTasks().get(2)); 
     798        assertEquals(iterationInstance, userSession.getExecutedTasks().get(3)); 
     799        assertEquals(optionalInstance, userSession.getExecutedTasks().get(4)); 
     800    } 
     801     
     802    /** 
     803     * 
    61804     */ 
    62805    @Test 
     
    67810 
    68811        for (int i = 0; i < noOfTrees; i++) { 
    69             System.err.println("iteration " + (i + 1) + ":"); 
    70             System.err.println("  creating tree"); 
    71             Map<ITaskTreeNode, ITaskTreeNodeInfo> treeInfos = 
    72                 new HashMap<ITaskTreeNode, ITaskTreeNodeInfo>(); 
    73             ITaskTreeNode rootNode = createTree(noOfMaxChildren, maxDepth, treeInfos); 
    74             System.err.println("  creating task tree"); 
    75             ITaskTree taskTree = taskTreeNodeFactory.createTaskTree(rootNode); 
     812            System.err.println("\niteration " + (i + 1) + ":"); 
     813            System.err.println("  creating tasks"); 
     814            Map<ITask, ITaskInfo> expectedTaskInfos = new HashMap<ITask, ITaskInfo>(); 
     815            ITask task = createTaskTree(noOfMaxChildren, maxDepth, expectedTaskInfos); 
     816            if (!(task instanceof ISequence)) { 
     817                ISequence sequence = taskFactory.createNewSequence(); 
     818                taskBuilder.addChild(sequence, task); 
     819                task = sequence; 
     820            } 
     821            else { 
     822                expectedTaskInfos.remove(task); 
     823            } 
     824             
     825            ITaskInstance taskInstance = instantiateTask(task, noOfMaxChildren); 
     826             
     827            System.err.println("  creating user session"); 
     828             
     829            IUserSession session = taskFactory.createUserSession(); 
     830             
     831            for (ITaskInstance child : taskInstance.getChildren()) { 
     832                taskBuilder.addExecutedTask(session, child); 
     833            } 
     834             
     835            List<IUserSession> sessions = new LinkedList<IUserSession>(); 
     836            sessions.add(session); 
     837             
     838            ITaskModel taskTree = taskFactory.createTaskModel(sessions); 
    76839 
    77840            System.err.println("  validating task tree"); 
    78             assertEquals(rootNode, taskTree.getRoot()); 
    79             assertMapsEqual(treeInfos, taskTree.getTaskMap()); 
    80         } 
    81     } 
    82  
    83     /** 
    84      * TODO: comment 
    85      *  
    86      * @param treeInfos 
    87      * @param taskMap 
    88      */ 
    89     private void assertMapsEqual(Map<ITaskTreeNode, ITaskTreeNodeInfo> map1, 
    90                                  Map<ITaskTreeNode, ITaskTreeNodeInfo> map2) 
     841            Map<ITask, ITaskInfo> actualTaskInfos = new HashMap<ITask, ITaskInfo>(); 
     842             
     843            for (ITask currentTask : taskTree.getTasks()) { 
     844                actualTaskInfos.put(currentTask, taskTree.getTaskInfo(currentTask)); 
     845            } 
     846             
     847            assertMapsEqual(expectedTaskInfos, actualTaskInfos); 
     848        } 
     849    } 
     850 
     851    /** 
     852     * 
     853     */ 
     854    private void assertMapsEqual(Map<ITask, ITaskInfo> map1, 
     855                                 Map<ITask, ITaskInfo> map2) 
    91856    { 
    92857        try { 
     
    98863            assertEquals(map1.size(), map2.size()); 
    99864 
    100             for (Map.Entry<ITaskTreeNode, ITaskTreeNodeInfo> entry : map1.entrySet()) { 
    101                 ITaskTreeNodeInfo value2 = map2.get(entry.getKey()); 
     865            for (Map.Entry<ITask, ITaskInfo> entry : map1.entrySet()) { 
     866                ITaskInfo value2 = map2.get(entry.getKey()); 
    102867                assertNotNull(value2); 
    103868                assertEquals(entry.getValue().getTask(), value2.getTask()); 
     
    114879 
    115880    /** 
    116      * TODO: comment 
    117      *  
    118      * @param map2 
    119      */ 
    120     private void dumpMap(Map<ITaskTreeNode, ITaskTreeNodeInfo> map) { 
     881     * 
     882     */ 
     883    private void dumpMap(Map<ITask, ITaskInfo> map) { 
    121884        System.err.println(); 
    122885 
     
    126889        else { 
    127890            System.err.println("map:"); 
    128             for (Map.Entry<ITaskTreeNode, ITaskTreeNodeInfo> entry : map.entrySet()) { 
     891            for (Map.Entry<ITask, ITaskInfo> entry : map.entrySet()) { 
    129892                System.err.print("  "); 
    130893                System.err.print(entry.getKey()); 
    131                 for (int i = entry.getKey().toString().length(); i < 49; i++) { 
     894                for (int i = entry.getKey().toString().length(); i < 60; i++) { 
    132895                    System.err.print(" "); 
    133896                } 
     
    141904 
    142905    /** 
    143      * TODO: comment 
    144      *  
    145      * @param noOfMaxChildren 
    146      * @param maxDepth 
    147      * @param treeInfos 
    148      * @return 
    149      */ 
    150     private ITaskTreeNode createTree(int                                   maxNoOfChildren, 
    151                                      int                                   maxDepth, 
    152                                      Map<ITaskTreeNode, ITaskTreeNodeInfo> treeInfos) 
     906     * 
     907     */ 
     908    private ITask createTaskTree(int                   maxNoOfChildren, 
     909                                 int                   maxDepth, 
     910                                 Map<ITask, ITaskInfo> taskInfos) 
    153911        throws Exception 
    154912    { 
    155         /* 
    156          * for (int i = 0; i < (MAX_TREE_DEPTH + 1 - maxDepth); i++) { System.err.print("  "); } 
    157          */ 
    158  
    159         ITaskTreeNode tree; 
     913 
     914        ITask task; 
    160915 
    161916        // integrating the maximum depth here assures, that either something between 0 and 8 will 
    162917        // be the type, or if the max depth decreases near 0 only event tasks will be created 
    163918        // to finish the tree creation 
    164         int type = (int) (Math.random() * (Math.min(8, maxDepth))); 
     919        int type = randomize(Math.min(10, maxDepth)); 
    165920 
    166921        switch (type) 
     
    168923            case 0: { 
    169924                // System.err.print("creating new event task "); 
    170                 tree = createNewEventTask(treeInfos); 
     925                task = createNewEventTask(taskInfos); 
    171926                break; 
    172927            } 
    173928            case 1: { 
    174929                // System.err.print("reusing event task "); 
    175                 tree = reuseEventTask(treeInfos); 
     930                task = reuseEventTask(taskInfos); 
    176931                break; 
    177932            } 
    178933            case 2: { 
    179934                // System.err.println("creating new sequence {"); 
    180                 tree = createNewSequence(maxNoOfChildren, maxDepth, treeInfos); 
     935                task = createNewSequence(maxNoOfChildren, maxDepth, taskInfos); 
    181936                break; 
    182937            } 
    183938            case 3: { 
    184939                // System.err.println("reusing sequence {"); 
    185                 tree = reuseSequence(maxNoOfChildren, maxDepth, treeInfos); 
     940                task = reuseSequence(maxNoOfChildren, maxDepth, taskInfos); 
    186941                break; 
    187942            } 
    188943            case 4: { 
    189944                // System.err.println("creating new selection {"); 
    190                 tree = createNewSelection(maxNoOfChildren, maxDepth, treeInfos); 
     945                task = createNewSelection(maxNoOfChildren, maxDepth, taskInfos); 
    191946                break; 
    192947            } 
    193948            case 5: { 
    194949                // System.err.println("reusing selection {"); 
    195                 tree = reuseSelection(maxNoOfChildren, maxDepth, treeInfos); 
     950                task = reuseSelection(maxNoOfChildren, maxDepth, taskInfos); 
    196951                break; 
    197952            } 
    198953            case 6: { 
    199954                // System.err.println("creating new iteration {"); 
    200                 tree = createNewIteration(maxNoOfChildren, maxDepth, treeInfos); 
     955                task = createNewIteration(maxNoOfChildren, maxDepth, taskInfos); 
    201956                break; 
    202957            } 
    203958            case 7: { 
    204959                // System.err.println("reusing iteration {"); 
    205                 tree = reuseIteration(maxNoOfChildren, maxDepth, treeInfos); 
     960                task = reuseIteration(maxNoOfChildren, maxDepth, taskInfos); 
     961                break; 
     962            } 
     963            case 8: { 
     964                // System.err.println("creating new optional {"); 
     965                task = createNewOptional(maxNoOfChildren, maxDepth, taskInfos); 
     966                break; 
     967            } 
     968            case 9: { 
     969                // System.err.println("reusing optional {"); 
     970                task = reuseOptional(maxNoOfChildren, maxDepth, taskInfos); 
    206971                break; 
    207972            } 
    208973            default: { 
    209974                // System.err.print("creating new event task per default "); 
    210                 tree = createNewEventTask(treeInfos); 
    211             } 
    212         } 
    213  
    214         /* 
    215          * if (!(tree instanceof InteractionTask)) { for (int i = 0; i < (MAX_TREE_DEPTH + 1 - 
    216          * maxDepth); i++) { System.err.print("  "); } 
    217          *  
    218          * System.err.print("} "); } 
    219          *  
    220          * System.err.println(tree); 
    221          */ 
    222  
    223         return tree; 
    224     } 
    225  
    226     /** 
    227      * TODO: comment 
    228      *  
    229      * @param treeInfos 
    230      * @return 
    231      */ 
    232     private IEventTask createNewEventTask(Map<ITaskTreeNode, ITaskTreeNodeInfo> treeInfos) 
     975                task = createNewEventTask(taskInfos); 
     976            } 
     977        } 
     978 
     979        return task; 
     980    } 
     981 
     982    /** 
     983     * 
     984     */ 
     985    private ITask createNewEventTask(Map<ITask, ITaskInfo> taskInfos) 
    233986        throws Exception 
    234987    { 
    235988        Thread.sleep(2); 
    236989        long id = System.currentTimeMillis(); 
    237         IEventTask task = 
    238             taskTreeNodeFactory.createNewEventTask(new DummyInteraction("interaction" + id, 1), 
    239                                                    new DummyGUIElement("elem" + id)); 
    240  
    241         treeInfos.put(task, new NodeInfo(task)); 
     990        IEventTask task = taskFactory.createNewEventTask 
     991            (new DummyInteraction("interaction" + id, 1), new DummyGUIElement("elem" + id)); 
     992 
     993        taskInfos.put(task, new TaskInfo(task)); 
    242994 
    243995        return task; 
     
    245997 
    246998    /** 
    247      * TODO: comment 
    248      *  
    249      * @param treeInfos 
    250      * @return 
    251      */ 
    252     private IEventTask reuseEventTask(Map<ITaskTreeNode, ITaskTreeNodeInfo> treeInfos) 
     999     * 
     1000     */ 
     1001    private ITask reuseEventTask(Map<ITask, ITaskInfo> taskInfos) 
    2531002        throws Exception 
    2541003    { 
    255         int noOfEventTasks = 0; 
    256  
    257         for (Map.Entry<ITaskTreeNode, ITaskTreeNodeInfo> entry : treeInfos.entrySet()) { 
    258             if (entry.getKey() instanceof IEventTask) { 
    259                 noOfEventTasks++; 
    260             } 
    261         } 
    262  
    263         if (noOfEventTasks > 0) { 
    264             noOfEventTasks = (int) (Math.random() * noOfEventTasks); 
    265  
    266             for (Map.Entry<ITaskTreeNode, ITaskTreeNodeInfo> entry : treeInfos.entrySet()) { 
    267                 if (entry.getKey() instanceof IEventTask) { 
    268                     if (--noOfEventTasks <= 0) { 
    269                         return (IEventTask) entry.getKey(); 
     1004        ITask eventTask = reuseTask(taskInfos, IEventTask.class); 
     1005         
     1006        if (eventTask == null) { 
     1007            eventTask = createNewEventTask(taskInfos); 
     1008        } 
     1009 
     1010        return eventTask; 
     1011    } 
     1012 
     1013    /** 
     1014     * 
     1015     */ 
     1016    private ITask createNewSequence(int                   maxNoOfChildren, 
     1017                                    int                   maxDepth, 
     1018                                    Map<ITask, ITaskInfo> taskInfos) 
     1019        throws Exception 
     1020    { 
     1021        ISequence sequence = taskFactory.createNewSequence(); 
     1022 
     1023        // ensure at the minimum 2 children 
     1024        int noOfChildren = randomize(2, maxNoOfChildren); 
     1025 
     1026        for (int i = 0; i < noOfChildren; i++) { 
     1027            ITask child = createTaskTree(maxNoOfChildren, maxDepth - 1, taskInfos); 
     1028            taskBuilder.addChild(sequence, child); 
     1029        } 
     1030 
     1031        taskInfos.put(sequence, new TaskInfo(sequence)); 
     1032        return sequence; 
     1033    } 
     1034 
     1035    /** 
     1036     * 
     1037     */ 
     1038    private ITask reuseSequence(int                   maxNoOfChildren, 
     1039                                int                   maxDepth, 
     1040                                Map<ITask, ITaskInfo> taskInfos) 
     1041        throws Exception 
     1042    { 
     1043        ITask sequence = reuseTask(taskInfos, ISequence.class); 
     1044         
     1045        if (sequence == null) { 
     1046            sequence = createNewSequence(maxNoOfChildren, maxDepth, taskInfos); 
     1047        } 
     1048 
     1049        return sequence; 
     1050    } 
     1051 
     1052    /** 
     1053     * 
     1054     */ 
     1055    private ITask createNewSelection(int                   maxNoOfChildren, 
     1056                                     int                   maxDepth, 
     1057                                     Map<ITask, ITaskInfo> taskInfos) 
     1058        throws Exception 
     1059    { 
     1060        ISelection selection = taskFactory.createNewSelection(); 
     1061 
     1062        // ensure at the minimum 1 child 
     1063        int noOfChildren = randomize(1, maxNoOfChildren); 
     1064         
     1065        for (int i = 0; i < noOfChildren; i++) { 
     1066            ITask child = createTaskTree(maxNoOfChildren, maxDepth - 1, taskInfos); 
     1067            taskBuilder.addChild(selection, child); 
     1068        } 
     1069 
     1070        taskInfos.put(selection, new TaskInfo(selection)); 
     1071        return selection; 
     1072    } 
     1073 
     1074    /** 
     1075     * 
     1076     */ 
     1077    private ITask reuseSelection(int                   maxNoOfChildren, 
     1078                                 int                   maxDepth, 
     1079                                 Map<ITask, ITaskInfo> taskInfos) 
     1080        throws Exception 
     1081    { 
     1082        ITask selection = reuseTask(taskInfos, ISelection.class); 
     1083         
     1084        if (selection == null) { 
     1085            selection = createNewSelection(maxNoOfChildren, maxDepth, taskInfos); 
     1086        } 
     1087 
     1088        return selection; 
     1089    } 
     1090 
     1091    /** 
     1092     *  
     1093     */ 
     1094    private ITask createNewIteration(int                   maxNoOfChildren, 
     1095                                     int                   maxDepth, 
     1096                                     Map<ITask, ITaskInfo> taskInfos) 
     1097        throws Exception 
     1098    { 
     1099        IIteration iteration = taskFactory.createNewIteration(); 
     1100 
     1101        ITask child = createTaskTree(maxNoOfChildren, maxDepth - 1, taskInfos); 
     1102        taskBuilder.setMarkedTask(iteration, child); 
     1103 
     1104        taskInfos.put(iteration, new TaskInfo(iteration)); 
     1105        return iteration; 
     1106    } 
     1107 
     1108    /** 
     1109     * 
     1110     */ 
     1111    private ITask reuseIteration(int                   maxNoOfChildren, 
     1112                                 int                   maxDepth, 
     1113                                 Map<ITask, ITaskInfo> taskInfos) 
     1114        throws Exception 
     1115    { 
     1116        ITask iteration = reuseTask(taskInfos, IIteration.class); 
     1117         
     1118        if (iteration == null) { 
     1119            iteration = createNewIteration(maxNoOfChildren, maxDepth, taskInfos); 
     1120        } 
     1121 
     1122        return iteration; 
     1123    } 
     1124 
     1125    /** 
     1126     *  
     1127     */ 
     1128    private ITask createNewOptional(int                   maxNoOfChildren, 
     1129                                    int                   maxDepth, 
     1130                                    Map<ITask, ITaskInfo> taskInfos) 
     1131        throws Exception 
     1132    { 
     1133        IOptional optional = taskFactory.createNewOptional(); 
     1134 
     1135        ITask child = createTaskTree(maxNoOfChildren, maxDepth - 1, taskInfos); 
     1136        taskBuilder.setMarkedTask(optional, child); 
     1137 
     1138        taskInfos.put(optional, new TaskInfo(optional)); 
     1139        return optional; 
     1140    } 
     1141 
     1142    /** 
     1143     * 
     1144     */ 
     1145    private ITask reuseOptional(int                   maxNoOfChildren, 
     1146                                int                   maxDepth, 
     1147                                Map<ITask, ITaskInfo> taskInfos) 
     1148        throws Exception 
     1149    { 
     1150        ITask optional = reuseTask(taskInfos, IOptional.class); 
     1151         
     1152        if (optional == null) { 
     1153            optional = createNewOptional(maxNoOfChildren, maxDepth, taskInfos); 
     1154        } 
     1155 
     1156        return optional; 
     1157    } 
     1158 
     1159    /** 
     1160     * 
     1161     */ 
     1162    private ITask reuseTask(Map<ITask, ITaskInfo> taskInfos, Class<? extends ITask> type) 
     1163        throws Exception 
     1164    { 
     1165        int noOfTasks = 0; 
     1166 
     1167        for (Map.Entry<ITask, ITaskInfo> entry : taskInfos.entrySet()) { 
     1168            if (type.isInstance(entry.getKey())) { 
     1169                noOfTasks++; 
     1170            } 
     1171        } 
     1172 
     1173        if (noOfTasks > 0) { 
     1174            noOfTasks = randomize(noOfTasks); 
     1175 
     1176            for (Map.Entry<ITask, ITaskInfo> entry : taskInfos.entrySet()) { 
     1177                if (type.isInstance(entry.getKey())) { 
     1178                    if (--noOfTasks <= 0) { 
     1179                        return entry.getKey(); 
    2701180                    } 
    2711181                } 
     
    2731183        } 
    2741184        else { 
    275             return createNewEventTask(treeInfos); 
     1185            return null; 
    2761186        } 
    2771187 
     
    2801190 
    2811191    /** 
    282      * TODO: comment 
    283      *  
    284      * @param treeInfos 
    285      * @return 
    286      */ 
    287     private ISequence createNewSequence(int                                   maxNoOfChildren, 
    288                                         int                                   maxDepth, 
    289                                         Map<ITaskTreeNode, ITaskTreeNodeInfo> treeInfos) 
    290         throws Exception 
    291     { 
    292         ISequence sequence = taskTreeNodeFactory.createNewSequence(); 
    293  
    294         int noOfChildren = (int) (Math.random() * maxNoOfChildren); 
    295  
    296         for (int i = 0; i < noOfChildren; i++) { 
    297             ITaskTreeNode child = createTree(maxNoOfChildren, maxDepth - 1, treeInfos); 
    298  
    299             // through first removing an existing parent it is assured, that a parent is recorded 
    300             // only once. This is needed, because parent may be reused in a tree as well, but we 
    301             // always 
    302             // iterate the whole tree 
    303             ((NodeInfo) treeInfos.get(child)).removeParent(sequence); 
    304             ((NodeInfo) treeInfos.get(child)).addParent(sequence); 
    305             taskTreeBuilder.addChild(sequence, child); 
    306         } 
    307  
    308         treeInfos.put(sequence, new NodeInfo(sequence)); 
    309         return sequence; 
    310     } 
    311  
    312     /** 
    313      * TODO: comment 
    314      *  
    315      * @param treeInfos 
    316      * @return 
    317      */ 
    318     private ISequence reuseSequence(int                                   maxNoOfChildren, 
    319                                     int                                   maxDepth, 
    320                                     Map<ITaskTreeNode, ITaskTreeNodeInfo> treeInfos) 
    321         throws Exception 
    322     { 
    323         int noOfSequences = 0; 
    324  
    325         for (Map.Entry<ITaskTreeNode, ITaskTreeNodeInfo> entry : treeInfos.entrySet()) { 
    326             if (entry.getKey() instanceof ISequence) { 
    327                 noOfSequences++; 
    328             } 
    329         } 
    330  
    331         if (noOfSequences > 0) { 
    332             noOfSequences = (int) (Math.random() * noOfSequences); 
    333  
    334             for (Map.Entry<ITaskTreeNode, ITaskTreeNodeInfo> entry : treeInfos.entrySet()) { 
    335                 if (entry.getKey() instanceof ISequence) { 
    336                     if (--noOfSequences <= 0) { 
    337                         return (ISequence) entry.getKey(); 
    338                     } 
    339                 } 
    340             } 
    341         } 
    342         else { 
    343             return createNewSequence(maxNoOfChildren, maxDepth, treeInfos); 
    344         } 
    345  
    346         throw new RuntimeException("this is an implementation error"); 
    347     } 
    348  
    349     /** 
    350      * TODO: comment 
    351      *  
    352      * @param treeInfos 
    353      * @return 
    354      */ 
    355     private ISelection createNewSelection(int                                   maxNoOfChildren, 
    356                                           int                                   maxDepth, 
    357                                           Map<ITaskTreeNode, ITaskTreeNodeInfo> treeInfos) 
    358         throws Exception 
    359     { 
    360         ISelection selection = taskTreeNodeFactory.createNewSelection(); 
    361  
    362         int noOfChildren = (int) (Math.random() * maxNoOfChildren); 
    363  
    364         for (int i = 0; i < noOfChildren; i++) { 
    365             ITaskTreeNode child = createTree(maxNoOfChildren, maxDepth - 1, treeInfos); 
    366  
    367             // through first removing an existing parent it is assured, that a parent is recorded 
    368             // only once. This is needed, because parent may be reused in a tree as well, but we 
    369             // always 
    370             // iterate the whole tree 
    371             ((NodeInfo) treeInfos.get(child)).removeParent(selection); 
    372             ((NodeInfo) treeInfos.get(child)).addParent(selection); 
    373             taskTreeBuilder.addChild(selection, child); 
    374         } 
    375  
    376         treeInfos.put(selection, new NodeInfo(selection)); 
    377         return selection; 
    378     } 
    379  
    380     /** 
    381      * TODO: comment 
    382      *  
    383      * @param treeInfos 
    384      * @return 
    385      */ 
    386     private ISelection reuseSelection(int                                   maxNoOfChildren, 
    387                                       int                                   maxDepth, 
    388                                       Map<ITaskTreeNode, ITaskTreeNodeInfo> treeInfos) 
    389         throws Exception 
    390     { 
    391         int noOfSelections = 0; 
    392  
    393         for (Map.Entry<ITaskTreeNode, ITaskTreeNodeInfo> entry : treeInfos.entrySet()) { 
    394             if (entry.getKey() instanceof ISelection) { 
    395                 noOfSelections++; 
    396             } 
    397         } 
    398  
    399         if (noOfSelections > 0) { 
    400             noOfSelections = (int) (Math.random() * noOfSelections); 
    401  
    402             for (Map.Entry<ITaskTreeNode, ITaskTreeNodeInfo> entry : treeInfos.entrySet()) { 
    403                 if (entry.getKey() instanceof ISelection) { 
    404                     if (--noOfSelections <= 0) { 
    405                         return (ISelection) entry.getKey(); 
    406                     } 
    407                 } 
    408             } 
    409         } 
    410         else { 
    411             return createNewSelection(maxNoOfChildren, maxDepth, treeInfos); 
    412         } 
    413  
    414         throw new RuntimeException("this is an implementation error"); 
    415     } 
    416  
    417     /** 
    418      * TODO: comment 
    419      *  
    420      * @param treeInfos 
    421      * @return 
    422      */ 
    423     private IIteration createNewIteration(int                                   maxNoOfChildren, 
    424                                           int                                   maxDepth, 
    425                                           Map<ITaskTreeNode, ITaskTreeNodeInfo> treeInfos) 
    426         throws Exception 
    427     { 
    428         IIteration iteration = taskTreeNodeFactory.createNewIteration(); 
    429  
    430         ITaskTreeNode child = createTree(maxNoOfChildren, maxDepth - 1, treeInfos); 
    431  
    432         // through first removing an existing parent it is assured, that a parent is recorded 
    433         // only once. This is needed, because parent may be reused in a tree as well, but we always 
    434         // iterate the whole tree 
    435         ((NodeInfo) treeInfos.get(child)).removeParent(iteration); 
    436         ((NodeInfo) treeInfos.get(child)).addParent(iteration); 
    437         taskTreeBuilder.setChild(iteration, child); 
    438  
    439         treeInfos.put(iteration, new NodeInfo(iteration)); 
    440         return iteration; 
    441     } 
    442  
    443     /** 
    444      * TODO: comment 
    445      *  
    446      * @param treeInfos 
    447      * @return 
    448      */ 
    449     private IIteration reuseIteration(int                                   maxNoOfChildren, 
    450                                       int                                   maxDepth, 
    451                                       Map<ITaskTreeNode, ITaskTreeNodeInfo> treeInfos) 
    452         throws Exception 
    453     { 
    454         int noOfIterations = 0; 
    455  
    456         for (Map.Entry<ITaskTreeNode, ITaskTreeNodeInfo> entry : treeInfos.entrySet()) { 
    457             if (entry.getKey() instanceof IIteration) { 
    458                 noOfIterations++; 
    459             } 
    460         } 
    461  
    462         if (noOfIterations > 0) { 
    463             noOfIterations = (int) (Math.random() * noOfIterations); 
    464  
    465             for (Map.Entry<ITaskTreeNode, ITaskTreeNodeInfo> entry : treeInfos.entrySet()) { 
    466                 if (entry.getKey() instanceof IIteration) { 
    467                     if (--noOfIterations <= 0) { 
    468                         return (IIteration) entry.getKey(); 
    469                     } 
    470                 } 
    471             } 
    472         } 
    473         else { 
    474             return createNewIteration(maxNoOfChildren, maxDepth, treeInfos); 
    475         } 
    476  
    477         throw new RuntimeException("this is an implementation error"); 
    478     } 
    479  
     1192     * 
     1193     */ 
     1194    private ITaskInstance instantiateTask(ITask task, int maxIterationCount) throws Exception { 
     1195        ITaskInstance instance = taskFactory.createNewTaskInstance(task); 
     1196 
     1197        if (task instanceof ISequence) { 
     1198            for (ITask child : ((ISequence) task).getChildren()) { 
     1199                taskBuilder.addChild(instance, instantiateTask(child, maxIterationCount)); 
     1200            } 
     1201        } 
     1202        else if (task instanceof ISelection) { 
     1203            List<ITask> children = ((ISelection) task).getChildren(); 
     1204            int index = randomize(children.size()); 
     1205            taskBuilder.addChild(instance, instantiateTask(children.get(index), maxIterationCount)); 
     1206        } 
     1207        else if (task instanceof IIteration) { 
     1208            int count = randomize(maxIterationCount); 
     1209            ITask child = ((IIteration) task).getMarkedTask(); 
     1210             
     1211            for (int i = 0; i < count; i++) { 
     1212                taskBuilder.addChild(instance, instantiateTask(child, maxIterationCount)); 
     1213            } 
     1214        } 
     1215        else if (task instanceof IOptional) { 
     1216            ITask child = ((IOptional) task).getMarkedTask(); 
     1217             
     1218            if (randomize(1) == 0) { 
     1219                taskBuilder.addChild(instance, instantiateTask(child, maxIterationCount)); 
     1220            } 
     1221        } 
     1222         
     1223        return instance; 
     1224    } 
     1225 
     1226    /** 
     1227     * 
     1228     */ 
     1229    private int randomize(int max) throws Exception { 
     1230        return randomize(0, max); 
     1231    } 
     1232     
     1233    /** 
     1234     * 
     1235     */ 
     1236    private int randomize(int min, int max) throws Exception { 
     1237        if (min > max) { 
     1238            throw new IllegalArgumentException("min must always be smaller or equal than max"); 
     1239        } 
     1240         
     1241        int deviation = max - min; 
     1242        int value = (int) (Math.random() * deviation); 
     1243         
     1244        return value + min; 
     1245    } 
    4801246} 
  • trunk/autoquest-core-tasktrees/.classpath

    r548 r1146  
    11<?xml version="1.0" encoding="UTF-8"?> 
    22<classpath> 
    3         <classpathentry kind="src" output="target/classes" path="src/main/java"> 
     3        <classpathentry excluding="de/ugoe/cs/autoquest/tasktrees/temporalrelation/copy/|de/ugoe/cs/autoquest/tasktrees/query/" kind="src" output="target/classes" path="src/main/java"> 
    44                <attributes> 
    55                        <attribute name="optional" value="true"/> 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/manager/ComponentManager.java

    r1113 r1146  
    1515package de.ugoe.cs.autoquest.tasktrees.manager; 
    1616 
    17 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEqualityRuleManager; 
     17import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEqualityRuleManager; 
    1818import de.ugoe.cs.autoquest.tasktrees.temporalrelation.TemporalRelationshipRuleManager; 
    19 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder; 
    20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; 
    21 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeBuilder; 
    22 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNodeFactory; 
     19import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; 
     20import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 
     21import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskBuilder; 
     22import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory; 
    2323 
    2424/** 
     
    3737 
    3838    /** */ 
    39     private NodeEqualityRuleManager nodeEqualityRuleManager; 
     39    private TaskEqualityRuleManager taskEqualityRuleManager; 
    4040 
    4141    /** */ 
    42     private ITaskTreeBuilder taskTreeBuilder; 
     42    private ITaskBuilder taskBuilder; 
    4343 
    4444    /** */ 
    45     private ITaskTreeNodeFactory taskTreeNodeFactory; 
     45    private ITaskFactory taskFactory; 
    4646 
    4747    /** 
     
    5555     * 
    5656     */ 
    57     public static NodeEqualityRuleManager getNodeEqualityRuleManager() { 
    58         return getInstance().nodeEqualityRuleManager; 
     57    public static TaskEqualityRuleManager getTaskEqualityRuleManager() { 
     58        return getInstance().taskEqualityRuleManager; 
    5959    } 
    6060 
     
    6262     * 
    6363     */ 
    64     public static ITaskTreeBuilder getDefaultTaskTreeBuilder() { 
    65         return getInstance().taskTreeBuilder; 
     64    public static ITaskBuilder getDefaultTaskBuilder() { 
     65        return getInstance().taskBuilder; 
    6666    } 
    6767 
     
    6969     * 
    7070     */ 
    71     public static ITaskTreeNodeFactory getDefaultTaskTreeNodeFactory() { 
    72         return getInstance().taskTreeNodeFactory; 
     71    public static ITaskFactory getDefaultTaskFactory() { 
     72        return getInstance().taskFactory; 
    7373    } 
    7474 
     
    9595     */ 
    9696    private void init() { 
    97         nodeEqualityRuleManager = new NodeEqualityRuleManager(); 
    98         nodeEqualityRuleManager.init(); 
     97        taskEqualityRuleManager = new TaskEqualityRuleManager(); 
     98        taskEqualityRuleManager.init(); 
    9999 
    100         taskTreeBuilder = new TaskTreeBuilder(); 
    101         taskTreeNodeFactory = new TaskTreeNodeFactory(); 
     100        taskBuilder = new TaskBuilder(); 
     101        taskFactory = new TaskFactory(); 
    102102 
    103103        temporalRelationshipRuleManager = new TemporalRelationshipRuleManager 
    104             (nodeEqualityRuleManager, taskTreeNodeFactory, taskTreeBuilder); 
     104            (taskEqualityRuleManager, taskFactory, taskBuilder); 
    105105        temporalRelationshipRuleManager.init(); 
    106106    } 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/manager/TaskTreeManager.java

    r1113 r1146  
    2121 
    2222import de.ugoe.cs.autoquest.eventcore.Event; 
    23 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 
    24 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 
    25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree; 
    26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder; 
    27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; 
     23import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     24import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 
     25import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; 
     26import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 
     27import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 
    2828import de.ugoe.cs.util.console.Console; 
    2929 
     
    3737     
    3838    /** */ 
    39     private ITaskTreeBuilder taskTreeBuilder = ComponentManager.getDefaultTaskTreeBuilder(); 
     39    private ITaskBuilder taskBuilder = ComponentManager.getDefaultTaskBuilder(); 
    4040 
    4141    /** */ 
    42     private ITaskTreeNodeFactory taskTreeNodeFactory = 
    43         ComponentManager.getDefaultTaskTreeNodeFactory(); 
     42    private ITaskFactory taskFactory = ComponentManager.getDefaultTaskFactory(); 
    4443 
    4544    /** */ 
    46     private List<List<IEventTask>> sessions = null; 
     45    private List<IUserSession> sessions = null; 
    4746 
    4847    /** */ 
    49     private List<IEventTask> currentSession = null; 
     48    private IUserSession currentSession = null; 
    5049 
    5150    /** 
     
    5352     */ 
    5453    public TaskTreeManager() { 
    55         sessions = new LinkedList<List<IEventTask>>(); 
     54        sessions = new LinkedList<IUserSession>(); 
    5655    } 
    5756 
     
    5958     * 
    6059     */ 
    61     public synchronized ITaskTree createTaskTree(Collection<List<Event>> newSessions) { 
     60    public synchronized ITaskModel createTaskModel(Collection<List<Event>> newSessions) { 
    6261        if ((currentSession != null) || (sessions.size() > 0)) { 
    6362            throw new IllegalStateException("do not mix calls to this method with calls to the " + 
     
    7574        } 
    7675         
    77         return getTaskTree(); 
     76        return getTaskModel(); 
    7877    } 
    7978 
     
    8382    public void handleNewEvent(Event event) { 
    8483        assertSessionSequence(); 
    85         currentSession.add 
    86             (taskTreeNodeFactory.createNewEventTask(event.getType(), event.getTarget())); 
     84        ITask eventTask = taskFactory.createNewEventTask(event.getType(), event.getTarget()); 
     85        taskBuilder.addExecutedTask(currentSession, taskFactory.createNewTaskInstance(eventTask)); 
    8786    } 
    8887 
     
    9190     */ 
    9291    public void finishSession() { 
    93         if ((currentSession != null) && (currentSession.size() > 0)) { 
     92        if ((currentSession != null) && (currentSession.getExecutedTasks().size() > 0)) { 
    9493            sessions.add(currentSession); 
    9594            currentSession = null; 
     
    10099     * 
    101100     */ 
    102     public synchronized ITaskTree getTaskTree() { 
     101    public synchronized ITaskModel getTaskModel() { 
    103102        finishSession(); 
    104103         
    105104        Console.traceln(Level.INFO, "applying temporal relationship generation rules"); 
    106105         
    107         ISequence rootSequence = taskTreeNodeFactory.createNewSequence(); 
    108         taskTreeBuilder.setDescription(rootSequence, "root"); 
    109          
    110         for (List<IEventTask> session : sessions) { 
    111             ISequence sequence = taskTreeNodeFactory.createNewSequence(); 
    112             taskTreeBuilder.setDescription(sequence, "session"); 
    113              
    114             for (IEventTask eventTask : session) { 
    115                 taskTreeBuilder.addChild(sequence, eventTask); 
    116             } 
    117              
    118             taskTreeBuilder.addChild(rootSequence, sequence); 
    119         } 
    120          
    121          
    122         ComponentManager.getTemporalRelationshipRuleManager().applyRules(rootSequence); 
     106        ComponentManager.getTemporalRelationshipRuleManager().applyRules(sessions); 
    123107 
    124         return taskTreeNodeFactory.createTaskTree(rootSequence); 
     108        return taskFactory.createTaskModel(sessions); 
    125109    } 
    126110 
     
    130114    private void assertSessionSequence() { 
    131115        if (currentSession == null) { 
    132             currentSession = new LinkedList<IEventTask>(); 
     116            currentSession = taskFactory.createUserSession(); 
    133117        } 
    134118    } 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/EventTaskComparisonRule.java

    r1125 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1616 
    1717import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 
    18 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
     18import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    1919 
    2020/** 
    2121 * <p> 
    22  * This rule identifies two task tree nodes as lexically equal, if they are both event tasks and 
     22 * This rule identifies two tasks as lexically equal, if they are both event tasks and 
    2323 * if their respective event types and targets equal.  
    2424 * </p> 
     
    2626 * @author Patrick Harms 
    2727 */ 
    28 public class EventTaskComparisonRule implements NodeComparisonRule { 
     28public class EventTaskComparisonRule implements TaskComparisonRule { 
    2929     
    3030    /* (non-Javadoc) 
    31      * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 
     31     * @see NodeComparisonRule#isApplicable(ITask, ITask) 
    3232     */ 
    3333    @Override 
    34     public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 
    35         return (node1 instanceof IEventTask) && (node2 instanceof IEventTask); 
     34    public boolean isApplicable(ITask task1, ITask task2) { 
     35        return (task1 instanceof IEventTask) && (task2 instanceof IEventTask); 
    3636    } 
    3737 
    3838    /* (non-Javadoc) 
    39      * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 
     39     * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask) 
    4040     */ 
    4141    @Override 
    42     public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    43         IEventTask task1 = (IEventTask) node1; 
    44         IEventTask task2 = (IEventTask) node2; 
     42    public boolean areLexicallyEqual(ITask task1, ITask task2) { 
     43        IEventTask eventTask1 = (IEventTask) task1; 
     44        IEventTask eventTask2 = (IEventTask) task2; 
    4545         
    46         return (task1.getEventType().equals(task2.getEventType()) && 
    47                 task1.getEventTarget().equals(task2.getEventTarget())); 
     46        return (eventTask1.getEventType().equals(eventTask2.getEventType()) && 
     47                eventTask1.getEventTarget().equals(eventTask2.getEventTarget())); 
    4848    } 
    4949 
    5050    /* (non-Javadoc) 
    51      * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     51     * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask) 
    5252     */ 
    5353    @Override 
    54     public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    55         return areLexicallyEqual(node1, node2); 
     54    public boolean areSyntacticallyEqual(ITask task1, ITask task2) { 
     55        return areLexicallyEqual(task1, task2); 
    5656    } 
    5757 
    5858    /* (non-Javadoc) 
    59      * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     59     * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask) 
    6060     */ 
    6161    @Override 
    62     public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    63         return areLexicallyEqual(node1, node2); 
     62    public boolean areSemanticallyEqual(ITask task1, ITask task2) { 
     63        return areLexicallyEqual(task1, task2); 
    6464    } 
    6565 
    6666    @Override 
    67     public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
    68         if (areLexicallyEqual(node1, node2)) { 
    69             return NodeEquality.LEXICALLY_EQUAL; 
     67    public TaskEquality compare(ITask task1, ITask task2) { 
     68        if (areLexicallyEqual(task1, task2)) { 
     69            return TaskEquality.LEXICALLY_EQUAL; 
    7070        } 
    7171        else { 
    72             return NodeEquality.UNEQUAL; 
     72            return TaskEquality.UNEQUAL; 
    7373        } 
    7474    } 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/GUIEventTaskComparisonRule.java

    r1125 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1616 
    1717import de.ugoe.cs.autoquest.eventcore.IEventTarget; 
     
    4242import de.ugoe.cs.autoquest.eventcore.guimodel.IToolTip; 
    4343import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 
    44 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
     44import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    4545 
    4646/** 
     
    5858 * @author Patrick Harms 
    5959 */ 
    60 public class GUIEventTaskComparisonRule implements NodeComparisonRule { 
     60public class GUIEventTaskComparisonRule implements TaskComparisonRule { 
    6161     
    6262    /* (non-Javadoc) 
    63      * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 
     63     * @see NodeComparisonRule#isApplicable(ITask, ITask) 
    6464     */ 
    6565    @Override 
    66     public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 
     66    public boolean isApplicable(ITask task1, ITask task2) { 
    6767        return 
    68             ((node1 instanceof IEventTask) && (node2 instanceof IEventTask) && 
    69             (((IEventTask) node1).getEventType() instanceof IInteraction) && 
    70             (((IEventTask) node2).getEventType() instanceof IInteraction)); 
     68            ((task1 instanceof IEventTask) && (task2 instanceof IEventTask) && 
     69            (((IEventTask) task1).getEventType() instanceof IInteraction) && 
     70            (((IEventTask) task2).getEventType() instanceof IInteraction)); 
    7171    } 
    7272 
    7373    /* (non-Javadoc) 
    74      * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 
     74     * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask) 
    7575     */ 
    7676    @Override 
    77     public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    78         NodeEquality equality = getEquality(node1, node2, NodeEquality.LEXICALLY_EQUAL); 
    79         return (equality != null) && (equality.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 
     77    public boolean areLexicallyEqual(ITask task1, ITask task2) { 
     78        TaskEquality equality = getEquality(task1, task2, TaskEquality.LEXICALLY_EQUAL); 
     79        return (equality != null) && (equality.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 
    8080    } 
    8181 
    8282    /* (non-Javadoc) 
    83      * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     83     * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask) 
    8484     */ 
    8585    @Override 
    86     public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    87         NodeEquality equality = getEquality(node1, node2, NodeEquality.SYNTACTICALLY_EQUAL); 
    88         return (equality != null) && (equality.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 
     86    public boolean areSyntacticallyEqual(ITask task1, ITask task2) { 
     87        TaskEquality equality = getEquality(task1, task2, TaskEquality.SYNTACTICALLY_EQUAL); 
     88        return (equality != null) && (equality.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 
    8989    } 
    9090 
    9191    /* (non-Javadoc) 
    92      * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     92     * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask) 
    9393     */ 
    9494    @Override 
    95     public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    96         NodeEquality equality = getEquality(node1, node2, NodeEquality.SEMANTICALLY_EQUAL); 
    97         return (equality != null) && (equality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 
     95    public boolean areSemanticallyEqual(ITask task1, ITask task2) { 
     96        TaskEquality equality = getEquality(task1, task2, TaskEquality.SEMANTICALLY_EQUAL); 
     97        return (equality != null) && (equality.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 
    9898    } 
    9999 
    100100    /* (non-Javadoc) 
    101      * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 
     101     * @see NodeComparisonRule#compare(ITask, ITask) 
    102102     */ 
    103103    @Override 
    104     public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
    105         return getEquality(node1, node2, null); 
    106     } 
    107  
    108     /** 
    109      *  
    110      */ 
    111     private NodeEquality getEquality(ITaskTreeNode node1, 
    112                                      ITaskTreeNode node2, 
    113                                      NodeEquality  requiredEqualityLevel) 
    114     { 
    115         IEventTask task1 = (IEventTask) node1; 
    116         IEventTask task2 = (IEventTask) node2; 
    117          
    118         if (!task1.getEventTarget().equals(task2.getEventTarget())) { 
    119             return NodeEquality.UNEQUAL; 
    120         } 
    121          
    122         IInteraction interaction1 = (IInteraction) task1.getEventType(); 
    123         IInteraction interaction2 = (IInteraction) task2.getEventType(); 
     104    public TaskEquality compare(ITask task1, ITask task2) { 
     105        return getEquality(task1, task2, null); 
     106    } 
     107 
     108    /** 
     109     *  
     110     */ 
     111    private TaskEquality getEquality(ITask task1, ITask task2, TaskEquality requiredEqualityLevel) { 
     112        IEventTask eventTask1 = (IEventTask) task1; 
     113        IEventTask eventTask2 = (IEventTask) task2; 
     114         
     115        if (!eventTask1.getEventTarget().equals(eventTask2.getEventTarget())) { 
     116            return TaskEquality.UNEQUAL; 
     117        } 
     118         
     119        IInteraction interaction1 = (IInteraction) eventTask1.getEventType(); 
     120        IInteraction interaction2 = (IInteraction) eventTask2.getEventType(); 
    124121         
    125122        return compareInteractions 
    126             (interaction1, interaction2, task1.getEventTarget(), requiredEqualityLevel); 
     123            (interaction1, interaction2, eventTask1.getEventTarget(), requiredEqualityLevel); 
    127124    } 
    128125 
     
    145142     * @return as described 
    146143     */ 
    147     private NodeEquality compareInteractions(IInteraction interaction1, 
     144    private TaskEquality compareInteractions(IInteraction interaction1, 
    148145                                             IInteraction interaction2, 
    149146                                             IEventTarget eventTarget, 
    150                                              NodeEquality equalityLevel) 
    151     { 
    152         NodeEquality level = equalityLevel; 
     147                                             TaskEquality equalityLevel) 
     148    { 
     149        TaskEquality level = equalityLevel; 
    153150         
    154151        if (level == null) { 
    155             level = NodeEquality.LEXICALLY_EQUAL; 
     152            level = TaskEquality.LEXICALLY_EQUAL; 
    156153        } 
    157154         
    158155        if (interaction1 == interaction2) { 
    159             return NodeEquality.LEXICALLY_EQUAL; 
     156            return TaskEquality.LEXICALLY_EQUAL; 
    160157        } 
    161158        else if ((interaction1 instanceof KeyInteraction) && 
     
    186183        } 
    187184        else if (interaction1.equals(interaction2)) { 
    188             return NodeEquality.LEXICALLY_EQUAL; 
     185            return TaskEquality.LEXICALLY_EQUAL; 
    189186        } 
    190187        else { 
    191             return NodeEquality.UNEQUAL; 
     188            return TaskEquality.UNEQUAL; 
    192189        } 
    193190    } 
     
    204201     * @return 
    205202     */ 
    206     private NodeEquality compareKeyInteractions(KeyInteraction interaction1, 
     203    private TaskEquality compareKeyInteractions(KeyInteraction interaction1, 
    207204                                                KeyInteraction interaction2, 
    208                                                 NodeEquality   equalityLevel) 
     205                                                TaskEquality   equalityLevel) 
    209206    { 
    210207        if (((interaction1 instanceof KeyPressed) && (interaction2 instanceof KeyPressed)) || 
     
    212209            ((interaction1 instanceof KeyTyped) && (interaction2 instanceof KeyTyped))) 
    213210        { 
    214             if ((equalityLevel.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)) && 
     211            if ((equalityLevel.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)) && 
    215212                (interaction1.getKey() == interaction2.getKey())) 
    216213            { 
    217                 return NodeEquality.LEXICALLY_EQUAL; 
     214                return TaskEquality.LEXICALLY_EQUAL; 
    218215            } 
    219216            else { 
    220                 return NodeEquality.SEMANTICALLY_EQUAL; 
    221             } 
    222         } 
    223          
    224         return NodeEquality.UNEQUAL; 
     217                return TaskEquality.SEMANTICALLY_EQUAL; 
     218            } 
     219        } 
     220         
     221        return TaskEquality.UNEQUAL; 
    225222    } 
    226223     
     
    236233     * @return as described 
    237234     */ 
    238     private NodeEquality compareMouseDragAndDrops(MouseDragAndDrop interaction1, 
     235    private TaskEquality compareMouseDragAndDrops(MouseDragAndDrop interaction1, 
    239236                                                  MouseDragAndDrop interaction2, 
    240                                                   NodeEquality     equalityLevel) 
     237                                                  TaskEquality     equalityLevel) 
    241238    { 
    242239        if (interaction1.getButton() != interaction2.getButton()) { 
    243             return NodeEquality.UNEQUAL; 
    244         } 
    245          
    246         if (equalityLevel.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)) { 
     240            return TaskEquality.UNEQUAL; 
     241        } 
     242         
     243        if (equalityLevel.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)) { 
    247244            int x1 = interaction1.getX(); 
    248245            int x1Start = interaction1.getXStart(); 
     
    255252         
    256253            if ((x1Start == x2Start) && (x1 == x2) && (y1Start == y2Start) && (y1 == y2)) { 
    257                 return NodeEquality.LEXICALLY_EQUAL; 
    258             } 
    259         } 
    260          
    261         return NodeEquality.SEMANTICALLY_EQUAL; 
     254                return TaskEquality.LEXICALLY_EQUAL; 
     255            } 
     256        } 
     257         
     258        return TaskEquality.SEMANTICALLY_EQUAL; 
    262259    } 
    263260 
     
    279276     * @return as described 
    280277     */ 
    281     private NodeEquality compareMouseButtonInteractions(MouseButtonInteraction interaction1, 
     278    private TaskEquality compareMouseButtonInteractions(MouseButtonInteraction interaction1, 
    282279                                                        MouseButtonInteraction interaction2, 
    283280                                                        IEventTarget           eventTarget, 
    284                                                         NodeEquality           equalityLevel) 
     281                                                        TaskEquality           equalityLevel) 
    285282    { 
    286283        boolean coordinatesMatch = true; 
     
    293290        } 
    294291        else if (interaction1.getButton() != interaction2.getButton()) { 
    295             return NodeEquality.UNEQUAL; 
    296         } 
    297         else if (equalityLevel.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL) && 
     292            return TaskEquality.UNEQUAL; 
     293        } 
     294        else if (equalityLevel.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL) && 
    298295                 clickCoordinatesMakeLexicalDifference(eventTarget)) 
    299296        { 
     
    319316        { 
    320317            if (coordinatesMatch) { 
    321                 return NodeEquality.LEXICALLY_EQUAL; 
     318                return TaskEquality.LEXICALLY_EQUAL; 
    322319            } 
    323320            else { 
    324                 return NodeEquality.SEMANTICALLY_EQUAL; 
    325             } 
    326         } 
    327          
    328         return NodeEquality.UNEQUAL; 
     321                return TaskEquality.SEMANTICALLY_EQUAL; 
     322            } 
     323        } 
     324         
     325        return TaskEquality.UNEQUAL; 
    329326    } 
    330327 
     
    346343     * @return as described 
    347344     */ 
    348     private NodeEquality compareScrolls(Scroll       interaction1, 
     345    private TaskEquality compareScrolls(Scroll       interaction1, 
    349346                                        Scroll       interaction2, 
    350                                         NodeEquality equalityLevel) 
    351     { 
    352         if (equalityLevel.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)) { 
     347                                        TaskEquality equalityLevel) 
     348    { 
     349        if (equalityLevel.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)) { 
    353350            int x1 = interaction1.getXPosition(); 
    354351            int x2 = interaction2.getXPosition(); 
     
    357354         
    358355            if ((x1 == x2) && (y1 == y2)) { 
    359                 return NodeEquality.LEXICALLY_EQUAL; 
    360             } 
    361         } 
    362          
    363         return NodeEquality.SEMANTICALLY_EQUAL; 
     356                return TaskEquality.LEXICALLY_EQUAL; 
     357            } 
     358        } 
     359         
     360        return TaskEquality.SEMANTICALLY_EQUAL; 
    364361    } 
    365362 
     
    377374     * @return as described 
    378375     */ 
    379     private NodeEquality compareTextInputs(TextInput    interaction1, 
     376    private TaskEquality compareTextInputs(TextInput    interaction1, 
    380377                                           TextInput    interaction2, 
    381                                            NodeEquality equalityLevel) 
     378                                           TaskEquality equalityLevel) 
    382379    { 
    383380        switch (equalityLevel) { 
    384381            case LEXICALLY_EQUAL: 
    385382                if (interaction1.getTextInputEvents().equals(interaction2.getTextInputEvents())) { 
    386                     return NodeEquality.LEXICALLY_EQUAL; 
     383                    return TaskEquality.LEXICALLY_EQUAL; 
    387384                } 
    388385                // fall through 
    389386            case SYNTACTICALLY_EQUAL: 
    390387                if (interaction1.getEnteredText().equals(interaction2.getEnteredText())) { 
    391                     return NodeEquality.SYNTACTICALLY_EQUAL; 
     388                    return TaskEquality.SYNTACTICALLY_EQUAL; 
    392389                } 
    393390                // fall through 
    394391            case SEMANTICALLY_EQUAL: 
    395                 return NodeEquality.SEMANTICALLY_EQUAL; 
     392                return TaskEquality.SEMANTICALLY_EQUAL; 
    396393            default: 
    397                 return NodeEquality.UNEQUAL; 
     394                return TaskEquality.UNEQUAL; 
    398395        } 
    399396    } 
     
    411408     * @return as described 
    412409     */ 
    413     private NodeEquality compareValueSelections(ValueSelection<?> interaction1, 
     410    private TaskEquality compareValueSelections(ValueSelection<?> interaction1, 
    414411                                                ValueSelection<?> interaction2, 
    415                                                 NodeEquality      equalityLevel) 
    416     { 
    417         if (equalityLevel.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)) { 
     412                                                TaskEquality      equalityLevel) 
     413    { 
     414        if (equalityLevel.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)) { 
    418415            Object value1 = interaction1.getSelectedValue(); 
    419416            Object value2 = interaction2.getSelectedValue(); 
    420417         
    421418            if ((value1 == value2) || ((value1 != null) && (value1.equals(value2)))) { 
    422                 return NodeEquality.LEXICALLY_EQUAL; 
    423             } 
    424         } 
    425          
    426         return NodeEquality.SEMANTICALLY_EQUAL; 
     419                return TaskEquality.LEXICALLY_EQUAL; 
     420            } 
     421        } 
     422         
     423        return TaskEquality.SEMANTICALLY_EQUAL; 
    427424    } 
    428425 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/IterationComparisonRule.java

    r1125 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
    16  
    17 import java.util.List; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1816 
    1917import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 
     
    2119import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
    2220import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 
    23 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
     21import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    2422 
    2523/** 
     
    8179 * @author 2012, last modified by $Author: patrick$ 
    8280 */ 
    83 public class IterationComparisonRule implements NodeComparisonRule { 
     81public class IterationComparisonRule implements TaskComparisonRule { 
    8482     
    85     /** the rule manager for internally comparing task tree nodes */ 
    86     private NodeEqualityRuleManager mRuleManager; 
     83    /** the rule manager for internally comparing tasks */ 
     84    private TaskEqualityRuleManager mRuleManager; 
    8785 
    8886    /** 
    8987     * <p> 
    90      * simple constructor to provide the rule with the node equality rule manager to be able 
    91      * to perform comparisons of the children of provided task tree nodes 
     88     * simple constructor to provide the rule with the task equality rule manager to be able 
     89     * to perform comparisons of the children of provided tasks 
    9290     * </p> 
    9391     *  
    94      * @param ruleManager the rule manager for comparing task tree nodes 
    95      */ 
    96     IterationComparisonRule(NodeEqualityRuleManager ruleManager) { 
     92     * @param ruleManager the rule manager for comparing tasks 
     93     */ 
     94    IterationComparisonRule(TaskEqualityRuleManager ruleManager) { 
    9795        super(); 
    9896        mRuleManager = ruleManager; 
     
    10098 
    10199    /* (non-Javadoc) 
    102      * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 
    103      */ 
    104     @Override 
    105     public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 
    106         return (node1 instanceof IIteration) && (node2 instanceof IIteration); 
    107     } 
    108  
    109     /* (non-Javadoc) 
    110      * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 
    111      */ 
    112     @Override 
    113     public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    114         List<ITaskTreeNode> children1 = node1.getChildren(); 
    115         List<ITaskTreeNode> children2 = node2.getChildren(); 
    116          
    117         if (children1.size() == children2.size()) { 
    118             if (children1.size() == 0) { 
    119                 return true; 
     100     * @see NodeComparisonRule#isApplicable(ITask, ITask) 
     101     */ 
     102    @Override 
     103    public boolean isApplicable(ITask task1, ITask task2) { 
     104        return (task1 instanceof IIteration) && (task2 instanceof IIteration); 
     105    } 
     106 
     107    /* (non-Javadoc) 
     108     * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask) 
     109     */ 
     110    @Override 
     111    public boolean areLexicallyEqual(ITask task1, ITask task2) { 
     112        ITask child1 = ((IIteration) task1).getMarkedTask(); 
     113        ITask child2 = ((IIteration) task2).getMarkedTask(); 
     114         
     115        if (child1 != null) { 
     116            if (child2 == null) { 
     117                return false; 
    120118            } 
    121119            else { 
    122                 ITaskTreeNode child1 = children1.get(0); 
    123                 ITaskTreeNode child2 = children2.get(0); 
    124                  
    125120                // iterations may have 3 different structures. 
    126121                // 1. they have one child, which is the iterated one 
     
    136131                { 
    137132                    return getNodeEquality 
    138                         (child1, child2).isAtLeast(NodeEquality.LEXICALLY_EQUAL); 
     133                        (child1, child2).isAtLeast(TaskEquality.LEXICALLY_EQUAL); 
    139134                } 
    140135            } 
    141136        } 
     137        else if (child2 == null) { 
     138            return true; 
     139        } 
    142140         
    143141        return false; 
     
    145143 
    146144    /* (non-Javadoc) 
    147      * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 
    148      */ 
    149     @Override 
    150     public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    151         List<ITaskTreeNode> children1 = node1.getChildren(); 
    152         List<ITaskTreeNode> children2 = node2.getChildren(); 
    153          
    154         if (children1.size() == children2.size()) { 
    155             if (children1.size() == 0) { 
    156                 return true; 
     145     * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask) 
     146     */ 
     147    @Override 
     148    public boolean areSyntacticallyEqual(ITask task1, ITask task2) { 
     149        ITask child1 = ((IIteration) task1).getMarkedTask(); 
     150        ITask child2 = ((IIteration) task2).getMarkedTask(); 
     151         
     152        if (child1 != null) { 
     153            if (child2 == null) { 
     154                return false; 
    157155            } 
    158156            else { 
    159                 ITaskTreeNode child1 = children1.get(0); 
    160                 ITaskTreeNode child2 = children2.get(0); 
    161                  
    162157                // iterations may have 3 different structures. 
    163158                // 1. they have one child, which is the iterated one 
     
    167162                // ignore the type of the children but check them for equality. 
    168163                 
    169                 return getNodeEquality(child1, child2).isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL); 
    170             } 
     164                return getNodeEquality(child1, child2).isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL); 
     165            } 
     166        } 
     167        else if (child2 == null) { 
     168            return true; 
    171169        } 
    172170         
     
    175173 
    176174    /* (non-Javadoc) 
    177      * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 
    178      */ 
    179     @Override 
    180     public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    181         return compare(node1, node2).isAtLeast(NodeEquality.SEMANTICALLY_EQUAL); 
    182     } 
    183  
    184     /* (non-Javadoc) 
    185      * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 
    186      */ 
    187     @Override 
    188     public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
    189         List<ITaskTreeNode> children1 = node1.getChildren(); 
    190         List<ITaskTreeNode> children2 = node2.getChildren(); 
     175     * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask) 
     176     */ 
     177    @Override 
     178    public boolean areSemanticallyEqual(ITask task1, ITask task2) { 
     179        return compare(task1, task2).isAtLeast(TaskEquality.SEMANTICALLY_EQUAL); 
     180    } 
     181 
     182    /* (non-Javadoc) 
     183     * @see NodeComparisonRule#compare(ITask, ITask) 
     184     */ 
     185    @Override 
     186    public TaskEquality compare(ITask task1, ITask task2) { 
     187        ITask child1 = ((IIteration) task1).getMarkedTask(); 
     188        ITask child2 = ((IIteration) task2).getMarkedTask(); 
    191189 
    192190        // if both iterations do not have children, they are equal although this doesn't make sense 
    193         if ((children1.size() == 0) && (children2.size() == 0)) { 
    194             return NodeEquality.LEXICALLY_EQUAL; 
    195         } 
    196         else if ((children1.size() == 0) || (children2.size() == 0)) { 
    197             return NodeEquality.UNEQUAL; 
    198         } 
    199  
    200         ITaskTreeNode child1 = children1.get(0); 
    201         ITaskTreeNode child2 = children2.get(0); 
     191        if ((child1 == null) && (child2 == null)) { 
     192            return TaskEquality.LEXICALLY_EQUAL; 
     193        } 
     194        else if ((child1 == null) || (child2 == null)) { 
     195            return TaskEquality.UNEQUAL; 
     196        } 
    202197 
    203198        // iterations may have 3 different structures. 
     
    209204        // the permutations of the three variants in combination must be checked 
    210205 
    211         // check if both nodes are the same variants of iterations and if their children are equal. 
     206        // check if both tasks are the same variants of iterations and if their children are equal. 
    212207        // This condition matches, if both iterations are the same variants of iteration. I.e. three 
    213208        // combinations of the permutation are handled herewith. 
    214         NodeEquality nodeEquality = getNodeEquality(child1, child2); 
    215          
    216         if (nodeEquality != null) { 
    217             return nodeEquality; 
    218         } 
    219  
    220         // compare one iteration with a single node as a child and another one with a selection of 
    221         // semantically equal nodes 
     209        TaskEquality taskEquality = getNodeEquality(child1, child2); 
     210         
     211        if (taskEquality != null) { 
     212            return taskEquality; 
     213        } 
     214 
     215        // compare one iteration with a single task as a child and another one with a selection of 
     216        // semantically equal tasks 
    222217        return selectionChildrenSemanticallyEqualNode(child1, child2); 
    223218         
     
    229224     * TODO update comment 
    230225     */ 
    231     private NodeEquality getNodeEquality(ITaskTreeNode child1, ITaskTreeNode child2) { 
    232         NodeEquality nodeEquality = callRuleManager(child1, child2, null); 
    233  
    234         if (nodeEquality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)) { 
     226    private TaskEquality getNodeEquality(ITask child1, ITask child2) { 
     227        TaskEquality taskEquality = callRuleManager(child1, child2, null); 
     228 
     229        if (taskEquality.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)) { 
    235230            // prevent, that identical is returned, because the iterations itself are not identical 
    236231            // although the iterated tasks are 
    237             if (nodeEquality == NodeEquality.IDENTICAL) { 
    238                 return NodeEquality.LEXICALLY_EQUAL; 
     232            if (taskEquality == TaskEquality.IDENTICAL) { 
     233                return TaskEquality.LEXICALLY_EQUAL; 
    239234            } 
    240235            else { 
    241                 return nodeEquality; 
    242             } 
    243         } 
    244          
    245         return NodeEquality.UNEQUAL; 
     236                return taskEquality; 
     237            } 
     238        } 
     239         
     240        return TaskEquality.UNEQUAL; 
    246241    } 
    247242 
    248243    /** 
    249244     * <p> 
    250      * compares two task tree nodes. One of them must be a selection, the other one can be any task 
    251      * tree node. The method returns a node equality that is not <code>NodeEquality.UNEQUAL</code> 
    252      * if the other node is at least semantically equal to the children of the selection. It 
    253      * returns more concrete equalities, if the equality between the other node and the children 
     245     * compares two tasks. One of them must be a selection, the other one can be any task 
     246     * tree task. The method returns a task equality that is not <code>NodeEquality.UNEQUAL</code> 
     247     * if the other task is at least semantically equal to the children of the selection. It 
     248     * returns more concrete equalities, if the equality between the other task and the children 
    254249     * of the selection is more concrete. 
    255250     * </p>  
    256251     *  
    257      * @param taskTreeNode  the first task tree node to compare 
    258      * @param taskTreeNode2 the second task tree node to compare 
     252     * @param taskTreeNode  the first task to compare 
     253     * @param taskTreeNode2 the second task to compare 
    259254     *  
    260255     * @return as described 
    261256     */ 
    262     private NodeEquality selectionChildrenSemanticallyEqualNode(ITaskTreeNode taskTreeNode, 
    263                                                                 ITaskTreeNode taskTreeNode2) 
    264     { 
     257    private TaskEquality selectionChildrenSemanticallyEqualNode(ITask task1, ITask task2) { 
    265258        ISelection selection = null; 
    266         ITaskTreeNode node = null; 
    267         if (taskTreeNode instanceof ISelection) { 
    268             selection = (ISelection) taskTreeNode; 
    269             node = taskTreeNode2; 
    270         } 
    271         else if (taskTreeNode2 instanceof ISelection) { 
    272             selection = (ISelection) taskTreeNode2; 
    273             node = taskTreeNode; 
     259        ITask task = null; 
     260        if (task1 instanceof ISelection) { 
     261            selection = (ISelection) task1; 
     262            task = task2; 
     263        } 
     264        else if (task2 instanceof ISelection) { 
     265            selection = (ISelection) task2; 
     266            task = task1; 
    274267        } 
    275268        else { 
    276             return NodeEquality.UNEQUAL; 
     269            return TaskEquality.UNEQUAL; 
    277270        } 
    278271 
    279272        // Iterations, where one has a selection and the other one not can at most be syntactically 
    280273        // equal but not identical 
    281         NodeEquality commonDenominatorForAllComparisons = NodeEquality.SYNTACTICALLY_EQUAL; 
    282  
    283         for (ITaskTreeNode child : selection.getChildren()) { 
    284             NodeEquality nodeEquality = 
    285                   callRuleManager(node, child, commonDenominatorForAllComparisons); 
    286  
    287             if ((nodeEquality == null) || (nodeEquality == NodeEquality.UNEQUAL)) 
     274        TaskEquality commonDenominatorForAllComparisons = TaskEquality.SYNTACTICALLY_EQUAL; 
     275 
     276        for (ITask child : selection.getChildren()) { 
     277            TaskEquality taskEquality = 
     278                  callRuleManager(task, child, commonDenominatorForAllComparisons); 
     279 
     280            if ((taskEquality == null) || (taskEquality == TaskEquality.UNEQUAL)) 
    288281            { 
    289                 return NodeEquality.UNEQUAL; 
     282                return TaskEquality.UNEQUAL; 
    290283            } 
    291284             
    292285            commonDenominatorForAllComparisons = 
    293                 commonDenominatorForAllComparisons.getCommonDenominator(nodeEquality); 
     286                commonDenominatorForAllComparisons.getCommonDenominator(taskEquality); 
    294287        } 
    295288 
     
    307300     * @return 
    308301     */ 
    309     private NodeEquality callRuleManager(ITaskTreeNode child1, 
    310                                          ITaskTreeNode child2, 
    311                                          NodeEquality requiredEqualityLevel) 
     302    private TaskEquality callRuleManager(ITask        child1, 
     303                                         ITask        child2, 
     304                                         TaskEquality requiredEqualityLevel) 
    312305    { 
    313306        if (requiredEqualityLevel == null) { 
     
    318311        } 
    319312        else { 
    320             return NodeEquality.UNEQUAL; 
     313            return TaskEquality.UNEQUAL; 
    321314        } 
    322315    } 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/SelectionComparisonRule.java

    r1125 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1616 
    1717import java.util.List; 
    1818 
    1919import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
    20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
     20import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    2121 
    2222/** 
    2323 * <p> 
    24  * this node comparison rule is capable of comparing selections. If both selections do not have 
    25  * children, they are treated as identical. If they have children, each child of both selections 
    26  * is compared to each child of the respective other selection. The resulting equality is the most 
    27  * concrete one of all these comparisons. I.e. if all children are at least lexically equal, then 
    28  * the selections are lexically equal. If all children are at least syntactically equal, then the 
    29  * selections are syntactically equal. If all children are at least semantically equal, then the 
    30  * selections are semantically equal. If only one of the selections has children, then the 
    31  * selections are unequal. 
     24 * this task comparison rule is capable of comparing selections. If both selections do not have 
     25 * children, they are treated as lexically equal. If they have children, each child of both 
     26 * selections is compared to each child of the respective other selection. The resulting equality 
     27 * is the most concrete one of all these comparisons. I.e. if all children are at least lexically 
     28 * equal, then the selections are lexically equal. If all children are at least syntactically 
     29 * equal, then the selections are syntactically equal. If all children are at least semantically 
     30 * equal, then the selections are semantically equal. If only one of the selections has children, 
     31 * then the selections are unequal. 
    3232 * </p> 
    3333 *  
     
    3535 * @author 2012, last modified by $Author: patrick$ 
    3636 */ 
    37 public class SelectionComparisonRule implements NodeComparisonRule { 
    38  
    39     /** the rule manager for internally comparing task tree nodes */ 
    40     private NodeEqualityRuleManager mRuleManager; 
    41  
    42     /** 
    43      * <p> 
    44      * simple constructor to provide the rule with the node equality rule manager to be able 
    45      * to perform comparisons of the children of provided task tree nodes 
     37public class SelectionComparisonRule implements TaskComparisonRule { 
     38 
     39    /** the rule manager for internally comparing tasks */ 
     40    private TaskEqualityRuleManager mRuleManager; 
     41 
     42    /** 
     43     * <p> 
     44     * simple constructor to provide the rule with the task equality rule manager to be able 
     45     * to perform comparisons of the children of provided tasks 
    4646     * </p> 
    4747     *  
    48      * @param ruleManager the rule manager for comparing task tree nodes 
    49      */ 
    50     SelectionComparisonRule(NodeEqualityRuleManager ruleManager) { 
     48     * @param ruleManager the rule manager for comparing tasks 
     49     */ 
     50    SelectionComparisonRule(TaskEqualityRuleManager ruleManager) { 
    5151        super(); 
    5252        mRuleManager = ruleManager; 
     
    5454 
    5555    /* (non-Javadoc) 
    56      * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 
    57      */ 
    58     @Override 
    59     public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 
    60         return (node1 instanceof ISelection) && (node2 instanceof ISelection); 
    61     } 
    62  
    63     /* (non-Javadoc) 
    64      * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 
    65      */ 
    66     @Override 
    67     public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    68         NodeEquality equality = getEquality(node1, node2, NodeEquality.LEXICALLY_EQUAL); 
    69         return (equality != null) && (equality.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 
    70     } 
    71  
    72     /* (non-Javadoc) 
    73      * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 
    74      */ 
    75     @Override 
    76     public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    77         NodeEquality equality = getEquality(node1, node2, NodeEquality.SYNTACTICALLY_EQUAL); 
    78         return (equality != null) && (equality.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 
    79     } 
    80  
    81     /* (non-Javadoc) 
    82      * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 
    83      */ 
    84     @Override 
    85     public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    86         NodeEquality equality = getEquality(node1, node2, NodeEquality.SEMANTICALLY_EQUAL); 
    87         return (equality != null) && (equality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 
    88     } 
    89  
    90     /* (non-Javadoc) 
    91      * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 
    92      */ 
    93     @Override 
    94     public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
    95         return getEquality(node1, node2, null); 
     56     * @see NodeComparisonRule#isApplicable(ITask, ITask) 
     57     */ 
     58    @Override 
     59    public boolean isApplicable(ITask task1, ITask task2) { 
     60        return (task1 instanceof ISelection) && (task2 instanceof ISelection); 
     61    } 
     62 
     63    /* (non-Javadoc) 
     64     * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask) 
     65     */ 
     66    @Override 
     67    public boolean areLexicallyEqual(ITask task1, ITask task2) { 
     68        TaskEquality equality = getEquality(task1, task2, TaskEquality.LEXICALLY_EQUAL); 
     69        return (equality != null) && (equality.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 
     70    } 
     71 
     72    /* (non-Javadoc) 
     73     * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask) 
     74     */ 
     75    @Override 
     76    public boolean areSyntacticallyEqual(ITask task1, ITask task2) { 
     77        TaskEquality equality = getEquality(task1, task2, TaskEquality.SYNTACTICALLY_EQUAL); 
     78        return (equality != null) && (equality.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 
     79    } 
     80 
     81    /* (non-Javadoc) 
     82     * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask) 
     83     */ 
     84    @Override 
     85    public boolean areSemanticallyEqual(ITask task1, ITask task2) { 
     86        TaskEquality equality = getEquality(task1, task2, TaskEquality.SEMANTICALLY_EQUAL); 
     87        return (equality != null) && (equality.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 
     88    } 
     89 
     90    /* (non-Javadoc) 
     91     * @see NodeComparisonRule#compare(ITask, ITask) 
     92     */ 
     93    @Override 
     94    public TaskEquality compare(ITask task1, ITask task2) { 
     95        return getEquality(task1, task2, null); 
    9696    } 
    9797 
     
    9999     *  
    100100     */ 
    101     private NodeEquality getEquality(ITaskTreeNode node1, 
    102                                      ITaskTreeNode node2, 
    103                                      NodeEquality  requiredEqualityLevel) 
    104     { 
    105         List<ITaskTreeNode> children1 = node1.getChildren(); 
    106         List<ITaskTreeNode> children2 = node2.getChildren(); 
     101    private TaskEquality getEquality(ITask task1, ITask task2, TaskEquality requiredEqualityLevel) { 
     102        List<ITask> children1 = ((ISelection) task1).getChildren(); 
     103        List<ITask> children2 = ((ISelection) task2).getChildren(); 
    107104 
    108105        // if both selections do not have children, they are lexically equal. If only one of them 
    109106        // has children, they are unequal. 
    110107        if ((children1.size() == 0) && (children2.size() == 0)) { 
    111             return NodeEquality.LEXICALLY_EQUAL; 
     108            return TaskEquality.LEXICALLY_EQUAL; 
    112109        } 
    113110        else if ((children1.size() == 0) || (children2.size() == 0)) { 
    114             return NodeEquality.UNEQUAL; 
    115         } 
    116  
    117         NodeEquality selectionEquality; 
     111            return TaskEquality.UNEQUAL; 
     112        } 
     113 
     114        TaskEquality selectionEquality; 
    118115 
    119116        if (requiredEqualityLevel == null) { 
     
    121118            // do it in both directions to ensure commutative comparison 
    122119            selectionEquality = getCommonEqualityLevel(children1, children2); 
    123             if (selectionEquality != NodeEquality.UNEQUAL) { 
     120            if (selectionEquality != TaskEquality.UNEQUAL) { 
    124121                return selectionEquality.getCommonDenominator 
    125122                    (getCommonEqualityLevel(children2, children1)); 
    126123            } 
    127124            else { 
    128                 return NodeEquality.UNEQUAL; 
     125                return TaskEquality.UNEQUAL; 
    129126            } 
    130127        } 
     
    137134            } 
    138135            else { 
    139                 return NodeEquality.UNEQUAL; 
     136                return TaskEquality.UNEQUAL; 
    140137            } 
    141138        } 
     
    151148     * @param requiredEqualityLevel 
    152149     */ 
    153     private NodeEquality getCommonEqualityLevel(List<ITaskTreeNode> children1, 
    154                                                 List<ITaskTreeNode> children2) 
    155     { 
    156         NodeEquality listEquality = NodeEquality.LEXICALLY_EQUAL; 
     150    private TaskEquality getCommonEqualityLevel(List<ITask> children1, List<ITask> children2) { 
     151        TaskEquality listEquality = TaskEquality.LEXICALLY_EQUAL; 
    157152         
    158         NodeEquality childEquality; 
    159         NodeEquality currentEquality; 
    160         for (ITaskTreeNode child1 : children1) { 
     153        TaskEquality childEquality; 
     154        TaskEquality currentEquality; 
     155        for (ITask child1 : children1) { 
    161156            childEquality = null; 
    162             for (ITaskTreeNode child2 : children2) { 
     157            for (ITask child2 : children2) { 
    163158                currentEquality = callRuleManager(child1, child2, null); 
    164                 if ((currentEquality != null) && (currentEquality != NodeEquality.UNEQUAL)) { 
     159                if ((currentEquality != null) && (currentEquality != TaskEquality.UNEQUAL)) { 
    165160                    if (childEquality == null) { 
    166161                        childEquality = currentEquality; 
     
    170165                    } 
    171166                     
    172                     if (childEquality == NodeEquality.SEMANTICALLY_EQUAL) { 
     167                    if (childEquality == TaskEquality.SEMANTICALLY_EQUAL) { 
    173168                        // as we calculate only the common denominator, we can break up here for 
    174169                        // the current child. We will not improve the denominator anymore 
     
    181176                // we did not find any child in the second list, that is equal to the searched 
    182177                // child 
    183                 return NodeEquality.UNEQUAL; 
     178                return TaskEquality.UNEQUAL; 
    184179            } 
    185180            else { 
     
    200195     * @param requiredEqualityLevel 
    201196     */ 
    202     private boolean checkEqualityLevel(List<ITaskTreeNode> children1, 
    203                                        List<ITaskTreeNode> children2, 
    204                                        NodeEquality        requiredEqualityLevel) 
     197    private boolean checkEqualityLevel(List<ITask> children1, 
     198                                       List<ITask> children2, 
     199                                       TaskEquality requiredEqualityLevel) 
    205200    { 
    206         NodeEquality childEquality; 
    207         NodeEquality currentEquality; 
    208         for (ITaskTreeNode child1 : children1) { 
     201        TaskEquality childEquality; 
     202        TaskEquality currentEquality; 
     203        for (ITask child1 : children1) { 
    209204            childEquality = null; 
    210             for (ITaskTreeNode child2 : children2) { 
     205            for (ITask child2 : children2) { 
    211206                currentEquality = callRuleManager(child1, child2, requiredEqualityLevel); 
    212207                if ((currentEquality != null) && (currentEquality.isAtLeast(requiredEqualityLevel))) 
     
    240235     * @return 
    241236     */ 
    242     private NodeEquality callRuleManager(ITaskTreeNode child1, 
    243                                          ITaskTreeNode child2, 
    244                                          NodeEquality requiredEqualityLevel) 
     237    private TaskEquality callRuleManager(ITask        child1, 
     238                                         ITask        child2, 
     239                                         TaskEquality requiredEqualityLevel) 
    245240    { 
    246241        if (requiredEqualityLevel == null) { 
     
    251246        } 
    252247        else { 
    253             return NodeEquality.UNEQUAL; 
     248            return TaskEquality.UNEQUAL; 
    254249        } 
    255250    } 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/SequenceComparisonRule.java

    r1125 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1616 
    1717import java.util.List; 
    1818 
    1919import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 
    20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
     20import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    2121 
    2222/** 
     
    3131 * @author 2012, last modified by $Author: patrick$ 
    3232 */ 
    33 public class SequenceComparisonRule implements NodeComparisonRule { 
     33public class SequenceComparisonRule implements TaskComparisonRule { 
    3434 
    35     /** the rule manager for internally comparing task tree nodes */ 
    36     private NodeEqualityRuleManager mRuleManager; 
     35    /** the rule manager for internally comparing tasks */ 
     36    private TaskEqualityRuleManager mRuleManager; 
    3737 
    3838    /** 
    3939     * <p> 
    40      * simple constructor to provide the rule with the node equality rule manager to be able 
    41      * to perform comparisons of the children of provided task tree nodes 
     40     * simple constructor to provide the rule with the task equality rule manager to be able 
     41     * to perform comparisons of the children of provided tasks 
    4242     * </p> 
    4343     *  
    44      * @param ruleManager the rule manager for comparing task tree nodes 
     44     * @param ruleManager the rule manager for comparing tasks 
    4545     */ 
    46     SequenceComparisonRule(NodeEqualityRuleManager ruleManager) { 
     46    SequenceComparisonRule(TaskEqualityRuleManager ruleManager) { 
    4747        super(); 
    4848        mRuleManager = ruleManager; 
     
    5050 
    5151    /* (non-Javadoc) 
    52      * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 
     52     * @see NodeComparisonRule#isApplicable(ITask, ITask) 
    5353     */ 
    5454    @Override 
    55     public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 
    56         return (node1 instanceof ISequence) && (node2 instanceof ISequence); 
     55    public boolean isApplicable(ITask task1, ITask task2) { 
     56        return (task1 instanceof ISequence) && (task2 instanceof ISequence); 
    5757    } 
    5858 
    5959    /* (non-Javadoc) 
    60      * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 
     60     * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask) 
    6161     */ 
    6262    @Override 
    63     public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    64         NodeEquality equality = getEquality(node1, node2, NodeEquality.LEXICALLY_EQUAL); 
    65         return (equality != null) && (equality.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 
     63    public boolean areLexicallyEqual(ITask task1, ITask task2) { 
     64        TaskEquality equality = getEquality(task1, task2, TaskEquality.LEXICALLY_EQUAL); 
     65        return (equality != null) && (equality.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 
    6666    } 
    6767 
    6868    /* (non-Javadoc) 
    69      * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     69     * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask) 
    7070     */ 
    7171    @Override 
    72     public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    73         NodeEquality equality = getEquality(node1, node2, NodeEquality.SYNTACTICALLY_EQUAL); 
    74         return (equality != null) && (equality.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 
     72    public boolean areSyntacticallyEqual(ITask task1, ITask task2) { 
     73        TaskEquality equality = getEquality(task1, task2, TaskEquality.SYNTACTICALLY_EQUAL); 
     74        return (equality != null) && (equality.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 
    7575    } 
    7676 
    7777    /* (non-Javadoc) 
    78      * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     78     * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask) 
    7979     */ 
    8080    @Override 
    81     public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    82         NodeEquality equality = getEquality(node1, node2, NodeEquality.SEMANTICALLY_EQUAL); 
    83         return (equality != null) && (equality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 
     81    public boolean areSemanticallyEqual(ITask task1, ITask task2) { 
     82        TaskEquality equality = getEquality(task1, task2, TaskEquality.SEMANTICALLY_EQUAL); 
     83        return (equality != null) && (equality.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 
    8484    } 
    8585 
    8686    /* (non-Javadoc) 
    87      * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 
     87     * @see NodeComparisonRule#compare(ITask, ITask) 
    8888     */ 
    8989    @Override 
    90     public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
    91         return getEquality(node1, node2, null); 
     90    public TaskEquality compare(ITask task1, ITask task2) { 
     91        return getEquality(task1, task2, null); 
    9292    } 
    9393 
     
    9595     *  
    9696     */ 
    97     private NodeEquality getEquality(ITaskTreeNode node1, 
    98                                      ITaskTreeNode node2, 
    99                                      NodeEquality  requiredEqualityLevel) 
    100     { 
    101         List<ITaskTreeNode> children1 = node1.getChildren(); 
    102         List<ITaskTreeNode> children2 = node2.getChildren(); 
     97    private TaskEquality getEquality(ITask task1, ITask task2, TaskEquality requiredEqualityLevel) { 
     98        List<ITask> children1 = ((ISequence) task1).getChildren(); 
     99        List<ITask> children2 = ((ISequence) task2).getChildren(); 
    103100 
    104101        // if both sequences do not have children, they are equal although this doesn't make sense 
    105102        if ((children1.size() == 0) && (children2.size() == 0)) { 
    106             return NodeEquality.LEXICALLY_EQUAL; 
     103            return TaskEquality.LEXICALLY_EQUAL; 
    107104        } 
    108105 
    109106        if (children1.size() != children2.size()) { 
    110             return NodeEquality.UNEQUAL; 
     107            return TaskEquality.UNEQUAL; 
    111108        } 
    112109 
    113         NodeEquality resultingEquality = NodeEquality.LEXICALLY_EQUAL; 
     110        TaskEquality resultingEquality = TaskEquality.LEXICALLY_EQUAL; 
    114111        for (int i = 0; i < children1.size(); i++) { 
    115             ITaskTreeNode child1 = children1.get(i); 
    116             ITaskTreeNode child2 = children2.get(i); 
     112            ITask child1 = children1.get(i); 
     113            ITask child2 = children2.get(i); 
    117114 
    118             NodeEquality nodeEquality = callRuleManager(child1, child2, requiredEqualityLevel); 
     115            TaskEquality taskEquality = callRuleManager(child1, child2, requiredEqualityLevel); 
    119116 
    120             if ((nodeEquality == null) || (nodeEquality == NodeEquality.UNEQUAL)) { 
    121                 return NodeEquality.UNEQUAL; 
     117            if ((taskEquality == null) || (taskEquality == TaskEquality.UNEQUAL)) { 
     118                return TaskEquality.UNEQUAL; 
    122119            } 
    123120             
    124             resultingEquality = resultingEquality.getCommonDenominator(nodeEquality); 
     121            resultingEquality = resultingEquality.getCommonDenominator(taskEquality); 
    125122        } 
    126123 
     
    138135     * @return 
    139136     */ 
    140     private NodeEquality callRuleManager(ITaskTreeNode child1, 
    141                                          ITaskTreeNode child2, 
    142                                          NodeEquality requiredEqualityLevel) 
     137    private TaskEquality callRuleManager(ITask        child1, 
     138                                         ITask        child2, 
     139                                         TaskEquality requiredEqualityLevel) 
    143140    { 
    144141        if (requiredEqualityLevel == null) { 
     
    149146        } 
    150147        else { 
    151             return NodeEquality.UNEQUAL; 
     148            return TaskEquality.UNEQUAL; 
    152149        } 
    153150    } 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskAndIterationComparisonRule.java

    r1125 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
    16  
    17 import java.util.List; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1816 
    1917import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 
    20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
     18import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    2119 
    2220/** 
    2321 * <p> 
    24  * This class is capable of comparing any task tree node which is not an iteration with an 
    25  * iteration. This is needed, because iterations may iterate exactly that node. In this 
    26  * case, the iteration would be equal to that node if it was executed exactly once. The rule 
    27  * returns lexically equal, it the child of the iteration is lexically equal to the node 
     22 * This class is capable of comparing any task which is not an iteration with an 
     23 * iteration. This is needed, because iterations may iterate exactly that task. In this 
     24 * case, the iteration would be equal to that task if it was executed exactly once. The rule 
     25 * returns lexically equal, it the child of the iteration is lexically equal to the task 
    2826 * or if the child of the iteration is a selection and this selections contains a lexically equal 
    29  * node. The same applies for syntactical and semantical equality. 
     27 * task. The same applies for syntactical and semantical equality. 
    3028 * </p> 
    3129 
    3230 * @author Patrick Harms 
    3331 */ 
    34 public class NodeAndIterationComparisonRule implements NodeComparisonRule { 
     32public class TaskAndIterationComparisonRule implements TaskComparisonRule { 
    3533     
    36     /** the rule manager for internally comparing task tree nodes */ 
    37     private NodeEqualityRuleManager mRuleManager; 
     34    /** the rule manager for internally comparing tasks */ 
     35    private TaskEqualityRuleManager mRuleManager; 
    3836 
    3937    /** 
    4038     * <p> 
    41      * simple constructor to provide the rule with the node equality rule manager to be able 
    42      * to perform comparisons of the children of provided task tree nodes 
     39     * simple constructor to provide the rule with the task equality rule manager to be able 
     40     * to perform comparisons of the children of provided tasks 
    4341     * </p> 
    4442     *  
    45      * @param ruleManager the rule manager for comparing task tree nodes 
     43     * @param ruleManager the rule manager for comparing tasks 
    4644     */ 
    47     NodeAndIterationComparisonRule(NodeEqualityRuleManager ruleManager) { 
     45    TaskAndIterationComparisonRule(TaskEqualityRuleManager ruleManager) { 
    4846        super(); 
    4947        mRuleManager = ruleManager; 
     
    5149 
    5250    /* (non-Javadoc) 
    53      * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 
     51     * @see NodeComparisonRule#isApplicable(ITask, ITask) 
    5452     */ 
    5553    @Override 
    56     public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 
    57         return ((node1 instanceof IIteration) && (!(node2 instanceof IIteration))) || 
    58                ((node2 instanceof IIteration) && (!(node1 instanceof IIteration))); 
     54    public boolean isApplicable(ITask task1, ITask task2) { 
     55        return ((task1 instanceof IIteration) && (!(task2 instanceof IIteration))) || 
     56               ((task2 instanceof IIteration) && (!(task1 instanceof IIteration))); 
    5957    } 
    6058 
    6159    /* (non-Javadoc) 
    62      * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 
     60     * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask) 
    6361     */ 
    6462    @Override 
    65     public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    66         NodeEquality equality = getEquality(node1, node2, NodeEquality.LEXICALLY_EQUAL); 
    67         return (equality != null) && (equality.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 
     63    public boolean areLexicallyEqual(ITask task1, ITask task2) { 
     64        TaskEquality equality = getEquality(task1, task2, TaskEquality.LEXICALLY_EQUAL); 
     65        return (equality != null) && (equality.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 
    6866    } 
    6967 
    7068    /* (non-Javadoc) 
    71      * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     69     * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask) 
    7270     */ 
    7371    @Override 
    74     public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    75         NodeEquality equality = getEquality(node1, node2, NodeEquality.SYNTACTICALLY_EQUAL); 
    76         return (equality != null) && (equality.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 
     72    public boolean areSyntacticallyEqual(ITask task1, ITask task2) { 
     73        TaskEquality equality = getEquality(task1, task2, TaskEquality.SYNTACTICALLY_EQUAL); 
     74        return (equality != null) && (equality.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 
    7775    } 
    7876 
    7977    /* (non-Javadoc) 
    80      * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     78     * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask) 
    8179     */ 
    8280    @Override 
    83     public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    84         NodeEquality equality = getEquality(node1, node2, NodeEquality.SEMANTICALLY_EQUAL); 
    85         return (equality != null) && (equality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 
     81    public boolean areSemanticallyEqual(ITask task1, ITask task2) { 
     82        TaskEquality equality = getEquality(task1, task2, TaskEquality.SEMANTICALLY_EQUAL); 
     83        return (equality != null) && (equality.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 
    8684    } 
    8785 
    8886    /* (non-Javadoc) 
    89      * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 
     87     * @see NodeComparisonRule#compare(ITask, ITask) 
    9088     */ 
    9189    @Override 
    92     public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
    93         return getEquality(node1, node2, null); 
     90    public TaskEquality compare(ITask task1, ITask task2) { 
     91        return getEquality(task1, task2, null); 
    9492    } 
    9593 
     
    9795     *  
    9896     */ 
    99     private NodeEquality getEquality(ITaskTreeNode node1, 
    100                                      ITaskTreeNode node2, 
    101                                      NodeEquality  requiredEqualityLevel) 
    102     { 
     97    private TaskEquality getEquality(ITask task1, ITask task2, TaskEquality requiredEqualityLevel) { 
    10398        IIteration iteration = null; 
    104         ITaskTreeNode node = null; 
     99        ITask task = null; 
    105100         
    106         if (node1 instanceof IIteration) { 
    107             if (node2 instanceof IIteration) { 
     101        if (task1 instanceof IIteration) { 
     102            if (task2 instanceof IIteration) { 
    108103                // the rule is not responsible for two iterations 
    109104                return null; 
    110105            } 
    111106             
    112             iteration = (IIteration) node1; 
    113             node = node2; 
     107            iteration = (IIteration) task1; 
     108            task = task2; 
    114109        } 
    115         else if (node2 instanceof IIteration) { 
    116             if (node1 instanceof IIteration) { 
     110        else if (task2 instanceof IIteration) { 
     111            if (task1 instanceof IIteration) { 
    117112                // the rule is not responsible for two iterations 
    118113                return null; 
    119114            } 
    120115             
    121             iteration = (IIteration) node2; 
    122             node = node1; 
     116            iteration = (IIteration) task2; 
     117            task = task1; 
    123118        } 
    124119        else { 
     
    126121        } 
    127122 
    128         List<ITaskTreeNode> children = iteration.getChildren(); 
     123        ITask child = iteration.getMarkedTask(); 
    129124         
    130         // now, that we found the iteration and the node, lets compare the child of the iteration 
    131         // with the node. 
    132         if (children.size() < 1) { 
     125        // now, that we found the iteration and the task, lets compare the child of the iteration 
     126        // with the task. 
     127        if (child == null) { 
    133128            return null; 
    134129        } 
    135130 
    136         NodeEquality nodeEquality = callRuleManager(children.get(0), node, requiredEqualityLevel); 
     131        TaskEquality taskEquality = callRuleManager(child, task, requiredEqualityLevel); 
    137132 
    138         // although the subtask may be identical to the node, we can not return identical, as 
    139         // the iteration is not identical to the node, but at most lexically equal 
    140         if (nodeEquality == NodeEquality.IDENTICAL) { 
    141             return NodeEquality.LEXICALLY_EQUAL; 
     133        // although the subtask may be identical to the task, we can not return identical, as 
     134        // the iteration is not identical to the task, but at most lexically equal 
     135        if (taskEquality == TaskEquality.IDENTICAL) { 
     136            return TaskEquality.LEXICALLY_EQUAL; 
    142137        } 
    143138        else { 
    144             return nodeEquality; 
     139            return taskEquality; 
    145140        } 
    146141 
     
    157152     * @return 
    158153     */ 
    159     private NodeEquality callRuleManager(ITaskTreeNode child1, 
    160                                          ITaskTreeNode child2, 
    161                                          NodeEquality requiredEqualityLevel) 
     154    private TaskEquality callRuleManager(ITask        child1, 
     155                                         ITask        child2, 
     156                                         TaskEquality requiredEqualityLevel) 
    162157    { 
    163158        if (requiredEqualityLevel == null) { 
     
    168163        } 
    169164        else { 
    170             return NodeEquality.UNEQUAL; 
     165            return TaskEquality.UNEQUAL; 
    171166        } 
    172167    } 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskAndSelectionComparisonRule.java

    r1125 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1616 
    1717import java.util.List; 
    1818 
    1919import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
    20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
     20import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    2121 
    2222/** 
    2323 * <p> 
    24  * This class is capable of comparing any task tree node which is not a selection with a 
    25  * selection. This is needed, because selections may contain exactly that node. Therefore, if 
    26  * this node is selected out of a selection the selection is equal to the node itself.  
    27  * The rule returns lexically equal, it the selection contains a lexically equal node. The same 
     24 * This class is capable of comparing any task which is not a selection with a 
     25 * selection. This is needed, because selections may contain exactly that task. Therefore, if 
     26 * this task is selected out of a selection the selection is equal to the task itself.  
     27 * The rule returns lexically equal, if the selection contains a lexically equal task. The same 
    2828 * applies for syntactical and semantical equality. 
    2929 * </p> 
     
    3131 * @author Patrick Harms 
    3232 */ 
    33 public class NodeAndSelectionComparisonRule implements NodeComparisonRule { 
     33public class TaskAndSelectionComparisonRule implements TaskComparisonRule { 
    3434     
    35     /** the rule manager for internally comparing task tree nodes */ 
    36     private NodeEqualityRuleManager mRuleManager; 
     35    /** the rule manager for internally comparing tasks */ 
     36    private TaskEqualityRuleManager mRuleManager; 
    3737     
    3838    /** 
    3939     * <p> 
    40      * simple constructor to provide the rule with the node equality rule manager to be able 
    41      * to perform comparisons of the children of provided task tree nodes 
     40     * simple constructor to provide the rule with the task equality rule manager to be able 
     41     * to perform comparisons of the children of provided tasks 
    4242     * </p> 
    4343     *  
    44      * @param ruleManager the rule manager for comparing task tree nodes 
     44     * @param ruleManager the rule manager for comparing tasks 
    4545     */ 
    46     NodeAndSelectionComparisonRule(NodeEqualityRuleManager ruleManager) { 
     46    TaskAndSelectionComparisonRule(TaskEqualityRuleManager ruleManager) { 
    4747        super(); 
    4848        mRuleManager = ruleManager; 
     
    5050 
    5151    /* (non-Javadoc) 
    52      * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 
     52     * @see NodeComparisonRule#isApplicable(ITask, ITask) 
    5353     */ 
    5454    @Override 
    55     public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 
    56         return ((node1 instanceof ISelection) && (!(node2 instanceof ISelection))) || 
    57                ((node2 instanceof ISelection) && (!(node1 instanceof ISelection))); 
     55    public boolean isApplicable(ITask task1, ITask task2) { 
     56        return ((task1 instanceof ISelection) && (!(task2 instanceof ISelection))) || 
     57               ((task2 instanceof ISelection) && (!(task1 instanceof ISelection))); 
    5858    } 
    5959 
    6060    /* (non-Javadoc) 
    61      * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 
     61     * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask) 
    6262     */ 
    6363    @Override 
    64     public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    65         NodeEquality equality = getEquality(node1, node2, NodeEquality.LEXICALLY_EQUAL); 
    66         return (equality != null) && (equality.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 
     64    public boolean areLexicallyEqual(ITask task1, ITask task2) { 
     65        TaskEquality equality = getEquality(task1, task2, TaskEquality.LEXICALLY_EQUAL); 
     66        return (equality != null) && (equality.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 
    6767    } 
    6868 
    6969    /* (non-Javadoc) 
    70      * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     70     * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask) 
    7171     */ 
    7272    @Override 
    73     public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    74         NodeEquality equality = getEquality(node1, node2, NodeEquality.SYNTACTICALLY_EQUAL); 
    75         return (equality != null) && (equality.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 
     73    public boolean areSyntacticallyEqual(ITask task1, ITask task2) { 
     74        TaskEquality equality = getEquality(task1, task2, TaskEquality.SYNTACTICALLY_EQUAL); 
     75        return (equality != null) && (equality.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 
    7676    } 
    7777 
    7878    /* (non-Javadoc) 
    79      * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     79     * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask) 
    8080     */ 
    8181    @Override 
    82     public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    83         NodeEquality equality = getEquality(node1, node2, NodeEquality.SEMANTICALLY_EQUAL); 
    84         return (equality != null) && (equality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 
     82    public boolean areSemanticallyEqual(ITask task1, ITask task2) { 
     83        TaskEquality equality = getEquality(task1, task2, TaskEquality.SEMANTICALLY_EQUAL); 
     84        return (equality != null) && (equality.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 
    8585    } 
    8686 
    8787    /* (non-Javadoc) 
    88      * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 
     88     * @see NodeComparisonRule#compare(ITask, ITask) 
    8989     */ 
    9090    @Override 
    91     public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
    92         return getEquality(node1, node2, null); 
     91    public TaskEquality compare(ITask task1, ITask task2) { 
     92        return getEquality(task1, task2, null); 
    9393    } 
    9494     
     
    9696     *  
    9797     */ 
    98     private NodeEquality getEquality(ITaskTreeNode node1, 
    99                                      ITaskTreeNode node2, 
    100                                      NodeEquality  requiredEqualityLevel) 
    101     { 
     98    private TaskEquality getEquality(ITask task1, ITask task2, TaskEquality requiredEqualityLevel) { 
    10299        ISelection selection = null; 
    103         ITaskTreeNode node = null; 
     100        ITask task = null; 
    104101         
    105         if (node1 instanceof ISelection) { 
    106             if (node2 instanceof ISelection) { 
     102        if (task1 instanceof ISelection) { 
     103            if (task2 instanceof ISelection) { 
    107104                // the rule is not responsible for two selections 
    108105                return null; 
    109106            } 
    110107             
    111             selection = (ISelection) node1; 
    112             node = node2; 
     108            selection = (ISelection) task1; 
     109            task = task2; 
    113110        } 
    114         else if (node2 instanceof ISelection) { 
    115             if (node1 instanceof ISelection) { 
     111        else if (task2 instanceof ISelection) { 
     112            if (task1 instanceof ISelection) { 
    116113                // the rule is not responsible for two selections 
    117114                return null; 
    118115            } 
    119116             
    120             selection = (ISelection) node2; 
    121             node = node1; 
     117            selection = (ISelection) task2; 
     118            task = task1; 
    122119        } 
    123120        else { 
     
    125122        } 
    126123 
    127         // now, that we found the selection and the node, lets compare the children of the selection 
    128         // with the node. 
    129         List<ITaskTreeNode> children = selection.getChildren(); 
     124        // now, that we found the selection and the task, lets compare the children of the selection 
     125        // with the task. 
     126        List<ITask> children = selection.getChildren(); 
    130127         
    131128        if (children.size() < 1) { 
     
    133130        } 
    134131 
    135         NodeEquality mostConcreteNodeEquality = null; 
     132        TaskEquality mostConcreteNodeEquality = null; 
    136133         
    137         for (ITaskTreeNode child : children) { 
    138             NodeEquality nodeEquality = callRuleManager(child, node, requiredEqualityLevel); 
     134        for (ITask child : children) { 
     135            TaskEquality taskEquality = callRuleManager(child, task, requiredEqualityLevel); 
    139136             
    140             if (nodeEquality != NodeEquality.UNEQUAL) { 
     137            if (taskEquality != TaskEquality.UNEQUAL) { 
    141138                if (mostConcreteNodeEquality == null) { 
    142                     mostConcreteNodeEquality = nodeEquality; 
     139                    mostConcreteNodeEquality = taskEquality; 
    143140                } 
    144                 else if (mostConcreteNodeEquality.isAtLeast(nodeEquality)) { 
    145                     mostConcreteNodeEquality = nodeEquality; 
     141                else if (mostConcreteNodeEquality.isAtLeast(taskEquality)) { 
     142                    mostConcreteNodeEquality = taskEquality; 
    146143                     
    147144                } 
     
    151148                { 
    152149                    // if we found one child of the selection that is as equal as required, then 
    153                     // we can consider the selection to be sufficiently equal to the other node. 
     150                    // we can consider the selection to be sufficiently equal to the other task. 
    154151                    // So we break up checking further children. 
    155152                    break; 
     
    158155        } 
    159156         
    160         // although the subtask may be identical to the node, we can not return identical, as 
    161         // the selection is not identical to the node, but at most lexically equal 
    162         if (mostConcreteNodeEquality == NodeEquality.IDENTICAL) { 
    163             return NodeEquality.LEXICALLY_EQUAL; 
     157        // although the subtask may be identical to the task, we can not return identical, as 
     158        // the selection is not identical to the task, but at most lexically equal 
     159        if (mostConcreteNodeEquality == TaskEquality.IDENTICAL) { 
     160            return TaskEquality.LEXICALLY_EQUAL; 
    164161        } 
    165162        else { 
     
    179176     * @return 
    180177     */ 
    181     private NodeEquality callRuleManager(ITaskTreeNode child1, 
    182                                          ITaskTreeNode child2, 
    183                                          NodeEquality requiredEqualityLevel) 
     178    private TaskEquality callRuleManager(ITask        child1, 
     179                                         ITask        child2, 
     180                                         TaskEquality requiredEqualityLevel) 
    184181    { 
    185182        if (requiredEqualityLevel == null) { 
     
    190187        } 
    191188        else { 
    192             return NodeEquality.UNEQUAL; 
     189            return TaskEquality.UNEQUAL; 
    193190        } 
    194191    } 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskComparator.java

    r1129 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.temporalrelation; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1616 
    1717import java.util.HashMap; 
    1818 
    19 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEquality; 
    20 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEqualityRuleManager; 
    21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
     19import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     20import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 
    2221import de.ugoe.cs.autoquest.usageprofiles.SymbolComparator; 
    2322import de.ugoe.cs.util.StopWatch; 
     
    3029 * @author Patrick Harms 
    3130 */ 
    32 public class TaskTreeNodeComparator implements SymbolComparator<ITaskTreeNode> { 
     31public class TaskComparator implements SymbolComparator<ITaskInstance> { 
    3332     
    3433    /** 
    3534     * <p> 
    36      * the node equality manager needed for comparing task tree nodes with each other 
     35     * the task equality manager needed for comparing tasks with each other 
    3736     * </p> 
    3837     */ 
    39     private NodeEqualityRuleManager nodeEqualityRuleManager; 
     38    private TaskEqualityRuleManager taskEqualityRuleManager; 
    4039 
    4140    /** 
    4241     * <p> 
    43      * the minimal node equality two identified sublists need to have to consider them as equal 
    44      * and to create an iteration for 
     42     * the minimal task equality two identified sublists need to have to consider them as equal 
    4543     * </p> 
    4644     */ 
    47     private NodeEquality minimalNodeEquality; 
    48  
     45    private TaskEquality minimalNodeEquality; 
     46 
     47    /** */ 
    4948    private Comparer comparer; 
    5049 
     50    /** */ 
    5151    private Comparer lexicalComparer; 
    5252 
     53    /** */ 
    5354    private StopWatch stopWatch = new StopWatch(); 
    5455     
     56    /** */ 
    5557    private HashMap<Long, Boolean> equalityBuffer = new HashMap<Long, Boolean>(); 
    5658 
     59    /** */ 
    5760    private HashMap<Long, Boolean> lexicalEqualityBuffer; 
    5861 
    5962    /** 
    60      * <p> 
    61      * TODO: comment 
    62      * </p> 
    63      * 
    64      * @param nodeEqualityRuleManager 
    65      * @param minimalNodeEquality 
    66      */ 
    67     public TaskTreeNodeComparator(NodeEqualityRuleManager nodeEqualityRuleManager, 
    68                                   NodeEquality            minimalNodeEquality) 
     63     * 
     64     */ 
     65    public TaskComparator(TaskEqualityRuleManager taskEqualityRuleManager, 
     66                                  TaskEquality            minimalNodeEquality) 
    6967    { 
    7068        super(); 
    71         this.nodeEqualityRuleManager = nodeEqualityRuleManager; 
     69        this.taskEqualityRuleManager = taskEqualityRuleManager; 
    7270        this.minimalNodeEquality = minimalNodeEquality; 
    7371         
    74         if (minimalNodeEquality == NodeEquality.LEXICALLY_EQUAL) { 
     72        if (minimalNodeEquality == TaskEquality.LEXICALLY_EQUAL) { 
    7573            comparer = new LexicalComparer(); 
    7674        } 
    77         else if (minimalNodeEquality == NodeEquality.SYNTACTICALLY_EQUAL) { 
     75        else if (minimalNodeEquality == TaskEquality.SYNTACTICALLY_EQUAL) { 
    7876            comparer = new SyntacticalComparer(); 
    7977        } 
    80         else if (minimalNodeEquality == NodeEquality.SEMANTICALLY_EQUAL) { 
     78        else if (minimalNodeEquality == TaskEquality.SEMANTICALLY_EQUAL) { 
    8179            comparer = new SemanticalComparer(); 
    8280        } 
     
    8583        } 
    8684         
    87         if (minimalNodeEquality == NodeEquality.LEXICALLY_EQUAL) { 
     85        if (minimalNodeEquality == TaskEquality.LEXICALLY_EQUAL) { 
    8886            lexicalComparer = comparer; 
    8987            lexicalEqualityBuffer = equalityBuffer; 
     
    9997     */ 
    10098    @Override 
    101     public boolean equals(ITaskTreeNode symbol1, ITaskTreeNode symbol2) { 
    102         //String id = "compare " + symbol1.getClass().getSimpleName() + " " + 
    103         //    symbol2.getClass().getSimpleName(); 
     99    public boolean equals(ITaskInstance taskInstance1, ITaskInstance taskInstance2) { 
     100        return equals(taskInstance1.getTask(), taskInstance2.getTask()); 
     101    }         
     102 
     103    /** 
     104     *  
     105     */ 
     106    public boolean equals(ITask task1, ITask task2) { 
     107        //String id = "compare " + taskInstance1.getClass().getSimpleName() + " " + 
     108        //    taskInstance2.getClass().getSimpleName(); 
    104109        //String id = "compare"; 
    105110        //stopWatch.start(id); 
     
    107112        Boolean result; 
    108113         
    109         if (symbol1 != symbol2) { 
    110             long key = ((long) System.identityHashCode(symbol1)) << 32; 
    111             key += System.identityHashCode(symbol2); 
     114        if (task1 != task2) { 
     115            long key = ((long) System.identityHashCode(task1)) << 32; 
     116            key += System.identityHashCode(task2); 
    112117             
    113118            result = equalityBuffer.get(key); 
    114119             
    115120            if (result == null) { 
    116                 result = comparer.compare(symbol1, symbol2); 
     121                result = comparer.compare(task1, task2); 
    117122                equalityBuffer.put(key, result); 
    118123            } 
     
    123128        //stopWatch.stop(id); 
    124129         
    125         /*boolean result2 = nodeEqualityRuleManager.areAtLeastEqual(symbol1, symbol2, minimalNodeEquality); 
     130        /*boolean result2 = taskEqualityRuleManager.areAtLeastEqual(symbol1, symbol2, minimalNodeEquality); 
    126131        if (result != result2) { 
    127132            throw new IllegalStateException("implementation error"); 
     
    132137 
    133138    /** 
    134      * <p> 
    135      * TODO: comment 
    136      * </p> 
    137      * 
    138      * @return 
     139     * 
     140     */ 
     141    public boolean haveLexicallyEqualTasks(ITaskInstance taskInstance1, 
     142                                           ITaskInstance taskInstance2) 
     143    { 
     144        return areLexicallyEqual(taskInstance1.getTask(), taskInstance2.getTask()); 
     145    } 
     146         
     147 
     148    /** 
     149     * 
     150     */ 
     151    public boolean areLexicallyEqual(ITask task1, ITask task2) { 
     152        Boolean result; 
     153         
     154        if (task1 != task2) { 
     155            long key = ((long) System.identityHashCode(task1)) << 32; 
     156            key += System.identityHashCode(task2); 
     157             
     158            result = lexicalEqualityBuffer.get(key); 
     159             
     160            if (result == null) { 
     161                result = lexicalComparer.compare(task1, task2); 
     162                lexicalEqualityBuffer.put(key, result); 
     163            } 
     164        } 
     165        else { 
     166            result = true; 
     167        } 
     168         
     169        return result; 
     170    } 
     171 
     172    /** 
     173     * 
    139174     */ 
    140175    StopWatch getStopWatch() { 
     
    143178 
    144179    /** 
    145      * <p> 
    146      * TODO: comment 
    147      * </p> 
    148      * 
    149      * @param node1 
    150      * @param node2 
    151      * @return 
    152      */ 
    153     boolean areLexicallyEqual(ITaskTreeNode symbol1, ITaskTreeNode symbol2) { 
    154         Boolean result; 
    155          
    156         if (symbol1 != symbol2) { 
    157             long key = ((long) System.identityHashCode(symbol1)) << 32; 
    158             key += System.identityHashCode(symbol2); 
    159              
    160             result = lexicalEqualityBuffer.get(key); 
    161              
    162             if (result == null) { 
    163                 result = lexicalComparer.compare(symbol1, symbol2); 
    164                 lexicalEqualityBuffer.put(key, result); 
    165             } 
    166         } 
    167         else { 
    168             result = true; 
    169         } 
    170          
    171         return result; 
    172     } 
    173  
    174     /** 
    175      * <p> 
    176      * TODO: comment 
    177      * </p> 
    178      * 
    179      * @return 
    180      */ 
    181     NodeEquality getConsideredNodeEquality() { 
     180     * 
     181     */ 
     182    TaskEquality getConsideredNodeEquality() { 
    182183        return minimalNodeEquality; 
    183184    } 
     
    190191         *  
    191192         */ 
    192         boolean compare(ITaskTreeNode node1, ITaskTreeNode node2); 
     193        boolean compare(ITask task1, ITask task2); 
    193194    } 
    194195 
     
    201202         *  
    202203         */ 
    203         public boolean compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
    204             return nodeEqualityRuleManager.areLexicallyEqual(node1, node2); 
     204        public boolean compare(ITask task1, ITask task2) { 
     205            return taskEqualityRuleManager.areLexicallyEqual(task1, task2); 
    205206        } 
    206207    } 
     
    214215         *  
    215216         */ 
    216         public boolean compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
    217             return nodeEqualityRuleManager.areSyntacticallyEqual(node1, node2); 
     217        public boolean compare(ITask task1, ITask task2) { 
     218            return taskEqualityRuleManager.areSyntacticallyEqual(task1, task2); 
    218219        } 
    219220    } 
     
    227228         *  
    228229         */ 
    229         public boolean compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
    230             return nodeEqualityRuleManager.areSemanticallyEqual(node1, node2); 
     230        public boolean compare(ITask task1, ITask task2) { 
     231            return taskEqualityRuleManager.areSemanticallyEqual(task1, task2); 
    231232        } 
    232233    } 
     
    240241         *  
    241242         */ 
    242         public boolean compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
    243             return nodeEqualityRuleManager.areAtLeastEqual(node1, node2, minimalNodeEquality); 
     243        public boolean compare(ITask task1, ITask task2) { 
     244            return taskEqualityRuleManager.areAtLeastEqual(task1, task2, minimalNodeEquality); 
    244245        } 
    245246    } 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskComparisonRule.java

    r1125 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1616 
    17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
     17import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    1818 
    1919/** 
    2020 * <p> 
    21  * A node comparison rule is used by the {@link NodeEqualityRuleManager} to compare task tree 
    22  * nodes with each other. It provides one method to be called for a comparison. 
     21 * A task comparison rule is used by the {@link TaskEqualityRuleManager} to compare tasks with 
     22 * each other. It provides several methods to be called for a comparison. 
    2323 * </p> 
    2424 *  
     
    2626 * @author 2012, last modified by $Author: patrick$ 
    2727 */ 
    28 public interface NodeComparisonRule { 
     28public interface TaskComparisonRule { 
    2929 
    3030    /** 
    3131     * <p> 
    32      * checks if the rule is applicable for comparing the two provided nodes 
     32     * checks if the rule is applicable for comparing the two provided tasks 
    3333     * </p> 
    3434     *  
    35      * @param node1 the first task tree node to compare 
    36      * @param node2 the second task tree node to compare 
     35     * @param task1 the first task to compare 
     36     * @param task2 the second task to compare 
    3737     *  
    3838     * @return true, if the rule is applicable, false else 
    3939     */ 
    40     public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2); 
     40    public boolean isApplicable(ITask task1, ITask task2); 
    4141 
    4242    /** 
    4343     * <p> 
    44      * checks, if the provided nodes are lexically equal 
     44     * checks, if the provided tasks are lexically equal 
    4545     * </p> 
    4646     *  
    47      * @param node1 the first task tree node to compare 
    48      * @param node2 the second task tree node to compare 
     47     * @param task1 the first task to compare 
     48     * @param task2 the second task to compare 
    4949     *  
    50      * @return true, if the nodes are equal, false else 
     50     * @return true, if the tasks are equal, false else 
    5151     */ 
    52     public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2); 
     52    public boolean areLexicallyEqual(ITask task1, ITask task2); 
    5353 
    5454    /** 
    5555     * <p> 
    56      * checks, if the provided nodes are syntactically equal 
     56     * checks, if the provided tasks are syntactically equal 
    5757     * </p> 
    5858     *  
    59      * @param node1 the first task tree node to compare 
    60      * @param node2 the second task tree node to compare 
     59     * @param task1 the first task to compare 
     60     * @param task2 the second task to compare 
    6161     *  
    62      * @return true, if the nodes are equal, false else 
     62     * @return true, if the tasks are equal, false else 
    6363     */ 
    64     public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2); 
     64    public boolean areSyntacticallyEqual(ITask task1, ITask task2); 
    6565 
    6666    /** 
    6767     * <p> 
    68      * checks, if the provided nodes are semantically equal 
     68     * checks, if the provided tasks are semantically equal 
    6969     * </p> 
    7070     *  
    71      * @param node1 the first task tree node to compare 
    72      * @param node2 the second task tree node to compare 
     71     * @param task1 the first task to compare 
     72     * @param task2 the second task to compare 
    7373     *  
    74      * @return true, if the nodes are equal, false else 
     74     * @return true, if the tasks are equal, false else 
    7575     */ 
    76     public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2); 
     76    public boolean areSemanticallyEqual(ITask task1, ITask task2); 
    7777 
    7878    /** 
    7979     * <p> 
    80      * compares two nodes with each other. The result of the method is either a node equality or 
     80     * compares two tasks with each other. The result of the method is either a task equality or 
    8181     * null. If it is null, it means, that the rule is not able to correctly compare the two given 
    82      * nodes 
     82     * tasks 
    8383     * </p> 
    8484     *  
    85      * @param node1 the first task tree node to compare 
    86      * @param node2 the second task tree node to compare 
     85     * @param task1 the first task to compare 
     86     * @param task2 the second task to compare 
    8787     *  
    8888     * @return as described 
    8989     */ 
    90     public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2); 
     90    public TaskEquality compare(ITask task1, ITask task2); 
    9191 
    9292} 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskEquality.java

    r1113 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1616 
    1717/** 
    1818 * <p> 
    19  * A node equality denotes, how equal two task tree nodes are. There are different equality levels 
     19 * A task equality denotes, how equal two tasks are. There are different equality levels 
    2020 * which are similar to the usual design levels of GUI design. These levels are 
    2121 * <ul> 
     
    2626 *       can be performed</li> 
    2727 * </ul> 
    28  * It is not possible to compare two task nodes conceptually. But the other design levels can be 
     28 * It is not possible to compare two tasks conceptually. But the other design levels can be 
    2929 * identified and compared. 
    3030 * </p> 
    3131 * <p> 
    32  * Nodes can be identical. This is the case if in the java virtual machine, their comparison 
     32 * Tasks can be identical. This is the case if in the java virtual machine, their comparison 
    3333 * using the <code>==</code> operator or the equals method return true. 
    3434 * </p> 
    3535 * <p> 
    36  * Nodes are lexically equal, if they represent the same events on a key stroke level to be 
    37  * carried out to execute the task. Identical nodes are also syntactically equal. 
     36 * Tasks are lexically equal, if they represent the same events on a key stroke level to be 
     37 * carried out to execute the task. Identical tasks are also syntactically equal. 
    3838 * </p> 
    3939 * <p> 
     
    4141 * syntactical result is the same. For example, entering the text "hello" into a text field can 
    4242 * be done by entering the letters in their correct order, but also by copying the text into the 
    43  * text field. The syntactical result is the same: The text hello was entered. But the tasks 
     43 * text field. The syntactical result is the same: The text "hello" was entered. But the tasks 
    4444 * lexically differ because the events on key stroke level are different. On the other hand, 
    45  * lexically equal nodes are also syntactically equal.   
     45 * lexically equal tasks are also syntactically equal.   
    4646 * </p> 
    4747 * <p> 
    48  * Task tree nodes are semantically equal, if they execute the same function for editing the 
    49  * concepts. An example are a click on a button and a short cut, both executing the same function. 
    50  * These task tree nodes are syntactically and, therefore, also lexically different, but 
    51  * semantically equal. Syntactically equal task tree nodes are always also semantically equal. 
     48 * Tasks are semantically equal, if they execute the same function for editing the concepts. An 
     49 * example are a click on a button and a short cut, both executing the same function. These tasks 
     50 * are syntactically and, therefore, also lexically different, but semantically equal. 
     51 * Syntactically equal tasks are always also semantically equal. 
    5252 * </p> 
    5353 *  
     
    5555 * @author 2012, last modified by $Author: patrick$ 
    5656 */ 
    57 public enum NodeEquality { 
     57public enum TaskEquality { 
    5858    IDENTICAL, 
    5959    LEXICALLY_EQUAL, 
     
    6464    /** 
    6565     * <p> 
    66      * Checks for the current node equality, if it is at least identical to the 
    67      * provided one or even more concrete. As an example, the node equality identical also 
    68      * indicates, that the nodes are e.g. lexically, syntactically and semantically equal. 
     66     * Checks for the current task equality, if it is at least identical to the 
     67     * provided one or even more concrete. As an example, the task equality identical also 
     68     * indicates, that the tasks are e.g. lexically, syntactically and semantically equal. 
    6969     * Therefore, the method called on <code>IDENTICAL</code> with <code>SEMANTICALLY_EQUAL</code> 
    7070     * as parameter will return true. If this method is called on <code>SYNTACTICALLY_EQUAL</code> 
     
    7272     * </p> 
    7373     * 
    74      * @param nodeEquality the node equality to compare with. 
     74     * @param taskEquality the task equality to compare with. 
    7575     *  
    7676     * @return as described 
    7777     */ 
    78     public boolean isAtLeast(NodeEquality nodeEquality) 
     78    public boolean isAtLeast(TaskEquality taskEquality) 
    7979    { 
    80         switch (nodeEquality) { 
     80        switch (taskEquality) { 
    8181            case IDENTICAL: 
    8282                return 
     
    107107    /** 
    108108     * <p> 
    109      * returns the common denominator of this node equality and the provided one. I.e. if one 
     109     * returns the common denominator of this task equality and the provided one. I.e. if one 
    110110     * equality is e.g. syntactical and the other one only semantical, then semantical is returned. 
    111111     * </p> 
    112112     * 
    113113     * @param equality the equality, to compare this with 
    114      * @return 
     114     *  
     115     * @return as described 
    115116     */ 
    116     public NodeEquality getCommonDenominator(NodeEquality otherEquality) { 
     117    public TaskEquality getCommonDenominator(TaskEquality otherEquality) { 
    117118        if (this.isAtLeast(otherEquality)) { 
    118119            return otherEquality; 
     
    122123        } 
    123124        else { 
    124             return NodeEquality.UNEQUAL; 
     125            return TaskEquality.UNEQUAL; 
    125126        } 
    126127    } 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskEqualityRuleManager.java

    r1125 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1616 
    1717import java.util.ArrayList; 
    1818import java.util.List; 
    1919 
    20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
     20import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    2121 
    2222/** 
    2323 * <p> 
    24  * The node equality rule manager is capable of comparing task tree nodes based on its internal list 
    25  * of comparison rules. The current list of rules contains the {@link NodeIdentityRule}, the 
     24 * The task equality rule manager is capable of comparing tasks based on its internal list 
     25 * of comparison rules. The current list of rules contains the {@link TaskIdentityRule}, the 
    2626 * {@link IterationComparisonRule}, the {@link SequenceComparisonRule}, and 
    27  * {@link SelectionComparisonRule}. These rules are asked for comparing the two provided task tree 
    28  * nodes in the mentioned order. If a rule returns a node equality other than null, this equality is 
     27 * {@link SelectionComparisonRule}. These rules are asked for comparing the two provided tasks 
     28 * in the mentioned order. If a rule returns a task equality other than null, this equality is 
    2929 * returned. Otherwise the next rule is asked. 
    3030 * </p> 
     
    3333 * @author 2012, last modified by $Author: patrick$ 
    3434 */ 
    35 public class NodeEqualityRuleManager { 
     35public class TaskEqualityRuleManager { 
    3636 
    3737    /** */ 
    38     private List<NodeComparisonRule> mRuleIndex = null; 
    39  
    40     /** 
    41      * <p> 
    42      * initializes the node equality rule manager by filling the internal list of comparison rules. 
     38    private List<TaskComparisonRule> mRuleIndex = null; 
     39 
     40    /** 
     41     * <p> 
     42     * initializes the task equality rule manager by filling the internal list of comparison rules. 
    4343     * This method must be called before any other method is called on the rule manager. 
    4444     * </p> 
    4545     */ 
    4646    public void init() { 
    47         mRuleIndex = new ArrayList<NodeComparisonRule>(); 
    48         mRuleIndex.add(new NodeIdentityRule()); 
     47        mRuleIndex = new ArrayList<TaskComparisonRule>(); 
     48        mRuleIndex.add(new TaskIdentityRule()); 
    4949        mRuleIndex.add(new GUIEventTaskComparisonRule()); 
    5050        mRuleIndex.add(new EventTaskComparisonRule()); 
     
    5252        mRuleIndex.add(new SequenceComparisonRule(this)); 
    5353        mRuleIndex.add(new SelectionComparisonRule(this)); 
    54         mRuleIndex.add(new NodeAndIterationComparisonRule(this)); 
    55         mRuleIndex.add(new NodeAndSelectionComparisonRule(this)); 
    56     } 
    57  
    58     /** 
    59      * <p> 
    60      * this method performs a comparison of the two provided task tree nodes. It iterates its 
    61      * internal comparison rules. If the first rule returns a node equality other than null, 
     54        mRuleIndex.add(new TaskAndIterationComparisonRule(this)); 
     55        mRuleIndex.add(new TaskAndSelectionComparisonRule(this)); 
     56    } 
     57 
     58    /** 
     59     * <p> 
     60     * this method performs a comparison of the two provided tasks. It iterates its internal 
     61     * comparison rules. If the first rule returns a task equality other than null, 
    6262     * this equality is returned. Otherwise the next rule is tried. If no rule returns an equality 
    6363     * <code>NodeEquality.UNEQUAL</code> is returned. 
    6464     * </p> 
    6565     *  
    66      * @param node1 the first task tree node to be compared 
    67      * @param node2 the second task tree node to be compared 
     66     * @param task1 the first task to be compared 
     67     * @param task2 the second task to be compared 
    6868     *  
    6969     * @return as described 
     
    7272     *                               manager before a call to this method. 
    7373     */ 
    74     public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) 
     74    public TaskEquality compare(ITask task1, ITask task2) 
    7575        throws IllegalStateException 
    7676    { 
     
    7979        } 
    8080         
    81         // LOG.info("checking for equality of " + node1 + " and " + node2); 
    82         NodeEquality nodeEquality = null; 
    83  
    84         for (NodeComparisonRule rule : mRuleIndex) { 
    85             if (rule.isApplicable(node1, node2)) { 
    86                 nodeEquality = rule.compare(node1, node2); 
    87                 if (nodeEquality != null) { 
     81        // LOG.info("checking for equality of " + task1 + " and " + task2); 
     82        TaskEquality taskEquality = null; 
     83 
     84        for (TaskComparisonRule rule : mRuleIndex) { 
     85            if (rule.isApplicable(task1, task2)) { 
     86                taskEquality = rule.compare(task1, task2); 
     87                if (taskEquality != null) { 
    8888                    // LOG.warning("used rule " + rule + " for equality check"); 
    89                     return nodeEquality; 
     89                    return taskEquality; 
    9090                } 
    9191            } 
    9292        } 
    9393 
    94         // LOG.warning("no rule could be applied --> handling nodes as unequal"); 
    95  
    96         return NodeEquality.UNEQUAL; 
     94        // LOG.warning("no rule could be applied --> handling tasks as unequal"); 
     95 
     96        return TaskEquality.UNEQUAL; 
    9797    } 
    9898 
     
    107107     * @return 
    108108     */ 
    109     public boolean areAtLeastEqual(ITaskTreeNode node1, 
    110                                    ITaskTreeNode node2, 
    111                                    NodeEquality  equalityLevel) 
    112     { 
     109    public boolean areAtLeastEqual(ITask task1, ITask task2, TaskEquality equalityLevel) { 
    113110        if (equalityLevel == null) { 
    114111            throw new IllegalArgumentException("required equality level must not be null"); 
     
    117114        switch (equalityLevel) { 
    118115            case IDENTICAL: 
    119                 return areIdentical(node1, node2); 
     116                return areIdentical(task1, task2); 
    120117            case LEXICALLY_EQUAL: 
    121                 return areLexicallyEqual(node1, node2); 
     118                return areLexicallyEqual(task1, task2); 
    122119            case SYNTACTICALLY_EQUAL: 
    123                 return areSyntacticallyEqual(node1, node2); 
     120                return areSyntacticallyEqual(task1, task2); 
    124121            case SEMANTICALLY_EQUAL: 
    125                 return areSemanticallyEqual(node1, node2); 
     122                return areSemanticallyEqual(task1, task2); 
    126123            case UNEQUAL: 
    127                 return !areSemanticallyEqual(node1, node2); 
     124                return !areSemanticallyEqual(task1, task2); 
    128125            default: 
    129126                throw new IllegalArgumentException("unknown required equality: " + equalityLevel); 
     
    140137     * @return 
    141138     */ 
    142     public boolean areIdentical(ITaskTreeNode node1, ITaskTreeNode node2) { 
    143         if (mRuleIndex == null) { 
    144             throw new IllegalStateException("not initialized"); 
    145         } 
    146          
    147         for (NodeComparisonRule rule : mRuleIndex) { 
    148             if (rule.isApplicable(node1, node2) && rule.areLexicallyEqual(node1, node2)) { 
    149                  return true; 
    150             } 
    151         } 
    152  
    153         return false; 
    154     } 
    155  
    156     /** 
    157      * <p> 
    158      * TODO: comment 
    159      * </p> 
    160      * 
    161      * @param child1 
    162      * @param child2 
    163      * @return 
    164      */ 
    165     public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    166         if (mRuleIndex == null) { 
    167             throw new IllegalStateException("not initialized"); 
    168         } 
    169          
    170         for (NodeComparisonRule rule : mRuleIndex) { 
    171             if (rule.isApplicable(node1, node2) && rule.areLexicallyEqual(node1, node2)) { 
    172                  return true; 
    173             } 
    174         } 
    175  
    176         return false; 
    177     } 
    178  
    179     /** 
    180      * <p> 
    181      * TODO: comment 
    182      * </p> 
    183      * 
    184      * @param child1 
    185      * @param child2 
    186      * @return 
    187      */ 
    188     public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    189         if (mRuleIndex == null) { 
    190             throw new IllegalStateException("not initialized"); 
    191         } 
    192          
    193         for (NodeComparisonRule rule : mRuleIndex) { 
    194             if (rule.isApplicable(node1, node2) && rule.areSyntacticallyEqual(node1, node2)) { 
    195                  return true; 
    196             } 
    197         } 
    198  
    199         return false; 
    200     } 
    201  
    202     /** 
    203      * <p> 
    204      * TODO: comment 
    205      * </p> 
    206      * 
    207      * @param child1 
    208      * @param child2 
    209      * @return 
    210      */ 
    211     public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    212         if (mRuleIndex == null) { 
    213             throw new IllegalStateException("not initialized"); 
    214         } 
    215          
    216         for (NodeComparisonRule rule : mRuleIndex) { 
    217             if (rule.isApplicable(node1, node2) && rule.areSemanticallyEqual(node1, node2)) { 
     139    public boolean areIdentical(ITask task1, ITask task2) { 
     140        if (mRuleIndex == null) { 
     141            throw new IllegalStateException("not initialized"); 
     142        } 
     143         
     144        for (TaskComparisonRule rule : mRuleIndex) { 
     145            if (rule.isApplicable(task1, task2) && rule.areLexicallyEqual(task1, task2)) { 
     146                 return true; 
     147            } 
     148        } 
     149 
     150        return false; 
     151    } 
     152 
     153    /** 
     154     * <p> 
     155     * TODO: comment 
     156     * </p> 
     157     * 
     158     * @param child1 
     159     * @param child2 
     160     * @return 
     161     */ 
     162    public boolean areLexicallyEqual(ITask task1, ITask task2) { 
     163        if (mRuleIndex == null) { 
     164            throw new IllegalStateException("not initialized"); 
     165        } 
     166         
     167        for (TaskComparisonRule rule : mRuleIndex) { 
     168            if (rule.isApplicable(task1, task2) && rule.areLexicallyEqual(task1, task2)) { 
     169                 return true; 
     170            } 
     171        } 
     172 
     173        return false; 
     174    } 
     175 
     176    /** 
     177     * <p> 
     178     * TODO: comment 
     179     * </p> 
     180     * 
     181     * @param child1 
     182     * @param child2 
     183     * @return 
     184     */ 
     185    public boolean areSyntacticallyEqual(ITask task1, ITask task2) { 
     186        if (mRuleIndex == null) { 
     187            throw new IllegalStateException("not initialized"); 
     188        } 
     189         
     190        for (TaskComparisonRule rule : mRuleIndex) { 
     191            if (rule.isApplicable(task1, task2) && rule.areSyntacticallyEqual(task1, task2)) { 
     192                 return true; 
     193            } 
     194        } 
     195 
     196        return false; 
     197    } 
     198 
     199    /** 
     200     * <p> 
     201     * TODO: comment 
     202     * </p> 
     203     * 
     204     * @param child1 
     205     * @param child2 
     206     * @return 
     207     */ 
     208    public boolean areSemanticallyEqual(ITask task1, ITask task2) { 
     209        if (mRuleIndex == null) { 
     210            throw new IllegalStateException("not initialized"); 
     211        } 
     212         
     213        for (TaskComparisonRule rule : mRuleIndex) { 
     214            if (rule.isApplicable(task1, task2) && rule.areSemanticallyEqual(task1, task2)) { 
    218215                 return true; 
    219216            } 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskIdentityRule.java

    r1125 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1616 
    17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
     17import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    1818 
    1919/** 
    2020 * <p> 
    21  * This comparison rule returns <code>NodeEquality.IDENTICAL</code> if the comparison of the two 
    22  * task tree nodes using the <code>==</code> operator or the <code>equals</code> method return true. 
    23  * Else it returns null to denote, that it can not compare the nodes. 
     21 * This comparison rule returns <code>TaskEquality.IDENTICAL</code> if the comparison of the two 
     22 * tasks using the <code>==</code> operator or the <code>equals</code> method return true. 
     23 * Else it returns null to denote, that it can not compare the tasks. 
    2424 * </p> 
    2525 *  
     
    2727 * @author 2012, last modified by $Author: patrick$ 
    2828 */ 
    29 public class NodeIdentityRule implements NodeComparisonRule { 
     29public class TaskIdentityRule implements TaskComparisonRule { 
    3030 
    3131    /* (non-Javadoc) 
    32      * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 
     32     * @see NodeComparisonRule#isApplicable(ITask, ITask) 
    3333     */ 
    3434    @Override 
    35     public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 
    36         return (node1 == node2); 
     35    public boolean isApplicable(ITask task1, ITask task2) { 
     36        return (task1 == task2); 
    3737    } 
    3838 
    3939    /* (non-Javadoc) 
    40      * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 
     40     * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask) 
    4141     */ 
    4242    @Override 
    43     public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    44         return (node1 == node2); 
     43    public boolean areLexicallyEqual(ITask task1, ITask task2) { 
     44        return (task1 == task2); 
    4545    } 
    4646 
    4747    /* (non-Javadoc) 
    48      * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     48     * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask) 
    4949     */ 
    5050    @Override 
    51     public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    52         return (node1 == node2); 
     51    public boolean areSyntacticallyEqual(ITask task1, ITask task2) { 
     52        return (task1 == task2); 
    5353    } 
    5454 
    5555    /* (non-Javadoc) 
    56      * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     56     * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask) 
    5757     */ 
    5858    @Override 
    59     public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    60         return (node1 == node2); 
     59    public boolean areSemanticallyEqual(ITask task1, ITask task2) { 
     60        return (task1 == task2); 
    6161    } 
    6262 
    6363    /* (non-Javadoc) 
    64      * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 
     64     * @see NodeComparisonRule#compare(ITask, ITask) 
    6565     */ 
    6666    @Override 
    67     public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
    68         if (isApplicable(node1, node2)) { 
    69             return NodeEquality.IDENTICAL; 
     67    public TaskEquality compare(ITask task1, ITask task2) { 
     68        if (isApplicable(task1, task2)) { 
     69            return TaskEquality.IDENTICAL; 
    7070        } 
    7171        else { 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/ITaskInstanceListScopeRule.java

    r1113 r1146  
    1515package de.ugoe.cs.autoquest.tasktrees.temporalrelation; 
    1616 
    17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
     17import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList; 
    1818 
    1919/** 
    2020 * <p> 
    21  * a temporal relationship rule is able to detected temporal relationships between the child nodes 
    22  * of the parent node provided to the {@link #apply(ITaskTreeNode, boolean)} method. A rule 
    23  * creates temporal relationships between the child nodes, i.e. substructures in the task tree, if 
    24  * it detects a temporal relationship and it can be sure that it is complete. Incomplete but 
    25  * detected temporal relationships may occur, if there can be more children expected to be added 
    26  * to the provided parent node. This could be the case during parsing a interaction log file of 
    27  * a GUI. 
     21 * a task instance list scope rule is able to detected temporal relationships between a list of task 
     22 * instances provided to the {@link #apply(ITaskInstanceList)} method. A rule creates temporal 
     23 * relationships between the task instances, i.e. substructures in the task tree, if 
     24 * it detects a temporal relationship and instantiates the temporal relationships accordingly. 
    2825 * </p> 
    2926 *  
    3027 * @author Patrick Harms 
    3128 */ 
    32 interface TemporalRelationshipRule { 
     29interface ITaskInstanceListScopeRule extends ITemporalRelationshipRule { 
    3330 
    3431  /** 
    3532   * <p> 
    36    * applies the rule to the given parent node. The finalize parameter is used to command the rule 
    37    * to finish rule applications, in the case it is known that no further data will be available.  
    38    * </p> 
    39    * <p> 
    40    * The returned rule application result is null, if the rule can not be applied, i.e. it does not 
    41    * detect a temporal relationship. It returns a rule application result with a status 
    42    * {@link RuleApplicationStatus#RULE_APPLICATION_FINISHED} if the rule was applied. The result 
    43    * contains all newly created parent nodes. It returns a rule application result with status 
    44    * {@link RuleApplicationStatus#RULE_APPLICATION_FEASIBLE} if the rule would be applicable if 
    45    * further children would be available in the parent node. This status MUST not be returned if  
    46    * the finalize parameter is true. In this case the rule must be applied or not.  
     33   * applies the rule to the given task instance list. The returned rule application result is null, 
     34   * if the rule can not be applied, i.e. it does not detect a temporal relationship. It returns a 
     35   * rule application result with a status {@link RuleApplicationStatus#RULE_APPLICATION_FINISHED} 
     36   * if the rule was applied. The result contains all newly created parent tasks and task instances. 
    4737   * </p> 
    4838   *  
    49    * @param parent   the parent node with the children to apply the rule on 
    50    * @param finalize true, if the rule shall not expect further children to come and that it 
    51    *                 should therefore be applied in any case 
     39   * @param taskInstances the list of task instances to apply the rule on 
    5240   *                     
    5341   * @return the rule application result as described. 
    5442   */ 
    55   RuleApplicationResult apply(ITaskTreeNode parent, 
    56                               boolean       finalize); 
     43  RuleApplicationResult apply(ITaskInstanceList taskInstances); 
    5744   
    5845} 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/RuleApplicationResult.java

    r1127 r1146  
    1818import java.util.List; 
    1919 
    20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
     20import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     21import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 
    2122 
    2223/** 
    2324 * <p> 
    24  * The rule application result describes the result of applying a {@link TemporalRelationshipRule} 
    25  * on a task tree node. It contains a {@link RuleApplicationStatus} and a list of all parent 
    26  * task tree nodes that were created during a rule application. See the description of 
    27  * {@link TemporalRelationshipRule} for more details. 
     25 * The rule application result describes the result of applying a {@link ITemporalRelationshipRule}. 
     26 * It contains a {@link RuleApplicationStatus} and a list of all parent task instances and tasks 
     27 * that were created during a rule application. See the description of 
     28 * {@link ITemporalRelationshipRule} for more details. 
    2829 * </p> 
    2930 *  
     
    3637 
    3738    /** */ 
    38     private List<ITaskTreeNode> newParents = new ArrayList<ITaskTreeNode>(); 
     39    private List<ITask> newParentTasks = new ArrayList<ITask>(); 
     40 
     41    /** */ 
     42    private List<ITaskInstance> newParentInstances = new ArrayList<ITaskInstance>(); 
    3943 
    4044    /** 
     
    6771    /** 
    6872     * <p> 
    69      * add a further parent node created during the rule application 
     73     * add a further parent task created during the rule application 
    7074     * </p> 
    7175     */ 
    72     void addNewlyCreatedParentNode(ITaskTreeNode newParent) { 
    73         newParents.add(newParent); 
     76    void addNewlyCreatedTask(ITask newParent) { 
     77        newParentTasks.add(newParent); 
    7478    } 
    7579 
    7680    /** 
    7781     * <p> 
    78      * return all parent nodes created during the rule application 
     82     * return all parent tasks created during the rule application 
    7983     * </p> 
    8084     */ 
    81     List<ITaskTreeNode> getNewlyCreatedParentNodes() { 
    82         return newParents; 
     85    List<ITask> getNewlyCreatedTasks() { 
     86        return newParentTasks; 
     87    } 
     88 
     89    /** 
     90     * <p> 
     91     * add a further parent task instance created during the rule application 
     92     * </p> 
     93     */ 
     94    void addNewlyCreatedTaskInstance(ITaskInstance newParent) { 
     95        newParentInstances.add(newParent); 
     96    } 
     97 
     98    /** 
     99     * <p> 
     100     * return all parent task instances created during the rule application 
     101     * </p> 
     102     */ 
     103    List<ITaskInstance> getNewlyCreatedTaskInstances() { 
     104        return newParentInstances; 
    83105    } 
    84106 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/RuleApplicationStatus.java

    r1127 r1146  
    1717/** 
    1818 * <p> 
    19  * The rule application status describes the result of applying a {@link TemporalRelationshipRule} 
    20  * on a task tree node. See the description of {@link TemporalRelationshipRule} for more details. 
     19 * The rule application status describes the result of applying a {@link ITemporalRelationshipRule}. 
     20 * See the description of {@link ITemporalRelationshipRule} for more details. 
    2121 * </p> 
    2222 *  
     
    2525enum RuleApplicationStatus { 
    2626    FINISHED, 
     27    // TODO drop feasible 
    2728    FEASIBLE, 
    2829    NOT_APPLIED; 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/RuleUtils.java

    r1127 r1146  
    1515package de.ugoe.cs.autoquest.tasktrees.temporalrelation; 
    1616 
    17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 
    18 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder; 
    19 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; 
     17import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     18import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; 
     19import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 
     20import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList; 
     21import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 
    2122 
    2223/** 
     
    3536     *  
    3637     */ 
    37     static ISequence getSubSequenceInRange(ITaskTreeNode        parent, 
    38                                            int                   startIndex, 
    39                                            int                   endIndex, 
    40                                            String                description, 
    41                                            ITaskTreeNodeFactory  nodeFactory, 
    42                                            ITaskTreeBuilder      builder) 
     38    static ITaskInstance getSubSequenceInRange(ITaskInstanceList parent, 
     39                                               int               startIndex, 
     40                                               int               endIndex, 
     41                                               ITask             model, 
     42                                               ITaskFactory      taskFactory, 
     43                                               ITaskBuilder      taskBuilder) 
    4344    { 
    44         ISequence sequence = nodeFactory.createNewSequence(); 
    45         if (description != null) { 
    46             builder.setDescription(sequence, description); 
     45        ITaskInstance subsequence = taskFactory.createNewTaskInstance(model); 
     46 
     47        for (int i = startIndex; i <= endIndex; i++) { 
     48            taskBuilder.addChild(subsequence, parent.get(i)); 
    4749        } 
    4850 
    49         for (int i = startIndex; i <= endIndex; i++) { 
    50             builder.addChild(sequence, parent.getChildren().get(i)); 
    51         } 
    52  
    53         return sequence; 
     51        return subsequence; 
    5452    } 
    5553 
     
    5755     *  
    5856     */ 
    59     static ISequence createNewSubSequenceInRange(ITaskTreeNode        parent, 
    60                                                  int                   startIndex, 
    61                                                  int                   endIndex, 
    62                                                  String                description, 
    63                                                  ITaskTreeNodeFactory  nodeFactory, 
    64                                                  ITaskTreeBuilder      builder) 
     57    static ITaskInstance createNewSubSequenceInRange(ITaskInstanceList parent, 
     58                                                     int               startIndex, 
     59                                                     int               endIndex, 
     60                                                     ITask             model, 
     61                                                     ITaskFactory      taskFactory, 
     62                                                     ITaskBuilder      taskBuilder) 
    6563    { 
    66         ISequence sequence = nodeFactory.createNewSequence(); 
    67         if (description != null) { 
    68             builder.setDescription(sequence, description); 
     64        ITaskInstance subsequence = taskFactory.createNewTaskInstance(model); 
     65 
     66        for (int i = startIndex; i <= endIndex; i++) { 
     67            taskBuilder.addChild(subsequence, parent.get(startIndex)); 
     68            taskBuilder.removeTaskInstance(parent, startIndex); 
    6969        } 
    7070 
    71         for (int i = startIndex; i <= endIndex; i++) { 
    72             builder.addChild(sequence, parent.getChildren().get(startIndex)); 
    73             builder.removeChild((ISequence) parent, startIndex); 
    74         } 
    7571 
    76         builder.addChild((ISequence) parent, startIndex, sequence); 
     72        taskBuilder.addTaskInstance(parent, startIndex, subsequence); 
    7773 
    78         return sequence; 
     74        return subsequence; 
    7975    } 
    8076 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRule.java

    r1133 r1146  
    1515package de.ugoe.cs.autoquest.tasktrees.temporalrelation; 
    1616 
     17import java.util.HashMap; 
    1718import java.util.Iterator; 
    1819import java.util.LinkedList; 
    1920import java.util.List; 
    2021 
    21 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEquality; 
    22 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEqualityRuleManager; 
     22import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 
     23import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEqualityRuleManager; 
     24import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 
    2325import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 
    2426import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
    2527import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 
    26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder; 
    27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; 
     28import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     29import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; 
     30import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 
     31import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 
     32import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList; 
     33import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 
     34import de.ugoe.cs.autoquest.usageprofiles.SymbolComparator; 
    2935import de.ugoe.cs.autoquest.usageprofiles.Trie; 
    3036import de.ugoe.cs.autoquest.usageprofiles.TrieProcessor; 
    3137import de.ugoe.cs.util.StopWatch; 
    32 import de.ugoe.cs.util.console.Console; 
    3338 
    3439/** 
     
    3944 * @author Patrick Harms 
    4045 */ 
    41 class SequenceForTaskDetectionRule implements TemporalRelationshipRule { 
     46class SequenceForTaskDetectionRule implements ISessionScopeRule { 
    4247     
    4348    /** 
    4449     * <p> 
    45      * the task tree node factory to be used for creating substructures for the temporal 
     50     * the task factory to be used for creating substructures for the temporal 
    4651     * relationships identified during rule 
    4752     * </p> 
    4853     */ 
    49     private ITaskTreeNodeFactory taskTreeNodeFactory; 
     54    private ITaskFactory taskFactory; 
    5055    /** 
    5156     * <p> 
    52      * the task tree builder to be used for creating substructures for the temporal relationships 
     57     * the task builder to be used for creating substructures for the temporal relationships 
    5358     * identified during rule application 
    5459     * </p> 
    5560     */ 
    56     private ITaskTreeBuilder taskTreeBuilder; 
     61    private ITaskBuilder taskBuilder; 
    5762 
    5863    /** 
    5964     * <p> 
    60      * the node comparator to be used for comparing task tree nodes 
     65     * the task comparator to be used for comparing tasks 
    6166     * </p> 
    6267     */ 
    63     private TaskTreeNodeComparator nodeComparator; 
     68    private TaskComparator taskComparator; 
    6469 
    6570    /** 
    6671     * <p> 
    67      * instantiates the rule and initializes it with a node equality rule manager and the minimal 
    68      * node equality identified sublist must have to consider them as iterated. 
     72     * instantiates the rule and initializes it with a task equality rule manager and the minimal 
     73     * task equality identified sublist must have to consider them as iterated. 
    6974     * </p> 
    7075     */ 
    71     SequenceForTaskDetectionRule(NodeEqualityRuleManager nodeEqualityRuleManager, 
    72                                  NodeEquality            minimalNodeEquality, 
    73                                  ITaskTreeNodeFactory    taskTreeNodeFactory, 
    74                                  ITaskTreeBuilder        taskTreeBuilder) 
     76    SequenceForTaskDetectionRule(TaskEqualityRuleManager taskEqualityRuleManager, 
     77                                 TaskEquality            minimalTaskEquality, 
     78                                 ITaskFactory            taskFactory, 
     79                                 ITaskBuilder            taskBuilder) 
    7580    { 
    76         this.taskTreeNodeFactory = taskTreeNodeFactory; 
    77         this.taskTreeBuilder = taskTreeBuilder; 
    78          
    79         this.nodeComparator = 
    80             new TaskTreeNodeComparator(nodeEqualityRuleManager, minimalNodeEquality); 
     81        this.taskFactory = taskFactory; 
     82        this.taskBuilder = taskBuilder; 
     83         
     84        this.taskComparator = new TaskComparator(taskEqualityRuleManager, minimalTaskEquality); 
    8185    } 
    8286 
     
    8993    } 
    9094 
    91     /* 
    92      * (non-Javadoc) 
    93      *  
    94      * @see de.ugoe.cs.tasktree.temporalrelation.TemporalRelationshipRule#apply(TaskTreeNode, 
    95      * boolean) 
     95    /* (non-Javadoc) 
     96     * @see de.ugoe.cs.autoquest.tasktrees.temporalrelation.ISessionScopeRule#apply(java.util.List) 
    9697     */ 
    9798    @Override 
    98     public RuleApplicationResult apply(ITaskTreeNode parent, boolean finalize) { 
    99         if (!(parent instanceof ISequence)) { 
    100             return null; 
    101         } 
    102  
    103         if (!finalize) { 
    104             // the rule is always feasible as tasks may occur at any time 
    105             RuleApplicationResult result = new RuleApplicationResult(); 
    106             result.setRuleApplicationStatus(RuleApplicationStatus.FEASIBLE); 
    107             return result; 
    108         } 
    109  
    110         List<ITaskTreeNode> children = parent.getChildren(); 
    111         List<ISequence> sessions = new LinkedList<ISequence>(); 
    112          
    113         for (ITaskTreeNode child : children) { 
    114             if (child instanceof ISequence) { 
    115                 sessions.add((ISequence) child); 
    116             } 
    117             else { 
    118                 Console.println("provided parent is no parent of sessions"); 
    119                 return null; 
    120             } 
    121         } 
    122          
     99    public RuleApplicationResult apply(List<IUserSession> sessions) { 
    123100        RuleApplicationData appData = new RuleApplicationData(sessions); 
    124101 
    125         boolean finished = false; 
    126          
    127102        // this is the real rule application. Loop while something is replaced. 
    128103        do { 
     
    137112            appData.getStopWatch().stop("whole loop"); 
    138113             
    139             //((TaskTreeNodeComparator) nodeComparator).getStopWatch().dumpStatistics(System.out); 
    140             //((TaskTreeNodeComparator) nodeComparator).getStopWatch().reset(); 
     114            //((TaskTreeNodeComparator) taskComparator).getStopWatch().dumpStatistics(System.out); 
     115            //((TaskTreeNodeComparator) taskComparator).getStopWatch().reset(); 
    141116             
    142117            appData.getStopWatch().dumpStatistics(System.out); 
    143118            appData.getStopWatch().reset(); 
    144119             
    145             finished = (appData.getReplacementCounter() == 0); 
    146         } 
    147         while (!finished); 
    148          
    149         System.out.println("created " + appData.getResult().getNewlyCreatedParentNodes().size() + 
    150                            " new parent nodes\n"); 
    151          
    152         if (appData.getResult().getNewlyCreatedParentNodes().size() > 0) { 
     120        } 
     121        while (appData.detectedAndReplacedTasks()); 
     122         
     123        System.out.println 
     124            ("created " + appData.getResult().getNewlyCreatedTasks().size() + 
     125             " new tasks and " + appData.getResult().getNewlyCreatedTaskInstances().size() + 
     126             " appropriate instances\n"); 
     127         
     128        if ((appData.getResult().getNewlyCreatedTasks().size() > 0) || 
     129            (appData.getResult().getNewlyCreatedTaskInstances().size() > 0)) 
     130        { 
    153131            appData.getResult().setRuleApplicationStatus(RuleApplicationStatus.FINISHED); 
    154132        } 
     
    164142        appData.getStopWatch().start("detecting iterations"); 
    165143         
    166         List<ISequence> sessions = appData.getSessions(); 
    167         int foundIterations = 0; 
    168          
    169         for (ISequence session : sessions) { 
    170             foundIterations += detectAndReplaceIterations(session, appData); 
    171         } 
     144        List<IUserSession> sessions = appData.getSessions(); 
     145        int iteratedTasks = 0; 
     146         
     147        ITask iteratedTask = null; 
     148         
     149        do { 
     150            iteratedTask = searchIteratedTask(sessions); 
     151             
     152            if (iteratedTask != null) { 
     153                replaceIterationsOf(iteratedTask, sessions, appData); 
     154                iteratedTasks++; 
     155            } 
     156        } 
     157        while (iteratedTask != null); 
    172158         
    173159        appData.getStopWatch().stop("detecting iterations"); 
    174         System.out.println(" --> found " + foundIterations); 
    175     } 
    176  
    177     /** 
    178      * @param appData 
    179      */ 
    180     private int detectAndReplaceIterations(ISequence           session, 
    181                                            RuleApplicationData appData) 
     160        System.out.println(" --> found " + iteratedTasks + " iterated tasks"); 
     161    } 
     162 
     163    /** 
     164     * 
     165     */ 
     166    private ITask searchIteratedTask(List<IUserSession> sessions) { 
     167        for (IUserSession session : sessions) { 
     168            for (int i = 0; i < (session.size() - 1); i++) { 
     169                if (taskComparator.equals(session.get(i).getTask(), session.get(i + 1).getTask())) { 
     170                    return session.get(i).getTask(); 
     171                } 
     172            } 
     173        } 
     174         
     175        return null; 
     176    } 
     177 
     178    /** 
     179     * 
     180     */ 
     181    private void replaceIterationsOf(ITask               iteratedTask, 
     182                                     List<IUserSession>  sessions, 
     183                                     RuleApplicationData appData) 
    182184    { 
    183         int count = 0; 
    184          
    185         TemporalRelationshipRule rule = new SimpleIterationDetectionRule 
    186             (nodeComparator, taskTreeNodeFactory, taskTreeBuilder); 
    187  
    188         RuleApplicationResult result = rule.apply(session, true); 
    189              
    190         if ((result != null) && (result.getNewlyCreatedParentNodes() != null)) { 
    191             for (ITaskTreeNode newParent : result.getNewlyCreatedParentNodes()) { 
    192                 appData.getResult().addNewlyCreatedParentNode(newParent); 
    193                 if (newParent instanceof IIteration) { 
    194                     count++; 
    195                 } 
    196             } 
    197         } 
    198          
    199         return count; 
     185        IIteration iteration = taskFactory.createNewIteration(); 
     186        ITaskInstance iterationInstance = null; 
     187         
     188        List<ITaskInstance> iterationInstances = new LinkedList<ITaskInstance>(); 
     189         
     190        for (IUserSession session : sessions) { 
     191            int index = 0; 
     192            while (index < session.size()) { 
     193                if (taskComparator.equals(iteratedTask, session.get(index).getTask())) { 
     194                    if (iterationInstance == null) { 
     195                        iterationInstance = taskFactory.createNewTaskInstance(iteration); 
     196                        iterationInstances.add(iterationInstance); 
     197                        taskBuilder.addTaskInstance(session, index, iterationInstance); 
     198                        index++; 
     199                    } 
     200                     
     201                    taskBuilder.addChild(iterationInstance, session.get(index)); 
     202                    taskBuilder.removeTaskInstance(session, index); 
     203                } 
     204                else { 
     205                    if (iterationInstance != null) { 
     206                        iterationInstance = null; 
     207                    } 
     208                    index++; 
     209                } 
     210            } 
     211        } 
     212         
     213        harmonizeIterationInstancesModel(iteration, iterationInstances); 
     214    } 
     215 
     216    /** 
     217     * <p> 
     218     * TODO: comment 
     219     * </p> 
     220     * 
     221     * @param iteratedTaskVariants 
     222     */ 
     223    private void harmonizeIterationInstancesModel(IIteration          iteration, 
     224                                                  List<ITaskInstance> iterationInstances) 
     225    { 
     226        List<ITask> iteratedTaskVariants = new LinkedList<ITask>(); 
     227         
     228        // merge the lexically different variants of iterated task to a unique list  
     229        for (ITaskInstance iterationInstance : iterationInstances) { 
     230            for (ITaskInstance executionVariant : iterationInstance) { 
     231                ITask candidate = executionVariant.getTask(); 
     232             
     233                boolean found = false; 
     234                for (ITask taskVariant : iteratedTaskVariants) { 
     235                    if (taskComparator.areLexicallyEqual(taskVariant, candidate)) { 
     236                        taskBuilder.setTask(executionVariant, taskVariant); 
     237                        found = true; 
     238                        break; 
     239                    } 
     240                } 
     241                 
     242                if (!found) { 
     243                    iteratedTaskVariants.add(candidate); 
     244                } 
     245            } 
     246        } 
     247         
     248        // if there are more than one lexically different variant of iterated tasks, adapt the 
     249        // iteration model to be a selection of different variants. In this case also adapt 
     250        // the generated iteration instances to correctly contain selection instances. If there 
     251        // is only one variant of an iterated task, simply set this as the marked task of the 
     252        // iteration. In this case, the instances can be preserved as is 
     253        if (iteratedTaskVariants.size() > 1) { 
     254            ISelection selection = taskFactory.createNewSelection(); 
     255             
     256            for (ITask variant : iteratedTaskVariants) { 
     257                taskBuilder.addChild(selection, variant); 
     258            } 
     259             
     260            taskBuilder.setMarkedTask(iteration, selection); 
     261             
     262            for (ITaskInstance instance : iterationInstances) { 
     263                for (int i = 0; i < instance.size(); i++) { 
     264                    ITaskInstance selectionInstance = taskFactory.createNewTaskInstance(selection); 
     265                    taskBuilder.addChild(selectionInstance, instance.get(i)); 
     266                    taskBuilder.setTaskInstance(instance, i, selectionInstance); 
     267                } 
     268            } 
     269        } 
     270        else { 
     271            taskBuilder.setMarkedTask(iteration, iteratedTaskVariants.get(0)); 
     272        } 
    200273    } 
    201274 
     
    226299        Tasks tasks; 
    227300        boolean createNewTrie = (appData.getLastTrie() == null) || 
    228             appData.getReplacementCounter() > 0; // tree has changed 
     301            appData.detectedAndReplacedTasks(); // tree has changed 
    229302         
    230303        do { 
     
    240313            createNewTrie = false; 
    241314             
    242             for (List<ITaskTreeNode> task : tasks) { 
     315            for (List<ITaskInstance> task : tasks) { 
    243316                if (task.size() >= appData.getTrainedSequenceLength()) { 
    244317                    // Trie must be recreated with a longer sequence length to be sure that 
     
    267340 
    268341        appData.getStopWatch().start("training trie"); 
    269         appData.setLastTrie(new Trie<ITaskTreeNode>(nodeComparator)); 
     342        appData.setLastTrie(new Trie<ITaskInstance>(taskComparator)); 
    270343     
    271         List<ISequence> sessions = appData.getSessions(); 
    272          
    273         for (ISequence session : sessions) { 
     344        List<IUserSession> sessions = appData.getSessions(); 
     345         
     346        for (IUserSession session : sessions) { 
    274347            trainTrie(session, appData); 
    275348        } 
     
    282355     * @param parent 
    283356     */ 
    284     private void trainTrie(ISequence session, RuleApplicationData appData) { 
    285         List<ITaskTreeNode> children = session.getChildren(); 
     357    private void trainTrie(IUserSession session, RuleApplicationData appData) { 
     358        List<ITaskInstance> children = session.getExecutedTasks(); 
    286359         
    287360        if ((children != null) && (children.size() > 0)) { 
     
    294367     */ 
    295368    private void replaceSequencesOccurringMostOften(RuleApplicationData appData) { 
    296         appData.resetReplacementCounter(); 
     369        appData.detectedAndReplacedTasks(false); 
    297370 
    298371        if ((appData.getLastFoundTasks().size() > 0) && 
    299372            (appData.getLastFoundTasks().getOccurrenceCount() > 1)) 
    300373        { 
    301             System.out.println("replacing tasks occurrences with merged variants of all versions"); 
    302  
    303             for (List<ITaskTreeNode> task : appData.getLastFoundTasks()) { 
    304                 String taskId = "task " + RuleUtils.getNewId(); 
    305                 System.out.println("replacing " + taskId + ": " + task); 
    306  
    307                 appData.clearTaskOccurrences(); 
    308                 determineVariantsOfTaskOccurrences(task, appData.getSessions(), appData); 
    309                  
    310                 appData.getStopWatch().start("merging task nodes"); 
    311                 ITaskTreeNode taskReplacement = mergeVariantsOfTaskOccurrence(taskId, appData); 
    312                 appData.getStopWatch().stop("merging task nodes"); 
    313  
    314                 appData.resetReplacementCounter(); 
    315                 replaceTaskOccurrences(task, taskReplacement, appData.getSessions(), appData); 
    316  
    317                 if (appData.getReplacementCounter() > 0) { 
    318                     appData.getResult().addNewlyCreatedParentNode(taskReplacement); 
    319                 } 
    320  
    321                 if (appData.getReplacementCounter() < 
    322                     appData.getLastFoundTasks().getOccurrenceCount()) 
    323                 { 
    324                     System.out.println(taskId + ": replaced task only " + 
    325                                        appData.getReplacementCounter() + 
    326                                        " times instead of expected " + 
     374            System.out.println("replacing tasks occurrences"); 
     375 
     376            for (List<ITaskInstance> task : appData.getLastFoundTasks()) { 
     377                ISequence sequence = taskFactory.createNewSequence(); 
     378                 
     379                System.out.println("replacing " + sequence.getId() + ": " + task); 
     380 
     381                List<ITaskInstance> sequenceInstances = 
     382                    replaceTaskOccurrences(task, appData.getSessions(), sequence); 
     383                 
     384                harmonizeSequenceInstancesModel(sequence, sequenceInstances,task.size()); 
     385                appData.detectedAndReplacedTasks(sequenceInstances.size() > 0); 
     386 
     387                if (sequenceInstances.size() < appData.getLastFoundTasks().getOccurrenceCount()) { 
     388                    System.out.println(sequence.getId() + ": replaced task only " + 
     389                                       sequenceInstances.size() + " times instead of expected " + 
    327390                                       appData.getLastFoundTasks().getOccurrenceCount()); 
    328391                } 
     
    333396 
    334397    /** 
    335      * @param tree 
    336      */ 
    337     private void determineVariantsOfTaskOccurrences(List<ITaskTreeNode> task, 
    338                                                     List<ISequence>     sessions, 
    339                                                     RuleApplicationData appData) 
     398     * 
     399     */ 
     400    private void harmonizeSequenceInstancesModel(ISequence           sequence, 
     401                                                 List<ITaskInstance> sequenceInstances, 
     402                                                 int                 sequenceLength) 
    340403    { 
    341         for (ISequence session : sessions) { 
    342             int index = -1; 
    343                  
    344             List<ITaskTreeNode> children = session.getChildren(); 
    345  
    346             do { 
    347                 index = getSubListIndex(children, task, ++index); 
    348  
    349                 if (index > -1) { 
    350                     ISequence taskOccurrence = RuleUtils.getSubSequenceInRange 
    351                             (session, index, index + task.size() - 1, null, 
    352                              taskTreeNodeFactory, taskTreeBuilder); 
    353  
    354                     appData.addTaskOccurrence(taskOccurrence); 
    355  
    356                     // let the index point to the last element the belongs the identified occurrence 
    357                     index += task.size() - 1; 
    358                 } 
    359             } 
    360             while (index > -1); 
    361         } 
    362     } 
    363  
    364     /** 
    365      * @param appData 
    366      * @return 
    367      */ 
    368     private ITaskTreeNode mergeVariantsOfTaskOccurrence(String              taskId, 
    369                                                         RuleApplicationData appData) 
    370     { 
    371         return mergeVariantsOfTasks(taskId, appData.getTaskOccurrences()); 
    372     } 
    373  
    374     /** 
    375      * @param appData 
    376      * @return 
    377      */ 
    378     private ITaskTreeNode mergeVariantsOfTasks(String description, List<ITaskTreeNode> variants) { 
    379         // merge but preserve lexically distinct variants 
    380         TaskTreeNodeMerger merger = new TaskTreeNodeMerger 
    381             (taskTreeNodeFactory, taskTreeBuilder, nodeComparator); 
    382          
    383         merger.mergeTaskNodes(variants); 
    384          
    385         if (variants.size() == 1) { 
    386             ITaskTreeNode replacement = variants.get(0); 
    387             taskTreeBuilder.setDescription(replacement, description); 
    388             return replacement; 
    389         } 
    390         else { 
    391             ISelection selection = taskTreeNodeFactory.createNewSelection(); 
    392             taskTreeBuilder.setDescription(selection, "variants of task " + description); 
    393              
    394             for (ITaskTreeNode variant : variants) { 
    395                 taskTreeBuilder.addChild(selection, variant); 
    396             } 
    397              
    398             return selection; 
    399         } 
    400     } 
    401  
    402     /** 
    403      * @param task 
    404      * @param parent 
    405      * @param treeBuilder 
    406      * @param nodeFactory 
    407      * @param result 
    408      */ 
    409     private void replaceTaskOccurrences(List<ITaskTreeNode> task, 
    410                                         ITaskTreeNode       replacement, 
    411                                         List<ISequence>     sessions, 
    412                                         RuleApplicationData appData) 
    413     { 
    414         // now check the children themselves for an occurrence of the task 
    415         for (int i = 0; i < sessions.size(); i++) { 
    416             ISequence session = sessions.get(i); 
    417              
    418             int index = -1; 
    419          
    420             List<ITaskTreeNode> children = session.getChildren(); 
    421  
    422             do { 
    423                 index = getSubListIndex(children, task, ++index); 
    424  
    425                 if (index > -1) { 
    426                     if ((!(replacement instanceof ISequence)) || 
    427                         (task.size() < children.size())) 
    428                     { 
    429                         for (int j = index; j < index + task.size(); j++) { 
    430                             taskTreeBuilder.removeChild(session, index); 
    431                         } 
    432  
    433                         taskTreeBuilder.addChild(session, index, replacement); 
    434                         appData.incrementReplacementCounter(); 
    435  
    436                         children = session.getChildren(); 
    437                     } 
    438                     else { 
    439                         // the whole list of children is an occurrence of this task. So ask the 
    440                         // caller of the method to replace the whole node 
    441                         sessions.set(i, (ISequence) replacement); 
    442                         appData.incrementReplacementCounter(); 
     404         
     405        // ensure for each subtask that lexically different variants are preserved 
     406        for (int subTaskIndex = 0; subTaskIndex < sequenceLength; subTaskIndex++) { 
     407            List<ITask> subTaskVariants = new LinkedList<ITask>(); 
     408             
     409            for (ITaskInstance sequenceInstance : sequenceInstances) { 
     410                ITask candidate = sequenceInstance.get(subTaskIndex).getTask(); 
     411                 
     412                boolean found = false; 
     413                 
     414                for (int i = 0; i < subTaskVariants.size(); i++) { 
     415                    if (taskComparator.areLexicallyEqual(subTaskVariants.get(i), candidate)) { 
     416                        taskBuilder.setTask 
     417                            (sequenceInstance.get(subTaskIndex), subTaskVariants.get(i)); 
     418                         
     419                        found = true; 
    443420                        break; 
    444421                    } 
    445422                } 
     423                 
     424                if (!found) { 
     425                    subTaskVariants.add(candidate); 
     426                } 
     427            } 
     428             
     429            // if there are more than one lexically different variant of the sub task at 
     430            // the considered position, adapt the sequence model at that position to have 
     431            // a selection of the different variants. In this case also adapt the 
     432            // generated sequence instances to correctly contain selection instances. If 
     433            // there is only one variant of sub tasks at the given position, simply set 
     434            // this variant as the sub task of the selection. In this case, the instances 
     435            // can be preserved as is 
     436            if (subTaskVariants.size() > 1) { 
     437                ISelection selection = taskFactory.createNewSelection(); 
     438                 
     439                for (ITask variant : subTaskVariants) { 
     440                    taskBuilder.addChild(selection, variant); 
     441                } 
     442                 
     443                taskBuilder.addChild(sequence, selection); 
     444                 
     445                for (ITaskInstance instance : sequenceInstances) { 
     446                    ITaskInstance selectionInstance = 
     447                        taskFactory.createNewTaskInstance(selection); 
     448                    taskBuilder.addChild(selectionInstance, instance.get(subTaskIndex)); 
     449                    taskBuilder.setTaskInstance(instance, subTaskIndex, selectionInstance); 
     450                } 
     451            } 
     452            else if (subTaskVariants.size() == 1) { 
     453                taskBuilder.addChild(sequence, subTaskVariants.get(0)); 
     454            } 
     455        } 
     456    } 
     457 
     458    /** 
     459     * @param tree 
     460     */ 
     461    private List<ITaskInstance> replaceTaskOccurrences(List<ITaskInstance> task, 
     462                                                       List<IUserSession>  sessions, 
     463                                                       ISequence           temporalTaskModel) 
     464    { 
     465        List<ITaskInstance> sequenceInstances = new LinkedList<ITaskInstance>(); 
     466         
     467        for (IUserSession session : sessions) { 
     468            int index = -1; 
     469                 
     470            do { 
     471                index = getSubListIndex(session, task, ++index); 
     472 
     473                if (index > -1) { 
     474                    sequenceInstances.add 
     475                        (RuleUtils.createNewSubSequenceInRange 
     476                             (session, index, index + task.size() - 1, temporalTaskModel, 
     477                              taskFactory, taskBuilder)); 
     478                } 
    446479            } 
    447480            while (index > -1); 
    448481        } 
     482         
     483        return sequenceInstances; 
    449484    } 
    450485 
     
    454489     * @return 
    455490     */ 
    456     private int getSubListIndex(List<ITaskTreeNode> list, 
    457                                 List<ITaskTreeNode> subList, 
     491    private int getSubListIndex(ITaskInstanceList  list, 
     492                                List<ITaskInstance> subList, 
    458493                                int                 startIndex) 
    459494    { 
     
    465500             
    466501            for (int j = 0; j < subList.size(); j++) { 
    467                 if (!nodeComparator.equals(list.get(i + j), subList.get(j))) { 
     502                if (!taskComparator.equals(list.get(i + j), subList.get(j))) { 
    468503                    matchFound = false; 
    469504                    break; 
     
    479514        return result; 
    480515    } 
     516 
     517    /** 
     518     * @param trie 
     519     * @param object 
     520     * @return 
     521     */ 
     522    private int getSubListIndex(List<ITaskInstance> list, 
     523                                List<ITaskInstance> subList, 
     524                                int                 startIndex) 
     525    { 
     526        boolean matchFound; 
     527        int result = -1; 
     528         
     529        for (int i = startIndex; i <= list.size() - subList.size(); i++) { 
     530            matchFound = true; 
     531             
     532            for (int j = 0; j < subList.size(); j++) { 
     533                if (!taskComparator.equals(list.get(i + j), subList.get(j))) { 
     534                    matchFound = false; 
     535                    break; 
     536                } 
     537            } 
     538             
     539            if (matchFound) { 
     540                result = i; 
     541                break; 
     542            } 
     543        } 
     544         
     545        return result; 
     546    } 
    481547     
    482548    /** 
    483549     * @author Patrick Harms 
    484550     */ 
    485     private class MaxCountAndLongestTasksFinder implements TrieProcessor<ITaskTreeNode> { 
     551    private class MaxCountAndLongestTasksFinder implements TrieProcessor<ITaskInstance> { 
    486552         
    487553        /** 
     
    493559         *  
    494560         */ 
    495         private List<List<ITaskTreeNode>> foundTasks = new LinkedList<List<ITaskTreeNode>>(); 
     561        private List<List<ITaskInstance>> foundTasks = new LinkedList<List<ITaskInstance>>(); 
    496562 
    497563        /** 
     
    507573         */ 
    508574        @Override 
    509         public TrieProcessor.Result process(List<ITaskTreeNode> task, int count) { 
    510             if (task.size() < 2) { 
    511                 // ignore single nodes 
     575        public TrieProcessor.Result process(List<ITaskInstance> foundTask, int count) { 
     576            if (foundTask.size() < 2) { 
     577                // ignore single tasks 
    512578                return TrieProcessor.Result.CONTINUE; 
    513579            } 
     
    519585 
    520586            if (this.currentCount > count) { 
    521                 // ignore this children of this node, as they may have only smaller counts than 
     587                // ignore this children of this task, as they may have only smaller counts than 
    522588                // the already found tasks 
    523589                return TrieProcessor.Result.SKIP_NODE; 
     
    536602                boolean added = false; 
    537603                for (int i = 0; i < foundTasks.size(); i++) { 
    538                     if (foundTasks.get(i).size() < task.size()) { 
     604                    if (foundTasks.get(i).size() < foundTask.size()) { 
    539605                        // defensive copy 
    540                         foundTasks.add(i, new LinkedList<ITaskTreeNode>(task)); // defensive copy 
     606                        foundTasks.add(i, new LinkedList<ITaskInstance>(foundTask)); // defensive copy 
    541607                        added = true; 
    542608                        break; 
     
    545611                 
    546612                if (!added) { 
    547                     foundTasks.add(new LinkedList<ITaskTreeNode>(task)); // defensive copy 
     613                    foundTasks.add(new LinkedList<ITaskInstance>(foundTask)); // defensive copy 
    548614                } 
    549615            } 
     
    571637                        // found a task that is a potential subtask. Check for this and remove the 
    572638                        // subtask if needed 
    573                         List<ITaskTreeNode> longTask = foundTasks.get(i); 
    574                         List<ITaskTreeNode> shortTask = foundTasks.get(j); 
     639                        List<ITaskInstance> longTask = foundTasks.get(i); 
     640                        List<ITaskInstance> shortTask = foundTasks.get(j); 
    575641                         
    576642                        if (getSubListIndex(longTask, shortTask, 0) > -1) { 
     
    598664         *  
    599665         */ 
    600         private List<ISequence> sessions; 
    601          
    602         /** 
    603          *  
    604          */ 
    605         private Trie<ITaskTreeNode> lastTrie; 
     666        private List<IUserSession> sessions; 
     667         
     668        /** 
     669         *  
     670         */ 
     671        private Trie<ITaskInstance> lastTrie; 
    606672         
    607673        /** 
     
    618684         *  
    619685         */ 
    620         private List<ITaskTreeNode> taskOccurrences = new LinkedList<ITaskTreeNode>(); 
    621          
    622         /** 
    623          *  
    624          */ 
    625         private int replacementCounter; 
     686        private boolean detectedAndReplacedTasks; 
    626687         
    627688        /** 
     
    638699         *  
    639700         */ 
    640         private RuleApplicationData(List<ISequence> sessions) { 
     701        private RuleApplicationData(List<IUserSession> sessions) { 
    641702            this.sessions = sessions; 
    642703        } 
     
    645706         * @return the tree 
    646707         */ 
    647         private List<ISequence> getSessions() { 
     708        private List<IUserSession> getSessions() { 
    648709            return sessions; 
    649710        } 
     
    652713         * @param lastTrie the lastTrie to set 
    653714         */ 
    654         private void setLastTrie(Trie<ITaskTreeNode> lastTrie) { 
     715        private void setLastTrie(Trie<ITaskInstance> lastTrie) { 
    655716            this.lastTrie = lastTrie; 
    656717        } 
     
    659720         * @return the lastTrie 
    660721         */ 
    661         private Trie<ITaskTreeNode> getLastTrie() { 
     722        private Trie<ITaskInstance> getLastTrie() { 
    662723            return lastTrie; 
    663724        } 
     
    692753 
    693754        /** 
    694          * @return the taskOccurrences 
    695          */ 
    696         private void clearTaskOccurrences() { 
    697             taskOccurrences.clear(); 
    698         } 
    699  
    700         /** 
    701          * @return the taskOccurrences 
    702          */ 
    703         private void addTaskOccurrence(ITaskTreeNode taskOccurrence) { 
    704             taskOccurrences.add(taskOccurrence); 
    705         } 
    706  
    707         /** 
    708          * @return the taskOccurrences 
    709          */ 
    710         private List<ITaskTreeNode> getTaskOccurrences() { 
    711             return taskOccurrences; 
    712         } 
    713  
    714         /** 
    715755         * 
    716756         */ 
    717         private void resetReplacementCounter() { 
    718             replacementCounter = 0; 
     757        private void detectedAndReplacedTasks(boolean detectedAndReplacedTasks) { 
     758            this.detectedAndReplacedTasks = detectedAndReplacedTasks; 
    719759        } 
    720760 
     
    722762         * 
    723763         */ 
    724         private void incrementReplacementCounter() { 
    725             replacementCounter++; 
    726         } 
    727  
    728         /** 
    729          * 
    730          */ 
    731         private int getReplacementCounter() { 
    732             return replacementCounter; 
     764        private boolean detectedAndReplacedTasks() { 
     765            return detectedAndReplacedTasks; 
    733766        } 
    734767         
     
    753786     * @author Patrick Harms 
    754787     */ 
    755     private static class Tasks implements Iterable<List<ITaskTreeNode>> { 
     788    private static class Tasks implements Iterable<List<ITaskInstance>> { 
    756789         
    757790        /** 
     
    763796         *  
    764797         */ 
    765         private List<List<ITaskTreeNode>> sequences; 
     798        private List<List<ITaskInstance>> sequences; 
    766799 
    767800        /** 
     
    769802         * @param sequences 
    770803         */ 
    771         private Tasks(int occurrenceCount, List<List<ITaskTreeNode>> sequences) { 
     804        private Tasks(int occurrenceCount, List<List<ITaskInstance>> sequences) { 
    772805            super(); 
    773806            this.occurrenceCount = occurrenceCount; 
     
    797830         */ 
    798831        @Override 
    799         public Iterator<List<ITaskTreeNode>> iterator() { 
     832        public Iterator<List<ITaskInstance>> iterator() { 
    800833            return this.sequences.iterator(); 
    801834        } 
     
    803836    } 
    804837 
     838    /** 
     839     * 
     840     */ 
     841    private class TaskComparator implements SymbolComparator<ITaskInstance> { 
     842 
     843        /** */ 
     844        private Comparer comparer; 
     845 
     846        /** */ 
     847        private Comparer lexicalComparer; 
     848 
     849        /** */ 
     850        private HashMap<Long, Boolean> equalityBuffer = new HashMap<Long, Boolean>(); 
     851 
     852        /** */ 
     853        private HashMap<Long, Boolean> lexicalEqualityBuffer; 
     854 
     855        /** 
     856         * 
     857         */ 
     858        public TaskComparator(TaskEqualityRuleManager taskEqualityRuleManager, 
     859                              TaskEquality            minimalNodeEquality) 
     860        { 
     861            super(); 
     862             
     863            if (minimalNodeEquality == TaskEquality.LEXICALLY_EQUAL) { 
     864                comparer = new LexicalComparer(taskEqualityRuleManager); 
     865            } 
     866            else if (minimalNodeEquality == TaskEquality.SYNTACTICALLY_EQUAL) { 
     867                comparer = new SyntacticalComparer(taskEqualityRuleManager); 
     868            } 
     869            else if (minimalNodeEquality == TaskEquality.SEMANTICALLY_EQUAL) { 
     870                comparer = new SemanticalComparer(taskEqualityRuleManager); 
     871            } 
     872            else { 
     873                comparer = new DefaultComparer(taskEqualityRuleManager, minimalNodeEquality); 
     874            } 
     875             
     876            if (minimalNodeEquality == TaskEquality.LEXICALLY_EQUAL) { 
     877                lexicalComparer = comparer; 
     878                lexicalEqualityBuffer = equalityBuffer; 
     879            } 
     880            else { 
     881                lexicalComparer = new LexicalComparer(taskEqualityRuleManager); 
     882                lexicalEqualityBuffer = new HashMap<Long, Boolean>(); 
     883            } 
     884        } 
     885 
     886        /* (non-Javadoc) 
     887         * @see de.ugoe.cs.autoquest.tasktrees.temporalrelation.SymbolComparator#equals(java.lang.Object, java.lang.Object) 
     888         */ 
     889        @Override 
     890        public boolean equals(ITaskInstance taskInstance1, ITaskInstance taskInstance2) { 
     891            return equals(taskInstance1.getTask(), taskInstance2.getTask()); 
     892        }         
     893 
     894        /** 
     895         *  
     896         */ 
     897        public boolean equals(ITask task1, ITask task2) { 
     898            Boolean result; 
     899             
     900            if (task1 != task2) { 
     901                if ((task1 instanceof IEventTask) && (task2 instanceof IEventTask)) { 
     902                    long key = ((long) System.identityHashCode(task1)) << 32; 
     903                    key += System.identityHashCode(task2); 
     904                 
     905                    result = equalityBuffer.get(key); 
     906                 
     907                    if (result == null) { 
     908                        result = comparer.compare(task1, task2); 
     909                        equalityBuffer.put(key, result); 
     910                    } 
     911                } 
     912                else { 
     913                    result = false; 
     914                } 
     915            } 
     916            else { 
     917                result = true; 
     918            } 
     919             
     920            return result; 
     921        } 
     922 
     923        /** 
     924         * 
     925         */ 
     926        public boolean areLexicallyEqual(ITask task1, ITask task2) { 
     927            Boolean result; 
     928             
     929            if (task1 != task2) { 
     930                long key = ((long) System.identityHashCode(task1)) << 32; 
     931                key += System.identityHashCode(task2); 
     932                 
     933                result = lexicalEqualityBuffer.get(key); 
     934                 
     935                if (result == null) { 
     936                    result = lexicalComparer.compare(task1, task2); 
     937                    lexicalEqualityBuffer.put(key, result); 
     938                } 
     939            } 
     940            else { 
     941                result = true; 
     942            } 
     943             
     944            return result; 
     945        } 
     946    } 
     947 
     948    /** 
     949     *  
     950     */ 
     951    private interface Comparer { 
     952         
     953        /** 
     954         *  
     955         */ 
     956        boolean compare(ITask task1, ITask task2); 
     957    } 
     958 
     959    /** 
     960     *  
     961     */ 
     962    private class LexicalComparer implements Comparer { 
     963         
     964        /** 
     965         * <p> 
     966         * the task equality manager needed for comparing tasks with each other 
     967         * </p> 
     968         */ 
     969        private TaskEqualityRuleManager taskEqualityRuleManager; 
     970         
     971        /** 
     972         * 
     973         */ 
     974        public LexicalComparer(TaskEqualityRuleManager taskEqualityRuleManager) { 
     975           this.taskEqualityRuleManager = taskEqualityRuleManager; 
     976        } 
     977         
     978        /** 
     979         *  
     980         */ 
     981        public boolean compare(ITask task1, ITask task2) { 
     982            return taskEqualityRuleManager.areLexicallyEqual(task1, task2); 
     983        } 
     984    } 
     985 
     986    /** 
     987     *  
     988     */ 
     989    private class SyntacticalComparer implements Comparer { 
     990         
     991        /** 
     992         * <p> 
     993         * the task equality manager needed for comparing tasks with each other 
     994         * </p> 
     995         */ 
     996        private TaskEqualityRuleManager taskEqualityRuleManager; 
     997         
     998        /** 
     999         * 
     1000         */ 
     1001        public SyntacticalComparer(TaskEqualityRuleManager taskEqualityRuleManager) { 
     1002           this.taskEqualityRuleManager = taskEqualityRuleManager; 
     1003        } 
     1004         
     1005        /** 
     1006         *  
     1007         */ 
     1008        public boolean compare(ITask task1, ITask task2) { 
     1009            return taskEqualityRuleManager.areSyntacticallyEqual(task1, task2); 
     1010        } 
     1011    } 
     1012 
     1013    /** 
     1014     *  
     1015     */ 
     1016    private class SemanticalComparer implements Comparer { 
     1017         
     1018        /** 
     1019         * <p> 
     1020         * the task equality manager needed for comparing tasks with each other 
     1021         * </p> 
     1022         */ 
     1023        private TaskEqualityRuleManager taskEqualityRuleManager; 
     1024         
     1025        /** 
     1026         * 
     1027         */ 
     1028        public SemanticalComparer(TaskEqualityRuleManager taskEqualityRuleManager) { 
     1029           this.taskEqualityRuleManager = taskEqualityRuleManager; 
     1030        } 
     1031         
     1032        /** 
     1033         *  
     1034         */ 
     1035        public boolean compare(ITask task1, ITask task2) { 
     1036            return taskEqualityRuleManager.areSemanticallyEqual(task1, task2); 
     1037        } 
     1038    } 
     1039 
     1040    /** 
     1041     *  
     1042     */ 
     1043    private class DefaultComparer implements Comparer { 
     1044         
     1045        /** 
     1046         * <p> 
     1047         * the task equality manager needed for comparing tasks with each other 
     1048         * </p> 
     1049         */ 
     1050        private TaskEqualityRuleManager taskEqualityRuleManager; 
     1051 
     1052        /** 
     1053         * <p> 
     1054         * the minimal task equality two identified sublists need to have to consider them as equal 
     1055         * </p> 
     1056         */ 
     1057        private TaskEquality minimalNodeEquality; 
     1058         
     1059        /** 
     1060         * 
     1061         */ 
     1062        public DefaultComparer(TaskEqualityRuleManager taskEqualityRuleManager, 
     1063                               TaskEquality            minimalNodeEquality) 
     1064        { 
     1065           this.taskEqualityRuleManager = taskEqualityRuleManager; 
     1066           this.minimalNodeEquality = minimalNodeEquality; 
     1067        } 
     1068         
     1069        /** 
     1070         *  
     1071         */ 
     1072        public boolean compare(ITask task1, ITask task2) { 
     1073            return taskEqualityRuleManager.areAtLeastEqual(task1, task2, minimalNodeEquality); 
     1074        } 
     1075    } 
    8051076} 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TemporalRelationshipRuleManager.java

    r1131 r1146  
    2222import de.ugoe.cs.autoquest.eventcore.guimodel.IFrame; 
    2323import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement; 
    24 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEquality; 
    25 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEqualityRuleManager; 
    26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder; 
    27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; 
     24import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 
     25import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEqualityRuleManager; 
     26import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; 
     27import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 
     28import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 
     29import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList; 
     30import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 
    2931import de.ugoe.cs.util.console.Console; 
    3032 
    3133/** 
     34 * TODO update comment 
     35 *  
    3236 * <p> 
    3337 * This class is responsible for applying temporal relationship rules on a task tree. Through this, 
    3438 * a flat task tree is restructured to have more depth but to include more temporal relationships 
    35  * between task tree nodes which are not only a major sequence. I.e. through the application of 
    36  * rule iterations and selections of task tree nodes are detected. Which kind of temporal relations 
    37  * between task tree nodes are detected depends on the {@link TemporalRelationshipRule}s known to 
     39 * between tasks which are not only a major sequence. I.e. through the application of the 
     40 * rules iterations and selections of tasks are detected. Which kind of temporal relations 
     41 * between tasks are detected depends on the {@link ITaskInstanceListScopeRule}s known to 
    3842 * this class. 
    3943 * </p> 
    40  * <p>The class holds references to the appropriate {@link TemporalRelationshipRule}s and calls 
    41  * their {@link TemporalRelationshipRule#apply(ITaskTreeNode, ITaskTreeBuilder, ITaskTreeNodeFactory, boolean)} 
    42  * method for each node in the task tree it is needed for. The general behavior of this class is 
     44 * <p>The class holds references to the appropriate {@link ITaskInstanceListScopeRule}s and calls 
     45 * their {@link ITaskInstanceListScopeRule#apply(ITask, ITaskBuilder, ITaskFactory, boolean)} 
     46 * method for each task in the task tree it is needed for. The general behavior of this class is 
    4347 * the following: 
    4448 * <ol> 
     
    4852 *   </li> 
    4953 *   <li> 
    50  *     then the {@link #applyRules(ITaskTreeNode, ITaskTreeBuilder, ITaskTreeNodeFactory, boolean)} 
    51  *     method is called for a so far unstructured task tree node 
     54 *     then the {@link #applyRules(ITask, ITaskBuilder, ITaskFactory, boolean)} 
     55 *     method is called for a so far unstructured task 
    5256 *   </li> 
    5357 *   <li> 
    5458 *     the class iterates its internal list of rules and calls their 
    55  *     {@link TemporalRelationshipRule#apply(ITaskTreeNode, ITaskTreeBuilder, ITaskTreeNodeFactory, boolean)} 
     59 *     {@link ITaskInstanceListScopeRule#apply(ITask, ITaskBuilder, ITaskFactory, boolean)} 
    5660 *     method. 
    5761 *   </li> 
     
    6973 *       <li> 
    7074 *         if a rule returns, that it was applied, the same rule is applied again until it returns 
    71  *         null or feasible. For each newly created parent node provided in the rule application 
    72  *         result, the {@link #applyRules(ITaskTreeNode, ITaskTreeBuilder, ITaskTreeNodeFactory, boolean)} 
     75 *         null or feasible. For each newly created parent task provided in the rule application 
     76 *         result, the {@link #applyRules(ITask, ITaskBuilder, ITaskFactory, boolean)} 
    7377 *         method is called. 
    7478 *       </li> 
     
    7680 *   </li> 
    7781 * </ol> 
    78  * Through this, all rules are tried to be applied at least once to the provided parent node and 
    79  * all parent nodes created during the rule application. 
     82 * Through this, all rules are tried to be applied at least once to the provided parent task and 
     83 * all parent tasks created during the rule application. 
    8084 * </p> 
    8185 *  
     
    8690    /** 
    8791     * <p> 
    88      * the node equality manager needed by the rules to compare task tree nodes with each other 
    89      * </p> 
    90      */ 
    91     private NodeEqualityRuleManager nodeEqualityRuleManager; 
    92  
    93     /** 
    94      * <p> 
    95      * the task tree node factory to be used during rule application 
    96      * </p> 
    97      */ 
    98     private ITaskTreeNodeFactory taskTreeNodeFactory; 
    99  
    100     /** 
    101      * <p> 
    102      * the task tree builder to be used during rule application 
    103      * </p> 
    104      */ 
    105     private ITaskTreeBuilder taskTreeBuilder; 
     92     * the task equality manager needed by the rules to compare tasks with each other 
     93     * </p> 
     94     */ 
     95    private TaskEqualityRuleManager taskEqualityRuleManager; 
     96 
     97    /** 
     98     * <p> 
     99     * the task factory to be used during rule application 
     100     * </p> 
     101     */ 
     102    private ITaskFactory taskFactory; 
     103 
     104    /** 
     105     * <p> 
     106     * the task builder to be used during rule application 
     107     * </p> 
     108     */ 
     109    private ITaskBuilder taskBuilder; 
     110 
     111    /** 
     112     * <p> 
     113     * the temporal relationship rules known to the manager that are executed on whole sessions. 
     114     * The rules are applied in the order they occur in this list. 
     115     * </p> 
     116     */ 
     117    private ISessionScopeRule[] sessionScopeRules; 
    106118 
    107119    /** 
     
    111123     * </p> 
    112124     */ 
    113     private TemporalRelationshipRule[] treeScopeRules; 
    114  
    115     /** 
    116      * <p> 
    117      * the temporal relationship rules known to the manager that are executed on whole sub trees. 
    118      * The rules are applied in the order they occur in this list. 
    119      * </p> 
    120      */ 
    121     private TemporalRelationshipRule[] nodeScopeRules; 
     125    private ITaskInstanceListScopeRule[] taskScopeRules; 
    122126 
    123127    /** 
     
    126130     * </p> 
    127131     *  
    128      * @param nodeEqualityRuleManager the node equality rule manager to be used by the known rules 
    129      *                                for task tree node comparison during rule application 
    130      * @param taskTreeNodeFactory     the node factory to be used for instantiating new task tree 
    131      *                                nodes during rule application 
    132      * @param taskTreeBuilder         the task tree builder to be used for linking task tree nodes 
     132     * @param taskEqualityRuleManager the task equality rule manager to be used by the known rules 
     133     *                                for task comparison during rule application 
     134     * @param taskFactory             the task factory to be used for instantiating new task tree 
     135     *                                tasks during rule application 
     136     * @param taskBuilder             the task builder to be used for linking tasks 
    133137     *                                with each other during rule application 
    134138     */ 
    135     public TemporalRelationshipRuleManager(NodeEqualityRuleManager nodeEqualityRuleManager, 
    136                                            ITaskTreeNodeFactory    taskTreeNodeFactory, 
    137                                            ITaskTreeBuilder        taskTreeBuilder) 
     139    public TemporalRelationshipRuleManager(TaskEqualityRuleManager taskEqualityRuleManager, 
     140                                           ITaskFactory            taskFactory, 
     141                                           ITaskBuilder            taskBuilder) 
    138142    { 
    139143        super(); 
    140         this.nodeEqualityRuleManager = nodeEqualityRuleManager; 
    141         this.taskTreeNodeFactory = taskTreeNodeFactory; 
    142         this.taskTreeBuilder = taskTreeBuilder; 
     144        this.taskEqualityRuleManager = taskEqualityRuleManager; 
     145        this.taskFactory = taskFactory; 
     146        this.taskBuilder = taskBuilder; 
    143147    } 
    144148 
     
    146150     * <p> 
    147151     * initialized the temporal relationship rule manager by instantiating the known rules and 
    148      * providing them with a reference to the node equality manager or other information they need. 
     152     * providing them with a reference to the task equality manager or other information they need. 
    149153     * </p> 
    150154     */ 
     
    156160        //frameFilter.add(ICanvas.class); 
    157161 
    158         treeScopeRules = new TemporalRelationshipRule[] { 
     162        sessionScopeRules = new ISessionScopeRule[] { 
    159163            new SequenceForTaskDetectionRule 
    160                 (nodeEqualityRuleManager, NodeEquality.SEMANTICALLY_EQUAL, 
    161                  taskTreeNodeFactory, taskTreeBuilder), 
     164                (taskEqualityRuleManager, TaskEquality.SEMANTICALLY_EQUAL, 
     165                 taskFactory, taskBuilder), 
    162166            /*new DefaultTaskSequenceDetectionRule 
    163                 (nodeEqualityRuleManager, NodeEquality.SYNTACTICALLY_EQUAL, 
    164                  taskTreeNodeFactory, taskTreeBuilder), 
     167                (taskEqualityRuleManager, NodeEquality.SYNTACTICALLY_EQUAL, 
     168                 taskFactory, taskTreeBuilder), 
    165169            new DefaultTaskSequenceDetectionRule 
    166                 (nodeEqualityRuleManager, NodeEquality.LEXICALLY_EQUAL, 
    167                  taskTreeNodeFactory, taskTreeBuilder),*/ 
     170                (taskEqualityRuleManager, NodeEquality.LEXICALLY_EQUAL, 
     171                 taskFactory, taskTreeBuilder),*/ 
    168172            /*new TreeScopeWrapperRule 
    169173                (new DefaultIterationDetectionRule 
    170                     (nodeEqualityRuleManager, NodeEquality.LEXICALLY_EQUAL, 
    171                      taskTreeNodeFactory, taskTreeBuilder)), 
     174                    (taskEqualityRuleManager, NodeEquality.LEXICALLY_EQUAL, 
     175                     taskFactory, taskTreeBuilder)), 
    172176            new TreeScopeWrapperRule 
    173177                (new DefaultIterationDetectionRule 
    174                     (nodeEqualityRuleManager, NodeEquality.SYNTACTICALLY_EQUAL, 
    175                      taskTreeNodeFactory, taskTreeBuilder)), 
     178                    (taskEqualityRuleManager, NodeEquality.SYNTACTICALLY_EQUAL, 
     179                     taskFactory, taskTreeBuilder)), 
    176180            new TreeScopeWrapperRule 
    177181                (new DefaultIterationDetectionRule 
    178                     (nodeEqualityRuleManager, NodeEquality.SEMANTICALLY_EQUAL, 
    179                      taskTreeNodeFactory, taskTreeBuilder))*/ 
     182                    (taskEqualityRuleManager, NodeEquality.SEMANTICALLY_EQUAL, 
     183                     taskFactory, taskTreeBuilder))*/ 
    180184        }; 
    181185         
    182186        //treeScopeRules.add(new DefaultGuiElementSequenceDetectionRule(frameFilter)); 
    183187 
    184         nodeScopeRules = new TemporalRelationshipRule[] { 
    185             //new SequenceOnGuiElementDetectionRule(taskTreeNodeFactory, taskTreeBuilder), 
    186             //new EventSequenceOnSameTargetDetectionRule(taskTreeNodeFactory, taskTreeBuilder), 
    187             new TrackBarSelectionDetectionRule 
    188                 (nodeEqualityRuleManager, taskTreeNodeFactory, taskTreeBuilder), 
    189             //new DefaultGuiEventSequenceDetectionRule(taskTreeNodeFactory, taskTreeBuilder), 
     188        taskScopeRules = new ITaskInstanceListScopeRule[] { 
     189            //new SequenceOnGuiElementDetectionRule(taskFactory, taskTreeBuilder), 
     190            //new EventSequenceOnSameTargetDetectionRule(taskFactory, taskTreeBuilder), 
     191            //new TrackBarSelectionDetectionRule(taskEqualityRuleManager, taskFactory, taskBuilder), 
     192            //new DefaultGuiEventSequenceDetectionRule(taskFactory, taskTreeBuilder), 
    190193        }; 
    191194 
     
    194197    /** 
    195198     * <p> 
    196      * applies the known rules to the provided parent node. For the creation of further nodes, 
    197      * the provided builder and node factory are utilized. The method expectes, that no more data 
     199     * applies the known rules to the provided sessions. For the creation of further tasks, 
     200     * the provided builder and task factory are utilized. The method expects, that no more data 
    198201     * is available and, therefore, finalizes the rule application. 
    199202     * </p> 
    200203     *  
    201      * @param nodeFactory  the node factory to be used for instantiating new task tree nodes. 
    202      */ 
    203     public void applyRules(ITaskTreeNode parent) { 
    204         applyRules(parent, true); 
    205     } 
    206  
    207     /** 
    208      * <p> 
    209      * applies the known rules to the provided parent node. For the creation of further nodes, 
    210      * the provided builder and node factory are utilized. If the finalize parameter is true, the 
     204     * @param taskFactory  the task factory to be used for instantiating new tasks. 
     205     */ 
     206    public void applyRules(List<IUserSession> sessions) { 
     207        applyRules(sessionScopeRules, sessions, ""); 
     208    } 
     209 
     210    /** 
     211     * <p> 
     212     * applies the known rules to the provided parent task. For the creation of further tasks, 
     213     * the provided builder and task factory are utilized. If the finalize parameter is true, the 
    211214     * rule application is finalized as far as possible without waiting for further data. If it is 
    212215     * false, the rule application is broken up at the first rule returning, that its application 
    213      * would be feasible.  
     216     * would be feasible. The method calls itself for each parent task created through the rule 
     217     * application. In this case, the finalize parameter is always true. 
    214218     * </p> 
    215219     *  
    216      * @param parent       the parent node to apply the rules on 
    217      * @param finalize     used to indicate, if the rule application shall break up if a rule would 
    218      *                     be feasible if further data was available, or not. 
    219      */ 
    220     public void applyRules(ITaskTreeNode parent, boolean finalize) { 
    221         applyRules(treeScopeRules, parent, finalize, ""); 
    222     } 
    223  
    224     /** 
    225      * <p> 
    226      * applies the known rules to the provided parent node. For the creation of further nodes, 
    227      * the provided builder and node factory are utilized. If the finalize parameter is true, the 
    228      * rule application is finalized as far as possible without waiting for further data. If it is 
    229      * false, the rule application is broken up at the first rule returning, that its application 
    230      * would be feasible. The method calls itself for each parent node created through the rule 
    231      * application. In this case, the finalize parameter is always true. 
    232      * </p> 
    233      *  
    234      * @param parent       the parent node to apply the rules on 
     220     * @param parent       the parent task to apply the rules on 
    235221     * @param finalize     used to indicate, if the rule application shall break up if a rule would 
    236222     *                     be feasible if further data was available, or not. 
     
    238224     *                     on the recursion depth of calling this method. 
    239225     */ 
    240     private int applyRules(TemporalRelationshipRule[] rules, 
    241                            ITaskTreeNode              parent, 
    242                            boolean                    finalize, 
    243                            String                     logIndent) 
     226    private int applyRules(ISessionScopeRule[] rules, 
     227                           List<IUserSession>  sessions, 
     228                           String              logIndent) 
    244229    { 
    245         Console.traceln(Level.FINER, logIndent + "applying rules for " + parent); 
     230        Console.traceln 
     231            (Level.FINER, logIndent + "applying rules for " + sessions.size() + " sessions"); 
    246232 
    247233        int noOfRuleApplications = 0; 
    248234 
    249         for (TemporalRelationshipRule rule : rules) { 
     235        for (ISessionScopeRule rule : rules) { 
    250236            RuleApplicationResult result; 
    251237            do { 
    252                 Console.traceln(Level.FINER, logIndent + "trying rule " + rule + " on " + parent); 
    253                 result = rule.apply(parent, finalize); 
     238                Console.traceln(Level.FINER, logIndent + "trying rule " + rule); 
     239                result = rule.apply(sessions); 
    254240 
    255241                if ((result != null) && 
    256242                    (result.getRuleApplicationStatus() == RuleApplicationStatus.FINISHED)) 
    257243                { 
    258                     Console.traceln 
    259                         (Level.FINE, logIndent + "applied rule " + rule + " on " + parent); 
     244                    Console.traceln(Level.FINE, logIndent + "applied rule " + rule); 
    260245                    noOfRuleApplications++; 
    261246                     
    262247                    //dumpTask(parent, ""); 
    263248 
    264                     for (ITaskTreeNode newParent : result.getNewlyCreatedParentNodes()) { 
     249                    for (ITaskInstance newParent : result.getNewlyCreatedTaskInstances()) { 
    265250                        noOfRuleApplications += 
    266                             applyRules(nodeScopeRules, newParent, true, logIndent + "  "); 
     251                            applyRules(taskScopeRules, newParent, logIndent + "  "); 
    267252                    } 
    268253                } 
     
    271256                   (result.getRuleApplicationStatus() == RuleApplicationStatus.FINISHED)); 
    272257 
    273             if ((!finalize) && 
    274                 (result != null) && 
    275                 (result.getRuleApplicationStatus() == RuleApplicationStatus.FEASIBLE)) 
    276             { 
    277                 // in this case, don't go on applying rules, which should not be applied yet 
    278                 break; 
    279             } 
    280258        } 
    281259 
     
    289267 
    290268    /** 
     269     * <p> 
     270     * applies the known rules to the provided parent task. For the creation of further tasks, 
     271     * the provided builder and task factory are utilized. If the finalize parameter is true, the 
     272     * rule application is finalized as far as possible without waiting for further data. If it is 
     273     * false, the rule application is broken up at the first rule returning, that its application 
     274     * would be feasible. The method calls itself for each parent task created through the rule 
     275     * application. In this case, the finalize parameter is always true. 
     276     * </p> 
     277     *  
     278     * @param parent       the parent task to apply the rules on 
     279     * @param finalize     used to indicate, if the rule application shall break up if a rule would 
     280     *                     be feasible if further data was available, or not. 
     281     * @param logIndent    simply used for logging purposes to indent the log messages depending 
     282     *                     on the recursion depth of calling this method. 
     283     */ 
     284    private int applyRules(ITaskInstanceListScopeRule[] rules, 
     285                           ITaskInstanceList            taskInstances, 
     286                           String                       logIndent) 
     287    { 
     288        Console.traceln(Level.FINER, logIndent + "applying rules for " + taskInstances.size() + 
     289                        " task instances"); 
     290 
     291        int noOfRuleApplications = 0; 
     292 
     293        for (ITaskInstanceListScopeRule rule : rules) { 
     294            RuleApplicationResult result; 
     295            do { 
     296                Console.traceln 
     297                    (Level.FINER, logIndent + "trying rule " + rule + " on " + taskInstances); 
     298                result = rule.apply(taskInstances); 
     299 
     300                if ((result != null) && 
     301                    (result.getRuleApplicationStatus() == RuleApplicationStatus.FINISHED)) 
     302                { 
     303                    Console.traceln 
     304                        (Level.FINE, logIndent + "applied rule " + rule + " on " + taskInstances); 
     305                    noOfRuleApplications++; 
     306                     
     307                    //dumpTask(parent, ""); 
     308 
     309                    for (ITaskInstance newParent : result.getNewlyCreatedTaskInstances()) { 
     310                        noOfRuleApplications += 
     311                            applyRules(taskScopeRules, newParent, logIndent + "  "); 
     312                    } 
     313                } 
     314            } 
     315            while ((result != null) && 
     316                   (result.getRuleApplicationStatus() == RuleApplicationStatus.FINISHED)); 
     317        } 
     318 
     319        if (noOfRuleApplications <= 0) { 
     320            Console.traceln(Level.FINE, logIndent + "no rules applied --> no temporal " + 
     321                            "relationship generated"); 
     322        } 
     323 
     324        return noOfRuleApplications; 
     325    } 
     326 
     327    /** 
    291328     * 
    292329     */ 
    293     /*private void dumpTask(ITaskTreeNode task, String indent) { 
     330    /*private void dumpTask(ITask task, String indent) { 
    294331        StringBuffer message = new StringBuffer(); 
    295332        message.append(indent); 
     
    304341         
    305342        if ((task.getChildren() != null) && (task.getChildren().size() > 0)) { 
    306             for (ITaskTreeNode child : task.getChildren()) { 
     343            for (ITask child : task.getChildren()) { 
    307344                dumpTask(child, indent + "  "); 
    308345            } 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/IEventTask.java

    r1114 r1146  
    2424 * @author 2011, last modified by $Author: $ 
    2525 */ 
    26 public interface IEventTask extends ITaskTreeNode { 
     26public interface IEventTask extends ITask { 
    2727     
    2828    /** 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/IIteration.java

    r1114 r1146  
    2121 * @author 2012, last modified by $Author: patrick$ 
    2222 */ 
    23 public interface IIteration extends ITemporalRelationship { 
     23public interface IIteration extends IMarkingTemporalRelationship { 
    2424 
    2525    /** 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/IOptional.java

    r1126 r1146  
    2121 * @author 2012, last modified by $Author: patrick$ 
    2222 */ 
    23 public interface IOptional extends ITemporalRelationship { 
     23public interface IOptional extends IMarkingTemporalRelationship { 
    2424 
    2525    /** 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ISelection.java

    r1114 r1146  
    2121 * @author 2012, last modified by $Author: patrick$ 
    2222 */ 
    23 public interface ISelection extends ITemporalRelationship { 
     23public interface ISelection extends IStructuringTemporalRelationship { 
    2424 
    2525    /** 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ISequence.java

    r1114 r1146  
    2121 * @author 2012, last modified by $Author: patrick$ 
    2222 */ 
    23 public interface ISequence extends ITemporalRelationship { 
     23public interface ISequence extends IStructuringTemporalRelationship { 
    2424 
    2525    /** 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITaskBuilder.java

    r1126 r1146  
    2121 * @author 2012, last modified by $Author: patrick$ 
    2222 */ 
    23 public interface ITaskTreeBuilder { 
     23public interface ITaskBuilder { 
    2424 
    2525    /** 
    26      * 
     26     * @param taskInstance 
     27     * @param child 
    2728     */ 
    28     void addChild(ISequence parent, ITaskTreeNode child); 
     29    void addChild(ITaskInstance taskInstance, ITaskInstance child) throws IllegalArgumentException; 
    2930 
    3031    /** 
     32     * <p> 
     33     * TODO: comment 
     34     * </p> 
    3135     * 
     36     * @param session 
     37     * @param taskInstance 
    3238     */ 
    33     void addChild(ISequence parent, int index, ITaskTreeNode child); 
     39    void addExecutedTask(IUserSession session, ITaskInstance taskInstance); 
    3440 
    3541    /** 
     
    3844     * @param i 
    3945     */ 
    40     void setChild(ISequence parent, int index, ITaskTreeNode child); 
     46    void addTaskInstance(ITaskInstanceList taskInstanceList, ITaskInstance taskInstance); 
     47 
     48    /** 
     49     *  
     50     * @param parent 
     51     * @param i 
     52     */ 
     53    void addTaskInstance(ITaskInstanceList taskInstanceList, int index, ITaskInstance taskInstance); 
     54 
     55    /** 
     56     *  
     57     * @param parent 
     58     * @param i 
     59     */ 
     60    void setTaskInstance(ITaskInstanceList taskInstanceList, int index, ITaskInstance taskInstance); 
     61 
     62    /** 
     63     * <p> 
     64     * TODO: comment 
     65     * </p> 
     66     * 
     67     * @param instance2 
     68     * @param task 
     69     */ 
     70    void setTask(ITaskInstance taskInstance, ITask task); 
     71 
     72    /** 
     73     * 
     74     */ 
     75    void addChild(ISequence parent, ITask child); 
     76 
     77    /** 
     78     * 
     79     */ 
     80    void addChild(ISequence parent, int index, ITask child); 
     81 
     82    /** 
     83     *  
     84     * @param parent 
     85     * @param i 
     86     */ 
     87    void setChild(ISequence parent, int index, ITask child); 
    4188 
    4289    /** 
     
    4491     * @param task 
    4592     */ 
    46     void addChild(ISelection parent, ITaskTreeNode child); 
     93    void addChild(ISelection parent, ITask child); 
    4794 
    4895    /** 
     
    5198     * @param newChild 
    5299     */ 
    53     void setChild(IIteration iteration, ITaskTreeNode newChild); 
     100    void setMarkedTask(IIteration iteration, ITask newChild); 
    54101 
    55102    /** 
     
    58105     * @param newChild 
    59106     */ 
    60     void setChild(IOptional optional, ITaskTreeNode newChild); 
     107    void setMarkedTask(IOptional optional, ITask newChild); 
    61108 
    62109    /** 
     
    72119     * @param i 
    73120     */ 
    74     void removeChild(ISelection parent, ITaskTreeNode child); 
     121    void removeChild(ISelection parent, ITask child); 
     122 
     123    /** 
     124     *  
     125     * @param parent 
     126     * @param i 
     127     */ 
     128    void removeTaskInstance(ITaskInstanceList taskInstanceList, int index); 
    75129 
    76130    /** 
     
    79133     * @param i 
    80134     */ 
    81     void replaceChild(ISelection parent, ITaskTreeNode oldChild, ITaskTreeNode newChild); 
     135    void replaceChild(ISelection parent, ITask oldChild, ITask newChild); 
    82136 
    83137    /** 
     
    86140     * @param i 
    87141     */ 
    88     void setDescription(ITaskTreeNode node, String description); 
     142    void setDescription(ITask task, String description); 
    89143 
    90144} 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITaskFactory.java

    r1126 r1146  
    1515package de.ugoe.cs.autoquest.tasktrees.treeifc; 
    1616 
     17import java.util.List; 
     18 
    1719import de.ugoe.cs.autoquest.eventcore.IEventTarget; 
    1820import de.ugoe.cs.autoquest.eventcore.IEventType; 
     
    2426 * @author 2012, last modified by $Author: patrick$ 
    2527 */ 
    26 public interface ITaskTreeNodeFactory 
    27 { 
     28public interface ITaskFactory { 
    2829 
    29   /** 
    30    * 
    31    * @param eventType 
    32    * @param eventTarget 
    33    * @return 
    34    */ 
    35   IEventTask createNewEventTask(IEventType eventType, IEventTarget eventTarget); 
     30    /** 
     31     *  
     32     * @param eventType 
     33     * @param eventTarget 
     34     * @return 
     35     */ 
     36    IEventTask createNewEventTask(IEventType eventType, IEventTarget eventTarget); 
    3637 
    37   /** 
    38    * 
    39    * @return 
    40    */ 
    41   ISequence createNewSequence(); 
     38    /** 
     39     *  
     40     * @return 
     41     */ 
     42    ISequence createNewSequence(); 
    4243 
    43   /** 
    44    * 
    45    * @return 
    46    */ 
    47   IIteration createNewIteration(); 
     44    /** 
     45     *  
     46     * @return 
     47     */ 
     48    IIteration createNewIteration(); 
    4849 
    49   /** 
    50    * 
    51    * @return 
    52    */ 
    53   IOptional createNewOptional(); 
     50    /** 
     51     *  
     52     * @return 
     53     */ 
     54    IOptional createNewOptional(); 
    5455 
    55   /** 
    56    * 
    57    * @return 
    58    */ 
    59   ISelection createNewSelection(); 
     56    /** 
     57     *  
     58     * @return 
     59     */ 
     60    ISelection createNewSelection(); 
    6061 
    61   /** 
    62    * 
    63    * @param rootSequence 
    64    * @return 
    65    */ 
    66   ITaskTree createTaskTree(ITaskTreeNode root); 
     62    /** 
     63     *  
     64     * @return 
     65     */ 
     66    ITaskInstance createNewTaskInstance(ITask task); 
     67 
     68    /** 
     69     * 
     70     * @return 
     71     */ 
     72    ITaskInstanceList createNewTaskInstanceList(); 
     73 
     74    /** 
     75     *  
     76     * @return 
     77     */ 
     78    IUserSession createUserSession(); 
     79 
     80    /** 
     81     *  
     82     * @param rootSequence 
     83     * @return 
     84     */ 
     85    ITaskModel createTaskModel(List<IUserSession> userSessions); 
    6786 
    6887} 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITaskInstance.java

    r1113 r1146  
    2323 * @author 2011, last modified by $Author: $ 
    2424 */ 
    25 public interface ITaskTreeNode extends Cloneable { 
     25public interface ITaskInstance extends ITaskInstanceList { 
    2626 
    2727    /** 
    2828     * 
    2929     */ 
    30     public String getName(); 
     30    public List<ITaskInstance> getChildren(); 
    3131 
    3232    /** 
    3333     * 
    3434     */ 
    35     public String getDescription(); 
     35    public ITask getTask(); 
    3636 
    3737    /** 
    3838     * 
    3939     */ 
    40     public List<ITaskTreeNode> getChildren(); 
    41  
    42     /** 
    43      * 
    44      */ 
    45     public boolean equals(ITaskTreeNode taskTreeNode); 
     40    public boolean equals(ITaskInstance taskInstance); 
    4641 
    4742    /** 
     
    5348     * 
    5449     */ 
    55     public ITaskTreeNode clone(); 
    56      
     50    public ITaskInstance clone(); 
     51 
    5752} 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITaskModel.java

    r1114 r1146  
    1515package de.ugoe.cs.autoquest.tasktrees.treeifc; 
    1616 
    17 import java.util.Map; 
     17import java.io.Serializable; 
     18import java.util.Collection; 
     19import java.util.List; 
    1820 
    1921/** 
     
    2325 * @author 2012, last modified by $Author: patrick$ 
    2426 */ 
    25 public interface ITaskTree extends Cloneable { 
     27public interface ITaskModel extends Cloneable, Serializable { 
    2628 
    2729    /** 
    2830     * 
    2931     */ 
    30     public ITaskTreeNode getRoot(); 
     32    public List<IUserSession> getUserSessions(); 
    3133 
    3234    /** 
    3335     * 
    3436     */ 
    35     public Map<ITaskTreeNode, ITaskTreeNodeInfo> getTaskMap(); 
     37    public Collection<ITask> getTasks(); 
    3638 
    3739    /** 
    3840     * 
    3941     */ 
    40     public ITaskTree clone(); 
     42    public ITaskInfo getTaskInfo(ITask task); 
     43 
     44    /** 
     45     * 
     46     */ 
     47    public ITaskModel clone(); 
    4148} 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITemporalRelationship.java

    r1113 r1146  
    2121 * @author 2012, last modified by $Author: patrick$ 
    2222 */ 
    23 public interface ITemporalRelationship extends ITaskTreeNode { 
     23public interface ITemporalRelationship extends ITask { 
    2424 
    2525    /** 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/EventTask.java

    r1126 r1146  
    1818import de.ugoe.cs.autoquest.eventcore.IEventType; 
    1919import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 
    20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    2120 
    2221/** 
     
    2625 * @author 2011, last modified by $Author: $ 
    2726 */ 
    28 public class EventTask extends TaskTreeNode implements IEventTask { 
     27class EventTask extends Task implements IEventTask { 
    2928     
     29    /**  */ 
     30    private static final long serialVersionUID = 1L; 
     31 
    3032    /** */ 
    3133    private IEventType eventType; 
     
    3941     */ 
    4042    EventTask(IEventType eventType, IEventTarget eventTarget) { 
    41         super(eventType.toString()); 
    42         super.setDescription("executed on " + eventTarget); 
     43        super.setDescription(eventType.toString() + " executed on " + eventTarget); 
    4344        this.eventType = eventType; 
    4445        this.eventTarget = eventTarget; 
     
    6263     * (non-Javadoc) 
    6364     *  
    64      * @see de.harms.ctte.Task#equals(de.harms.ctte.Task) 
    65      */ 
    66     @Override 
    67     public boolean equals(ITaskTreeNode task) { 
    68         if (!(task instanceof IEventTask)) { 
    69             return false; 
    70         } 
    71  
    72         IEventType otherType = ((IEventTask) task).getEventType(); 
    73         IEventTarget otherTarget = ((IEventTask) task).getEventTarget(); 
    74  
    75         if (((eventType == otherType) || 
    76              ((eventType != null) && (eventType.equals(otherType)))) && 
    77             ((eventTarget == otherTarget) || 
    78              ((eventTarget != null) && (eventTarget.equals(otherTarget))))) 
    79         { 
    80             return true; 
    81         } 
    82  
    83         return false; 
    84     } 
    85  
    86     /* 
    87      * (non-Javadoc) 
    88      *  
    8965     * @see de.harms.tasktrees.TreeNode#clone() 
    9066     */ 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/Iteration.java

    r1126 r1146  
    1616 
    1717import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 
    18 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
     18import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 
     19import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    1920 
    2021/** 
     
    2425 * @author 2012, last modified by $Author: patrick$ 
    2526 */ 
    26 public class Iteration extends TaskTreeNode implements IIteration { 
     27class Iteration extends MarkingTemporalRelationship implements IIteration { 
     28 
     29    /**  */ 
     30    private static final long serialVersionUID = 1L; 
    2731 
    2832    /** 
     
    3034     */ 
    3135    Iteration() { 
    32         super("Iteration"); 
     36        super("iteration"); 
    3337    } 
    3438 
    35     /* 
    36      * (non-Javadoc) 
    37      *  
    38      * @see de.ugoe.cs.tasktree.treeifc.TaskTreeNode#addChild(TaskTreeNode) 
     39    /* (non-Javadoc) 
     40     * @see MarkingTemporalRelationship#setMarkedTask(ITask) 
    3941     */ 
    4042    @Override 
    41     public void addChild(ITaskTreeNode child) { 
    42         // adding more children is not allowed 
    43         throw new UnsupportedOperationException 
    44             ("iterations may not have a list of children. Use setChild() instead."); 
    45     } 
    46  
    47     /** 
    48      * TODO: comment 
    49      *  
    50      * @param selection 
    51      * @return 
    52      */ 
    53     public void setChild(ITaskTreeNode child) { 
    54         if (super.getChildren().size() > 0) { 
    55             super.removeChild(0); 
     43    protected void setMarkedTask(ITask markedTask) { 
     44        if (markedTask instanceof IIteration) { 
     45            throw new IllegalArgumentException 
     46                ("the marked task of an iteration must not be an iteration"); 
    5647        } 
    57         super.addChild(child); 
     48        else if (markedTask instanceof IOptional) { 
     49            throw new IllegalArgumentException 
     50                ("the marked task of an iteration must not be an optional"); 
     51        } 
     52         
     53        super.setMarkedTask(markedTask); 
    5854    } 
    5955 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/Optional.java

    r1126 r1146  
    1616 
    1717import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 
    18 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
     18import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    1919 
    2020/** 
     
    2424 * @author 2012, last modified by $Author: patrick$ 
    2525 */ 
    26 public class Optional extends TaskTreeNode implements IOptional { 
     26class Optional extends MarkingTemporalRelationship implements IOptional { 
     27 
     28    /**  */ 
     29    private static final long serialVersionUID = 1L; 
    2730 
    2831    /** 
     
    3033     */ 
    3134    Optional() { 
    32         super("Optional"); 
     35        super("optionality"); 
    3336    } 
    34  
    35     /* 
    36      * (non-Javadoc) 
    37      *  
    38      * @see de.ugoe.cs.tasktree.treeifc.TaskTreeNode#addChild(TaskTreeNode) 
     37     
     38    /* (non-Javadoc) 
     39     * @see MarkingTemporalRelationship#setMarkedTask(ITask) 
    3940     */ 
    4041    @Override 
    41     public void addChild(ITaskTreeNode child) { 
    42         // adding more children is not allowed 
    43         throw new UnsupportedOperationException 
    44             ("optionalities may not have a list of children. Use setChild() instead."); 
    45     } 
    46  
    47     /** 
    48      * TODO: comment 
    49      *  
    50      * @param selection 
    51      * @return 
    52      */ 
    53     public void setChild(ITaskTreeNode child) { 
    54         if (super.getChildren().size() > 0) { 
    55             super.removeChild(0); 
     42    protected void setMarkedTask(ITask markedTask) { 
     43        if (markedTask instanceof IOptional) { 
     44            throw new IllegalArgumentException 
     45                ("the marked task of an optional must not be an optional"); 
    5646        } 
    57         super.addChild(child); 
     47         
     48        super.setMarkedTask(markedTask); 
    5849    } 
    5950 
     
    6758        return (Optional) super.clone(); 
    6859    } 
    69  
    7060} 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/Selection.java

    r1113 r1146  
    1616 
    1717import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
     18import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    1819 
    1920/** 
     
    2324 * @author 2012, last modified by $Author: patrick$ 
    2425 */ 
    25 public class Selection extends TaskTreeNode implements ISelection { 
     26class Selection extends StructuringTemporalRelationship implements ISelection { 
     27 
     28    /**  */ 
     29    private static final long serialVersionUID = 1L; 
    2630 
    2731    /** 
     
    3135     */ 
    3236    Selection() { 
    33         super("Selection"); 
     37        super("selection"); 
    3438    } 
    3539 
     
    4448    } 
    4549 
     50    /** 
     51     * <p> 
     52     * TODO: comment 
     53     * </p> 
     54     * 
     55     * @param i 
     56     * @param newChild 
     57     */ 
     58    public void addChild(ITask newChild) { 
     59        super.addChild(newChild); 
     60        super.setDescription("selection of " + newChild); 
     61    } 
     62 
     63    /** 
     64     * <p> 
     65     * TODO: comment 
     66     * </p> 
     67     * 
     68     * @param i 
     69     * @param newChild 
     70     */ 
     71    public void addChild(int index, ITask newChild) { 
     72        super.addChild(index, newChild); 
     73        super.setDescription("selection of " + newChild); 
     74    } 
     75 
    4676} 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/Sequence.java

    r1113 r1146  
    2323 * @author 2012, last modified by $Author: patrick$ 
    2424 */ 
    25 public class Sequence extends TaskTreeNode implements ISequence { 
     25class Sequence extends StructuringTemporalRelationship implements ISequence { 
    2626     
     27    /**  */ 
     28    private static final long serialVersionUID = 1L; 
     29 
    2730    /** 
    2831     * TODO: comment 
     
    3134     */ 
    3235    Sequence() { 
    33         super("Sequence"); 
    34     } 
    35  
    36     /** 
    37      * TODO: comment 
    38      *  
    39      * @param name 
    40      */ 
    41     Sequence(String name) { 
    42         super(name); 
     36        super("sequence"); 
    4337    } 
    4438 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/Task.java

    r1126 r1146  
    1515package de.ugoe.cs.autoquest.tasktrees.treeimpl; 
    1616 
    17 import java.util.Collections; 
    18 import java.util.LinkedList; 
    19 import java.util.List; 
    20  
    21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
     17import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    2218 
    2319/** 
     
    2723 * @author 2011, last modified by $Author: $ 
    2824 */ 
    29 public class TaskTreeNode implements ITaskTreeNode { 
     25class Task implements ITask { 
     26 
     27    /**  */ 
     28    private static final long serialVersionUID = 1L; 
     29 
    3030    /** */ 
    3131    private static int temporalId = 0; 
    3232 
    3333    /** */ 
    34     private String name; 
     34    private int id; 
    3535 
    3636    /** */ 
    3737    private String description; 
    3838 
    39     /** */ 
    40     private int id; 
    41  
    42     /** children */ 
    43     private List<ITaskTreeNode> children; 
    44  
    4539    /** 
    4640     *  
    4741     */ 
    48     public TaskTreeNode(String name) { 
    49         this.name = name; 
     42    Task() { 
    5043        id = getNewId(); 
    5144    } 
     
    6760     * @return Returns the name. 
    6861     */ 
    69     public String getName() { 
    70         return name; 
     62    public int getId() { 
     63        return id; 
    7164    } 
    7265 
     
    8174    } 
    8275 
    83     /** 
    84      *  
    85      */ 
    86     public synchronized List<ITaskTreeNode> getChildren() { 
    87         if ((children == null) || (children.size() == 0)) { 
    88             return new LinkedList<ITaskTreeNode>(); 
    89         } 
    90  
    91         return Collections.unmodifiableList(children); 
    92     } 
    93  
    9476    /* 
    9577     * (non-Javadoc) 
     
    9880     */ 
    9981    @Override 
    100     public boolean equals(ITaskTreeNode taskTreeNode) { 
    101         if (!this.getClass().isInstance(taskTreeNode)) { 
    102             return false; 
    103         } 
    104  
    105         if (taskTreeNode.hashCode() != hashCode()) { 
    106             return false; 
    107         } 
    108  
    109         TaskTreeNode other = (TaskTreeNode) taskTreeNode; 
    110  
    111         if (id != other.id) { 
    112             return false; 
    113         } 
    114  
    115         if (!name.equals(other.name)) { 
    116             return false; 
    117         } 
    118  
    119         synchronized (other) { 
    120             if (children == null) { 
    121                 return (other.children == null); 
    122             } 
    123             else if (other.children == null) { 
    124                 return (children == null); 
    125             } 
    126             else if (other.children.size() != children.size()) { 
    127                 return false; 
    128             } 
    129  
    130             for (int i = 0; i < children.size(); i++) { 
    131                 if (!children.get(i).equals(other.children.get(i))) { 
    132                     return false; 
    133                 } 
    134             } 
    135         } 
    136  
    137         return true; 
     82    public final boolean equals(ITask task) { 
     83        // tasks are only equal if they are identical or if they have the same id 
     84        // (may happen, if they are cloned) 
     85        return (this == task) || (this.hashCode() == task.hashCode()); 
    13886    } 
    13987 
     
    14593    @Override 
    14694    public synchronized int hashCode() { 
    147         return getClass().getSimpleName().hashCode(); 
     95        return id; 
    14896    } 
    14997 
     
    156104    public synchronized String toString() { 
    157105        StringBuffer result = new StringBuffer(); 
    158         result.append(name); 
    159         result.append('('); 
     106        result.append("task "); 
    160107        result.append(id); 
    161108         
    162109        if (description != null) { 
    163             result.append(", "); 
     110            result.append(" ("); 
    164111            result.append(description); 
     112            result.append(')'); 
    165113        } 
    166114         
    167         if (children != null) { 
    168             result.append(", "); 
    169             result.append(children.size()); 
    170             result.append(" children"); 
     115        return result.toString(); 
     116    } 
     117 
     118    /* 
     119     * (non-Javadoc) 
     120     *  
     121     * @see java.lang.Object#clone() 
     122     */ 
     123    @Override 
     124    public synchronized ITask clone() { 
     125        Task clone = null; 
     126        try { 
     127            clone = (Task) super.clone(); 
    171128        } 
    172          
    173         result.append(')'); 
    174         return result.toString(); 
     129        catch (CloneNotSupportedException e) { 
     130            // this should never happen. Therefore simply dump the exception 
     131            e.printStackTrace(); 
     132        } 
     133 
     134        return clone; 
    175135    } 
    176136 
     
    185145    } 
    186146 
    187     /** 
    188      *  
    189      */ 
    190     synchronized void addChild(ITaskTreeNode child) { 
    191         if (children == null) { 
    192             children = new LinkedList<ITaskTreeNode>(); 
    193         } 
    194  
    195         children.add(child); 
    196     } 
    197  
    198     /** 
    199      *  
    200      */ 
    201     synchronized void addChild(int index, ITaskTreeNode child) { 
    202         if (children == null) { 
    203             children = new LinkedList<ITaskTreeNode>(); 
    204         } 
    205  
    206         children.add(index, child); 
    207     } 
    208  
    209     /** 
    210      * TODO: comment 
    211      *  
    212      * @param i 
    213      * @return 
    214      */ 
    215     synchronized ITaskTreeNode removeChild(int index) { 
    216         return children.remove(index); 
    217     } 
    218  
    219     /* 
    220      * (non-Javadoc) 
    221      *  
    222      * @see java.lang.Object#clone() 
    223      */ 
    224     @Override 
    225     public synchronized ITaskTreeNode clone() { 
    226         TaskTreeNode clone = null; 
    227         try { 
    228             clone = (TaskTreeNode) super.clone(); 
    229  
    230             if (children != null) { 
    231                 clone.children = new LinkedList<ITaskTreeNode>(); 
    232  
    233                 for (ITaskTreeNode child : children) { 
    234                     clone.children.add(child.clone()); 
    235                 } 
    236             } 
    237  
    238         } 
    239         catch (CloneNotSupportedException e) { 
    240             // this should never happen. Therefore simply dump the exception 
    241             e.printStackTrace(); 
    242         } 
    243  
    244         return clone; 
    245     } 
    246  
    247147} 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskBuilder.java

    r1126 r1146  
    1717import java.util.List; 
    1818 
     19import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 
    1920import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 
    2021import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 
    2122import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
    2223import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 
    23 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder; 
    24 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
     24import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     25import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; 
     26import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 
     27import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList; 
     28import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 
    2529 
    2630/** 
     
    3034 * @author 2012, last modified by $Author: patrick$ 
    3135 */ 
    32 public class TaskTreeBuilder implements ITaskTreeBuilder { 
     36public class TaskBuilder implements ITaskBuilder { 
     37 
     38    /* (non-Javadoc) 
     39     * @see ITaskBuilder#addChild(ITaskInstance, ITaskInstance) 
     40     */ 
     41    @Override 
     42    public void addChild(ITaskInstance parent, ITaskInstance child) throws IllegalArgumentException 
     43    { 
     44        if (!(parent instanceof TaskInstance)) { 
     45            throw new IllegalArgumentException 
     46                ("illegal type of task instance provided: " + parent.getClass()); 
     47        } 
     48 
     49        if (!(child instanceof TaskInstance)) { 
     50            throw new IllegalArgumentException 
     51                ("illegal type of task instance provided: " + parent.getClass()); 
     52        } 
     53         
     54        // check, that the correct number of children for the distinct types are added 
     55        ITask task = parent.getTask(); 
     56         
     57        if (task instanceof IEventTask) { 
     58            throw new IllegalArgumentException 
     59                ("can not add children to a task instance of an event task"); 
     60        } 
     61        else if (task instanceof ISelection) { 
     62            if (parent.getChildren().size() > 0) { 
     63                throw new IllegalArgumentException 
     64                    ("the instance of a selection must have at most one child"); 
     65            } 
     66        } 
     67        else if (task instanceof IOptional) { 
     68            if (parent.getChildren().size() > 1) { 
     69                throw new IllegalArgumentException 
     70                    ("the instance of an optional must have at most one child"); 
     71            } 
     72        } 
     73/*        else if (task instanceof IIteration) { 
     74            for (ITaskInstance childInstance : parent.getChildren()) { 
     75                if (!childInstance.getTask().equals(child.getTask())) { 
     76                    throw new IllegalArgumentException 
     77                        ("all children of an instance of an iteration must have exactly the " + 
     78                         "same type"); 
     79                } 
     80            } 
     81        } 
     82         
     83        boolean foundChildTask = false; 
     84        if (parent.getTask() instanceof IStructuringTemporalRelationship) { 
     85            IStructuringTemporalRelationship parentTask = 
     86                (IStructuringTemporalRelationship) parent.getTask(); 
     87         
     88            for (ITask parentTaskChild : parentTask.getChildren()) { 
     89                if (parentTaskChild.equals(child.getTask())) { 
     90                    foundChildTask = true; 
     91                    break; 
     92                } 
     93            } 
     94        } 
     95        else if (parent.getTask() instanceof IMarkingTemporalRelationship) { 
     96            IMarkingTemporalRelationship parentTask = 
     97                (IMarkingTemporalRelationship) parent.getTask(); 
     98             
     99            foundChildTask = parentTask.getMarkedTask() != null ? 
     100                parentTask.getMarkedTask().equals(child.getTask()) : false; 
     101        } 
     102         
     103        if (!foundChildTask) { 
     104            throw new IllegalArgumentException 
     105                ("the task of the child instance to be added does not belong to the children " + 
     106                 "of the task of the parent instance"); 
     107        }*/ 
     108 
     109        // finally, after all checks are positive, add the child 
     110        ((TaskInstance) parent).addChild(child); 
     111    } 
     112 
     113    /* (non-Javadoc) 
     114     * @see ITaskBuilder#addExecutedTask(IUserSession, ITaskInstance) 
     115     */ 
     116    @Override 
     117    public void addExecutedTask(IUserSession session, ITaskInstance taskInstance) { 
     118        if (!(session instanceof UserSession)) { 
     119            throw new IllegalArgumentException 
     120                ("illegal type of session provided: " + session.getClass()); 
     121        } 
     122 
     123        if (!(taskInstance instanceof TaskInstance)) { 
     124            throw new IllegalArgumentException 
     125                ("illegal type of task instance provided: " + taskInstance.getClass()); 
     126        } 
     127         
     128        ((UserSession) session).addExecutedTask(taskInstance); 
     129    } 
     130 
     131    /* (non-Javadoc) 
     132     * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder#addTaskInstance(de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList, de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance) 
     133     */ 
     134    @Override 
     135    public void addTaskInstance(ITaskInstanceList taskInstanceList, ITaskInstance taskInstance) { 
     136        if (taskInstanceList instanceof TaskInstance) { 
     137            ((TaskInstance) taskInstanceList).addChild(taskInstance); 
     138        } 
     139        else if (taskInstanceList instanceof UserSession) { 
     140            ((UserSession) taskInstanceList).addExecutedTask(taskInstance); 
     141        } 
     142        else { 
     143            throw new IllegalArgumentException 
     144                ("illegal type of task instance list provided: " + taskInstanceList.getClass()); 
     145        } 
     146    } 
     147 
     148    /* (non-Javadoc) 
     149     * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder#addTaskInstance(de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList, int, de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance) 
     150     */ 
     151    @Override 
     152    public void addTaskInstance(ITaskInstanceList taskInstanceList, 
     153                                int               index, 
     154                                ITaskInstance     taskInstance) 
     155    { 
     156        if (taskInstanceList instanceof TaskInstance) { 
     157            ((TaskInstance) taskInstanceList).addChild(index, taskInstance); 
     158        } 
     159        else if (taskInstanceList instanceof UserSession) { 
     160            ((UserSession) taskInstanceList).addExecutedTask(index, taskInstance); 
     161        } 
     162        else { 
     163            throw new IllegalArgumentException 
     164                ("illegal type of task instance list provided: " + taskInstanceList.getClass()); 
     165        } 
     166    } 
     167 
     168    /* (non-Javadoc) 
     169     * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder#setTaskInstance(de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList, int, de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance) 
     170     */ 
     171    @Override 
     172    public void setTaskInstance(ITaskInstanceList taskInstanceList, 
     173                                int               index, 
     174                                ITaskInstance     taskInstance) 
     175    { 
     176        if (taskInstanceList instanceof TaskInstance) { 
     177            ((TaskInstance) taskInstanceList).removeChild(index); 
     178            ((TaskInstance) taskInstanceList).addChild(index, taskInstance); 
     179        } 
     180        else if (taskInstanceList instanceof UserSession) { 
     181            ((UserSession) taskInstanceList).removeExecutedTask(index); 
     182            ((UserSession) taskInstanceList).addExecutedTask(index, taskInstance); 
     183        } 
     184        else { 
     185            throw new IllegalArgumentException 
     186                ("illegal type of task instance list provided: " + taskInstanceList.getClass()); 
     187        } 
     188    } 
     189 
     190    /* (non-Javadoc) 
     191     * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder#setTask(de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance, de.ugoe.cs.autoquest.tasktrees.treeifc.ITask) 
     192     */ 
     193    @Override 
     194    public void setTask(ITaskInstance taskInstance, ITask task) { 
     195        if (!(taskInstance instanceof TaskInstance)) { 
     196            throw new IllegalArgumentException 
     197                ("illegal type of task instance provided: " + taskInstance.getClass()); 
     198        } 
     199         
     200        ((TaskInstance) taskInstance).setTask(task); 
     201    } 
    33202 
    34203    /* 
     
    38207     */ 
    39208    @Override 
    40     public void addChild(ISequence parent, ITaskTreeNode child) { 
     209    public void addChild(ISequence parent, ITask child) { 
    41210        if (!(parent instanceof Sequence)) { 
    42211            throw new IllegalArgumentException 
    43                 ("illegal type of task tree node provided: " + parent.getClass()); 
    44         } 
    45  
    46         addChildInternal(parent, -1, child); 
     212                ("illegal type of sequence provided: " + parent.getClass()); 
     213        } 
     214 
     215        addChildInternal((Sequence) parent, -1, child); 
    47216    } 
    48217 
     
    53222     */ 
    54223    @Override 
    55     public void addChild(ISequence parent, int index, ITaskTreeNode child) { 
     224    public void addChild(ISequence parent, int index, ITask child) { 
    56225        if (!(parent instanceof Sequence)) { 
    57226            throw new IllegalArgumentException 
    58                 ("illegal type of task tree node provided: " + parent.getClass()); 
    59         } 
    60  
    61         addChildInternal(parent, index, child); 
     227                ("illegal type of sequence provided: " + parent.getClass()); 
     228        } 
     229 
     230        addChildInternal((Sequence) parent, index, child); 
    62231    } 
    63232 
     
    66235     */ 
    67236    @Override 
    68     public void setChild(ISequence parent, int index, ITaskTreeNode child) { 
     237    public void setChild(ISequence parent, int index, ITask child) { 
    69238        if (!(parent instanceof Sequence)) { 
    70239            throw new IllegalArgumentException 
    71                 ("illegal type of task tree node provided: " + parent.getClass()); 
    72         } 
    73  
    74         ((TaskTreeNode) parent).removeChild(index); 
    75         addChildInternal(parent, index, child); 
     240                ("illegal type of sequence provided: " + parent.getClass()); 
     241        } 
     242 
     243        ((Sequence) parent).removeChild(index); 
     244        addChildInternal((Sequence) parent, index, child); 
    76245    } 
    77246 
     
    82251     */ 
    83252    @Override 
    84     public void addChild(ISelection parent, ITaskTreeNode child) { 
     253    public void addChild(ISelection parent, ITask child) { 
    85254        if (!(parent instanceof Selection)) { 
    86255            throw new IllegalArgumentException 
    87                 ("illegal type of task tree node provided: " + parent.getClass()); 
    88         } 
    89  
    90         addChildInternal(parent, -1, child); 
     256                ("illegal type of selection provided: " + parent.getClass()); 
     257        } 
     258 
     259        addChildInternal((Selection) parent, -1, child); 
    91260    } 
    92261 
     
    97266     */ 
    98267    @Override 
    99     public void setChild(IIteration iteration, ITaskTreeNode newChild) { 
     268    public void setMarkedTask(IIteration iteration, ITask newChild) { 
    100269        if (!(iteration instanceof Iteration)) { 
    101270            throw new IllegalArgumentException 
     
    103272        } 
    104273 
    105         if (!(newChild instanceof TaskTreeNode)) { 
    106             throw new IllegalArgumentException 
    107                 ("illegal type of task tree node provided: " + newChild.getClass()); 
    108         } 
    109  
    110         ((Iteration) iteration).setChild(newChild); 
     274        if (!(newChild instanceof Task)) { 
     275            throw new IllegalArgumentException 
     276                ("illegal type of task provided: " + newChild.getClass()); 
     277        } 
     278 
     279        ((Iteration) iteration).setMarkedTask(newChild); 
    111280    } 
    112281 
     
    115284     */ 
    116285    @Override 
    117     public void setChild(IOptional optional, ITaskTreeNode newChild) { 
     286    public void setMarkedTask(IOptional optional, ITask newChild) { 
    118287        if (!(optional instanceof Optional)) { 
    119288            throw new IllegalArgumentException 
     
    121290        } 
    122291 
    123         if (!(newChild instanceof TaskTreeNode)) { 
    124             throw new IllegalArgumentException 
    125                 ("illegal type of task tree node provided: " + newChild.getClass()); 
    126         } 
    127  
    128         ((Optional) optional).setChild(newChild); 
     292        if (!(newChild instanceof Task)) { 
     293            throw new IllegalArgumentException 
     294                ("illegal type of task provided: " + newChild.getClass()); 
     295        } 
     296 
     297        ((Optional) optional).setMarkedTask(newChild); 
    129298    } 
    130299 
     
    136305    @Override 
    137306    public void removeChild(ISequence parent, int index) { 
    138         if (!(parent instanceof TaskTreeNode)) { 
    139             throw new IllegalArgumentException 
    140                 ("illegal type of task tree node provided: " + parent.getClass()); 
    141         } 
    142  
    143         ((TaskTreeNode) parent).removeChild(index); 
     307        if (!(parent instanceof Sequence)) { 
     308            throw new IllegalArgumentException 
     309                ("illegal type of sequence provided: " + parent.getClass()); 
     310        } 
     311 
     312        ((Sequence) parent).removeChild(index); 
    144313    } 
    145314 
     
    150319     */ 
    151320    @Override 
    152     public void removeChild(ISelection parent, ITaskTreeNode child) { 
    153         if (!(parent instanceof TaskTreeNode)) { 
    154             throw new IllegalArgumentException 
    155                 ("illegal type of task tree node provided: " + parent.getClass()); 
    156         } 
    157  
    158         List<ITaskTreeNode> children = parent.getChildren(); 
     321    public void removeChild(ISelection parent, ITask child) { 
     322        if (!(parent instanceof Selection)) { 
     323            throw new IllegalArgumentException 
     324                ("illegal type of selection provided: " + parent.getClass()); 
     325        } 
     326 
     327        List<ITask> children = parent.getChildren(); 
    159328         
    160329        for (int i = 0; i < children.size(); i++) { 
     
    162331                ((children.get(i) != null) && (children.get(i).equals(child)))) 
    163332            { 
    164                 ((TaskTreeNode) parent).removeChild(i); 
     333                ((Selection) parent).removeChild(i); 
    165334                break; 
    166335            } 
     
    169338 
    170339    /* (non-Javadoc) 
     340     * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder#removeTaskInstance(de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList, int) 
     341     */ 
     342    @Override 
     343    public void removeTaskInstance(ITaskInstanceList taskInstanceList, int index) { 
     344        if (taskInstanceList instanceof TaskInstance) { 
     345            ((TaskInstance) taskInstanceList).removeChild(index); 
     346        } 
     347        else if (taskInstanceList instanceof UserSession) { 
     348            ((UserSession) taskInstanceList).removeExecutedTask(index); 
     349        } 
     350        else { 
     351            throw new IllegalArgumentException 
     352                ("illegal type of task instance list provided: " + taskInstanceList.getClass()); 
     353        } 
     354    } 
     355 
     356    /* (non-Javadoc) 
    171357     * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder#replaceChild(de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection, de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode, de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode) 
    172358     */ 
    173359    @Override 
    174     public void replaceChild(ISelection parent, ITaskTreeNode oldChild, ITaskTreeNode newChild) { 
    175         if (!(parent instanceof TaskTreeNode)) { 
    176             throw new IllegalArgumentException 
    177                 ("illegal type of task tree node provided: " + parent.getClass()); 
    178         } 
    179  
    180         List<ITaskTreeNode> children = parent.getChildren(); 
     360    public void replaceChild(ISelection parent, ITask oldChild, ITask newChild) { 
     361        if (!(parent instanceof Selection)) { 
     362            throw new IllegalArgumentException 
     363                ("illegal type of selection provided: " + parent.getClass()); 
     364        } 
     365 
     366        List<ITask> children = parent.getChildren(); 
    181367         
    182368        for (int i = 0; i < children.size(); i++) { 
     
    184370                ((children.get(i) != null) && (children.get(i).equals(oldChild)))) 
    185371            { 
    186                 ((TaskTreeNode) parent).removeChild(i); 
    187                 ((TaskTreeNode) parent).addChild(i, newChild); 
     372                ((Selection) parent).removeChild(i); 
     373                ((Selection) parent).addChild(i, newChild); 
    188374                break; 
    189375            } 
     
    197383     */ 
    198384    @Override 
    199     public void setDescription(ITaskTreeNode parent, String description) { 
    200         if (!(parent instanceof TaskTreeNode)) { 
    201             throw new IllegalArgumentException 
    202                 ("illegal type of task tree node provided: " + parent.getClass()); 
    203         } 
    204  
    205         ((TaskTreeNode) parent).setDescription(description); 
     385    public void setDescription(ITask parent, String description) { 
     386        if (!(parent instanceof Task)) { 
     387            throw new IllegalArgumentException 
     388                ("illegal type of task provided: " + parent.getClass()); 
     389        } 
     390 
     391        ((Task) parent).setDescription(description); 
    206392    } 
    207393 
     
    209395     *  
    210396     */ 
    211     private void addChildInternal(ITaskTreeNode parent, int index, ITaskTreeNode child) { 
    212         if (!(child instanceof TaskTreeNode)) { 
    213             throw new IllegalArgumentException 
    214                 ("illegal type of task tree node provided: " + child.getClass()); 
     397    private void addChildInternal(StructuringTemporalRelationship parent, int index, ITask child) { 
     398        if (!(child instanceof Task)) { 
     399            throw new IllegalArgumentException 
     400                ("illegal type of task provided: " + child.getClass()); 
    215401        } 
    216402 
    217403        if (index > -1) { 
    218             ((TaskTreeNode) parent).addChild(index, child); 
     404            parent.addChild(index, child); 
    219405        } 
    220406        else { 
    221             ((TaskTreeNode) parent).addChild(child); 
     407            parent.addChild(child); 
    222408        } 
    223409    } 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskFactory.java

    r1126 r1146  
    1515package de.ugoe.cs.autoquest.tasktrees.treeimpl; 
    1616 
     17import java.util.List; 
     18 
    1719import de.ugoe.cs.autoquest.eventcore.IEventTarget; 
    1820import de.ugoe.cs.autoquest.eventcore.IEventType; 
     
    2224import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
    2325import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 
    24 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree; 
    25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; 
     26import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     27import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 
     28import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList; 
     29import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 
     30import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 
     31import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 
    2732 
    2833/** 
     
    3237 * @author 2012, last modified by $Author: patrick$ 
    3338 */ 
    34 public class TaskTreeNodeFactory implements ITaskTreeNodeFactory { 
     39public class TaskFactory implements ITaskFactory { 
    3540 
    3641    /* 
     
    8287    } 
    8388 
    84     /* 
    85      * (non-Javadoc) 
    86      *  
    87      * @see 
    88      * de.ugoe.cs.tasktree.treeifc.TaskTreeNodeFactory#createTaskTree(de.ugoe.cs.tasktree.treeifc 
    89      * .TaskTreeNode) 
     89    /* (non-Javadoc) 
     90     * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory#createNewTaskInstance(ITask) 
    9091     */ 
    9192    @Override 
    92     public ITaskTree createTaskTree(ITaskTreeNode root) { 
    93         return new TaskTree(root); 
     93    public ITaskInstance createNewTaskInstance(ITask task) { 
     94        return new TaskInstance(task); 
     95    } 
     96 
     97    /* (non-Javadoc) 
     98     * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory#createNewTaskInstanceList() 
     99     */ 
     100    @Override 
     101    public ITaskInstanceList createNewTaskInstanceList() { 
     102        return new TaskInstance(new Sequence()); 
     103    } 
     104 
     105    /* (non-Javadoc) 
     106     * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory#createUserSession() 
     107     */ 
     108    @Override 
     109    public IUserSession createUserSession() { 
     110        return new UserSession(); 
     111    } 
     112 
     113    /* (non-Javadoc) 
     114     * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory#createTaskModel(IUserSession) 
     115     */ 
     116    @Override 
     117    public ITaskModel createTaskModel(List<IUserSession> userSessions) { 
     118        return new TaskModel(userSessions); 
    94119    } 
    95120 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskModel.java

    r1132 r1146  
    1515package de.ugoe.cs.autoquest.tasktrees.treeimpl; 
    1616 
     17import java.util.Collection; 
     18import java.util.Collections; 
    1719import java.util.HashMap; 
     20import java.util.List; 
    1821import java.util.Map; 
    1922 
    20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree; 
    21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    22 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeInfo; 
     23import de.ugoe.cs.autoquest.tasktrees.treeifc.IMarkingTemporalRelationship; 
     24import de.ugoe.cs.autoquest.tasktrees.treeifc.IStructuringTemporalRelationship; 
     25import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     26import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 
     27import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 
     28import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInfo; 
     29import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 
    2330 
    2431/** 
     
    2835 * @author 2012, last modified by $Author: patrick$ 
    2936 */ 
    30 public class TaskTree implements ITaskTree { 
     37class TaskModel implements ITaskModel { 
    3138     
    32     /** the map of nodes */ 
    33     private Map<ITaskTreeNode, ITaskTreeNodeInfo> taskMap; 
     39    /** */ 
     40    private static final long serialVersionUID = 1L; 
    3441 
    35     /** the root node of the task tree */ 
    36     private ITaskTreeNode rootNode; 
     42    /** the map of tasks */ 
     43    private List<IUserSession> userSessions; 
     44 
     45    /** the map of tasks */ 
     46    private Map<ITask, TaskInfo> taskMap = new HashMap<ITask, TaskInfo>(); 
    3747 
    3848    /** 
    39      * TODO: comment 
    40      *  
     49     * 
    4150     */ 
    42     TaskTree(ITaskTreeNode rootNode) { 
    43         this.rootNode = rootNode; 
     51    TaskModel(List<IUserSession> userSessions) { 
     52        if ((userSessions == null) || (userSessions.size() == 0)) { 
     53            throw new IllegalArgumentException("user sessions must not be null"); 
     54        } 
     55         
     56        this.userSessions = userSessions; 
     57         
     58        for (IUserSession session : this.userSessions) { 
     59            for (ITaskInstance taskInstance : session) { 
     60                addTaskToMap(taskInstance.getTask()); 
     61            } 
     62        } 
    4463    } 
    4564 
    46     /* 
    47      * (non-Javadoc) 
    48      *  
    49      * @see de.ugoe.cs.tasktree.treeifc.TaskTree#getRoot() 
     65 
     66    /* (non-Javadoc) 
     67     * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel#getUserSessions() 
    5068     */ 
    5169    @Override 
    52     public ITaskTreeNode getRoot() { 
    53         return rootNode; 
     70    public List<IUserSession> getUserSessions() { 
     71        return Collections.unmodifiableList(userSessions); 
    5472    } 
    5573 
    56     /* 
    57      * (non-Javadoc) 
    58      *  
    59      * @see de.ugoe.cs.tasktree.treeifc.TaskTree#getTaskMap() 
     74 
     75    /* (non-Javadoc) 
     76     * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel#getTasks() 
    6077     */ 
    6178    @Override 
    62     public synchronized Map<ITaskTreeNode, ITaskTreeNodeInfo> getTaskMap() { 
    63         if (taskMap == null) { 
    64             taskMap = new HashMap<ITaskTreeNode, ITaskTreeNodeInfo>(); 
    65             addNodeToMap(rootNode, null); 
    66         } 
    67         return taskMap; 
     79    public Collection<ITask> getTasks() { 
     80        return Collections.unmodifiableCollection(taskMap.keySet()); 
     81    } 
     82 
     83 
     84    /* (non-Javadoc) 
     85     * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel#getTaskInfo(de.ugoe.cs.autoquest.tasktrees.treeifc.ITask) 
     86     */ 
     87    @Override 
     88    public ITaskInfo getTaskInfo(ITask task) { 
     89        return taskMap.get(task); 
    6890    } 
    6991 
    7092    /** 
    71      * TODO: comment 
    72      *  
    73      * @param rootNode 
     93     * 
    7494     */ 
    75     private void addNodeToMap(ITaskTreeNode node, ITaskTreeNode parent) { 
    76         NodeInfo nodeInfo = (NodeInfo) taskMap.get(node); 
     95    private void addTaskToMap(ITask task) { 
     96        TaskInfo taskInfo = taskMap.get(task); 
    7797 
    78         if (nodeInfo == null) { 
    79             nodeInfo = new NodeInfo(node); 
    80             taskMap.put(node, nodeInfo); 
     98        if (taskInfo == null) { 
     99            taskInfo = new TaskInfo(task); 
     100            taskMap.put(task, taskInfo); 
    81101        } 
    82102 
    83         if (parent != null) { 
    84             // through first removing an existing parent it is assured, that a parent is recorded 
    85             // only once. This is needed, because parent may be reused in a tree as well, but we 
    86             // always iterate the whole tree 
    87             //nodeInfo.removeParent(parent); 
    88             nodeInfo.addParent(parent); 
     103        if (task instanceof IStructuringTemporalRelationship) { 
     104            for (ITask child : ((IStructuringTemporalRelationship) task).getChildren()) { 
     105                addTaskToMap(child); 
     106            } 
    89107        } 
    90  
    91         for (ITaskTreeNode child : node.getChildren()) { 
    92             addNodeToMap(child, node); 
     108        else if (task instanceof IMarkingTemporalRelationship) { 
     109            addTaskToMap(((IMarkingTemporalRelationship) task).getMarkedTask()); 
    93110        } 
    94111    } 
     
    100117     */ 
    101118    @Override 
    102     public TaskTree clone() { 
    103         TaskTree clone = null; 
    104         try { 
    105             clone = (TaskTree) super.clone(); 
    106  
    107             clone.rootNode = rootNode.clone(); 
    108  
    109             // the clone will create the task map itself, when it is first retrieved 
    110             clone.taskMap = null; 
    111  
    112         } 
    113         catch (CloneNotSupportedException e) { 
    114             // this should never happen. Therefore simply dump the exception 
    115             e.printStackTrace(); 
    116         } 
    117  
    118         return clone; 
     119    public TaskModel clone() { 
     120        return new TaskModel(userSessions); 
    119121    } 
    120122 
  • trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/tasktrees/TaskTreeChecker.java

    r1123 r1146  
    1717import static org.junit.Assert.*; 
    1818 
    19 import java.io.FileNotFoundException; 
    20 import java.io.FileOutputStream; 
    21 import java.io.PrintWriter; 
    2219import java.util.ArrayList; 
    2320import java.util.HashMap; 
     
    3330import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
    3431import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 
    35 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree; 
    36 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    37 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeInfo; 
     32import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     33import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 
     34import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList; 
     35import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 
    3836 
    3937/** 
     
    5654 
    5755    /** 
    58      * TODO: comment 
    59      *  
     56     * 
    6057     */ 
    6158    public TaskTreeChecker() { 
     
    6461 
    6562    /** 
    66      * TODO: comment 
    67      *  
     63     * 
    6864     */ 
    6965    public TaskTreeChecker(boolean doTrace) { 
     
    7470     * 
    7571     */ 
    76     public void assertTaskTree(String taskTreeSpec, ITaskTree taskTree) { 
    77         Map<ITaskTreeNode, Integer> taskMapCopy = new HashMap<ITaskTreeNode, Integer>(); 
    78  
    79         for (Map.Entry<ITaskTreeNode, ITaskTreeNodeInfo> entry : taskTree.getTaskMap().entrySet()) { 
    80             if (entry.getValue().getNoOfOccurencesInTree() > 0) { 
    81                 taskMapCopy.put(entry.getKey(), entry.getValue().getNoOfOccurencesInTree()); 
    82             } 
    83             else { 
    84                 taskMapCopy.put(entry.getKey(), 1); 
    85             } 
    86         } 
    87  
     72    public void assertTaskInstanceList(String userSessionSpec, ITaskInstanceList taskInstances) { 
    8873        if (doTrace) { 
    89             dumpTaskMap(taskMapCopy); 
    90         } 
    91  
    92         TaskSpec task = null; 
    93  
    94         Matcher taskMatcher = taskPattern.matcher(taskTreeSpec); 
     74            new TaskTreeEncoder().encode(taskInstances, System.err); 
     75        } 
     76 
     77        TaskSpec taskInstanceSpec = null; 
     78 
     79        Matcher taskMatcher = taskPattern.matcher(userSessionSpec); 
     80         
     81        Map<String, ITask> tasks = new HashMap<String, ITask>(); 
    9582 
    9683        while (taskMatcher.find()) { 
    9784 
    98             task = parseTask(taskMatcher); 
    99              
    100             if (task != null) { 
    101                 assertTaskAndChildrenInMapAndRemove(task, taskMapCopy); 
    102             } 
    103         } 
    104  
    105         assertTrue("more tasks in map, than expected", taskMapCopy.isEmpty()); 
    106     } 
    107  
    108     /** 
    109      * <p> 
    110      * TODO: comment 
    111      * </p> 
    112      * 
    113      * @param oracle 
    114      * @param result 
    115      */ 
    116     public void assertTaskNodesEqual(ITaskTreeNode expected, ITaskTreeNode checked) { 
     85            taskInstanceSpec = parseTaskInstance(taskMatcher); 
     86             
     87            if (taskInstanceSpec != null) { 
     88                assertTaskInstanceList(taskInstanceSpec, taskInstances, tasks); 
     89            } 
     90        } 
     91    } 
     92 
     93    /** 
     94     * 
     95     */ 
     96    public void assertTaskInstanceListsEqual(ITaskInstanceList expected, ITaskInstanceList checked) 
     97    { 
    11798        if (expected == null) { 
    11899            assertNull("null", checked); 
     
    123104            assertEquals(expected.toString() + ": types do not match", 
    124105                         expected.getClass(), checked.getClass()); 
    125             assertEquals(expected.toString() + ": names do not match", 
    126                          expected.getName(), checked.getName()); 
    127              
    128             List<ITaskTreeNode> expectedChildren = expected.getChildren(); 
    129             List<ITaskTreeNode> checkedChildren = checked.getChildren(); 
     106             
     107            if ((expected != null) && (expected.size() > 0)) { 
     108                assertNotNull(expected.toString() + ": children not there", checked); 
     109                assertEquals(expected.toString() + ": different number of children", 
     110                             expected.size(), checked.size()); 
     111                 
     112                Map<ITask, ITask> equalTasksMap = new HashMap<ITask, ITask>(); 
     113                for (int i = 0; i < expected.size(); i++) { 
     114                    assertTaskInstancesEqual(expected.get(i), checked.get(i), equalTasksMap); 
     115                } 
     116            } 
     117            else { 
     118                assertTrue(expected.toString() + ": unexpected children", 
     119                           (checked == null) || (checked.size() == 0)); 
     120            } 
     121        } 
     122    } 
     123 
     124    /** 
     125     * 
     126     */ 
     127    public void assertTaskInstancesEqual(ITaskInstance expected, ITaskInstance checked) { 
     128        Map<ITask, ITask> equalTasksMap = new HashMap<ITask, ITask>(); 
     129        assertTaskInstancesEqual(expected, checked, equalTasksMap); 
     130    } 
     131 
     132    /** 
     133     * 
     134     */ 
     135    private void assertTaskInstancesEqual(ITaskInstance     expected, 
     136                                          ITaskInstance     checked, 
     137                                          Map<ITask, ITask> equalTasksMap) 
     138    { 
     139        if (expected == null) { 
     140            assertNull("null", checked); 
     141        } 
     142        else { 
     143            assertNotNull(expected.toString(), checked); 
     144             
     145            assertEquals(expected.toString() + ": types do not match", 
     146                         expected.getClass(), checked.getClass()); 
     147             
     148            if (equalTasksMap.containsKey(expected.getTask())) { 
     149                assertEquals(expected.toString() + ": tasks do not match", 
     150                             checked.getTask(), equalTasksMap.get(expected.getTask())); 
     151            } 
     152            else { 
     153                equalTasksMap.put(expected.getTask(), checked.getTask()); 
     154            } 
     155             
     156            List<ITaskInstance> expectedChildren = expected.getChildren(); 
     157            List<ITaskInstance> checkedChildren = checked.getChildren(); 
    130158             
    131159            if ((expectedChildren != null) && (expectedChildren.size() > 0)) { 
     
    136164                if (expected instanceof ISequence) { 
    137165                    for (int i = 0; i < expectedChildren.size(); i++) { 
    138                         assertTaskNodesEqual(expectedChildren.get(i), checkedChildren.get(i)); 
     166                        assertTaskInstancesEqual(expectedChildren.get(i), checkedChildren.get(i)); 
    139167                    } 
    140168                } 
     
    144172                        for (int j = 0; j < checkedChildren.size(); j++) { 
    145173                            try { 
    146                                 assertTaskNodesEqual 
     174                                assertTaskInstancesEqual 
    147175                                    (expectedChildren.get(i), checkedChildren.get(j)); 
    148176                                found = true; 
     
    166194 
    167195    /** 
    168      * TODO: comment 
    169196     *  
    170      * @param taskTree 
    171      */ 
    172     public void dumpAsCheckString(ITaskTree taskTree) { 
    173         dumpNodeAsCheckString(taskTree.getRoot(), new int[4], ""); 
    174     } 
    175  
    176     /** 
    177      * TODO: comment 
    178      *  
    179      * @param root 
    180      * @param string 
    181      */ 
    182     private void dumpNodeAsCheckString(ITaskTreeNode node, int[] typeCounters, String indent) { 
    183         System.out.print("       \""); 
    184         System.out.print(indent); 
    185  
    186         if (node instanceof ISequence) { 
    187             System.out.print("Sequence sequence"); 
    188             System.out.print(typeCounters[0]++); 
    189             System.out.println(" {\" +"); 
    190         } 
    191         else if (node instanceof IIteration) { 
    192             System.out.print("Iteration iteration"); 
    193             System.out.print(typeCounters[1]++); 
    194             System.out.println(" {\" +"); 
    195         } 
    196         else if (node instanceof ISelection) { 
    197             System.out.print("Selection selection"); 
    198             System.out.print(typeCounters[2]++); 
    199             System.out.println(" {\" +"); 
    200         } 
    201         else if (node instanceof IEventTask) { 
    202             if (((IEventTask) node).getEventType() instanceof TextInput) { 
    203                 System.out.print("TextInputEvent textInput"); 
    204                 System.out.print(typeCounters[3]++); 
    205                 System.out.print(" \""); 
    206                 System.out.print(((TextInput) ((IEventTask) node).getEventType()).getEnteredText()); 
    207                 System.out.print("\""); 
    208             } 
    209             else { 
    210                 System.out.print("Event "); 
    211                 System.out.print(((IEventTask) node).getEventType().getName()); 
    212             } 
    213             System.out.print(" {}\" +"); 
    214         } 
    215         else { 
    216             fail("unknown type of node in task tree " + node); 
    217         } 
    218  
    219         for (ITaskTreeNode child : node.getChildren()) { 
    220             dumpNodeAsCheckString(child, typeCounters, indent + "  "); 
    221         } 
    222  
    223         if (!(node instanceof IEventTask)) { 
    224             System.out.print("       \""); 
    225             System.out.print(indent); 
    226             System.out.print("}\" +"); 
    227         } 
    228  
    229         System.out.println(); 
    230     } 
    231  
    232     /** 
    233      * TODO: comment 
    234      *  
    235      * @param taskTree 
    236      */ 
    237     public void dumpFullTaskTree(ITaskTree taskTree) throws FileNotFoundException { 
    238         PrintWriter out = null; 
    239         try { 
    240             out = new PrintWriter(new FileOutputStream("taskTree.txt")); 
    241             dumpFullNode(taskTree.getRoot(), out, "", 0); 
    242         } 
    243         finally { 
    244             if (out != null) { 
    245                 out.close(); 
    246             } 
    247         } 
    248  
    249     } 
    250  
    251     /** 
    252      * 
    253      */ 
    254     private void dumpFullNode(ITaskTreeNode node, PrintWriter out, String indent, int index) { 
    255         if (node instanceof ISequence) { 
    256             if (index > 0) { 
    257                 out.println(); 
    258             } 
    259             out.print(indent); 
    260             out.print(node.toString()); 
    261             out.println(" {"); 
    262         } 
    263         else if (node instanceof IIteration) { 
    264             if (index > 0) { 
    265                 out.println(); 
    266             } 
    267             out.print(indent); 
    268             out.print(node.toString()); 
    269             out.println(" {"); 
    270         } 
    271         else if (node instanceof ISelection) { 
    272             if (index > 0) { 
    273                 out.println(); 
    274             } 
    275             out.print(indent); 
    276             out.print(node.toString()); 
    277             out.println(" {"); 
    278         } 
    279         else if (node instanceof IEventTask) { 
    280             out.print(indent); 
    281             out.print(((IEventTask) node).getEventType()); 
    282             out.print(" "); 
    283             out.print(((IEventTask) node).getEventTarget().getStringIdentifier()); 
    284 //            if (((IEventTask) node).getEventTarget() instanceof IGUIElement) { 
    285 //              out.print(" "); 
    286 //              out.print(((IGUIElement) ((IEventTask) node).getEventTarget()).getSpecification()); 
    287 //            } 
    288         } 
    289         else { 
    290             fail("unknown type of node in task tree " + node); 
    291         } 
    292  
    293         int i = 0; 
    294         for (ITaskTreeNode child : node.getChildren()) { 
    295             dumpFullNode(child, out, indent + "  ", i++); 
    296         } 
    297  
    298         if (!(node instanceof IEventTask)) { 
    299             out.print(indent); 
    300             out.print("}"); 
    301         } 
    302  
    303         out.println(); 
    304     } 
    305  
    306     /** 
    307      *  
    308      */ 
    309     private TaskSpec parseTask(Matcher taskMatcher) { 
     197     */ 
     198    private TaskSpec parseTaskInstance(Matcher taskMatcher) { 
    310199        if ("}".equals(taskMatcher.group(1))) { 
    311200            throw new IllegalArgumentException("invalid task specification"); 
     
    338227        List<TaskSpec> children = new ArrayList<TaskSpec>(); 
    339228        while (taskMatcher.find() && !"}".equals(taskMatcher.group(0))) { 
    340             children.add(parseTask(taskMatcher)); 
     229            children.add(parseTaskInstance(taskMatcher)); 
    341230        } 
    342231 
     
    352241     * @param taskMapCopy 
    353242     */ 
    354     private void assertTaskAndChildrenInMapAndRemove(TaskSpec                    task, 
    355                                                      Map<ITaskTreeNode, Integer> taskMap) 
     243    private void assertTaskInstanceList(TaskSpec           taskSpec, 
     244                                        ITaskInstanceList  taskInstances, 
     245                                        Map<String, ITask> tasks) 
    356246    { 
    357         for (Map.Entry<ITaskTreeNode, Integer> entry : taskMap.entrySet()) { 
    358             if (taskSpecEqualsTask(task, entry.getKey())) { 
    359                 if (task.children != null) { 
    360                     for (TaskSpec child : task.children) { 
    361                         assertTaskAndChildrenInMapAndRemove(child, taskMap); 
    362                     } 
    363                 } 
    364  
    365                 int count = taskMap.get(entry.getKey()); 
    366                 if (count == 1) { 
    367                     taskMap.remove(entry.getKey()); 
    368                 } 
    369                 else { 
    370                     taskMap.put(entry.getKey(), count - 1); 
    371                 } 
    372                 return; 
    373             } 
    374         } 
    375  
    376         fail("expected task " + task.type + " " + task.name + " not included in task map"); 
    377     } 
    378  
    379     /** 
    380      * 
    381      */ 
    382     private boolean taskSpecEqualsTask(TaskSpec taskSpec, ITaskTreeNode task) { 
     247        if (doTrace) { 
     248            System.err.println("\ncomparing " + taskSpec.type + " with " + taskInstances + "\n"); 
     249        } 
     250 
     251        if ((taskInstances instanceof IUserSession) && (!"UserSession".equals(taskSpec.type))) { 
     252            fail("can not compare a task instance with a user session"); 
     253        } 
     254        else if ((!(taskInstances instanceof IUserSession)) && 
     255                 (!"TaskInstances".equals(taskSpec.type))) 
     256        { 
     257            fail("can not compare a task instance with a task instance list"); 
     258        } 
     259         
     260        if (taskSpec.children.length != taskInstances.size()) { 
     261            fail("number of task instances in task instance list does not match"); 
     262        } 
     263         
     264        for (int i = 0; i < taskInstances.size(); i++) { 
     265            TaskSpec childSpec = taskSpec.children[i]; 
     266            assertTrue(taskSpecEqualsTaskInstance(childSpec, taskInstances.get(i), tasks)); 
     267        } 
     268    } 
     269 
     270    /** 
     271     * 
     272     */ 
     273    private boolean taskSpecEqualsTaskInstance(TaskSpec           taskSpec, 
     274                                               ITaskInstance      taskInstance, 
     275                                               Map<String, ITask> tasks) 
     276    { 
    383277        if (doTrace) { 
    384278            System.err.println("comparing " + taskSpec.name + " with"); 
    385             dumpTask(task, 0, ""); 
    386         } 
    387  
     279            new TaskTreeEncoder().encode(taskInstance, System.err); 
     280        } 
     281 
     282        ITask task = taskInstance.getTask(); 
     283         
    388284        if (("Event".equals(taskSpec.type) && (!(task instanceof IEventTask))) || 
    389285            ("TextInputEvent".equals(taskSpec.type) && 
     
    396292            if (doTrace) { 
    397293                System.err.println("task types do not match: " + taskSpec.type + " != " + 
    398                     task.getClass().getSimpleName() + "\n"); 
     294                                   task.getClass().getSimpleName() + "\n"); 
    399295            } 
    400296            return false; 
     
    440336            } 
    441337        } 
    442  
    443         if (((taskSpec.children == null) && (task.getChildren().size() > 0)) || 
    444             ((taskSpec.children != null) && (taskSpec.children.length != task.getChildren().size()))) 
     338         
     339        // check the task name against the map 
     340        if (tasks.containsKey(taskSpec.name)) { 
     341            if (!tasks.get(taskSpec.name).equals(task)) { 
     342                if (doTrace) { 
     343                    System.err.println("the task instance is not of the expected task: " + 
     344                                       taskSpec.name + " != " + task + "\n"); 
     345                } 
     346                return false; 
     347            } 
     348        } 
     349        else if (tasks.containsValue(task)) { 
     350            if (doTrace) { 
     351                System.err.println("the task of the task instance " + taskSpec.name + 
     352                                   " should be different to another one but it isn't\n"); 
     353            } 
     354            return false; 
     355        } 
     356        else { 
     357            tasks.put(taskSpec.name, task); 
     358        } 
     359 
     360        if (((taskSpec.children == null) && (taskInstance.getChildren().size() > 0)) || 
     361            ((taskSpec.children != null) && 
     362             (taskSpec.children.length != taskInstance.getChildren().size()))) 
    445363        { 
    446364            if (doTrace) { 
     
    448366                    ("numbers of children do not match: " + 
    449367                     (taskSpec.children == null ? "0" : taskSpec.children.length) + " != " + 
    450                      (task.getChildren() == null ? "0" : task.getChildren().size()) + "\n"); 
     368                     (taskInstance.getChildren() == null ? "0" : 
     369                          taskInstance.getChildren().size()) + "\n"); 
    451370            } 
    452371            return false; 
    453372        } 
    454373 
    455         Iterator<ITaskTreeNode> children = task.getChildren().iterator(); 
     374        Iterator<ITaskInstance> children = taskInstance.getChildren().iterator(); 
    456375        if (taskSpec.children != null) { 
    457376            for (TaskSpec child : taskSpec.children) { 
    458                 if (!taskSpecEqualsTask(child, children.next())) { 
     377                if (!taskSpecEqualsTaskInstance(child, children.next(), tasks)) { 
    459378                    if (doTrace) { 
    460379                        System.err.println("one of the children does not match\n"); 
     
    478397        } 
    479398    } 
    480  
    481     /** 
    482    * 
    483    */ 
    484     private void dumpTaskMap(Map<ITaskTreeNode, Integer> taskMap) { 
    485         System.err.println(); 
    486         for (Map.Entry<ITaskTreeNode, Integer> entry : taskMap.entrySet()) { 
    487             dumpTask(entry.getKey(), entry.getValue(), ""); 
    488             System.err.println(); 
    489         } 
    490     } 
    491  
    492     /** 
    493      * 
    494      */ 
    495     private void dumpTask(ITaskTreeNode task, int count, String indent) { 
    496         System.err.print(indent); 
    497         System.err.print(task); 
    498         System.err.print(" "); 
    499         System.err.print(task.getDescription()); 
    500         System.err.print(" "); 
    501  
    502         if (count > 0) { 
    503             System.err.print("("); 
    504             System.err.print(count); 
    505             System.err.print(" occurrences)"); 
    506         } 
    507  
    508         System.err.println(); 
    509  
    510         if ((task.getChildren() != null) && (task.getChildren().size() > 0)) { 
    511             for (ITaskTreeNode child : task.getChildren()) { 
    512                 dumpTask(child, 0, indent + "  "); 
    513             } 
    514         } 
    515     } 
    516399     
    517400    /** 
    518      * TODO comment 
    519      *  
    520      * @version $Revision: $ $Date: $ 
    521      * @author 2011, last modified by $Author: $ 
     401     * 
    522402     */ 
    523403    private class TaskSpec { 
  • trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/tasktrees/TaskTreeDecoder.java

    r1123 r1146  
    2626import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
    2727import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 
    28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder; 
    29 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    30 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; 
     28import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     29import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; 
     30import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 
     31import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 
     32import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList; 
     33import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 
    3134import de.ugoe.cs.autoquest.test.DummyGUIElement; 
    3235 
     
    3740 * @author 2012, last modified by $Author: patrick$ 
    3841 */ 
    39 public class TaskTreeInstantiator { 
    40      
    41     /** */ 
    42     private static Pattern taskPattern = Pattern.compile("([^{}]+)\\{|\\}"); 
    43      
    44     /** */ 
    45     private static Pattern taskDetailsPattern = 
     42public class TaskTreeDecoder { 
     43     
     44    /** */ 
     45    private static Pattern taskInstancePattern = Pattern.compile("([^{}]+)\\{|\\}"); 
     46     
     47    /** */ 
     48    private static Pattern taskInstanceDetailsPattern = 
    4649        Pattern.compile("\\s*(\\w*)\\s*([\\w\\(\\)\"]*)\\s*((\\w*)|(\".*\"))?"); 
    4750     
    4851    /** */ 
    49     private ITaskTreeNodeFactory taskTreeNodeFactory; 
    50      
    51     /** */ 
    52     private ITaskTreeBuilder taskTreeBuilder; 
     52    private ITaskFactory taskFactory; 
     53     
     54    /** */ 
     55    private ITaskBuilder taskBuilder; 
    5356     
    5457    /** */ 
    5558    Map<String, IEventTarget> targets = new HashMap<String, IEventTarget>(); 
    5659     
     60    /** */ 
     61    Map<String, ITask> tasks = new HashMap<String, ITask>(); 
     62     
    5763    /** 
    5864     * 
    5965     */ 
    60     public TaskTreeInstantiator(ITaskTreeNodeFactory taskTreeNodeFactory, 
    61                                 ITaskTreeBuilder taskTreeBuilder) 
    62     { 
     66    public TaskTreeDecoder(ITaskFactory taskFactory, ITaskBuilder taskBuilder) { 
    6367        super(); 
    64         this.taskTreeNodeFactory = taskTreeNodeFactory; 
    65         this.taskTreeBuilder = taskTreeBuilder; 
     68        this.taskFactory = taskFactory; 
     69        this.taskBuilder = taskBuilder; 
    6670    } 
    6771 
     
    6973     * 
    7074     */ 
    71     public ITaskTreeNode instantiateTaskTree(String taskTreeSpec) { 
    72         ITaskTreeNode task = null; 
    73  
    74         Matcher taskMatcher = taskPattern.matcher(taskTreeSpec); 
     75    public ITaskInstanceList decode(String taskTreeSpec) { 
     76        ITaskInstanceList taskInstanceList = null; 
     77 
     78        Matcher taskMatcher = taskInstancePattern.matcher(taskTreeSpec); 
    7579 
    7680        if (taskMatcher.find()) { 
    77             task = parseTask(taskMatcher); 
     81            taskInstanceList = parseTaskInstanceList(taskMatcher); 
    7882        } 
    7983         
     
    8286        } 
    8387         
    84         return task; 
     88        return taskInstanceList; 
    8589    } 
    8690 
     
    8892     *  
    8993     */ 
    90     private ITaskTreeNode parseTask(Matcher taskMatcher) { 
     94    private ITaskInstanceList parseTaskInstanceList(Matcher taskMatcher) { 
    9195        if ("}".equals(taskMatcher.group(1))) { 
    92             throw new IllegalArgumentException("invalid task specification"); 
     96            throw new IllegalArgumentException("invalid task instance list specification"); 
    9397        } 
    9498         
    9599        String taskDetails = taskMatcher.group(1); 
    96100         
    97         Matcher matcher = taskDetailsPattern.matcher(taskDetails); 
     101        Matcher matcher = taskInstanceDetailsPattern.matcher(taskDetails); 
    98102         
    99103        if (!matcher.find()) { 
     
    101105        } 
    102106 
    103         ITaskTreeNode task; 
    104          
    105107        String type = matcher.group(1); 
    106108         
    107         String targetId = matcher.group(2); 
    108         if ((matcher.group(4) != null) && (!"".equals(matcher.group(4).trim()))) { 
    109             targetId += matcher.group(4).trim(); 
    110         } 
    111          
    112         IEventTarget target = targets.get(targetId); 
    113          
    114         if (target == null) { 
    115             target = new DummyGUIElement(targetId); 
    116             targets.put(targetId, target); 
    117         } 
    118          
    119         if ("Sequence".equals(type)) { 
    120             task = taskTreeNodeFactory.createNewSequence(); 
    121         } 
    122         else if ("Selection".equals(type)) { 
    123             task = taskTreeNodeFactory.createNewSelection(); 
    124         } 
    125         else if ("Iteration".equals(type)) { 
    126             task = taskTreeNodeFactory.createNewIteration(); 
    127         } 
    128         else if ("Optional".equals(type)) { 
    129             task = taskTreeNodeFactory.createNewOptional(); 
     109        ITaskInstanceList list; 
     110         
     111        if ("UserSession".equals(type)) { 
     112            list = taskFactory.createUserSession(); 
     113        } 
     114        else if ("TaskInstances".equals(type)) { 
     115            list = taskFactory.createNewTaskInstance(taskFactory.createNewSequence()); 
    130116        } 
    131117        else { 
    132             task = taskTreeNodeFactory.createNewEventTask(new StringEventType(type), target); 
     118            throw new IllegalArgumentException("unknown type of task instance list: " + type); 
     119        } 
     120         
     121        while (taskMatcher.find() && !"}".equals(taskMatcher.group(0))) { 
     122            ITaskInstance childInstance = parseTaskInstance(taskMatcher); 
     123             
     124            if (!(list instanceof IUserSession)) { 
     125                taskBuilder.addChild 
     126                    ((ISequence) ((ITaskInstance) list).getTask(), childInstance.getTask()); 
     127            } 
     128 
     129            taskBuilder.addTaskInstance(list, childInstance); 
     130        } 
     131 
     132        return list; 
     133    } 
     134 
     135    /** 
     136     *  
     137     */ 
     138    private ITaskInstance parseTaskInstance(Matcher taskMatcher) { 
     139        if ("}".equals(taskMatcher.group(1))) { 
     140            throw new IllegalArgumentException("invalid task instance specification"); 
     141        } 
     142         
     143        String taskDetails = taskMatcher.group(1); 
     144         
     145        Matcher matcher = taskInstanceDetailsPattern.matcher(taskDetails); 
     146         
     147        if (!matcher.find()) { 
     148            throw new IllegalArgumentException("could not parse task details"); 
     149        } 
     150 
     151        String type = matcher.group(1); 
     152        String id = matcher.group(2); 
     153         
     154        ITask task = tasks.get(id); 
     155         
     156        if (task == null) { 
     157            if ("Sequence".equals(type)) { 
     158                task = taskFactory.createNewSequence(); 
     159            } 
     160            else if ("Selection".equals(type)) { 
     161                task = taskFactory.createNewSelection(); 
     162            } 
     163            else if ("Iteration".equals(type)) { 
     164                task = taskFactory.createNewIteration(); 
     165            } 
     166            else if ("Optional".equals(type)) { 
     167                task = taskFactory.createNewOptional(); 
     168            } 
     169            else { 
     170                IEventTarget target = targets.get(id); 
     171             
     172                if (target == null) { 
     173                    target = new DummyGUIElement(id); 
     174                    targets.put(id, target); 
     175                } 
     176             
     177                task = taskFactory.createNewEventTask(new StringEventType(type), target); 
     178            } 
     179             
     180            tasks.put(id, task); 
    133181        } 
    134182         
    135183        if ((matcher.group(5) != null) && (!"".equals(matcher.group(5).trim()))) { 
    136             taskTreeBuilder.setDescription(task, matcher.group(5).trim()); 
    137         } 
    138  
     184            taskBuilder.setDescription(task, matcher.group(5).trim()); 
     185        } 
     186 
     187        ITaskInstance instance = taskFactory.createNewTaskInstance(task); 
     188         
    139189        while (taskMatcher.find() && !"}".equals(taskMatcher.group(0))) { 
     190            ITaskInstance childInstance = parseTaskInstance(taskMatcher); 
     191             
    140192            if (task instanceof ISequence) { 
    141                 taskTreeBuilder.addChild((ISequence) task, parseTask(taskMatcher)); 
     193                taskBuilder.addChild((ISequence) task, childInstance.getTask()); 
    142194            } 
    143195            else if (task instanceof ISelection) { 
    144                 taskTreeBuilder.addChild((ISelection) task, parseTask(taskMatcher)); 
     196                taskBuilder.addChild((ISelection) task, childInstance.getTask()); 
    145197            } 
    146198            else if (task instanceof IIteration) { 
    147                 if ((task.getChildren() == null) || (task.getChildren().size() == 0)) { 
    148                     taskTreeBuilder.setChild((IIteration) task, parseTask(taskMatcher)); 
    149                 } 
    150                 else { 
     199                if (((IIteration) task).getMarkedTask() == null) { 
     200                    taskBuilder.setMarkedTask((IIteration) task, childInstance.getTask()); 
     201                } 
     202                else if (!((IIteration) task).getMarkedTask().equals(childInstance.getTask())) { 
    151203                    throw new IllegalArgumentException 
    152204                        ("can not add more than one child to an iteration"); 
     
    154206            } 
    155207            else if (task instanceof IOptional) { 
    156                 if ((task.getChildren() == null) || (task.getChildren().size() == 0)) { 
    157                     taskTreeBuilder.setChild((IOptional) task, parseTask(taskMatcher)); 
    158                 } 
    159                 else { 
     208                if (((IOptional) task).getMarkedTask() == null) { 
     209                    taskBuilder.setMarkedTask((IOptional) task, childInstance.getTask()); 
     210                } 
     211                else if (!((IOptional) task).getMarkedTask().equals(childInstance.getTask())) { 
    160212                    throw new IllegalArgumentException 
    161213                        ("can not add more than one child to an optional"); 
     
    164216            else { 
    165217                throw new IllegalArgumentException("can not add children to something that is no " + 
    166                                                    "sequence, selection, or iteration"); 
    167             } 
    168         } 
    169  
    170         return task; 
     218                                                   "sequence, selection, iteration, or optional"); 
     219            } 
     220             
     221            taskBuilder.addChild(instance, childInstance); 
     222        } 
     223 
     224        return instance; 
    171225    } 
    172226 
  • trunk/autoquest-ui-core/src/main/java/de/ugoe/cs/autoquest/commands/usability/CMDevaluateUsability.java

    r927 r1146  
    1818 
    1919import de.ugoe.cs.autoquest.CommandHelpers; 
    20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree; 
     20import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 
    2121import de.ugoe.cs.autoquest.usability.UsabilityEvaluationManager; 
    2222import de.ugoe.cs.autoquest.usability.UsabilityEvaluationResult; 
     
    7373            return; 
    7474        } 
    75         if (!(dataObject instanceof ITaskTree)) { 
     75        if (!(dataObject instanceof ITaskModel)) { 
    7676            CommandHelpers.objectNotType(tasktreeName, "ITaskTree"); 
    7777            return; 
    7878        } 
    7979 
    80         ITaskTree taskTree = (ITaskTree) dataObject; 
     80        ITaskModel taskTree = (ITaskModel) dataObject; 
    8181         
    8282        UsabilityEvaluationResult result = 
  • trunk/autoquest-ui-core/src/main/java/de/ugoe/cs/autoquest/commands/usability/CMDgenerateTaskTree.java

    r927 r1146  
    2222import de.ugoe.cs.autoquest.eventcore.Event; 
    2323import de.ugoe.cs.autoquest.tasktrees.manager.TaskTreeManager; 
    24 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree; 
     24import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 
    2525import de.ugoe.cs.util.console.Command; 
    2626import de.ugoe.cs.util.console.GlobalDataContainer; 
     
    8484        sequences = (Collection<List<Event>>) dataObject; 
    8585         
    86         ITaskTree taskTree = new TaskTreeManager().createTaskTree(sequences); 
     86        ITaskModel taskModel = new TaskTreeManager().createTaskModel(sequences); 
    8787         
    88         if (GlobalDataContainer.getInstance().addData(tasktreeName, taskTree)) { 
     88        if (GlobalDataContainer.getInstance().addData(tasktreeName, taskModel)) { 
    8989            CommandHelpers.dataOverwritten(sequencesName); 
    9090        } 
  • trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/ModelsTabComposite.java

    r1094 r1146  
    2323import org.eclipse.swt.layout.GridData; 
    2424 
    25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree; 
     25import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 
    2626import de.ugoe.cs.autoquest.usageprofiles.FirstOrderMarkovModel; 
    2727import de.ugoe.cs.autoquest.usageprofiles.IDotCompatible; 
     
    130130                    CommandExecuter.getInstance().exec(command); 
    131131                } 
    132                 else if (obj instanceof ITaskTree) { 
     132                else if (obj instanceof ITaskModel) { 
    133133                    ShowTaskTreeDialog showTaskTreeDialog = new ShowTaskTreeDialog 
    134                         (getShell(), SWT.NONE, (ITaskTree) obj, selectedStrings[0]); 
     134                        (getShell(), SWT.NONE, (ITaskModel) obj, selectedStrings[0]); 
    135135                    showTaskTreeDialog.open(); 
    136136                } 
     
    291291        for (String key : GlobalDataContainer.getInstance().getAllKeys()) { 
    292292            if ((GlobalDataContainer.getInstance().getData(key) instanceof IStochasticProcess) || 
    293                 (GlobalDataContainer.getInstance().getData(key) instanceof ITaskTree)) 
     293                (GlobalDataContainer.getInstance().getData(key) instanceof ITaskModel)) 
    294294            { 
    295295                modelList.add(key); 
  • trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/ShowTaskTreeDialog.java

    r1122 r1146  
    1515package de.ugoe.cs.autoquest.ui.swt; 
    1616 
     17import java.util.List; 
     18 
    1719import org.eclipse.swt.SWT; 
     20import org.eclipse.swt.custom.SashForm; 
    1821import org.eclipse.swt.events.SelectionAdapter; 
    1922import org.eclipse.swt.events.SelectionEvent; 
     
    2730import org.eclipse.swt.widgets.TreeItem; 
    2831 
    29 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree; 
    30 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
     32import de.ugoe.cs.autoquest.tasktrees.treeifc.IMarkingTemporalRelationship; 
     33import de.ugoe.cs.autoquest.tasktrees.treeifc.IStructuringTemporalRelationship; 
     34import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     35import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 
     36import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList; 
     37import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 
     38import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 
    3139 
    3240import org.eclipse.swt.widgets.Label; 
     
    4553     
    4654    /** */ 
    47     private Tree tree; 
    48  
    49     /** */ 
    50     protected ITaskTree taskTree; 
    51  
    52     /** 
    53      *  
    54      */ 
    55     public ShowTaskTreeDialog(Shell parent, int style, ITaskTree taskTree, String taskTreeName) { 
     55    private Tree instanceTree; 
     56     
     57    /** */ 
     58    private Tree modelTree; 
     59 
     60    /** */ 
     61    protected ITaskModel taskModel; 
     62 
     63    /** 
     64     *  
     65     */ 
     66    public ShowTaskTreeDialog(Shell parent, int style, ITaskModel taskModel, String taskTreeName) { 
    5667        super(parent, style); 
    57         setText("Task Tree " + taskTreeName); 
    58         this.taskTree = taskTree; 
     68        setText("Task Model " + taskTreeName); 
     69        this.taskModel = taskModel; 
    5970    } 
    6071 
     
    8394 
    8495        shell.setLayout(new GridLayout(4, false)); 
    85  
    86         tree = new Tree(shell, SWT.BORDER | SWT.MULTI); 
    87         tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1)); 
    88  
    89         buildTree(); 
     96         
     97        SashForm sashForm = new SashForm(shell, SWT.VERTICAL); 
     98        sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1)); 
     99         
     100        instanceTree = new Tree(sashForm, SWT.BORDER | SWT.MULTI); 
     101        instanceTree.addSelectionListener(new SelectionAdapter() { 
     102            @Override 
     103            public void widgetSelected(SelectionEvent e) { 
     104                modelTree.removeAll(); 
     105                TreeItem[] selectedItems = instanceTree.getSelection(); 
     106                if ((selectedItems.length == 1) && 
     107                    (selectedItems[0].getData() instanceof ITaskInstance)) 
     108                { 
     109                    buildModelTree((ITaskInstance) selectedItems[0].getData()); 
     110                } 
     111            } 
     112        }); 
     113 
     114        buildInstanceTree(); 
     115 
     116        modelTree = new Tree(sashForm, SWT.BORDER | SWT.MULTI); 
    90117 
    91118        Button btnExpandAll = new Button(shell, SWT.NONE); 
     
    93120            @Override 
    94121            public void widgetSelected(SelectionEvent e) { 
    95                 expandAll(tree, true); 
     122                expandAll(instanceTree, true); 
    96123            } 
    97124        }); 
     
    102129            @Override 
    103130            public void widgetSelected(SelectionEvent e) { 
    104                 expandAll(tree, false); 
     131                expandAll(instanceTree, false); 
    105132            } 
    106133        }); 
     
    117144     *  
    118145     */ 
    119     private void buildTree() { 
    120         ITaskTreeNode root = taskTree.getRoot(); 
    121          
    122         TreeItem child = new TreeItem(tree, SWT.NULL); 
    123         child.setText(root.getName() + " (" + root.getDescription() + ")"); 
    124         child.setData(root); 
    125         buildGuiTree(child, root); 
    126     } 
    127  
    128     /** 
    129      *  
    130      */ 
    131     private void buildGuiTree(TreeItem currentParent, ITaskTreeNode node) { 
    132         if (node.getChildren() != null) { 
    133              
    134             for (ITaskTreeNode childTask : node.getChildren()) { 
    135                 TreeItem child = new TreeItem(currentParent, SWT.NULL); 
    136                 child.setText(childTask.getName() + " (" + childTask.getDescription() + ")"); 
    137                 child.setData(childTask); 
    138                 buildGuiTree(child, childTask); 
    139             } 
     146    private void buildInstanceTree() { 
     147        List<IUserSession> sessions = taskModel.getUserSessions(); 
     148         
     149        TreeItem root = new TreeItem(instanceTree, SWT.NULL); 
     150        root.setText(sessions.size() + " sessions"); 
     151        root.setData(sessions); 
     152         
     153        for (IUserSession session : sessions) { 
     154            buildInstanceTree(root, session); 
     155        } 
     156    } 
     157 
     158    /** 
     159     *  
     160     */ 
     161    private void buildInstanceTree(TreeItem currentParent, ITaskInstanceList taskInstanceList) { 
     162        TreeItem child = new TreeItem(currentParent, SWT.NULL); 
     163        child.setText(taskInstanceList.toString()); 
     164        child.setData(taskInstanceList); 
     165         
     166        for (ITaskInstanceList childTask : taskInstanceList) { 
     167            buildInstanceTree(child, childTask); 
     168        } 
     169    } 
     170 
     171    /** 
     172     *  
     173     */ 
     174    private void buildModelTree(ITaskInstance taskInstance) { 
     175        modelTree.removeAll(); 
     176        TreeItem root = new TreeItem(modelTree, SWT.NULL); 
     177        root.setText("model of instance " + taskInstance); 
     178        root.setData(taskInstance); 
     179 
     180        buildModelTree(taskInstance.getTask(), root); 
     181        expandAll(root, true); 
     182    } 
     183 
     184    /** 
     185     *  
     186     */ 
     187    private void buildModelTree(ITask task, TreeItem parent) { 
     188        TreeItem node = new TreeItem(parent, SWT.NULL); 
     189        node.setText(task.toString()); 
     190        node.setData(task); 
     191         
     192        if (task instanceof IStructuringTemporalRelationship) { 
     193            for (ITask subTask : ((IStructuringTemporalRelationship) task).getChildren()) { 
     194                buildModelTree(subTask, node); 
     195            } 
     196        } 
     197        else if (task instanceof IMarkingTemporalRelationship) { 
     198            buildModelTree(((IMarkingTemporalRelationship) task).getMarkedTask(), node); 
    140199        } 
    141200    } 
Note: See TracChangeset for help on using the changeset viewer.