/* * Copyright 2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System.Collections; using Agility.Core; namespace Nexus.Core { /// /// Extend ICommand to utilize an IRequestContext [OVR-9] /// ///

/// Rather than have each command cast its context to an /// IRequestContext, /// provide a IRequestCommand with an alternative signature. ///

/// public interface IRequestCommand : ICommand { /// /// An identifier for this Command. /// /// /// Corresponds to the Command property of IHelperContext. /// /// An identifier for this Command. /// string ID { get; set; } /// /// An identifier for a Query associated with this Command (if any). /// /// /// If Query is not set, then ID is returned instead. /// (The default QueryID is the command ID.) /// /// An identifier for this Command. string QueryID { get; set; } /// /// Factory method to provide an empty context that can be used /// with the Command instance. /// /// Context instance with Command ID set. /// IRequestContext NewContext(); /// /// Field IDs required by this Command. /// ///

/// If requisite fields are not present in the main Context, /// appropriate errors should be posted to the Errors property, /// so that the client can correct the oversight and resubmit the request. ///

/// The RelatedIDs property may be used by the command itself, /// or by a collaborating "conversion" command, /// to confirm that related fields, when present, are in the expected format. ///

/// The RelatedIDs property may be used by the command itself, /// or by a collaborating "validation" command, /// to confirm that related fields, when present, are in the expected format. ///

IList RequiredIDs { get; set; } /// /// Add a IList of IDs to the list of {@link RequiredIds}. /// IList AddRequiredIDs { set; } /// /// Record FieldContext IDs related to this Command, including any RequiredIDs. /// ///

/// If a Field ID is not specified as a RelatedID or a RequiredID, /// than it may not be passed from the Criteria to the main Context, /// and so will not be available to the Command. ///

/// As the field is passed from the Fieldstate to the main Context, /// it may also be converted to the appropriate DataType or string format. /// A collaborating Command may reference the FieldTable in a INexusContext /// to ascertain the expected type or format for a value and /// to obtain the appropriate error messages for each field. ///

/// The RelatedIDs property may be used by the command itself, /// or by a collaborating "conversion" command, /// to confirm that related fields, when present, are in the expected format. ///

/// Since posting errors and messages is a specialized concern, /// it is recommended that collaborating Commands handle validation and confirmation. ///

/// A collaborating Command may reference the FieldTable in a INexusContext /// to ascertain the expected format for a value and /// to obtain the appropriate error messages for each field. ///

IList RelatedIDs { get; set; } /// /// Add a IList of IDs to the list of {@link RelatedIds}. /// IList AddRelatedIDs { set; } /// /// Record Field IDs provided during the processing of a Chain. /// ///

/// When Commands are chained, the output from one Command may be used /// as input for another Command. If a collaborating Command is /// validating the Criteria for required input, prior to processing, /// then Runtime FieldIDs may be excluded from the set of RequiredIDs. ///

/// The RuntimeIDs are expected to be set on a Chain rather than an individual /// Command. The property is a member of the INexusCommand interface so that /// Command and Chains can observe the substitution principle. ///

IList RuntimeIDs { get; set; } /// /// Add a IList of IDs to the list of {@link RuntimeIds}. /// IList AddRuntimeIDs { set; } /// /// Invoke the business operation. /// ///

/// Expected to be called from Execute as a casting convenience. ///

/// Context to process. /// bool RequestExecute(IRequestContext context); } }