-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pr/225 - Entity Services fixes (#226)
* Fixes to specify the objectType in calls to EntityService.GetAll (#225) thanks, there is a minor annoyance that the MediaIdMapper inherits the content one, so sometimes the lookup is for media, not content, but I will fix that. * set baseObjectType for class so MediaMapper can use it too. #225 adds extra baseObjectType value so we can set the type of things we are looking up (because media mapper looks up Media) * Base type in ContentType Serializer #225 Like the Mapper, the base serializer lookup can be used for ContentTypes, MediaTypes and MemberTypes * update RjpMapper to do the getall lookup properly (like #225) * Refactor RJP Mapper to use GetKeyForId / GetIdForKey EntityService calls * tidy up, use GetIdForKey and GetKeyForId where we can #225 * ID Testing.
- Loading branch information
Showing
30 changed files
with
505 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
Jumoo.uSync.Core/Extensions/EntityServicePatchExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Umbraco.Core; | ||
using Umbraco.Core.Events; | ||
using Umbraco.Core.Logging; | ||
using Umbraco.Core.Models; | ||
using Umbraco.Core.Models.EntityBase; | ||
using Umbraco.Core.Persistence; | ||
using Umbraco.Core.Persistence.UnitOfWork; | ||
using Umbraco.Core.Services; | ||
|
||
namespace Jumoo.uSync.Core | ||
{ | ||
/// <summary> | ||
/// Series of extensions methods to work around the change in interface for EntityService | ||
/// in Umbraco 7.15.0 - we can't safely call Get(int id) or Get(Guid key) because things | ||
/// changed. but other alternatives in the service need to know types before they will | ||
/// do anything. | ||
/// </summary> | ||
public static class EntityServicePatchExtensions | ||
{ | ||
/// <summary> | ||
/// gets you the Key (Guid) for an entity if all you know is the Id (int) | ||
/// </summary> | ||
public static Attempt<Guid> uSyncGetKeyForId(this IEntityService entityService, int id) | ||
{ | ||
try | ||
{ | ||
if (entityService.Exists(id)) | ||
{ | ||
var type = entityService.GetObjectType(id); | ||
if (type != UmbracoObjectTypes.Unknown) | ||
{ | ||
return entityService.GetKeyForId(id, type); | ||
} | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
// it shouldn't but we might fire a ObjectNotSet exception if the type is missing | ||
// (but we do a check, so that is very unlikely) | ||
return Attempt.Fail(Guid.Empty, ex); | ||
} | ||
|
||
|
||
return Attempt.Fail(Guid.Empty); | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Child> | ||
@using ContentModels = Umbraco.Web.PublishedContentModels; | ||
@{ | ||
Layout = null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.