v4sample.pas 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808
  1. unit v4sample;
  2. {$MODE objfpc}
  3. {$H+}
  4. interface
  5. uses sysutils, classes, fpjson, restbase, odatabase, odataservice;
  6. (*
  7. Options used to generate:
  8. OData version : ODataV4
  9. BasecomplexType : TODataObject
  10. BaseEntityType : TODataEntity
  11. BaseEntityContainerType : TODataEntityContainer
  12. BaseServiceType : TODataService
  13. BaseEntitySetType : TODataEntitySet
  14. Aliases[0] : Microsoft.OData.SampleService.Models.TripPin=
  15. SchemaAncestor : TObject
  16. FieldPrefix : F
  17. ServiceSuffix :
  18. EnumerationMode : emScoped
  19. *)
  20. type
  21. // Needed for binary data
  22. TByteArray = Array of byte;
  23. TInt16Array = Array of SmallInt;
  24. //
  25. TCity = class;
  26. TCityArray = Array of TCity;
  27. TLocation = class;
  28. TLocationArray = Array of TLocation;
  29. TEventLocation = class;
  30. TEventLocationArray = Array of TEventLocation;
  31. TAirportLocation = class;
  32. TAirportLocationArray = Array of TAirportLocation;
  33. TPhoto = class;
  34. TPhotoArray = Array of TPhoto;
  35. TPerson = class;
  36. TPersonArray = Array of TPerson;
  37. TAirline = class;
  38. TAirlineArray = Array of TAirline;
  39. TAirport = class;
  40. TAirportArray = Array of TAirport;
  41. TPlanItem = class;
  42. TPlanItemArray = Array of TPlanItem;
  43. TPublicTransportation = class;
  44. TPublicTransportationArray = Array of TPublicTransportation;
  45. TFlight = class;
  46. TFlightArray = Array of TFlight;
  47. TEvent = class;
  48. TEventArray = Array of TEvent;
  49. TTrip = class;
  50. TTripArray = Array of TTrip;
  51. TDefaultContainer = class;
  52. TDefaultContainerArray = Array of TDefaultContainer;
  53. TPhotosEntitySet = class;
  54. TPhotosEntitySetArray = Array of TPhotosEntitySet;
  55. TPeopleEntitySet = class;
  56. TPeopleEntitySetArray = Array of TPeopleEntitySet;
  57. TAirlinesEntitySet = class;
  58. TAirlinesEntitySetArray = Array of TAirlinesEntitySet;
  59. TAirportsEntitySet = class;
  60. TAirportsEntitySetArray = Array of TAirportsEntitySet;
  61. TTripImplicitEntitySet = class;
  62. TTripImplicitEntitySetArray = Array of TTripImplicitEntitySet;
  63. TPlanItemImplicitEntitySet = class;
  64. TPlanItemImplicitEntitySetArray = Array of TPlanItemImplicitEntitySet;
  65. TService = class;
  66. TServiceArray = Array of TService;
  67. //
  68. // Enumerations
  69. {$SCOPEDENUMS ON}
  70. TPersonGender = (Male,Female,Unknown);
  71. TPersonGenderArray = Array of TPersonGender;
  72. { --------------------------------------------------------------------
  73. Microsoft.OData.SampleService.Models.TripPin: City
  74. --------------------------------------------------------------------}
  75. TCity = Class(TODataEntity)
  76. private
  77. FCountryRegion : string;
  78. FName : string;
  79. FRegion : string;
  80. procedure SetCountryRegion(AIndex: Integer; const AValue: string);
  81. procedure SetName(AIndex: Integer; const AValue: string);
  82. procedure SetRegion(AIndex: Integer; const AValue: string);
  83. public
  84. class function ObjectRestKind : String; Override;
  85. published
  86. Property CountryRegion : string index 0 read FCountryRegion write SetCountryRegion;
  87. Property Name : string index 8 read FName write SetName;
  88. Property Region : string index 16 read FRegion write SetRegion;
  89. end;
  90. { --------------------------------------------------------------------
  91. Microsoft.OData.SampleService.Models.TripPin: Location
  92. --------------------------------------------------------------------}
  93. TLocation = Class(TODataEntity)
  94. private
  95. FAddress : string;
  96. FCity : TCity;
  97. procedure SetAddress(AIndex: Integer; const AValue: string);
  98. procedure SetCity(AIndex: Integer; const AValue: TCity);
  99. public
  100. class function ObjectRestKind : String; Override;
  101. published
  102. Property Address : string index 0 read FAddress write SetAddress;
  103. Property City : TCity index 8 read FCity write SetCity;
  104. end;
  105. { --------------------------------------------------------------------
  106. Microsoft.OData.SampleService.Models.TripPin: EventLocation
  107. --------------------------------------------------------------------}
  108. TEventLocation = Class(TLocation)
  109. private
  110. FBuildingInfo : string;
  111. procedure SetBuildingInfo(AIndex: Integer; const AValue: string);
  112. public
  113. class function ObjectRestKind : String; Override;
  114. published
  115. Property BuildingInfo : string index 16 read FBuildingInfo write SetBuildingInfo;
  116. end;
  117. { --------------------------------------------------------------------
  118. Microsoft.OData.SampleService.Models.TripPin: AirportLocation
  119. --------------------------------------------------------------------}
  120. TAirportLocation = Class(TLocation)
  121. private
  122. FLoc : TGeographyPoint;
  123. procedure SetLoc(AIndex: Integer; const AValue: TGeographyPoint);
  124. public
  125. class function ObjectRestKind : String; Override;
  126. published
  127. Property Loc : TGeographyPoint index 16 read FLoc write SetLoc;
  128. end;
  129. { --------------------------------------------------------------------
  130. Microsoft.OData.SampleService.Models.TripPin: Photo
  131. --------------------------------------------------------------------}
  132. TPhoto = Class(TODataEntity)
  133. private
  134. FId : int64;
  135. FName : string;
  136. procedure SetId(AIndex: Integer; const AValue: int64);
  137. procedure SetName(AIndex: Integer; const AValue: string);
  138. public
  139. class function ObjectRestKind : String; Override;
  140. function KeyAsURLPart : String; Override;
  141. procedure GetStream(AService: TODataService; AContentType: String;
  142. AStream: TStream);
  143. procedure SetStream(AService: TODataService; AContentType: String;
  144. AStream: TStream);
  145. published
  146. Property Id : int64 index 0 read FId write SetId;
  147. Property Name : string index 8 read FName write SetName;
  148. end;
  149. { --------------------------------------------------------------------
  150. Microsoft.OData.SampleService.Models.TripPin: Person
  151. --------------------------------------------------------------------}
  152. TPerson = Class(TODataEntity)
  153. private
  154. FUserName : string;
  155. FFirstName : string;
  156. FLastName : string;
  157. FEmails : TStringArray;
  158. FAddressInfo : TLocationArray;
  159. FGender : TPersonGender;
  160. FConcurrency : int64;
  161. procedure SetUserName(AIndex: Integer; const AValue: string);
  162. procedure SetFirstName(AIndex: Integer; const AValue: string);
  163. procedure SetLastName(AIndex: Integer; const AValue: string);
  164. procedure SetEmails(AIndex: Integer; const AValue: TStringArray);
  165. procedure SetAddressInfo(AIndex: Integer; const AValue: TLocationArray);
  166. procedure SetGender(AIndex: Integer; const AValue: TPersonGender);
  167. procedure SetConcurrency(AIndex: Integer; const AValue: int64);
  168. protected
  169. {$IFDEF VER2_6}
  170. procedure SetArrayLength(const AName: String; ALength: Longint)
  171. ; Override;
  172. {$ENDIF VER2_6}
  173. public
  174. function GetFavoriteAirline(AService: TODataService) : TAirline;
  175. function GetFriendsTrips(AService: TODataService; userName: string)
  176. : TTripArray;
  177. procedure ShareTrip(AService: TODataService; userName: string;
  178. tripId: TInt32);
  179. class function ObjectRestKind : String; Override;
  180. function KeyAsURLPart : String; Override;
  181. function Friends(AService: TODataService) : TPeopleEntitySet;
  182. function Trips(AService: TODataService) : TTripImplicitEntitySet;
  183. function Photo(AService: TODataService) : TPhoto;
  184. published
  185. Property UserName : string index 0 read FUserName write SetUserName;
  186. Property FirstName : string index 8 read FFirstName write SetFirstName;
  187. Property LastName : string index 16 read FLastName write SetLastName;
  188. Property Emails : TStringArray index 24 read FEmails write SetEmails;
  189. Property AddressInfo : TLocationArray index 32 read FAddressInfo write SetAddressInfo;
  190. Property Gender : TPersonGender index 40 read FGender write SetGender;
  191. Property Concurrency : int64 index 48 read FConcurrency write SetConcurrency;
  192. end;
  193. { --------------------------------------------------------------------
  194. Microsoft.OData.SampleService.Models.TripPin: Airline
  195. --------------------------------------------------------------------}
  196. TAirline = Class(TODataEntity)
  197. private
  198. FAirlineCode : string;
  199. FName : string;
  200. procedure SetAirlineCode(AIndex: Integer; const AValue: string);
  201. procedure SetName(AIndex: Integer; const AValue: string);
  202. public
  203. class function ObjectRestKind : String; Override;
  204. function KeyAsURLPart : String; Override;
  205. published
  206. Property AirlineCode : string index 0 read FAirlineCode write SetAirlineCode;
  207. Property Name : string index 8 read FName write SetName;
  208. end;
  209. { --------------------------------------------------------------------
  210. Microsoft.OData.SampleService.Models.TripPin: Airport
  211. --------------------------------------------------------------------}
  212. TAirport = Class(TODataEntity)
  213. private
  214. FIcaoCode : string;
  215. FName : string;
  216. FIataCode : string;
  217. FLocation : TAirportLocation;
  218. procedure SetIcaoCode(AIndex: Integer; const AValue: string);
  219. procedure SetName(AIndex: Integer; const AValue: string);
  220. procedure SetIataCode(AIndex: Integer; const AValue: string);
  221. procedure SetLocation(AIndex: Integer; const AValue: TAirportLocation);
  222. public
  223. class function ObjectRestKind : String; Override;
  224. function KeyAsURLPart : String; Override;
  225. published
  226. Property IcaoCode : string index 0 read FIcaoCode write SetIcaoCode;
  227. Property Name : string index 8 read FName write SetName;
  228. Property IataCode : string index 16 read FIataCode write SetIataCode;
  229. Property Location : TAirportLocation index 24 read FLocation write SetLocation;
  230. end;
  231. { --------------------------------------------------------------------
  232. Microsoft.OData.SampleService.Models.TripPin: PlanItem
  233. --------------------------------------------------------------------}
  234. TPlanItem = Class(TODataEntity)
  235. private
  236. FPlanItemId : TInt32;
  237. FConfirmationCode : string;
  238. FStartsAt : TDateTime;
  239. FEndsAt : TDateTime;
  240. FDuration : TDuration;
  241. procedure SetPlanItemId(AIndex: Integer; const AValue: TInt32);
  242. procedure SetConfirmationCode(AIndex: Integer; const AValue: string);
  243. procedure SetStartsAt(AIndex: Integer; const AValue: TDateTime);
  244. procedure SetEndsAt(AIndex: Integer; const AValue: TDateTime);
  245. procedure SetDuration(AIndex: Integer; const AValue: TDuration);
  246. public
  247. class function ObjectRestKind : String; Override;
  248. function KeyAsURLPart : String; Override;
  249. published
  250. Property PlanItemId : TInt32 index 0 read FPlanItemId write SetPlanItemId;
  251. Property ConfirmationCode : string index 8 read FConfirmationCode write SetConfirmationCode;
  252. Property StartsAt : TDateTime index 16 read FStartsAt write SetStartsAt;
  253. Property EndsAt : TDateTime index 24 read FEndsAt write SetEndsAt;
  254. Property Duration : TDuration index 32 read FDuration write SetDuration;
  255. end;
  256. { --------------------------------------------------------------------
  257. Microsoft.OData.SampleService.Models.TripPin: PublicTransportation
  258. --------------------------------------------------------------------}
  259. TPublicTransportation = Class(TPlanItem)
  260. private
  261. FSeatNumber : string;
  262. procedure SetSeatNumber(AIndex: Integer; const AValue: string);
  263. public
  264. class function ObjectRestKind : String; Override;
  265. published
  266. Property SeatNumber : string index 40 read FSeatNumber write SetSeatNumber;
  267. end;
  268. { --------------------------------------------------------------------
  269. Microsoft.OData.SampleService.Models.TripPin: Flight
  270. --------------------------------------------------------------------}
  271. TFlight = Class(TPublicTransportation)
  272. private
  273. FFlightNumber : string;
  274. procedure SetFlightNumber(AIndex: Integer; const AValue: string);
  275. public
  276. class function ObjectRestKind : String; Override;
  277. function From(AService: TODataService) : TAirport;
  278. function _To(AService: TODataService) : TAirport;
  279. function Airline(AService: TODataService) : TAirline;
  280. published
  281. Property FlightNumber : string index 48 read FFlightNumber write SetFlightNumber;
  282. end;
  283. { --------------------------------------------------------------------
  284. Microsoft.OData.SampleService.Models.TripPin: Event
  285. --------------------------------------------------------------------}
  286. TEvent = Class(TPlanItem)
  287. private
  288. FDescription : string;
  289. FOccursAt : TEventLocation;
  290. procedure SetDescription(AIndex: Integer; const AValue: string);
  291. procedure SetOccursAt(AIndex: Integer; const AValue: TEventLocation);
  292. public
  293. class function ObjectRestKind : String; Override;
  294. published
  295. Property Description : string index 40 read FDescription write SetDescription;
  296. Property OccursAt : TEventLocation index 48 read FOccursAt write SetOccursAt;
  297. end;
  298. { --------------------------------------------------------------------
  299. Microsoft.OData.SampleService.Models.TripPin: Trip
  300. --------------------------------------------------------------------}
  301. TTrip = Class(TODataEntity)
  302. private
  303. FTripId : TInt32;
  304. FShareId : TGUIDString;
  305. FDescription : string;
  306. FName : string;
  307. FBudget : Single;
  308. FStartsAt : TDateTime;
  309. FEndsAt : TDateTime;
  310. FTags : TStringArray;
  311. procedure SetTripId(AIndex: Integer; const AValue: TInt32);
  312. procedure SetShareId(AIndex: Integer; const AValue: TGUIDString);
  313. procedure SetDescription(AIndex: Integer; const AValue: string);
  314. procedure SetName(AIndex: Integer; const AValue: string);
  315. procedure SetBudget(AIndex: Integer; const AValue: Single);
  316. procedure SetStartsAt(AIndex: Integer; const AValue: TDateTime);
  317. procedure SetEndsAt(AIndex: Integer; const AValue: TDateTime);
  318. procedure SetTags(AIndex: Integer; const AValue: TStringArray);
  319. protected
  320. {$IFDEF VER2_6}
  321. procedure SetArrayLength(const AName: String; ALength: Longint)
  322. ; Override;
  323. {$ENDIF VER2_6}
  324. public
  325. function GetInvolvedPeople(AService: TODataService) : TPersonArray;
  326. class function ObjectRestKind : String; Override;
  327. function KeyAsURLPart : String; Override;
  328. function Photos(AService: TODataService) : TPhotosEntitySet;
  329. function PlanItems(AService: TODataService) : TPlanItemImplicitEntitySet;
  330. published
  331. Property TripId : TInt32 index 0 read FTripId write SetTripId;
  332. Property ShareId : TGUIDString index 8 read FShareId write SetShareId;
  333. Property Description : string index 16 read FDescription write SetDescription;
  334. Property Name : string index 24 read FName write SetName;
  335. Property Budget : Single index 32 read FBudget write SetBudget;
  336. Property StartsAt : TDateTime index 40 read FStartsAt write SetStartsAt;
  337. Property EndsAt : TDateTime index 48 read FEndsAt write SetEndsAt;
  338. Property Tags : TStringArray index 56 read FTags write SetTags;
  339. end;
  340. { --------------------------------------------------------------------
  341. Microsoft.OData.SampleService.Models.TripPin: DefaultContainer
  342. --------------------------------------------------------------------}
  343. TDefaultContainer = Class(TODataEntityContainer)
  344. private
  345. FPhotos : TPhotosEntitySet;
  346. FPeople : TPeopleEntitySet;
  347. FAirlines : TAirlinesEntitySet;
  348. FAirports : TAirportsEntitySet;
  349. FMe : TPerson;
  350. function GetPhotos : TPhotosEntitySet;
  351. function GetPeople : TPeopleEntitySet;
  352. function GetAirlines : TAirlinesEntitySet;
  353. function GetAirports : TAirportsEntitySet;
  354. function GetMe : TPerson;
  355. public
  356. class function ObjectRestKind : String; Override;
  357. function CreateNewPhotos : TPhotosEntitySet;
  358. function CreateNewPeople : TPeopleEntitySet;
  359. function CreateNewAirlines : TAirlinesEntitySet;
  360. function CreateNewAirports : TAirportsEntitySet;
  361. function FetchMe : TPerson;
  362. procedure ResetDataSource;
  363. function GetNearestAirport(lat: Double; lon: Double) : TAirport;
  364. published
  365. Property Photos : TPhotosEntitySet read GetPhotos;
  366. Property People : TPeopleEntitySet read GetPeople;
  367. Property Airlines : TAirlinesEntitySet read GetAirlines;
  368. Property Airports : TAirportsEntitySet read GetAirports;
  369. Property Me : TPerson read GetMe;
  370. end;
  371. { --------------------------------------------------------------------
  372. Microsoft.OData.SampleService.Models.TripPin: Photos
  373. --------------------------------------------------------------------}
  374. TPhotosEntitySet = Class(TODataEntitySet)
  375. public
  376. class function ObjectRestKind : String; Override;
  377. class function EntityClass : TODataEntityClass; Override;
  378. function Get(const Id: int64) : TPhoto;
  379. function List(const AQuery: String; out NextLink: String) : TPhotoArray;
  380. function List(const AQuery: TQueryParams; out NextLink: String)
  381. : TPhotoArray;
  382. function ListAll(const AQuery: String) : TPhotoArray;
  383. function ListAll(const AQuery: TQueryParams) : TPhotoArray;
  384. end;
  385. { --------------------------------------------------------------------
  386. Microsoft.OData.SampleService.Models.TripPin: People
  387. --------------------------------------------------------------------}
  388. TPeopleEntitySet = Class(TODataEntitySet)
  389. public
  390. class function ObjectRestKind : String; Override;
  391. class function EntityClass : TODataEntityClass; Override;
  392. function Get(const UserName: string) : TPerson;
  393. function List(const AQuery: String; out NextLink: String) : TPersonArray;
  394. function List(const AQuery: TQueryParams; out NextLink: String)
  395. : TPersonArray;
  396. function ListAll(const AQuery: String) : TPersonArray;
  397. function ListAll(const AQuery: TQueryParams) : TPersonArray;
  398. end;
  399. { --------------------------------------------------------------------
  400. Microsoft.OData.SampleService.Models.TripPin: Airlines
  401. --------------------------------------------------------------------}
  402. TAirlinesEntitySet = Class(TODataEntitySet)
  403. public
  404. class function ObjectRestKind : String; Override;
  405. class function EntityClass : TODataEntityClass; Override;
  406. function Get(const AirlineCode: string) : TAirline;
  407. function List(const AQuery: String; out NextLink: String)
  408. : TAirlineArray;
  409. function List(const AQuery: TQueryParams; out NextLink: String)
  410. : TAirlineArray;
  411. function ListAll(const AQuery: String) : TAirlineArray;
  412. function ListAll(const AQuery: TQueryParams) : TAirlineArray;
  413. end;
  414. { --------------------------------------------------------------------
  415. Microsoft.OData.SampleService.Models.TripPin: Airports
  416. --------------------------------------------------------------------}
  417. TAirportsEntitySet = Class(TODataEntitySet)
  418. public
  419. class function ObjectRestKind : String; Override;
  420. class function EntityClass : TODataEntityClass; Override;
  421. function Get(const IcaoCode: string) : TAirport;
  422. function List(const AQuery: String; out NextLink: String)
  423. : TAirportArray;
  424. function List(const AQuery: TQueryParams; out NextLink: String)
  425. : TAirportArray;
  426. function ListAll(const AQuery: String) : TAirportArray;
  427. function ListAll(const AQuery: TQueryParams) : TAirportArray;
  428. end;
  429. { --------------------------------------------------------------------
  430. Microsoft.OData.SampleService.Models.TripPin: TripImplicitEntitySet
  431. --------------------------------------------------------------------}
  432. TTripImplicitEntitySet = Class(TODataEntitySet)
  433. public
  434. class function ObjectRestKind : String; Override;
  435. class function EntityClass : TODataEntityClass; Override;
  436. function Get(const TripId: TInt32) : TTrip;
  437. function List(const AQuery: String; out NextLink: String) : TTripArray;
  438. function List(const AQuery: TQueryParams; out NextLink: String)
  439. : TTripArray;
  440. function ListAll(const AQuery: String) : TTripArray;
  441. function ListAll(const AQuery: TQueryParams) : TTripArray;
  442. end;
  443. { --------------------------------------------------------------------
  444. Microsoft.OData.SampleService.Models.TripPin: PlanItemImplicitEntitySet
  445. --------------------------------------------------------------------}
  446. TPlanItemImplicitEntitySet = Class(TODataEntitySet)
  447. public
  448. class function ObjectRestKind : String; Override;
  449. class function EntityClass : TODataEntityClass; Override;
  450. function Get(const PlanItemId: TInt32) : TPlanItem;
  451. function List(const AQuery: String; out NextLink: String)
  452. : TPlanItemArray;
  453. function List(const AQuery: TQueryParams; out NextLink: String)
  454. : TPlanItemArray;
  455. function ListAll(const AQuery: String) : TPlanItemArray;
  456. function ListAll(const AQuery: TQueryParams) : TPlanItemArray;
  457. end;
  458. { --------------------------------------------------------------------
  459. Microsoft.OData.SampleService.Models.TripPin: Microsoft.OData.SampleService.Models.TripPin
  460. --------------------------------------------------------------------}
  461. TService = Class(TODataService)
  462. private
  463. FDefaultContainer : TDefaultContainer;
  464. function GetDefaultContainer : TDefaultContainer;
  465. public
  466. class function ObjectRestKind : String; Override;
  467. function CreateNewDefaultContainer : TDefaultContainer;
  468. published
  469. Property DefaultContainer : TDefaultContainer read GetDefaultContainer;
  470. end;
  471. implementation
  472. { --------------------------------------------------------------------
  473. TCity
  474. --------------------------------------------------------------------}
  475. Class Function TCity.ObjectRestKind : String;
  476. begin
  477. Result:='City';
  478. end;
  479. Procedure TCity.SetCountryRegion(AIndex: Integer; const AValue: string);
  480. begin
  481. If (FCountryRegion=AValue) then exit;
  482. FCountryRegion:=AValue;
  483. MarkPropertyChanged(AIndex);
  484. end;
  485. Procedure TCity.SetName(AIndex: Integer; const AValue: string);
  486. begin
  487. If (FName=AValue) then exit;
  488. FName:=AValue;
  489. MarkPropertyChanged(AIndex);
  490. end;
  491. Procedure TCity.SetRegion(AIndex: Integer; const AValue: string);
  492. begin
  493. If (FRegion=AValue) then exit;
  494. FRegion:=AValue;
  495. MarkPropertyChanged(AIndex);
  496. end;
  497. { --------------------------------------------------------------------
  498. TLocation
  499. --------------------------------------------------------------------}
  500. Class Function TLocation.ObjectRestKind : String;
  501. begin
  502. Result:='Location';
  503. end;
  504. Procedure TLocation.SetAddress(AIndex: Integer; const AValue: string);
  505. begin
  506. If (FAddress=AValue) then exit;
  507. FAddress:=AValue;
  508. MarkPropertyChanged(AIndex);
  509. end;
  510. Procedure TLocation.SetCity(AIndex: Integer; const AValue: TCity);
  511. begin
  512. If (FCity=AValue) then exit;
  513. FCity:=AValue;
  514. MarkPropertyChanged(AIndex);
  515. end;
  516. { --------------------------------------------------------------------
  517. TEventLocation
  518. --------------------------------------------------------------------}
  519. Class Function TEventLocation.ObjectRestKind : String;
  520. begin
  521. Result:='EventLocation';
  522. end;
  523. Procedure TEventLocation.SetBuildingInfo(AIndex: Integer; const AValue: string);
  524. begin
  525. If (FBuildingInfo=AValue) then exit;
  526. FBuildingInfo:=AValue;
  527. MarkPropertyChanged(AIndex);
  528. end;
  529. { --------------------------------------------------------------------
  530. TAirportLocation
  531. --------------------------------------------------------------------}
  532. Class Function TAirportLocation.ObjectRestKind : String;
  533. begin
  534. Result:='AirportLocation';
  535. end;
  536. Procedure TAirportLocation.SetLoc(AIndex: Integer; const AValue: TGeographyPoint);
  537. begin
  538. If (FLoc=AValue) then exit;
  539. FLoc:=AValue;
  540. MarkPropertyChanged(AIndex);
  541. end;
  542. { --------------------------------------------------------------------
  543. TPhoto
  544. --------------------------------------------------------------------}
  545. Class Function TPhoto.ObjectRestKind : String;
  546. begin
  547. Result:='Photo';
  548. end;
  549. Procedure TPhoto.SetId(AIndex: Integer; const AValue: int64);
  550. begin
  551. If (FId=AValue) then exit;
  552. FId:=AValue;
  553. MarkPropertyChanged(AIndex);
  554. end;
  555. Procedure TPhoto.SetName(AIndex: Integer; const AValue: string);
  556. begin
  557. If (FName=AValue) then exit;
  558. FName:=AValue;
  559. MarkPropertyChanged(AIndex);
  560. end;
  561. Function TPhoto.KeyAsURLPart : string;
  562. begin
  563. Result:=IntToStr(Id);
  564. end;
  565. Procedure TPhoto.GetStream(AService: TODataService; AContentType: String; AStream: TStream);
  566. begin
  567. DoGetStream(AService,AContentType,AStream);
  568. end;
  569. Procedure TPhoto.SetStream(AService: TODataService; AContentType: String; AStream: TStream);
  570. begin
  571. DoSetStream(AService,AContentType,AStream);
  572. end;
  573. { --------------------------------------------------------------------
  574. TPerson
  575. --------------------------------------------------------------------}
  576. Function TPerson.GetFavoriteAirline(AService: TODataService) : TAirline;
  577. Var
  578. _Res : String;
  579. _Path : String;
  580. begin
  581. _Path:='('+_Path+')';
  582. _Path:='Microsoft.OData.SampleService.Models.TripPin.GetFavoriteAirline'+_Path;
  583. _Path:=BaseURL(AService)+'/'+_Path;
  584. Result:=TAirline(AService.SingleServiceCall(_Path,'',TAirline));
  585. end;
  586. Function TPerson.GetFriendsTrips(AService: TODataService; userName: string) : TTripArray;
  587. Var
  588. _Res : String;
  589. _Path : String;
  590. begin
  591. _Path:='userName='+TODataObject.MakeKeyString(userName);
  592. _Path:='('+_Path+')';
  593. _Path:='Microsoft.OData.SampleService.Models.TripPin.GetFriendsTrips'+_Path;
  594. _Path:=BaseURL(AService)+'/'+_Path;
  595. Result:=TTripArray(AService.GetMulti(_Path,'',TTrip,True,_Res));
  596. end;
  597. Procedure TPerson.ShareTrip(AService: TODataService; userName: string; tripId: TInt32);
  598. Var
  599. _JSON : TJSONObject;
  600. _data : String;
  601. _Path : String;
  602. begin
  603. _JSON:=TJSONObject.Create;
  604. try
  605. _JSON.Add('userName',userName);
  606. _JSON.Add('tripId',tripId);
  607. _data:=_JSON.AsJSON;
  608. finally
  609. FreeAndNil(_JSON);
  610. end;
  611. _Path:=BaseURL(AService)+'/Microsoft.OData.SampleService.Models.TripPin.ShareTrip';
  612. AService.ServiceCall('POST',_Path,'',_Data);
  613. end;
  614. Class Function TPerson.ObjectRestKind : String;
  615. begin
  616. Result:='Person';
  617. end;
  618. Procedure TPerson.SetUserName(AIndex: Integer; const AValue: string);
  619. begin
  620. If (FUserName=AValue) then exit;
  621. FUserName:=AValue;
  622. MarkPropertyChanged(AIndex);
  623. end;
  624. Procedure TPerson.SetFirstName(AIndex: Integer; const AValue: string);
  625. begin
  626. If (FFirstName=AValue) then exit;
  627. FFirstName:=AValue;
  628. MarkPropertyChanged(AIndex);
  629. end;
  630. Procedure TPerson.SetLastName(AIndex: Integer; const AValue: string);
  631. begin
  632. If (FLastName=AValue) then exit;
  633. FLastName:=AValue;
  634. MarkPropertyChanged(AIndex);
  635. end;
  636. Procedure TPerson.SetEmails(AIndex: Integer; const AValue: TStringArray);
  637. begin
  638. If (FEmails=AValue) then exit;
  639. FEmails:=AValue;
  640. MarkPropertyChanged(AIndex);
  641. end;
  642. Procedure TPerson.SetAddressInfo(AIndex: Integer; const AValue: TLocationArray);
  643. begin
  644. If (FAddressInfo=AValue) then exit;
  645. FAddressInfo:=AValue;
  646. MarkPropertyChanged(AIndex);
  647. end;
  648. Procedure TPerson.SetGender(AIndex: Integer; const AValue: TPersonGender);
  649. begin
  650. If (FGender=AValue) then exit;
  651. FGender:=AValue;
  652. MarkPropertyChanged(AIndex);
  653. end;
  654. Procedure TPerson.SetConcurrency(AIndex: Integer; const AValue: int64);
  655. begin
  656. If (FConcurrency=AValue) then exit;
  657. FConcurrency:=AValue;
  658. MarkPropertyChanged(AIndex);
  659. end;
  660. {$IFDEF VER2_6}
  661. Procedure TPerson.SetArrayLength(const AName: String; ALength: Longint);
  662. begin
  663. Case aName of
  664. 'emails' : SetLength(FEmails,aLength);
  665. 'addressinfo' : SetLength(FAddressInfo,aLength);
  666. else
  667. inherited SetArrayLength(aName,ALength);
  668. end;
  669. end;
  670. {$ENDIF VER2_6}
  671. Function TPerson.KeyAsURLPart : string;
  672. begin
  673. Result:=TODataObject.MakeKeyString(UserName);
  674. end;
  675. Function TPerson.Friends(AService: TODataService) : TPeopleEntitySet;
  676. begin
  677. Result:=TPeopleEntitySet(CreateContainedEntitySet(AService,'Friends', TPeopleEntitySet));
  678. end;
  679. Function TPerson.Trips(AService: TODataService) : TTripImplicitEntitySet;
  680. begin
  681. Result:=TTripImplicitEntitySet(CreateContainedEntitySet(AService,'Trips', TTripImplicitEntitySet));
  682. end;
  683. Function TPerson.Photo(AService: TODataService) : TPhoto;
  684. begin
  685. Result:=TPhoto(GetContainedSingleTon(AService,'Photo', TPhoto));
  686. end;
  687. { --------------------------------------------------------------------
  688. TAirline
  689. --------------------------------------------------------------------}
  690. Class Function TAirline.ObjectRestKind : String;
  691. begin
  692. Result:='Airline';
  693. end;
  694. Procedure TAirline.SetAirlineCode(AIndex: Integer; const AValue: string);
  695. begin
  696. If (FAirlineCode=AValue) then exit;
  697. FAirlineCode:=AValue;
  698. MarkPropertyChanged(AIndex);
  699. end;
  700. Procedure TAirline.SetName(AIndex: Integer; const AValue: string);
  701. begin
  702. If (FName=AValue) then exit;
  703. FName:=AValue;
  704. MarkPropertyChanged(AIndex);
  705. end;
  706. Function TAirline.KeyAsURLPart : string;
  707. begin
  708. Result:=TODataObject.MakeKeyString(AirlineCode);
  709. end;
  710. { --------------------------------------------------------------------
  711. TAirport
  712. --------------------------------------------------------------------}
  713. Class Function TAirport.ObjectRestKind : String;
  714. begin
  715. Result:='Airport';
  716. end;
  717. Procedure TAirport.SetIcaoCode(AIndex: Integer; const AValue: string);
  718. begin
  719. If (FIcaoCode=AValue) then exit;
  720. FIcaoCode:=AValue;
  721. MarkPropertyChanged(AIndex);
  722. end;
  723. Procedure TAirport.SetName(AIndex: Integer; const AValue: string);
  724. begin
  725. If (FName=AValue) then exit;
  726. FName:=AValue;
  727. MarkPropertyChanged(AIndex);
  728. end;
  729. Procedure TAirport.SetIataCode(AIndex: Integer; const AValue: string);
  730. begin
  731. If (FIataCode=AValue) then exit;
  732. FIataCode:=AValue;
  733. MarkPropertyChanged(AIndex);
  734. end;
  735. Procedure TAirport.SetLocation(AIndex: Integer; const AValue: TAirportLocation);
  736. begin
  737. If (FLocation=AValue) then exit;
  738. FLocation:=AValue;
  739. MarkPropertyChanged(AIndex);
  740. end;
  741. Function TAirport.KeyAsURLPart : string;
  742. begin
  743. Result:=TODataObject.MakeKeyString(IcaoCode);
  744. end;
  745. { --------------------------------------------------------------------
  746. TPlanItem
  747. --------------------------------------------------------------------}
  748. Class Function TPlanItem.ObjectRestKind : String;
  749. begin
  750. Result:='PlanItem';
  751. end;
  752. Procedure TPlanItem.SetPlanItemId(AIndex: Integer; const AValue: TInt32);
  753. begin
  754. If (FPlanItemId=AValue) then exit;
  755. FPlanItemId:=AValue;
  756. MarkPropertyChanged(AIndex);
  757. end;
  758. Procedure TPlanItem.SetConfirmationCode(AIndex: Integer; const AValue: string);
  759. begin
  760. If (FConfirmationCode=AValue) then exit;
  761. FConfirmationCode:=AValue;
  762. MarkPropertyChanged(AIndex);
  763. end;
  764. Procedure TPlanItem.SetStartsAt(AIndex: Integer; const AValue: TDateTime);
  765. begin
  766. If (FStartsAt=AValue) then exit;
  767. FStartsAt:=AValue;
  768. MarkPropertyChanged(AIndex);
  769. end;
  770. Procedure TPlanItem.SetEndsAt(AIndex: Integer; const AValue: TDateTime);
  771. begin
  772. If (FEndsAt=AValue) then exit;
  773. FEndsAt:=AValue;
  774. MarkPropertyChanged(AIndex);
  775. end;
  776. Procedure TPlanItem.SetDuration(AIndex: Integer; const AValue: TDuration);
  777. begin
  778. If (FDuration=AValue) then exit;
  779. FDuration:=AValue;
  780. MarkPropertyChanged(AIndex);
  781. end;
  782. Function TPlanItem.KeyAsURLPart : string;
  783. begin
  784. Result:=IntToStr(PlanItemId);
  785. end;
  786. { --------------------------------------------------------------------
  787. TPublicTransportation
  788. --------------------------------------------------------------------}
  789. Class Function TPublicTransportation.ObjectRestKind : String;
  790. begin
  791. Result:='PublicTransportation';
  792. end;
  793. Procedure TPublicTransportation.SetSeatNumber(AIndex: Integer; const AValue: string);
  794. begin
  795. If (FSeatNumber=AValue) then exit;
  796. FSeatNumber:=AValue;
  797. MarkPropertyChanged(AIndex);
  798. end;
  799. { --------------------------------------------------------------------
  800. TFlight
  801. --------------------------------------------------------------------}
  802. Class Function TFlight.ObjectRestKind : String;
  803. begin
  804. Result:='Flight';
  805. end;
  806. Procedure TFlight.SetFlightNumber(AIndex: Integer; const AValue: string);
  807. begin
  808. If (FFlightNumber=AValue) then exit;
  809. FFlightNumber:=AValue;
  810. MarkPropertyChanged(AIndex);
  811. end;
  812. Function TFlight.From(AService: TODataService) : TAirport;
  813. begin
  814. Result:=TAirport(GetContainedSingleTon(AService,'From', TAirport));
  815. end;
  816. Function TFlight._To(AService: TODataService) : TAirport;
  817. begin
  818. Result:=TAirport(GetContainedSingleTon(AService,'To', TAirport));
  819. end;
  820. Function TFlight.Airline(AService: TODataService) : TAirline;
  821. begin
  822. Result:=TAirline(GetContainedSingleTon(AService,'Airline', TAirline));
  823. end;
  824. { --------------------------------------------------------------------
  825. TEvent
  826. --------------------------------------------------------------------}
  827. Class Function TEvent.ObjectRestKind : String;
  828. begin
  829. Result:='Event';
  830. end;
  831. Procedure TEvent.SetDescription(AIndex: Integer; const AValue: string);
  832. begin
  833. If (FDescription=AValue) then exit;
  834. FDescription:=AValue;
  835. MarkPropertyChanged(AIndex);
  836. end;
  837. Procedure TEvent.SetOccursAt(AIndex: Integer; const AValue: TEventLocation);
  838. begin
  839. If (FOccursAt=AValue) then exit;
  840. FOccursAt:=AValue;
  841. MarkPropertyChanged(AIndex);
  842. end;
  843. { --------------------------------------------------------------------
  844. TTrip
  845. --------------------------------------------------------------------}
  846. Function TTrip.GetInvolvedPeople(AService: TODataService) : TPersonArray;
  847. Var
  848. _Res : String;
  849. _Path : String;
  850. begin
  851. _Path:='('+_Path+')';
  852. _Path:='Microsoft.OData.SampleService.Models.TripPin.GetInvolvedPeople'+_Path;
  853. _Path:=BaseURL(AService)+'/'+_Path;
  854. Result:=TPersonArray(AService.GetMulti(_Path,'',TPerson,True,_Res));
  855. end;
  856. Class Function TTrip.ObjectRestKind : String;
  857. begin
  858. Result:='Trip';
  859. end;
  860. Procedure TTrip.SetTripId(AIndex: Integer; const AValue: TInt32);
  861. begin
  862. If (FTripId=AValue) then exit;
  863. FTripId:=AValue;
  864. MarkPropertyChanged(AIndex);
  865. end;
  866. Procedure TTrip.SetShareId(AIndex: Integer; const AValue: TGUIDString);
  867. begin
  868. If (FShareId=AValue) then exit;
  869. FShareId:=AValue;
  870. MarkPropertyChanged(AIndex);
  871. end;
  872. Procedure TTrip.SetDescription(AIndex: Integer; const AValue: string);
  873. begin
  874. If (FDescription=AValue) then exit;
  875. FDescription:=AValue;
  876. MarkPropertyChanged(AIndex);
  877. end;
  878. Procedure TTrip.SetName(AIndex: Integer; const AValue: string);
  879. begin
  880. If (FName=AValue) then exit;
  881. FName:=AValue;
  882. MarkPropertyChanged(AIndex);
  883. end;
  884. Procedure TTrip.SetBudget(AIndex: Integer; const AValue: Single);
  885. begin
  886. If (FBudget=AValue) then exit;
  887. FBudget:=AValue;
  888. MarkPropertyChanged(AIndex);
  889. end;
  890. Procedure TTrip.SetStartsAt(AIndex: Integer; const AValue: TDateTime);
  891. begin
  892. If (FStartsAt=AValue) then exit;
  893. FStartsAt:=AValue;
  894. MarkPropertyChanged(AIndex);
  895. end;
  896. Procedure TTrip.SetEndsAt(AIndex: Integer; const AValue: TDateTime);
  897. begin
  898. If (FEndsAt=AValue) then exit;
  899. FEndsAt:=AValue;
  900. MarkPropertyChanged(AIndex);
  901. end;
  902. Procedure TTrip.SetTags(AIndex: Integer; const AValue: TStringArray);
  903. begin
  904. If (FTags=AValue) then exit;
  905. FTags:=AValue;
  906. MarkPropertyChanged(AIndex);
  907. end;
  908. {$IFDEF VER2_6}
  909. Procedure TTrip.SetArrayLength(const AName: String; ALength: Longint);
  910. begin
  911. Case aName of
  912. 'tags' : SetLength(FTags,aLength);
  913. else
  914. inherited SetArrayLength(aName,ALength);
  915. end;
  916. end;
  917. {$ENDIF VER2_6}
  918. Function TTrip.KeyAsURLPart : string;
  919. begin
  920. Result:=IntToStr(TripId);
  921. end;
  922. Function TTrip.Photos(AService: TODataService) : TPhotosEntitySet;
  923. begin
  924. Result:=TPhotosEntitySet(CreateContainedEntitySet(AService,'Photos', TPhotosEntitySet));
  925. end;
  926. Function TTrip.PlanItems(AService: TODataService) : TPlanItemImplicitEntitySet;
  927. begin
  928. Result:=TPlanItemImplicitEntitySet(CreateContainedEntitySet(AService,'PlanItems', TPlanItemImplicitEntitySet));
  929. end;
  930. { --------------------------------------------------------------------
  931. TDefaultContainer
  932. --------------------------------------------------------------------}
  933. Class Function TDefaultContainer.ObjectRestKind : String;
  934. begin
  935. Result:='DefaultContainer';
  936. end;
  937. Function TDefaultContainer.CreateNewPhotos : TPhotosEntitySet;
  938. begin
  939. Result:=TPhotosEntitySet(CreateEntitySet(TPhotosEntitySet));
  940. end;
  941. Function TDefaultContainer.GetPhotos : TPhotosEntitySet;
  942. begin
  943. If Not Assigned(FPhotos) then
  944. FPhotos:=TPhotosEntitySet(CreateEntitySet(TPhotosEntitySet));
  945. Result:=FPhotos;
  946. end;
  947. Function TDefaultContainer.CreateNewPeople : TPeopleEntitySet;
  948. begin
  949. Result:=TPeopleEntitySet(CreateEntitySet(TPeopleEntitySet));
  950. end;
  951. Function TDefaultContainer.GetPeople : TPeopleEntitySet;
  952. begin
  953. If Not Assigned(FPeople) then
  954. FPeople:=TPeopleEntitySet(CreateEntitySet(TPeopleEntitySet));
  955. Result:=FPeople;
  956. end;
  957. Function TDefaultContainer.CreateNewAirlines : TAirlinesEntitySet;
  958. begin
  959. Result:=TAirlinesEntitySet(CreateEntitySet(TAirlinesEntitySet));
  960. end;
  961. Function TDefaultContainer.GetAirlines : TAirlinesEntitySet;
  962. begin
  963. If Not Assigned(FAirlines) then
  964. FAirlines:=TAirlinesEntitySet(CreateEntitySet(TAirlinesEntitySet));
  965. Result:=FAirlines;
  966. end;
  967. Function TDefaultContainer.CreateNewAirports : TAirportsEntitySet;
  968. begin
  969. Result:=TAirportsEntitySet(CreateEntitySet(TAirportsEntitySet));
  970. end;
  971. Function TDefaultContainer.GetAirports : TAirportsEntitySet;
  972. begin
  973. If Not Assigned(FAirports) then
  974. FAirports:=TAirportsEntitySet(CreateEntitySet(TAirportsEntitySet));
  975. Result:=FAirports;
  976. end;
  977. Function TDefaultContainer.FetchMe : TPerson;
  978. begin
  979. CheckService;
  980. Result:=TPerson(Service.SingleServiceCall('Me','',TPerson));
  981. Result.BasePath:='Me';
  982. end;
  983. Function TDefaultContainer.GetMe : TPerson;
  984. begin
  985. If Not Assigned(FMe) then
  986. FMe:=FetchMe;
  987. Result:=FMe;
  988. end;
  989. Procedure TDefaultContainer.ResetDataSource;
  990. Var
  991. _data : String;
  992. _Path : String;
  993. begin
  994. CheckService;
  995. _data:='';
  996. _Path:='/ResetDataSource';
  997. Service.ServiceCall('POST',_Path,'',_Data);
  998. end;
  999. Function TDefaultContainer.GetNearestAirport(lat: Double; lon: Double) : TAirport;
  1000. Var
  1001. _Res : String;
  1002. _Path : String;
  1003. begin
  1004. CheckService;
  1005. _Path:='lat='+FloatToStr(lat);
  1006. _Path:=_Path+','+'lon='+FloatToStr(lon);
  1007. _Path:='('+_Path+')';
  1008. _Path:='GetNearestAirport'+_Path;
  1009. Result:=TAirport(Service.SingleServiceCall(_Path,'',TAirport));
  1010. end;
  1011. { --------------------------------------------------------------------
  1012. TPhotosEntitySet
  1013. --------------------------------------------------------------------}
  1014. Class Function TPhotosEntitySet.ObjectRestKind : String;
  1015. begin
  1016. Result:='Photos';
  1017. end;
  1018. Class Function TPhotosEntitySet.EntityClass : TODataEntityClass;
  1019. begin
  1020. Result:=TPhoto;
  1021. end;
  1022. Function TPhotosEntitySet.Get(const Id: int64) : TPhoto;
  1023. begin
  1024. Result:=TPhoto(GetSingle(IntToStr(Id)));
  1025. end;
  1026. Function TPhotosEntitySet.List(const AQuery: String; out NextLink: String) : TPhotoArray;
  1027. begin
  1028. Result:=TPhotoArray(GetMulti(AQuery,False,NextLink));
  1029. end;
  1030. Function TPhotosEntitySet.List(const AQuery: TQueryParams; out NextLink: String) : TPhotoArray;
  1031. begin
  1032. Result:=TPhotoArray(GetMulti(AQuery,False,NextLink));
  1033. end;
  1034. Function TPhotosEntitySet.ListAll(const AQuery: String) : TPhotoArray;
  1035. var N : String;
  1036. begin
  1037. Result:=TPhotoArray(GetMulti(AQuery,True,N));
  1038. end;
  1039. Function TPhotosEntitySet.ListAll(const AQuery: TQueryParams) : TPhotoArray;
  1040. var N : String;
  1041. begin
  1042. Result:=TPhotoArray(GetMulti(AQuery,True,N));
  1043. end;
  1044. { --------------------------------------------------------------------
  1045. TPeopleEntitySet
  1046. --------------------------------------------------------------------}
  1047. Class Function TPeopleEntitySet.ObjectRestKind : String;
  1048. begin
  1049. Result:='People';
  1050. end;
  1051. Class Function TPeopleEntitySet.EntityClass : TODataEntityClass;
  1052. begin
  1053. Result:=TPerson;
  1054. end;
  1055. Function TPeopleEntitySet.Get(const UserName: string) : TPerson;
  1056. begin
  1057. Result:=TPerson(GetSingle(TODataObject.MakeKeyString(UserName)));
  1058. end;
  1059. Function TPeopleEntitySet.List(const AQuery: String; out NextLink: String) : TPersonArray;
  1060. begin
  1061. Result:=TPersonArray(GetMulti(AQuery,False,NextLink));
  1062. end;
  1063. Function TPeopleEntitySet.List(const AQuery: TQueryParams; out NextLink: String) : TPersonArray;
  1064. begin
  1065. Result:=TPersonArray(GetMulti(AQuery,False,NextLink));
  1066. end;
  1067. Function TPeopleEntitySet.ListAll(const AQuery: String) : TPersonArray;
  1068. var N : String;
  1069. begin
  1070. Result:=TPersonArray(GetMulti(AQuery,True,N));
  1071. end;
  1072. Function TPeopleEntitySet.ListAll(const AQuery: TQueryParams) : TPersonArray;
  1073. var N : String;
  1074. begin
  1075. Result:=TPersonArray(GetMulti(AQuery,True,N));
  1076. end;
  1077. { --------------------------------------------------------------------
  1078. TAirlinesEntitySet
  1079. --------------------------------------------------------------------}
  1080. Class Function TAirlinesEntitySet.ObjectRestKind : String;
  1081. begin
  1082. Result:='Airlines';
  1083. end;
  1084. Class Function TAirlinesEntitySet.EntityClass : TODataEntityClass;
  1085. begin
  1086. Result:=TAirline;
  1087. end;
  1088. Function TAirlinesEntitySet.Get(const AirlineCode: string) : TAirline;
  1089. begin
  1090. Result:=TAirline(GetSingle(TODataObject.MakeKeyString(AirlineCode)));
  1091. end;
  1092. Function TAirlinesEntitySet.List(const AQuery: String; out NextLink: String) : TAirlineArray;
  1093. begin
  1094. Result:=TAirlineArray(GetMulti(AQuery,False,NextLink));
  1095. end;
  1096. Function TAirlinesEntitySet.List(const AQuery: TQueryParams; out NextLink: String) : TAirlineArray;
  1097. begin
  1098. Result:=TAirlineArray(GetMulti(AQuery,False,NextLink));
  1099. end;
  1100. Function TAirlinesEntitySet.ListAll(const AQuery: String) : TAirlineArray;
  1101. var N : String;
  1102. begin
  1103. Result:=TAirlineArray(GetMulti(AQuery,True,N));
  1104. end;
  1105. Function TAirlinesEntitySet.ListAll(const AQuery: TQueryParams) : TAirlineArray;
  1106. var N : String;
  1107. begin
  1108. Result:=TAirlineArray(GetMulti(AQuery,True,N));
  1109. end;
  1110. { --------------------------------------------------------------------
  1111. TAirportsEntitySet
  1112. --------------------------------------------------------------------}
  1113. Class Function TAirportsEntitySet.ObjectRestKind : String;
  1114. begin
  1115. Result:='Airports';
  1116. end;
  1117. Class Function TAirportsEntitySet.EntityClass : TODataEntityClass;
  1118. begin
  1119. Result:=TAirport;
  1120. end;
  1121. Function TAirportsEntitySet.Get(const IcaoCode: string) : TAirport;
  1122. begin
  1123. Result:=TAirport(GetSingle(TODataObject.MakeKeyString(IcaoCode)));
  1124. end;
  1125. Function TAirportsEntitySet.List(const AQuery: String; out NextLink: String) : TAirportArray;
  1126. begin
  1127. Result:=TAirportArray(GetMulti(AQuery,False,NextLink));
  1128. end;
  1129. Function TAirportsEntitySet.List(const AQuery: TQueryParams; out NextLink: String) : TAirportArray;
  1130. begin
  1131. Result:=TAirportArray(GetMulti(AQuery,False,NextLink));
  1132. end;
  1133. Function TAirportsEntitySet.ListAll(const AQuery: String) : TAirportArray;
  1134. var N : String;
  1135. begin
  1136. Result:=TAirportArray(GetMulti(AQuery,True,N));
  1137. end;
  1138. Function TAirportsEntitySet.ListAll(const AQuery: TQueryParams) : TAirportArray;
  1139. var N : String;
  1140. begin
  1141. Result:=TAirportArray(GetMulti(AQuery,True,N));
  1142. end;
  1143. { --------------------------------------------------------------------
  1144. TTripImplicitEntitySet
  1145. --------------------------------------------------------------------}
  1146. Class Function TTripImplicitEntitySet.ObjectRestKind : String;
  1147. begin
  1148. Result:='TripImplicitEntitySet';
  1149. end;
  1150. Class Function TTripImplicitEntitySet.EntityClass : TODataEntityClass;
  1151. begin
  1152. Result:=TTrip;
  1153. end;
  1154. Function TTripImplicitEntitySet.Get(const TripId: TInt32) : TTrip;
  1155. begin
  1156. Result:=TTrip(GetSingle(IntToStr(TripId)));
  1157. end;
  1158. Function TTripImplicitEntitySet.List(const AQuery: String; out NextLink: String) : TTripArray;
  1159. begin
  1160. Result:=TTripArray(GetMulti(AQuery,False,NextLink));
  1161. end;
  1162. Function TTripImplicitEntitySet.List(const AQuery: TQueryParams; out NextLink: String) : TTripArray;
  1163. begin
  1164. Result:=TTripArray(GetMulti(AQuery,False,NextLink));
  1165. end;
  1166. Function TTripImplicitEntitySet.ListAll(const AQuery: String) : TTripArray;
  1167. var N : String;
  1168. begin
  1169. Result:=TTripArray(GetMulti(AQuery,True,N));
  1170. end;
  1171. Function TTripImplicitEntitySet.ListAll(const AQuery: TQueryParams) : TTripArray;
  1172. var N : String;
  1173. begin
  1174. Result:=TTripArray(GetMulti(AQuery,True,N));
  1175. end;
  1176. { --------------------------------------------------------------------
  1177. TPlanItemImplicitEntitySet
  1178. --------------------------------------------------------------------}
  1179. Class Function TPlanItemImplicitEntitySet.ObjectRestKind : String;
  1180. begin
  1181. Result:='PlanItemImplicitEntitySet';
  1182. end;
  1183. Class Function TPlanItemImplicitEntitySet.EntityClass : TODataEntityClass;
  1184. begin
  1185. Result:=TPlanItem;
  1186. end;
  1187. Function TPlanItemImplicitEntitySet.Get(const PlanItemId: TInt32) : TPlanItem;
  1188. begin
  1189. Result:=TPlanItem(GetSingle(IntToStr(PlanItemId)));
  1190. end;
  1191. Function TPlanItemImplicitEntitySet.List(const AQuery: String; out NextLink: String) : TPlanItemArray;
  1192. begin
  1193. Result:=TPlanItemArray(GetMulti(AQuery,False,NextLink));
  1194. end;
  1195. Function TPlanItemImplicitEntitySet.List(const AQuery: TQueryParams; out NextLink: String) : TPlanItemArray;
  1196. begin
  1197. Result:=TPlanItemArray(GetMulti(AQuery,False,NextLink));
  1198. end;
  1199. Function TPlanItemImplicitEntitySet.ListAll(const AQuery: String) : TPlanItemArray;
  1200. var N : String;
  1201. begin
  1202. Result:=TPlanItemArray(GetMulti(AQuery,True,N));
  1203. end;
  1204. Function TPlanItemImplicitEntitySet.ListAll(const AQuery: TQueryParams) : TPlanItemArray;
  1205. var N : String;
  1206. begin
  1207. Result:=TPlanItemArray(GetMulti(AQuery,True,N));
  1208. end;
  1209. { --------------------------------------------------------------------
  1210. TService
  1211. --------------------------------------------------------------------}
  1212. Class Function TService.ObjectRestKind : String;
  1213. begin
  1214. Result:='Microsoft.OData.SampleService.Models.TripPin';
  1215. end;
  1216. Function TService.CreateNewDefaultContainer : TDefaultContainer;
  1217. begin
  1218. Result:=TDefaultContainer(CreateEntityContainer(TDefaultContainer));
  1219. end;
  1220. Function TService.GetDefaultContainer : TDefaultContainer;
  1221. begin
  1222. If Not Assigned(FDefaultContainer) then
  1223. FDefaultContainer:=TDefaultContainer(CreateEntityContainer(TDefaultContainer));
  1224. Result:=FDefaultContainer;
  1225. end;
  1226. end.