Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HIPM-909: Replace Realm with SQLite/EF Core #207

Merged
merged 81 commits into from
Mar 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
835b300
Iss hipm 792 (#170)
sayantik Feb 1, 2018
b67d8b3
Remove Realm references
cbruegg Feb 4, 2018
f894f57
Fix namespaces
cbruegg Feb 4, 2018
7bb6781
Reformat Token
cbruegg Feb 4, 2018
6add175
WIP
cbruegg Feb 4, 2018
fffd1ff
iss-hipm-904-Strings.resx Strings should always be located in the Str…
Senne021 Feb 4, 2018
1e2038d
Fixed toolbar color and unnecessary adjust-statusbar calls (#180)
Resudo Feb 5, 2018
851bb54
Iss hipm 859 As a user, I want to see my own rating of an exhibit (#177)
Senne021 Feb 5, 2018
47b11d1
iss-hipm-802 reformat info bubble on map for ios device (#187)
BeisiXiong Feb 5, 2018
96bdbb5
iss-hipm-908 Update layout of the download page of routes/exhibits to…
Senne021 Feb 9, 2018
4996ee5
Restored download functionality + some code cleanup (#193)
Resudo Feb 12, 2018
0bccf46
GeoLocation and Rectangle are now structs (instead of DB entities), c…
SvenEV Feb 12, 2018
8064d07
Iss hipm 844 (#192)
sayantik Feb 15, 2018
7781b4b
WIP Replaced Dapper with Entity Framework Core
SvenEV Feb 16, 2018
9eafaac
Unified MediaFileManager
cbruegg Feb 17, 2018
a63f981
WIP
SvenEV Feb 18, 2018
fb951b2
WIP projects compiling again! Refactored model classes so they now fo…
SvenEV Feb 18, 2018
9e43b58
Fixed issues preventing EF Core from creating a correct model
SvenEV Feb 18, 2018
604e4cb
Merged changes from Christian
SvenEV Feb 18, 2018
139e568
Added support for eager loading of navigation properties, started usi…
SvenEV Feb 18, 2018
75e3383
Re-enabled map control, bugfixes
SvenEV Feb 18, 2018
b358523
iss-hipm-913 Labels to Buttons (#194)
BeisiXiong Feb 19, 2018
8b92353
Implemented a debug view for DbContexts to inspect data & change trac…
SvenEV Feb 19, 2018
e664f46
Fixed status bar color bug; solved related indexing problem hiding pa…
Resudo Feb 19, 2018
4c18fd7
Bug fixes in debug view and EF Core model creation
SvenEV Feb 19, 2018
3e0ec11
Bugfix
SvenEV Feb 19, 2018
d13e1d8
iss-hipm-907-bug icon doesn't fit new design manual (#190)
BeisiXiong Feb 20, 2018
194111d
Bug fix in DtoToModelConverter
SvenEV Feb 26, 2018
f5e88b5
Updated DbContextDebugView (copied over changes from a personal project)
SvenEV Feb 26, 2018
1b28a63
EFCoreDataAccess now also queries the local cache so that in a transa…
SvenEV Feb 26, 2018
ce3bdeb
Removed debug output of EFCoreTransaction, fixed GeoLocationConverter…
SvenEV Feb 26, 2018
3ab4993
Fixed OsmMap exhibit binding
SvenEV Feb 26, 2018
f367a50
Fixed route download, BackupImage & BackupImageTag now tracked by def…
SvenEV Feb 26, 2018
d25f5de
Minor cleanup
SvenEV Feb 26, 2018
8098227
Iss hipm 910 As a user, I want to use the application in English (#195)
Senne021 Feb 28, 2018
199985b
WIP deep-loading exhibit pages and associated media, fixed JoinCollec…
SvenEV Mar 1, 2018
31efbfb
Iss hipm 911 - Rework of the main menu (#189)
Resudo Mar 1, 2018
d1b947f
Condnl. visibility on score (#197)
sayantik Mar 6, 2018
a9e866a
Iss hipm 902 infobubble (#196)
sayantik Mar 7, 2018
a58fee0
Formatting fixes (#198)
cbruegg Mar 7, 2018
e2ae314
Iss-hipm-905 changed all the fonts and colors (#185)
BeisiXiong Mar 7, 2018
6309d41
Small changes for a more consistent UI experience (#199)
Resudo Mar 8, 2018
e2df7e2
Iss hipm 929 ratingtoappetizer (#200)
sayantik Mar 9, 2018
03932e2
Don't automatically target latest Android version (dangerous)
cbruegg Mar 12, 2018
4220f4e
Merge remote-tracking branch 'origin/iss-hipm-909-dapper-based-on-890…
cbruegg Mar 12, 2018
cde200b
Merge remote-tracking branch 'origin/master' into iss-hipm-909-dapper…
cbruegg Mar 12, 2018
f75d2c4
Fixed iOS project
SvenEV Mar 12, 2018
ff16899
Merge branch 'iss-hipm-909-dapper-based-on-890' of https://github.com…
SvenEV Mar 12, 2018
0a33179
Make it build
cbruegg Mar 12, 2018
ed1d6bc
Fix warnings
cbruegg Mar 12, 2018
22292c7
Fixed first page missing in exhibit details, some cleanup
SvenEV Mar 12, 2018
9cce282
Iss hipm 918 iosexhibitdetails (#203)
sayantik Mar 12, 2018
d7aed81
Fixes
cbruegg Mar 12, 2018
f009975
Merge remote-tracking branch 'origin/iss-hipm-909-dapper-based-on-890…
cbruegg Mar 12, 2018
1f3d883
Merge branch 'master' into iss-hipm-909-dapper-based-on-890
cbruegg Mar 12, 2018
0f710f2
Merge master again
cbruegg Mar 12, 2018
3d2a746
Fix iOS by recharging Sqlite PCL battery
cbruegg Mar 12, 2018
5b968ca
Merged changes
SvenEV Mar 12, 2018
33557cd
TFS builds fixed! (Problem was OsmSharp: my PC selected the patched v…
SvenEV Mar 12, 2018
8d781be
Cleanup
SvenEV Mar 12, 2018
cdf8ad0
Increased Java heap size during compilation to hopefully fix TFS builds
SvenEV Mar 12, 2018
dc412e2
Fixed test compilation
SvenEV Mar 12, 2018
10835cc
Fixed private field naming according to ReSharper config
SvenEV Mar 12, 2018
68b9a62
ReSharper fixes
SvenEV Mar 12, 2018
4d63e1d
Merge branch 'iss-hipm-890' into iss-hipm-909-dapper-based-on-890
SvenEV Mar 13, 2018
c4a9f01
Removed TODOs, edited comments
SvenEV Mar 13, 2018
84c2b0b
Made write access to the database even more explicit: DbManager.DataA…
SvenEV Mar 13, 2018
1f65e4f
Improved documentation
SvenEV Mar 13, 2018
0859656
Fixed tests
SvenEV Mar 13, 2018
abd7b56
Moved patched dependency "System.Runtime.CompilerServices.Unsafe" fro…
SvenEV Mar 13, 2018
c9503a5
Build works in VSMac via VNC, but not when executed through TFS. Tryi…
SvenEV Mar 14, 2018
2f31297
Removed unused type "SliderImage"
SvenEV Mar 14, 2018
baa86cc
Removed unused type "AppetizerPage"
SvenEV Mar 14, 2018
1da72c3
Remove references to Fody
cbruegg Mar 17, 2018
4509de8
Addressed feedback
SvenEV Mar 17, 2018
3c76201
Merge branch 'iss-hipm-909-dapper-based-on-890' of https://github.com…
SvenEV Mar 17, 2018
5c1f590
Removed redundant " : this()"
SvenEV Mar 17, 2018
86ce0e4
Improved documentation
SvenEV Mar 17, 2018
03a5d0d
Added TODO to unclear properties
SvenEV Mar 17, 2018
53834b2
Clarified null behavior
SvenEV Mar 17, 2018
5b7a7bd
Now using 'nameof' everywhere when eager loading related entities
SvenEV Mar 17, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion HipMobileForms.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HipMobile", "HipMobile", "{
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HipMobileUI", "HipMobileUI", "{9135C941-A58C-4733-B191-A61C6CA2A016}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HipMobileUI.UITests", "Sources\HipMobileUI.UITests\HipMobileUI.UITests.csproj", "{5CCB5487-8031-4BAB-9EBA-D4A04A1D010E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HipMobileUI.UITests", "Sources\HipMobileUI.UITests\HipMobileUI.UITests.csproj", "{5CCB5487-8031-4BAB-9EBA-D4A04A1D010E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HipMobileUI.Android", "Sources\HipMobileUI.Android\HipMobileUI.Android.csproj", "{C400B409-92B2-4726-B24A-3942722189FA}"
EndProject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.BusinessLayer.ContentApiFetchers.Contracts;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.BusinessLayer.DtoToModelConverters;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.BusinessLayer.Managers;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.BusinessLayer.Models;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.DataAccessLayer;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.ServiceAccessLayer.ContentApiAccesses.Contracts;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace PaderbornUniversity.SILab.Hip.Mobile.Shared.BusinessLayer.ContentApiFetchers
{
Expand All @@ -32,25 +33,22 @@ public AchievementFetcher(IAchievementsApiAccess client)
this.client = client;
}

public async Task<IEnumerable<IAchievement>> UpdateAchievements()
public async Task<IEnumerable<AchievementBase>> UpdateAchievements(ITransactionDataAccess dataAccess)
{
var existingUnlocked = AchievementManager.GetAchievements()
.Where(it => it.IsUnlocked)
.Select(it => it.Id);
var existingUnlocked = dataAccess.Achievements().GetAchievements()
.Where(it => it.IsUnlocked)
.Select(it => it.Id);

var achievementDtos = await client.GetAchievements();
var unlockedAchievementIds = (await client.GetUnlockedAchievements())
.Select(it => it.Id.ToString()).ToList();

using (DbManager.StartTransaction())

var achievements = AchievementConverter.Convert(achievementDtos, dataAccess).ToList();
foreach (var unlocked in achievements.Where(it => unlockedAchievementIds.Contains(it.Id)))
{
var achievements = AchievementConverter.Convert(achievementDtos).ToList();
foreach (var unlocked in achievements.Where(it => unlockedAchievementIds.Contains(it.Id)))
{
unlocked.IsUnlocked = true;
}
return achievements.Where(it => it.IsUnlocked && !existingUnlocked.Contains(it.Id));
unlocked.IsUnlocked = true;
}
return achievements.Where(it => it.IsUnlocked && !existingUnlocked.Contains(it.Id));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.BusinessLayer.ContentApiFetchers.Contracts;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.BusinessLayer.Managers;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.DataAccessLayer;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.Helpers;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace PaderbornUniversity.SILab.Hip.Mobile.Shared.BusinessLayer.ContentApiFetchers
{
Expand All @@ -36,61 +37,61 @@ public BaseDataFetcher(IRoutesBaseDataFetcher routesBaseDataFetcher, IExhibitsBa

public async Task<bool> IsDatabaseUpToDate()
{
bool anyExhibitChanged = await exhibitsBaseDataFetcher.AnyExhibitChanged();
bool anyRouteChanged = await routesBaseDataFetcher.AnyRouteChanged();
bool anyExhibitChanged = await exhibitsBaseDataFetcher.AnyExhibitChanged(DbManager.DataAccess);
bool anyRouteChanged = await routesBaseDataFetcher.AnyRouteChanged(DbManager.DataAccess);

return !(anyExhibitChanged || anyRouteChanged);
}

public async Task FetchBaseDataIntoDatabase(CancellationToken token, IProgressListener listener)
{
var routes = RouteManager.GetRoutes().ToDictionary(x => x.IdForRestApi, x => x.Timestamp);
var exhibits = ExhibitManager.GetExhibits().ToDictionary(x => x.IdForRestApi, x => x.Timestamp);

double totalSteps = await exhibitsBaseDataFetcher.FetchNeededDataForExhibits(exhibits);
totalSteps += await routesBaseDataFetcher.FetchNeededDataForRoutes(routes);

if (token.IsCancellationRequested)
using (var transaction = DbManager.StartTransaction())
{
return;
}
var routes = transaction.DataAccess.Routes().GetRoutes().ToDictionary(x => x.IdForRestApi, x => x.Timestamp);
var exhibits = transaction.DataAccess.Exhibits().GetExhibits().ToDictionary(x => x.IdForRestApi, x => x.Timestamp);

listener.SetMaxProgress(totalSteps);
double totalSteps = await exhibitsBaseDataFetcher.FetchNeededDataForExhibits(exhibits);
totalSteps += await routesBaseDataFetcher.FetchNeededDataForRoutes(routes);

await exhibitsBaseDataFetcher.FetchMediaData(token, listener);
if (token.IsCancellationRequested)
{
return;
}
await routesBaseDataFetcher.FetchMediaData(token, listener);
if (token.IsCancellationRequested)
{
return;
}
if (token.IsCancellationRequested)
{
transaction.Rollback();
return;
}

using (var transaction = DbManager.StartTransaction())
{
await exhibitsBaseDataFetcher.ProcessExhibits(listener);
listener.SetMaxProgress(totalSteps);

await exhibitsBaseDataFetcher.FetchMediaData(token, listener);
if (token.IsCancellationRequested)
{
transaction.Rollback();
return;
}
await routesBaseDataFetcher.ProcessRoutes(listener);
await routesBaseDataFetcher.FetchMediaData(token, listener);
if (token.IsCancellationRequested)
{
transaction.Rollback();
return;
}

await exhibitsBaseDataFetcher.ProcessExhibits(listener, transaction.DataAccess);
if (token.IsCancellationRequested)
{
transaction.Rollback();
return;
}
await routesBaseDataFetcher.ProcessRoutes(listener, transaction.DataAccess);
if (token.IsCancellationRequested)
{
transaction.Rollback();
return;
}
}
await dataToRemoveFetcher.FetchDataToDelete(token);
using (DbManager.StartTransaction())

using (var transaction = DbManager.StartTransaction())
{
await dataToRemoveFetcher.CleanupRemovedData();
await dataToRemoveFetcher.FetchDataToDelete(token);
await dataToRemoveFetcher.CleanupRemovedData(transaction.DataAccess);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using PaderbornUniversity.SILab.Hip.Mobile.Shared.BusinessLayer.Models;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.DataAccessLayer;
using System.Collections.Generic;
using System.Threading.Tasks;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.BusinessLayer.Models;

namespace PaderbornUniversity.SILab.Hip.Mobile.Shared.BusinessLayer.ContentApiFetchers.Contracts
{
public interface IAchievementFetcher
{
/// <summary>
/// Fetches the all achievements from the API and stores
/// Fetches all achievements from the API and stores
/// them in the database, including locked ones.
/// WARNING: If you call this method, use the return value to show
/// notifications about new unlocked achievements!
/// </summary>
/// <returns>Achievements that have been newly added to the database and are unlocked.</returns>
Task<IEnumerable<IAchievement>> UpdateAchievements();
Task<IEnumerable<AchievementBase>> UpdateAchievements(ITransactionDataAccess dataAccess);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using PaderbornUniversity.SILab.Hip.Mobile.Shared.DataAccessLayer;
using System.Threading;
using System.Threading.Tasks;

Expand All @@ -21,6 +22,6 @@ public interface IDataToRemoveFetcher
{
Task FetchDataToDelete(CancellationToken token);

Task CleanupRemovedData();
Task CleanupRemovedData(ITransactionDataAccess dataAccess);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.DataAccessLayer;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.Helpers;

namespace PaderbornUniversity.SILab.Hip.Mobile.Shared.BusinessLayer.ContentApiFetchers.Contracts
Expand Down Expand Up @@ -44,12 +45,12 @@ public interface IExhibitsBaseDataFetcher
/// </summary>
/// <param name="listener"></param>
/// <returns></returns>
Task ProcessExhibits(IProgressListener listener);
Task ProcessExhibits(IProgressListener listener, ITransactionDataAccess dataAccess);

/// <summary>
/// Indicates whether any exhibit was changed
/// </summary>
/// <returns></returns>
Task<bool> AnyExhibitChanged();
Task<bool> AnyExhibitChanged(IReadOnlyDataAccess dataAccess);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading;
using System.Threading.Tasks;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.DataAccessLayer;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.Helpers;

namespace PaderbornUniversity.SILab.Hip.Mobile.Shared.BusinessLayer.ContentApiFetchers.Contracts
Expand All @@ -17,7 +14,9 @@ public interface IFullDownloadableDataFetcher
/// <param name="idForRestApi">The id for the REST API of the exhibit to be fetched</param>
/// <param name="token">Used for cancelling the download</param>
/// <param name="listener">Used for reporting progress</param>
/// <param name="dataAccess">Provides read/write access to the database</param>
/// <returns></returns>
Task FetchFullDownloadableDataIntoDatabase(string downloadableId, int idForRestApi, CancellationToken token, IProgressListener listener);
Task FetchFullDownloadableDataIntoDatabase(
string downloadableId, int idForRestApi, CancellationToken token, IProgressListener listener);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Collections.Generic;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.Helpers;
using System.Threading;
using System.Threading.Tasks;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.Helpers;

namespace PaderbornUniversity.SILab.Hip.Mobile.Shared.BusinessLayer.ContentApiFetchers.Contracts
{
Expand All @@ -32,8 +31,9 @@ public interface IFullExhibitDataFetcher : IFullDownloadableDataFetcher
/// <param name="token">For cancellation</param>
/// <param name="listener">To update the progressbar of the downloadpage</param>
/// <returns></returns>
Task FetchFullExhibitDataIntoDatabaseWithFetchedPagesAndMedia(string exhibitId, ExhibitPagesAndMediaContainer pagesAndMediaContainer, CancellationToken token,
IProgressListener listener);
Task FetchFullExhibitDataIntoDatabaseWithFetchedPagesAndMedia(
string exhibitId, ExhibitPagesAndMediaContainer pagesAndMediaContainer, CancellationToken token,
IProgressListener listener);

/// <summary>
/// Load pages for related exhibit and prefetch media of an exhibit for later use in a full route fetcher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Threading;
using System.Threading.Tasks;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.Helpers;

namespace PaderbornUniversity.SILab.Hip.Mobile.Shared.BusinessLayer.ContentApiFetchers.Contracts
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,31 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.DataAccessLayer;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.Helpers;

namespace PaderbornUniversity.SILab.Hip.Mobile.Shared.BusinessLayer.ContentApiFetchers.Contracts
{
/// <summary>
/// Fetcher for audio and images
/// Fetcher for audio and images.
/// </summary>
public interface IMediaDataFetcher
{
/// <summary>
/// Fetches the media data including the real files for the given ids
/// Fetches the media data including the real files for the given IDs.
/// </summary>
/// <param name="mediaIds"></param>
/// <param name="token">Can be provided for canceling the action</param>
/// <param name="progressListener">Can be provided for reporting progress on the download</param>
Task FetchMedias(IList<int?> mediaIds, CancellationToken token, IProgressListener progressListener);

/// <summary>
/// Combines media data and files
/// Must be called inside a database transaction
/// Combines media data and files, creating new image/audio entities in the database or updating existing ones.
/// Must be called inside a database transaction.
/// </summary>
/// <returns></returns>
Task<FetchedMediaData> CombineMediasAndFiles();
Task<FetchedMediaData> CombineMediasAndFiles(ITransactionDataAccess dataAccess);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.DataAccessLayer;
using PaderbornUniversity.SILab.Hip.Mobile.Shared.Helpers;

namespace PaderbornUniversity.SILab.Hip.Mobile.Shared.BusinessLayer.ContentApiFetchers.Contracts
Expand Down Expand Up @@ -44,12 +45,12 @@ public interface IRoutesBaseDataFetcher
/// </summary>
/// <param name="listener"></param>
/// <returns></returns>
Task ProcessRoutes(IProgressListener listener);
Task ProcessRoutes(IProgressListener listener, ITransactionDataAccess dataAccess);

/// <summary>
/// Indicates whether any route was changed
/// </summary>
/// <returns></returns>
Task<bool> AnyRouteChanged();
Task<bool> AnyRouteChanged(IReadOnlyDataAccess dataAccess);
}
}
Loading