Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/save graph #17

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,

Check warning on line 18 in mohaymen-codestar-Team02/Controllers/DataAdminController.cs

View workflow job for this annotation

GitHub Actions / test

Non-nullable field '_dataService' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 18 in mohaymen-codestar-Team02/Controllers/DataAdminController.cs

View workflow job for this annotation

GitHub Actions / test

Non-nullable field '_dataService' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
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)

Check warning on line 38 in mohaymen-codestar-Team02/Controllers/DataAdminController.cs

View workflow job for this annotation

GitHub Actions / test

The variable 'e' is declared but never used

Check warning on line 38 in mohaymen-codestar-Team02/Controllers/DataAdminController.cs

View workflow job for this annotation

GitHub Actions / test

The variable 'e' is declared but never used
{
return BadRequest("your File is not on a correct format");
}
}

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

[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;

Check warning on line 56 in mohaymen-codestar-Team02/Controllers/DataAdminController.cs

View workflow job for this annotation

GitHub Actions / test

Dereference of a possibly null reference.

Check warning on line 56 in mohaymen-codestar-Team02/Controllers/DataAdminController.cs

View workflow job for this annotation

GitHub Actions / test

Dereference of a possibly null reference.
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)

Check warning on line 62 in mohaymen-codestar-Team02/Controllers/DataAdminController.cs

View workflow job for this annotation

GitHub Actions / test

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 62 in mohaymen-codestar-Team02/Controllers/DataAdminController.cs

View workflow job for this annotation

GitHub Actions / test

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
return BadRequest();
}

[HttpGet("DataSets/{dataSetName}/Edges/{edgeId}")]
public void DisplayEdgeDetails(string datasetName, int edgeId)
public async Task<IActionResult> DisplayEdgeDetails(string datasetName, int edgeId)

Check warning on line 68 in mohaymen-codestar-Team02/Controllers/DataAdminController.cs

View workflow job for this annotation

GitHub Actions / test

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
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
Loading