[1227] | 1 | /* RefreshDisplayBoardCommand.as */
|
---|
| 2 |
|
---|
| 3 | package gov.va.med.edp.command
|
---|
| 4 | {
|
---|
| 5 | import com.adobe.cairngorm.commands.ICommand;
|
---|
| 6 | import com.adobe.cairngorm.control.CairngormEvent;
|
---|
| 7 |
|
---|
| 8 | import gov.va.med.edp.business.RefreshDisplayBoardDelegate;
|
---|
| 9 | import gov.va.med.edp.control.DisplayBoardEvent;
|
---|
| 10 | import gov.va.med.edp.model.BigBoardDebugInfo;
|
---|
| 11 | import gov.va.med.edp.model.TrackingModelLocator;
|
---|
| 12 |
|
---|
| 13 | import mx.collections.Sort;
|
---|
| 14 | import mx.collections.SortField;
|
---|
| 15 | import mx.collections.XMLListCollection;
|
---|
| 16 | import mx.rpc.IResponder;
|
---|
| 17 | import mx.rpc.events.FaultEvent;
|
---|
| 18 | import mx.rpc.events.ResultEvent;
|
---|
| 19 |
|
---|
| 20 | public class RefreshDisplayBoardCommand extends AbstractResponderCommand implements ICommand, IResponder
|
---|
| 21 | {
|
---|
| 22 | private var model:TrackingModelLocator = TrackingModelLocator.getInstance();
|
---|
| 23 | private var initDisplayBoardEvent: DisplayBoardEvent;
|
---|
| 24 |
|
---|
| 25 | public function execute(event:CairngormEvent):void
|
---|
| 26 | {
|
---|
| 27 | var delegate:RefreshDisplayBoardDelegate = new RefreshDisplayBoardDelegate(this);
|
---|
| 28 | var refreshEvent: DisplayBoardEvent = DisplayBoardEvent(event);
|
---|
| 29 |
|
---|
| 30 | //save off the refreshEvent as an initDisplayBoardEvent in case we need to fire it if needed..
|
---|
| 31 | initDisplayBoardEvent = new DisplayBoardEvent(DisplayBoardEvent.EVENT_INIT_DISPLAY_BOARD);
|
---|
| 32 | initDisplayBoardEvent.name = refreshEvent.name;
|
---|
| 33 |
|
---|
| 34 | delegate.refreshDisplayBoard(model.session.area, refreshEvent.name, model.boardSpec.configLastUpdated);
|
---|
| 35 | model.boardReady = false;
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | public override function result(data:Object):void
|
---|
| 39 | {
|
---|
| 40 | var xml:XML = ResultEvent(data).result as XML;
|
---|
| 41 |
|
---|
| 42 | // if the version on the server has changed we will need to load the new bigboard .swf automatically
|
---|
| 43 | // (UI used by human will get updated during login process)
|
---|
| 44 | if (model.appName == TrackingModelLocator.APP_NAME_BIGBOARD && model.appClientVersion != xml.rows.@version) {
|
---|
| 45 | model.logout();
|
---|
| 46 | return;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | model.boardSpec.configLastUpdated = xml.rows.@configLastUpdated;
|
---|
| 50 | model.boardSpec.reloadConfig = (xml.rows.@reloadConfig == "true");
|
---|
| 51 |
|
---|
| 52 | //if reloadConfig is true, fire an InitDisplayBoard Event Instead..
|
---|
| 53 | // this will cause the new Display Board Configuration and Data to be reloaded
|
---|
| 54 | //instead of just reloading the data...
|
---|
| 55 | if (model.boardSpec.reloadConfig == true){
|
---|
| 56 | initDisplayBoardEvent.dispatch();
|
---|
| 57 | return;
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | model.boardData = null;
|
---|
| 61 | model.boardData = new XMLListCollection(xml.rows.children() as XMLList);
|
---|
| 62 | model.boardLastUpdated = new Date();
|
---|
| 63 |
|
---|
| 64 |
|
---|
| 65 | // sort based on previous settings
|
---|
| 66 | if (model.boardSortField.length > 0) {
|
---|
| 67 | var sort: Sort = new Sort();
|
---|
| 68 | //Do a numeric sort for any mins related columns
|
---|
| 69 | if ((model.boardSortField.indexOf("min") != -1 )){
|
---|
| 70 | sort.fields = [new SortField(model.boardSortField, true, model.boardSortDescending, true)];
|
---|
| 71 | } else {
|
---|
| 72 | sort.fields = [new SortField(model.boardSortField, true, model.boardSortDescending, false)];
|
---|
| 73 | }
|
---|
| 74 | model.boardData.sort = sort;
|
---|
| 75 | model.boardData.refresh();
|
---|
| 76 | }
|
---|
| 77 | model.boardReady = true;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | protected override function getFaultMessage(faultEvent:FaultEvent):String {
|
---|
| 81 | return "Unable to refresh display board: " + super.getFaultMessage(faultEvent);
|
---|
| 82 | }
|
---|
| 83 | }
|
---|
| 84 | }
|
---|