Skip to content

Commit

Permalink
7.1 Deployment (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraser Greenroyd authored Mar 27, 2024
2 parents 7610c16 + 55fafd2 commit b15a2aa
Show file tree
Hide file tree
Showing 32 changed files with 86 additions and 53 deletions.
3 changes: 2 additions & 1 deletion Mongo_Adapter/AdapterActions/Execute.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -91,3 +91,4 @@ public bool MoveCollection(MongoAdapter other, bool replaceContent = true)




3 changes: 2 additions & 1 deletion Mongo_Adapter/AdapterActions/Pull.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -79,3 +79,4 @@ public override IEnumerable<object> Pull(IRequest query, PullType pullType = Pul




22 changes: 14 additions & 8 deletions Mongo_Adapter/AdapterActions/Push.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -44,6 +44,18 @@ public override List<object> Push(IEnumerable<object> objects, string tag = "",
if (m_Client.Cluster.Description.State == MongoDB.Driver.Core.Clusters.ClusterState.Disconnected)
return new List<object>();

// Make sure that the push type is supported
if (pushType != PushType.AdapterDefault && pushType != PushType.DeleteThenCreate && pushType != PushType.CreateOnly && pushType != PushType.UpdateOrCreateOnly)
{
BH.Engine.Base.Compute.RecordError($"{this.GetType().Name} only supports the following {nameof(PushType)}s:" +
$"\n\t- {nameof(PushType.CreateOnly)} => appends content (default setting)" +
$"\n\t- {nameof(PushType.DeleteThenCreate)} => replaces all content" +
$"\n\t- {nameof(PushType.UpdateOrCreateOnly)} => upsert" +
$"\nEvery other {nameof(PushType)} will behave as {nameof(PushType.CreateOnly)}.");

return new List<object>();
}

// Create the bulk query for the object to replace/insert
DateTime timestamp = DateTime.Now;
IEnumerable<BsonDocument> documents = objects.Select(x => Engine.Adapters.Mongo.Convert.ToBson(x, tag, timestamp));
Expand All @@ -70,13 +82,6 @@ public override List<object> Push(IEnumerable<object> objects, string tag = "",
else
m_Collection.InsertMany(documents);

if (pushType != PushType.AdapterDefault && pushType != PushType.DeleteThenCreate && pushType != PushType.CreateOnly && pushType != PushType.UpdateOrCreateOnly)
BH.Engine.Base.Compute.RecordNote($"{this.GetType().Name} only supports the following {nameof(PushType)}s:" +
$"\n\t- {nameof(PushType.CreateOnly)} => appends content (default setting)" +
$"\n\t- {nameof(PushType.DeleteThenCreate)} => replaces all content" +
$"\n\t- {nameof(PushType.UpdateOrCreateOnly)} => upsert" +
$"\nEvery other {nameof(PushType)} will behave as {nameof(PushType.CreateOnly)}.");

// Push in the history database as well
if (m_History != null)
{
Expand All @@ -102,3 +107,4 @@ public override List<object> Push(IEnumerable<object> objects, string tag = "",




3 changes: 2 additions & 1 deletion Mongo_Adapter/AdapterActions/Remove.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -54,3 +54,4 @@ public override int Remove(IRequest filter, ActionConfig actionConfig = null)




29 changes: 15 additions & 14 deletions Mongo_Adapter/MongoAdapter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -41,13 +41,13 @@ public partial class MongoAdapter : BHoMAdapter
/**** Constructors ****/
/***************************************************/

[Description("Create an adapter to a Mongo database. Use this constructor if you have the name of the server hosting the database and its port number")]
[Input("serverName", "address of the server hosting the database. Will generally start with \"mongodb://\"")]
[Input("port", "port number used to access the database. This will generally be the number after the ':' at the end of the address of the database")]
[Input("databaseName", "name of the database itself")]
[Input("collectionName", "name of the collection you want to access inside that database")]
[Input("useHistory", "If true, will store a copy of the data pushed to Mongo in a separate collection. Data from the last 5 pushes is available there")]
[Output("adapter", "Adapter to Mongo Database")]
[Description("Create an adapter to a Mongo database. Use this constructor if you have the name of the server hosting the database and its port number.")]
[Input("serverName", "address of the server hosting the database. Will generally start with \"mongodb://\".")]
[Input("port", "port number used to access the database. This will generally be the number after the ':' at the end of the address of the database.")]
[Input("databaseName", "name of the database itself.")]
[Input("collectionName", "name of the collection you want to access inside that database.")]
[Input("useHistory", "If true, will store a copy of the data pushed to Mongo in a separate collection. Data from the last 5 pushes is available there.")]
[Output("adapter", "Adapter to Mongo Database.")]
public MongoAdapter(string serverName = "mongodb://localhost", int port = 27017, string databaseName = "project", string collectionName = "bhomObjects", bool useHistory = true)
{

Expand Down Expand Up @@ -85,12 +85,12 @@ public MongoAdapter(string serverName = "mongodb://localhost", int port = 27017,

/***************************************************/

[Description("Create an adapter to a Mongo database. Use this constructor if you have a single long string representing the location of your database (and potentially identification)")]
[Input("connectionString", "Text given to you to access the database. Will generally start with \"mongodb://\"")]
[Input("databaseName", "name of the database itself")]
[Input("collectionName", "name of the collection you want to access inside that database")]
[Input("useHistory", "If true, will store a copy of the data pushed to Mongo in a separate collection. Data from the last 5 pushes is available there")]
[Output("adapter", "Adapter to Mongo Database")]
[Description("Create an adapter to a Mongo database. Use this constructor if you have a single long string representing the location of your database (and potentially identification).")]
[Input("connectionString", "Text given to you to access the database. Will generally start with \"mongodb://\".")]
[Input("databaseName", "name of the database itself.")]
[Input("collectionName", "name of the collection you want to access inside that database.")]
[Input("useHistory", "If true, will store a copy of the data pushed to Mongo in a separate collection. Data from the last 5 pushes is available there.")]
[Output("adapter", "Adapter to Mongo Database.")]
public MongoAdapter(string connectionString, string databaseName = "project", string collectionName = "bhomObjects", bool useHistory = false)
{

Expand Down Expand Up @@ -183,3 +183,4 @@ public bool IsConnected()




3 changes: 2 additions & 1 deletion Mongo_Adapter/MongoServer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -109,3 +109,4 @@ private void M_Process_Exited(object sender, EventArgs e)




2 changes: 1 addition & 1 deletion Mongo_Adapter/Mongo_Adapter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Copyright>Copyright © https://github.com/BHoM</Copyright>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<RootNamespace>BH.Adapter.Mongo</RootNamespace>
<FileVersion>7.0.0.0</FileVersion>
<FileVersion>7.1.0.0</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
3 changes: 2 additions & 1 deletion Mongo_Engine/Compute/MongoAbsoluteValue.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -48,3 +48,4 @@ public static string MongoAbsVal(List<object> item)




3 changes: 2 additions & 1 deletion Mongo_Engine/Compute/MongoAddField.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -55,3 +55,4 @@ public static string MongoAddField(string key, List<object> items)




3 changes: 2 additions & 1 deletion Mongo_Engine/Compute/MongoAnd.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -48,3 +48,4 @@ public static string MongoAnd(List<object> operands)




3 changes: 2 additions & 1 deletion Mongo_Engine/Compute/MongoClean.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -65,3 +65,4 @@ public static string MongoCleanVariable(List<object> cleanMe, string outputObjec




3 changes: 2 additions & 1 deletion Mongo_Engine/Compute/MongoCrossRef.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -77,3 +77,4 @@ public static string MongoCrossRef(string otherColl, List<string> props2Match, L




3 changes: 2 additions & 1 deletion Mongo_Engine/Compute/MongoDivision.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -48,3 +48,4 @@ public static string MongoDivision(object numerator, object denominator)




3 changes: 2 additions & 1 deletion Mongo_Engine/Compute/MongoGroup.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -69,3 +69,4 @@ public static string MongoGroup(List<string> groupBy, List<string> projectForwar




3 changes: 2 additions & 1 deletion Mongo_Engine/Compute/MongoListItem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -54,3 +54,4 @@ public static string MongoListItem(string mongoArrayName, object index)




3 changes: 2 additions & 1 deletion Mongo_Engine/Compute/MongoMatchDomain.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -53,3 +53,4 @@ public static List<string> MongoMatchDomain(List<object> key, List<object> upper




3 changes: 2 additions & 1 deletion Mongo_Engine/Compute/MongoMatchList.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -59,3 +59,4 @@ public static List<string> MongoMatchList(string key, List<object> filter)




3 changes: 2 additions & 1 deletion Mongo_Engine/Compute/MongoMax.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -58,3 +58,4 @@ public static string MongoMax(string mongoArrayName)




3 changes: 2 additions & 1 deletion Mongo_Engine/Compute/MongoMin.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -58,3 +58,4 @@ public static string MongoMin(string mongoArrayName)




3 changes: 2 additions & 1 deletion Mongo_Engine/Compute/MongoPower.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -48,3 +48,4 @@ public static string MongoPower(object @base, object exponent)




3 changes: 2 additions & 1 deletion Mongo_Engine/Compute/MongoProduct.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -48,3 +48,4 @@ public static string MongoProduct(List<object> operands)




3 changes: 2 additions & 1 deletion Mongo_Engine/Compute/MongoProject.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -60,3 +60,4 @@ public static string MongoProject(List<string> filter)




3 changes: 2 additions & 1 deletion Mongo_Engine/Compute/MongoSubtraction.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -48,3 +48,4 @@ public static string MongoSubtraction(object a, object b)




3 changes: 2 additions & 1 deletion Mongo_Engine/Compute/MongoSum.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
* 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.
Expand Down Expand Up @@ -48,3 +48,4 @@ public static string MongoSum( List<object> operands)




Loading

0 comments on commit b15a2aa

Please sign in to comment.