[1240] | 1 | /* InitTrackingCommand.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.InitTrackingDelegate;
|
---|
| 9 | import gov.va.med.edp.control.SwitchAppViewEvent;
|
---|
| 10 | import gov.va.med.edp.model.TrackingModelLocator;
|
---|
| 11 | import gov.va.med.edp.vo.LookupVO;
|
---|
| 12 |
|
---|
| 13 | import mx.rpc.IResponder;
|
---|
| 14 | import mx.rpc.events.FaultEvent;
|
---|
| 15 | import mx.rpc.events.ResultEvent;
|
---|
| 16 |
|
---|
| 17 | public class InitTrackingCommand extends AbstractResponderCommand implements ICommand, IResponder
|
---|
| 18 | {
|
---|
| 19 | private var model:TrackingModelLocator = TrackingModelLocator.getInstance();
|
---|
| 20 |
|
---|
| 21 | public function execute(event:CairngormEvent):void
|
---|
| 22 | {
|
---|
| 23 | var delegate: InitTrackingDelegate = new InitTrackingDelegate(this);
|
---|
| 24 | delegate.initTracking(model.session.areaName);
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | public override function result(data:Object):void
|
---|
| 28 | {
|
---|
| 29 | var xml:XML = ResultEvent(data).result as XML;
|
---|
| 30 |
|
---|
| 31 | model.session.serverPackageVersion = xml.user[0].@version;
|
---|
| 32 | if (model.session.area <= 0) {
|
---|
| 33 | model.session.area = xml.user[0].@area;
|
---|
| 34 | model.session.areaName = xml.user[0].@areaNm;
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | model.logArea = model.session.area; // set initial logArea value
|
---|
| 38 |
|
---|
| 39 | if (model.appName == TrackingModelLocator.APP_NAME_TRACKING) {
|
---|
| 40 | var e:SwitchAppViewEvent = new SwitchAppViewEvent(SwitchAppViewEvent.EVENT_SWITCH_APP_VIEW);
|
---|
| 41 | if (isVersionIncompatibility()) {
|
---|
| 42 | e.view = TrackingModelLocator.VIEW_APP_VERSION_INCOMPATIBILITY;
|
---|
| 43 | } else if (model.appViewList.length > 0) {
|
---|
| 44 | e.view = (model.appViewList[0] as LookupVO).data;
|
---|
| 45 | }
|
---|
| 46 | e.dispatch();
|
---|
| 47 | } else if (model.appName == TrackingModelLocator.APP_NAME_BIGBOARD) {
|
---|
| 48 | if (isVersionIncompatibility()) {
|
---|
| 49 | model.appViewState = TrackingModelLocator.VIEW_APP_VERSION_INCOMPATIBILITY;
|
---|
| 50 | } else {
|
---|
| 51 | model.appViewState = TrackingModelLocator.VIEW_APP_DISPLAY_BOARD;
|
---|
| 52 | }
|
---|
| 53 | }
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | private function isVersionIncompatibility():Boolean {
|
---|
| 57 | return model.appClientVersion != model.session.serverPackageVersion;
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | protected override function getFaultMessage(faultEvent:FaultEvent):String {
|
---|
| 61 | return "Unable to initialize tracking views: " + super.getFaultMessage(faultEvent);
|
---|
| 62 | }
|
---|
| 63 | }
|
---|
| 64 | }
|
---|