diff --git a/NextGenSoftware.OASIS.API.Core/Enums/HolonType.cs b/NextGenSoftware.OASIS.API.Core/Enums/HolonType.cs index bdef4411..27b87f3f 100644 --- a/NextGenSoftware.OASIS.API.Core/Enums/HolonType.cs +++ b/NextGenSoftware.OASIS.API.Core/Enums/HolonType.cs @@ -50,6 +50,7 @@ public enum HolonType NFT, GEONFT, OAPP, - InstalledOAPP + InstalledOAPP, + None } } \ No newline at end of file diff --git a/NextGenSoftware.OASIS.API.ONODE.Core/Interfaces/Objects/IOAPPDNA.cs b/NextGenSoftware.OASIS.API.ONODE.Core/Interfaces/Objects/IOAPPDNA.cs index 0c8cd57a..ec7961ab 100644 --- a/NextGenSoftware.OASIS.API.ONODE.Core/Interfaces/Objects/IOAPPDNA.cs +++ b/NextGenSoftware.OASIS.API.ONODE.Core/Interfaces/Objects/IOAPPDNA.cs @@ -1,21 +1,30 @@ using System; +using System.Collections; +using System.Collections.Generic; using NextGenSoftware.OASIS.API.Core.Enums; +using NextGenSoftware.OASIS.API.Core.Interfaces.STAR; using NextGenSoftware.OASIS.API.ONode.Core.Enums; +using NextGenSoftware.OASIS.STAR.CelestialBodies; namespace NextGenSoftware.OASIS.API.ONode.Core.Interfaces.Objects { public interface IOAPPDNA { + ICelestialBody CelestialBody { get; set; } //optional Guid CelestialBodyId { get; set; } - Guid CreatedByAvtarId { get; set; } - DateTime CreatedDate { get; set; } + string CelestialBodyName { get; set; } + HolonType CelestialBodyType { get; set; } + IEnumerable Zomes { get; set; } + Guid CreatedByAvatarId { get; set; } + DateTime CreatedOn { get; set; } string Description { get; set; } GenesisType GenesisType { get; set; } Guid OAPPId { get; set; } string OAPPName { get; set; } OAPPType OAPPType { get; set; } Guid PublishedByAvatarId { get; set; } - DateTime PublishedDate { get; set; } + DateTime PublishedOn { get; set; } + bool PublishedOnSTARNET { get; set; } string Version { get; set; } } } \ No newline at end of file diff --git a/NextGenSoftware.OASIS.API.ONODE.Core/Managers/OAPPManager.cs b/NextGenSoftware.OASIS.API.ONODE.Core/Managers/OAPPManager.cs index c2cc1294..b8926eac 100644 --- a/NextGenSoftware.OASIS.API.ONODE.Core/Managers/OAPPManager.cs +++ b/NextGenSoftware.OASIS.API.ONODE.Core/Managers/OAPPManager.cs @@ -196,7 +196,7 @@ public OASISResult LoadOAPP(Guid OAPPId, ProviderType providerType = Prov return result; } - public async Task> CreateOAPPAsync(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, Guid avatarId, ICelestialBody celestialBody = null, ProviderType providerType = ProviderType.Default) + public async Task> CreateOAPPAsync(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, Guid avatarId, ICelestialBody celestialBody = null, IEnumerable zomes = null, ProviderType providerType = ProviderType.Default) { OASISResult result = new OASISResult(); string errorMessage = "Error occured in OAPPManager.CreateOAPPAsync, Reason:"; @@ -209,19 +209,26 @@ public async Task> CreateOAPPAsync(string OAPPName, string CelestialBody = celestialBody, //The CelestialBody that represents the OAPP (if any). CelestialBodyId = celestialBody != null ? celestialBody.Id : Guid.Empty, OAPPType = OAPPType, - GenesisType = genesisType + GenesisType = genesisType, }; + foreach (IZome zome in zomes) + OAPP.Children.Add(zome); + OAPPDNA OAPPDNA = new OAPPDNA() { OAPPId = OAPP.Id, OAPPName = OAPPName, Description = OAPPDescription, + CelestialBody = celestialBody, CelestialBodyId = celestialBody != null ? celestialBody.Id : Guid.Empty, + CelestialBodyName = celestialBody != null ? celestialBody.Name : "", + CelestialBodyType = celestialBody != null ? celestialBody.HolonType : HolonType.None, + Zomes = zomes, //Can be either zomes of CelestialBody but not both (zomes are contained in CelestialBody) but if no CelestialBody is generated then this prop is used instead. OAPPType = OAPPType, GenesisType = genesisType, - CreatedByAvtarId = avatarId, - CreatedDate = DateTime.Now, + CreatedByAvatarId = avatarId, + CreatedOn = DateTime.Now, Version = "1.0.0" }; @@ -253,7 +260,7 @@ public async Task> CreateOAPPAsync(string OAPPName, string return result; } - public OASISResult CreateOAPP(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, Guid avatarId, ICelestialBody celestialBody = null, ProviderType providerType = ProviderType.Default) + public OASISResult CreateOAPP(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, Guid avatarId, ICelestialBody celestialBody = null, , IEnumerable zomes = null, ProviderType providerType = ProviderType.Default) { OASISResult result = new OASISResult(); string errorMessage = "Error occured in OAPPManager.CreateOAPP, Reason:"; @@ -269,16 +276,23 @@ public OASISResult CreateOAPP(string OAPPName, string OAPPDescription, GenesisType = genesisType }; + foreach (IZome zome in zomes) + OAPP.Children.Add(zome); + OAPPDNA OAPPDNA = new OAPPDNA() { OAPPId = OAPP.Id, OAPPName = OAPPName, Description = OAPPDescription, CelestialBodyId = celestialBody != null ? celestialBody.Id : Guid.Empty, + CelestialBody = celestialBody, + CelestialBodyName = celestialBody != null ? celestialBody.Name : "", + CelestialBodyType = celestialBody != null ? celestialBody.HolonType : HolonType.None, + Zomes = zomes, //Can be either zomes of CelestialBody but not both (zomes are contained in CelestialBody) but if no CelestialBody is generated then this prop is used instead. OAPPType = OAPPType, GenesisType = genesisType, - CreatedByAvtarId = avatarId, - CreatedDate = DateTime.Now, + CreatedByAvatarId = avatarId, + CreatedOn = DateTime.Now, Version = "1.0.0" }; @@ -364,7 +378,7 @@ public async Task> PublishOAPPAsync(IOAPPDNA OAPPDNA, stri OAPPResult.Result.PublishedOn = DateTime.Now; OAPPResult.Result.PublishedByAvatarId = avatarId; - OAPPDNA.PublishedDate = OAPPResult.Result.PublishedOn; + OAPPDNA.PublishedOn = OAPPResult.Result.PublishedOn; OAPPDNA.PublishedByAvatarId = avatarId; OASISResult OAPPSaveResult = await SaveOAPPAsync(OAPPResult.Result, providerType); @@ -400,7 +414,7 @@ public OASISResult PublishOAPP(IOAPPDNA OAPPDNA, string fullPathToOAPP OAPPResult.Result.PublishedOn = DateTime.Now; OAPPResult.Result.PublishedByAvatarId = avatarId; - OAPPDNA.PublishedDate = OAPPResult.Result.PublishedOn; + OAPPDNA.PublishedOn = OAPPResult.Result.PublishedOn; OAPPDNA.PublishedByAvatarId = avatarId; OASISResult OAPPSaveResult = SaveOAPP(OAPPResult.Result, providerType); @@ -456,7 +470,7 @@ public async Task> UnPublishOAPPAsync(IOAPPDNA OAPPDNA, Pr if (oappResult != null && oappResult.Result != null && !oappResult.IsError) { - OAPPDNA.PublishedDate = DateTime.MinValue; + OAPPDNA.PublishedOn = DateTime.MinValue; OAPPDNA.PublishedByAvatarId = Guid.Empty; result.Message = "OAPP Unpublised"; } @@ -484,7 +498,7 @@ public OASISResult UnPublishOAPP(IOAPPDNA OAPPDNA, ProviderType provid if (oappResult != null && oappResult.Result != null && !oappResult.IsError) { - OAPPDNA.PublishedDate = DateTime.MinValue; + OAPPDNA.PublishedOn = DateTime.MinValue; OAPPDNA.PublishedByAvatarId = Guid.Empty; result.Message = "OAPP Unpublised"; } @@ -943,21 +957,31 @@ public OASISResult IsOAPPInstalled(Guid avatarId, string OAPPName, Provide private IOAPPDNA ConvertOAPPToOAPPDNA(IOAPP OAPP) { - return new OAPPDNA() + OAPPDNA OAPPDNA = new OAPPDNA() { CelestialBodyId = OAPP.CelestialBodyId, - CreatedByAvtarId = OAPP.CreatedByAvatarId, - CreatedDate = OAPP.CreatedDate, + CelestialBody = OAPP.CelestialBody, + CelestialBodyName = OAPP.CelestialBody != null ? OAPP.CelestialBody.Name : "", + CelestialBodyType = OAPP.CelestialBody != null ? OAPP.CelestialBody.HolonType : HolonType.None, + CreatedByAvatarId = OAPP.CreatedByAvatarId, + CreatedOn = OAPP.CreatedDate, Description = OAPP.Description, GenesisType = OAPP.GenesisType, OAPPId = OAPP.Id, OAPPName = OAPP.Name, OAPPType = OAPP.OAPPType, PublishedByAvatarId = OAPP.PublishedByAvatarId, - PublishedDate = OAPP.PublishedOn, + PublishedOn = OAPP.PublishedOn, + PublishedOnSTARNET = OAPP.PublishedOAPP != null, Version = OAPP.Version.ToString() }; - } + List zomes = new List(); + foreach (IHolon holon in OAPP.Children) + zomes.Add((IZome)holon); + + OAPPDNA.Zomes = zomes; + return OAPPDNA; + } } } \ No newline at end of file diff --git a/NextGenSoftware.OASIS.API.ONODE.Core/NextGenSoftware.OASIS.API.ONODE.Core.csproj b/NextGenSoftware.OASIS.API.ONODE.Core/NextGenSoftware.OASIS.API.ONODE.Core.csproj index c5387087..cd3f8c71 100644 --- a/NextGenSoftware.OASIS.API.ONODE.Core/NextGenSoftware.OASIS.API.ONODE.Core.csproj +++ b/NextGenSoftware.OASIS.API.ONODE.Core/NextGenSoftware.OASIS.API.ONODE.Core.csproj @@ -38,6 +38,12 @@ + + \ diff --git a/NextGenSoftware.OASIS.API.ONODE.Core/Objects/OAPPDNA.cs b/NextGenSoftware.OASIS.API.ONODE.Core/Objects/OAPPDNA.cs index 50d6b7eb..806960e7 100644 --- a/NextGenSoftware.OASIS.API.ONODE.Core/Objects/OAPPDNA.cs +++ b/NextGenSoftware.OASIS.API.ONODE.Core/Objects/OAPPDNA.cs @@ -1,5 +1,7 @@ using System; +using System.Collections.Generic; using NextGenSoftware.OASIS.API.Core.Enums; +using NextGenSoftware.OASIS.API.Core.Interfaces.STAR; using NextGenSoftware.OASIS.API.ONode.Core.Enums; using NextGenSoftware.OASIS.API.ONode.Core.Interfaces.Objects; @@ -10,13 +12,18 @@ public class OAPPDNA : IOAPPDNA public Guid OAPPId { get; set; } public string OAPPName { get; set; } public string Description { get; set; } - public Guid CreatedByAvtarId { get; set; } - public DateTime CreatedDate { get; set; } + public Guid CreatedByAvatarId { get; set; } + public DateTime CreatedOn { get; set; } public Guid PublishedByAvatarId { get; set; } - public DateTime PublishedDate { get; set; } + public DateTime PublishedOn { get; set; } + public bool PublishedOnSTARNET { get; set; } public OAPPType OAPPType { get; set; } public GenesisType GenesisType { get; set; } + public ICelestialBody CelestialBody { get; set; } //optional public Guid CelestialBodyId { get; set; } + public string CelestialBodyName { get; set; } + public HolonType CelestialBodyType { get; set; } + public IEnumerable Zomes { get; set; } public string Version { get; set; } diff --git a/NextGenSoftware.OASIS.STAR.CLI.Lib/STARCLI.cs b/NextGenSoftware.OASIS.STAR.CLI.Lib/STARCLI.cs index 8a2c0ddf..704c0500 100644 --- a/NextGenSoftware.OASIS.STAR.CLI.Lib/STARCLI.cs +++ b/NextGenSoftware.OASIS.STAR.CLI.Lib/STARCLI.cs @@ -314,11 +314,53 @@ public static async Task ListAllOAPPsAsync() if (oapps != null && oapps.Result != null && !oapps.IsError) { + CLIEngine.ShowDivider(); + foreach (IOAPP oapp in oapps.Result) + ShowOAPP(oapp); + } + else + CLIEngine.ShowErrorMessage("No OAPP's Found."); + } + + public static async Task ListOAPPsCreatedByBeamedInAvatar() + { + if (STAR.BeamedInAvatar != null) + { + OASISResult> oapps = await STAR.OASISAPI.OAPPs.ListOAPPsCreatedByAvatarAsync(STAR.BeamedInAvatar.AvatarId); + + if (oapps != null && oapps.Result != null && !oapps.IsError) { + CLIEngine.ShowDivider(); + foreach (IOAPP oapp in oapps.Result) + ShowOAPP(oapp); } + else + CLIEngine.ShowErrorMessage("No OAPP's Found."); } + else + CLIEngine.ShowErrorMessage("No Avatar Is Beamed In. Please Beam In First!"); + } + + public static async Task ListOAPPsInstalledForBeamedInAvatar() + { + if (STAR.BeamedInAvatar != null) + { + OASISResult> oapps = await STAR.OASISAPI.OAPPs.ListInstalledOAPPsAsync(STAR.BeamedInAvatar.AvatarId); + + if (oapps != null && oapps.Result != null && !oapps.IsError) + { + CLIEngine.ShowDivider(); + + foreach (IInstalledOAPP oapp in oapps.Result) + ShowInstalledOAPP(oapp); + } + else + CLIEngine.ShowErrorMessage("No OAPP's Found."); + } + else + CLIEngine.ShowErrorMessage("No Avatar Is Beamed In. Please Beam In First!"); } public static async Task LoadCelestialBodyAsync(T celestialBody, string name) where T : ICelestialBody, new() @@ -569,6 +611,68 @@ public static void ShowGeoNFT(IOASISGeoSpatialNFT nft) CLIEngine.ShowDivider(); } + public static void ShowOAPP(IOAPP oapp) + { + CLIEngine.ShowMessage(string.Concat($"Title: ", !string.IsNullOrEmpty(oapp.Name) ? oapp.Name : "None")); + CLIEngine.ShowMessage(string.Concat($"Description: ", !string.IsNullOrEmpty(oapp.Description) ? oapp.Description : "None")); + CLIEngine.ShowMessage(string.Concat($"OAPP Type: ", Enum.GetName(typeof(OAPPType), oapp.OAPPType))); + CLIEngine.ShowMessage(string.Concat($"Genesis Type: ", Enum.GetName(typeof(GenesisType), oapp.GenesisType))); + CLIEngine.ShowMessage(string.Concat($"Celestial Body Id: ", oapp.CelestialBodyId != Guid.Empty ? oapp.CelestialBodyId : "None")); + + if (oapp.CelestialBody != null) + { + CLIEngine.ShowMessage(string.Concat($"Celestial Body Name: ", oapp.CelestialBody != null ? oapp.CelestialBody.Name : "None")); + CLIEngine.ShowMessage(string.Concat($"Celestial Body Type: ", Enum.GetName(typeof(HolonType), oapp.CelestialBody.HolonType))); + } + + CLIEngine.ShowMessage(string.Concat($"Created On: ", oapp.CreatedDate != DateTime.MinValue ? oapp.CreatedDate.ToString() : "None")); + CLIEngine.ShowMessage(string.Concat($"Created By: ", oapp.CreatedByAvatarId != Guid.Empty ? oapp.CreatedByAvatarId.ToString() : "None")); + CLIEngine.ShowMessage(string.Concat($"Published On: ", oapp.PublishedOn != DateTime.MinValue ? oapp.PublishedOn.ToString() : "None")); + CLIEngine.ShowMessage(string.Concat($"Published By: ", oapp.PublishedByAvatarId != Guid.Empty ? oapp.PublishedByAvatarId.ToString() : "None")); + CLIEngine.ShowMessage(string.Concat($"Published On STARNET: ", oapp.PublishedOAPP != null ? "True" : "False")); + CLIEngine.ShowMessage(string.Concat($"Version: ", oapp.Version)); + + CLIEngine.ShowMessage($"Zomes: "); + + if (oapp.CelestialBody != null) + ShowZomesAndHolons(oapp.CelestialBody.CelestialBodyCore.Zomes); + else + ShowHolons(oapp.Children); + + CLIEngine.ShowDivider(); + } + + public static void ShowInstalledOAPP(IInstalledOAPP oapp) + { + CLIEngine.ShowMessage(string.Concat($"Title: ", !string.IsNullOrEmpty(oapp.OAPPDNA.OAPPName) ? oapp.Name : "None")); + CLIEngine.ShowMessage(string.Concat($"Description: ", !string.IsNullOrEmpty(oapp.OAPPDNA.Description) ? oapp.Description : "None")); + CLIEngine.ShowMessage(string.Concat($"OAPP Type: ", Enum.GetName(typeof(OAPPType), oapp.OAPPDNA.OAPPType))); + CLIEngine.ShowMessage(string.Concat($"Genesis Type: ", Enum.GetName(typeof(GenesisType), oapp.OAPPDNA.GenesisType))); + CLIEngine.ShowMessage(string.Concat($"Celestial Body Id: ", oapp.OAPPDNA.CelestialBodyId != Guid.Empty ? oapp.OAPPDNA.CelestialBodyId : "None")); + + if (oapp.OAPPDNA.CelestialBodyId != Guid.Empty) + { + CLIEngine.ShowMessage(string.Concat($"Celestial Body Name: ", oapp.OAPPDNA.CelestialBodyName != null ? oapp.OAPPDNA.CelestialBodyName : "None")); + CLIEngine.ShowMessage(string.Concat($"Celestial Body Type: ", Enum.GetName(typeof(HolonType), oapp.OAPPDNA.CelestialBodyType))); + } + + CLIEngine.ShowMessage(string.Concat($"Created On: ", oapp.OAPPDNA.CreatedOn != DateTime.MinValue ? oapp.OAPPDNA.CreatedOn.ToString() : "None")); + CLIEngine.ShowMessage(string.Concat($"Created By: ", oapp.OAPPDNA.CreatedByAvatarId != Guid.Empty ? oapp.OAPPDNA.CreatedByAvatarId.ToString() : "None")); + CLIEngine.ShowMessage(string.Concat($"Published On: ", oapp.OAPPDNA.PublishedOn != DateTime.MinValue ? oapp.OAPPDNA.PublishedOn.ToString() : "None")); + CLIEngine.ShowMessage(string.Concat($"Published By: ", oapp.OAPPDNA.PublishedByAvatarId != Guid.Empty ? oapp.OAPPDNA.PublishedByAvatarId.ToString() : "None")); + CLIEngine.ShowMessage(string.Concat($"Published On STARNET: ", oapp.OAPPDNA.PublishedOnSTARNET ? "True" : "False")); + CLIEngine.ShowMessage(string.Concat($"Version: ", !string.IsNullOrEmpty(oapp.OAPPDNA.Version) ? oapp.OAPPDNA.Version : "None")); + + //CLIEngine.ShowMessage($"Zomes: "); + + //if (oapp.CelestialBody != null) + // ShowZomesAndHolons(oapp.CelestialBody.CelestialBodyCore.Zomes); + //else + // ShowHolons(oapp.Children); + + CLIEngine.ShowDivider(); + } + public static async Task SendNFTAsync() { //string mintWalletAddress = CLIEngine.GetValidInput("What is the original mint address?"); diff --git a/NextGenSoftware.OASIS.STAR.CLI/Program.cs b/NextGenSoftware.OASIS.STAR.CLI/Program.cs index 33fb21ee..f89f645c 100644 --- a/NextGenSoftware.OASIS.STAR.CLI/Program.cs +++ b/NextGenSoftware.OASIS.STAR.CLI/Program.cs @@ -482,39 +482,91 @@ private static async Task ReadyPlayerOne() case "listoapps": { - await STARCLI.ListAllOAPPsAsync(); + if (CLIEngine.GetConfirmation("Do you want to list all OAPPs? Press 'Y' to list all OAPPs or 'N' to list only the OAPPs you have created.")) + await STARCLI.ListAllOAPPsAsync(); + else + await STARCLI.ListOAPPsCreatedByBeamedInAvatar(); + } break; + //case "listmyoapps": + // { + // await STARCLI.ListOAPPsCreatedByBeamedInAvatar(); + // } + // break; + + case "listinstalledoapps": + { + await STARCLI.ListOAPPsInstalledForBeamedInAvatar(); + } + break; + case "listhapps": { CLIEngine.ShowMessage("Coming soon..."); } break; + //case "listmyhapps": + // { + // CLIEngine.ShowMessage("Coming soon..."); + // } + // break; + + case "listinstalledhapps": + { + CLIEngine.ShowMessage("Coming soon..."); + } + break; + case " listcelestialspaces": { CLIEngine.ShowMessage("Coming soon..."); } break; + //case " listmycelestialspaces": + // { + // CLIEngine.ShowMessage("Coming soon..."); + // } + // break; + case "listcelestialbodies": { CLIEngine.ShowMessage("Coming soon..."); } break; + //case "listmycelestialbodies": + // { + // CLIEngine.ShowMessage("Coming soon..."); + // } + // break; + case "listzomes": { CLIEngine.ShowMessage("Coming soon..."); } break; + //case "listmyzomes": + // { + // CLIEngine.ShowMessage("Coming soon..."); + // } + // break; + case "listholons": { CLIEngine.ShowMessage("Coming soon..."); } break; + //case "listmyholons": + // { + // CLIEngine.ShowMessage("Coming soon..."); + // } + // break; + case "showoapp": { CLIEngine.ShowMessage("Coming soon..."); @@ -2475,9 +2527,9 @@ private static void EnableOrDisableAutoProviderList(Func