-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ODS-1462] Use semantic model to derive entity specifications (#862)
- Loading branch information
1 parent
9f01dce
commit 0953d71
Showing
13 changed files
with
244 additions
and
311 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
38 changes: 38 additions & 0 deletions
38
Application/EdFi.Ods.Common/Specifications/EducationOrganizationTypesProvider.cs
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,38 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Licensed to the Ed-Fi Alliance under one or more agreements. | ||
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | ||
// See the LICENSE and NOTICES files in the project root for more information. | ||
|
||
using System; | ||
using System.Linq; | ||
using EdFi.Common.Extensions; | ||
using EdFi.Ods.Common.Conventions; | ||
using EdFi.Ods.Common.Models; | ||
using EdFi.Ods.Common.Models.Domain; | ||
|
||
namespace EdFi.Ods.Common.Specifications; | ||
|
||
public class EducationOrganizationTypesProvider : IEducationOrganizationTypesProvider | ||
{ | ||
private readonly Lazy<Entity> _educationOrganizationEntity; | ||
private readonly Lazy<string[]> _validEducationOrganizationTypes; | ||
|
||
public EducationOrganizationTypesProvider(IDomainModelProvider domainModelProvider) | ||
{ | ||
_educationOrganizationEntity = new(() => domainModelProvider.GetDomainModel() | ||
.EntityByFullName[EdFiConventions.EducationOrganizationFullName]); | ||
|
||
_validEducationOrganizationTypes = new(() => domainModelProvider.GetDomainModel() | ||
.Entities.Where(e => e.BaseEntity == _educationOrganizationEntity.Value) | ||
.Select(e => e.Name) | ||
.InsertAtHead(_educationOrganizationEntity.Value.Name) | ||
.ToArray() | ||
); | ||
} | ||
|
||
/// <inheritdoc cref="IEducationOrganizationTypesProvider.EducationOrganizationTypes" /> | ||
public string[] EducationOrganizationTypes | ||
{ | ||
get => _validEducationOrganizationTypes.Value; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Application/EdFi.Ods.Common/Specifications/IEducationOrganizationEntitySpecification.cs
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,17 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Licensed to the Ed-Fi Alliance under one or more agreements. | ||
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | ||
// See the LICENSE and NOTICES files in the project root for more information. | ||
|
||
using System; | ||
|
||
namespace EdFi.Ods.Common.Specifications | ||
{ | ||
public interface IEducationOrganizationEntitySpecification | ||
{ | ||
bool IsEducationOrganizationBaseEntity(string typeName); | ||
bool IsEducationOrganizationEntity(string typeName); | ||
bool IsEducationOrganizationEntity(Type type); | ||
bool IsEducationOrganizationIdentifier(string propertyName); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
Application/EdFi.Ods.Common/Specifications/IEducationOrganizationTypesProvider.cs
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,19 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Licensed to the Ed-Fi Alliance under one or more agreements. | ||
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | ||
// See the LICENSE and NOTICES files in the project root for more information. | ||
|
||
namespace EdFi.Ods.Common.Specifications; | ||
|
||
/// <summary> | ||
/// Defines a method for obtaining the names of the Education Organization type entities | ||
/// in the model. | ||
/// </summary> | ||
public interface IEducationOrganizationTypesProvider | ||
{ | ||
/// <summary> | ||
/// Gets the names of the entities of the Education Organization types found in the | ||
/// model. | ||
/// </summary> | ||
string[] EducationOrganizationTypes { get; } | ||
} |
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.