diff --git a/CampusAppWP8/CampusAppDLL/Model/GeoDb/PlaceInformation.cs b/CampusAppWP8/CampusAppDLL/Model/GeoDb/PlaceInformation.cs index f23d4124..96390875 100644 --- a/CampusAppWP8/CampusAppDLL/Model/GeoDb/PlaceInformation.cs +++ b/CampusAppWP8/CampusAppDLL/Model/GeoDb/PlaceInformation.cs @@ -7,20 +7,35 @@ //---------------------------------------------------------------------- namespace CampusAppDLL.Model.GeoDb { + using System; using System.Xml.Serialization; /// Information about the place. /// Stubbfel, 19.08.2013. - public class PlaceInformation + public class PlaceInformation : IEquatable { /// Gets or sets the name of the information. /// The name of the information. - [XmlElement("placeInformationName")] + [XmlAttribute("placeInformationName")] public string InformationName { get; set; } /// Gets or sets the information value. /// The information value. [XmlText] public string InformationValue { get; set; } + + /// Tests if this PlaceInformation is considered equal to another. + /// Stubbfel, 09.09.2013. + /// The place information to compare to this object. + /// true if the objects are considered equal, false if they are not. + public bool Equals(PlaceInformation other) + { + if (other.InformationName.Equals(this.InformationName)) + { + return true; + } + + return false; + } } } diff --git a/CampusAppWP8/CampusAppDLL/Model/GeoDb/PlaceModel.cs b/CampusAppWP8/CampusAppDLL/Model/GeoDb/PlaceModel.cs index 8e0a0d20..939b4f76 100644 --- a/CampusAppWP8/CampusAppDLL/Model/GeoDb/PlaceModel.cs +++ b/CampusAppWP8/CampusAppDLL/Model/GeoDb/PlaceModel.cs @@ -8,13 +8,16 @@ namespace CampusAppDLL.Model.GeoDb { + using System; + using System.Collections.Generic; using System.Collections.ObjectModel; + using System.Text.RegularExpressions; using System.Xml.Serialization; /// /// Model for a place of the SPSService /// - public class PlaceModel + public class PlaceModel : IEquatable { /// /// Gets or sets the placeId @@ -34,6 +37,7 @@ namespace CampusAppDLL.Model.GeoDb [XmlAttribute("refpoint")] public string RefPoint { get; set; } + /// Gets or sets the information. /// The information. [XmlElement("placeInformation")] @@ -43,5 +47,121 @@ namespace CampusAppDLL.Model.GeoDb /// The services. [XmlElement("placeService")] public ObservableCollection Services { get; set; } + + /// Converts this object to a nfc string. + /// Stubbfel, 21.08.2013. + /// This object as a string. + public string ToNfcString() + { + string nfcStr = "{\"pid\":\"" + this.PlaceId + "\",\"parent\":\"" + this.ParentId + "\"}"; + return nfcStr; + } + + /// Tests if this PlaceModel is considered equal to another. + /// Stubbfel, 09.09.2013. + /// The place model to compare to this object. + /// true if the objects are considered equal, false if they are not. + public bool Equals(PlaceModel other) + { + if (other.PlaceId.Equals(this.PlaceId)) + { + return true; + } + + return false; + } + + /// Adds a place informations. + /// Stubbfel, 09.09.2013. + /// The place informations. + public void AddPlaceInformations(List placeInformations) + { + foreach (PlaceInformation info in placeInformations) + { + if (this.Informations.Contains(info)) + { + int index = this.Informations.IndexOf(info); + this.Informations[index].InformationValue = info.InformationValue; + } + else + { + this.Informations.Add(info); + } + } + } + + /// Adds a place services. + /// Stubbfel, 09.09.2013. + /// The place services. + public void AddPlaceServices(List placeServices) + { + foreach (PlaceService service in placeServices) + { + if (this.Services.Contains(service)) + { + int index = this.Services.IndexOf(service); + this.Services[index].Request = service.Request; + this.Services[index].SAP = service.SAP; + } + else + { + this.Services.Add(service); + } + } + } + + /// Query if 'names' contains information names. + /// Stubbfel, 09.09.2013. + /// The names. + /// true if it succeeds, false if it fails. + public bool ContainsInformationNames(List names) + { + foreach (string name in names) + { + bool tmpResult = false; + foreach (PlaceInformation info in this.Informations) + { + if (name.Equals(info.InformationName)) + { + tmpResult = true; + break; + } + } + + if (!tmpResult) + { + return tmpResult; + } + } + + return true; + } + + /// Query if 'services' contains service names. + /// Stubbfel, 09.09.2013. + /// The services. + /// true if it succeeds, false if it fails. + public bool ContainsServiceNames(List services) + { + foreach (string name in services) + { + bool tmpResult = false; + foreach (PlaceService service in this.Services) + { + if (name.Equals(service.ServiceName)) + { + tmpResult = true; + break; + } + } + + if (!tmpResult) + { + return tmpResult; + } + } + + return true; + } } } diff --git a/CampusAppWP8/CampusAppDLL/Model/GeoDb/PlaceService.cs b/CampusAppWP8/CampusAppDLL/Model/GeoDb/PlaceService.cs index 7e17403c..2804886d 100644 --- a/CampusAppWP8/CampusAppDLL/Model/GeoDb/PlaceService.cs +++ b/CampusAppWP8/CampusAppDLL/Model/GeoDb/PlaceService.cs @@ -8,11 +8,12 @@ namespace CampusAppDLL.Model.GeoDb { + using System; using System.Xml.Serialization; /// Place service. /// Stubbfel, 19.08.2013. - public class PlaceService + public class PlaceService : IEquatable { /// Gets or sets the name of the service. /// The name of the service. @@ -28,5 +29,29 @@ namespace CampusAppDLL.Model.GeoDb /// The request. [XmlElement("request")] public string Request { get; set; } + + /// Gets the URL string. + /// The URL string. + public string URLString + { + get + { + return this.SAP + this.Request; + } + } + + /// Tests if this PlaceService is considered equal to another. + /// Stubbfel, 09.09.2013. + /// The place service to compare to this object. + /// true if the objects are considered equal, false if they are not. + public bool Equals(PlaceService other) + { + if (other.ServiceName.Equals(this.ServiceName)) + { + return true; + } + + return false; + } } } diff --git a/CampusAppWP8/CampusAppDLL/Model/GeoDb/SpsModel.cs b/CampusAppWP8/CampusAppDLL/Model/GeoDb/SpsModel.cs index 4fa4bb86..396fa73e 100644 --- a/CampusAppWP8/CampusAppDLL/Model/GeoDb/SpsModel.cs +++ b/CampusAppWP8/CampusAppDLL/Model/GeoDb/SpsModel.cs @@ -23,6 +23,7 @@ namespace CampusAppDLL.Model.GeoDb /// Stubbfel, 20.08.2013. public SpsModel() { + this.HasChanged = false; this.Places = new ObservableCollection(); } @@ -32,6 +33,10 @@ namespace CampusAppDLL.Model.GeoDb [XmlElement("place")] public ObservableCollection Places { get; set; } + /// Gets a value indicating whether this object has changed. + /// true if this object has changed, false if not. + public bool HasChanged { get; set; } + /// Gets places by information. /// Stubbfel, 19.08.2013. /// The query. @@ -83,5 +88,113 @@ namespace CampusAppDLL.Model.GeoDb return resultplaces.ToList(); } + + /// Adds the places. + /// Stubbfel, 09.09.2013. + /// A list of places. + public void AddPlaces(List places) + { + foreach (PlaceModel place in places) + { + if (this.Places.Contains(place)) + { + int index = this.Places.IndexOf(place); + this.Places[index].AddPlaceInformations(place.Informations.ToList()); + this.Places[index].AddPlaceServices(place.Services.ToList()); + } + else + { + this.Places.Add(place); + } + } + this.HasChanged = true; + } + + /// Creates PID list. + /// Stubbfel, 09.09.2013. + /// The new PID list. + public List CreatePidList() + { + List pidList = new List(); + foreach (PlaceModel place in this.Places) + { + pidList.Add(place.PlaceId); + } + + return pidList; + } + + /// Gets place by identifier. + /// Stubbfel, 09.09.2013. + /// The identifier. + /// The place by identifier. + public PlaceModel GetPlaceById(string id) + { + foreach (PlaceModel place in this.Places) + { + if (place.PlaceId.Equals(id)) + { + return place; + } + } + + return null; + } + + /// Query if 'pidList' contains information names. + /// Stubbfel, 09.09.2013. + /// List of pids. + /// The names. + /// true if it succeeds, false if it fails. + public bool ContainsInformationNames(List pidList, List names) + { + foreach (string pid in pidList) + { + PlaceModel place = this.GetPlaceById(pid); + if (!place.ContainsInformationNames(names)) + { + return false; + } + } + + return true; + } + + /// Query if 'pidList' contains service names. + /// Stubbfel, 09.09.2013. + /// List of pids. + /// The names. + /// true if it succeeds, false if it fails. + public bool ContainsServiceNames(List pidList, List names) + { + foreach (string pid in pidList) + { + PlaceModel place = this.GetPlaceById(pid); + if (!place.ContainsServiceNames(names)) + { + return false; + } + } + + return true; + } + + /// Filter by PID. + /// Stubbfel, 11.09.2013. + /// List of pids. + /// flitered list of places + public List FilterByPid(List pidList) + { + List fitlerList = new List(); + foreach (PlaceModel place in this.Places) + { + if (pidList.Contains(place.PlaceId)) + { + fitlerList.Add(place); + } + } + + return fitlerList; + } } } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/GeoDb/PlaceInformation.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/GeoDb/PlaceInformation.cs index 4768712b..050c92bf 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/GeoDb/PlaceInformation.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/GeoDb/PlaceInformation.cs @@ -7,20 +7,35 @@ //---------------------------------------------------------------------- namespace CampusAppWPortalLib8.Model.GeoDb { + using System; using System.Xml.Serialization; /// Information about the place. /// Stubbfel, 19.08.2013. - public class PlaceInformation + public class PlaceInformation : IEquatable { /// Gets or sets the name of the information. /// The name of the information. - [XmlElement("placeInformationName")] + [XmlAttribute("placeInformationName")] public string InformationName { get; set; } /// Gets or sets the information value. /// The information value. [XmlText] public string InformationValue { get; set; } + + /// Tests if this PlaceInformation is considered equal to another. + /// Stubbfel, 09.09.2013. + /// The place information to compare to this object. + /// true if the objects are considered equal, false if they are not. + public bool Equals(PlaceInformation other) + { + if (other.InformationName.Equals(this.InformationName)) + { + return true; + } + + return false; + } } } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/GeoDb/PlaceModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/GeoDb/PlaceModel.cs index 3b048ee8..6b533c75 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/GeoDb/PlaceModel.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/GeoDb/PlaceModel.cs @@ -8,13 +8,16 @@ namespace CampusAppWPortalLib8.Model.GeoDb { + using System; + using System.Collections.Generic; using System.Collections.ObjectModel; + using System.Text.RegularExpressions; using System.Xml.Serialization; /// /// Model for a place of the SPSService /// - public class PlaceModel + public class PlaceModel : IEquatable { /// /// Gets or sets the placeId @@ -34,6 +37,7 @@ namespace CampusAppWPortalLib8.Model.GeoDb [XmlAttribute("refpoint")] public string RefPoint { get; set; } + /// Gets or sets the information. /// The information. [XmlElement("placeInformation")] @@ -43,5 +47,121 @@ namespace CampusAppWPortalLib8.Model.GeoDb /// The services. [XmlElement("placeService")] public ObservableCollection Services { get; set; } + + /// Converts this object to a nfc string. + /// Stubbfel, 21.08.2013. + /// This object as a string. + public string ToNfcString() + { + string nfcStr = "{\"pid\":\"" + this.PlaceId + "\",\"parent\":\"" + this.ParentId + "\"}"; + return nfcStr; + } + + /// Tests if this PlaceModel is considered equal to another. + /// Stubbfel, 09.09.2013. + /// The place model to compare to this object. + /// true if the objects are considered equal, false if they are not. + public bool Equals(PlaceModel other) + { + if (other.PlaceId.Equals(this.PlaceId)) + { + return true; + } + + return false; + } + + /// Adds a place informations. + /// Stubbfel, 09.09.2013. + /// The place informations. + public void AddPlaceInformations(List placeInformations) + { + foreach (PlaceInformation info in placeInformations) + { + if (this.Informations.Contains(info)) + { + int index = this.Informations.IndexOf(info); + this.Informations[index].InformationValue = info.InformationValue; + } + else + { + this.Informations.Add(info); + } + } + } + + /// Adds a place services. + /// Stubbfel, 09.09.2013. + /// The place services. + public void AddPlaceServices(List placeServices) + { + foreach (PlaceService service in placeServices) + { + if (this.Services.Contains(service)) + { + int index = this.Services.IndexOf(service); + this.Services[index].Request = service.Request; + this.Services[index].SAP = service.SAP; + } + else + { + this.Services.Add(service); + } + } + } + + /// Query if 'names' contains information names. + /// Stubbfel, 09.09.2013. + /// The names. + /// true if it succeeds, false if it fails. + public bool ContainsInformationNames(List names) + { + foreach (string name in names) + { + bool tmpResult = false; + foreach (PlaceInformation info in this.Informations) + { + if (name.Equals(info.InformationName)) + { + tmpResult = true; + break; + } + } + + if (!tmpResult) + { + return tmpResult; + } + } + + return true; + } + + /// Query if 'services' contains service names. + /// Stubbfel, 09.09.2013. + /// The services. + /// true if it succeeds, false if it fails. + public bool ContainsServiceNames(List services) + { + foreach (string name in services) + { + bool tmpResult = false; + foreach (PlaceService service in this.Services) + { + if (name.Equals(service.ServiceName)) + { + tmpResult = true; + break; + } + } + + if (!tmpResult) + { + return tmpResult; + } + } + + return true; + } } } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/GeoDb/PlaceService.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/GeoDb/PlaceService.cs index 8a5f5bf8..220b59bb 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/GeoDb/PlaceService.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/GeoDb/PlaceService.cs @@ -8,11 +8,12 @@ namespace CampusAppWPortalLib8.Model.GeoDb { + using System; using System.Xml.Serialization; /// Place service. /// Stubbfel, 19.08.2013. - public class PlaceService + public class PlaceService : IEquatable { /// Gets or sets the name of the service. /// The name of the service. @@ -28,5 +29,29 @@ namespace CampusAppWPortalLib8.Model.GeoDb /// The request. [XmlElement("request")] public string Request { get; set; } + + /// Gets the URL string. + /// The URL string. + public string URLString + { + get + { + return this.SAP + this.Request; + } + } + + /// Tests if this PlaceService is considered equal to another. + /// Stubbfel, 09.09.2013. + /// The place service to compare to this object. + /// true if the objects are considered equal, false if they are not. + public bool Equals(PlaceService other) + { + if (other.ServiceName.Equals(this.ServiceName)) + { + return true; + } + + return false; + } } } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/GeoDb/SpsModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/GeoDb/SpsModel.cs index 378d7e90..ea41c617 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/GeoDb/SpsModel.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/GeoDb/SpsModel.cs @@ -23,6 +23,7 @@ namespace CampusAppWPortalLib8.Model.GeoDb /// Stubbfel, 20.08.2013. public SpsModel() { + this.HasChanged = false; this.Places = new ObservableCollection(); } @@ -32,6 +33,10 @@ namespace CampusAppWPortalLib8.Model.GeoDb [XmlElement("place")] public ObservableCollection Places { get; set; } + /// Gets a value indicating whether this object has changed. + /// true if this object has changed, false if not. + public bool HasChanged { get; set; } + /// Gets places by information. /// Stubbfel, 19.08.2013. /// The query. @@ -83,5 +88,113 @@ namespace CampusAppWPortalLib8.Model.GeoDb return resultplaces.ToList(); } + + /// Adds the places. + /// Stubbfel, 09.09.2013. + /// A list of places. + public void AddPlaces(List places) + { + foreach (PlaceModel place in places) + { + if (this.Places.Contains(place)) + { + int index = this.Places.IndexOf(place); + this.Places[index].AddPlaceInformations(place.Informations.ToList()); + this.Places[index].AddPlaceServices(place.Services.ToList()); + } + else + { + this.Places.Add(place); + } + } + this.HasChanged = true; + } + + /// Creates PID list. + /// Stubbfel, 09.09.2013. + /// The new PID list. + public List CreatePidList() + { + List pidList = new List(); + foreach (PlaceModel place in this.Places) + { + pidList.Add(place.PlaceId); + } + + return pidList; + } + + /// Gets place by identifier. + /// Stubbfel, 09.09.2013. + /// The identifier. + /// The place by identifier. + public PlaceModel GetPlaceById(string id) + { + foreach (PlaceModel place in this.Places) + { + if (place.PlaceId.Equals(id)) + { + return place; + } + } + + return null; + } + + /// Query if 'pidList' contains information names. + /// Stubbfel, 09.09.2013. + /// List of pids. + /// The names. + /// true if it succeeds, false if it fails. + public bool ContainsInformationNames(List pidList, List names) + { + foreach (string pid in pidList) + { + PlaceModel place = this.GetPlaceById(pid); + if (!place.ContainsInformationNames(names)) + { + return false; + } + } + + return true; + } + + /// Query if 'pidList' contains service names. + /// Stubbfel, 09.09.2013. + /// List of pids. + /// The names. + /// true if it succeeds, false if it fails. + public bool ContainsServiceNames(List pidList, List names) + { + foreach (string pid in pidList) + { + PlaceModel place = this.GetPlaceById(pid); + if (!place.ContainsServiceNames(names)) + { + return false; + } + } + + return true; + } + + /// Filter by PID. + /// Stubbfel, 11.09.2013. + /// List of pids. + /// flitered list of places + public List FilterByPid(List pidList) + { + List fitlerList = new List(); + foreach (PlaceModel place in this.Places) + { + if (pidList.Contains(place.PlaceId)) + { + fitlerList.Add(place); + } + } + + return fitlerList; + } } }