Logic

Below you will see a sample Logic. Java use the same 'extends' to extend the abstract class located in the Odyssey library (mssl.ucl.odyssey.logic.Juncture). As noted in the main Odyssey page and in the XML, you can define a Logic tag to be BEGIN, FIRST, MID, LAST, or END.

BEGIN - is the first thing called after the facade is instantiated and before any data is loaded, and is called before any Looping (if any).

FIRST - is the FIRST thing no data has been loaded and no facade has been called, but is always called in a Loop hence if you load multiple DM but your Facade uses Single DM this Logic is always called.

MID - All data has been loaded for the Facade nothing else, but is always called in a Loop hence if you load multiple DM but your Facade uses Single DM this Logic is always called.

POSTPRECONTROL -- Immediately called after preControl method.

POSTCALL -- Immediately called after call method.

POSTPOSTCONTROL -- Immediately after postcontrol method.

LAST - All Facade methods called, DM data written and Storage data will be written, but is always called in a Loop hence if you load multiple DM but your Facade uses Single DM this Logic is always called.

END - is the thing called and is after any looping (if any). This is the last thing called before going on to the next test.

When you create a Logic class you must define this doTrek method and with it will come your ModuleFacade, your own personal Storage hashtable you can use, and a TestJourney class which is mostly used to pass to the goto methods. I ask you please do not change the TestJourney using the 'set' methods, although you might find the getHistory helpful to see how tests have been called or to see what test your currently on and the next test in the chain. Note the ModuleFacade depending on FIRST (no data), MID (INPUT and PARAM data loaded), LAST/END (ALL facade data located both input and output). It will have what you need from the Facade class.

GOTO

Below you will see two sample method calls of a goto:
They have 3 params. The first is just a TestJourney that is originally passed into your doTrek method, the second is testID that you need to give a String of the test you are
going to, and finally the 'now' boolean, which says you want to go to it right now, as soon as this method is over. Hence if this logic was a FIRST or MID type logic, then don't even bother
calling the Facade, you've found something in the data that is wrong and need to go to a test right now.

You might be wondering why there are two different methods, a 'New' and a 'Keep' Sequence. Well, the 'NEW' which will probably be used the most and, typical of loops, means start a new sequence of tests from the one you are about to 'goto'. 'Keep' is for coming back. Best to show you in a alphabet example.
lets say you have Tests A->B....->Z and you are currently on 'M'.
You decide to go back to test B and start everything over hence M->B->C->D->.... and so on. Then you need the 'NewSequence'
BUT
What if you just want to go back to B and then come back to 'N', hence you want M->B->N->O->P.... and so on. There are a few cases where this would be nice, hence the 'KeepSequence' go to method.

Final Note: another method called 'skipTest()' is also available, that will simply skip to the next test in the sequence.

Handling Large Amounts of Data

As the datasets keep getting bigger and bigger, we can't hold everything in memory. In comes the 'TransitLoop' Logic class. See greater detail here: Odyssey LoopLogic

END

As noted below you will see one 'endChain' method which you give it a message and if this is an end for an error or not an error. Hence their is either Success or ERROR in this type of endChain.

public void endChain(TestJourney tj, String message,boolean error)

Common Logic classes

Below is a listing of common Logic classes that is so common they are now packaged with Odyssey:

Logic Description

Now for a sample Logic class that does not really do much just iterates a counter - see attachments for better examples of goto and looping. MTASourceLoopLogic for instance uses values from a storage array to determine when and where to loop. The below sample demonstrated here is more about seeing the method signature and imports:

package mssl.ucl.odyssey.samplelogic;
//you will need all these imports.
import gaia.dpcc.facade.ModuleFacade;
import java.util.Hashtable;
import mssl.ucl.odyssey.TestJourney;
import mssl.ucl.odyssey.logic.Juncture;
//BE SURE TO EXTENDS THIS JUNCTURE. It is what defines the Interface and abstract methods along with 'goto' ability.
public class LoopLogic extends Juncture {
public void doTrek(ModuleFacade facade, Hashtable storage, TestJourney tj) {
int loop = 0;
if(storage.containsKey("loopindex")) {
loop = (Integer)storage.get("loopindex");
System.out.println("Found loop it was " + loop);
//typically you would do an endChain or goto statement on a certain loop number. You can see these
// types of examples in the attached samples.
loop++;
}
//store it in the hashtable will be used later in another Logic or in the XML file.
storage.put("loopindex", loop);
System.out.println("Loop now at = " + loop);
}
}