public WindowNode( PlanNodeId id, PlanNode source, Specification specification, IDictionary <string, Function> windowFunctions, Symbol hashSymbol, HashSet <Symbol> prePartitionedInputs, int preSortedOrderPrefix ) : base(id) { this.Source = source ?? throw new ArgumentNullException("source"); this.PrePartitionedInputs = prePartitionedInputs; this.Specification = specification ?? throw new ArgumentNullException("specification"); this.PreSortedOrderPrefix = preSortedOrderPrefix; ParameterCheck.Check(this.PrePartitionedInputs.All(x => this.Specification.PartitionBy.Contains(x)), "Prepartitioned inputs must be contained in partitionBy."); ParameterCheck.Check(preSortedOrderPrefix == 0 || (this.Specification.OrderingScheme != null && this.PreSortedOrderPrefix <= this.Specification.OrderingScheme.OrderBy.Count()), "Cannot have sorted more symbols than those requested."); ParameterCheck.Check(preSortedOrderPrefix == 0 || this.PrePartitionedInputs.Equals(this.Specification.PartitionBy), "Presorted order prefix can only be greater than zero if all partition symbols are pre-partitioned"); this.WindowFunctions = windowFunctions ?? throw new ArgumentNullException("windowFunctions"); this.HashSymbol = hashSymbol; }
/// <summary> /// Sets the status attribute of a JDF node. /// </summary> /// <param name="element"></param> /// <param name="status"></param> /// <returns></returns> public static XElement SetStatus(this XElement element, JdfStatus status) { ParameterCheck.ParameterRequired(element, "element"); element.ThrowExceptionIfNotJdfElement(); element.SetAttributeValue("Status", status.ToString()); return(element); }
/// <summary> /// Sets any attribute. /// </summary> /// <param name="name"></param> /// <param name="value"></param> /// <returns></returns> public KnownJDFServicesQueryAttributeBuilder Attribute(XName name, string value) { ParameterCheck.ParameterRequired(name, "name"); Element.SetAttributeValue(name, value); return(this); }
/// <summary> /// Determine if we can change the Id of the Resource. /// </summary> /// <remarks>The id of the element does not need to be set at Element creation time, /// if the With().Id("foo") is used, we need to verify if another element uses it.</remarks> /// <param name="element"></param> /// <param name="newId"></param> /// <returns></returns> public static bool CanResourceIdBeChanged(XElement element, string newId) { ParameterCheck.ParameterRequired(element, "jdfNode"); ParameterCheck.ParameterRequired(newId, "newId"); var foundElement = element.JdfXPathSelectElement(string.Format("//*[@ID='{0}']", newId)); if (foundElement == null) { return(true); } var originalAttributeValue = element.GetAttributeValueOrNull("ID"); element.SetAttributeValue("ID", newId); var areEqual = XElement.DeepEquals(foundElement, element); if (!areEqual) { areEqual = element.FirstChild() == null; } element.SetAttributeValue("ID", originalAttributeValue); return(areEqual); }
//TODO Does the method GetJdfNodesContainingProcessType throw off the intellisense for the builders and should it just be a static method? /// <summary> /// Get any JDF Node that contains the processType passed in. /// </summary> /// <param name="element"></param> /// <param name="processType"></param> /// <returns></returns> public static IEnumerable <XElement> GetJdfNodesContainingProcessType(this XContainer element, string processType) { ParameterCheck.ParameterRequired(element, "element"); ParameterCheck.StringRequiredAndNotWhitespace(processType, "processType"); return(element.JdfXPathSelectElements("//JDF").Where(item => GetAllJdfTypes(item).Any(t => t == processType))); }
/// <summary> /// Gets all resources with a particular usage associated with a JDF element. /// </summary> /// <param name="jdfElement">The JDF element to search</param> /// <param name="usage">The resorce usage -- input or output</param> /// <param name="resourceRoot">The root element for finding resources - default is the document root</param> /// <returns>An IEnumerable{XElement} containing a list of resources with the correct usage. /// The list will be empty if there are no resources linked with the given usage.</returns> /// <exception cref="PreconditionException">If the given XElement is not a JDf element.</exception> public static IEnumerable <XElement> ResourcesByUsage(this XElement jdfElement, ResourceUsage usage, XElement resourceRoot = null) { ParameterCheck.ParameterRequired(jdfElement, "jdfElement"); jdfElement.ThrowExceptionIfNotJdfElement(); var linkPool = jdfElement.Element(Element.ResourceLinkPool); if (linkPool == null) { return(new List <XElement>()); } var qualifiedLinkIds = (from resourceLink in linkPool.Elements() where resourceLink.Attribute("Usage") != null && resourceLink.Attribute("Usage").Value == usage.ToString() && resourceLink.Attribute("rRef") != null select resourceLink.Attribute("rRef").Value); var resources = (from resource in (resourceRoot ?? linkPool.Document.Root).Descendants() where resource.Attribute("ID") != null && qualifiedLinkIds.Contains(resource.Attribute("ID").Value) select resource); return(resources); }
/// <summary> /// Modify an existing JDF node. /// </summary> /// <param name="jdfNode"></param> /// <returns></returns> public static JdfNodeBuilder ModifyJdfNode(this XElement jdfNode) { ParameterCheck.ParameterRequired(jdfNode, "jdfNode"); jdfNode.ThrowExceptionIfNotJdfElement(); return(new JdfNodeBuilder(jdfNode)); }
void Initialize(Message message) { ParameterCheck.ParameterRequired(message, "message"); if (message.Root != null) { message.Root.ThrowExceptionIfNotJmfElement(); } if (message.Root == null) { Element = new XElement(LinqToJdf.Element.JMF); Element.SetAttributeValue(XNamespace.Xmlns.GetName("xsi"), Globals.XsiNamespace.NamespaceName); Element.SetVersion(); if (Configuration.FluentJdfLibrary.Settings.JdfAuthoringSettings.HasDefaultSenderId) { Element.SetSenderId(); } Element.SetTimeStampToUtcNow(); message.Add(Element); } else { Element = message.Root; } ParentJmfNode = this; }
internal JmfNodeBuilder(XElement element) { ParameterCheck.ParameterRequired(element, "element"); element.ThrowExceptionIfNotInMessage(); Initialize(element.Document as Message); }
public PlanFragment( PlanFragmentId id, PlanNode root, IDictionary <string, string> symbols, PartitioningHandle partitioning, IEnumerable <PlanNodeId> partitionedSources, PartitioningScheme partitioningScheme, PipelineExecutionStrategy pipelineExecutionStrategy ) { this.Id = id ?? throw new ArgumentNullException("id"); this.Root = root ?? throw new ArgumentNullException("root"); this.Symbols = symbols ?? throw new ArgumentNullException("symbols"); this.Partitioning = partitioning ?? throw new ArgumentNullException("partitioning"); this.PartitionedSources = partitionedSources ?? throw new ArgumentNullException("partitionedSources"); this.PipelineExecutionStrategy = pipelineExecutionStrategy; this.PartitioningScheme = partitioningScheme ?? throw new ArgumentNullException("partitioningScheme"); ParameterCheck.Check(this.PartitionedSources.Distinct().Count() == this.PartitionedSources.Count(), "PartitionedSources contains duplicates."); this.Types = this.PartitioningScheme.OutputLayout.Select(x => x.ToString()); // Materialize this during construction this.PartionedSourceNodes = new HashSet <PlanNode>(FindSources(this.Root, this.PartitionedSources)); this.RemoteSourceNodes = FindRemoteSourceNodes(this.Root).ToList(); }
public BasicQueryInfo( QueryId queryId, SessionRepresentation session, QueryState state, MemoryPoolId memoryPool, bool scheduled, Uri self, string query, BasicQueryStats queryStats, ErrorType errorType, ErrorCode errorCode ) { ParameterCheck.NotNullOrEmpty(query, "query"); this.QueryId = queryId ?? throw new ArgumentNullException("queryId"); this.Session = session ?? throw new ArgumentNullException("session"); this.State = state; this.MemoryPool = memoryPool; this.ErrorType = errorType; this.ErrorCode = errorCode; this.Scheduled = scheduled; this.Self = self ?? throw new ArgumentNullException("self"); this.Query = query; this.QueryStats = queryStats ?? throw new ArgumentNullException("queryStats"); }
/// <summary> /// Register a transmission part for a mime type. /// </summary> /// <param name="mimeType"></param> public void RegisterTransmissionPartForMimeType <T>(string mimeType) where T : ITransmissionPart { ParameterCheck.StringRequiredAndNotWhitespace(mimeType, "mimeType"); RegisterTransmissionPartIfRequired <T>(); transmissionPartsByMimeType[mimeType] = typeof(T); }
public JoinNode( PlanNodeId id, JoinType type, PlanNode left, PlanNode right, IEnumerable <EquiJoinClause> criteria, IEnumerable <Symbol> outputSymbols, dynamic filter, Symbol leftHashSymbol, Symbol rightHashSymbol, DistributionType distributionType ) : base(id) { this.Type = type; this.Left = left ?? throw new ArgumentNullException("left"); this.Right = right ?? throw new ArgumentNullException("right"); this.Criteria = criteria ?? throw new ArgumentNullException("criteria"); this.OutputSymbols = outputSymbols ?? throw new ArgumentNullException("outputSymbols"); this.Filter = filter; this.LeftHashSymbol = leftHashSymbol; this.RightHashSymbol = rightHashSymbol; this.DistributionType = distributionType; HashSet <Symbol> InputSymbols = new HashSet <Symbol>(this.Left.GetOutputSymbols().Concat(this.Right.GetOutputSymbols())); ParameterCheck.Check(this.OutputSymbols.All(x => InputSymbols.Contains(x)), "Left and right join inputs do not contain all output symbols."); ParameterCheck.Check(!this.IsCrossJoin() || InputSymbols.Equals(this.OutputSymbols), "Cross join does not support output symbols pruning or reordering."); ParameterCheck.Check(!(!this.Criteria.Any() && this.LeftHashSymbol != null), "Left hash symbol is only valid in equijoin."); ParameterCheck.Check(!(!this.Criteria.Any() && this.RightHashSymbol != null), "Right hash symbol is only valid in equijoin."); }
/// <summary> /// Constructor. /// </summary> /// <param name="ticket"></param> public Validator(XContainer ticket) { ParameterCheck.ParameterRequired(ticket, "ticket"); Messages = new ReadOnlyCollection <ValidationMessage>(messages); this.ticket = ticket; }
/// <summary> /// Constructor. /// </summary> /// <param name="stream">The stream.</param> /// <param name="contentType">Optional mime type of the request. Defaults /// to HTML (text/html).</param> /// <param name="title">If title is null, the default log entry title will be used.</param> public TransmissionData(Stream stream, string contentType = MimeTypeHelper.HtmlMimeType, string title = null) : this(new NameValueCollection { { "content-type", contentType } }, stream, title) { ParameterCheck.StringRequiredAndNotWhitespace(contentType, "contentType"); }
/// <summary> /// Register an encoding for a specific mime type. /// </summary> /// <param name="mimeType"></param> public EncodingSettingsBuilder EncodingForMimeType <T>(string mimeType) where T : IEncoding { ParameterCheck.StringRequiredAndNotWhitespace(mimeType, "mimeType"); encodingSettings.RegisterEncodingForMimeType <T>(mimeType); return(this); }
/// <summary> /// Constructor. /// </summary> /// <param name="headers"></param> /// <param name="stream"></param> /// <param name="title">If title is null, the default log entry title will be used.</param> public TransmissionData(NameValueCollection headers, Stream stream, string title = null) { ParameterCheck.ParameterRequired(headers, "headers"); ParameterCheck.ParameterRequired(stream, "stream"); this.title = title; if (stream.CanSeek) { Stream = stream; } else { Stream = new TempFileStream(); using (stream) { stream.CopyTo(Stream); } } Stream.Seek(0, SeekOrigin.Begin); if (headers["content-type"] != null) { ContentType = headers["content-type"].NormalizeContentType(); } else { ContentType = MimeTypeHelper.HtmlMimeType; } Headers = headers; }
internal TransmissionPartSettingsBuilder(FluentJdfLibrary fluentJdfLibrary, TransmissionPartSettings transmissionPartSettings) : base(fluentJdfLibrary) { ParameterCheck.ParameterRequired(transmissionPartSettings, "transmissionPartSettings"); this.transmissionPartSettings = transmissionPartSettings; }
/// <summary> /// Add an audit to the JDF's audit pool. /// </summary> /// <returns></returns> /// <remarks>Configured values for author, agent name and /// agent version are used if they are not passed.</remarks> public static XElement AddAudit(this XElement jdfNode, XName auditName, string author = null, DateTime?eventDateTime = null, string agentName = null, string agentVersion = null) { ParameterCheck.ParameterRequired(jdfNode, "jdfNode"); ParameterCheck.ParameterRequired(auditName, "auditName"); jdfNode.ThrowExceptionIfNotJdfElement(); if (agentName == null) { agentName = Configuration.FluentJdfLibrary.Settings.JdfAuthoringSettings.AgentName; } if (agentVersion == null) { agentVersion = Configuration.FluentJdfLibrary.Settings.JdfAuthoringSettings.AgentVersion; } if (author == null) { author = Configuration.FluentJdfLibrary.Settings.JdfAuthoringSettings.Author; } if (eventDateTime == null) { eventDateTime = DateTime.UtcNow; } var auditPool = jdfNode.AuditPoolElement(); auditPool.Add(new XElement(auditName, new XAttribute("AgentName", agentName), new XAttribute("AgentVersion", agentVersion), new XAttribute("Author", author), new XAttribute("TimeStamp", eventDateTime.Value.ToString("O")))); return(jdfNode); }
/// <summary> /// Sets any attribute. /// </summary> /// <param name="name"></param> /// <param name="value"></param> /// <returns></returns> public CloseQueueCommandAttributeBuilder Attribute(XName name, string value) { ParameterCheck.ParameterRequired(name, "name"); Element.SetAttributeValue(name, value); return(this); }
/// <summary> /// Link an existing resource with the given id as an input. Promote the resource if required. /// </summary> /// <param name="jdfNode"></param> /// <param name="id"></param> /// <exception cref="JdfException">If a resource with the given id cannot be found /// and promoted without breaking any existing references.</exception> /// <returns></returns> public static XElement AddInput(this XElement jdfNode, string id) { ParameterCheck.ParameterRequired(jdfNode, "jdfNode"); ParameterCheck.StringRequiredAndNotWhitespace(id, "id"); return(jdfNode.LinkResource(ResourceUsage.Input, null, id)); }
/// <summary> /// Sets the version of this JMF node. /// </summary> /// <param name="jdfVersion"></param> /// <returns></returns> public CloseQueueCommandAttributeBuilder JdfVersion(string jdfVersion) { ParameterCheck.StringRequiredAndNotWhitespace(jdfVersion, "jdfVersion"); Element.SetVersion(jdfVersion); return(this); }
/// <summary> /// Change the ID of a resource and promote if needed. /// </summary> /// <param name="element">The Resource Element to change</param> /// <param name="id">The new Id of the Element</param> /// <param name="updateReferences"></param> public static void ChangeResourceId(XElement element, string id, bool updateReferences = true) { ParameterCheck.ParameterRequired(element, "jdfNode"); ParameterCheck.ParameterRequired(id, "newId"); if (!CanResourceIdBeChanged(element, id)) { throw new JdfException(string.Format(FluentJdf.Resources.Messages.TheId0AlreadyExistsOnAResourceNotMatchingTheCurrent, id)); } var originalElement = element.JdfXPathSelectElement(string.Format("//*[@ID='{0}']", id)); element.SetId(id, updateReferences); if (originalElement != null) { foreach (var item in originalElement.Elements()) { element.Add(item); } } PromoteResourceIfNeeded(element); if (originalElement != null) { originalElement.Remove(); } }
/// <summary> /// Sets the job id of the instance. /// </summary> /// <param name="jobId"></param> /// <returns></returns> public GeneratedDocumentBuilderHelper JobId(string jobId) { ParameterCheck.StringRequiredAndNotWhitespace(jobId, "jobId"); this.jobId = jobId; return(this); }
/// <summary> /// Sets the type of the node. /// </summary> /// <param name="element"></param> /// <param name="value"></param> /// <returns></returns> public static XElement SetJdfType(this XElement element, string value) { ParameterCheck.ParameterRequired(element, "element"); element.SetAttributeValue("Type", value); return(element); }
internal GeneratedDocumentBuilderHelper(string templateFileName) { ParameterCheck.StringRequiredAndNotWhitespace(templateFileName, "templateFileName"); Initialize(); this.templateFileName = templateFileName; }
/// <summary> /// Set type and optionally types of a JDF node. /// </summary> /// <param name="jdfNode"></param> /// <param name="isGrayBox">If true, makes a gray box (Process group with types set)</param> /// <param name="types"></param> /// <returns></returns> public static XElement SetTypeAndTypes(this XElement jdfNode, bool isGrayBox, params string[] types) { ParameterCheck.ParameterRequired(jdfNode, "jdfNode"); ThrowExceptionIfNotJdfElement(jdfNode); if (types == null || types.Length == 0) { jdfNode.SetAttributeValue("Type", ProcessType.ProcessGroup); jdfNode.SetXsiType(ProcessType.XsiJdfElementType(ProcessType.ProcessGroup).ToString()); } if (types.Length > 0 && isGrayBox) { MakeGrayBox(jdfNode, types); } else { if (types.Length == 1) { MakeSimpleProcess(jdfNode, types); } else { MakeCombinedProcess(jdfNode, types); } } return(jdfNode); }
internal GeneratedDocumentBuilderHelper(Stream templateStream) { ParameterCheck.ParameterRequired(templateStream, "templateStream"); Initialize(); this.templateStream = templateStream; }
/// <summary> /// Sets the version of this JMF node. /// </summary> /// <param name="jdfVersion"></param> /// <returns></returns> public KnownJDFServicesQueryAttributeBuilder JdfVersion(string jdfVersion) { ParameterCheck.StringRequiredAndNotWhitespace(jdfVersion, "jdfVersion"); Element.SetVersion(jdfVersion); return(this); }
/// <summary> /// Sets the version of this JMF node. /// </summary> /// <param name="jdfVersion"></param> /// <returns></returns> public QueueEntryStatusQueryAttributeBuilder JdfVersion(string jdfVersion) { ParameterCheck.StringRequiredAndNotWhitespace(jdfVersion, "jdfVersion"); Element.SetVersion(jdfVersion); return(this); }