/// <summary> /// Build <see cref="ProcessType"/> from <paramref name="buildFrom"/>. /// </summary> /// <param name="buildFrom"> /// The build from. /// </param> /// <returns> /// The <see cref="ProcessType"/> from <paramref name="buildFrom"/> . /// </returns> public ProcessType Build(IProcessObject buildFrom) { var builtObj = new ProcessType(); // MAINTAINABLE ATTRIBTUES string value = buildFrom.AgencyId; if (!string.IsNullOrWhiteSpace(value)) { builtObj.agencyID = buildFrom.AgencyId; } string value1 = buildFrom.Id; if (!string.IsNullOrWhiteSpace(value1)) { builtObj.id = buildFrom.Id; } if (buildFrom.Uri != null) { builtObj.uri = buildFrom.Uri; } else if (buildFrom.StructureUrl != null) { builtObj.uri = buildFrom.StructureUrl; } else if (buildFrom.ServiceUrl != null) { builtObj.uri = buildFrom.StructureUrl; } if (ObjectUtil.ValidString(buildFrom.Urn)) { builtObj.urn = buildFrom.Urn; } string value2 = buildFrom.Version; if (!string.IsNullOrWhiteSpace(value2)) { builtObj.version = buildFrom.Version; } if (buildFrom.StartDate != null) { builtObj.validFrom = buildFrom.StartDate; } if (buildFrom.EndDate != null) { builtObj.validTo = buildFrom.EndDate; } IList<ITextTypeWrapper> names = buildFrom.Names; if (ObjectUtil.ValidCollection(names)) { builtObj.Name = this.GetTextType(names); } IList<ITextTypeWrapper> descriptions = buildFrom.Descriptions; if (ObjectUtil.ValidCollection(descriptions)) { builtObj.Description = this.GetTextType(descriptions); } if (this.HasAnnotations(buildFrom)) { builtObj.Annotations = this.GetAnnotationsType(buildFrom); } if (buildFrom.IsExternalReference.IsSet()) { builtObj.isExternalReference = buildFrom.IsExternalReference.IsTrue; } if (buildFrom.IsFinal.IsSet()) { builtObj.isFinal = buildFrom.IsFinal.IsTrue; } /* foreach */ foreach (IProcessStepObject processStep in buildFrom.ProcessSteps) { var processStepType = new ProcessStepType(); builtObj.ProcessStep.Add(processStepType); this.ProcessProcessStep(processStep, processStepType); } return builtObj; }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM V2.1 SCHEMA ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes a new instance of the <see cref="ProcessStepCore"/> class. /// </summary> /// <param name="parent"> /// The parent. /// </param> /// <param name="process"> /// The process. /// </param> /// <exception cref="SdmxSemmanticException"> /// Throws Validate exception. /// </exception> public ProcessStepCore(INameableObject parent, ProcessStepType process) : base(process, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ProcessStep), parent) { this.input = new List<IInputOutputObject>(); this.output = new List<IInputOutputObject>(); this.transitions = new List<ITransition>(); this.processSteps = new List<IProcessStepObject>(); if (process.Input != null) { foreach (InputOutputType currentIo in process.Input) { this.input.Add(new InputOutputCore(this, currentIo)); } } if (process.Output != null) { foreach (InputOutputType currentIo0 in process.Output) { this.output.Add(new InputOutputCore(this, currentIo0)); } } if (process.Computation != null) { this.computation = new ComputationCore(this, process.Computation); } if (process.ProcessStep != null) { foreach (ProcessStepType processStep in process.ProcessStep) { this.processSteps.Add(new ProcessStepCore(this, processStep)); } } if (process.Transition != null) { foreach (TransitionType trans in process.Transition) { ITransition transitionCore = new TransitionCore(trans, this); this.transitions.Add(transitionCore); } } try { this.Validate(); } catch (SdmxSemmanticException e) { throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this); } }
/// <summary> /// Process <paramref name="buildFrom"/> /// </summary> /// <param name="buildFrom"> /// The <see cref="IProcessStepObject"/> to build from /// </param> /// <param name="builtObj"> /// The output /// </param> private void ProcessProcessStep(IProcessStepObject buildFrom, ProcessStepType builtObj) { string value = buildFrom.Id; if (!string.IsNullOrWhiteSpace(value)) { builtObj.id = buildFrom.Id; } IList<ITextTypeWrapper> names = buildFrom.Names; if (ObjectUtil.ValidCollection(names)) { builtObj.Name = this.GetTextType(names); } IList<ITextTypeWrapper> descriptions = buildFrom.Descriptions; if (ObjectUtil.ValidCollection(descriptions)) { builtObj.Description = this.GetTextType(descriptions); } IList<IInputOutputObject> inputObjects = buildFrom.Input; if (ObjectUtil.ValidCollection(inputObjects)) { /* foreach */ foreach (IInputOutputObject input in inputObjects) { if (input.StructureReference != null) { builtObj.Input.Add( XmlobjectsEnumUtil.GetSdmxObjectIdType(input.StructureReference.TargetReference)); } } } IList<IInputOutputObject> outputObjects = buildFrom.Output; if (ObjectUtil.ValidCollection(outputObjects)) { /* foreach */ foreach (IInputOutputObject outputObject in outputObjects) { if (outputObject.StructureReference != null) { builtObj.Input.Add( XmlobjectsEnumUtil.GetSdmxObjectIdType(outputObject.StructureReference.TargetReference)); } } } if (buildFrom.Computation != null) { builtObj.Computation.AddAll(this.GetTextType(buildFrom.Computation.Description)); } IList<ITransition> transitions = buildFrom.Transitions; if (ObjectUtil.ValidCollection(transitions)) { /* foreach */ foreach (ITransition transition in transitions) { var transitionType = new TransitionType(); builtObj.Transition.Add(transitionType); if (transition.TargetStep != null) { transitionType.TargetStep = transition.TargetStep.Id; } IList<ITextTypeWrapper> textTypeWrappers = transition.Condition; if (ObjectUtil.ValidCollection(textTypeWrappers)) { transitionType.Condition = this.GetTextType(textTypeWrappers[0]); } } } IList<IProcessStepObject> processStepObjects = buildFrom.ProcessSteps; if (ObjectUtil.ValidCollection(processStepObjects)) { /* foreach */ foreach (IProcessStepObject processStep in processStepObjects) { var newProcessStepType = new ProcessStepType(); builtObj.ProcessStep.Add(newProcessStepType); this.ProcessProcessStep(processStep, newProcessStepType); } } if (this.HasAnnotations(buildFrom)) { builtObj.Annotations = this.GetAnnotationsType(buildFrom); } }