Module: nagvis Branch: master Commit: c85ab59707f731712df1c4933f44f51fe40e6b81 URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis/commit/?id=c85ab59707f731712df1c4933f44f51fe40e6b81
Author: Roman Kyrylych <[email protected]> Date: Fri Jul 17 14:26:54 2009 +0300 Initial work on new netmap vs objects binding scheme Signed-off-by: Roman Kyrylych <[email protected]> --- share/netmap/Database.php | 27 +++++++++++++++++ share/netmap/Location.php | 51 ++++++++++++++++++++++++++++---- uifx/src/modules/gmap/GMapModule.as | 28 ++++++++++++++++++ uifx/src/modules/gmap/GMapModule.mxml | 2 + uifx/src/modules/gmap/Link.as | 1 - uifx/src/modules/gmap/Location.as | 31 +++++++++++++++---- 6 files changed, 125 insertions(+), 15 deletions(-) diff --git a/share/netmap/Database.php b/share/netmap/Database.php index cf1e9a7..c115f14 100644 --- a/share/netmap/Database.php +++ b/share/netmap/Database.php @@ -59,6 +59,33 @@ class Database return $services; } + + /** + * @return array of HostGroup + */ + public function getHostGroups() + { + $hostgroups = array(); + + $hostgroups[] = new HostGroup('1', 'Gothenburg'); + $hostgroups[] = new HostGroup('2', 'Stockholm'); + $hostgroups[] = new HostGroup('3', 'Lviv'); + + return $hostgroups; + } + + /** + * @return array of ServiceGroup + */ + public function getServiceGroups() + { + $servicegroups = array(); + + $servicegroups[] = new ServiceGroup('1', 'Gothenburg-Stockholm VPN link'); + $servicegroups[] = new ServiceGroup('2', 'Stockholm-Lviv VPN link'); + + return $servicegroups; + } } ?> diff --git a/share/netmap/Location.php b/share/netmap/Location.php index a74d97f..fae272d 100644 --- a/share/netmap/Location.php +++ b/share/netmap/Location.php @@ -28,16 +28,18 @@ class Location public $label; public $address; public $description; - public $hosts; + public $object; + public $objectType; - public function __construct($id = "", $point = "", $label = "", $address = "", $description = "", $hosts = array()) + public function __construct($id = "", $point = "", $label = "", $address = "", $description = "", $object = null, $objectType = "") { $this->id = $id; $this->point = $point; $this->label = $label; $this->address = $address; $this->description = $description; - $this->hosts = $hosts; + $this->object = $object; + $this->objectType = $objectType; } /** @@ -51,14 +53,49 @@ class Location $locations = array(); foreach ($xml->location as $location) { - $hosts = array(); - foreach ($location->children() as $host) - $hosts[] = array('id' => (string)$host['id'], 'name' => (string)$host['name']); + $object = null; + $object_type = ''; + + /* Note: there should be only one child of location node, + but it is required to use foreach with children() */ + foreach ($location->children() as $object_node) + { + $object_type = $object_node->getName(); + switch ($object_type) + { + case 'host': + $object = new Host((string)$object_node['id'], + (string)$object_node['name'], + (string)$object_node['address']); + break; + + case 'hostgroup': + $object = new HostGroup((string)$object_node['id'], + (string)$object_node['name'], + (string)$object_node['alias']); + break; + + case 'service': + $object = new Service((string)$object_node['id'], + (string)$object_node['description'], + (string)$object_node['host']); + break; + + case 'servicegroup': + $object = new ServiceGroup((string)$object_node['id'], + (string)$object_node['name'], + (string)$object_node['alias']); + break; + + default: + throw new Exception('Unknown object type in locations.xml'); + } + } $locations[] = new Location((string)$location['id'], (string)$location['point'], (string)$location['label'], (string)$location['address'], (string)$location['description'], - $hosts); + $object, $object_type); } return $locations; diff --git a/uifx/src/modules/gmap/GMapModule.as b/uifx/src/modules/gmap/GMapModule.as index 2a5629b..a40be65 100644 --- a/uifx/src/modules/gmap/GMapModule.as +++ b/uifx/src/modules/gmap/GMapModule.as @@ -48,7 +48,9 @@ private var locations : LocationsCollection = new LocationsCollection; private var foundLocations : LocationsCollection = new LocationsCollection; private var links : ArrayCollection; private var hosts : ArrayCollection; +private var hostgroups : ArrayCollection; private var services : ArrayCollection = new ArrayCollection(); +private var servicegroups : ArrayCollection = new ArrayCollection(); private var locationsView : LocationsView; private var foundLocationsView : FoundLocationsView; @@ -230,6 +232,28 @@ private function getServices_handler(event : ResultEvent) : void //linksBox.services.dataProvider = services; } +private function getHostGroups_handler(event : ResultEvent) : void +{ + var result : ArrayCollection = new ArrayCollection(event.result as Array); + + hostgroups = new ArrayCollection(); + for each (var hostgroup : HostGroup in result) + hostgroups.addItem(hostgroup); + + //locationBox.locHosts.dataProvider = hosts; +} + +private function getServiceGroups_handler(event : ResultEvent) : void +{ + var result : ArrayCollection = new ArrayCollection(event.result as Array); + + servicegroups = new ArrayCollection(); + for each (var servicegroup : ServiceGroup in result) + servicegroups.addItem(servicegroup); + + //linksBox.services.dataProvider = services; +} + /*********************************************/ /* Location markers /*********************************************/ @@ -311,6 +335,7 @@ private function onShowLocationBox() : void if (searchBox.status == "expanded") searchBox.setCurrentState("right-contracted"); + /* for each (var host : Host in hosts) next_host: for each (var location : Location in locations) @@ -320,6 +345,7 @@ next_host: host.selected = true; break next_host; } + */ if (locationsView && locationsView.selectedLocation) locationBox.update(locationsView.selectedLocation); @@ -366,6 +392,7 @@ private function onDeleteLocation() : void private function onShowLinkBox() : void { + /* for each (var service : Service in services) next_service: for each (var link : Link in links) @@ -375,6 +402,7 @@ next_service: service.selected = true; break next_service; } + */ } private function onLink() : void diff --git a/uifx/src/modules/gmap/GMapModule.mxml b/uifx/src/modules/gmap/GMapModule.mxml index 233b22b..60290d6 100644 --- a/uifx/src/modules/gmap/GMapModule.mxml +++ b/uifx/src/modules/gmap/GMapModule.mxml @@ -118,6 +118,8 @@ </mx:RemoteObject> <mx:RemoteObject id="rDatabase" destination="zend" source="Database" fault="fault(event)"> <mx:method name="getHosts" result="getHosts_handler(event)"/> + <mx:method name="getHostGroups" result="getHostGroups_handler(event)"/> <mx:method name="getServices" result="getServices_handler(event)"/> + <mx:method name="getServiceGroups" result="getServiceGroups_handler(event)"/> </mx:RemoteObject> </mx:Module> diff --git a/uifx/src/modules/gmap/Link.as b/uifx/src/modules/gmap/Link.as index 3f35600..f9ec33f 100644 --- a/uifx/src/modules/gmap/Link.as +++ b/uifx/src/modules/gmap/Link.as @@ -27,6 +27,5 @@ package modules.gmap { public var id1 : String; public var id2 : String; - public var services : Array; } } diff --git a/uifx/src/modules/gmap/Location.as b/uifx/src/modules/gmap/Location.as index f8a1448..3e89d76 100644 --- a/uifx/src/modules/gmap/Location.as +++ b/uifx/src/modules/gmap/Location.as @@ -31,7 +31,8 @@ package modules.gmap private var _label : String; private var _address : String; private var _description : String; - private var _hosts : Array; + private var _object : Object; + private var _objectType : String; public function get id() : String { @@ -103,16 +104,30 @@ package modules.gmap } } - public function get hosts() : Array + public function get object() : Object { - return this._hosts; + return this._object; } - public function set hosts(value : Array) : void + public function set object(value : Object) : void { - if ( _hosts != value) + if (_object != value) { - this._hosts = value; + this._object = value; + dispatchEvent(new LocationEvent('change', this)); + } + } + + public function get objectType() : String + { + return this._objectType; + } + + public function set objectType(value : String) : void + { + if (_objectType != value) + { + this._objectType = value; dispatchEvent(new LocationEvent('change', this)); } } @@ -123,7 +138,9 @@ package modules.gmap this.point = value.point; this.label = value.label; this.address = value.address; - this.description = value.description; + this.description = value.description; + this.object = value.object; + this.objectType = value.objectType; } } } ------------------------------------------------------------------------------ Enter the BlackBerry Developer Challenge This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
