[1227] | 1 | /* SaveSelectionConfigCommand.as */
|
---|
| 2 |
|
---|
| 3 | package gov.va.med.edp.command.config
|
---|
| 4 | {
|
---|
| 5 | import com.adobe.cairngorm.commands.ICommand;
|
---|
| 6 | import com.adobe.cairngorm.control.CairngormEvent;
|
---|
| 7 |
|
---|
| 8 | import gov.va.med.edp.business.config.SaveSelectionConfigDelegate;
|
---|
| 9 | import gov.va.med.edp.command.AbstractResponderCommand;
|
---|
| 10 | import gov.va.med.edp.model.TrackingModelLocator;
|
---|
| 11 | import gov.va.med.edp.util.BoardTools;
|
---|
| 12 | import gov.va.med.edp.widget.InfoDialog;
|
---|
| 13 |
|
---|
| 14 | import mx.collections.ArrayCollection;
|
---|
| 15 | import mx.rpc.IResponder;
|
---|
| 16 | import mx.rpc.events.FaultEvent;
|
---|
| 17 | import mx.rpc.events.ResultEvent;
|
---|
| 18 |
|
---|
| 19 | public class SaveSelectionConfigCommand extends AbstractResponderCommand implements ICommand, IResponder
|
---|
| 20 | {
|
---|
| 21 | private var model:TrackingModelLocator = TrackingModelLocator.getInstance();
|
---|
| 22 |
|
---|
| 23 | public function execute(event:CairngormEvent): void
|
---|
| 24 | {
|
---|
| 25 | var newStatuses: ArrayCollection;
|
---|
| 26 | var newDispositions: ArrayCollection;
|
---|
| 27 | var newDelays: ArrayCollection;
|
---|
| 28 | var newArrivals: ArrayCollection;
|
---|
| 29 |
|
---|
| 30 | if (model.config.statusesChanged) {
|
---|
| 31 | newStatuses = model.config.statuses;
|
---|
| 32 | }
|
---|
| 33 | if (model.config.dispositionsChanged) {
|
---|
| 34 | newDispositions = model.config.dispositions;
|
---|
| 35 | }
|
---|
| 36 | if (model.config.delaysChanged) {
|
---|
| 37 | newDelays = model.config.delays;
|
---|
| 38 | }
|
---|
| 39 | if (model.config.arrivalsChanged) {
|
---|
| 40 | newArrivals = model.config.arrivals;
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | model.config.selectionConfigLoaded = false;
|
---|
| 44 | var delegate: SaveSelectionConfigDelegate = new SaveSelectionConfigDelegate(this);
|
---|
| 45 | delegate.saveSelectionConfig(model.logArea, model.config.selectionToken,
|
---|
| 46 | newStatuses, newDispositions, newDelays, newArrivals);
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | public override function result(data:Object):void
|
---|
| 50 | {
|
---|
| 51 | var xml:XML = ResultEvent(data).result as XML;
|
---|
| 52 | if ((xml.save.@status == "ok") || (xml.save.@status == "collide")) {
|
---|
| 53 | BoardTools.applySelectionLists(model.config, xml);
|
---|
| 54 | model.config.selectionConfigLoaded = true;
|
---|
| 55 |
|
---|
| 56 | if (xml.save.@status == "ok") {
|
---|
| 57 | InfoDialog.show("New selection configuration saved.");
|
---|
| 58 | } else {
|
---|
| 59 | InfoDialog.show("Save failed: " + xml.save);
|
---|
| 60 | }
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | if (xml.save.@status == "fail") {
|
---|
| 64 | InfoDialog.show("Save failed: " + xml.save);
|
---|
| 65 | }
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | protected override function getFaultMessage(faultEvent:FaultEvent):String {
|
---|
| 69 | return "Error saving configuration for selections: " + super.getFaultMessage(faultEvent);
|
---|
| 70 | }
|
---|
| 71 | }
|
---|
| 72 | }
|
---|