diff --git a/mohaymen-codestar-Team02.sln.DotSettings b/mohaymen-codestar-Team02.sln.DotSettings new file mode 100644 index 0000000..7ff5b6c --- /dev/null +++ b/mohaymen-codestar-Team02.sln.DotSettings @@ -0,0 +1,2 @@ + + True \ No newline at end of file diff --git a/mohaymen-codestar-Team02/Controllers/DataAdminController.cs b/mohaymen-codestar-Team02/Controllers/DataAdminController.cs index 375224e..0529ce9 100644 --- a/mohaymen-codestar-Team02/Controllers/DataAdminController.cs +++ b/mohaymen-codestar-Team02/Controllers/DataAdminController.cs @@ -10,15 +10,15 @@ namespace mohaymen_codestar_Team02.Controllers; [ApiController] -[Authorize(Roles = nameof(RoleType.DataAdmin))] +[Authorize] public class DataAdminController : ControllerBase { private readonly IDataAdminService _dataAdminService; private readonly IFileReader _fileReader; - private readonly IDisplayDataService _dataService; + private readonly IGraphService _graphService; - public DataAdminController(IDataAdminService dataAdminService, IFileReader fileReader, - IDisplayDataService dataService) + public DataAdminController(IDataAdminService dataAdminService, + IFileReader fileReader) { _dataAdminService = dataAdminService; _fileReader = fileReader; @@ -33,8 +33,7 @@ public async Task StoreNewDataSet([FromForm] StoreDataDto storeDa var edgeFile = _fileReader.Read(storeDataDto.EdgeFile); var vertexFile = _fileReader.Read(storeDataDto.VertexFile); var response = await _dataAdminService.StoreData(edgeFile, vertexFile, storeDataDto.DataName, - Path.GetFileName(storeDataDto.EdgeFile.FileName), Path.GetFileName(storeDataDto.VertexFile.FileName), - storeDataDto.CreatorUserName); + Path.GetFileName(storeDataDto.EdgeFile.FileName), Path.GetFileName(storeDataDto.VertexFile.FileName)); return StatusCode((int)response.Type, response); } catch (FormatException e) @@ -44,8 +43,10 @@ public async Task StoreNewDataSet([FromForm] StoreDataDto storeDa } [HttpGet("DataSets")] - public void GetDataSetsList() + public IActionResult GetDataSetsList() { + var response = _dataAdminService.DisplayDataSet(); + return StatusCode((int)response.Type, response); } [HttpGet("DataSets/{dataSetName}")] @@ -61,15 +62,17 @@ await _dataAdminService.DisplayGeraphData(dataSetName, sourceEdgeIdentifierField } - [HttpGet("DataSets/{dataSetName}/Vertices/{vertexId}")] - public async Task DisplayVertexDetails(string datasetName, int vertexId) + [HttpGet("DataSets/Vertices/{objectId}")] + public async Task DisplayVertexDetails(string objectId) { - return BadRequest(); + var respond = _dataAdminService.GetVertexDetail(objectId); + return StatusCode((int)respond.Type, respond); } - [HttpGet("DataSets/{dataSetName}/Edges/{edgeId}")] - public async Task DisplayEdgeDetails(string datasetName, int edgeId) + [HttpGet("DataSets/Edges/{objectId}")] + public async Task DisplayEdgeDetails(string objectId) { - return BadRequest(); + var respond = _dataAdminService.GetEdgeDetail(objectId); + return StatusCode((int)respond.Type, respond); } } \ No newline at end of file diff --git a/mohaymen-codestar-Team02/Data/Resources.Designer.cs b/mohaymen-codestar-Team02/Data/Resources.Designer.cs index 9e3a71d..3740723 100644 --- a/mohaymen-codestar-Team02/Data/Resources.Designer.cs +++ b/mohaymen-codestar-Team02/Data/Resources.Designer.cs @@ -1,6 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -104,6 +105,15 @@ internal static string GetPermissionsSuccessfuly { } } + /// + /// Looks up a localized string similar to GraphFetchedSuccessfully. + /// + internal static string GraphFetchedSuccessfully { + get { + return ResourceManager.GetString("GraphFetchedSuccessfully", resourceCulture); + } + } + /// /// Looks up a localized string similar to InvalidInput. /// diff --git a/mohaymen-codestar-Team02/Data/Resources.resx b/mohaymen-codestar-Team02/Data/Resources.resx index c253cc7..0c7f2b9 100644 --- a/mohaymen-codestar-Team02/Data/Resources.resx +++ b/mohaymen-codestar-Team02/Data/Resources.resx @@ -97,4 +97,7 @@ Authorized Message + + GraphFetchedSuccessfully + \ No newline at end of file diff --git a/mohaymen-codestar-Team02/Dto/GetDataGroupDto.cs b/mohaymen-codestar-Team02/Dto/GetDataGroupDto.cs new file mode 100644 index 0000000..95d6523 --- /dev/null +++ b/mohaymen-codestar-Team02/Dto/GetDataGroupDto.cs @@ -0,0 +1,15 @@ +using mohaymen_codestar_Team02.Models.EdgeEAV; +using mohaymen_codestar_Team02.Models.VertexEAV; + +namespace mohaymen_codestar_Team02.Dto; + +public class GetDataGroupDto +{ + public string Name { get; set; } + + public DateTime CreateAt { get; set; } = DateTime.UtcNow; + public DateTime UpdateAt { get; set; } = DateTime.UtcNow; + + public virtual GetEdgeEntityDto EdgeEntity { get; set; } + public virtual GetVertexEntityDto VertexEntity { get; set; } +} \ No newline at end of file diff --git a/mohaymen-codestar-Team02/Dto/GetEdgeEntityDto.cs b/mohaymen-codestar-Team02/Dto/GetEdgeEntityDto.cs new file mode 100644 index 0000000..e8e11ec --- /dev/null +++ b/mohaymen-codestar-Team02/Dto/GetEdgeEntityDto.cs @@ -0,0 +1,6 @@ +namespace mohaymen_codestar_Team02.Dto; + +public class GetEdgeEntityDto +{ + public string Name { get; set; } +} \ No newline at end of file diff --git a/mohaymen-codestar-Team02/Dto/GetGraphDto.cs b/mohaymen-codestar-Team02/Dto/GetGraphDto.cs deleted file mode 100644 index 40dade6..0000000 --- a/mohaymen-codestar-Team02/Dto/GetGraphDto.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace mohaymen_codestar_Team02.Dto; - -public class GetGraphDto -{ - public string databaseName; - public string sourceEdgeIdentifierFieldName; - public string destinationEdgeIdentifierFieldName; - public string vertexIdentifierFieldName; -} \ No newline at end of file diff --git a/mohaymen-codestar-Team02/Dto/GetVertexEntityDto.cs b/mohaymen-codestar-Team02/Dto/GetVertexEntityDto.cs new file mode 100644 index 0000000..2efc85c --- /dev/null +++ b/mohaymen-codestar-Team02/Dto/GetVertexEntityDto.cs @@ -0,0 +1,6 @@ +namespace mohaymen_codestar_Team02.Dto; + +public class GetVertexEntityDto +{ + public string Name { get; set; } +} \ No newline at end of file diff --git a/mohaymen-codestar-Team02/Dto/GraphDTO/DetailDto.cs b/mohaymen-codestar-Team02/Dto/GraphDTO/DetailDto.cs index 400a15d..535f59f 100644 --- a/mohaymen-codestar-Team02/Dto/GraphDTO/DetailDto.cs +++ b/mohaymen-codestar-Team02/Dto/GraphDTO/DetailDto.cs @@ -2,5 +2,5 @@ namespace mohaymen_codestar_Team02.Dto.GraphDTO; public class DetailDto { - public Dictionary AttributeValue { get; init; } + public Dictionary? AttributeValue { get; set; } = new(); } \ No newline at end of file diff --git a/mohaymen-codestar-Team02/Dto/InfoDto/InfoDto.cs b/mohaymen-codestar-Team02/Dto/InfoDto/InfoDto.cs new file mode 100644 index 0000000..1eb7a52 --- /dev/null +++ b/mohaymen-codestar-Team02/Dto/InfoDto/InfoDto.cs @@ -0,0 +1,5 @@ +namespace mohaymen_codestar_Team02.Dto.InfoDto; + +public class InfoDto +{ +} \ No newline at end of file diff --git a/mohaymen-codestar-Team02/Dto/StoreDataDto/StoreDataDto.cs b/mohaymen-codestar-Team02/Dto/StoreDataDto/StoreDataDto.cs index 052bb7b..3b953af 100644 --- a/mohaymen-codestar-Team02/Dto/StoreDataDto/StoreDataDto.cs +++ b/mohaymen-codestar-Team02/Dto/StoreDataDto/StoreDataDto.cs @@ -4,8 +4,5 @@ public class StoreDataDto { public IFormFile EdgeFile { get; set; } public IFormFile VertexFile { get; set; } - public string FileType { get; set; } public string DataName { get; set; } - - public string CreatorUserName { get; set; } } \ No newline at end of file diff --git a/mohaymen-codestar-Team02/Mapper/AutoMapperProfile.cs b/mohaymen-codestar-Team02/Mapper/AutoMapperProfile.cs index cd6750e..bb2a3a4 100644 --- a/mohaymen-codestar-Team02/Mapper/AutoMapperProfile.cs +++ b/mohaymen-codestar-Team02/Mapper/AutoMapperProfile.cs @@ -1,9 +1,11 @@ using AutoMapper; +using mohaymen_codestar_Team02.Dto; using mohaymen_codestar_Team02.Dto.Role; using mohaymen_codestar_Team02.Dto.User; using mohaymen_codestar_Team02.Dto.UserDtos; -using mohaymen_codestar_Team02.Dto.UserRole; using mohaymen_codestar_Team02.Models; +using mohaymen_codestar_Team02.Models.EdgeEAV; +using mohaymen_codestar_Team02.Models.VertexEAV; namespace mohaymen_codestar_Team02.Mapper; @@ -17,5 +19,14 @@ public AutoMapperProfile() CreateMap(); CreateMap(); CreateMap(); + CreateMap() + .ForMember(dest => dest.EdgeEntity, opt => + opt.MapFrom(src => src.EdgeEntity)) + .ForMember(dest => dest.VertexEntity, opt => + opt.MapFrom(src => src.VertexEntity)); + CreateMap() + .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Name)); + CreateMap(); + CreateMap(); } } \ No newline at end of file diff --git a/mohaymen-codestar-Team02/Migrations/20240826115617_fixName.Designer.cs b/mohaymen-codestar-Team02/Migrations/20240826115617_fixName.Designer.cs new file mode 100644 index 0000000..95f6161 --- /dev/null +++ b/mohaymen-codestar-Team02/Migrations/20240826115617_fixName.Designer.cs @@ -0,0 +1,418 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using mohaymen_codestar_Team02.Data; + +#nullable disable + +namespace mohaymen_codestar_Team02.Migrations +{ + [DbContext(typeof(DataContext))] + [Migration("20240826115617_fixName")] + partial class fixName + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.6") + .HasAnnotation("Proxies:ChangeTracking", false) + .HasAnnotation("Proxies:CheckEquality", false) + .HasAnnotation("Proxies:LazyLoading", true) + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.DataGroup", b => + { + b.Property("DataGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("DataGroupId")); + + b.Property("CreateAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UpdateAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("DataGroupId"); + + b.HasIndex("UserId"); + + b.ToTable("DataSets"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.EdgeEAV.EdgeAttribute", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EdgeEntityId") + .HasColumnType("bigint"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("EdgeEntityId"); + + b.ToTable("EdgeAttributes"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.EdgeEAV.EdgeEntity", b => + { + b.Property("EdgeEntityId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EdgeEntityId")); + + b.Property("DataGroupId") + .HasColumnType("bigint"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("EdgeEntityId"); + + b.HasIndex("DataGroupId") + .IsUnique(); + + b.ToTable("EdgeEntities"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.EdgeEAV.EdgeValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EdgeAttributeId") + .HasColumnType("bigint"); + + b.Property("ObjectId") + .IsRequired() + .HasColumnType("text"); + + b.Property("StringValue") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("EdgeAttributeId"); + + b.ToTable("EdgeValues"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.Role", b => + { + b.Property("RoleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RoleId")); + + b.Property("Permissions") + .IsRequired() + .HasColumnType("integer[]"); + + b.Property("RoleType") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("RoleId"); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.User", b => + { + b.Property("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UserId")); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("PasswordHash") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("bytea"); + + b.Property("Salt") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("bytea"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.HasKey("UserId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.UserRole", b => + { + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("UserRoles"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.VertexEAV.VertexAttribute", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("VertexEntityId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("VertexEntityId"); + + b.ToTable("VertexAttributes"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.VertexEAV.VertexEntity", b => + { + b.Property("VertexEntityId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("VertexEntityId")); + + b.Property("DataGroupId") + .HasColumnType("bigint"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("VertexEntityId"); + + b.HasIndex("DataGroupId") + .IsUnique(); + + b.ToTable("VertexEntities"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.VertexEAV.VertexValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ObjectId") + .IsRequired() + .HasColumnType("text"); + + b.Property("StringValue") + .IsRequired() + .HasColumnType("text"); + + b.Property("VertexAttributeId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("VertexAttributeId"); + + b.ToTable("VertexValues"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.DataGroup", b => + { + b.HasOne("mohaymen_codestar_Team02.Models.User", "User") + .WithMany("DataSets") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.EdgeEAV.EdgeAttribute", b => + { + b.HasOne("mohaymen_codestar_Team02.Models.EdgeEAV.EdgeEntity", "EdgeEntity") + .WithMany("EdgeAttributes") + .HasForeignKey("EdgeEntityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EdgeEntity"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.EdgeEAV.EdgeEntity", b => + { + b.HasOne("mohaymen_codestar_Team02.Models.DataGroup", "DataGroup") + .WithOne("EdgeEntity") + .HasForeignKey("mohaymen_codestar_Team02.Models.EdgeEAV.EdgeEntity", "DataGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DataGroup"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.EdgeEAV.EdgeValue", b => + { + b.HasOne("mohaymen_codestar_Team02.Models.EdgeEAV.EdgeAttribute", "EdgeAttribute") + .WithMany("EdgeValues") + .HasForeignKey("EdgeAttributeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EdgeAttribute"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.UserRole", b => + { + b.HasOne("mohaymen_codestar_Team02.Models.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("mohaymen_codestar_Team02.Models.User", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.VertexEAV.VertexAttribute", b => + { + b.HasOne("mohaymen_codestar_Team02.Models.VertexEAV.VertexEntity", "VertexEntity") + .WithMany("VertexAttributes") + .HasForeignKey("VertexEntityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("VertexEntity"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.VertexEAV.VertexEntity", b => + { + b.HasOne("mohaymen_codestar_Team02.Models.DataGroup", "DataGroup") + .WithOne("VertexEntity") + .HasForeignKey("mohaymen_codestar_Team02.Models.VertexEAV.VertexEntity", "DataGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DataGroup"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.VertexEAV.VertexValue", b => + { + b.HasOne("mohaymen_codestar_Team02.Models.VertexEAV.VertexAttribute", "VertexAttribute") + .WithMany("VertexValues") + .HasForeignKey("VertexAttributeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("VertexAttribute"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.DataGroup", b => + { + b.Navigation("EdgeEntity") + .IsRequired(); + + b.Navigation("VertexEntity") + .IsRequired(); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.EdgeEAV.EdgeAttribute", b => + { + b.Navigation("EdgeValues"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.EdgeEAV.EdgeEntity", b => + { + b.Navigation("EdgeAttributes"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.Role", b => + { + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.User", b => + { + b.Navigation("DataSets"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.VertexEAV.VertexAttribute", b => + { + b.Navigation("VertexValues"); + }); + + modelBuilder.Entity("mohaymen_codestar_Team02.Models.VertexEAV.VertexEntity", b => + { + b.Navigation("VertexAttributes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/mohaymen-codestar-Team02/Migrations/20240826115617_fixName.cs b/mohaymen-codestar-Team02/Migrations/20240826115617_fixName.cs new file mode 100644 index 0000000..6d30013 --- /dev/null +++ b/mohaymen-codestar-Team02/Migrations/20240826115617_fixName.cs @@ -0,0 +1,38 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace mohaymen_codestar_Team02.Migrations +{ + /// + public partial class fixName : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "Id", + table: "VertexEntities", + newName: "VertexEntityId"); + + migrationBuilder.RenameColumn( + name: "Id", + table: "EdgeEntities", + newName: "EdgeEntityId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "VertexEntityId", + table: "VertexEntities", + newName: "Id"); + + migrationBuilder.RenameColumn( + name: "EdgeEntityId", + table: "EdgeEntities", + newName: "Id"); + } + } +} diff --git a/mohaymen-codestar-Team02/Migrations/DataContextModelSnapshot.cs b/mohaymen-codestar-Team02/Migrations/DataContextModelSnapshot.cs index 8afc2cd..5b4783a 100644 --- a/mohaymen-codestar-Team02/Migrations/DataContextModelSnapshot.cs +++ b/mohaymen-codestar-Team02/Migrations/DataContextModelSnapshot.cs @@ -77,11 +77,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("mohaymen_codestar_Team02.Models.EdgeEAV.EdgeEntity", b => { - b.Property("Id") + b.Property("EdgeEntityId") .ValueGeneratedOnAdd() .HasColumnType("bigint"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EdgeEntityId")); b.Property("DataGroupId") .HasColumnType("bigint"); @@ -90,7 +90,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired() .HasColumnType("text"); - b.HasKey("Id"); + b.HasKey("EdgeEntityId"); b.HasIndex("DataGroupId") .IsUnique(); @@ -226,11 +226,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("mohaymen_codestar_Team02.Models.VertexEAV.VertexEntity", b => { - b.Property("Id") + b.Property("VertexEntityId") .ValueGeneratedOnAdd() .HasColumnType("bigint"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("VertexEntityId")); b.Property("DataGroupId") .HasColumnType("bigint"); @@ -239,7 +239,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired() .HasColumnType("text"); - b.HasKey("Id"); + b.HasKey("VertexEntityId"); b.HasIndex("DataGroupId") .IsUnique(); diff --git a/mohaymen-codestar-Team02/Models/DataGraph/DataGroup.cs b/mohaymen-codestar-Team02/Models/DataGraph/DataGroup.cs index d16fcd7..f7fda17 100644 --- a/mohaymen-codestar-Team02/Models/DataGraph/DataGroup.cs +++ b/mohaymen-codestar-Team02/Models/DataGraph/DataGroup.cs @@ -13,12 +13,15 @@ public DataGroup(string name, long userId) UserId = userId; } + public DataGroup() + { + } + [Key] public long DataGroupId { get; set; } public string Name { get; set; } public DateTime CreateAt { get; set; } = DateTime.UtcNow; public DateTime UpdateAt { get; set; } = DateTime.UtcNow; - public virtual EdgeEntity EdgeEntity { get; set; } public virtual VertexEntity VertexEntity { get; set; } diff --git a/mohaymen-codestar-Team02/Models/EdgeEAV/EdgeEntity.cs b/mohaymen-codestar-Team02/Models/EdgeEAV/EdgeEntity.cs index e6387f5..cdde2a6 100644 --- a/mohaymen-codestar-Team02/Models/EdgeEAV/EdgeEntity.cs +++ b/mohaymen-codestar-Team02/Models/EdgeEAV/EdgeEntity.cs @@ -6,6 +6,10 @@ namespace mohaymen_codestar_Team02.Models.EdgeEAV; public class EdgeEntity { + public EdgeEntity() + { + } + public EdgeEntity(string name, long dataGroupId) { var regex = @@ -28,7 +32,7 @@ public EdgeEntity(string name, long dataGroupId) } } - [Key] public long Id { get; set; } + [Key] public long EdgeEntityId { get; set; } private string _name; public string Name diff --git a/mohaymen-codestar-Team02/Models/VertexEAV/VertexEntity.cs b/mohaymen-codestar-Team02/Models/VertexEAV/VertexEntity.cs index 8c9b459..5ffce26 100644 --- a/mohaymen-codestar-Team02/Models/VertexEAV/VertexEntity.cs +++ b/mohaymen-codestar-Team02/Models/VertexEAV/VertexEntity.cs @@ -7,6 +7,10 @@ namespace mohaymen_codestar_Team02.Models.VertexEAV; public class VertexEntity { + public VertexEntity() + { + } + public VertexEntity(string name, long dataGroupId) { var regex = @@ -29,7 +33,7 @@ public VertexEntity(string name, long dataGroupId) } } - [Key] public long Id { get; set; } + [Key] public long VertexEntityId { get; set; } private string _name; public string Name diff --git a/mohaymen-codestar-Team02/Models/newModel/Tables.cs b/mohaymen-codestar-Team02/Models/newModel/Tables.cs new file mode 100644 index 0000000..ac2fa11 --- /dev/null +++ b/mohaymen-codestar-Team02/Models/newModel/Tables.cs @@ -0,0 +1,9 @@ +using System.ComponentModel.DataAnnotations; + +namespace mohaymen_codestar_Team02.Models.newModel; + +public class Tables +{ + [Key] public long Id { get; set; } + public string Name { get; set; } +} \ No newline at end of file diff --git a/mohaymen-codestar-Team02/Services/DataAdminService/DataAdminService.cs b/mohaymen-codestar-Team02/Services/DataAdminService/DataAdminService.cs index f1fdeb2..c52957e 100644 --- a/mohaymen-codestar-Team02/Services/DataAdminService/DataAdminService.cs +++ b/mohaymen-codestar-Team02/Services/DataAdminService/DataAdminService.cs @@ -1,6 +1,10 @@ +using AutoMapper; +using Microsoft.EntityFrameworkCore; +using mohaymen_codestar_Team02.Data; +using mohaymen_codestar_Team02.Dto; using mohaymen_codestar_Team02.Dto.GraphDTO; using mohaymen_codestar_Team02.Models; -using mohaymen_codestar_Team02.Models.EdgeEAV; +using mohaymen_codestar_Team02.Services.CookieService; using mohaymen_codestar_Team02.Services.StoreData.Abstraction; namespace mohaymen_codestar_Team02.Services.DataAdminService; @@ -8,37 +12,64 @@ namespace mohaymen_codestar_Team02.Services.DataAdminService; public class DataAdminService : IDataAdminService { - private readonly IStorHandler storHandler; + private readonly ITokenService _tokenService; + private readonly ICookieService _cookieService; + private readonly IEdgeService _edgeService; + private readonly IVertexService _vertexService; + private readonly IStorHandler _storHandler; private readonly IDisplayDataService _displayDataService; + private readonly IServiceProvider _serviceProvider; + private readonly IMapper _mapper; + private readonly IGraphService _graphService; - public DataAdminService(IStorHandler storHandler, IDisplayDataService displayDataService) + public DataAdminService( + IServiceProvider serviceProvider, + ITokenService tokenService, + ICookieService cookieService, + IStorHandler storHandler, + IDisplayDataService displayDataService, + IEdgeService edgeService, + IVertexService vertexService, IMapper mapper, IGraphService graphService) { - this.storHandler = storHandler; + _tokenService = tokenService; + _cookieService = cookieService; + _vertexService = vertexService; + _edgeService = edgeService; + _storHandler = storHandler; _displayDataService = displayDataService; + _mapper = mapper; + _graphService = graphService; + _serviceProvider = serviceProvider; } public async Task> StoreData(string? edgeFile, string? vertexFile, string graphName - , string? edgeEntityName, string vertexEntityName, string userName) + , string? edgeEntityName, string vertexEntityName) { try { + var token = _cookieService.GetCookieValue(); + if (string.IsNullOrEmpty(token)) + return new ServiceResponse(null, ApiResponseType.Unauthorized, + Resources.UnauthorizedMessage); + + var userName = _tokenService.GetUserNameFromToken(); if (string.IsNullOrEmpty(edgeEntityName) || string.IsNullOrEmpty(graphName) || string.IsNullOrEmpty(vertexEntityName)) return new ServiceResponse(string.Empty, ApiResponseType.BadRequest, - Data.Resources.InvalidInpute); + Resources.InvalidInpute); - var dataGroupId = await storHandler.StoreDataSet(graphName, userName); + var dataGroupId = await _storHandler.StoreDataSet(graphName, userName); if (dataGroupId == -1) return new ServiceResponse(string.Empty, ApiResponseType.BadRequest, - Data.Resources.InvalidInpute); + Resources.InvalidInpute); - if (!await storHandler.EdageStorer.StoreFileData(edgeEntityName, edgeFile, dataGroupId)) + if (!await _storHandler.EdageStorer.StoreFileData(edgeEntityName, edgeFile, dataGroupId)) return new ServiceResponse(string.Empty, - ApiResponseType.BadRequest, Data.Resources.InvalidInpute); + ApiResponseType.BadRequest, Resources.InvalidInpute); - if (!await storHandler.VertexStorer.StoreFileData(vertexEntityName, vertexFile, dataGroupId)) + if (!await _storHandler.VertexStorer.StoreFileData(vertexEntityName, vertexFile, dataGroupId)) return new ServiceResponse(string.Empty, - ApiResponseType.BadRequest, Data.Resources.InvalidInpute); + ApiResponseType.BadRequest, Resources.InvalidInpute); return new ServiceResponse(null, ApiResponseType.Success, string.Empty); } @@ -48,37 +79,25 @@ public async Task> StoreData(string? edgeFile, string? v } } - public Task> DisplayDataSetAsGraph(string dataSetName, string vertexFieldName, - string sourceField, string targetField) + public ServiceResponse> DisplayDataSet() { - throw new NotImplementedException(); - } + var scope = _serviceProvider.CreateScope(); + var context = scope.ServiceProvider.GetRequiredService(); - public Task> DisplayGraph() - { - throw new NotImplementedException(); - } + var datasets = context.DataSets + .Include(ds => ds.VertexEntity) + .Include(ds => ds.EdgeEntity) + .ToList(); - public Task> DisplayDataSet() - { - throw new NotImplementedException(); + var dataGroupDtos = datasets.Select(ds => _mapper.Map(ds)).ToList(); + return new ServiceResponse>(dataGroupDtos, ApiResponseType.Success, ""); } - /* - public Task> DisplayGraph(string databaseName, string sourceEdgeIdentifierFieldName, - string destinationEdgeIdentifierFieldName, string vertexIdentifierFieldName) - { - var graph = _displayDataService.GetGraph2(databaseName, sourceEdgeIdentifierFieldName, destinationEdgeIdentifierFieldName, - vertexIdentifierFieldName); - return new Task>() - } -*/ - public async Task> DisplayGeraphData(string databaseName, string sourceEdgeIdentifierFieldName, string destinationEdgeIdentifierFieldName, string vertexIdentifierFieldName) { - var graph = _displayDataService.GetGraph(databaseName, sourceEdgeIdentifierFieldName, + var graph = _graphService.GetGraph(databaseName, sourceEdgeIdentifierFieldName, destinationEdgeIdentifierFieldName, vertexIdentifierFieldName); @@ -87,11 +106,18 @@ public async Task> DisplayGeraphData(string dat Vertices = graph.vertices, Edges = graph.edges }; - return new ServiceResponse(dto, ApiResponseType.Success, ""); + return new ServiceResponse(dto, ApiResponseType.Success, Resources.GraphFetchedSuccessfully); + } + + public ServiceResponse GetVertexDetail(string objectId) + { + return new ServiceResponse(_vertexService.GetVertexDetails(objectId), ApiResponseType.Success, + string.Empty); } - public Task>> DisplayEdgeData() + public ServiceResponse GetEdgeDetail(string objectId) { - throw new NotImplementedException(); + return new ServiceResponse(_edgeService.GetEdgeDetails(objectId), ApiResponseType.Success, + string.Empty); } } \ No newline at end of file diff --git a/mohaymen-codestar-Team02/Services/DataAdminService/IDataAdminService.cs b/mohaymen-codestar-Team02/Services/DataAdminService/IDataAdminService.cs index d3e9175..03f994c 100644 --- a/mohaymen-codestar-Team02/Services/DataAdminService/IDataAdminService.cs +++ b/mohaymen-codestar-Team02/Services/DataAdminService/IDataAdminService.cs @@ -1,3 +1,4 @@ +using mohaymen_codestar_Team02.Dto; using mohaymen_codestar_Team02.Dto.GraphDTO; using mohaymen_codestar_Team02.Models; @@ -6,10 +7,13 @@ namespace mohaymen_codestar_Team02.Services.DataAdminService; public interface IDataAdminService { Task> StoreData(string? edgeFile, string? vertexFile, string graphName - , string? edgeEntityName, string vertexEntityName, string userName); + , string? edgeEntityName, string vertexEntityName); - Task> DisplayDataSet(); + ServiceResponse> DisplayDataSet(); Task> DisplayGeraphData(string databaseName, string sourceEdgeIdentifierFieldName, string destinationEdgeIdentifierFieldName, string vertexIdentifierFieldName); + + ServiceResponse GetVertexDetail(string objectId); + ServiceResponse GetEdgeDetail(string objectId); } \ No newline at end of file diff --git a/mohaymen-codestar-Team02/Services/DisplayData/DisplayService.cs b/mohaymen-codestar-Team02/Services/DisplayData/DisplayService.cs index 2a30405..65cdcab 100644 --- a/mohaymen-codestar-Team02/Services/DisplayData/DisplayService.cs +++ b/mohaymen-codestar-Team02/Services/DisplayData/DisplayService.cs @@ -60,43 +60,44 @@ public DisplayService(IServiceProvider serviceProvider) List destinations = new(); foreach (var record1 in vertexRecords) - foreach (var item in record1) - { - if (item.VertexAttribute.Name == vertexIdentifierFieldName && item.StringValue == sourceValue) + foreach (var item in record1) { - var vertex = new Vertex() + if (item.VertexAttribute.Name == vertexIdentifierFieldName && item.StringValue == sourceValue) { - Id = record1.Key - }; - sources.Add(vertex); - } + var vertex = new Vertex() + { + Id = record1.Key + }; + sources.Add(vertex); + } - if (item.VertexAttribute.Name == vertexIdentifierFieldName && item.StringValue == destinationValue) - { - var vertex = new Vertex() + if (item.VertexAttribute.Name == vertexIdentifierFieldName && item.StringValue == destinationValue) { - Id = record1.Key - }; - destinations.Add(vertex); + var vertex = new Vertex() + { + Id = record1.Key + }; + destinations.Add(vertex); + } } - } foreach (var source in sources) - foreach (var des in destinations) - { - var edge = new Edge() + foreach (var des in destinations) { - Id = record.Key, - Source = source.Id, - Target = des.Id - }; - edges.Add(edge); - } + var edge = new Edge() + { + Id = record.Key, + Source = source.Id, + Target = des.Id + }; + edges.Add(edge); + } } return (vertices, edges); } + /* public void GetGraph(string databaseName, string sourceEdgeIdentifierFieldName, string destinationEdgeIdentifierFieldName, string vertexIdentifierFieldName, bool directed, diff --git a/mohaymen-codestar-Team02/Services/EdgeService.cs b/mohaymen-codestar-Team02/Services/EdgeService.cs new file mode 100644 index 0000000..fe92cef --- /dev/null +++ b/mohaymen-codestar-Team02/Services/EdgeService.cs @@ -0,0 +1,116 @@ +using Microsoft.EntityFrameworkCore; +using mohaymen_codestar_Team02.Data; +using mohaymen_codestar_Team02.Dto.GraphDTO; +using mohaymen_codestar_Team02.Models; +using mohaymen_codestar_Team02.Models.EdgeEAV; +using mohaymen_codestar_Team02.Models.VertexEAV; +using QuikGraph; + +namespace mohaymen_codestar_Team02.Services; + +public class EdgeService : IEdgeService +{ + private readonly IServiceProvider _serviceProvider; + + public EdgeService(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + } + + public List GetAllEdges(string databaseName, string vertexIdentifierFieldName, + string sourceEdgeIdentifierFieldName, + string destinationEdgeIdentifierFieldName) + { + var scope = _serviceProvider.CreateScope(); + var context = scope.ServiceProvider.GetRequiredService(); + var dataSet = context.DataSets.Include(ds => ds.VertexEntity) + .ThenInclude(ve => ve.VertexAttributes).ThenInclude(vv => vv.VertexValues).Include(ds => ds.EdgeEntity) + .ThenInclude(ee => ee.EdgeAttributes).ThenInclude(ev => ev.EdgeValues) + .FirstOrDefault(ds => ds.Name.ToLower().Equals(databaseName.ToLower())); + + var vertexRecords = dataSet.VertexEntity.VertexAttributes.Select(a => a.VertexValues).SelectMany(v => v) + .GroupBy(v => v.ObjectId); + + var edgeRecords = dataSet.EdgeEntity.EdgeAttributes.Select(ea => ea.EdgeValues).SelectMany(v => v) + .GroupBy(v => v.ObjectId); + + List edges = new(); + foreach (var record in edgeRecords) + { + GetSourceAndDerstinationValues(sourceEdgeIdentifierFieldName, destinationEdgeIdentifierFieldName, record, + out var sourceValue, out var destinationValue); + + GetSourcesAndDestinations(vertexIdentifierFieldName, vertexRecords, sourceValue, destinationValue, + out var sources, out var destinations); + + foreach (var source in sources) + foreach (var des in destinations) + { + var edge = new Edge() + { + Id = record.Key, + Source = source.Id, + Target = des.Id + }; + edges.Add(edge); + } + } + + return edges; + } + + private void GetSourcesAndDestinations(string vertexIdentifierFieldName, + IEnumerable> vertexRecords, + string sourceValue, string destinationValue, out List sources, out List destinations) + { + sources = new List(); + destinations = new List(); + + foreach (var record1 in vertexRecords) + foreach (var item in record1) + { + if (item.VertexAttribute.Name == vertexIdentifierFieldName && item.StringValue == sourceValue) + { + var vertex = new Vertex() + { + Id = record1.Key + }; + sources.Add(vertex); + } + + if (item.VertexAttribute.Name == vertexIdentifierFieldName && item.StringValue == destinationValue) + { + var vertex = new Vertex() + { + Id = record1.Key + }; + destinations.Add(vertex); + } + } + } + + private void GetSourceAndDerstinationValues(string sourceEdgeIdentifierFieldName, + string destinationEdgeIdentifierFieldName, IGrouping record, out string sourceValue, + out string destinationValue) + { + sourceValue = string.Empty; + destinationValue = string.Empty; + foreach (var item in record) + { + if (item.EdgeAttribute.Name == sourceEdgeIdentifierFieldName) sourceValue = item.StringValue; + + if (item.EdgeAttribute.Name == destinationEdgeIdentifierFieldName) destinationValue = item.StringValue; + } + } + + public DetailDto GetEdgeDetails(string objId) + { + using var scope = _serviceProvider.CreateScope(); + var context = scope.ServiceProvider.GetRequiredService(); + var validValue = context.EdgeValues.Where(value => value.ObjectId.ToLower() == objId.ToLower()).ToList(); + var result = new DetailDto(); + foreach (var value in validValue) + result.AttributeValue[context.EdgeAttributes.Find(value.EdgeAttributeId).Name] = value.StringValue; + return result; + } +} \ No newline at end of file diff --git a/mohaymen-codestar-Team02/Services/GraphService.cs b/mohaymen-codestar-Team02/Services/GraphService.cs new file mode 100644 index 0000000..ef2cf80 --- /dev/null +++ b/mohaymen-codestar-Team02/Services/GraphService.cs @@ -0,0 +1,25 @@ +using mohaymen_codestar_Team02.Models; +using QuikGraph; + +namespace mohaymen_codestar_Team02.Services; + +public class GraphService : IGraphService +{ + private readonly IVertexService _vertexService; + private readonly IEdgeService _edgeService; + + public GraphService(IVertexService vertexService, IEdgeService edgeService) + { + _vertexService = vertexService; + _edgeService = edgeService; + } + + public (List vertices, List edges) GetGraph(string databaseName, string sourceEdgeIdentifierFieldName, + string destinationEdgeIdentifierFieldName, string vertexIdentifierFieldName) + { + var vertices = _vertexService.GetAllVertices(databaseName, vertexIdentifierFieldName); + var edges = _edgeService.GetAllEdges(databaseName, vertexIdentifierFieldName, sourceEdgeIdentifierFieldName, + destinationEdgeIdentifierFieldName); + return (vertices, edges); + } +} \ No newline at end of file diff --git a/mohaymen-codestar-Team02/Services/IEdgeService.cs b/mohaymen-codestar-Team02/Services/IEdgeService.cs new file mode 100644 index 0000000..e8324b5 --- /dev/null +++ b/mohaymen-codestar-Team02/Services/IEdgeService.cs @@ -0,0 +1,14 @@ +using mohaymen_codestar_Team02.Dto.GraphDTO; +using mohaymen_codestar_Team02.Models; +using QuikGraph; + +namespace mohaymen_codestar_Team02.Services; + +public interface IEdgeService +{ + public List GetAllEdges(string databaseName, string vertexIdentifierFieldName, + string sourceEdgeIdentifierFieldName, + string destinationEdgeIdentifierFieldName); + + DetailDto GetEdgeDetails(string objId); +} \ No newline at end of file diff --git a/mohaymen-codestar-Team02/Services/IGraphService.cs b/mohaymen-codestar-Team02/Services/IGraphService.cs new file mode 100644 index 0000000..2611a7d --- /dev/null +++ b/mohaymen-codestar-Team02/Services/IGraphService.cs @@ -0,0 +1,11 @@ +using mohaymen_codestar_Team02.Models; +using QuikGraph; + +namespace mohaymen_codestar_Team02.Services; + +public interface IGraphService +{ + (List vertices, List edges) GetGraph(string databaseName, + string sourceEdgeIdentifierFieldName, + string destinationEdgeIdentifierFieldName, string vertexIdentifierFieldName); +} \ No newline at end of file diff --git a/mohaymen-codestar-Team02/Services/IVertexService.cs b/mohaymen-codestar-Team02/Services/IVertexService.cs new file mode 100644 index 0000000..6c49638 --- /dev/null +++ b/mohaymen-codestar-Team02/Services/IVertexService.cs @@ -0,0 +1,10 @@ +using mohaymen_codestar_Team02.Dto.GraphDTO; +using mohaymen_codestar_Team02.Models; + +namespace mohaymen_codestar_Team02.Services; + +public interface IVertexService +{ + public List GetAllVertices(string datasetName, string vertexIdentifierFieldName); + DetailDto GetVertexDetails(string objId); +} \ No newline at end of file diff --git a/mohaymen-codestar-Team02/Services/StoreData/EdgeStorerCsv.cs b/mohaymen-codestar-Team02/Services/StoreData/EdgeStorerCsv.cs index 79f202a..8756df9 100644 --- a/mohaymen-codestar-Team02/Services/StoreData/EdgeStorerCsv.cs +++ b/mohaymen-codestar-Team02/Services/StoreData/EdgeStorerCsv.cs @@ -36,7 +36,7 @@ public async Task StoreFileData(string entityName, string dataFile, long d headers[headers.Length - 1] = lastWodrd.Substring(0, lastWodrd.Length - 1); - foreach (var att in headers) edgeAttributes.Add(new EdgeAttribute(att, edgeEntity.Id)); + foreach (var att in headers) edgeAttributes.Add(new EdgeAttribute(att, edgeEntity.EdgeEntityId)); foreach (var attribute in edgeAttributes) await dataContext.EdgeAttributes.AddAsync(attribute); diff --git a/mohaymen-codestar-Team02/Services/StoreData/VertexStorerCsv.cs b/mohaymen-codestar-Team02/Services/StoreData/VertexStorerCsv.cs index e5a705f..9c2d193 100644 --- a/mohaymen-codestar-Team02/Services/StoreData/VertexStorerCsv.cs +++ b/mohaymen-codestar-Team02/Services/StoreData/VertexStorerCsv.cs @@ -38,7 +38,7 @@ public async Task StoreFileData(string entityName, string dataFile, long d headers[headers.Length - 1] = lastWords.Substring(0, lastWords.Length - 1); } - foreach (var att in headers) edgeAttributes.Add(new VertexAttribute(att, edgeEntity.Id)); + foreach (var att in headers) edgeAttributes.Add(new VertexAttribute(att, edgeEntity.VertexEntityId)); foreach (var attribute in edgeAttributes) await dataContext.VertexAttributes.AddAsync(attribute); diff --git a/mohaymen-codestar-Team02/Services/VertexService.cs b/mohaymen-codestar-Team02/Services/VertexService.cs new file mode 100644 index 0000000..a7d6746 --- /dev/null +++ b/mohaymen-codestar-Team02/Services/VertexService.cs @@ -0,0 +1,60 @@ +using Microsoft.EntityFrameworkCore; +using mohaymen_codestar_Team02.Data; +using mohaymen_codestar_Team02.Dto.GraphDTO; +using mohaymen_codestar_Team02.Models; + +namespace mohaymen_codestar_Team02.Services; + +public class VertexService : IVertexService +{ + private readonly IServiceProvider _serviceProvider; + + public VertexService(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + } + + public List GetAllVertices(string datasetName, string vertexIdentifierFieldName) + { + using var scope = _serviceProvider.CreateScope(); + var context = scope.ServiceProvider.GetRequiredService(); + + var dataSet = context.DataSets.Include(ds => ds.VertexEntity) + .ThenInclude(ve => ve.VertexAttributes).ThenInclude(vv => vv.VertexValues) + .FirstOrDefault(ds => ds.Name.ToLower().Equals(datasetName.ToLower())); + + var vertexRecords = dataSet.VertexEntity.VertexAttributes.Select(a => a.VertexValues).SelectMany(v => v) + .GroupBy(v => v.ObjectId); + + List vertices = new(); + foreach (var record in vertexRecords) + { + var value = record.SingleOrDefault(r => r.VertexAttribute.Name == vertexIdentifierFieldName).StringValue; + var v = new Vertex() + { + Id = record.Key, + Value = value + }; + vertices.Add(v); + } + + return vertices; + } + + public DetailDto GetVertexDetails(string objId) + { + using var scope = _serviceProvider.CreateScope(); + var context = scope.ServiceProvider.GetRequiredService(); + var validValue = context.VertexValues.Where(value => value.ObjectId.ToLower() == objId.ToLower()).ToList(); + var result = new DetailDto(); + foreach (var value in validValue) + result.AttributeValue[context.VertexAttributes.Find(value.VertexAttributeId).Name] = value.StringValue; + + return result; + } + + public List GetAllVertices(string datasetName) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/mohaymen-codestar-Team02/initialProgram/InitialServices.cs b/mohaymen-codestar-Team02/initialProgram/InitialServices.cs index 5aa7a30..7c9d309 100644 --- a/mohaymen-codestar-Team02/initialProgram/InitialServices.cs +++ b/mohaymen-codestar-Team02/initialProgram/InitialServices.cs @@ -40,6 +40,7 @@ public static void ConfigureServices(IServiceCollection services, WebApplication // Configure DbContext and Dependency Injection var cs = builder.Configuration["CONNECTION_STRING"]; + Console.WriteLine("your connection string is ==>" + cs); services.AddDbContext(options => options.UseNpgsql(cs)); @@ -58,8 +59,10 @@ public static void ConfigureServices(IServiceCollection services, WebApplication .AddScoped() .AddScoped() .AddScoped() - .AddScoped(); - + .AddScoped() + .AddScoped() + .AddScoped() + .AddScoped(); services.AddAutoMapper(typeof(AutoMapperProfile)); services.AddAuthorization(); diff --git a/mohaymen-codestar-Team02/todos b/mohaymen-codestar-Team02/todos index bba1b46..21cae23 100644 --- a/mohaymen-codestar-Team02/todos +++ b/mohaymen-codestar-Team02/todos @@ -1,21 +1,14 @@ -add identity -prog.cs into app initialize -code migration handdle excptio -regex for password -permissions -get permisions get users data for response -function for if elses -additional add Singlton lazy -lazy khodemon test container Observabality ilooger -password and email check +email check and username -permission list -Dto & massage +update cookie when add role + +Add scope?? +what about test Regex update cookie when add role \ No newline at end of file diff --git a/mohaymen-codestar-Team02_XUnitTest/Servies/DataAdminService/DataAdminServiceTest.cs b/mohaymen-codestar-Team02_XUnitTest/Servies/DataAdminService/DataAdminServiceTest.cs index c07ee82..ac42353 100644 --- a/mohaymen-codestar-Team02_XUnitTest/Servies/DataAdminService/DataAdminServiceTest.cs +++ b/mohaymen-codestar-Team02_XUnitTest/Servies/DataAdminService/DataAdminServiceTest.cs @@ -1,5 +1,13 @@ +using AutoMapper; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using mohaymen_codestar_Team02.Data; +using mohaymen_codestar_Team02.Dto; using mohaymen_codestar_Team02.Models; +using mohaymen_codestar_Team02.Models.EdgeEAV; +using mohaymen_codestar_Team02.Models.VertexEAV; using mohaymen_codestar_Team02.Services; +using mohaymen_codestar_Team02.Services.CookieService; using mohaymen_codestar_Team02.Services.StoreData.Abstraction; using NSubstitute; @@ -9,26 +17,81 @@ public class DataAdminServiceTest { private readonly IStorHandler _storHandler; private readonly IDisplayDataService _displayDataService; + private readonly IMapper _mapper; + private readonly IServiceProvider _serviceProvider; + private DataContext _dataContext; private readonly mohaymen_codestar_Team02.Services.DataAdminService.DataAdminService _sut; + private readonly IEdgeService _edgeService; + private readonly IVertexService _vertexService; + private readonly ITokenService _tokenService; + private readonly ICookieService _cookieService; + private readonly IGraphService _graphService; public DataAdminServiceTest() { + _graphService = Substitute.For(); + _cookieService = Substitute.For(); + _tokenService = Substitute.For(); + _vertexService = Substitute.For(); + _edgeService = Substitute.For(); _storHandler = Substitute.For(); _displayDataService = Substitute.For(); - _sut = new mohaymen_codestar_Team02.Services.DataAdminService.DataAdminService(_storHandler, - _displayDataService); + _mapper = Substitute.For(); + + var serviceCollection = new ServiceCollection(); + + var options = new DbContextOptionsBuilder() + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .Options; + + serviceCollection.AddScoped(_ => new DataContext(options)); + + _serviceProvider = serviceCollection.BuildServiceProvider(); + + + _sut = new mohaymen_codestar_Team02.Services.DataAdminService.DataAdminService(_serviceProvider, _tokenService, + _cookieService, _storHandler, _displayDataService, _edgeService, _vertexService, _mapper, _graphService); _storHandler.EdageStorer.StoreFileData(Arg.Any(), Arg.Any(), Arg.Any()).Returns(true); _storHandler.VertexStorer.StoreFileData(Arg.Any(), Arg.Any(), Arg.Any()).Returns(true); } + private void FixTheReturnOfCookies(string? returnThis) + { + _cookieService.GetCookieValue().Returns(returnThis); + _tokenService.GetUserNameFromToken().Returns(returnThis); + } + + private UserRole AddUserWithRole(string userName, string roleType, long id) + { + using var scope = _serviceProvider.CreateScope(); + var _mockContext = scope.ServiceProvider.GetRequiredService(); + + var user = new User + { + Salt = Array.Empty(), + PasswordHash = Array.Empty(), + Username = userName, + UserId = id + }; + var role = new Role { RoleType = roleType, RoleId = id }; + var userRole = new UserRole { UserId = user.UserId, RoleId = role.RoleId }; + _mockContext.Users.Add(user); + _mockContext.Roles.Add(role); + _mockContext.UserRoles.Add(userRole); + _mockContext.SaveChanges(); + return new UserRole { Role = role, User = user }; + } + [Theory] [InlineData("")] [InlineData(null)] public async Task StoreData_ReturnsBadRequest_WhenNameIsNullOrEmpty(string? name) { + FixTheReturnOfCookies("admin"); + AddUserWithRole("admin", "SustemAdmin", 1); //Arrange //Action - var result = await _sut.StoreData("sample", "sample", "mahdddd", name, "ma", "8"); + var result = await _sut.StoreData("sample", "sample", "mahdddd", name, "ma"); //Assert Assert.Equal(ApiResponseType.BadRequest, result.Type); } @@ -37,9 +100,11 @@ public async Task StoreData_ReturnsBadRequest_WhenNameIsNullOrEmpty(string? name public async Task StoreData_ReturnsBadRequest_WhenCreatingTheDataGroupIsFail() { //Arrange - _storHandler.StoreDataSet("mahdddd", "8").Returns(-1); + FixTheReturnOfCookies("admin"); + AddUserWithRole("admin", "SustemAdmin", 1); + _storHandler.StoreDataSet("mahdddd", Arg.Any()).Returns(-1); //Action - var result = await _sut.StoreData("sample", "sample", "mahdddd", "name", "ma", "8"); + var result = await _sut.StoreData("sample", "sample", "mahdddd", "name", "ma"); //Assert Assert.Equal(ApiResponseType.BadRequest, result.Type); } @@ -48,9 +113,11 @@ public async Task StoreData_ReturnsBadRequest_WhenCreatingTheDataGroupIsFail() public async Task StoreData_ReturnsBadRequest_WhenEdageStorerStoreValuesReturnFalse() { //Arrange + FixTheReturnOfCookies("admin"); + AddUserWithRole("admin", "SustemAdmin", 1); _storHandler.EdageStorer.StoreFileData(Arg.Any(), Arg.Any(), Arg.Any()).Returns(false); //Action - var result = await _sut.StoreData("sample", "sample", "test", "mahdddd", "mahdddd", "8"); + var result = await _sut.StoreData("sample", "sample", "test", "mahdddd", "mahdddd"); //Assert Assert.Equal(ApiResponseType.BadRequest, result.Type); } @@ -59,10 +126,12 @@ public async Task StoreData_ReturnsBadRequest_WhenEdageStorerStoreValuesReturnFa public async Task StoreData_ReturnsBadRequest_WhenVertexStorerStoreValuesReturnFalse() { // Arrange + FixTheReturnOfCookies("admin"); + AddUserWithRole("admin", "SustemAdmin", 1); _storHandler.VertexStorer.StoreFileData(Arg.Any(), Arg.Any(), Arg.Any()).Returns(false); // Act - var result = await _sut.StoreData("sampleEdgeFile", "sampleVertexFile", "testData", "mamama", "mmm", "2"); + var result = await _sut.StoreData("sampleEdgeFile", "sampleVertexFile", "testData", "mamama", "mmm"); // Assert Assert.Equal(ApiResponseType.BadRequest, result.Type); @@ -72,10 +141,117 @@ public async Task StoreData_ReturnsBadRequest_WhenVertexStorerStoreValuesReturnF public async Task StoreData_ReturnsSuccess_WhenInputAreValid() { // Arrange + FixTheReturnOfCookies("admin"); + AddUserWithRole("admin", "SustemAdmin", 1); _storHandler.StoreDataSet(Arg.Any(), Arg.Any()).Returns(9); // Act - var result = await _sut.StoreData("sampleEdgeFile", "sampleVertexFile", "testData", "a", "lll", "2"); + var result = await _sut.StoreData("sampleEdgeFile", "sampleVertexFile", "testData", "a", "lll"); // Assert Assert.Equal(ApiResponseType.Success, result.Type); } + + [Fact] + public void DisplayDataSet_ShouldGetDataSet_WhenGivenCorrectUsername() + { + using var scope = _serviceProvider.CreateScope(); + _dataContext = scope.ServiceProvider.GetRequiredService(); + + // Arrange + FixTheReturnOfCookies("admin"); + AddUserWithRole("admin", "SustemAdmin", 1); + var username = "username1"; + var datasetName1 = "Dataset1"; + var datasetName2 = "Dataset2"; + var vertexEntityName1 = "Account1"; + var EdgeEntityName1 = "Transaction1"; + var vertexEntityName2 = "Account2"; + var EdgeEntityName2 = "Transaction2"; + + var GetDataGroupDtos = new List() + { + new() + { + Name = datasetName1, + CreateAt = DateTime.MaxValue, + UpdateAt = DateTime.MaxValue, + VertexEntity = new GetVertexEntityDto() + { + Name = vertexEntityName1 + }, + EdgeEntity = new GetEdgeEntityDto() + { + Name = EdgeEntityName1 + } + }, + new() + { + Name = datasetName2, + + CreateAt = DateTime.MaxValue, + UpdateAt = DateTime.MaxValue, + VertexEntity = new GetVertexEntityDto() + { + Name = vertexEntityName2 + }, + EdgeEntity = new GetEdgeEntityDto() + { + Name = EdgeEntityName2 + } + } + }; + + var expected = new ServiceResponse>(GetDataGroupDtos, ApiResponseType.Success, ""); + + var dataset1 = new DataGroup + { + Name = datasetName1, + UserId = 1, + DataGroupId = 1, + CreateAt = DateTime.MaxValue, + UpdateAt = DateTime.MaxValue, + VertexEntity = new VertexEntity(vertexEntityName1, 1), + EdgeEntity = new EdgeEntity(EdgeEntityName1, 1) + }; + var dataset2 = new DataGroup + { + Name = datasetName2, + UserId = 1, + DataGroupId = 2, + CreateAt = DateTime.MaxValue, + UpdateAt = DateTime.MaxValue, + VertexEntity = new VertexEntity(vertexEntityName2, 2), + EdgeEntity = new EdgeEntity(EdgeEntityName2, 2) + }; + + _dataContext.DataSets.Add(dataset1); + _dataContext.DataSets.Add(dataset2); + _dataContext.SaveChanges(); + + + _mapper.Map(Arg.Is(dg => dg.Name == datasetName1)) + .Returns(new GetDataGroupDto + { + Name = datasetName1, + CreateAt = DateTime.MaxValue, + UpdateAt = DateTime.MaxValue, + VertexEntity = new GetVertexEntityDto { Name = vertexEntityName1 }, + EdgeEntity = new GetEdgeEntityDto { Name = EdgeEntityName1 } + }); + + _mapper.Map(Arg.Is(dg => dg.Name == datasetName2)) + .Returns(new GetDataGroupDto + { + Name = datasetName2, + CreateAt = DateTime.MaxValue, + UpdateAt = DateTime.MaxValue, + VertexEntity = new GetVertexEntityDto { Name = vertexEntityName2 }, + EdgeEntity = new GetEdgeEntityDto { Name = EdgeEntityName2 } + }); + + // Act + var actual = _sut.DisplayDataSet(); + + // Assert + Assert.Equivalent(expected, actual); + } } \ No newline at end of file diff --git a/mohaymen-codestar-Team02_XUnitTest/Servies/EdgeServiceTest.cs b/mohaymen-codestar-Team02_XUnitTest/Servies/EdgeServiceTest.cs new file mode 100644 index 0000000..dfb7f00 --- /dev/null +++ b/mohaymen-codestar-Team02_XUnitTest/Servies/EdgeServiceTest.cs @@ -0,0 +1,148 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.IdentityModel.Protocols; +using mohaymen_codestar_Team02.Data; +using mohaymen_codestar_Team02.Models; +using mohaymen_codestar_Team02.Models.EdgeEAV; +using mohaymen_codestar_Team02.Models.VertexEAV; +using mohaymen_codestar_Team02.Services; + +namespace mohaymen_codestar_Team02_XUnitTest.Servies; + +public class EdgeServiceTest +{ + private IServiceProvider _serviceProvider; + private EdgeService _sut; + + public EdgeServiceTest() + { + var serviceCollection = new ServiceCollection(); + + var options = new DbContextOptionsBuilder() + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .Options; + + serviceCollection.AddScoped(_ => new DataContext(options)); + + _serviceProvider = serviceCollection.BuildServiceProvider(); + _sut = new EdgeService(_serviceProvider); + } + + [Fact] + public void GetEdgeDetails_ReturnsCorrectDetails() + { + //Arange + var objectId1 = "object1"; + var objectId2 = "object2"; + using var scope = _serviceProvider.CreateScope(); + var mockContext = scope.ServiceProvider.GetRequiredService(); + + var att1 = new EdgeAttribute("att1", 1); + var att2 = new EdgeAttribute("att2", 2); + att1.Id = 1; + att2.Id = 2; + + List att = new() { att1, att2 }; + + foreach (var attribute in att) mockContext.Add(attribute); + + var val1 = new EdgeValue("val1", 1, objectId2); + var val2 = new EdgeValue("val2", 1, objectId1); + var val3 = new EdgeValue("val3", 2, objectId1); + var val4 = new EdgeValue("val4", 2, objectId2); + List vertexValues = new() { val1, val2, val3, val4 }; + foreach (var value in vertexValues) mockContext.Add(value); + + mockContext.SaveChanges(); + var expected = new Dictionary(); + expected[att1.Name] = val2.StringValue; + expected[att2.Name] = val3.StringValue; + //Action + var result = _sut.GetEdgeDetails(objectId1); + //assert + Assert.Equal(result.AttributeValue, expected); + } + + [Fact] + public void GetAllEdges_ShouldReturnAllEdges_WhenGivenCorrectDatasetAndIdentifiersName() + { + using var scope = _serviceProvider.CreateScope(); + var _dataContext = scope.ServiceProvider.GetRequiredService(); + + // Arrange + var datasetName = "DataSet1"; + var vertexIdentifierFieldName = "CardID"; + var sourceEdgeIdentifierFieldName = "SourceAcount"; + var destinationEdgeIdentifierFieldName = "DestiantionAccount"; + + var expected = new List() + { + new() + { + Id = "id1", + Source = "id2", + Target = "id3" + }, + new() + { + Id = "id2", + Source = "id4", + Target = "id5" + } + }; + + var dataset = new DataGroup("Dataset1", 1) + { + Name = "DataSet1", + EdgeEntity = new EdgeEntity("Transaction", 1) + { + EdgeAttributes = new List + { + new("SourceAcount", 1) + { + EdgeValues = new List + { + new("value1", 1, "id1") { EdgeAttribute = new EdgeAttribute("SourceAcount", 1) }, + new("value2", 1, "id2") { EdgeAttribute = new EdgeAttribute("SourceAcount", 1) } + } + }, + new("DestiantionAccount", 2) + { + EdgeValues = new List + { + new("value3", 2, "id1") { EdgeAttribute = new EdgeAttribute("DestiantionAccount", 1) }, + new("value3", 2, "id2") { EdgeAttribute = new EdgeAttribute("DestiantionAccount", 1) } + } + } + } + }, + VertexEntity = new VertexEntity("Account", 1) + { + VertexAttributes = new List + { + new("CardID", 1) + { + VertexValues = new List + { + new("value1", 1, "id2") { VertexAttribute = new VertexAttribute("CardID", 1) }, + new("value3", 1, "id3") { VertexAttribute = new VertexAttribute("CardID", 1) }, + new("value2", 1, "id4") { VertexAttribute = new VertexAttribute("CardID", 1) }, + new("value3", 1, "id5") { VertexAttribute = new VertexAttribute("CardID", 1) } + } + } + } + } + }; + + _dataContext.DataSets.Add(dataset); + _dataContext.SaveChanges(); + + + // Act + var actual = _sut.GetAllEdges(datasetName, vertexIdentifierFieldName, sourceEdgeIdentifierFieldName, + destinationEdgeIdentifierFieldName); + + // Assert + Assert.Equivalent(expected, actual); + } +} \ No newline at end of file diff --git a/mohaymen-codestar-Team02_XUnitTest/Servies/GraphServiceTest.cs b/mohaymen-codestar-Team02_XUnitTest/Servies/GraphServiceTest.cs new file mode 100644 index 0000000..0b373eb --- /dev/null +++ b/mohaymen-codestar-Team02_XUnitTest/Servies/GraphServiceTest.cs @@ -0,0 +1,71 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using mohaymen_codestar_Team02.Data; +using mohaymen_codestar_Team02.Models; +using mohaymen_codestar_Team02.Services; +using NSubstitute; +using QuikGraph; + +namespace mohaymen_codestar_Team02_XUnitTest.Servies; + +public class GraphServiceTest +{ + private GraphService _sut; + private readonly IVertexService _vertexService; + private readonly IEdgeService _edgeService; + + public GraphServiceTest() + { + _vertexService = Substitute.For(); + _edgeService = Substitute.For(); + _sut = new GraphService(_vertexService, _edgeService); + } + + [Fact] + public void GetGraph_ShouldReturnListOfVerticesAndDestinations_WhenGivenDatasetNameAndIdentifiers() + { + // Arrange + var datasetName = "datasetName1"; + var sourceEdgeIdentifierFieldName = "AccountID"; + var destinationEdgeIdentifierFieldName = "SourceAcount"; + var vertexIdentifierFieldName = "DestiantionAccount"; + + var expectedVertex = new List() + { + new() + { + Id = "id1", + Value = "value1" + }, + new() + { + Id = "id2", + Value = "value2" + } + }; + + var expectedEdge = new List() + { + new() + { + Id = "id1", + Source = "id1", + Target = "id2" + } + }; + + var expected = (expectedVertex, expectedEdge); + + _vertexService.GetAllVertices(datasetName, vertexIdentifierFieldName).Returns(expectedVertex); + _edgeService.GetAllEdges(datasetName, vertexIdentifierFieldName, sourceEdgeIdentifierFieldName, + destinationEdgeIdentifierFieldName).Returns(expectedEdge); + + // Act + var actual = _sut.GetGraph(datasetName, sourceEdgeIdentifierFieldName, destinationEdgeIdentifierFieldName, + vertexIdentifierFieldName); + + // Assert + Assert.Equivalent(expected, actual); + } +} \ No newline at end of file diff --git a/mohaymen-codestar-Team02_XUnitTest/Servies/VertexServiceTest.cs b/mohaymen-codestar-Team02_XUnitTest/Servies/VertexServiceTest.cs new file mode 100644 index 0000000..c12dc55 --- /dev/null +++ b/mohaymen-codestar-Team02_XUnitTest/Servies/VertexServiceTest.cs @@ -0,0 +1,117 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.IdentityModel.Protocols; +using mohaymen_codestar_Team02.Data; +using mohaymen_codestar_Team02.Models; +using mohaymen_codestar_Team02.Models.VertexEAV; +using mohaymen_codestar_Team02.Services; + +namespace mohaymen_codestar_Team02_XUnitTest.Servies; + +public class VertexServiceTest +{ + private IServiceProvider _serviceProvider; + private VertexService _sut; + + public VertexServiceTest() + { + var serviceCollection = new ServiceCollection(); + + var options = new DbContextOptionsBuilder() + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .Options; + + serviceCollection.AddScoped(_ => new DataContext(options)); + + _serviceProvider = serviceCollection.BuildServiceProvider(); + _sut = new VertexService(_serviceProvider); + } + + [Fact] + public void GetVertexDetails_ReturnsCorrectDetails() + { + //Arange + var objectId1 = "object1"; + var objectId2 = "object2"; + using var scope = _serviceProvider.CreateScope(); + var mockContext = scope.ServiceProvider.GetRequiredService(); + + var att1 = new VertexAttribute("att1", 1); + var att2 = new VertexAttribute("att2", 2); + att1.Id = 1; + att2.Id = 2; + + List att = new() { att1, att2 }; + + foreach (var attribute in att) mockContext.Add(attribute); + + var val1 = new VertexValue("val1", 1, objectId2); + var val2 = new VertexValue("val2", 1, objectId1); + var val3 = new VertexValue("val3", 2, objectId1); + var val4 = new VertexValue("val4", 2, objectId2); + List vertexValues = new() { val1, val2, val3, val4 }; + foreach (var value in vertexValues) mockContext.Add(value); + + mockContext.SaveChanges(); + var expected = new Dictionary(); + expected[att1.Name] = val2.StringValue; + expected[att2.Name] = val3.StringValue; + //Action + var result = _sut.GetVertexDetails(objectId1); + //assert + Assert.Equal(result.AttributeValue, expected); + } + + [Fact] + public void GetAllVertices_ShouldReturnAllVertices_WhenGivenCorrectDatasetName() + { + using var scope = _serviceProvider.CreateScope(); + var mockContext = scope.ServiceProvider.GetRequiredService(); + + // Arrange + var datasetName = "DataSet1"; + var vertexIdentifierFieldName = "CardID"; + + var dataset = new DataGroup(datasetName, 1) + { + VertexEntity = new VertexEntity("Account", 1) + { + VertexAttributes = new List + { + new("CardID", 1) + { + VertexValues = new List + { + new("value1", 1, "id1") { VertexAttribute = new VertexAttribute("CardID", 1) }, + new("value2", 1, "id2") { VertexAttribute = new VertexAttribute("CardID", 1) } + } + } + } + } + }; + + mockContext.DataSets.Add(dataset); + mockContext.SaveChanges(); + + List expected = new() + { + new() + { + Id = "id1", + Value = "value1" + }, + new() + { + Id = "id2", + Value = "value2" + } + }; + + + // Act + var actual = _sut.GetAllVertices(datasetName, vertexIdentifierFieldName); + + // Assert + Assert.Equivalent(expected, actual); + } +} \ No newline at end of file diff --git a/task.txt b/task.txt new file mode 100644 index 0000000..d9039f9 --- /dev/null +++ b/task.txt @@ -0,0 +1,7 @@ +save data 1 +send graph 2 +show list valid data 3 +get target graph 3 +vertex detail 3 +edge detail 3 +