Example #1
0
 public MultiConduitCommandHandler(IAggregateRepository aggregateRepository, IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService, IConduitSpecificationRepository conduitSpecificationRepository)
 {
     this.repo = aggregateRepository;
     this.conduitNetworkQueryService     = conduitNetworkQueryService;
     this.routeNetworkQueryService       = routeNetworkQueryService;
     this.conduitSpecificationRepository = conduitSpecificationRepository;
 }
Example #2
0
 public FiberCableCommandHandler(IAggregateRepository aggregateRepository, IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService, IFiberNetworkQueryService fiberNetworkQueryService)
 {
     this.repo = aggregateRepository;
     this.conduitNetworkQueryService = conduitNetworkQueryService;
     this.routeNetworkQueryService   = routeNetworkQueryService;
     this.fiberNetworkQueryService   = fiberNetworkQueryService;
 }
Example #3
0
 public ConduitClosureCommandHandler(IAggregateRepository aggregateRepository, IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService, IConduitClosureRepository conduitClosureRepository)
 {
     this.repo = aggregateRepository;
     this.routeNetworkQueryService   = routeNetworkQueryService;
     this.conduitNetworkQueryService = conduitNetworkQueryService;
     this.conduitClosureRepository   = conduitClosureRepository;
 }
Example #4
0
        public DiagramServiceQuery(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkEqueryService, IConduitClosureRepository conduitClosureRepository, IFiberNetworkQueryService fiberNetworkService, IDataLoaderContextAccessor dataLoader)
        {
            Description = "GraphQL API for generating fiber equiment diagrams.";

            Field <DiagramType>(
                "buildRouteNodeDiagram",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "routeNodeId"
            },
                    new QueryArgument <StringGraphType> {
                Name = "exportGeojsonFileName"
            }
                    ),
                resolve: context =>
            {
                var routeNodeId  = context.GetArgument <Guid>("routeNodeId");
                var jsonFilename = context.GetArgument <string>("exportGeojsonFileName");

                var diagram = new ConduitClosureBuilder().Build(routeNodeId, routeNetworkQueryService, conduitNetworkEqueryService, fiberNetworkService, conduitClosureRepository);

                if (jsonFilename != null)
                {
                    var export = new GeoJsonExporter(diagram);
                    export.Export(jsonFilename);
                }

                return(diagram);
            }
                );
        }
        public ConduitClosureType(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkEqueryService, IDataLoaderContextAccessor dataLoader)
        {
            this.routeNetworkQueryService    = routeNetworkQueryService;
            this.conduitNetworkEqueryService = conduitNetworkEqueryService;

            Description = "A conduit closure.";

            Field(x => x.Id, type: typeof(IdGraphType)).Description("Guid property");
            Field(x => x.Sides, type: typeof(ListGraphType <ConduitClosureSideType>)).Description("Sides of the closure");
        }
Example #6
0
        public ConduitClosureSideType(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkEqueryService, IDataLoaderContextAccessor dataLoader)
        {
            this.routeNetworkQueryService    = routeNetworkQueryService;
            this.conduitNetworkEqueryService = conduitNetworkEqueryService;

            Description = "A specific side of a conduit closure. Sides are numbered clockwise: 1=Top 2=Right 3=Buttom 4=Left";

            Field(x => x.DigramLabel, type: typeof(StringGraphType)).Description("Label the user/system like to be placed along the side. Could e.g. be a street name.");
            Field(x => x.Position, type: typeof(ConduitClosureSideEnumType)).Description("Side position. 1=Top 2=Right 3=Buttom 4=Left");
            Field(x => x.Ports, type: typeof(ListGraphType <ConduitClosurePortType>)).Description("Ports on the side");
        }
Example #7
0
        public ConduitServiceQuery(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkEqueryService, IConduitSpecificationRepository conduitSpecificationRepository, IDataLoaderContextAccessor dataLoader)
        {
            Description = "GraphQL API for querying the conduit service.";

            Field <ListGraphType <ConduitSpecificationType> >(
                "conduitSpecifications",
                resolve: context =>
            {
                return(conduitSpecificationRepository.GetConduitSpecifications());
            }
                );
        }
Example #8
0
        public ConduitClosureRepository(IDocumentStore documentStore, IConduitNetworkQueryService conduitNetworkQueryService)
        {
            this.documentStore = documentStore;
            this.conduitNetworkQueryService = conduitNetworkQueryService;

            // Initialize mapper
            var config = new MapperConfiguration(cfg => {
                cfg.CreateMap <ConduitClosureInfo, ConduitClosureInfo>();
            });

            _mapper = config.CreateMapper();

            Load();
        }
        public RouteSegmentGraphFunctions(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkEqueryService, IConduitClosureRepository conduitClosureRepository, IDataLoaderContextAccessor dataLoader)
        {
            this.routeNetworkQueryService    = routeNetworkQueryService;
            this.conduitNetworkEqueryService = conduitNetworkEqueryService;
            this.conduitClosureRepository    = conduitClosureRepository;

            Description = "Route segment graph functions";

            Field <ListGraphType <RouteNodeType> >(
                "neighborNodes",
                resolve: context =>
            {
                List <RouteNodeInfo> result = new List <RouteNodeInfo>();

                var routeSegment = context.Source as RouteSegmentInfo;

                foreach (var neighbor in routeSegment.NeighborElements)
                {
                    result.Add((RouteNodeInfo)neighbor);
                }

                return(result);
            });


            Field <ListGraphType <RouteSegmentType> >(
                "neighborSegments",
                resolve: context =>
            {
                List <RouteSegmentInfo> result = new List <RouteSegmentInfo>();

                var routeSegment = context.Source as RouteSegmentInfo;

                foreach (var neighbor in routeSegment.NeighborElements)
                {
                    var neighborNeighbors = neighbor.NeighborElements;

                    foreach (var neighborNeighbor in neighborNeighbors)
                    {
                        if (neighborNeighbor != routeSegment)
                        {
                            result.Add((RouteSegmentInfo)neighborNeighbor);
                        }
                    }
                }

                return(result);
            });
        }
Example #10
0
        public ConduitSpecificationType(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkEqueryService, IConduitSpecificationRepository conduitSpecificationRepository, IDataLoaderContextAccessor dataLoader)
        {
            Description = "A specification of a conduit, that might be shared among manufacturer product models.";

            Field <ConduitKindEnumType>("Kind", "Kind of conduit (multi or single conduit)");
            Field(x => x.Id, type: typeof(IdGraphType)).Description("Guid property");
            Field(x => x.SequenceNumber, type: typeof(IdGraphType)).Description("The position of the conduit inside a multi conduit. Field only populated on inner conduits (conduits inside a multi conduit)");
            Field <ConduitShapeKindEnumType>("Shape", "Shape of conduit - flat, round etc.");
            Field <ConduitColorEnumType>("Color", "Color of the conduit itself");
            Field(x => x.InnerDiameter, type: typeof(IdGraphType)).Description("Inner diameter of the conduit");
            Field(x => x.OuterDiameter, type: typeof(IdGraphType)).Description("Outer diameter of the conduit");

            Field(x => x.ProductModels, type: typeof(ListGraphType <ProductModelInfoType>)).Description("Product models that use this specification");

            Field(x => x.ChildSpecifications, type: typeof(ListGraphType <ConduitSpecificationType>)).Description("Product models that use this specification");
        }
        public ConduitClosureTerminalType(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService, IDataLoaderContextAccessor dataLoader)
        {
            this.routeNetworkQueryService    = routeNetworkQueryService;
            this.conduitNetworkEqueryService = conduitNetworkQueryService;

            var traversal = new TraversalHelper(routeNetworkQueryService);

            Description = "A specific terminal part of a condult closure port. Terminal are like sides and ports numbered clockwise reflecting their position. Only single conduits or cables can be attached to terminals.";

            Field(x => x.Position, type: typeof(IntGraphType)).Description("Terminal position/number.");

            Field(x => x.LineSegment, type: typeof(ConduitSegmentType)).Description("The single conduit or cable attacthed to the terminal.");

            Field(x => x.ConnectionKind, type: typeof(ConduitClosureInternalConnectionKindType)).Description("The type of connection the cable or single conduit segment has (or don't have) to another port terminal in the closure.");

            Field(x => x.ConnectedToSide, type: typeof(ConduitClosureSideEnumType)).Description("The other end side position/number, if the cable/conduit segment is connected to another cable/conduit segment (attached to another port terminal) or passing through to another port terminal.");

            Field(x => x.ConnectedToPort, type: typeof(IntGraphType)).Description("The other end port position/number, if the cable/conduit segment is connected to another cable/conduit segment (attached to another port terminal) or passing through to another port terminal.");

            Field(x => x.ConnectedToTerminal, type: typeof(IntGraphType)).Description("The other end terminal position/number, if the cable/conduit segment is connected to another cable/conduit segment (attached to another port terminal) or passing through to another port terminal.");

            Field <StringGraphType>(
                "DiagramLabel",
                resolve: context =>
            {
                // If conduit segment, show end node name
                if (context.Source.LineSegment != null && context.Source.LineSegment is ConduitSegmentInfo)
                {
                    var conduitSegmentInfo = context.Source.LineSegment as ConduitSegmentInfo;
                    var lineInfo           = traversal.CreateTraversalInfoFromSegment(conduitSegmentInfo);

                    if (context.Source.LineSegmentEndKind == ConduitEndKindEnum.Incomming)
                    {
                        return(lineInfo.StartRouteNode.Name);
                    }
                    else
                    {
                        return(lineInfo.EndRouteNode.Name);
                    }
                }


                return(null);
            });
        }
        public ConduitClosureAttachmentProjection(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService, IConduitClosureRepository conduitClosureRepository)
        {
            this.routeNetworkQueryService   = routeNetworkQueryService;
            this.conduitNetworkQueryService = conduitNetworkQueryService;
            this.conduitClosureRepository   = conduitClosureRepository;

            // Conduit passing by attached to closure
            ProjectEvent <ConduitClosurePassingByConduitAttached>(
                (session, multiConduitEndAttached) =>
            {
                return(multiConduitEndAttached.ConduitClosureId);
            },
                OnConduitClosurePassingByConduitAttached);


            // Conduit end attached to closure
            ProjectEvent <ConduitClosureConduitEndAttached>(
                (session, e) =>
            {
                return(e.ConduitClosureId);
            },
                OnConduitClosureConduitEndAttached);


            // Inner conduit added to multi conduit
            ProjectEvent <MultiConduitInnerConduitAdded>((session, e) =>
            {
                // Try find conduit closure affected by inner conduit addition
                if (conduitClosureRepository.CheckIfConduitClosureIsRelatedToLine(e.MultiConduitId))
                {
                    var conduitClosure = conduitClosureRepository.GetConduitClosureInfoByRelatedLineId(e.MultiConduitId);

                    if (conduitClosure.Sides.Exists(s => s.Ports.Exists(p => p.MultiConduitId == e.MultiConduitId)))
                    {
                        return(conduitClosure.Id);
                    }
                }

                return(Guid.Empty);
            },
                                                         OnMultiConduitInnerConduitAdded);
        }
Example #13
0
        public ConduitClosurePortType(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkEqueryService, IDataLoaderContextAccessor dataLoader)
        {
            this.routeNetworkQueryService    = routeNetworkQueryService;
            this.conduitNetworkEqueryService = conduitNetworkEqueryService;

            Description = "A specific port sitting on a side of a condult closure. Ports are like sides numbered clockwise reflecting their position. Only multi conduits can be attached to ports. A port might have no multi conduit attached, in the case were single conduits or cables are connected to the closure port terminals without being part of (running inside) a multi conduit.";

            Field(x => x.DiagramLabel, type: typeof(StringGraphType)).Description("Label informaion the user like to be displayed on the port. Could e.g. be a the multi conduit model type.");

            Field(x => x.Position, type: typeof(IntGraphType)).Description("Port position/number.");

            Field(x => x.MultiConduitSegment, type: typeof(ConduitSegmentType)).Description("The multi conduit segment attached to the port. Null of no multi conduit is used.");

            Field(x => x.ConnectionKind, type: typeof(ConduitClosureInternalConnectionKindType)).Description("The type of connection the multi conduit segment has (or don't have) to another port in the closure.");

            Field(x => x.ConnectedToSide, type: typeof(ConduitClosureSideEnumType)).Description("The other end side position/number, if the multi conduit segment is connected to another multi conduit segment (attached to another port) or passing through to another port.");

            Field(x => x.ConnectedToPort, type: typeof(IntGraphType)).Description("The other end port position/number, if the multi conduit segment is connected to another multi conduit segment (attached to another port) or passing through to another port.");

            Field(x => x.Terminals, type: typeof(ListGraphType <ConduitClosureTerminalType>)).Description("Terminals of the port.");
        }
Example #14
0
        public ConduitClosureLifecyleEventProjection(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService, IConduitClosureRepository conduitClosureRepository)
        {
            this.routeNetworkQueryService   = routeNetworkQueryService;
            this.conduitNetworkQueryService = conduitNetworkQueryService;
            this.conduitClosureRepository   = conduitClosureRepository;

            // Conduits closure placed
            ProjectEvent <ConduitClosurePlaced>(
                (session, e) =>
            {
                return(e.ConduitClosureId);
            },
                OnConduitClosurePlaced);

            // Conduit closure removed
            DeleteEvent <ConduitClosureRemoved>(
                (session, e) =>
            {
                return(e.ConduitClosureId);
            },
                OnConduitClosureRemoved);
        }
Example #15
0
        public ConduitSegment(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkEqueryService, IDataLoaderContextAccessor dataLoader, IHttpContextAccessor httpContextAccessor)
        {
            this.routeNetworkQueryService    = routeNetworkQueryService;
            this.conduitNetworkEqueryService = conduitNetworkEqueryService;

            var traversal = new TraversalHelper(routeNetworkQueryService);

            Description = "A conduit will initially contain one segment that spans the whole length of conduit that was originally placed in the route network. When the user starts to cut the conduit at various nodes, more conduit segments will emerge. However, the original conduit asset is the same, now just cut in pieces. The segment represent the pieces. The line represent the original asset. Graph connectivity is maintained on segment level. Use line field to access general asset information. Use the conduit field to access conduit specific asset information.";

            // Interface fields

            Interface <SegmentInterface>();

            Field(x => x.Id, type: typeof(IdGraphType)).Description("Guid property");

            Field <LineSegmentRelationTypeEnumType>(
                "RelationType",
                resolve: context =>
            {
                Guid routeNodeId = (Guid)httpContextAccessor.HttpContext.Items["routeNodeId"];
                return(context.Source.RelationType(routeNodeId));
            });

            Field(x => x.Line.LineKind, type: typeof(LineSegmentKindType)).Description("Type of line segment - i.e. multi conduit, single conduit, fiber cable etc.");

            Field(x => x.Line, type: typeof(LineInterface)).Description("Line that this segment belongs to.");

            Field(x => x.Parents, type: typeof(ListGraphType <SegmentInterface>)).Description("The parent segments of this segment, if this segment is contained within another segment network - i.e. a fiber cable segment running within one of more conduit segments.");

            Field(x => x.Children, type: typeof(ListGraphType <SegmentInterface>)).Description("The child segments of this segment. As an example, if this is multi conduit, then child segments might be fiber cable segments or inner conduit segments running inside the multi conduit.");

            Field <RouteNodeType>(
                "FromRouteNode",
                resolve: context =>
            {
                return(routeNetworkQueryService.GetRouteNodeInfo(context.Source.FromRouteNodeId));
            });

            Field <RouteNodeType>(
                "ToRouteNode",
                resolve: context =>
            {
                return(routeNetworkQueryService.GetRouteNodeInfo(context.Source.ToRouteNodeId));
            });

            Field <SegmentTraversalType>(
                "Traversal",
                resolve: context =>
            {
                return(traversal.CreateTraversalInfoFromSegment(context.Source));
            });

            // Additional fields

            Field(x => x.Conduit, type: typeof(ConduitInfoType)).Description("The original conduit that this segment belongs to.");

            Field <SegmentTraversalType>(
                "Connectivity",
                resolve: context =>
            {
                return(traversal.CreateTraversalInfoFromSegment(context.Source));
            });


            Field <ListGraphType <RouteSegmentType> >(
                "AllRouteSegments",
                resolve: context =>
            {
                List <RouteSegmentInfo> result = new List <RouteSegmentInfo>();

                var woi = routeNetworkQueryService.GetWalkOfInterestInfo(context.Source.Conduit.GetRootConduit().WalkOfInterestId).SubWalk2(context.Source.FromRouteNodeId, context.Source.ToRouteNodeId);

                foreach (var segmentId in woi.AllSegmentIds)
                {
                    result.Add(routeNetworkQueryService.GetRouteSegmentInfo(segmentId));
                }

                return(result);
            });

            Field <ListGraphType <RouteNodeType> >(
                "AllRouteNodes",
                resolve: context =>
            {
                List <RouteNodeInfo> result = new List <RouteNodeInfo>();

                var woi = routeNetworkQueryService.GetWalkOfInterestInfo(context.Source.Conduit.GetRootConduit().WalkOfInterestId).SubWalk2(context.Source.FromRouteNodeId, context.Source.ToRouteNodeId);

                foreach (var nodeId in woi.AllNodeIds)
                {
                    result.Add(routeNetworkQueryService.GetRouteNodeInfo(nodeId));
                }

                return(result);
            });
        }
Example #16
0
        public MultiConduit(Guid conduitId, Guid walkOfInterestId, Guid conduitSpecificationId, string name, ConduitColorEnum markingColor, string markingText, IConduitNetworkQueryService conduitNetworkQueryService, IConduitSpecificationRepository conduitSpecificationRepository, string demoDataSpec = null) : this()
        {
            // Conduit Id check
            if (conduitId == null || conduitId == Guid.Empty)
            {
                throw new ArgumentException("Id cannot be null or empty");
            }

            // Walk of interest id check
            if (walkOfInterestId == null || walkOfInterestId == Guid.Empty)
            {
                throw new ArgumentException("WalkOfInterestId cannot be null or empty");
            }

            // Check that not already exists
            if (conduitNetworkQueryService.CheckIfMultiConduitIdExists(conduitId))
            {
                throw new ArgumentException("A multi conduit id: " + conduitId + " already exists");
            }

            // Create the multi conduit itself
            if (demoDataSpec != null && demoDataSpec != "")
            {
                var multiConduitPlaced = ConduitEventBuilder.CreateMultiConduitPlacedEvent(conduitId, walkOfInterestId, demoDataSpec);
                RaiseEvent(multiConduitPlaced);

                // Create all the inner conduits (if the multi conduit has such - the demo data builder will know)
                if (!demoDataSpec.StartsWith("FLEX"))
                {
                    var innerConduitAddedEvents = ConduitEventBuilder.CreateInnerConduitAddedEvents(multiConduitPlaced, demoDataSpec);

                    foreach (var innerConduitAddedEvent in innerConduitAddedEvents)
                    {
                        RaiseEvent(innerConduitAddedEvent);
                    }
                }
            }
            else
            {
                var conduitSpec = conduitSpecificationRepository.GetConduitSpecification(conduitSpecificationId);

                var assetInfo = new AssetInfo();
                assetInfo.Model        = conduitSpec.ProductModels[0];
                assetInfo.Manufacturer = conduitSpec.ProductModels[0].Manufacturer;

                var conduitInfo = new ConduitInfo()
                {
                    Id            = conduitId,
                    Name          = name,
                    Shape         = conduitSpec.Shape,
                    Color         = conduitSpec.Color,
                    ColorMarking  = markingColor,
                    TextMarking   = markingText,
                    OuterDiameter = conduitSpec.OuterDiameter,
                    InnerDiameter = conduitSpec.InnerDiameter
                };

                var multiConduitEvent = new MultiConduitPlaced()
                {
                    WalkOfInterestId = walkOfInterestId,
                    MultiConduitId   = conduitId,
                    ConduitInfo      = conduitInfo,
                    AssetInfo        = assetInfo
                };

                RaiseEvent(multiConduitEvent);


                // Create all the inner conduit
                foreach (var innerConduitSpec in conduitSpec.ChildSpecifications)
                {
                    var innerConduitInfo = new ConduitInfo()
                    {
                        Id            = Guid.NewGuid(),
                        Name          = "Subrør " + innerConduitSpec.SequenceNumber,
                        Color         = innerConduitSpec.Color,
                        InnerDiameter = innerConduitSpec.InnerDiameter,
                        OuterDiameter = innerConduitSpec.OuterDiameter,
                        Shape         = innerConduitSpec.Shape,
                        ColorMarking  = ConduitColorEnum.None
                    };

                    var innerConduitAddedEvent = new MultiConduitInnerConduitAdded()
                    {
                        MultiConduitId    = conduitId,
                        MultiConduitIndex = innerConduitSpec.SequenceNumber,
                        ConduitInfo       = innerConduitInfo
                    };

                    RaiseEvent(innerConduitAddedEvent);
                }
            }
        }
        public Fiber(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkEqueryService, IDataLoaderContextAccessor dataLoader)
        {
            this.routeNetworkQueryService    = routeNetworkQueryService;
            this.conduitNetworkEqueryService = conduitNetworkEqueryService;

            Description = "A fiber cable.";

            // Interface fields

            Interface <LineInterface>();

            Field(x => x.Id, type: typeof(IdGraphType)).Description("Guid property");

            Field(x => x.LineKind, type: typeof(LineSegmentKindType)).Description("Type of line - i.e. multi conduit, single conduit, fiber cable etc.");

            Field(x => x.FromRouteNode, type: typeof(NodeInterface)).Description("The node where this line equipment starts.");

            Field(x => x.ToRouteNode, type: typeof(NodeInterface)).Description("The node where this line equipment ends.");

            Field(x => x.Parent, type: typeof(LineInterface)).Description("The parent, if this object is part of a composite equipment structure - i.e. a fiber inside a fiber cable or an inner conduit inside a multi conduit. Notice that the parent-child relationship on line level only cover the relationship inside a single composite equipment such as a fiber cable or multi conduit. Containment relationships between different types of equipment is on segment level only.");

            //Field(x => x.Children, type: typeof(ListGraphType<LineInterface>)).Description("The children of a composite equipment structure - i.e. inner conduits part of a multi conduit. Notice that the parent-child relationship on line level only cover the relationship inside a composite equipment such as a fiber cable or multi conduit. Containment relationships between different types of equipment is on segment level only.");

            Field <ListGraphType <LineInterface> > (
                "Children",
                resolve: context =>
            {
                return(null);
            });

            // Fiber specific fields
            Field(x => x.SequenceNumber, type: typeof(IdGraphType)).Description("The position of fiber cable inside of conduit or route.");

            Field <ListGraphType <RouteSegmentType> >(
                "AllRouteSegments",
                resolve: context =>
            {
                List <RouteSegmentInfo> result = new List <RouteSegmentInfo>();

                var woi = routeNetworkQueryService.GetWalkOfInterestInfo(context.Source.GetRoot().WalkOfInterestId);

                foreach (var segmentId in woi.AllSegmentIds)
                {
                    result.Add(routeNetworkQueryService.GetRouteSegmentInfo(segmentId));
                }

                return(result);
            });

            Field <ListGraphType <RouteNodeType> >(
                "AllRouteNodes",
                resolve: context =>
            {
                List <RouteNodeInfo> result = new List <RouteNodeInfo>();

                var woi = routeNetworkQueryService.GetWalkOfInterestInfo(context.Source.GetRoot().WalkOfInterestId);

                foreach (var nodeId in woi.AllNodeIds)
                {
                    result.Add(routeNetworkQueryService.GetRouteNodeInfo(nodeId));
                }

                return(result);
            });
        }
Example #18
0
 public ConduitCutHandler(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService)
 {
     this.routeNetworkQueryService   = routeNetworkQueryService;
     this.conduitNetworkQueryService = (ConduitNetworkQueryService)conduitNetworkQueryService;
 }
        public ConduitInfoType(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkEqueryService, IDataLoaderContextAccessor dataLoader)
        {
            this.routeNetworkQueryService    = routeNetworkQueryService;
            this.conduitNetworkEqueryService = conduitNetworkEqueryService;

            Description = "A conduit. Can be a multi conduit (i.e. has inner ducts) or a single conduit.";

            // Interface fields

            //Interface<LineInterface>();

            Field(x => x.Id, type: typeof(IdGraphType)).Description("Guid property");

            Field(x => x.LineKind, type: typeof(LineSegmentKindType)).Description("Type of line - i.e. multi conduit, single conduit, fiber cable etc.");

            Field(x => x.FromRouteNode, type: typeof(NodeInterface)).Description("The node where this line equipment starts.");

            Field(x => x.ToRouteNode, type: typeof(NodeInterface)).Description("The node where this line equipment ends.");

            //Field(x => x.Parent, type: typeof(LineInterface)).Description("The parent, if this object is part of a composite equipment structure - i.e. a fiber inside a fiber cable or an inner conduit inside a multi conduit. Notice that the parent-child relationship on line level only cover the relationship inside a single composite equipment such as a fiber cable or multi conduit. Containment relationships between different types of equipment is on segment level only.");


            Field <ConduitInfoType>(
                "Parent",
                "The parent, if this object is part of a composite equipment structure - i.e. a fiber inside a fiber cable or an inner conduit inside a multi conduit. Notice that the parent-child relationship on line level only cover the relationship inside a single composite equipment such as a fiber cable or multi conduit. Containment relationships between different types of equipment is on segment level only.",
                resolve: context =>
            {
                return(context.Source.Parent);
            });


            // Additional fields, some for backwards compabtiblely

            Field <ConduitKindEnumType>("Kind", "Kind of conduit (multi or single conduit)");
            Field(x => x.Name, type: typeof(IdGraphType)).Description("The uility might give each conduit a name/number");

            Field <IdGraphType>(
                "Position",
                "The position of the conduit inside a multi conduit. Field only populated on inner conduits (conduits inside a multi conduit)",
                resolve: context =>
            {
                return(context.Source.SequenceNumber);
            });

            //Field(x => x.SequenceNumber, type: typeof(IdGraphType)).Description("The position of the conduit inside a multi conduit. Field only populated on inner conduits (conduits inside a multi conduit)");


            Field <ConduitShapeKindEnumType>("Shape", "Shape of conduit - flat, round etc.");
            Field <ConduitColorEnumType>("Color", "Color of the conduit itself");
            Field <ConduitColorEnumType>("ColorMarking", "Normally a colored stripe to distinguish between many conduits of same type in a trench");
            Field(x => x.TextMarking, type: typeof(IdGraphType)).Description("Normally some text printed along the conduitto distinguish between many conduits of same type in a trench");
            Field(x => x.InnerDiameter, type: typeof(IdGraphType)).Description("Inner diameter of the conduit");
            Field(x => x.OuterDiameter, type: typeof(IdGraphType)).Description("Outer diameter of the conduit");
            Field(x => x.AssetInfo, type: typeof(AssetInfoType)).Description("Asset info");

            Field(x => x.Children, type: typeof(ListGraphType <ConduitInfoType>)).Description("Child conduits. Field only populated on multi conduits.");
            //Field(x => x.Parent, type: typeof(ConduitInfoType)).Description("The parent of an inner conduit. Not available on multi and single conduits.");

            /*
             * Field<RouteNodeType>(
             * "FromRouteNode",
             * resolve: context =>
             * {
             *  var woi = routeNetworkQueryService.GetWalkOfInterestInfo(context.Source.GetRootConduit().WalkOfInterestId);
             *  return routeNetworkQueryService.GetRouteNodeInfo(woi.StartNodeId);
             * });
             *
             * Field<RouteNodeType>(
             * "ToRouteNode",
             * resolve: context =>
             * {
             *  var woi = routeNetworkQueryService.GetWalkOfInterestInfo(context.Source.GetRootConduit().WalkOfInterestId);
             *  return routeNetworkQueryService.GetRouteNodeInfo(woi.EndNodeId);
             * });
             */

            Field <ListGraphType <RouteSegmentType> >(
                "AllRouteSegments",
                resolve: context =>
            {
                List <RouteSegmentInfo> result = new List <RouteSegmentInfo>();

                var woi = routeNetworkQueryService.GetWalkOfInterestInfo(context.Source.GetRootConduit().WalkOfInterestId);

                foreach (var segmentId in woi.AllSegmentIds)
                {
                    result.Add(routeNetworkQueryService.GetRouteSegmentInfo(segmentId));
                }

                return(result);
            });

            Field <ListGraphType <RouteNodeType> >(
                "AllRouteNodes",
                resolve: context =>
            {
                List <RouteNodeInfo> result = new List <RouteNodeInfo>();

                var woi = routeNetworkQueryService.GetWalkOfInterestInfo(context.Source.GetRootConduit().WalkOfInterestId);

                foreach (var nodeId in woi.AllNodeIds)
                {
                    result.Add(routeNetworkQueryService.GetRouteNodeInfo(nodeId));
                }

                return(result);
            });
        }
Example #20
0
        public static void Run(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService, IMediator commandBus)
        {
            var conduitClosureId  = Guid.Parse("4ba4e2de-a06d-4168-b85b-a65490a9f313");
            var pointOfInterestId = Guid.Parse("0b2168f2-d9be-455c-a4de-e9169f000122");

            // Create conduit closure in J-1010
            var createConduitClosureCmd = new PlaceConduitClosureCommand()
            {
                ConduitClosureId  = conduitClosureId,
                PointOfInterestId = pointOfInterestId
            };

            commandBus.Send(createConduitClosureCmd).Wait();

            // Attached the two flex conduits from J-1010 to SP-1010 to conduit closure
            var attachFlexConduitCmd1 = new AttachConduitEndToClosureCommand()
            {
                ConduitClosureId = conduitClosureId,
                ConduitId        = Guid.Parse("9f779e83-9ffd-e5dd-2cfe-cb58197f74b0"),
                Side             = ConduitClosureInfoSide.Top
            };

            commandBus.Send(attachFlexConduitCmd1).Wait();

            var attachFlexConduitCmd2 = new AttachConduitEndToClosureCommand()
            {
                ConduitClosureId = conduitClosureId,
                ConduitId        = Guid.Parse("a7425e14-ba84-c958-c89f-6e00d84355a4"),
                Side             = ConduitClosureInfoSide.Top
            };

            commandBus.Send(attachFlexConduitCmd2).Wait();

            // Create 96 fiber cable from CO-BDAL to CO-BRED
            Guid startNodeId = Guid.Parse("0b2168f2-d9be-455c-a4de-e9169f000016");
            Guid endNodeId   = Guid.Parse("0b2168f2-d9be-455c-a4de-e9169f000046");
            Guid cableId     = Guid.Parse("15960ab1-a6f8-46ca-964d-504354ec06b9");

            PlaceCable(routeNetworkQueryService, commandBus, cableId, 96, startNodeId, endNodeId);

            // Create 72 fiber cable from CO-BDAL to FP-1010
            startNodeId = Guid.Parse("0b2168f2-d9be-455c-a4de-e9169f000016");
            endNodeId   = Guid.Parse("0b2168f2-d9be-455c-a4de-e9169f000015");
            var fpCableId = Guid.Parse("3ebf7e5d-ebfe-4c06-b875-513c89b44ef0");

            PlaceCable(routeNetworkQueryService, commandBus, fpCableId, 72, startNodeId, endNodeId);

            // Create 48 fiber cable from FP-1010 to SP-1010
            startNodeId = Guid.Parse("0b2168f2-d9be-455c-a4de-e9169f000015");
            endNodeId   = Guid.Parse("0b2168f2-d9be-455c-a4de-e9169f000022");
            var spCableId1 = Guid.Parse("ba9e4da4-92df-4208-bd66-98e7ba659d9e");

            PlaceCable(routeNetworkQueryService, commandBus, spCableId1, 48, startNodeId, endNodeId);

            // Create 48 fiber cable from FP-1010 to SP-1020
            startNodeId = Guid.Parse("0b2168f2-d9be-455c-a4de-e9169f000015");
            endNodeId   = Guid.Parse("0b2168f2-d9be-455c-a4de-e9169f000059");
            var spCableId2 = Guid.Parse("5ee30eee-f9a5-4034-8d0e-871aa85cf6c7");

            PlaceCable(routeNetworkQueryService, commandBus, spCableId2, 48, startNodeId, endNodeId);
        }
Example #21
0
        internal void Cut(Guid pointOfInterestId, IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService)
        {
            // Point of interest id check
            if (pointOfInterestId == null || pointOfInterestId == Guid.Empty)
            {
                throw new ArgumentException("PointOfInterestId cannot be null or empty");
            }

            // Check if single conduit is already cut
            var singleConduitInfo = conduitNetworkQueryService.GetSingleConduitInfo(Id);

            if (singleConduitInfo.Segments.Exists(s => s.FromRouteNodeId == pointOfInterestId || s.ToRouteNodeId == pointOfInterestId))
            {
                throw new ArgumentException("Single conduit: " + Id + " is already cut at: " + pointOfInterestId);
            }

            // Check that conduit is cut at a node part of conduit walk of interest
            var walkOfInterest = routeNetworkQueryService.GetWalkOfInterestInfo(singleConduitInfo.GetRootConduit().WalkOfInterestId);

            if (!walkOfInterest.AllNodeIds.Contains(pointOfInterestId))
            {
                throw new ArgumentException("The point of interest: " + pointOfInterestId + " was not found in walk of interest:" + singleConduitInfo.WalkOfInterestId + " of single conduit: " + Id);
            }

            // Check that conduit is not cut at ends
            if (walkOfInterest.StartNodeId == pointOfInterestId || walkOfInterest.EndNodeId == pointOfInterestId)
            {
                throw new ArgumentException("The point of interest: " + pointOfInterestId + " is one of the ends in walk of interest:" + singleConduitInfo.WalkOfInterestId + " of single conduit: " + Id + " This is not allowed. You cannot cut a conduit at its ends.");
            }

            RaiseEvent(new SingleConduitCut
            {
                SingleConduitId   = Id,
                PointOfInterestId = pointOfInterestId
            });
        }
        public ConduitSegmentType(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkEqueryService, IDataLoaderContextAccessor dataLoader)
        {
            this.routeNetworkQueryService    = routeNetworkQueryService;
            this.conduitNetworkEqueryService = conduitNetworkEqueryService;

            var traversal = new TraversalHelper(routeNetworkQueryService);

            Description = "A conduit segment will initially be the original whole length piece of conduit. When the user starts to cut the conduit at various nodes, more conduit segments will emerge. Graph connectivity is maintained on segment level.";

            Field(x => x.Id, type: typeof(IdGraphType)).Description("Guid property");

            Field(x => x.Conduit, type: typeof(ConduitInfoType)).Description("The original conduit that this segment is part of.");

            Field(x => x.Children, type: typeof(ListGraphType <ConduitSegmentType>)).Description("The children of a multi conduit segment.");
            Field(x => x.Parents, type: typeof(ListGraphType <ConduitSegmentType>)).Description("The parents of an inner conduit segment.");

            Field <ConduitLineType>(
                "Line",
                resolve: context =>
            {
                var traversalInfo = traversal.CreateTraversalInfoFromSegment(context.Source);

                var cLineType               = new ConduitLineInfo();
                cLineType.AllSegments       = traversalInfo.AllSegments.OfType <ConduitSegmentInfo>().ToList();
                cLineType.AllRouteNodes     = traversalInfo.AllRouteNodes.OfType <RouteNodeInfo>().ToList();
                cLineType.AllRouteSegments  = traversalInfo.AllRouteSegments.OfType <RouteSegmentInfo>().ToList();
                cLineType.EndRouteNode      = (RouteNodeInfo)traversalInfo.EndRouteNode;
                cLineType.StartRouteNode    = (RouteNodeInfo)traversalInfo.StartRouteNode;
                cLineType.StartRouteSegment = (RouteSegmentInfo)traversalInfo.StartRouteSegment;
                cLineType.EndRouteSegment   = (RouteSegmentInfo)traversalInfo.EndRouteSegment;

                return(cLineType);
            });

            Field <RouteNodeType>(
                "FromRouteNode",
                resolve: context =>
            {
                return(routeNetworkQueryService.GetRouteNodeInfo(context.Source.FromRouteNodeId));
            });

            Field <RouteNodeType>(
                "ToRouteNode",
                resolve: context =>
            {
                return(routeNetworkQueryService.GetRouteNodeInfo(context.Source.ToRouteNodeId));
            });

            Field <ListGraphType <RouteSegmentType> >(
                "AllRouteSegments",
                resolve: context =>
            {
                List <RouteSegmentInfo> result = new List <RouteSegmentInfo>();

                var woi = routeNetworkQueryService.GetWalkOfInterestInfo(context.Source.Conduit.GetRootConduit().WalkOfInterestId).SubWalk2(context.Source.FromRouteNodeId, context.Source.ToRouteNodeId);

                foreach (var segmentId in woi.AllSegmentIds)
                {
                    result.Add(routeNetworkQueryService.GetRouteSegmentInfo(segmentId));
                }

                return(result);
            });

            Field <ListGraphType <RouteNodeType> >(
                "AllRouteNodes",
                resolve: context =>
            {
                List <RouteNodeInfo> result = new List <RouteNodeInfo>();

                var woi = routeNetworkQueryService.GetWalkOfInterestInfo(context.Source.Conduit.GetRootConduit().WalkOfInterestId).SubWalk2(context.Source.FromRouteNodeId, context.Source.ToRouteNodeId);

                foreach (var nodeId in woi.AllNodeIds)
                {
                    result.Add(routeNetworkQueryService.GetRouteNodeInfo(nodeId));
                }

                return(result);
            });

            Field(x => x.Line.LineKind, type: typeof(LineSegmentKindType)).Description("Type of line segment - i.e. conduit, power cable, signal cable etc.");


            //Interface<LineSegmentInterface>();
        }
Example #23
0
        public DemoNetwork(IHostingEnvironment env, IDocumentStore documentStore, IMediator commandBus, IConduitClosureRepository conduitClosureRepository, IRouteNetworkState routeNetwork, IConduitNetworkQueryService conduitNetwork, IFiberNetworkQueryService fiberNetworkQueryService)
        {
            Description = "API for invoking the demo/test data builder";

            Field <StringGraphType>(
                "rebuild",
                description: "Deletes the database and rebuild the demo data from the GeoJson files created using QGIS",
                resolve: context =>
            {
                try
                {
                    // First delete everything in the database
                    documentStore.Advanced.Clean.CompletelyRemoveAll();

                    // Clean everything in projected in-memory read models
                    routeNetwork.Clean();
                    conduitNetwork.Clean();
                    conduitClosureRepository.Clean();
                    fiberNetworkQueryService.Clean();

                    var iisExpressFolder = AppDomain.CurrentDomain.BaseDirectory;

                    var pathToData = env.ContentRootPath;

                    if (iisExpressFolder.Contains("Debug\\netcoreapp"))
                    {
                        pathToData = iisExpressFolder;
                    }

                    pathToData += Path.DirectorySeparatorChar.ToString() + "Data" + Path.DirectorySeparatorChar.ToString();

                    // Rebuild demo data
                    RouteNetworkBuilder.Run(pathToData, commandBus);
                    ConduitBuilder.Run(conduitNetwork, commandBus);
                    EquipmentBuilder.Run(routeNetwork, conduitNetwork, commandBus);

                    // Reload everything again
                    routeNetwork.Clean();
                    conduitNetwork.Clean();
                    conduitClosureRepository.Clean();
                    fiberNetworkQueryService.Clean();

                    return("Read models cleaned and test data was rebuilt.");
                }
                catch (Exception ex)
                {
                    context.Errors.Add(new ExecutionError(ex.Message, ex));
                    return("Failed");
                }
            }
                );
        }
Example #24
0
        public ConduitClosureCommandHandler(IMediator commandBus, IConduitClosureRepository conduitClosureRepository, IRouteNetworkState routeNetwork, IConduitNetworkQueryService conduitNetwork)
        {
            Description = "API for sending commands to the conduit closure aggregate root";

            Field <ConduitClosureType>(
                "placeConduitClosure",
                description: "Place a new conduit clousure in a point of interest (route node)",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "pointOfInterestId"
            },
                    new QueryArgument <IdGraphType> {
                Name = "conduitClosureId"
            }
                    ),
                resolve: context =>
            {
                var conduitClosureId = context.GetArgument <Guid>("conduitClosureId");

                var createConduitClosureCmd = new PlaceConduitClosureCommand()
                {
                    ConduitClosureId  = Guid.NewGuid(),
                    PointOfInterestId = context.GetArgument <Guid>("pointOfInterestId")
                };

                if (conduitClosureId != Guid.Empty)
                {
                    createConduitClosureCmd.ConduitClosureId = conduitClosureId;
                }

                try
                {
                    commandBus.Send(createConduitClosureCmd).Wait();
                }
                catch (Exception ex)
                {
                    context.Errors.Add(new ExecutionError(ex.Message, ex));
                    return(null);
                }

                return(conduitClosureRepository.GetConduitClosureInfo(createConduitClosureCmd.ConduitClosureId));
            }
                );

            Field <ConduitClosureType>(
                "removeConduitClosure",
                description: "Remove a new conduit clousure from its point of interest (route node)",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "conduitClosureId"
            }
                    ),
                resolve: context =>
            {
                var removeConduitClosureCmd = new RemoveConduitClosureCommand()
                {
                    ConduitClosureId = context.GetArgument <Guid>("conduitClosureId")
                };

                try
                {
                    commandBus.Send(removeConduitClosureCmd).Wait();
                }
                catch (Exception ex)
                {
                    context.Errors.Add(new ExecutionError(ex.Message, ex));
                    return(null);
                }

                return(null);
            }
                );

            Field <ConduitClosureType>(
                "attachPassByConduitToClosure",
                description: "Attach a conduit that is passing by to the conduit closure",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "conduitClosureId", Description = "Id of the conduit closure where the passing conduit should be attached to"
            },
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "conduitId", Description = "Id of the conduit to be attached to the conduit closure"
            },
                    new QueryArgument <NonNullGraphType <ConduitClosureSideEnumType> > {
                Name = "incommingSide", Description = "The side where the conduit should enter the closure. This argument is mandatory."
            },
                    new QueryArgument <NonNullGraphType <ConduitClosureSideEnumType> > {
                Name = "outgoingSide", Description = "The side where the conduit should leav the closure. This argument is mandatory."
            },
                    new QueryArgument <IntGraphType> {
                Name = "incommingPortPosition", Description = "The position where the port should be placed. If not specified, the system will position the new port after eventually existing ports. If specified, and the port number references an existing occupied port, the system will move the existing and following ports one position, and place the new port on the specified position."
            },
                    new QueryArgument <IntGraphType> {
                Name = "outgoingPortPosition", Description = "The position where the port should be placed. If not specified, the system will position the new port after eventually existing ports. If specified, and the port number references an existing occupied port, the system will move the existing and following ports one position, and place the new port on the specified position."
            },
                    new QueryArgument <IntGraphType> {
                Name = "incommingTerminalPosition", Description = "The position where the new terminal should be placed. Only used when attaching single conduits to closures. If specified the single conduit will be attached to a new terminal with the specified position on an existing port. If this argument is specified, you must also specify the port argument."
            },
                    new QueryArgument <IntGraphType> {
                Name = "outgoingTerminalPosition", Description = "The position where the new terminal should be placed. Only used when attaching single conduits to closures. If specified the single conduit will be attached to a new terminal with the specified position on an existing port. If this argument is specified, you must also specify the port argument."
            }
                    ),
                resolve: context =>
            {
                var routeConduitThroughClosureCmd = new AttachPassByConduitToClosureCommand()
                {
                    ConduitClosureId          = context.GetArgument <Guid>("conduitClosureId"),
                    ConduitId                 = context.GetArgument <Guid>("conduitId"),
                    IncommingSide             = context.GetArgument <ConduitClosureInfoSide>("incommingSide"),
                    OutgoingSide              = context.GetArgument <ConduitClosureInfoSide>("outgoingSide"),
                    IncommingPortPosition     = context.GetArgument <int>("incommingPortPosition"),
                    OutgoingPortPosition      = context.GetArgument <int>("outgoingPortPosition"),
                    IncommingTerminalPosition = context.GetArgument <int>("incommingPortPosition"),
                    OutgoingTerminalPosition  = context.GetArgument <int>("outgoingPortPosition"),
                };

                try
                {
                    commandBus.Send(routeConduitThroughClosureCmd).Wait();
                }
                catch (Exception ex)
                {
                    context.Errors.Add(new ExecutionError(ex.Message, ex));
                    return(null);
                }

                return(conduitClosureRepository.GetConduitClosureInfo(routeConduitThroughClosureCmd.ConduitClosureId));
            }
                );


            Field <ConduitClosureType>(
                "attachConduitEndToClosure",
                description: "Attach a conduit to the conduit closure, that is ending in the point of interest (node) where the conduit closure is also located.",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "conduitClosureId", Description = "Id of the ending conduit that should be attached to the conduit closure."
            },
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "conduitId", Description = "Id of the conduit to be attached to the conduit closure"
            },
                    new QueryArgument <NonNullGraphType <ConduitClosureSideEnumType> > {
                Name = "side", Description = "The side where the conduit should enter the closure. This argument is mandatory."
            },
                    new QueryArgument <IntGraphType> {
                Name = "portPosition", Description = "The position where the port should be placed. If not specified, the system will position the new port after eventually existing ports. If specified, and the port number references an existing occupied port, the system will move the existing and following ports one position, and place the new port on the specified position."
            },
                    new QueryArgument <IntGraphType> {
                Name = "terminalPosition", Description = "The position where the new terminal should be placed. Only used when attaching single conduits to closures. If specified the single conduit will be attached to a new terminal with the specified position on an existing port. If this argument is specified, you must also specify the port argument."
            }
                    ),
                resolve: context =>
            {
                var attachConduitEndCmd = new AttachConduitEndToClosureCommand()
                {
                    ConduitClosureId = context.GetArgument <Guid>("conduitClosureId"),
                    ConduitId        = context.GetArgument <Guid>("conduitId"),
                    Side             = context.GetArgument <ConduitClosureInfoSide>("side"),
                    PortPosition     = context.GetArgument <int>("portPosition"),
                    TerminalPosition = context.GetArgument <int>("terminalPosition"),
                };

                try
                {
                    commandBus.Send(attachConduitEndCmd).Wait();
                }
                catch (Exception ex)
                {
                    context.Errors.Add(new ExecutionError(ex.Message, ex));
                    return(null);
                }

                return(conduitClosureRepository.GetConduitClosureInfo(attachConduitEndCmd.ConduitClosureId));
            }
                );
        }
Example #25
0
        public RouteSegmentType(IConduitNetworkQueryService conduitNetworkEqueryService, IConduitClosureRepository conduitClosureRepository, IDataLoaderContextAccessor dataLoader)
        {
            this.routeNetworkQueryService    = routeNetworkQueryService;
            this.conduitNetworkEqueryService = conduitNetworkEqueryService;
            this.conduitClosureRepository    = conduitClosureRepository;

            Description = "A route segment in a route network.";

            Field(x => x.Id, type: typeof(IdGraphType)).Description("Guid property");
            Field <RouteSegmentKindEnumType>("SegmentKind", "Kind of segment");

            Field <GeometryType>(
                "geometry",
                resolve: context =>
            {
                return(new Geometry(context.Source.Geometry.GeoJsonType, context.Source.Geometry.GeoJsonCoordinates));
            });

            Field <FloatGraphType>("length", resolve: x => x.Source.Length);

            Field <ListGraphType <ConduitRelationType> >(
                "relatedConduits",
                arguments: new QueryArguments(
                    new QueryArgument <BooleanGraphType> {
                Name = "includeMultiConduits"
            },
                    new QueryArgument <BooleanGraphType> {
                Name = "includeSingleConduits"
            },
                    new QueryArgument <BooleanGraphType> {
                Name = "includeInnerConduits"
            },
                    new QueryArgument <StringGraphType> {
                Name = "conduitSegmentId"
            }
                    ),
                resolve: context =>
            {
                var includeMultiConduits  = context.GetArgument <Boolean>("includeMultiConduits", true);
                var includeSingleConduits = context.GetArgument <Boolean>("includeSingleConduits", true);
                var includeInnerConduits  = context.GetArgument <Boolean>("includeInnerConduits", true);

                var conduitSegmentIdParam = context.GetArgument <string>("conduitSegmentId");

                var conduitSegmentId = Guid.Empty;

                if (conduitSegmentIdParam != null)
                {
                    if (!Guid.TryParse(conduitSegmentIdParam, out conduitSegmentId))
                    {
                        context.Errors.Add(new ExecutionError("Wrong value for guid"));
                        return(null);
                    }
                }

                List <ConduitRelation> result = new List <ConduitRelation>();

                var conduitSegmentRels = conduitNetworkEqueryService.GetConduitSegmentsRelatedToRouteSegment(context.Source.Id, conduitSegmentIdParam);

                foreach (var conduitSegmentRel in conduitSegmentRels)
                {
                    ConduitRelation rel = new ConduitRelation()
                    {
                        RelationType   = conduitSegmentRel.Type,
                        Conduit        = conduitSegmentRel.Segment.Conduit,
                        ConduitSegment = conduitSegmentRel.Segment
                    };

                    if (includeMultiConduits && conduitSegmentRel.Segment.Conduit.Kind == ConduitKindEnum.MultiConduit)
                    {
                        result.Add(rel);
                    }

                    if (includeInnerConduits && conduitSegmentRel.Segment.Conduit.Kind == ConduitKindEnum.InnerConduit)
                    {
                        result.Add(rel);
                    }

                    if (includeSingleConduits && conduitSegmentRel.Segment.Conduit.Kind == ConduitKindEnum.SingleConduit)
                    {
                        result.Add(rel);
                    }
                }

                return(result);
            }
                );


            Field <RouteSegmentGraphFunctions>("graph", resolve: context => context.Source);
        }
Example #26
0
        internal void Connect(Guid pointOfInterestId, ConduitEndKindEnum endKind, Guid junctionId, IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService)
        {
            var singleConduitInfo = conduitNetworkQueryService.GetSingleConduitInfo(Id);

            // endKind check
            if (endKind == 0)
            {
                throw new ArgumentException("End kind must be specified. Otherwise the system don't know with end of the segment to connect, if a conduit has been cut into two pieces in a node.");
            }

            if (!singleConduitInfo.Segments.Exists(s => s.FromRouteNodeId == pointOfInterestId || s.ToRouteNodeId == pointOfInterestId))
            {
                throw new ArgumentException("The single conduit: " + Id + " is not cut at: " + pointOfInterestId);
            }

            // Check that conduit is connected at a node part of conduit walk of interest
            var walkOfInterest = routeNetworkQueryService.GetWalkOfInterestInfo(singleConduitInfo.GetRootConduit().WalkOfInterestId);

            if (!walkOfInterest.AllNodeIds.Contains(pointOfInterestId))
            {
                throw new ArgumentException("The point of interest: " + pointOfInterestId + " was not found in walk of interest:" + singleConduitInfo.WalkOfInterestId + " of single conduit: " + Id);
            }

            ISegment connectingSegment = null;

            // Check incomming
            if (endKind == ConduitEndKindEnum.Incomming)
            {
                if (!singleConduitInfo.Segments.Exists(s => s.ToRouteNodeId == pointOfInterestId))
                {
                    throw new ArgumentException("No segments are incomming to point of interest: " + pointOfInterestId + " in single conduit: " + Id);
                }

                connectingSegment = singleConduitInfo.Segments.Find(s => s.ToRouteNodeId == pointOfInterestId);

                // Check if already connect to a junction
                if (connectingSegment.ToNodeId != Guid.Empty)
                {
                    throw new ArgumentException("the incomming segment: " + connectingSegment.Id + " is already connected to a junction: " + connectingSegment.ToNodeId);
                }
            }
            // Check outgoing
            else
            {
                if (!singleConduitInfo.Segments.Exists(s => s.FromRouteNodeId == pointOfInterestId))
                {
                    throw new ArgumentException("No segments are outgoing from point of interest: " + pointOfInterestId + " in single conduit: " + Id);
                }

                connectingSegment = singleConduitInfo.Segments.Find(s => s.FromRouteNodeId == pointOfInterestId);

                // Check if already connect to a junction
                if (connectingSegment.FromNodeId != Guid.Empty)
                {
                    throw new ArgumentException("the outgoing segment: " + connectingSegment.Id + " is already connected to a junction: " + connectingSegment.FromNodeId);
                }
            }



            RaiseEvent(new SingleConduitConnected
            {
                SingleConduitId     = Id,
                PointOfInterestId   = pointOfInterestId,
                ConnectedEndKind    = endKind,
                ConnectedJunctionId = junctionId
            });
        }
Example #27
0
        internal void ConnectInnerConduit(Guid pointOfInterestId, int sequenceNumber, ConduitEndKindEnum endKind, Guid junctionId, IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService)
        {
            // Point of interest id check
            if (pointOfInterestId == null || pointOfInterestId == Guid.Empty)
            {
                throw new ArgumentException("PointOfInterestId cannot be null or empty");
            }

            // endKind check
            if (endKind == 0)
            {
                throw new ArgumentException("End kind must be specified. Otherwise the system don't know with end of the segment to connect, if a conduit has been cut into two pieces in a node.");
            }


            var multiConduitInfo = conduitNetworkQueryService.GetMultiConduitInfo(Id);

            // Inner conduit number check
            if (!multiConduitInfo.Children.OfType <ConduitInfo>().Any(i => i.SequenceNumber == sequenceNumber))
            {
                throw new ArgumentException("Cannot find inner conduit number: " + sequenceNumber + " in multi conduit: " + Id);
            }

            var singleConduitInfo = conduitNetworkQueryService.GetSingleConduitInfo(multiConduitInfo.Children.OfType <ConduitInfo>().Single(i => i.SequenceNumber == sequenceNumber).Id);

            if (!singleConduitInfo.Segments.Exists(s => s.FromRouteNodeId == pointOfInterestId || s.ToRouteNodeId == pointOfInterestId))
            {
                throw new ArgumentException("Inner conduit number: " + sequenceNumber + " in multi conduit: " + Id + " is not cut at: " + pointOfInterestId);
            }

            // Check that conduit is connected at a node part of conduit walk of interest
            var walkOfInterest = routeNetworkQueryService.GetWalkOfInterestInfo(multiConduitInfo.WalkOfInterestId);

            if (!walkOfInterest.AllNodeIds.Contains(pointOfInterestId))
            {
                throw new ArgumentException("The point of interest: " + pointOfInterestId + " was not found in walk of interest:" + multiConduitInfo.WalkOfInterestId + " of multi conduit: " + Id);
            }

            // Check incomming
            if (endKind == ConduitEndKindEnum.Incomming && !multiConduitInfo.Segments.Exists(s => s.ToRouteNodeId == pointOfInterestId))
            {
                throw new ArgumentException("No segments are incomming to point of interest: " + pointOfInterestId + " in multi conduit: " + Id);
            }

            // Check outgoing
            if (endKind == ConduitEndKindEnum.Outgoing && !multiConduitInfo.Segments.Exists(s => s.FromRouteNodeId == pointOfInterestId))
            {
                throw new ArgumentException("No segments are outgoing from point of interest: " + pointOfInterestId + " in multi conduit: " + Id);
            }

            ISegment connectingSegment = null;

            // Check incomming inner conduit
            if (endKind == ConduitEndKindEnum.Incomming)
            {
                if (!singleConduitInfo.Segments.Exists(s => s.ToRouteNodeId == pointOfInterestId))
                {
                    throw new ArgumentException("No inner conduit segments are incomming to point of interest: " + pointOfInterestId + " in single conduit: " + Id);
                }

                connectingSegment = singleConduitInfo.Segments.Find(s => s.ToRouteNodeId == pointOfInterestId);

                // Check if already connect to a junction
                if (connectingSegment.ToNodeId != Guid.Empty)
                {
                    throw new ArgumentException("the incomming  inner conduit segment: " + connectingSegment.Id + " is already connected to a junction: " + connectingSegment.ToNodeId);
                }
            }
            // Check outgoing inner conduit
            else
            {
                if (!singleConduitInfo.Segments.Exists(s => s.FromRouteNodeId == pointOfInterestId))
                {
                    throw new ArgumentException("No  inner conduit segments are outgoing from point of interest: " + pointOfInterestId + " in single conduit: " + Id);
                }

                connectingSegment = singleConduitInfo.Segments.Find(s => s.FromRouteNodeId == pointOfInterestId);

                // Check if already connect to a junction
                if (connectingSegment.FromNodeId != Guid.Empty)
                {
                    throw new ArgumentException("the outgoing  inner conduit segment: " + connectingSegment.Id + " is already connected to a junction: " + connectingSegment.FromNodeId);
                }
            }


            RaiseEvent(new MultiConduitInnerConduitConnected
            {
                MultiConduitId             = Id,
                PointOfInterestId          = pointOfInterestId,
                InnerConduitSequenceNumber = sequenceNumber,
                ConnectedEndKind           = endKind,
                ConnectedJunctionId        = junctionId
            });
        }
Example #28
0
        public void ContinueInnerConduitIntoAnotherMultiConduit(Guid pointOfInterestId, Guid fromConduitSegmentId, Guid toConduitSegmentId, IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService)
        {
            var multiConduitInfo = conduitNetworkQueryService.GetMultiConduitInfo(Id);

            var fromSegment = multiConduitInfo.Segments.Find(s => s.Id == fromConduitSegmentId);

            // Junction id
            Guid junctionId = Guid.NewGuid();

            // Find from direction
            ConduitEndKindEnum fromEndKind = ConduitEndKindEnum.Incomming;

            if (fromSegment.FromRouteNodeId == pointOfInterestId)
            {
                fromEndKind = ConduitEndKindEnum.Outgoing;
            }

            RaiseEvent(new MultiConduitInnerConduitConnected
            {
                MultiConduitId             = Id,
                PointOfInterestId          = pointOfInterestId,
                InnerConduitSequenceNumber = fromSegment.Line.SequenceNumber,
                ConnectedEndKind           = fromEndKind,
                ConnectedJunctionId        = junctionId
            });
        }
Example #29
0
        public RouteNodeGraphFunctions(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkEqueryService, IConduitClosureRepository conduitClosureRepository, IDataLoaderContextAccessor dataLoader)
        {
            this.routeNetworkQueryService = routeNetworkQueryService;
            this.conduitNetworkEqueryService = conduitNetworkEqueryService;
            this.conduitClosureRepository = conduitClosureRepository;

            Description = "Route node graph functions";

            Field<ListGraphType<IdGraphType>>(
              "shortestPath",
              arguments: new QueryArguments(new QueryArgument<NonNullGraphType<IdGraphType>> { Name = "ToNodeId" }),
              resolve: context =>
              {
                  var startNode = context.Source as RouteNodeInfo;

                  Guid endNodeId = context.GetArgument<Guid>("toNodeId");

                  List<Guid> result = new List<Guid>();

                  List<IGraphElement> graphElements = new List<IGraphElement>();

                  graphElements.AddRange(routeNetworkQueryService.GetAllRouteNodes());
                  graphElements.AddRange(routeNetworkQueryService.GetAllRouteSegments());

                  var graph = new Graph(graphElements);


                  var shortestPathResult = graph.ShortestPath(startNode.Id.ToString(), endNodeId.ToString()).Select(s => s.Id);

                  return shortestPathResult;
              });


            Field<ListGraphType<RouteNodeType>>(
               "neighborNodes",
               resolve: context =>
               {
                   List<RouteNodeInfo> result = new List<RouteNodeInfo>();

                   var routeNode = context.Source as RouteNodeInfo;

                   foreach (var neighbor in routeNode.NeighborElements)
                   {
                       var neighborNeighbors = neighbor.NeighborElements;

                       foreach (var neighborNeighbor in neighborNeighbors)
                       {
                           if (neighborNeighbor != routeNode)
                               result.Add((RouteNodeInfo)neighborNeighbor);
                       }
                       
                   }

                   return result;

               });


            Field<ListGraphType<RouteSegmentType>>(
              "neighborSegments",
              resolve: context =>
              {
                  List<RouteSegmentInfo> result = new List<RouteSegmentInfo>();

                  var routeNode = context.Source as RouteNodeInfo;

                  foreach (var neighbor in routeNode.NeighborElements)
                  {
                    result.Add((RouteSegmentInfo)neighbor);
                  }

                  return result;
              });

        }
Example #30
0
        public SingleConduit(Guid conduitId, Guid walkOfInterestId, Guid conduitSpecificationId, string name, ConduitColorEnum markingColor, string markingText, IConduitNetworkQueryService conduitNetworkQueryService, IConduitSpecificationRepository conduitSpecificationRepository, string demoDataSpec = null) : this()
        {
            //////////////////////////////////////////////////////////////////////////////////////
            // NOTICE:
            // This constructor is currently a hack that just uses the demo data builder.
            // Must be refactored to use a conduit catalog system.

            // Conduit Id check
            if (conduitId == null || conduitId == Guid.Empty)
            {
                throw new ArgumentException("Id cannot be null or empty");
            }

            // Walk of interest id check
            if (walkOfInterestId == null || walkOfInterestId == Guid.Empty)
            {
                throw new ArgumentException("WalkOfInterestId cannot be null or empty");
            }

            // Check that not already exists
            if (conduitNetworkQueryService.CheckIfSingleConduitIdExists(conduitId))
            {
                throw new ArgumentException("A singe conduit id: " + conduitId + " already exists");
            }

            // Create the conduit
            if (demoDataSpec != null && demoDataSpec != "")
            {
                var singleConduitPlaced = ConduitEventBuilder.CreateSingleConduitPlacedEvent(conduitId, walkOfInterestId, demoDataSpec);
                RaiseEvent(singleConduitPlaced);
            }
            else
            {
                var conduitSpec = conduitSpecificationRepository.GetConduitSpecification(conduitSpecificationId);

                var assetInfo = new AssetInfo();
                if (conduitSpec.ProductModels != null && conduitSpec.ProductModels.Count > 0)
                {
                    assetInfo.Model = conduitSpec.ProductModels[0];

                    if (conduitSpec.ProductModels[0].Manufacturer != null)
                    {
                        assetInfo.Manufacturer = conduitSpec.ProductModels[0].Manufacturer;
                    }
                }

                var conduitInfo = new ConduitInfo()
                {
                    Id            = conduitId,
                    Name          = name,
                    Shape         = conduitSpec.Shape,
                    Color         = conduitSpec.Color,
                    ColorMarking  = markingColor,
                    OuterDiameter = conduitSpec.OuterDiameter,
                    InnerDiameter = conduitSpec.InnerDiameter
                };

                var singleConduitPlaccedEvent = new SingleConduitPlaced()
                {
                    WalkOfInterestId = walkOfInterestId,
                    SingleConduitId  = conduitId,
                    ConduitInfo      = conduitInfo,
                    AssetInfo        = assetInfo
                };

                RaiseEvent(singleConduitPlaccedEvent);
            }
        }