Skip to content

Commit

Permalink
Bug fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
barnstee committed Mar 21, 2022
1 parent c5e7921 commit 1a4f249
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 60 deletions.
6 changes: 3 additions & 3 deletions UACloudLibraryServer/GraphQL/GraphTypes/AddressSpaceType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* ======================================================================*/

namespace UACloudLibrary
{
{
using GraphQL.Types;

public class AddressSpaceType : ObjectGraphType<AddressSpace>
Expand All @@ -43,8 +43,8 @@ public AddressSpaceType()
Field(e => e.SupportedLocales);
Field(e => e.Keywords);
Field(e => e.License);
Field(e => e.Contributor);
Field(e => e.Category);
Field(e => e.Contributor, type: typeof(OrganisationType));
Field(e => e.Category, type: typeof(CategoryType));
Field(e => e.LicenseUrl);
Field(e => e.DocumentationUrl);
Field(e => e.IconUrl);
Expand Down
139 changes: 82 additions & 57 deletions UACloudLibraryServer/GraphQL/UaCloudLibDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,50 +79,58 @@ public Task<List<AddressSpace>> GetAdressSpaceTypes()
List<AddressSpace> result = new List<AddressSpace>();
foreach (string name in names)
{
if (uint.TryParse(name, out uint nodesetId))
try
{
AddressSpace addressSpace = new AddressSpace();

addressSpace.Description = _database.RetrieveMetaData(nodesetId, "description");
addressSpace.Version = _database.RetrieveMetaData(nodesetId, "version");
addressSpace.Title = _database.RetrieveMetaData(nodesetId, "nodesettitle");
addressSpace.CopyrightText = _database.RetrieveMetaData(nodesetId, "copyright");
addressSpace.DocumentationUrl = CreateUri(_database.RetrieveMetaData(nodesetId, "documentationurl"));
addressSpace.PurchasingInformationUrl = CreateUri(_database.RetrieveMetaData(nodesetId, "purchasinginfo"));
addressSpace.IconUrl = CreateUri(_database.RetrieveMetaData(nodesetId, "iconurl"));
addressSpace.LicenseUrl = CreateUri(_database.RetrieveMetaData(nodesetId, "licenseurl"));
addressSpace.ReleaseNotesUrl = CreateUri(_database.RetrieveMetaData(nodesetId, "releasenotes"));
addressSpace.TestSpecificationUrl = CreateUri(_database.RetrieveMetaData(nodesetId, "testspecification"));
addressSpace.NumberOfDownloads = Convert.ToUInt32(_database.RetrieveMetaData(nodesetId, "numdownloads"));
addressSpace.Keywords = _database.RetrieveMetaData(nodesetId, "keywords").Split(',');
addressSpace.SupportedLocales = _database.RetrieveMetaData(nodesetId, "locales").Split(',');
switch (_database.RetrieveMetaData(nodesetId, "license"))
string[] tuple = name.Split(',');
if (uint.TryParse(tuple[1], out uint nodesetId))
{
case "MIT":
addressSpace.License = AddressSpaceLicense.MIT;
break;
case "ApacheLicense20":
addressSpace.License = AddressSpaceLicense.ApacheLicense20;
break;
case "Custom":
addressSpace.License = AddressSpaceLicense.Custom;
break;
default:
addressSpace.License = AddressSpaceLicense.Custom;
break;
}
AddressSpace addressSpace = new AddressSpace();

addressSpace.Description = _database.RetrieveMetaData(nodesetId, "description");
addressSpace.Version = _database.RetrieveMetaData(nodesetId, "version");
addressSpace.Title = _database.RetrieveMetaData(nodesetId, "nodesettitle");
addressSpace.CopyrightText = _database.RetrieveMetaData(nodesetId, "copyright");
addressSpace.DocumentationUrl = CreateUri(_database.RetrieveMetaData(nodesetId, "documentationurl"));
addressSpace.PurchasingInformationUrl = CreateUri(_database.RetrieveMetaData(nodesetId, "purchasinginfo"));
addressSpace.IconUrl = CreateUri(_database.RetrieveMetaData(nodesetId, "iconurl"));
addressSpace.LicenseUrl = CreateUri(_database.RetrieveMetaData(nodesetId, "licenseurl"));
addressSpace.ReleaseNotesUrl = CreateUri(_database.RetrieveMetaData(nodesetId, "releasenotes"));
addressSpace.TestSpecificationUrl = CreateUri(_database.RetrieveMetaData(nodesetId, "testspecification"));
addressSpace.NumberOfDownloads = Convert.ToUInt32(_database.RetrieveMetaData(nodesetId, "numdownloads"));
addressSpace.Keywords = _database.RetrieveMetaData(nodesetId, "keywords").Split(',');
addressSpace.SupportedLocales = _database.RetrieveMetaData(nodesetId, "locales").Split(',');
switch (_database.RetrieveMetaData(nodesetId, "license"))
{
case "MIT":
addressSpace.License = AddressSpaceLicense.MIT;
break;
case "ApacheLicense20":
addressSpace.License = AddressSpaceLicense.ApacheLicense20;
break;
case "Custom":
addressSpace.License = AddressSpaceLicense.Custom;
break;
default:
addressSpace.License = AddressSpaceLicense.Custom;
break;
}

addressSpace.Contributor.ContactEmail = _database.RetrieveMetaData(nodesetId, "orgcontact");
addressSpace.Contributor.Name = _database.RetrieveMetaData(nodesetId, "orgname");
addressSpace.Contributor.Description = _database.RetrieveMetaData(nodesetId, "orgdescription");
addressSpace.Contributor.Website = CreateUri(_database.RetrieveMetaData(nodesetId, "orgwebsite"));
addressSpace.Contributor.LogoUrl = CreateUri(_database.RetrieveMetaData(nodesetId, "orglogo"));
addressSpace.Contributor.ContactEmail = _database.RetrieveMetaData(nodesetId, "orgcontact");
addressSpace.Contributor.Name = _database.RetrieveMetaData(nodesetId, "orgname");
addressSpace.Contributor.Description = _database.RetrieveMetaData(nodesetId, "orgdescription");
addressSpace.Contributor.Website = CreateUri(_database.RetrieveMetaData(nodesetId, "orgwebsite"));
addressSpace.Contributor.LogoUrl = CreateUri(_database.RetrieveMetaData(nodesetId, "orglogo"));

addressSpace.Category.Name = _database.RetrieveMetaData(nodesetId, "addressspacename");
addressSpace.Category.Description = _database.RetrieveMetaData(nodesetId, "addressspacedescription");
addressSpace.Category.IconUrl = CreateUri(_database.RetrieveMetaData(nodesetId, "addressspaceiconurl"));
addressSpace.Category.Name = _database.RetrieveMetaData(nodesetId, "addressspacename");
addressSpace.Category.Description = _database.RetrieveMetaData(nodesetId, "addressspacedescription");
addressSpace.Category.IconUrl = CreateUri(_database.RetrieveMetaData(nodesetId, "addressspaceiconurl"));

result.Add(addressSpace);
result.Add(addressSpace);
}
}
catch (Exception)
{
// ignore this entity
}
}

Expand All @@ -136,15 +144,23 @@ public Task<List<AddressSpaceCategory>> GetCategoryTypes()
List<AddressSpaceCategory> result = new List<AddressSpaceCategory>();
foreach (string name in names)
{
if (uint.TryParse(name, out uint nodesetId))
try
{
AddressSpaceCategory category = new AddressSpaceCategory();
string[] tuple = name.Split(',');
if (uint.TryParse(tuple[1], out uint nodesetId))
{
AddressSpaceCategory category = new AddressSpaceCategory();

category.Name = _database.RetrieveMetaData(nodesetId, "addressspacename");
category.Description = _database.RetrieveMetaData(nodesetId, "addressspacedescription");
category.IconUrl = CreateUri(_database.RetrieveMetaData(nodesetId, "addressspaceiconurl"));
category.Name = tuple[0];
category.Description = _database.RetrieveMetaData(nodesetId, "addressspacedescription");
category.IconUrl = CreateUri(_database.RetrieveMetaData(nodesetId, "addressspaceiconurl"));

result.Add(category);
result.Add(category);
}
}
catch (Exception)
{
// ignire this entity
}
}

Expand All @@ -158,17 +174,25 @@ public Task<List<Organisation>> GetOrganisationTypes()
List<Organisation> result = new List<Organisation>();
foreach (string name in names)
{
if (uint.TryParse(name, out uint nodesetId))
try
{
Organisation organisation = new Organisation();
string[] tuple = name.Split(',');
if (uint.TryParse(tuple[1], out uint nodesetId))
{
Organisation organisation = new Organisation();

organisation.ContactEmail = _database.RetrieveMetaData(nodesetId, "orgcontact");
organisation.Name = _database.RetrieveMetaData(nodesetId, "orgname");
organisation.Description = _database.RetrieveMetaData(nodesetId, "orgdescription");
organisation.Website = CreateUri(_database.RetrieveMetaData(nodesetId, "orgwebsite"));
organisation.LogoUrl = CreateUri(_database.RetrieveMetaData(nodesetId, "orglogo"));
organisation.ContactEmail = _database.RetrieveMetaData(nodesetId, "orgcontact");
organisation.Name = _database.RetrieveMetaData(nodesetId, "orgname");
organisation.Description = _database.RetrieveMetaData(nodesetId, "orgdescription");
organisation.Website = CreateUri(_database.RetrieveMetaData(nodesetId, "orgwebsite"));
organisation.LogoUrl = CreateUri(_database.RetrieveMetaData(nodesetId, "orglogo"));

result.Add(organisation);
result.Add(organisation);
}
}
catch (Exception)
{
// ignore this entity
}
}

Expand All @@ -177,13 +201,14 @@ public Task<List<Organisation>> GetOrganisationTypes()

private Uri CreateUri(string uri)
{
Uri result = null;
if (!string.IsNullOrEmpty(uri))
{
result = new Uri(uri);
return new Uri(uri);
}
else
{
return null;
}

return result;
}
}
}

0 comments on commit 1a4f249

Please sign in to comment.