Skip to content

Commit

Permalink
Merge pull request #19 from Star-Academy/feature/save-graph
Browse files Browse the repository at this point in the history
Feature/save graph
  • Loading branch information
Ftm-Sayadzadeh authored Aug 24, 2024
2 parents 993baf7 + 72e3f9f commit 03fa2d4
Show file tree
Hide file tree
Showing 50 changed files with 2,428 additions and 531 deletions.
1 change: 0 additions & 1 deletion mohaymen-codestar-Team02/.Env.Example

This file was deleted.

2 changes: 1 addition & 1 deletion mohaymen-codestar-Team02/Controllers/AdminController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public async Task<IActionResult> Delete([FromBody] DeleteUserDto request)
{
var user = new User
{
Username = request.Username,
Username = request.Username
};

ServiceResponse<GetUserDto?> response =
Expand Down
46 changes: 35 additions & 11 deletions mohaymen-codestar-Team02/Controllers/DataAdminController.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,44 @@
using Microsoft.AspNetCore.Mvc;
using mohaymen_codestar_Team02.Dto;
using mohaymen_codestar_Team02.Dto.GraphDTO;
using mohaymen_codestar_Team02.Dto.StoreDataDto;
using mohaymen_codestar_Team02.Models;
using mohaymen_codestar_Team02.Services;
using mohaymen_codestar_Team02.Services.DataAdminService;
using mohaymen_codestar_Team02.Services.FileReaderService;

namespace mohaymen_codestar_Team02.Controllers;

public class DataAdminController : ControllerBase
{

private readonly IDataAdminService _dataAdminService;
private readonly IFileReader _fileReader;
public DataAdminController(IDataAdminService dataAdminService, IFileReader fileReader)
private readonly IDisplayDataService _dataService;

public DataAdminController(IDataAdminService dataAdminService, IFileReader fileReader,
IDisplayDataService dataService)
{
_dataAdminService = dataAdminService;
_fileReader = fileReader;
_dataAdminService = dataAdminService;
}

[HttpPost("DataSets")]
public async Task<IActionResult> StoreNewDataSet([FromForm] StoreDataDto storeDataDto)
{
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);
return StatusCode((int)response.Type, response);
try
{
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);
return StatusCode((int)response.Type, response);
}
catch (FormatException e)
{
return BadRequest("your File is not on a correct format");
}
}

[HttpGet("DataSets")]
Expand All @@ -32,17 +47,26 @@ public void GetDataSetsList()
}

[HttpGet("DataSets/{dataSetName}")]
public void DisplayDataSetAsGraph(string dataSetName)
public async Task<IActionResult> DisplayDataSetAsGraph(string dataSetName,
[FromQuery] string sourceEdgeIdentifierFieldName, [FromQuery] string destinationEdgeIdentifierFieldName,
[FromQuery] string vertexIdentifierFieldName)
{
ServiceResponse<DisplayGraphDto> response =
await _dataAdminService.DisplayGeraphData(dataSetName, sourceEdgeIdentifierFieldName, destinationEdgeIdentifierFieldName, vertexIdentifierFieldName);
response.Data.GraphName = dataSetName;
return StatusCode((int)response.Type, response);
}


[HttpGet("DataSets/{dataSetName}/Vertices/{vertexId}")]
public void DisplayVertexDetails(string datasetName, int vertexId)
public async Task<IActionResult> DisplayVertexDetails(string datasetName, int vertexId)
{
return BadRequest();
}

[HttpGet("DataSets/{dataSetName}/Edges/{edgeId}")]
public void DisplayEdgeDetails(string datasetName, int edgeId)
public async Task<IActionResult> DisplayEdgeDetails(string datasetName, int edgeId)
{
return BadRequest();
}
}
9 changes: 9 additions & 0 deletions mohaymen-codestar-Team02/Dto/GetGraphDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace mohaymen_codestar_Team02.Dto;

public class GetGraphDto
{
public string databaseName;
public string sourceEdgeIdentifierFieldName;
public string destinationEdgeIdentifierFieldName;
public string vertexIdentifierFieldName;
}
6 changes: 6 additions & 0 deletions mohaymen-codestar-Team02/Dto/GraphDTO/DetailDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace mohaymen_codestar_Team02.Dto.GraphDTO;

public class DetailDto
{
public Dictionary<string, string> AttributeValue { get; init; }
}
10 changes: 10 additions & 0 deletions mohaymen-codestar-Team02/Dto/GraphDTO/DisplayGraphDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using mohaymen_codestar_Team02.Models;

namespace mohaymen_codestar_Team02.Dto.GraphDTO;

public class DisplayGraphDto
{
public List<Edge> Edges { get; init; }
public List<Vertex> Vertices { get; init; }
public string GraphName { get; set; }
}
Loading

0 comments on commit 03fa2d4

Please sign in to comment.