Skip to content

Commit

Permalink
- Added HcObjectTypeEnum to HoloOASIS Provider.
Browse files Browse the repository at this point in the history
- Added new IHcObject interface HoloOASIS Provider to allow to make the code even more generic and efficient.

- IHcAvatar and IHcAvatarDetail interfaces now extend the new IHcObject interface.

- Moved IHcAvatar, IHcAvatarDetail & IHcObject interfaces to new Interfaces folder.

- Finished implementing missing properties from IHolonBase interface to HcAvatarDetail in HoloOASIS Provider.

- Updated LoadAvatarAsync, LoadAvatar, LoadAvatarByEmailAsync & LoadAvatarByEmail methods in HoloOASIS Provider.

- Changed ConvertHcAvatarToAvatar method return type to IAvatar in HoloOASIS Provider.

- Added ConvertKeyValuePairToAvatar method to HoloOASIS Provider.

- Added ConvertHcAvatarDetailToAvatarDetail method to HoloOASIS Provider.

- Added ConvertKeyValuePairToAvatarDetail method to HoloOASIS Provider.

- Updated generic LoadAsync & Load methods in HoloOASIS Provider to make it even more efficient so all load operations now go through it.

- Added new HandleResponse method to HoloOASIS Provider.

- Started adding new generic SaveAsync method to HoloOASIS Provider.
  • Loading branch information
dellams committed Apr 14, 2023
1 parent cc3ea30 commit 6fcd57b
Show file tree
Hide file tree
Showing 9 changed files with 350 additions and 236 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

namespace NextGenSoftware.OASIS.API.Providers.HoloOASIS
{
public enum HcObjectTypeEnum
{
Avatar,
AvatarDetail,
Holon
}
}
385 changes: 162 additions & 223 deletions NextGenSoftware.OASIS.API.Providers.HoloOASIS.Core/HoloOASIS.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

using NextGenSoftware.Holochain.HoloNET.Client;
using NextGenSoftware.Holochain.HoloNET.Client.TestHarness;
using NextGenSoftware.OASIS.API.Core.Enums;
using NextGenSoftware.OASIS.API.Core.Helpers;
using NextGenSoftware.OASIS.API.Core.Interfaces;
Expand Down Expand Up @@ -81,14 +80,19 @@ public HcAvatar(HoloNETClient holoNETClient) : base("oasis", "get_entry_avatar",

[HolochainFieldName("meta_data")]
public Dictionary<string, string> MetaData { get; set; }

[HolochainFieldName("version")]
public int Version { get; set; }

[HolochainFieldName("version_id")]
public Guid VersionId { get; set; }

[HolochainFieldName("previous_version_id")]
public Guid PreviousVersionId { get; set; }

[HolochainFieldName("is_active")]
public bool IsActive { get; set; }
public bool IsChanged { get; set; }
public bool IsNewHolon { get; set; }
public bool IsSaving { get; set; }
public IHolon Original { get; set; }


//Part of HoloNETAuditEntryBaseClass so no need to re-define here.
//Guid CreatedByAvatarId { get; set; }
Expand All @@ -97,7 +101,11 @@ public HcAvatar(HoloNETClient holoNETClient) : base("oasis", "get_entry_avatar",
//DateTime ModifiedDate { get; set; }
//Guid DeletedByAvatarId { get; set; }
//DateTime DeletedDate { get; set; }

[HolochainFieldName("created_provider_type")]
public EnumValue<ProviderType> CreatedProviderType { get; set; }

[HolochainFieldName("created_oasis_type")]
public EnumValue<OASISType> CreatedOASISType { get; set; }

#endregion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

using NextGenSoftware.Holochain.HoloNET.Client;
using NextGenSoftware.Holochain.HoloNET.Client.TestHarness;
using NextGenSoftware.OASIS.API.Core.Enums;
using NextGenSoftware.OASIS.API.Core.Interfaces;
using NextGenSoftware.OASIS.API.Core.Interfaces.STAR;
Expand All @@ -15,6 +14,8 @@ public class HcAvatarDetail : HoloNETAuditEntryBaseClass, IHcAvatarDetail
public HcAvatarDetail() : base("oasis", "get_entry_avatar_detail", "create_entry_avatar_detail", "update_entry_avatar_detail", "delete_entry_avatar_detail") { }
public HcAvatarDetail(HoloNETClient holoNETClient) : base("oasis", "get_entry_avatar_detail", "create_entry_avatar_detail", "update_entry_avatar_detail", "delete_entry_avatar_detail", holoNETClient) { }

#region IAvatarDetail Properties

[HolochainFieldName("id")]
public Guid Id { get; set; }

Expand Down Expand Up @@ -88,5 +89,62 @@ public HcAvatarDetail(HoloNETClient holoNETClient) : base("oasis", "get_entry_av
public ConsoleColor STARCLIColour { get; set; }
public IAvatarStats Stats { get; set; }
public IAvatarSuperPowers SuperPowers { get; set; }

#endregion

#region IHolonBase Properties

public string Name { get; set; }
public string Description { get; set; }

[HolochainFieldName("holon_type")]
public HolonType HolonType { get; set; }

[HolochainFieldName("provider_key")]
public string ProviderUniqueStorageKey { get; set; }

[HolochainFieldName("previous_version_provider_unique_storage_key")]
public Dictionary<ProviderType, string> PreviousVersionProviderUniqueStorageKey { get; set; }

[HolochainFieldName("provider_wallets")]
public Dictionary<ProviderType, List<IProviderWallet>> ProviderWallets { get; set; }

[HolochainFieldName("provider_username")]
public Dictionary<ProviderType, string> ProviderUsername { get; set; }

[HolochainFieldName("provider_meta_data")]
public Dictionary<ProviderType, Dictionary<string, string>> ProviderMetaData { get; set; }

[HolochainFieldName("meta_data")]
public Dictionary<string, string> MetaData { get; set; }

[HolochainFieldName("version")]
public int Version { get; set; }

[HolochainFieldName("version_id")]
public Guid VersionId { get; set; }

[HolochainFieldName("previous_version_id")]
public Guid PreviousVersionId { get; set; }

[HolochainFieldName("is_active")]
public bool IsActive { get; set; }


//Part of HoloNETAuditEntryBaseClass so no need to re-define here.
//Guid CreatedByAvatarId { get; set; }
//DateTime CreatedDate { get; set; }
//Guid ModifiedByAvatarId { get; set; }
//DateTime ModifiedDate { get; set; }
//Guid DeletedByAvatarId { get; set; }
//DateTime DeletedDate { get; set; }

[HolochainFieldName("created_provider_type")]
public EnumValue<ProviderType> CreatedProviderType { get; set; }

[HolochainFieldName("created_oasis_type")]
public EnumValue<OASISType> CreatedOASISType { get; set; }

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace NextGenSoftware.OASIS.API.Providers.HoloOASIS
{
public interface IHcAvatar
public interface IHcAvatar : IHcObject
{
#region IAvatar Properties

Expand Down Expand Up @@ -50,10 +50,6 @@ public interface IHcAvatar
Guid VersionId { get; set; }
Guid PreviousVersionId { get; set; }
bool IsActive { get; set; }
bool IsChanged { get; set; }
bool IsNewHolon { get; set; }
bool IsSaving { get; set; }
IHolon Original { get; set; }
string CreatedBy { get; set; }
DateTime CreatedDate { get; set; }
string ModifiedBy { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NextGenSoftware.OASIS.API.Core.Enums;
using NextGenSoftware.OASIS.API.Core.Helpers;
using NextGenSoftware.OASIS.API.Core.Interfaces;
using NextGenSoftware.OASIS.API.Core.Interfaces.STAR;
using NextGenSoftware.OASIS.API.Core.Objects;
Expand All @@ -7,8 +8,9 @@

namespace NextGenSoftware.OASIS.API.Providers.HoloOASIS
{
public interface IHcAvatarDetail
public interface IHcAvatarDetail : IHcObject
{
#region IAvatarDetail Properties
Guid Id { get; set; }
string Email { get; set; }
string Username { get; set; }
Expand Down Expand Up @@ -47,5 +49,33 @@ public interface IHcAvatarDetail
public ConsoleColor STARCLIColour { get; set; }
public IAvatarStats Stats { get; set; }
public IAvatarSuperPowers SuperPowers { get; set; }

#endregion

#region IHolonBase Properties

string Name { get; set; }
string Description { get; set; }
HolonType HolonType { get; set; }
string ProviderUniqueStorageKey { get; set; }
Dictionary<ProviderType, string> PreviousVersionProviderUniqueStorageKey { get; set; }
public Dictionary<ProviderType, List<IProviderWallet>> ProviderWallets { get; set; }
public Dictionary<ProviderType, string> ProviderUsername { get; set; }
Dictionary<ProviderType, Dictionary<string, string>> ProviderMetaData { get; set; }
Dictionary<string, string> MetaData { get; set; }
int Version { get; set; }
Guid VersionId { get; set; }
Guid PreviousVersionId { get; set; }
bool IsActive { get; set; }
string CreatedBy { get; set; }
DateTime CreatedDate { get; set; }
string ModifiedBy { get; set; }
DateTime ModifiedDate { get; set; }
string DeletedBy { get; set; }
DateTime DeletedDate { get; set; }
EnumValue<ProviderType> CreatedProviderType { get; set; }
EnumValue<OASISType> CreatedOASISType { get; set; }

#endregion
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@

using NextGenSoftware.Holochain.HoloNET.Client;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace NextGenSoftware.OASIS.API.Providers.HoloOASIS
{
public interface IHcObject // : IHoloNETAuditEntryBaseClass
{
//TODO: Temp until release new version of HoloNET with interfaces defined.
List<HoloNETAuditEntry> AuditEntries { get; set; }
string CreatedBy { get; set; }
DateTime CreatedDate { get; set; }
string DeletedBy { get; set; }
DateTime DeletedDate { get; set; }
Guid Id { get; set; }
bool IsActive { get; set; }
bool IsAuditAgentCreateModifyDeleteFieldsEnabled { get; set; }
bool IsAuditTrackingEnabled { get; set; }
bool IsVersionTrackingEnabled { get; set; }
string ModifiedBy { get; set; }
DateTime ModifiedDate { get; set; }
int Version { get; set; }

EntryData EntryData { get; set; }
string EntryHash { get; set; }
HoloNETClient HoloNETClient { get; set; }
bool IsInitialized { get; }
bool IsInitializing { get; }
string PreviousVersionEntryHash { get; set; }
string ZomeCreateCollectionFunction { get; set; }
string ZomeCreateEntryFunction { get; set; }
string ZomeDeleteCollectionFunction { get; set; }
string ZomeDeleteEntryFunction { get; set; }
string ZomeLoadCollectionFunction { get; set; }
string ZomeLoadEntryFunction { get; set; }
string ZomeName { get; set; }
string ZomeUpdateCollectionFunction { get; set; }
string ZomeUpdateEntryFunction { get; set; }

event HoloNETEntryBaseClass.Closed OnClosed;
event HoloNETEntryBaseClass.Deleted OnDeleted;
event HoloNETEntryBaseClass.Error OnError;
event HoloNETEntryBaseClass.Initialized OnInitialized;
event HoloNETEntryBaseClass.Loaded OnLoaded;
event HoloNETEntryBaseClass.Saved OnSaved;

HoloNETShutdownEventArgs Close(ShutdownHolochainConductorsMode shutdownHolochainConductorsMode = ShutdownHolochainConductorsMode.UseConfigSettings);
Task<HoloNETShutdownEventArgs> CloseAsync(DisconnectedCallBackMode disconnectedCallBackMode = DisconnectedCallBackMode.WaitForHolochainConductorToDisconnect, ShutdownHolochainConductorsMode shutdownHolochainConductorsMode = ShutdownHolochainConductorsMode.UseConfigSettings);
ZomeFunctionCallBackEventArgs Delete();
ZomeFunctionCallBackEventArgs Delete(object customFieldToLoadByValue);
ZomeFunctionCallBackEventArgs Delete(string entryHash);
Task<ZomeFunctionCallBackEventArgs> DeleteAsync();
Task<ZomeFunctionCallBackEventArgs> DeleteAsync(object customFieldToLoadByValue);
Task<ZomeFunctionCallBackEventArgs> DeleteAsync(string entryHash);
void Initialize(bool retrieveAgentPubKeyAndDnaHashFromConductor = true, bool retrieveAgentPubKeyAndDnaHashFromSandbox = true, bool automaticallyAttemptToRetrieveFromConductorIfSandBoxFails = true, bool automaticallyAttemptToRetrieveFromSandBoxIfConductorFails = true, bool updateConfigWithAgentPubKeyAndDnaHashOnceRetrieved = true);
Task InitializeAsync(ConnectedCallBackMode connectedCallBackMode = ConnectedCallBackMode.WaitForHolochainConductorToConnect, RetrieveAgentPubKeyAndDnaHashMode retrieveAgentPubKeyAndDnaHashMode = RetrieveAgentPubKeyAndDnaHashMode.Wait, bool retrieveAgentPubKeyAndDnaHashFromConductor = true, bool retrieveAgentPubKeyAndDnaHashFromSandbox = true, bool automaticallyAttemptToRetrieveFromConductorIfSandBoxFails = true, bool automaticallyAttemptToRetrieveFromSandBoxIfConductorFails = true, bool updateConfigWithAgentPubKeyAndDnaHashOnceRetrieved = true);
ZomeFunctionCallBackEventArgs Load(bool useReflectionToMapOntoEntryDataObject = true);
ZomeFunctionCallBackEventArgs Load(object customFieldToLoadByValue, bool useReflectionToMapOntoEntryDataObject = true);
ZomeFunctionCallBackEventArgs Load(string entryHash, bool useReflectionToMapOntoEntryDataObject = true);
Task<ZomeFunctionCallBackEventArgs> LoadAsync(bool useReflectionToMapOntoEntryDataObject = true);
Task<ZomeFunctionCallBackEventArgs> LoadAsync(object customFieldToLoadByValue, bool useReflectionToMapOntoEntryDataObject = true);
Task<ZomeFunctionCallBackEventArgs> LoadAsync(string entryHash, bool useReflectionToMapOntoEntryDataObject = true);
ZomeFunctionCallBackEventArgs LoadCollection(string collectionAnchor);
Task<ZomeFunctionCallBackEventArgs> LoadCollectionAsync(string collectionAnchor);
ZomeFunctionCallBackEventArgs Save(Dictionary<string, string> customDataKeyValuePair = null, Dictionary<string, bool> holochainFieldsIsEnabledKeyValuePair = null, bool cachePropertyInfos = true);
ZomeFunctionCallBackEventArgs Save(dynamic paramsObject);
Task<ZomeFunctionCallBackEventArgs> SaveAsync(Dictionary<string, string> customDataKeyValuePair = null, Dictionary<string, bool> holochainFieldsIsEnabledKeyValuePair = null, bool cachePropertyInfos = true);
Task<ZomeFunctionCallBackEventArgs> SaveAsync(dynamic paramsObject);
Task<ReadyForZomeCallsEventArgs> WaitTillHoloNETInitializedAsync();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NextGenSoftware.Holochain.HoloNET.Client.Embedded" Version="2.1.2" />
<PackageReference Include="NextGenSoftware.Holochain.HoloNET.Client.Embedded" Version="2.1.3" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 6fcd57b

Please sign in to comment.