Skip to content

Commit e5226e5

Browse files
committed
- Added None to HolonType enum in OASIS.API.Core.
- 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.
1 parent af9c0e7 commit e5226e5

7 files changed

Lines changed: 240 additions & 34 deletions

File tree

NextGenSoftware.OASIS.API.Core/Enums/HolonType.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public enum HolonType
5050
NFT,
5151
GEONFT,
5252
OAPP,
53-
InstalledOAPP
53+
InstalledOAPP,
54+
None
5455
}
5556
}
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
24
using NextGenSoftware.OASIS.API.Core.Enums;
5+
using NextGenSoftware.OASIS.API.Core.Interfaces.STAR;
36
using NextGenSoftware.OASIS.API.ONode.Core.Enums;
7+
using NextGenSoftware.OASIS.STAR.CelestialBodies;
48

59
namespace NextGenSoftware.OASIS.API.ONode.Core.Interfaces.Objects
610
{
711
public interface IOAPPDNA
812
{
13+
ICelestialBody CelestialBody { get; set; } //optional
914
Guid CelestialBodyId { get; set; }
10-
Guid CreatedByAvtarId { get; set; }
11-
DateTime CreatedDate { get; set; }
15+
string CelestialBodyName { get; set; }
16+
HolonType CelestialBodyType { get; set; }
17+
IEnumerable<IZome> Zomes { get; set; }
18+
Guid CreatedByAvatarId { get; set; }
19+
DateTime CreatedOn { get; set; }
1220
string Description { get; set; }
1321
GenesisType GenesisType { get; set; }
1422
Guid OAPPId { get; set; }
1523
string OAPPName { get; set; }
1624
OAPPType OAPPType { get; set; }
1725
Guid PublishedByAvatarId { get; set; }
18-
DateTime PublishedDate { get; set; }
26+
DateTime PublishedOn { get; set; }
27+
bool PublishedOnSTARNET { get; set; }
1928
string Version { get; set; }
2029
}
2130
}

NextGenSoftware.OASIS.API.ONODE.Core/Managers/OAPPManager.cs

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public OASISResult<IOAPP> LoadOAPP(Guid OAPPId, ProviderType providerType = Prov
196196
return result;
197197
}
198198

199-
public async Task<OASISResult<IOAPPDNA>> CreateOAPPAsync(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, Guid avatarId, ICelestialBody celestialBody = null, ProviderType providerType = ProviderType.Default)
199+
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)
200200
{
201201
OASISResult<IOAPPDNA> result = new OASISResult<IOAPPDNA>();
202202
string errorMessage = "Error occured in OAPPManager.CreateOAPPAsync, Reason:";
@@ -209,19 +209,26 @@ public async Task<OASISResult<IOAPPDNA>> CreateOAPPAsync(string OAPPName, string
209209
CelestialBody = celestialBody, //The CelestialBody that represents the OAPP (if any).
210210
CelestialBodyId = celestialBody != null ? celestialBody.Id : Guid.Empty,
211211
OAPPType = OAPPType,
212-
GenesisType = genesisType
212+
GenesisType = genesisType,
213213
};
214214

215+
foreach (IZome zome in zomes)
216+
OAPP.Children.Add(zome);
217+
215218
OAPPDNA OAPPDNA = new OAPPDNA()
216219
{
217220
OAPPId = OAPP.Id,
218221
OAPPName = OAPPName,
219222
Description = OAPPDescription,
223+
CelestialBody = celestialBody,
220224
CelestialBodyId = celestialBody != null ? celestialBody.Id : Guid.Empty,
225+
CelestialBodyName = celestialBody != null ? celestialBody.Name : "",
226+
CelestialBodyType = celestialBody != null ? celestialBody.HolonType : HolonType.None,
227+
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.
221228
OAPPType = OAPPType,
222229
GenesisType = genesisType,
223-
CreatedByAvtarId = avatarId,
224-
CreatedDate = DateTime.Now,
230+
CreatedByAvatarId = avatarId,
231+
CreatedOn = DateTime.Now,
225232
Version = "1.0.0"
226233
};
227234

@@ -253,7 +260,7 @@ public async Task<OASISResult<IOAPPDNA>> CreateOAPPAsync(string OAPPName, string
253260
return result;
254261
}
255262

256-
public OASISResult<IOAPPDNA> CreateOAPP(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, Guid avatarId, ICelestialBody celestialBody = null, ProviderType providerType = ProviderType.Default)
263+
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)
257264
{
258265
OASISResult<IOAPPDNA> result = new OASISResult<IOAPPDNA>();
259266
string errorMessage = "Error occured in OAPPManager.CreateOAPP, Reason:";
@@ -269,16 +276,23 @@ public OASISResult<IOAPPDNA> CreateOAPP(string OAPPName, string OAPPDescription,
269276
GenesisType = genesisType
270277
};
271278

279+
foreach (IZome zome in zomes)
280+
OAPP.Children.Add(zome);
281+
272282
OAPPDNA OAPPDNA = new OAPPDNA()
273283
{
274284
OAPPId = OAPP.Id,
275285
OAPPName = OAPPName,
276286
Description = OAPPDescription,
277287
CelestialBodyId = celestialBody != null ? celestialBody.Id : Guid.Empty,
288+
CelestialBody = celestialBody,
289+
CelestialBodyName = celestialBody != null ? celestialBody.Name : "",
290+
CelestialBodyType = celestialBody != null ? celestialBody.HolonType : HolonType.None,
291+
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.
278292
OAPPType = OAPPType,
279293
GenesisType = genesisType,
280-
CreatedByAvtarId = avatarId,
281-
CreatedDate = DateTime.Now,
294+
CreatedByAvatarId = avatarId,
295+
CreatedOn = DateTime.Now,
282296
Version = "1.0.0"
283297
};
284298

@@ -364,7 +378,7 @@ public async Task<OASISResult<IOAPPDNA>> PublishOAPPAsync(IOAPPDNA OAPPDNA, stri
364378

365379
OAPPResult.Result.PublishedOn = DateTime.Now;
366380
OAPPResult.Result.PublishedByAvatarId = avatarId;
367-
OAPPDNA.PublishedDate = OAPPResult.Result.PublishedOn;
381+
OAPPDNA.PublishedOn = OAPPResult.Result.PublishedOn;
368382
OAPPDNA.PublishedByAvatarId = avatarId;
369383

370384
OASISResult<IOAPP> OAPPSaveResult = await SaveOAPPAsync(OAPPResult.Result, providerType);
@@ -400,7 +414,7 @@ public OASISResult<IOAPPDNA> PublishOAPP(IOAPPDNA OAPPDNA, string fullPathToOAPP
400414

401415
OAPPResult.Result.PublishedOn = DateTime.Now;
402416
OAPPResult.Result.PublishedByAvatarId = avatarId;
403-
OAPPDNA.PublishedDate = OAPPResult.Result.PublishedOn;
417+
OAPPDNA.PublishedOn = OAPPResult.Result.PublishedOn;
404418
OAPPDNA.PublishedByAvatarId = avatarId;
405419

406420
OASISResult<IOAPP> OAPPSaveResult = SaveOAPP(OAPPResult.Result, providerType);
@@ -456,7 +470,7 @@ public async Task<OASISResult<IOAPPDNA>> UnPublishOAPPAsync(IOAPPDNA OAPPDNA, Pr
456470

457471
if (oappResult != null && oappResult.Result != null && !oappResult.IsError)
458472
{
459-
OAPPDNA.PublishedDate = DateTime.MinValue;
473+
OAPPDNA.PublishedOn = DateTime.MinValue;
460474
OAPPDNA.PublishedByAvatarId = Guid.Empty;
461475
result.Message = "OAPP Unpublised";
462476
}
@@ -484,7 +498,7 @@ public OASISResult<IOAPPDNA> UnPublishOAPP(IOAPPDNA OAPPDNA, ProviderType provid
484498

485499
if (oappResult != null && oappResult.Result != null && !oappResult.IsError)
486500
{
487-
OAPPDNA.PublishedDate = DateTime.MinValue;
501+
OAPPDNA.PublishedOn = DateTime.MinValue;
488502
OAPPDNA.PublishedByAvatarId = Guid.Empty;
489503
result.Message = "OAPP Unpublised";
490504
}
@@ -943,21 +957,31 @@ public OASISResult<bool> IsOAPPInstalled(Guid avatarId, string OAPPName, Provide
943957

944958
private IOAPPDNA ConvertOAPPToOAPPDNA(IOAPP OAPP)
945959
{
946-
return new OAPPDNA()
960+
OAPPDNA OAPPDNA = new OAPPDNA()
947961
{
948962
CelestialBodyId = OAPP.CelestialBodyId,
949-
CreatedByAvtarId = OAPP.CreatedByAvatarId,
950-
CreatedDate = OAPP.CreatedDate,
963+
CelestialBody = OAPP.CelestialBody,
964+
CelestialBodyName = OAPP.CelestialBody != null ? OAPP.CelestialBody.Name : "",
965+
CelestialBodyType = OAPP.CelestialBody != null ? OAPP.CelestialBody.HolonType : HolonType.None,
966+
CreatedByAvatarId = OAPP.CreatedByAvatarId,
967+
CreatedOn = OAPP.CreatedDate,
951968
Description = OAPP.Description,
952969
GenesisType = OAPP.GenesisType,
953970
OAPPId = OAPP.Id,
954971
OAPPName = OAPP.Name,
955972
OAPPType = OAPP.OAPPType,
956973
PublishedByAvatarId = OAPP.PublishedByAvatarId,
957-
PublishedDate = OAPP.PublishedOn,
974+
PublishedOn = OAPP.PublishedOn,
975+
PublishedOnSTARNET = OAPP.PublishedOAPP != null,
958976
Version = OAPP.Version.ToString()
959977
};
960-
}
961978

979+
List<IZome> zomes = new List<IZome>();
980+
foreach (IHolon holon in OAPP.Children)
981+
zomes.Add((IZome)holon);
982+
983+
OAPPDNA.Zomes = zomes;
984+
return OAPPDNA;
985+
}
962986
}
963987
}

NextGenSoftware.OASIS.API.ONODE.Core/NextGenSoftware.OASIS.API.ONODE.Core.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838
</None>
3939
</ItemGroup>
4040

41+
<!--<ItemGroup>
42+
<Reference Include="NextGenSoftware.OASIS.STAR">
43+
<HintPath>..\NextGenSoftware.OASIS.STAR.DNATemplates.OAPP.Console.DLL\Runtimes\STAR ODK Runtime v2.0.2\NextGenSoftware.OASIS.STAR.dll</HintPath>
44+
</Reference>
45+
</ItemGroup>-->
46+
4147
<ItemGroup>
4248
<None Update="README.md">
4349
<PackagePath>\</PackagePath>

NextGenSoftware.OASIS.API.ONODE.Core/Objects/OAPPDNA.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System;
2+
using System.Collections.Generic;
23
using NextGenSoftware.OASIS.API.Core.Enums;
4+
using NextGenSoftware.OASIS.API.Core.Interfaces.STAR;
35
using NextGenSoftware.OASIS.API.ONode.Core.Enums;
46
using NextGenSoftware.OASIS.API.ONode.Core.Interfaces.Objects;
57

@@ -10,13 +12,18 @@ public class OAPPDNA : IOAPPDNA
1012
public Guid OAPPId { get; set; }
1113
public string OAPPName { get; set; }
1214
public string Description { get; set; }
13-
public Guid CreatedByAvtarId { get; set; }
14-
public DateTime CreatedDate { get; set; }
15+
public Guid CreatedByAvatarId { get; set; }
16+
public DateTime CreatedOn { get; set; }
1517
public Guid PublishedByAvatarId { get; set; }
16-
public DateTime PublishedDate { get; set; }
18+
public DateTime PublishedOn { get; set; }
19+
public bool PublishedOnSTARNET { get; set; }
1720
public OAPPType OAPPType { get; set; }
1821
public GenesisType GenesisType { get; set; }
22+
public ICelestialBody CelestialBody { get; set; } //optional
1923
public Guid CelestialBodyId { get; set; }
24+
public string CelestialBodyName { get; set; }
25+
public HolonType CelestialBodyType { get; set; }
26+
public IEnumerable<IZome> Zomes { get; set; }
2027
public string Version { get; set; }
2128

2229

NextGenSoftware.OASIS.STAR.CLI.Lib/STARCLI.cs

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,53 @@ public static async Task ListAllOAPPsAsync()
314314

315315
if (oapps != null && oapps.Result != null && !oapps.IsError)
316316
{
317+
CLIEngine.ShowDivider();
318+
317319
foreach (IOAPP oapp in oapps.Result)
320+
ShowOAPP(oapp);
321+
}
322+
else
323+
CLIEngine.ShowErrorMessage("No OAPP's Found.");
324+
}
325+
326+
public static async Task ListOAPPsCreatedByBeamedInAvatar()
327+
{
328+
if (STAR.BeamedInAvatar != null)
329+
{
330+
OASISResult<IEnumerable<IOAPP>> oapps = await STAR.OASISAPI.OAPPs.ListOAPPsCreatedByAvatarAsync(STAR.BeamedInAvatar.AvatarId);
331+
332+
if (oapps != null && oapps.Result != null && !oapps.IsError)
318333
{
334+
CLIEngine.ShowDivider();
319335

336+
foreach (IOAPP oapp in oapps.Result)
337+
ShowOAPP(oapp);
320338
}
339+
else
340+
CLIEngine.ShowErrorMessage("No OAPP's Found.");
321341
}
342+
else
343+
CLIEngine.ShowErrorMessage("No Avatar Is Beamed In. Please Beam In First!");
344+
}
345+
346+
public static async Task ListOAPPsInstalledForBeamedInAvatar()
347+
{
348+
if (STAR.BeamedInAvatar != null)
349+
{
350+
OASISResult<IEnumerable<IInstalledOAPP>> oapps = await STAR.OASISAPI.OAPPs.ListInstalledOAPPsAsync(STAR.BeamedInAvatar.AvatarId);
351+
352+
if (oapps != null && oapps.Result != null && !oapps.IsError)
353+
{
354+
CLIEngine.ShowDivider();
355+
356+
foreach (IInstalledOAPP oapp in oapps.Result)
357+
ShowInstalledOAPP(oapp);
358+
}
359+
else
360+
CLIEngine.ShowErrorMessage("No OAPP's Found.");
361+
}
362+
else
363+
CLIEngine.ShowErrorMessage("No Avatar Is Beamed In. Please Beam In First!");
322364
}
323365

324366
public static async Task LoadCelestialBodyAsync<T>(T celestialBody, string name) where T : ICelestialBody, new()
@@ -569,6 +611,68 @@ public static void ShowGeoNFT(IOASISGeoSpatialNFT nft)
569611
CLIEngine.ShowDivider();
570612
}
571613

614+
public static void ShowOAPP(IOAPP oapp)
615+
{
616+
CLIEngine.ShowMessage(string.Concat($"Title: ", !string.IsNullOrEmpty(oapp.Name) ? oapp.Name : "None"));
617+
CLIEngine.ShowMessage(string.Concat($"Description: ", !string.IsNullOrEmpty(oapp.Description) ? oapp.Description : "None"));
618+
CLIEngine.ShowMessage(string.Concat($"OAPP Type: ", Enum.GetName(typeof(OAPPType), oapp.OAPPType)));
619+
CLIEngine.ShowMessage(string.Concat($"Genesis Type: ", Enum.GetName(typeof(GenesisType), oapp.GenesisType)));
620+
CLIEngine.ShowMessage(string.Concat($"Celestial Body Id: ", oapp.CelestialBodyId != Guid.Empty ? oapp.CelestialBodyId : "None"));
621+
622+
if (oapp.CelestialBody != null)
623+
{
624+
CLIEngine.ShowMessage(string.Concat($"Celestial Body Name: ", oapp.CelestialBody != null ? oapp.CelestialBody.Name : "None"));
625+
CLIEngine.ShowMessage(string.Concat($"Celestial Body Type: ", Enum.GetName(typeof(HolonType), oapp.CelestialBody.HolonType)));
626+
}
627+
628+
CLIEngine.ShowMessage(string.Concat($"Created On: ", oapp.CreatedDate != DateTime.MinValue ? oapp.CreatedDate.ToString() : "None"));
629+
CLIEngine.ShowMessage(string.Concat($"Created By: ", oapp.CreatedByAvatarId != Guid.Empty ? oapp.CreatedByAvatarId.ToString() : "None"));
630+
CLIEngine.ShowMessage(string.Concat($"Published On: ", oapp.PublishedOn != DateTime.MinValue ? oapp.PublishedOn.ToString() : "None"));
631+
CLIEngine.ShowMessage(string.Concat($"Published By: ", oapp.PublishedByAvatarId != Guid.Empty ? oapp.PublishedByAvatarId.ToString() : "None"));
632+
CLIEngine.ShowMessage(string.Concat($"Published On STARNET: ", oapp.PublishedOAPP != null ? "True" : "False"));
633+
CLIEngine.ShowMessage(string.Concat($"Version: ", oapp.Version));
634+
635+
CLIEngine.ShowMessage($"Zomes: ");
636+
637+
if (oapp.CelestialBody != null)
638+
ShowZomesAndHolons(oapp.CelestialBody.CelestialBodyCore.Zomes);
639+
else
640+
ShowHolons(oapp.Children);
641+
642+
CLIEngine.ShowDivider();
643+
}
644+
645+
public static void ShowInstalledOAPP(IInstalledOAPP oapp)
646+
{
647+
CLIEngine.ShowMessage(string.Concat($"Title: ", !string.IsNullOrEmpty(oapp.OAPPDNA.OAPPName) ? oapp.Name : "None"));
648+
CLIEngine.ShowMessage(string.Concat($"Description: ", !string.IsNullOrEmpty(oapp.OAPPDNA.Description) ? oapp.Description : "None"));
649+
CLIEngine.ShowMessage(string.Concat($"OAPP Type: ", Enum.GetName(typeof(OAPPType), oapp.OAPPDNA.OAPPType)));
650+
CLIEngine.ShowMessage(string.Concat($"Genesis Type: ", Enum.GetName(typeof(GenesisType), oapp.OAPPDNA.GenesisType)));
651+
CLIEngine.ShowMessage(string.Concat($"Celestial Body Id: ", oapp.OAPPDNA.CelestialBodyId != Guid.Empty ? oapp.OAPPDNA.CelestialBodyId : "None"));
652+
653+
if (oapp.OAPPDNA.CelestialBodyId != Guid.Empty)
654+
{
655+
CLIEngine.ShowMessage(string.Concat($"Celestial Body Name: ", oapp.OAPPDNA.CelestialBodyName != null ? oapp.OAPPDNA.CelestialBodyName : "None"));
656+
CLIEngine.ShowMessage(string.Concat($"Celestial Body Type: ", Enum.GetName(typeof(HolonType), oapp.OAPPDNA.CelestialBodyType)));
657+
}
658+
659+
CLIEngine.ShowMessage(string.Concat($"Created On: ", oapp.OAPPDNA.CreatedOn != DateTime.MinValue ? oapp.OAPPDNA.CreatedOn.ToString() : "None"));
660+
CLIEngine.ShowMessage(string.Concat($"Created By: ", oapp.OAPPDNA.CreatedByAvatarId != Guid.Empty ? oapp.OAPPDNA.CreatedByAvatarId.ToString() : "None"));
661+
CLIEngine.ShowMessage(string.Concat($"Published On: ", oapp.OAPPDNA.PublishedOn != DateTime.MinValue ? oapp.OAPPDNA.PublishedOn.ToString() : "None"));
662+
CLIEngine.ShowMessage(string.Concat($"Published By: ", oapp.OAPPDNA.PublishedByAvatarId != Guid.Empty ? oapp.OAPPDNA.PublishedByAvatarId.ToString() : "None"));
663+
CLIEngine.ShowMessage(string.Concat($"Published On STARNET: ", oapp.OAPPDNA.PublishedOnSTARNET ? "True" : "False"));
664+
CLIEngine.ShowMessage(string.Concat($"Version: ", !string.IsNullOrEmpty(oapp.OAPPDNA.Version) ? oapp.OAPPDNA.Version : "None"));
665+
666+
//CLIEngine.ShowMessage($"Zomes: ");
667+
668+
//if (oapp.CelestialBody != null)
669+
// ShowZomesAndHolons(oapp.CelestialBody.CelestialBodyCore.Zomes);
670+
//else
671+
// ShowHolons(oapp.Children);
672+
673+
CLIEngine.ShowDivider();
674+
}
675+
572676
public static async Task SendNFTAsync()
573677
{
574678
//string mintWalletAddress = CLIEngine.GetValidInput("What is the original mint address?");

0 commit comments

Comments
 (0)