Skip to content

Commit

Permalink
- Added None to HolonType enum in OASIS.API.Core.
Browse files Browse the repository at this point in the history
- Added CelestialBodyName, CelestialBodyType, CelestialBody, PublishedOnSTARNET & Zomes to IOAPPDNA in OASIS.API.ONODE.Core and renamed CreatedDate to CreatedOn & renamed PublishedDate to PublishedOn.

- Updated CreateOAPPAsync, CreateOAPP, PublishOAPPAsync, PublishOAPP, UnPublishOAPPAsync, UnPublishOAPP & ConvertOAPPToOAPPDNA in OASIS.API.ONODE.Core.

- Finished implementing listoapps & listinstalledoapps command hooks in ReadPlayerOne function in STAR CLI.

- Finished implementing ListAllOAPPsAsync, ListOAPPsCreatedByBeamedInAvatar & ListOAPPsInstalledForBeamedInAvatar in STAR.CLI.Lib.
  • Loading branch information
dellams committed Sep 10, 2024
1 parent 846f4bf commit 772984d
Show file tree
Hide file tree
Showing 7 changed files with 240 additions and 34 deletions.
3 changes: 2 additions & 1 deletion NextGenSoftware.OASIS.API.Core/Enums/HolonType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public enum HolonType
NFT,
GEONFT,
OAPP,
InstalledOAPP
InstalledOAPP,
None
}
}
Original file line number Diff line number Diff line change
@@ -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<IZome> 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; }
}
}
56 changes: 40 additions & 16 deletions NextGenSoftware.OASIS.API.ONODE.Core/Managers/OAPPManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public OASISResult<IOAPP> LoadOAPP(Guid OAPPId, ProviderType providerType = Prov
return result;
}

public async Task<OASISResult<IOAPPDNA>> CreateOAPPAsync(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, Guid avatarId, ICelestialBody celestialBody = null, ProviderType providerType = ProviderType.Default)
public async Task<OASISResult<IOAPPDNA>> CreateOAPPAsync(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, Guid avatarId, ICelestialBody celestialBody = null, IEnumerable<IZome> zomes = null, ProviderType providerType = ProviderType.Default)
{
OASISResult<IOAPPDNA> result = new OASISResult<IOAPPDNA>();
string errorMessage = "Error occured in OAPPManager.CreateOAPPAsync, Reason:";
Expand All @@ -209,19 +209,26 @@ public async Task<OASISResult<IOAPPDNA>> 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"
};

Expand Down Expand Up @@ -253,7 +260,7 @@ public async Task<OASISResult<IOAPPDNA>> CreateOAPPAsync(string OAPPName, string
return result;
}

public OASISResult<IOAPPDNA> CreateOAPP(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, Guid avatarId, ICelestialBody celestialBody = null, ProviderType providerType = ProviderType.Default)
public OASISResult<IOAPPDNA> CreateOAPP(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, Guid avatarId, ICelestialBody celestialBody = null, , IEnumerable<IZome> zomes = null, ProviderType providerType = ProviderType.Default)
{
OASISResult<IOAPPDNA> result = new OASISResult<IOAPPDNA>();
string errorMessage = "Error occured in OAPPManager.CreateOAPP, Reason:";
Expand All @@ -269,16 +276,23 @@ public OASISResult<IOAPPDNA> 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"
};

Expand Down Expand Up @@ -364,7 +378,7 @@ public async Task<OASISResult<IOAPPDNA>> 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<IOAPP> OAPPSaveResult = await SaveOAPPAsync(OAPPResult.Result, providerType);
Expand Down Expand Up @@ -400,7 +414,7 @@ public OASISResult<IOAPPDNA> 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<IOAPP> OAPPSaveResult = SaveOAPP(OAPPResult.Result, providerType);
Expand Down Expand Up @@ -456,7 +470,7 @@ public async Task<OASISResult<IOAPPDNA>> 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";
}
Expand Down Expand Up @@ -484,7 +498,7 @@ public OASISResult<IOAPPDNA> 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";
}
Expand Down Expand Up @@ -943,21 +957,31 @@ public OASISResult<bool> 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<IZome> zomes = new List<IZome>();
foreach (IHolon holon in OAPP.Children)
zomes.Add((IZome)holon);

OAPPDNA.Zomes = zomes;
return OAPPDNA;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
</None>
</ItemGroup>

<!--<ItemGroup>
<Reference Include="NextGenSoftware.OASIS.STAR">
<HintPath>..\NextGenSoftware.OASIS.STAR.DNATemplates.OAPP.Console.DLL\Runtimes\STAR ODK Runtime v2.0.2\NextGenSoftware.OASIS.STAR.dll</HintPath>
</Reference>
</ItemGroup>-->

<ItemGroup>
<None Update="README.md">
<PackagePath>\</PackagePath>
Expand Down
13 changes: 10 additions & 3 deletions NextGenSoftware.OASIS.API.ONODE.Core/Objects/OAPPDNA.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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<IZome> Zomes { get; set; }
public string Version { get; set; }


Expand Down
104 changes: 104 additions & 0 deletions NextGenSoftware.OASIS.STAR.CLI.Lib/STARCLI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IEnumerable<IOAPP>> 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<IEnumerable<IInstalledOAPP>> 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>(T celestialBody, string name) where T : ICelestialBody, new()
Expand Down Expand Up @@ -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?");
Expand Down
Loading

0 comments on commit 772984d

Please sign in to comment.