[1240] | 1 | /* InitAppCommand.as */
|
---|
| 2 |
|
---|
| 3 | package gov.va.med.edp.command
|
---|
| 4 | {
|
---|
| 5 | import com.adobe.cairngorm.business.ServiceLocator;
|
---|
| 6 | import com.adobe.cairngorm.commands.ICommand;
|
---|
| 7 | import com.adobe.cairngorm.control.CairngormEvent;
|
---|
| 8 |
|
---|
| 9 | import gov.va.med.edp.business.InitUserDelegate;
|
---|
| 10 | import gov.va.med.edp.business.Services;
|
---|
| 11 | import gov.va.med.edp.control.InitAppEvent;
|
---|
| 12 | import gov.va.med.edp.control.TrackingEvent;
|
---|
| 13 | import gov.va.med.edp.factory.SessionFactory;
|
---|
| 14 | import gov.va.med.edp.model.TrackingModelLocator;
|
---|
| 15 | import gov.va.med.edp.view.ErrorDialog;
|
---|
| 16 | import gov.va.med.edp.vo.SessionVO;
|
---|
| 17 |
|
---|
| 18 | import mx.core.Application;
|
---|
| 19 |
|
---|
| 20 | import mx.rpc.IResponder;
|
---|
| 21 | import mx.rpc.events.FaultEvent;
|
---|
| 22 | import mx.rpc.events.ResultEvent;
|
---|
| 23 |
|
---|
| 24 | public class InitAppCommand extends AbstractResponderCommand implements ICommand, IResponder
|
---|
| 25 | {
|
---|
| 26 | private var model:TrackingModelLocator = TrackingModelLocator.getInstance();
|
---|
| 27 |
|
---|
| 28 | public function execute(event:CairngormEvent):void
|
---|
| 29 | {
|
---|
| 30 | // set up Services.mxml so it knows the runtime URL
|
---|
| 31 | var e: InitAppEvent = InitAppEvent(event);
|
---|
| 32 | var prefix: String = "";
|
---|
| 33 |
|
---|
| 34 | if (e.mode == InitAppEvent.SERVICE_USE_VLJ) {
|
---|
| 35 | prefix = e.protocol + "://" + e.server + e.contextRoot + "/";
|
---|
| 36 | model.rootURL = prefix;
|
---|
| 37 | model.logoutURL = prefix + "logout.html?swfID=" + Application.application.parameters.swfID;
|
---|
| 38 | model.helpContextRootURL = e.protocol + "://" + e.server + "/" + e.helpContextRoot + "/";
|
---|
| 39 | if (e.appName == TrackingModelLocator.APP_NAME_BIGBOARD) {
|
---|
| 40 | if (!e.timeout) {
|
---|
| 41 | model.logoutURL = prefix + "reset.jsp";
|
---|
| 42 | }
|
---|
| 43 | }
|
---|
| 44 | }
|
---|
| 45 | if (e.mode == InitAppEvent.SERVICE_USE_CSP) {
|
---|
| 46 | prefix = e.protocol + "://" + e.server + "/";
|
---|
| 47 | model.rootURL = prefix;
|
---|
| 48 | model.logoutURL = prefix + "edp.logout.cls";
|
---|
| 49 | model.helpContextRootURL = e.protocol + "://" + e.server + "/" + e.helpContextRoot + "/";
|
---|
| 50 | }
|
---|
| 51 | Services(ServiceLocator.getInstance()).callPrefix = prefix;
|
---|
| 52 | Services(ServiceLocator.getInstance()).callMode = e.mode;
|
---|
| 53 | model.appName = e.appName;
|
---|
| 54 | model.contextRoot = e.contextRoot;
|
---|
| 55 |
|
---|
| 56 | if (e.appName == TrackingModelLocator.APP_NAME_BIGBOARD) {
|
---|
| 57 | if (e.timeout) {
|
---|
| 58 | new InitUserDelegate(this).initUser(e.token);
|
---|
| 59 | } else {
|
---|
| 60 | initAnonymousUser(e.areaName);
|
---|
| 61 | }
|
---|
| 62 | } else {
|
---|
| 63 | new InitUserDelegate(this).initUser(e.token);
|
---|
| 64 | }
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | // don't call facility server for big board
|
---|
| 68 | private function initAnonymousUser(areaName: String): void
|
---|
| 69 | {
|
---|
| 70 | model.session = new SessionVO();
|
---|
| 71 | model.session.duz = "0";
|
---|
| 72 | model.session.site = "";
|
---|
| 73 | model.session.siteName = "";
|
---|
| 74 | model.session.area = 0;
|
---|
| 75 | model.session.areaName = areaName;
|
---|
| 76 | model.session.baseTime = new Date();
|
---|
| 77 | model.session.timeOut = 3600000;
|
---|
| 78 | model.session.countDown = 0;
|
---|
| 79 | model.session.canExport = false;
|
---|
| 80 | model.session.showProviderReport = false;
|
---|
| 81 | model.session.showPatientCrossReferenceReport = false;
|
---|
| 82 | model.session.debugEnabled = false;
|
---|
| 83 | // model.appViewList not used by big board (no menu on left side)
|
---|
| 84 | new TrackingEvent(TrackingEvent.EVENT_INIT_TRACKING).dispatch();
|
---|
| 85 |
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | public override function result(data:Object):void
|
---|
| 89 | {
|
---|
| 90 | var xml:XML = ResultEvent(data).result as XML;
|
---|
| 91 |
|
---|
| 92 | model.session = SessionFactory.buildSessionFromXML(xml);
|
---|
| 93 | model.appViewList = SessionFactory.buildLookupListFromXML(xml.view);
|
---|
| 94 |
|
---|
| 95 | // now that information has been obtained from the local facility
|
---|
| 96 | // post this event to get the main server info and start the application
|
---|
| 97 | new TrackingEvent(TrackingEvent.EVENT_INIT_TRACKING).dispatch();
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | protected override function getFaultMessage(fault:FaultEvent) : String {
|
---|
| 101 | return "Unable to get user profile.";
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | protected override function createFaultDetail(fault:FaultEvent) : Object {
|
---|
| 105 | var detail:Object = super.createFaultDetail(fault);
|
---|
| 106 | detail.callPrefix = Services(ServiceLocator.getInstance()).callPrefix;
|
---|
| 107 | detail.callMode = Services(ServiceLocator.getInstance()).callMode;
|
---|
| 108 | return detail;
|
---|
| 109 | }
|
---|
| 110 | }
|
---|
| 111 | }
|
---|