-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cwdoe 1372 build inject catalog api (#102)
* add models to DB and new migration * add services and controllers
- Loading branch information
1 parent
fd5001f
commit c545ae2
Showing
38 changed files
with
4,904 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2024 Carnegie Mellon University. All Rights Reserved. | ||
// Released under a MIT (SEI)-style license, please see LICENSE.md in the project root for license information or contact [email protected] for full terms. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Blueprint.Api.Data.Models | ||
{ | ||
public class CatalogEntity : BaseEntity | ||
{ | ||
[Key] | ||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] | ||
public Guid Id { get; set; } | ||
public string Name { get; set; } | ||
public string Description { get; set; } | ||
public Guid InjectTypeId { get; set; } | ||
public InjectTypeEntity InjectType { get; set; } | ||
public bool IsPublic { get; set; } | ||
public Guid? ParentId { get; set; } | ||
public CatalogEntity Parent { get; set; } | ||
public virtual ICollection<InjectEntity> Injects { get; set; } = new HashSet<InjectEntity>(); | ||
public virtual ICollection<CatalogUnitEntity> CatalogUnits { get; set; } = new HashSet<CatalogUnitEntity>(); | ||
public virtual ICollection<CatalogInjectEntity> CatalogInjects { get; set; } = new HashSet<CatalogInjectEntity>(); | ||
} | ||
|
||
public class CatalogConfiguration : IEntityTypeConfiguration<CatalogEntity> | ||
{ | ||
public void Configure(EntityTypeBuilder<CatalogEntity> builder) | ||
{ | ||
builder.HasIndex(x => new { x.Name }).IsUnique(); | ||
} | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2024 Carnegie Mellon University. All Rights Reserved. | ||
// Released under a MIT (SEI)-style license, please see LICENSE.md in the project root for license information or contact [email protected] for full terms. | ||
|
||
using System; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Blueprint.Api.Data.Models | ||
{ | ||
public class CatalogInjectEntity | ||
{ | ||
public CatalogInjectEntity() { } | ||
|
||
public CatalogInjectEntity(Guid injectId, Guid catalogId) | ||
{ | ||
InjectId = injectId; | ||
CatalogId = catalogId; | ||
} | ||
|
||
[Key] | ||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] | ||
public Guid Id { get; set; } | ||
|
||
public Guid InjectId { get; set; } | ||
public InjectEntity Inject { get; set; } | ||
|
||
public Guid CatalogId { get; set; } | ||
public CatalogEntity Catalog { get; set; } | ||
} | ||
|
||
public class CatalogInjectConfiguration : IEntityTypeConfiguration<CatalogInjectEntity> | ||
{ | ||
public void Configure(EntityTypeBuilder<CatalogInjectEntity> builder) | ||
{ | ||
builder.HasIndex(x => new { x.InjectId, x.CatalogId }).IsUnique(); | ||
|
||
builder | ||
.HasOne(u => u.Inject) | ||
.WithMany(p => p.CatalogInjects) | ||
.HasForeignKey(x => x.InjectId) | ||
.OnDelete(DeleteBehavior.Cascade); | ||
builder | ||
.HasOne(u => u.Catalog) | ||
.WithMany(p => p.CatalogInjects) | ||
.HasForeignKey(x => x.CatalogId) | ||
.OnDelete(DeleteBehavior.Cascade); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2024 Carnegie Mellon University. All Rights Reserved. | ||
// Released under a MIT (SEI)-style license, please see LICENSE.md in the project root for license information or contact [email protected] for full terms. | ||
|
||
using System; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Blueprint.Api.Data.Models | ||
{ | ||
public class CatalogUnitEntity | ||
{ | ||
public CatalogUnitEntity() { } | ||
|
||
public CatalogUnitEntity(Guid unitId, Guid catalogId) | ||
{ | ||
UnitId = unitId; | ||
CatalogId = catalogId; | ||
} | ||
|
||
[Key] | ||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] | ||
public Guid Id { get; set; } | ||
|
||
public Guid UnitId { get; set; } | ||
public UnitEntity Unit { get; set; } | ||
|
||
public Guid CatalogId { get; set; } | ||
public CatalogEntity Catalog { get; set; } | ||
} | ||
|
||
public class CatalogUnitConfiguration : IEntityTypeConfiguration<CatalogUnitEntity> | ||
{ | ||
public void Configure(EntityTypeBuilder<CatalogUnitEntity> builder) | ||
{ | ||
builder.HasIndex(x => new { x.UnitId, x.CatalogId }).IsUnique(); | ||
|
||
builder | ||
.HasOne(u => u.Unit) | ||
.WithMany(p => p.CatalogUnits) | ||
.HasForeignKey(x => x.UnitId) | ||
.OnDelete(DeleteBehavior.Cascade); | ||
builder | ||
.HasOne(u => u.Catalog) | ||
.WithMany(p => p.CatalogUnits) | ||
.HasForeignKey(x => x.CatalogId) | ||
.OnDelete(DeleteBehavior.Cascade); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2024 Carnegie Mellon University. All Rights Reserved. | ||
// Released under a MIT (SEI)-style license, please see LICENSE.md in the project root for license information or contact [email protected] for full terms. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
|
||
namespace Blueprint.Api.Data.Models | ||
{ | ||
public class InjectEntity : BaseEntity | ||
{ | ||
[Key] | ||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] | ||
public Guid Id { get; set; } | ||
public Guid InjectTypeId { get; set; } | ||
public InjectTypeEntity InjectType { get; set; } | ||
public Guid? RequiresInjectId { get; set; } | ||
public virtual InjectEntity RequiresInject { get; set; } | ||
public virtual ICollection<DataValueEntity> DataValues { get; set; } = new HashSet<DataValueEntity>(); | ||
public virtual ICollection<CatalogInjectEntity> CatalogInjects { get; set; } = new HashSet<CatalogInjectEntity>(); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2024 Carnegie Mellon University. All Rights Reserved. | ||
// Released under a MIT (SEI)-style license, please see LICENSE.md in the project root for license information or contact [email protected] for full terms. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Blueprint.Api.Data.Models | ||
{ | ||
public class InjectTypeEntity : BaseEntity | ||
{ | ||
[Key] | ||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] | ||
public Guid Id { get; set; } | ||
public string Name { get; set; } | ||
public string Description { get; set; } | ||
public virtual ICollection<DataFieldEntity> DataFields { get; set; } = new HashSet<DataFieldEntity>(); | ||
} | ||
|
||
public class InjectTypeConfiguration : IEntityTypeConfiguration<InjectTypeEntity> | ||
{ | ||
public void Configure(EntityTypeBuilder<InjectTypeEntity> builder) | ||
{ | ||
builder.HasIndex(x => new { x.Name }).IsUnique(); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.