source: EDIS/trunk/java/tracking-ui-core/src/main/flex/gov/va/med/edp/business/CSPService.as

Last change on this file was 1227, checked in by George Lilly, 13 years ago

initial load of EDIS 1.0

File size: 3.2 KB
Line 
1/* CSPService.as */
2
3package gov.va.med.edp.business
4{
5 import flash.display.DisplayObject;
6
7 import gov.va.med.edp.command.debug.DebugHTTPServiceResponder;
8 import gov.va.med.edp.model.TrackingModelLocator;
9
10 import mx.containers.Panel;
11 import mx.controls.Label;
12 import mx.core.Application;
13 import mx.managers.PopUpManager;
14 import mx.rpc.AsyncToken;
15 import mx.rpc.IResponder;
16 import mx.rpc.http.mxml.HTTPService;
17
18 public class CSPService extends HTTPService implements IResponder
19 {
20 public var command:String; // command to pass to CSP Controller
21 public var csp:String; // url for the Cache Server Page
22 public var vlj: String // url for VistALink Call
23 public var mock:String; // file name if using a mock object
24 public var callType: int // determines which call (vlj, csp, mock) to use
25 public var block: Boolean = false;
26
27 public static const SERVICE_USE_VLJ: int = 0;
28 public static const SERVICE_USE_CSP: int = 1
29 public static const SERVICE_USE_MOCK: int = 2;
30 private var model:TrackingModelLocator = TrackingModelLocator.getInstance();
31
32 private var _wait: Panel;
33
34 public function CSPService()
35 {
36 super();
37 this.resultFormat = "text";
38 this.method = "POST";
39 this.requestTimeout = 20;
40 }
41
42
43 override public function send(parameters:Object=null):AsyncToken
44 {
45 if ((vlj.length == 0) || (csp.length == 0) || (command.length == 0))
46 throw new Error( "csp, vlj and command may not be empty" );
47 if (parameters == null)
48 parameters = new Object;
49 parameters.command = this.command;
50 if (Application.application.parameters.swfID != null) parameters.swfID = Application.application.parameters.swfID;
51 if (Application.application.parameters.siteId != null)parameters.siteId = Application.application.parameters.siteId;
52 switch (callType) {
53 case SERVICE_USE_CSP:
54 this.url = csp;
55 break;
56 case SERVICE_USE_MOCK:
57 this.url = mock;
58 break;
59 default:
60 this.url = vlj;
61 break;
62 }
63 model.connecting = true;
64 //trace(this.url, ": ", this.command);
65 var token: AsyncToken = super.send(parameters);
66 token.addResponder(this);
67 if (this.block) {
68 showWaitWindow();
69 }
70
71 if (model.session != null && model.session.debugEnabled){
72 var debugResponder:DebugHTTPServiceResponder = new DebugHTTPServiceResponder(this, parameters);
73 token.addResponder(debugResponder);
74 }
75
76 return token;
77 }
78
79 private function showWaitWindow(): void
80 {
81 var label: Label = new Label();
82 label.text = "Wait...";
83 _wait =
84 Panel(PopUpManager.createPopUp(Application.application as DisplayObject, Panel, true));
85 _wait.addChild(label);
86 PopUpManager.centerPopUp(_wait);
87 }
88
89 public function result(data:Object):void
90 {
91 model.connecting = false;
92 if (model.disconnected) model.disconnected = false;
93 if (this.block) PopUpManager.removePopUp(_wait);
94 }
95
96 public function fault(info:Object):void
97 {
98 model.connecting = false;
99 if (this.block) PopUpManager.removePopUp(_wait);
100 }
101
102 }
103}
Note: See TracBrowser for help on using the repository browser.