Beispiel #1
0
 public MultiConduitCommandHandler(IAggregateRepository aggregateRepository, IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService, IConduitSpecificationRepository conduitSpecificationRepository)
 {
     this.repo = aggregateRepository;
     this.conduitNetworkQueryService     = conduitNetworkQueryService;
     this.routeNetworkQueryService       = routeNetworkQueryService;
     this.conduitSpecificationRepository = conduitSpecificationRepository;
 }
Beispiel #2
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());
            }
                );
        }
Beispiel #3
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);
            }
        }
Beispiel #4
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);
                }
            }
        }
Beispiel #5
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");
        }
Beispiel #6
0
        public ConduitServiceCommandHandler(IMediator commandBus, IConduitClosureRepository conduitClosureRepository, IConduitNetworkQueryService conduitNetworkQueryService, IRouteNetworkState routeNetwork, IConduitNetworkQueryService conduitNetwork, IConduitSpecificationRepository conduitSpecificationRepository)
        {
            Description = "API for sending commands to the conduit service";

            Field <ConduitClosureCommandHandler>("conduitClosure", resolve: context => new { });
            Field <MultiConduitCommandHandler>("multiConduit", resolve: context => new { });
            Field <SingleConduitCommandHandler>("singleConduit", resolve: context => new { });

            Field <ConduitInfoType>(
                "placeConduit",
                description: "Place a multi or single conduit in the route network",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "conduitSpecificationId"
            },
                    new QueryArgument <NonNullGraphType <ListGraphType <IdGraphType> > > {
                Name = "walkOfInterest", Description = "Route network walk specified as a list of route element ids (route-node-id, route-segment-id, route-node-id...)"
            },
                    new QueryArgument <IdGraphType> {
                Name = "conduitId", Description = "If not specified, a new guid will automatically be created"
            },
                    new QueryArgument <StringGraphType> {
                Name = "name"
            },
                    new QueryArgument <ConduitColorEnumType> {
                Name = "markingColor"
            },
                    new QueryArgument <StringGraphType> {
                Name = "markingText"
            }
                    ),
                resolve: context =>
            {
                try
                {
                    var conduitSpec = conduitSpecificationRepository.GetConduitSpecification(context.GetArgument <Guid>("conduitSpecificationId"));

                    // Check that conduit not already exists


                    // First create walk of interest
                    var walkOfInterestCmd = new RegisterWalkOfInterestCommand()
                    {
                        WalkOfInterestId = Guid.NewGuid(),
                        RouteElementIds  = context.GetArgument <List <Guid> >("walkOfInterest")
                    };

                    commandBus.Send(walkOfInterestCmd).Wait();


                    var conduitId = context.GetArgument <Guid>("conduitId");

                    // Multi conduit
                    if (conduitSpec.Kind == ConduitKindEnum.MultiConduit)
                    {
                        var placeConduitCommand = new PlaceMultiConduitCommand()
                        {
                            MultiConduitId         = Guid.NewGuid(),
                            ConduitSpecificationId = context.GetArgument <Guid>("conduitSpecificationId"),
                            WalkOfInterestId       = walkOfInterestCmd.WalkOfInterestId,
                            Name         = context.GetArgument <string>("name"),
                            MarkingColor = context.GetArgument <ConduitColorEnum>("markingColor"),
                            MarkingText  = context.GetArgument <string>("markingText")
                        };

                        if (conduitId != Guid.Empty)
                        {
                            placeConduitCommand.MultiConduitId = conduitId;
                        }

                        commandBus.Send(placeConduitCommand).Wait();

                        return(conduitNetworkQueryService.GetMultiConduitInfo(placeConduitCommand.MultiConduitId));
                    }
                    // Single conduit
                    else
                    {
                        var placeConduitCommand = new PlaceSingleConduitCommand()
                        {
                            SingleConduitId        = Guid.NewGuid(),
                            ConduitSpecificationId = context.GetArgument <Guid>("conduitSpecificationId"),
                            WalkOfInterestId       = walkOfInterestCmd.WalkOfInterestId,
                            Name         = context.GetArgument <string>("name"),
                            MarkingColor = context.GetArgument <ConduitColorEnum>("markingColor"),
                            MarkingText  = context.GetArgument <string>("markingText")
                        };

                        if (conduitId != Guid.Empty)
                        {
                            placeConduitCommand.SingleConduitId = conduitId;
                        }

                        commandBus.Send(placeConduitCommand).Wait();

                        return(conduitNetworkQueryService.GetSingleConduitInfo(placeConduitCommand.SingleConduitId));
                    }
                }

                catch (Exception ex)
                {
                    context.Errors.Add(new ExecutionError(ex.Message, ex));
                }

                return(null);
            });


            Field <StringGraphType>(
                "placeFiberCableWithinConduit",
                description: "Place a fiber cable inside a conduit",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "cableSegmentId", Description = "Id of the cable segment to be placed inside a conduit"
            },
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "conduitSegmentId1", Description = "Id of the conduit segment where the cable should be placed"
            },
                    new QueryArgument <IdGraphType> {
                Name = "conduitSegmentId2", Description = "Used when placing cables into a conduit that is cut and not connected in a well. The you must specify both the incomming and outgoing conduit segment in the well, because otherwise the cable has an unknown route."
            }
                    ),
                resolve: context =>
            {
                return(null);
            });
        }