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

[ODS-6332] NHibernate query issues relating to GeneralStudentProgramAssociation #1024

Merged
merged 6 commits into from
Apr 18, 2024
Merged
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
4 changes: 0 additions & 4 deletions .github/workflows/CodeQL Security Scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ jobs:
fail-fast: false

steps:
- name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
with:
dotnet-version: 3.1.x
- name: Checkout Ed-Fi-ODS-Implementation
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ jobs:
runs-on: windows-latest

steps:
- name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
with:
dotnet-version: 3.1.x
Comment on lines -33 to -36
Copy link
Contributor Author

@axelmarquezh axelmarquezh Apr 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this step because we need .net sdk >= v6 which comes pre-installed with the base image.

- name: Support longpaths
run: git config --system core.longpaths true
- name: Checkout Ed-Fi-ODS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ jobs:
runs-on: windows-latest

steps:
- name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
with:
dotnet-version: 3.1.x
- name: Support longpaths
run: git config --system core.longpaths true
- name: Checkout Ed-Fi-ODS
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/Pkg EdFi.Ods.Minimal.Template.TPDM.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ jobs:
runs-on: windows-latest

steps:
- name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
with:
dotnet-version: 3.1.x
- name: Support longpaths
run: git config --system core.longpaths true
- name: Checkout Ed-Fi-ODS
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/Pkg EdFi.Ods.Minimal.Template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ jobs:
runs-on: windows-latest

steps:
- name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
with:
dotnet-version: 3.1.x
- name: Support longpaths
run: git config --system core.longpaths true
- name: Checkout Ed-Fi-ODS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ jobs:
runs-on: windows-latest

steps:
- name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
with:
dotnet-version: 3.1.x
- name: Support longpaths
run: git config --system core.longpaths true
- name: Checkout Ed-Fi-ODS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ jobs:
runs-on: windows-latest

steps:
- name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
with:
dotnet-version: 3.1.x
- name: Support longpaths
run: git config --system core.longpaths true
- name: Checkout Ed-Fi-ODS
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/Pkg EdFi.Ods.Populated.Template.TPDM.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ jobs:
runs-on: windows-latest

steps:
- name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
with:
dotnet-version: 3.1.x
- name: Support longpaths
run: git config --system core.longpaths true
- name: Checkout Ed-Fi-ODS
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/Pkg EdFi.Ods.Populated.Template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ jobs:
runs-on: windows-latest

steps:
- name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
with:
dotnet-version: 3.1.x
- name: Support longpaths
run: git config --system core.longpaths true
- name: Checkout Ed-Fi-ODS
Expand Down
3 changes: 2 additions & 1 deletion Application/EdFi.Admin.DataAccess/Contexts/UsersContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public abstract class UsersContext : DbContext, IUsersContext
protected UsersContext(string connectionString)
: base(connectionString)
{
Database.SetInitializer(new ValidateDatabase<UsersContext>());
Database.SetInitializer(new ValidateDatabase<SqlServerUsersContext>());
Database.SetInitializer(new ValidateDatabase<PostgresUsersContext>());
}
public const string UserTableName = "Users";

Expand Down
7 changes: 1 addition & 6 deletions Application/EdFi.Admin.DataAccess/Utils/ValidateDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ public void InitializeDatabase(TContext context)
{
if (!context.Database.Exists())
{
throw new ConfigurationErrorsException("Admin database does not exist.");
}

if (!context.Database.CompatibleWithModel(true))
{
throw new InvalidOperationException($"The {context.Database.Connection.Database} database is not compatible with the entity model.");
throw new ConfigurationErrorsException("Unable to open connection to the Admin database.");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Application/EdFi.Ods.Api/EdFi.Ods.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="AspNetCore.HealthChecks.NpgSql" Version="6.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="6.0.1" />
<PackageReference Include="EdFi.Suite3.Admin.DataAccess" Version="5.4.256" />
<PackageReference Include="EdFi.Suite3.Admin.DataAccess" Version="5.4.300" />
<PackageReference Include="EdFi.Suite3.Common" Version="5.4.247" />
<PackageReference Include="EdFi.Suite3.Security.DataAccess" Version="5.4.250" />
<PackageReference Include="EdFi.Suite3.Security.DataAccess" Version="5.4.292" />
<PackageReference Include="EntityFramework" Version="6.4.4" />
<PackageReference Include="FluentValidation" Version="8.6.3" />
<PackageReference Include="Iesi.Collections" Version="4.0.4" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// See the LICENSE and NOTICES files in the project root for more information.

using System.Collections.Generic;
using System.Configuration;
using System.Net.Http.Headers;
using System.Security.Claims;
using System.Text.Encodings.Web;
Expand Down Expand Up @@ -59,6 +60,11 @@ protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
return authenticationResult.AuthenticateResult;
}
}
catch(ConfigurationException)
{
// The Security repository couldn't open a connection to the Security database
throw;
}
catch
{
return AuthenticateResult.Fail("Invalid Authorization Header");
Expand Down
13 changes: 2 additions & 11 deletions Application/EdFi.Ods.Common/Caching/IdentificationCodeMatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,7 @@ public override bool Equals(object obj)
return Equals((IdentificationCodeMatch) obj);
}

public override int GetHashCode()
{
unchecked
{
return ((IdentificationCode != null
? IdentificationCode.GetHashCode()
: 0) * 397) ^ (AssigningOrganizationIdentificationCode != null
? AssigningOrganizationIdentificationCode.GetHashCode()
: 0);
}
}
public override int GetHashCode()
=> HashCode.Combine(IdentificationCode, AssigningOrganizationIdentificationCode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,6 @@ public override bool Equals(object obj)
}

public override int GetHashCode()
{
unchecked
{
int hashCode = (PersonType != null
? PersonType.GetHashCode()
: 0);

hashCode = (hashCode * 397) ^ (IdentificationSystemDescriptorUri != null
? IdentificationSystemDescriptorUri.GetHashCode()
: 0);

hashCode = (hashCode * 397) ^ (IdentificationCodeValue != null
? IdentificationCodeValue.GetHashCode()
: 0);

hashCode = (hashCode * 397) ^ EducationOrganizationId;
return hashCode;
}
}
=> HashCode.Combine(PersonType, IdentificationSystemDescriptorUri, IdentificationCodeValue, EducationOrganizationId);
}
}
11 changes: 1 addition & 10 deletions Application/EdFi.Ods.Common/Caching/UniqueIdMatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@ public override bool Equals(object obj)
}

public override int GetHashCode()
{
unchecked
{
return ((UniqueId != null
? UniqueId.GetHashCode()
: 0) * 397) ^ (AssigningOrganizationIdentificationCode != null
? AssigningOrganizationIdentificationCode.GetHashCode()
: 0);
}
}
=> HashCode.Combine(UniqueId, AssigningOrganizationIdentificationCode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,6 @@ public override bool Equals(object obj)
}

public override int GetHashCode()
{
unchecked
{
int hashCode = (PersonType != null
? PersonType.GetHashCode()
: 0);

hashCode = (hashCode * 397) ^ (IdentificationSystemDescriptorUri != null
? IdentificationSystemDescriptorUri.GetHashCode()
: 0);

hashCode = (hashCode * 397) ^ (UniqueId != null
? UniqueId.GetHashCode()
: 0);

hashCode = (hashCode * 397) ^ EducationOrganizationId;
return hashCode;
}
}
=> HashCode.Combine(PersonType, IdentificationSystemDescriptorUri, UniqueId, EducationOrganizationId);
}
}
42 changes: 9 additions & 33 deletions Application/EdFi.Ods.Common/Models/Domain/DomainObjectBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,10 @@ namespace EdFi.Ods.Common.Models.Domain
{
/// <summary>
/// Provides a standard base class for facilitating comparison of objects.
/// For a discussion of the implementation of Equals/GetHashCode, see
/// http://devlicio.us/blogs/billy_mccafferty/archive/2007/04/25/using-equals-gethashcode-effectively.aspx
/// and http://groups.google.com/group/sharp-architecture/browse_thread/thread/f76d1678e68e3ece?hl=en for
/// an in depth and conclusive resolution.
/// </summary>
[Serializable]
public abstract class DomainObjectBase
{
/// <summary>
/// To help ensure hashcode uniqueness, a carefully selected random number multiplier
/// is used within the calculation. Goodrich and Tamassia's Data Structures and
/// Algorithms in Java asserts that 31, 33, 37, 39 and 41 will produce the fewest number
/// of collissions. See http://computinglife.wordpress.com/2008/11/20/why-do-hash-functions-use-prime-numbers/
/// for more information.
/// </summary>
private const int HashMultiplier = 31;

/// <summary>
/// This static member caches the domain signature properties to avoid looking them up for
/// each instance of the same type.
Expand Down Expand Up @@ -80,29 +67,18 @@ public override int GetHashCode()
/// </summary>
public virtual int GetHashCode(Func<PropertyInfo, object> getPropertyValue)
{
unchecked
{
var signatureProperties = GetSignatureProperties();

// It's possible for two objects to return the same hash code based on
// identically valued properties, even if they're of two different types,
// so we include the object's type in the hash calculation
var hashCode = GetType()
.GetHashCode();

hashCode = signatureProperties.Select(property => property.GetValue(this, null))
.Where(value => value != null)
.Aggregate(hashCode, (current, value) => (current * HashMultiplier) ^ value.GetHashCode());
var signatureProperties = GetSignatureProperties();

if (signatureProperties.Any())
{
return hashCode;
}
var hashCode = new HashCode();

// If no properties were flagged as being part of the signature of the object,
// then simply return the hashcode of the base object as the hashcode.
return base.GetHashCode();
foreach (var signatureProperty in signatureProperties)
{
hashCode.Add(signatureProperty.GetValue(this, null));
}

// If no properties were flagged as being part of the signature of the object,
// then simply return the hashcode of the base object as the hashcode.
return signatureProperties.Any() ? hashCode.ToHashCode() : base.GetHashCode();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,9 @@

namespace EdFi.Ods.Common.Models.Domain
{
/// <summary>
/// For a discussion of this object, see
/// http://devlicio.us/blogs/billy_mccafferty/archive/2007/04/25/using-equals-gethashcode-effectively.aspx
/// </summary>
[Serializable]
public abstract class EntityWithCompositeKey : DomainObjectBase //ValidatableObject
{
/// <summary>
/// To help ensure hashcode uniqueness, a carefully selected random number multiplier
/// is used within the calculation. Goodrich and Tamassia's Data Structures and
/// Algorithms in Java asserts that 31, 33, 37, 39 and 41 will produce the fewest number
/// of collissions. See http://computinglife.wordpress.com/2008/11/20/why-do-hash-functions-use-prime-numbers/
/// for more information.
/// </summary>
private const int HashMultiplier = 31;

private int? cachedHashcode;

public override bool Equals(object obj)
Expand Down Expand Up @@ -91,52 +78,20 @@ public override int GetHashCode()
return cachedHashcode.Value;
}

//if (this.IsTransient())
//{
// this.cachedHashcode = base.GetHashCode();
//}
//else
{
unchecked
{
// It's possible for two objects to return the same hash code based on
// identically valued properties, even if they're of two different types,
// so we include the object's type in the hash calculation
var hashCode = GetType()
.GetHashCode();
var signatureProperties = GetSignatureProperties();

cachedHashcode = (hashCode * HashMultiplier) ^ GetSignatureHashCode();
}
}

return cachedHashcode.Value;
}
var hashCode = new HashCode();

private int GetSignatureHashCode()
{
unchecked
foreach (var signatureProperty in signatureProperties)
{
var signatureProperties = GetSignatureProperties();

// It's possible for two objects to return the same hash code based on
// identically valued properties, even if they're of two different types,
// so we include the object's type in the hash calculation
var hashCode = GetType()
.GetHashCode();
hashCode.Add(signatureProperty.GetValue(this, null));
}

hashCode = signatureProperties.Select(property => property.GetValue(this, null))
.Where(value => value != null)
.Aggregate(hashCode, (current, value) => (current * HashMultiplier) ^ value.GetHashCode());
// If no properties were flagged as being part of the signature of the object,
// then simply return the hashcode of the base object as the hashcode.
cachedHashcode = signatureProperties.Any() ? hashCode.ToHashCode() : base.GetHashCode();

if (signatureProperties.Any())
{
return hashCode;
}

// If no properties were flagged as being part of the signature of the object,
// then simply return the hashcode of the base object as the hashcode.
return base.GetHashCode();
}
return cachedHashcode.Value;
}

// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<ItemGroup>
<PackageReference Include="EdFi.Suite3.Common" Version="5.4.247" />
<PackageReference Include="Autofac" Version="6.3.0" />
<PackageReference Include="EdFi.Suite3.Security.DataAccess" Version="5.4.250" />
<PackageReference Include="EdFi.Suite3.Security.DataAccess" Version="5.4.292" />
<PackageReference Include="EntityFramework" Version="6.4.4" />
<PackageReference Include="FakeItEasy" Version="7.2.0" />
<PackageReference Include="Iesi.Collections" Version="4.0.4" />
Expand Down
Loading
Loading