/// <summary> /// Determine the engineering model setup based on the supplied routeSegments. /// </summary> /// <param name="processor"> /// The processor instance. /// </param> /// <param name="routeSegments"> /// The route segments constructed from the request path. /// </param> /// <returns> /// The resolved <see cref="EngineeringModelSetup"/>. /// </returns> /// <exception cref="Exception"> /// If engineering model could not be resolved /// </exception> private EngineeringModelSetup DetermineEngineeringModelSetup(IProcessor processor, string[] routeSegments) { // override query parameters to return only extent shallow this.RequestUtils.OverrideQueryParameters = new QueryParameters(); var securityContext = new RequestSecurityContext { ContainerReadAllowed = true }; // set the transaction to default context to retrieve SiteDirectory data this.TransactionManager.SetDefaultContext(processor.Transaction); // take first segment and try to resolve the engineering model setup for further processing var siteDir = (SiteDirectory)processor.GetResource("SiteDirectory", SiteDirectoryData, null, securityContext).Single(); var requestedModelId = Utils.ParseIdentifier(routeSegments[1]); var engineeringModelSetups = processor.GetResource("EngineeringModelSetup", SiteDirectoryData, siteDir.Model, securityContext); var modelSetups = engineeringModelSetups.Where(x => ((EngineeringModelSetup)x).EngineeringModelIid == requestedModelId).ToList(); if (modelSetups.Count != 1) { throw new Exception("Engineering model could not be resolved"); } // override query parameters to return only extent shallow this.RequestUtils.OverrideQueryParameters = null; return((EngineeringModelSetup)modelSetups.Single()); }
/// <summary> /// Determine the iteration based on the supplied routeSegments. /// </summary> /// <param name="processor"> /// The processor instance. /// </param> /// <param name="partition">The partition of the search.</param> /// <param name="routeSegments"> /// The route segments constructed from the request path. /// </param> /// <returns> /// The resolved <see cref="Iteration"/>. /// </returns> private Iteration DetermineIteration(IProcessor processor, string partition, string[] routeSegments) { if (routeSegments.Length >= 4 && routeSegments[2] == "iteration") { var securityContext = new RequestSecurityContext { ContainerReadAllowed = true, Credentials = this.PermissionService.Credentials }; var requestedIterationId = Utils.ParseIdentifier(routeSegments[3]); var iterations = processor.GetResource("Iteration", partition, new List <Guid> { requestedIterationId }, securityContext).ToList(); if (iterations.Count != 1) { throw new Exception("Iteration could not be resolved"); } return((Iteration)iterations.Single()); } return(null); }