Skip to content

Commit

Permalink
Merge pull request #476 from noi-techpark/main
Browse files Browse the repository at this point in the history
latest changes availabilitysearch and tags
  • Loading branch information
RudiThoeni authored Dec 5, 2024
2 parents 49d94a0 + 6a9fec7 commit 995e198
Show file tree
Hide file tree
Showing 15 changed files with 139 additions and 50 deletions.
8 changes: 1 addition & 7 deletions Helper/Generic/MetaInfoHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,7 @@ public static Metadata GetMetadataforOdhTag(ODHTagLinked data)

public static Metadata GetMetadataforTag(TagLinked data)
{
string sourcemeta = data.Source.ToLower();

if (data.Types != null && data.Types.Contains("LTSCategory"))
sourcemeta = "lts";
else if (data.Types != null && (data.Types.Contains("IDMRedactionalCategory") || data.Types.Contains("ODHCategory")))
sourcemeta = "idm";

string sourcemeta = data.Source.ToLower();

return GetMetadata(data, sourcemeta, data.LastChange);
}
Expand Down
4 changes: 3 additions & 1 deletion Helper/Reduced/ReduceDataHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ public static LTSODHActivityPoiReduced CopyLTSODHActivtyPoiToReducedObject(ODHAc

//Tagging
reduced.Tags = mypoi.Tags;
reduced.TagIds = mypoi.TagIds;

reduced.Detail = ReducedDataHelper.ReduceDetailInfo(mypoi.Detail);
reduced.ContactInfos = ReducedDataHelper.ReduceContactInfoForODHActivityPoi(mypoi.ContactInfos, mypoi.SyncSourceInterface);
Expand Down Expand Up @@ -385,6 +386,7 @@ public static EventLinkedReduced CopyLTSEventToReducedObject(EventLinked myevent
//ImageGallery
reduced.ImageGallery = ReducedDataHelper.ReduceImagesToCC0Only(myevent.ImageGallery);


return reduced;
}

Expand Down Expand Up @@ -534,7 +536,7 @@ public static VenueReduced CopyLTSVenueToReducedObject(VenueLinked venue)
reduced.PublishedOn = venue.PublishedOn;

//ImageGallery
reduced.ImageGallery = ReducedDataHelper.ReduceImagesToCC0Only(venue.ImageGallery);
reduced.ImageGallery = ReducedDataHelper.ReduceImagesToCC0Only(venue.ImageGallery);

return reduced;
}
Expand Down
3 changes: 2 additions & 1 deletion Helper/Tagging/GenericTaggingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public static async Task AddTagIdsToODHActivityPoi(IIdentifiable mypgdata, strin

foreach(var translatedtag in GenerateNewTagIds(((ODHActivityPoiLinked)mypgdata).SmgTags ?? new List<string>(), myalltaglist))
{
((ODHActivityPoiLinked)mypgdata).TagIds.Add(translatedtag);
if (!((ODHActivityPoiLinked)mypgdata).TagIds.Contains(translatedtag))
((ODHActivityPoiLinked)mypgdata).TagIds.Add(translatedtag);
}

}
Expand Down
2 changes: 1 addition & 1 deletion MSS/GetMssData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static class GetMssData
allmyoffers));

//Und iatz no parsen
MssResult myparsedresponse = ParseMssResponse.ParsemyMssResponse(lang, hgvservicecode, myresult, idlist, myroompersons, requestsource, version);
MssResult myparsedresponse = ParseMssResponse.ParsemyMssResponse(lang, hgvservicecode, myresult, idlist, myroompersons, requestsource, version, withoutmssids);

return myparsedresponse;
}
Expand Down
14 changes: 11 additions & 3 deletions MSS/ParseMssResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace MSS
{
public class ParseMssResponse
{
public static MssResult ParsemyMssResponse(string lang, string servicecode, XDocument mssresponse, List<MssRoom> myroompersons, string requestsource, string version)
public static MssResult ParsemyMssResponse(string lang, string servicecode, XDocument mssresponse, List<MssRoom> myroompersons, string requestsource, string version, bool withoutids)
{
try
{
Expand All @@ -32,7 +32,7 @@ public static MssResult ParsemyMssResponse(string lang, string servicecode, XDoc

}

public static MssResult ParsemyMssResponse(string lang, string servicecode, XDocument mssresponse, List<string> A0Rids, List<MssRoom> myroompersons, string requestsource, string version)
public static MssResult ParsemyMssResponse(string lang, string servicecode, XDocument mssresponse, List<string> A0Rids, List<MssRoom> myroompersons, string requestsource, string version, bool withoutids)
{
try
{
Expand All @@ -46,6 +46,10 @@ public static MssResult ParsemyMssResponse(string lang, string servicecode, XDoc
var myresult = mssresponse.Root.Elements("root").Elements("result").Elements("hotel").Where
(x => A0Rids.Contains(x.Element("id_lts").Value.ToLower()) && x.Elements("channel").Count() > 0);

if (A0Rids.Count == 0 && withoutids)
myresult = mssresponse.Elements("result").Elements("hotel").Where
(x => x.Elements("channel").Count() > 0);

return ResponseParser(myresult, servicecode, myroompersons, resultid, requestsource, lang, version);


Expand All @@ -57,7 +61,7 @@ public static MssResult ParsemyMssResponse(string lang, string servicecode, XDoc

}

public static MssResult ParsemyMssResponse(string lang, string servicecode, XElement mssresponse, List<string> A0Rids, List<MssRoom> myroompersons, string requestsource, string version)
public static MssResult ParsemyMssResponse(string lang, string servicecode, XElement mssresponse, List<string> A0Rids, List<MssRoom> myroompersons, string requestsource, string version, bool withoutids)
{
try
{
Expand All @@ -71,6 +75,10 @@ public static MssResult ParsemyMssResponse(string lang, string servicecode, XEle
var myresult = mssresponse.Elements("result").Elements("hotel").Where
(x => A0Rids.Contains(x.Element("id_lts").Value.ToUpper()) && x.Elements("channel").Count() > 0);

if(A0Rids.Count == 0 && withoutids)
myresult = mssresponse.Elements("result").Elements("hotel").Where
(x => x.Elements("channel").Count() > 0);

return ResponseParser(myresult, servicecode, myroompersons, resultid, requestsource, lang, version);
}
catch (Exception)
Expand Down
20 changes: 12 additions & 8 deletions NINJA/Parser/ParseNinjaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Microsoft.AspNetCore.DataProtection.KeyManagement;
using Microsoft.FSharp.Control;
using Newtonsoft.Json.Linq;
using static Dapper.SqlMapper;

namespace NINJA.Parser
{
Expand Down Expand Up @@ -697,15 +698,18 @@ public static ODHActivityPoiLinked ParseNinjaEchargingToODHActivityPoi(string id
"e-auto ladestation"
};

echargingpoi.Tags = new List<Tags>()
{
new Tags(){ Id = "poi", Source = "lts" },
new Tags(){ Id = "mobility", Source = "lts", Type = "categorytag" },
new Tags(){ Id = "electric charging stations", Source = "lts", Type = "tag" }
};
//echargingpoi.Tags = new List<Tags>()
//{
// new Tags(){ Id = "poi", Source = "idm", Type = "odhcategory", Name = "Poi" },
// new Tags(){ Id = "mobility", Source = "idm", Type = "odhcategory", Name = "Mobility" },
// new Tags(){ Id = "electric charging stations", Source = "idm", Type = "ltscategory", Name = "Electric charging stations" }
//};

//echargingpoi.TagIds = echargingpoi.Tags.Select(x => x.Id).ToList();


//Adding Category
if(echargingstationtag.DisplayAsCategory == true)
if (echargingstationtag.DisplayAsCategory == true)
{
echargingpoi.AdditionalPoiInfos = new Dictionary<string, AdditionalPoiInfos>();
foreach(var lang in new List<string>() { "de", "it", "en"})
Expand Down Expand Up @@ -769,7 +773,7 @@ public static ODHActivityPoiLinked ParseNinjaEchargingToODHActivityPoi(string id
properties.PaymentInfo = data.pmetadata?.paymentInfo;

//properties.ChargingPlugCount = 1;
properties.ChargingPistolTypes = data.smetadata.outlets.Select(y => y.outletTypeCode).Distinct().ToList();
properties.ChargingPistolTypes = data.smetadata.outlets != null ? data.smetadata.outlets.Select(y => y.outletTypeCode).Distinct().ToList() : null;

//TODO do not overwrite the old values
var additionalpropertieskey = typeof(EchargingDataProperties).Name;
Expand Down
20 changes: 14 additions & 6 deletions OdhApiCore/Controllers/api/AccommodationApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,12 @@ public async Task<IActionResult> GetAccoRoomInfosById(
/// <param name="departure">Departure Date (yyyy-MM-dd) REQUIRED</param>
/// <param name="roominfo">Roominfo Filter REQUIRED (Splitter for Rooms '|' Splitter for Persons Ages ',') (Room Types: 0=notprovided, 1=room, 2=apartment, 4=pitch/tent(onlyLTS), 8=dorm(onlyLTS)) possible Values Example 1-18,10|1-18 = 2 Rooms, Room 1 for 2 person Age 18 and Age 10, Room 2 for 1 Person Age 18), (default:'1-18,18')</param>/// <param name="bokfilter">Booking Channels Filter (Separator ',' possible values: hgv = (Booking Südtirol), htl = (Hotel.de), exp = (Expedia), bok = (Booking.com), lts = (LTS Availability check), (default:hgv)) REQUIRED</param>
/// <param name="detail">Include Offer Details (String, 1 = full Details)</param>
/// <param name="msssource">Source of the Requester (possible value: 'sinfo' = Suedtirol.info, 'sbalance' = Südtirol Balance) REQUIRED</param>
/// <param name="withoutids">Search over all bookable Accommodations (No Ids have to be provided as Post Data, when set to true, all passed Ids are omitted) (default: false)</param>
/// <param name="msssource">Source of the Requester (possible value: 'sinfo' = Suedtirol.info, 'sbalance' = Südtirol Balance) REQUIRED</param>
/// <param name="availabilityonly">Get only availability information without Accommodation information</param>
/// <param name="locfilter">Locfilter SPECIAL Separator ',' possible values: reg + REGIONID = (Filter by Region), reg + REGIONID = (Filter by Region), tvs + TOURISMVEREINID = (Filter by Tourismverein), mun + MUNICIPALITYID = (Filter by Municipality), fra + FRACTIONID = (Filter by Fraction), 'null' = (No Filter), (default:'null') <a href="https://github.com/noi-techpark/odh-docs/wiki/Geosorting-and-Locationfilter-usage#location-filter-locfilter" target="_blank">Wiki locfilter</a></param>
/// <param name="usemsscache">Use the MSS Cache to Request Data. No Ids have to be passed, the whole MSS Result of whole South Tyrol is used, default(false)</param>
/// <param name="uselcscache">Currently not used (planned to be active in 2025)</param>
/// <param name="removeduplicatesfrom">Remove all duplicate offers from the requested booking channel possible values: ('lts','hgv'), default(NULL)</param>
/// <param name="idfilter">Posted Accommodation IDs (Separated by , must be specified in the POST Body as raw)</param>
/// <returns>Result Object with Collection of Accommodation Objects</returns>
[ProducesResponseType(typeof(JsonResultWithBookingInfo<AccommodationV2>), StatusCodes.Status200OK)]
Expand Down Expand Up @@ -593,10 +596,15 @@ public async Task<IActionResult> PostAvailableAccommodations(
/// <param name="boardfilter">Boardfilter (BITMASK values: 0 = (all boards), 1 = (without board), 2 = (breakfast), 4 = (half board), 8 = (full board), 16 = (All inclusive), 'null' = No Filter)</param>
/// <param name="arrival">Arrival Date (yyyy-MM-dd) REQUIRED</param>
/// <param name="departure">Departure Date (yyyy-MM-dd) REQUIRED</param>
/// <param name="roominfo">Roominfo Filter REQUIRED (Splitter for Rooms '|' Splitter for Persons Ages ',') (Room Types: 0=notprovided, 1=room, 2=apartment, 4=pitch/tent(onlyLTS), 8=dorm(onlyLTS)) possible Values Example 1-18,10|1-18 = 2 Rooms, Room 1 for 2 person Age 18 and Age 10, Room 2 for 1 Person Age 18), (default:'1-18,18')</param>/// <param name="bokfilter">Booking Channels Filter (Separator ',' possible values: hgv = (Booking Südtirol), htl = (Hotel.de), exp = (Expedia), bok = (Booking.com), lts = (LTS Availability check), (default:hgv)) REQUIRED</param>
/// <param name="roominfo">Roominfo Filter REQUIRED (Splitter for Rooms '|' Splitter for Persons Ages ',') (Room Types: 0=notprovided, 1=room, 2=apartment, 4=pitch/tent(onlyLTS), 8=dorm(onlyLTS)) possible Values Example 1-18,10|1-18 = 2 Rooms, Room 1 for 2 person Age 18 and Age 10, Room 2 for 1 Person Age 18), (default:'1-18,18')</param>
/// <param name="bokfilter">Booking Channels Filter (Separator ',' possible values: hgv = (Booking Südtirol), htl = (Hotel.de), exp = (Expedia), bok = (Booking.com), lts = (LTS Availability check), (default:hgv)) REQUIRED</param>
/// <param name="detail">Include Offer Details (String, 1 = full Details)</param>
/// <param name="msssource">Source of the Requester (possible value: 'sinfo' = Suedtirol.info, 'sbalance' = Südtirol Balance) REQUIRED</param>
/// <param name="idfilter">Posted Accommodation IDs (Separated by , must be specified in the POST Body as raw)</param>
/// <param name="locfilter">Locfilter SPECIAL Separator ',' possible values: reg + REGIONID = (Filter by Region), reg + REGIONID = (Filter by Region), tvs + TOURISMVEREINID = (Filter by Tourismverein), mun + MUNICIPALITYID = (Filter by Municipality), fra + FRACTIONID = (Filter by Fraction), 'null' = (No Filter), (default:'null') <a href="https://github.com/noi-techpark/odh-docs/wiki/Geosorting-and-Locationfilter-usage#location-filter-locfilter" target="_blank">Wiki locfilter</a></param>
/// <param name="usemsscache">Use the MSS Cache to Request Data. No Ids have to be passed, the whole MSS Result of whole South Tyrol is used, default(false)</param>
/// <param name="uselcscache">Currently not used (planned to be active in 2025)</param>
/// <param name="removeduplicatesfrom">Remove all duplicate offers from the requested booking channel possible values: ('lts','hgv'), default(NULL)</param>
/// <param name="idfilter">Posted Accommodation IDs (Separated by , must be specified in the POST Body as raw)</param>
/// <returns>Result Object with Collection of Accommodation Objects</returns>
[ProducesResponseType(typeof(JsonResultWithBookingInfo<MssResult>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
Expand All @@ -618,7 +626,7 @@ public async Task<IActionResult> PostAvailableAccommodationsOnlyMssResult(
string? locfilter = null,
bool usemsscache = false,
bool uselcscache = false,
string removeduplicatesfrom = null,
string? removeduplicatesfrom = null,
CancellationToken cancellationToken = default)
{
return await PostAvailableAccommodations(idfilter, availabilitychecklanguage, boardfilter, arrival, departure, roominfo, bokfilter, msssource, detail, locfilter, true, usemsscache, uselcscache, removeduplicatesfrom, cancellationToken);
Expand All @@ -642,7 +650,7 @@ private Task<IActionResult> GetFiltered(string[] fields, string? language, uint
//Hack Bookable Filter
bool? customisbookablefilter = bookablefilter;
if (idfilter != null && idfilter.Count() > 0)
customisbookablefilter = false;
customisbookablefilter = null;

AccommodationHelper myhelper = await AccommodationHelper.CreateAsync(
QueryFactory, idfilter: idfilter, locfilter: locfilter, boardfilter: boardfilter, categoryfilter: categoryfilter, typefilter: typefilter,
Expand Down
Loading

0 comments on commit 995e198

Please sign in to comment.