| 1 | /* |
|---|
| 2 | * To change this license header, choose License Headers in Project Properties. |
|---|
| 3 | * To change this template file, choose Tools | Templates |
|---|
| 4 | * and open the template in the editor. |
|---|
| 5 | */ |
|---|
| 6 | package scriptbuilder.structures.events; |
|---|
| 7 | |
|---|
| 8 | import java.util.ArrayList; |
|---|
| 9 | import scriptbuilder.structures.ELEMENT; |
|---|
| 10 | import scriptbuilder.structures.I_XML_Writable; |
|---|
| 11 | import scriptbuilder.structures.ScriptEvent; |
|---|
| 12 | import scriptbuilder.structures.XMLWriter; |
|---|
| 13 | |
|---|
| 14 | /** |
|---|
| 15 | * Data model for a CMS evaluatiion event. A CMS event has a location, a set of |
|---|
| 16 | * messages, an ID, and a type. It also is an evaluation event. |
|---|
| 17 | * |
|---|
| 18 | * @author Bryan McGuffin |
|---|
| 19 | */ |
|---|
| 20 | public class CMSEvaluationEvent extends ScriptEvent implements I_EvaluationEvent, I_XML_Writable |
|---|
| 21 | { |
|---|
| 22 | |
|---|
| 23 | public CMSEvaluationEvent() |
|---|
| 24 | { |
|---|
| 25 | super(ScriptEventType.CMS_EVAL_EVENT); |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | public String location = ""; |
|---|
| 29 | |
|---|
| 30 | public ArrayList<String> message = new ArrayList<String>(); |
|---|
| 31 | |
|---|
| 32 | public String cmsID = ""; |
|---|
| 33 | |
|---|
| 34 | public String cmsType = ""; |
|---|
| 35 | |
|---|
| 36 | public ArrayList<String> expectedAction = new ArrayList<String>(); |
|---|
| 37 | |
|---|
| 38 | @Override |
|---|
| 39 | public ArrayList<String> getExpectedActions() |
|---|
| 40 | { |
|---|
| 41 | return expectedAction; |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | @Override |
|---|
| 45 | public void addAction(String act) |
|---|
| 46 | { |
|---|
| 47 | expectedAction.add(act); |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | @Override |
|---|
| 51 | public void updateAction(int index, String act) |
|---|
| 52 | { |
|---|
| 53 | expectedAction.set(index, act); |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | @Override |
|---|
| 57 | public void removeAction(int index) |
|---|
| 58 | { |
|---|
| 59 | expectedAction.remove(index); |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | @Override |
|---|
| 63 | public String toXML() |
|---|
| 64 | { |
|---|
| 65 | String output = XMLWriter.openTag(ELEMENT.CMS_EVALUATION.tag + " cmsID=\"" + cmsID + "\" type=\"" + cmsType + "\""); |
|---|
| 66 | output += XMLWriter.simpleTag(location, ELEMENT.LOCATION); |
|---|
| 67 | |
|---|
| 68 | if (message.size() > 0) |
|---|
| 69 | { |
|---|
| 70 | output += XMLWriter.openTag(ELEMENT.SAMPLE_MESSAGE.tag); |
|---|
| 71 | for (String str : message) |
|---|
| 72 | { |
|---|
| 73 | if (str == null) |
|---|
| 74 | { |
|---|
| 75 | str = ""; |
|---|
| 76 | } |
|---|
| 77 | output += XMLWriter.simpleTag(str, ELEMENT.CMS_LINE); |
|---|
| 78 | } |
|---|
| 79 | output += XMLWriter.closeTag(ELEMENT.SAMPLE_MESSAGE.tag); |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | output += XMLWriter.closeTag(ELEMENT.CMS_EVALUATION.tag); |
|---|
| 83 | |
|---|
| 84 | return output; |
|---|
| 85 | } |
|---|
| 86 | } |
|---|