ln.skyscanner/SkyEntities.cs

61 lines
2.0 KiB
C#
Raw Normal View History

2019-03-26 12:53:42 +01:00
// /**
// * File: SkyEntities.cs
// * Author: haraldwolff
// *
// * This file and it's content is copyrighted by the Author and / or copyright holder.
// * Any use wihtout proper permission is illegal and may lead to legal actions.
// *
// *
// **/
using System;
using ln.types.odb;
using ln.skyscanner.entities;
using System.IO;
2019-04-05 00:59:04 +02:00
using ln.http.resources;
using System.Linq;
2019-04-08 08:47:12 +02:00
using ln.types.odb.mapped;
2019-03-26 12:53:42 +01:00
namespace ln.skyscanner
{
public class SkyEntities
{
2019-04-05 00:59:04 +02:00
[Callable]
public Node[] Nodes => nodeCollection.ToArray();
2019-03-26 12:53:42 +01:00
public SkyScanner SkyScanner { get; }
public string BasePath => Path.Combine(SkyScanner.BasePath, "entities");
public GlobalNetwork GlobalNetwork { get; private set; }
2019-03-27 07:49:49 +01:00
public ODB odDatabase { get; private set; }
public ODBCollection<Node> nodeCollection { get; private set; }
2019-04-03 09:19:37 +02:00
//public ODBCollection<NetworkInterface> interfaceCollection { get; private set; }
//public ODBCollection<IntfIP> intfIPCollection { get; private set; }
2019-03-27 07:49:49 +01:00
public ODBCollection<Subnet> subnetCollection { get; private set; }
2019-04-08 08:47:12 +02:00
public ODBCollection<PointOfPresence> popCollection { get; private set; }
2019-03-26 12:53:42 +01:00
public SkyEntities(SkyScanner skyScanner)
{
SkyScanner = skyScanner;
2019-03-27 07:49:49 +01:00
odDatabase = new ODB(BasePath);
nodeCollection = odDatabase.GetCollection<Node>();
subnetCollection = odDatabase.GetCollection<Subnet>();
2019-03-26 12:53:42 +01:00
2019-04-01 15:17:41 +02:00
nodeCollection.EnsureIndex("PrimaryIP");
2019-04-03 09:19:37 +02:00
nodeCollection.EnsureIndex("Interfaces[].ConfiguredIPs[].IP");
nodeCollection.EnsureIndex("Interfaces[].ConfiguredIPs[].Network");
2019-04-08 08:47:12 +02:00
nodeCollection.EnsureIndex("uniqueIdentity");
2019-04-02 13:00:15 +02:00
2019-04-03 09:19:37 +02:00
subnetCollection.EnsureIndex("Network");
2019-03-29 08:55:09 +01:00
2019-04-08 08:47:12 +02:00
popCollection = odDatabase.GetCollection<PointOfPresence>();
popCollection.EnsureIndex("ForeignName");
popCollection.EnsureIndex("nodeIDList[]");
2019-03-26 12:53:42 +01:00
GlobalNetwork = new GlobalNetwork(this);
}
}
}