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

8.0 Deployment #394

Merged
merged 20 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
badf1a5
Update assembly file version to 8.0.0.0 and AssemblyVersion to 8.0.0.0
BHoMBot Sep 20, 2024
7bc0969
Start of milestone changes for 8.0 (#392)
adecler Sep 23, 2024
2d7c56d
Add attribute PriorityTypes to IBHoMAdapter
GCRA101 Oct 1, 2024
db4103c
Implement PriorityTypes attribute in the BHoMAdapter concrete class
GCRA101 Oct 1, 2024
e1cf3c7
Turn PriorityTypes data structure from List into Queue
GCRA101 Oct 1, 2024
24e3b8a
Add HandlePriorities attribute to AdapterSettings class
GCRA101 Oct 2, 2024
944f808
Build the PriorityComparer and use it to sort objects based on Priori…
GCRA101 Oct 2, 2024
268dbdd
Merge branch 'develop' of https://github.com/BHoM/BHoM_Adapter into B…
GCRA101 Oct 2, 2024
708753b
Turn PriorityTypes data structure from Dictionary to List
GCRA101 Oct 16, 2024
3fa7b39
Update PriorityTypes Constructor as List<Type>
GCRA101 Oct 16, 2024
363b59b
Remove reference to System.Collections.Immutable dll
GCRA101 Oct 16, 2024
5da9c0d
Merge branch 'BHoM_Adapter-#390-AddPriorityTypesForPush' of https://g…
GCRA101 Oct 16, 2024
b50f126
Update method for sorting elements based on PriorityTypes
GCRA101 Oct 16, 2024
12d2250
Make Run of Objects Sorting Algorithm based on Priorities independent…
GCRA101 Oct 16, 2024
a683a27
Moved location of GetPrioritySortedObjects method call
GCRA101 Oct 16, 2024
96225d9
Remove PriorityComparer Class
GCRA101 Oct 16, 2024
3587c92
Merge branch 'BHoM_Adapter-#390-AddPriorityTypesForPush' of https://g…
GCRA101 Oct 16, 2024
07b5331
Fix bug wrong equality symbol
GCRA101 Oct 28, 2024
81bab0e
Udpate Copyright Header for the GetPrioritySortedObjects.cs Class
GCRA101 Nov 8, 2024
dcb1bd9
Add Priority Types For Push (#393)
alelom Nov 13, 2024
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: 2 additions & 2 deletions .ci/unit-tests/BHoM_Adapter_Tests/BHoM_Adapter_Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<FileVersion>7.3.0.0</FileVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<FileVersion>8.0.0.0</FileVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<Description>https://github.com/BHoM/BHoM_Adapter</Description>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
4 changes: 2 additions & 2 deletions Adapter_Engine/Adapter_Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<Description>https://github.com/BHoM/BHoM_Adapter</Description>
<Version>5.0.0</Version>
<Authors>BHoM</Authors>
<Copyright>Copyright © https://github.com/BHoM</Copyright>
<RootNamespace>BH.Engine.Adapter</RootNamespace>
<FileVersion>7.3.0.0</FileVersion>
<FileVersion>8.0.0.0</FileVersion>
<Configurations>Debug;Release;Test</Configurations>
</PropertyGroup>

Expand Down
85 changes: 85 additions & 0 deletions Adapter_Engine/Query/GetPrioritySortedObjects.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2024, the respective contributors. All rights reserved.
*
* Each contributor holds copyright over their respective contributions.
* The project versioning (Git) records all such contribution source information.
*
*
* The BHoM is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3.0 of the License, or
* (at your option) any later version.
*
* The BHoM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/


using BH.oM.Base;
using BH.Engine.Base;
using BH.oM.Data;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using BH.oM.Adapter;
using BH.oM.Base.Attributes;
using BH.Engine.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;

namespace BH.Engine.Adapter
{
public static partial class Query
{
/***************************************************/
/**** Push Support methods ****/
/***************************************************/
// These are support methods required by other methods in the Push process.

[Description("Groups of objects are sorted by priority order.")]
[Input("objects", "Objects to group and sort by priority order.")]
[Input("pushType", "PushType provided in the Push.")]
[Input("bHoMAdapter", "The PriorityTypes that define the order of the output will be gathered from this Adapter instance.")]
public static List<Tuple<Type, PushType, IEnumerable<object>>> GetPrioritySortedObjects(this List<Tuple<Type, PushType, IEnumerable<object>>> objects, PushType pushType, IBHoMAdapter bHoMAdapter)

Check warning on line 50 in Adapter_Engine/Query/GetPrioritySortedObjects.cs

View check run for this annotation

BHoMBot-CI / beta-documentation-compliance

Adapter_Engine/Query/GetPrioritySortedObjects.cs#L50

Method must contain an Output or MultiOutput attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/HasOutputAttribute
{
List<Type> priorityTypes = bHoMAdapter?.PriorityTypes;

if(objects == null || objects.Count == 0 || priorityTypes == null || priorityTypes.Count == 0)
return objects;

List<Tuple<Type, PushType, IEnumerable<object>>> prioritySortedObjects = objects.ToList();

//Loop through the priority types backwards to ensure the first one in the list is moved to the top
for (int i = priorityTypes.Count - 1; i >= 0; i--)
{
Type current = priorityTypes[i];
//Loop through the object list backwards to keep previous sorting intact
//Intentionally skipping index 0 (j >= 1) as object will be moved there anyway
for (int j = prioritySortedObjects.Count - 1; j >= 1; j--)
{
if (prioritySortedObjects[j].Item1 == current)
{
var temp = prioritySortedObjects[j];
prioritySortedObjects.RemoveAt(j);
prioritySortedObjects.Insert(0, temp);
j++; //Increment index to test against the same index again (counteracting the j-- in the for loop) as list will have been shifted
}
}
}

return prioritySortedObjects;
}

/***************************************************/
}
}



4 changes: 2 additions & 2 deletions Adapter_oM/Adapter_oM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<Description>https://github.com/BHoM/BHoM_Adapter</Description>
<Version>5.0.0</Version>
<Authors>BHoM</Authors>
<Copyright>Copyright © https://github.com/BHoM</Copyright>
<RootNamespace>BH.oM.Adapter</RootNamespace>
<FileVersion>7.3.0.0</FileVersion>
<FileVersion>8.0.0.0</FileVersion>
<Configurations>Debug;Release;Test</Configurations>
</PropertyGroup>

Expand Down
2 changes: 2 additions & 0 deletions Adapter_oM/IBHoMAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using BH.oM.Base;
using BH.oM.Data.Requests;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
Expand All @@ -37,6 +38,7 @@ public interface IBHoMAdapter
ModuleSet AdapterModules { get; }
Dictionary<Type, object> AdapterComparers { get; }
Dictionary<Type, List<Type>> DependencyTypes { get; }
List<Type> PriorityTypes {get;}
Guid AdapterGuid { get; }

List<object> Push(IEnumerable<object> objects, string tag = "", PushType pushType = PushType.AdapterDefault, ActionConfig actionConfig = null);
Expand Down
1 change: 1 addition & 0 deletions Adapter_oM/Settings-Config/AdapterSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class AdapterSettings : IObject

[Description("If your adapter does not define DependencyTypes, this can be set to false for performance.")]
public virtual bool HandleDependencies { get; set; } = true;
public virtual bool HandlePriorities { get; set; } = false;
public virtual bool UseAdapterId { get; set; } = true;
public virtual bool UseHashComparerAsDefault { get; set; } = false;
public virtual bool ProcessInMemory { get; set; } = false;
Expand Down
5 changes: 5 additions & 0 deletions BHoM_Adapter/AdapterActions/Push.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,15 @@ public virtual List<object> Push(IEnumerable<object> objects, string tag = "", P
List<Tuple<Type, PushType, IEnumerable<object>>> orderedObjects;

if(m_AdapterSettings.HandleDependencies)
{
orderedObjects = Engine.Adapter.Query.GetDependencySortedObjects(objectsToPush, pushType, this);
}
else
orderedObjects = objectsToPush.GroupBy(x => x.GetType()).Select(x => new Tuple<Type, PushType, IEnumerable<object>>(x.Key, pushType, x.Cast<object>())).ToList();


if (m_AdapterSettings.HandlePriorities)
orderedObjects = Engine.Adapter.Query.GetPrioritySortedObjects(orderedObjects, pushType, this);
// We now have objects grouped per type, and the groups are sorted following the dependency order.
foreach (var group in orderedObjects)
{
Expand Down
9 changes: 9 additions & 0 deletions BHoM_Adapter/BHoMAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

public Type AdapterIdFragmentType { get; set; }

[Description("Modules containing adapter functionality")]

Check warning on line 41 in BHoM_Adapter/BHoMAdapter.cs

View check run for this annotation

BHoMBot-CI / beta-documentation-compliance

BHoM_Adapter/BHoMAdapter.cs#L41

Documentation attribute should end with grammatically correct punctuation (., !, or ?) - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/AttributeHasEndingPunctuation
public ModuleSet AdapterModules { get; set; } = new ModuleSet();

[Description("Object comparers to be used within a specific Adapter." +
Expand All @@ -59,6 +59,15 @@
// {typeof(Bar), new List<Type> { typeof(ISectionProperty), typeof(Node) } }
};

public List<Type> PriorityTypes { get; protected set; } = new List<Type>()
{
// If you are using the dependency types, this only needs to cover cases that are not already handled by this system
// e.g., if Bars are set to have a dependency on Nodes, then there is no need to add them in order in the priority types
// In your adapter constructor, populate this with values like:
// {typeof(Level), typeof(Node), typeof(Bar), ...}

};

public Guid AdapterGuid { get; set; } = Guid.NewGuid();

/***************************************************/
Expand Down
4 changes: 2 additions & 2 deletions BHoM_Adapter/BHoM_Adapter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<Description>https://github.com/BHoM/BHoM_Adapter</Description>
<Version>5.0.0</Version>
<Authors>BHoM</Authors>
<Copyright>Copyright © https://github.com/BHoM</Copyright>
<RootNamespace>BH.Adapter</RootNamespace>
<FileVersion>7.3.0.0</FileVersion>
<FileVersion>8.0.0.0</FileVersion>
<Configurations>Debug;Release;Test</Configurations>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions Structure_AdapterModules/Structure_AdapterModules.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<Description>https://github.com/BHoM/BHoM_Adapter</Description>
<Version>5.0.0</Version>
<Authors>BHoM</Authors>
<Copyright>Copyright © https://github.com/BHoM</Copyright>
<RootNamespace>BH.Adapter.Modules.Structure</RootNamespace>
<FileVersion>7.3.0.0</FileVersion>
<FileVersion>8.0.0.0</FileVersion>
<Configurations>Debug;Release;Test</Configurations>
</PropertyGroup>

Expand Down