示例#1
0
        /// <summary>
        /// Replace or insert the specified <paramref name="artefact"/> to MAPPING STORE
        /// </summary>
        /// <param name="state">
        /// The state.
        /// </param>
        /// <param name="artefact">
        /// The artefact.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="state"/> is null
        ///     -or-
        ///     <paramref name="artefact"/> is null
        /// </exception>
        /// <returns>
        /// The <see cref="ArtefactImportStatus"/>.
        /// </returns>
        protected ArtefactImportStatus ReplaceOrInsert(DbTransactionState state, IMaintainableObject artefact)
        {
            if (state == null)
            {
                throw new ArgumentNullException("state");
            }

            if (artefact == null)
            {
                throw new ArgumentNullException("artefact");
            }

            var structureReference = artefact.AsReference;

            _log.DebugFormat(CultureInfo.InvariantCulture, "Replacing or Insert artefact = {0}", structureReference);
            var finalStatus = GetFinalStatus(state, structureReference);
            ArtefactImportStatus status;

            if (finalStatus == null || finalStatus.PrimaryKey < 0)
            {
                status = this.InsertArtefact(state, artefact);
            }
            else if (!finalStatus.IsFinal)
            {
                this.Delete(state, finalStatus.PrimaryKey);
                status = this.InsertArtefact(state, artefact);
            }
            else
            {
                status = new ArtefactImportStatus(finalStatus.PrimaryKey, this.GetCannotReplaceMessage(structureReference));
            }

            return(status);
        }
示例#2
0
        private static ISet <ICategorisationObject> GetCategorisations(
            IMaintainableObject maintainable, IEnumerable <ICategorisationObject> categorisations)
        {
            ISet <ICategorisationObject> returnSet = new HashSet <ICategorisationObject>();

            if (maintainable.IsExternalReference.IsTrue)
            {
                return(returnSet);
            }

            /* foreach */
            foreach (ICategorisationObject cat in categorisations)
            {
                if (cat.IsExternalReference.IsTrue)
                {
                    continue;
                }

                if (cat.StructureReference.TargetReference.EnumType == maintainable.StructureType.EnumType)
                {
                    if (MaintainableUtil <IMaintainableObject> .Match(maintainable, cat.StructureReference))
                    {
                        returnSet.Add(cat);
                    }
                }
            }

            return(returnSet);
        }
		public MaintainableObjectBaseCore(IMaintainableObject maintainable) : base(maintainable) {
			//TODO AgencyId should be full agency
			this.builtFrom = maintainable;
			this.agencyId = maintainable.AgencyId;
			this.version = maintainable.Version;
			this.isFinal = maintainable.IsFinal().IsTrue;
			this.isStub = maintainable.Stub;
		}
        /// <summary>
        /// The write structure.
        /// </summary>
        /// <param name="bean">
        /// The maintainable object.
        /// </param>
        /// <exception cref="NotImplementedException">
        /// SDMX EDI for structures is not implemented in this implementation.
        /// </exception>
        public virtual void WriteStructure(IMaintainableObject bean)
        {
            throw new NotImplementedException("SDMX EDI for structures is not implemented in this implementation.");

            ////ISdmxObjects beans = new SdmxObjectsImpl();
            ////beans.AddIdentifiable(bean);
            ////WriteStructures(beans);
        }
 private void PrintMaintainable(IMaintainableObject maintainableObject)
 {
     this._writer.WriteLine("<tr><td>{0}</td>", maintainableObject.AgencyId);
     this._writer.WriteLine("<td>{0}</td>", maintainableObject.StructureType.StructureType);
     this._writer.WriteLine("<td>{0}</td>", maintainableObject.Name);
     this._writer.WriteLine("<td>{0}</td>", maintainableObject.IdentifiableComposites.Count);
     this._writer.WriteLine("</tr>");
 }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECTS             //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="MeasureListCore"/> class.
        /// </summary>
        /// <param name="measureList">
        /// The measure list. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        public MeasureListCore(IMeasureListMutableObject measureList, IMaintainableObject parent)
            : base(measureList, parent)
        {
            if (measureList.PrimaryMeasure != null)
            {
                this.primaryMeasure = new PrimaryMeasureCore(measureList.PrimaryMeasure, this);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CrossReferencingTreeCore"/> class.
 /// </summary>
 /// <param name="maintainable">
 /// The maintainable. 
 /// </param>
 /// <param name="referencingObjects">
 /// The referencing objects 
 /// </param>
 public CrossReferencingTreeCore(
     IMaintainableObject maintainable, IList<ICrossReferencingTree> referencingObjects)
 {
     this.referencingObjects = new List<ICrossReferencingTree>();
     this.maintainableObject = maintainable;
     if (referencingObjects != null)
     {
         this.referencingObjects = referencingObjects;
     }
 }
 /// <summary>
 /// Returns the set of cross referenced structures from this maintainable.
 /// </summary>
 /// <param name="retrievalManager">
 /// The retrieval manager
 /// </param>
 /// <param name="maintainable">
 /// The maintainable object
 /// </param>
 /// <returns>
 /// The cross references set.
 /// </returns>
 public ISet<ICrossReference> GetCrossReferences(ISdmxObjectRetrievalManager retrievalManager, IMaintainableObject maintainable)
 {
     switch (maintainable.StructureType.EnumType)
     {
         case SdmxStructureEnumType.ContentConstraint:
             return GetCrossReferences(retrievalManager, (IContentConstraintObject)maintainable);
         default:
             return maintainable.CrossReferences;
     }
 }
示例#9
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="MeasureListCore"/> class.
        /// </summary>
        /// <param name="measureList">
        /// The measure list. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        public MeasureListCore(MeasureListType measureList, IMaintainableObject parent)
            : base(measureList, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.MeasureDescriptor), parent)
        {
            if (measureList.Component != null)
            {
                this.primaryMeasure =
                    new PrimaryMeasureCore(
                        (Org.Sdmx.Resources.SdmxMl.Schemas.V21.Structure.PrimaryMeasureType)
                        measureList.Component[0].Content, 
                        this);
            }
        }
示例#10
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="AttributeListCore"/> class.
        /// </summary>
        /// <param name="attributeList">
        /// The attributeObject list. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        public AttributeListCore(AttributeListType attributeList, IMaintainableObject parent)
            : base(attributeList, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.AttributeDescriptor), parent)
        {
            this.attributes = new List<IAttributeObject>();
            if (attributeList.Attribute != null)
            {
                foreach (Attribute currentAttribute in attributeList.Attribute)
                {
                    this.attributes.Add(new AttributeObjectCore(currentAttribute.Content, this));
                }
            }
        }
        /// <summary>
        /// The assemble maintainable.
        /// </summary>
        /// <param name="builtObj">
        /// The object to populate.
        /// </param>
        /// <param name="buildFrom">
        /// The build from.
        /// </param>
        public void AssembleMaintainable(MaintainableType builtObj, IMaintainableObject buildFrom)
        {
            // Populate it from inherited super
            this.AssembleNameable(builtObj, buildFrom);

            // Populate it using this class's specifics
            string str1 = buildFrom.AgencyId;
            if (!string.IsNullOrWhiteSpace(str1))
            {
                builtObj.agencyID = buildFrom.AgencyId;
            }

            string str0 = buildFrom.Version;
            if (!string.IsNullOrWhiteSpace(str0))
            {
                builtObj.version = buildFrom.Version;
            }

            if (buildFrom.StartDate != null)
            {
                builtObj.validFrom = buildFrom.StartDate.Date;
            }

            if (buildFrom.EndDate != null)
            {
                builtObj.validTo = buildFrom.EndDate.Date;
            }

            if (buildFrom.IsExternalReference.IsSet())
            {
                builtObj.isExternalReference = buildFrom.IsExternalReference.IsTrue;
            }

            if (buildFrom.IsFinal.IsSet())
            {
                builtObj.isFinal = buildFrom.IsFinal.IsTrue;
            }

            if (buildFrom.StructureUrl != null)
            {
                builtObj.structureURL = buildFrom.StructureUrl;
            }

            if (buildFrom.ServiceUrl != null)
            {
                builtObj.serviceURL = buildFrom.ServiceUrl;
            }
        }
示例#12
0
        /// <summary>
        /// Run common artefact import command.
        /// </summary>
        /// <param name="artefact">
        /// The artefact.
        /// </param>
        /// <param name="command">
        /// The command.
        /// </param>
        /// <param name="artefactStoredProcedure">
        /// The artefact stored procedure.
        /// </param>
        /// <returns>
        /// The <see cref="ArtefactImportStatus"/>.
        /// </returns>
        protected ArtefactImportStatus RunArtefactCommand(IMaintainableObject artefact, DbCommand command, ArtefactProcedurebase artefactStoredProcedure)
        {
            DbParameter versionParameter = artefactStoredProcedure.CreateVersionParameter(command);

            versionParameter.Value = artefact.Version ?? (object)DBNull.Value;

            DbParameter agencyParameter = artefactStoredProcedure.CreateAgencyParameter(command);

            agencyParameter.Value = artefact.AgencyId ?? (object)DBNull.Value;

            DbParameter validFromParameter = artefactStoredProcedure.CreateValidFromParameter(command);

            if (artefact.StartDate != null)
            {
                validFromParameter.Value = artefact.StartDate.Date;
            }

            DbParameter validToParameter = artefactStoredProcedure.CreateValidToParameter(command);

            if (artefact.EndDate != null)
            {
                validToParameter.Value = artefact.EndDate.Date;
            }

            DbParameter uriParameter = artefactStoredProcedure.CreateUriParameter(command);

            if (artefact.Uri != null)
            {
                uriParameter.Value = artefact.Uri.ToString();
            }

            DbParameter isFinalParameter = artefactStoredProcedure.CreateIsFinalParameter(command);

            isFinalParameter.Value = artefact.IsFinal.IsTrue ? 1 : 0;

            var artID = this.RunNameableArtefactCommand(artefact, command, artefactStoredProcedure);

            // "Inserted artefact with ID:" + artefactGetID + " VERSION:" + artefact.version + " AGENCY:" + artefact.agencyID + Environment.NewLine;
            var structureReference = artefact.AsReference;
            var importMessage      = new ImportMessage(
                ImportMessageStatus.Success,
                structureReference,
                string.Format("Success: {0} was inserted.{1}", structureReference.GetAsHumanReadableString(), Environment.NewLine));

            return(new ArtefactImportStatus(artID, importMessage));
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="DimensionListCore"/> class.
        /// </summary>
        /// <param name="keyFamily">
        /// The agencyScheme. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <exception cref="SdmxSemmanticException"> Throws SdmxSemmanticException.
        /// </exception>
        public DimensionListCore(KeyFamilyType keyFamily, IMaintainableObject parent)
            : base(
                DimensionList.FixedId, 
                SdmxStructureType.GetFromEnum(SdmxStructureEnumType.DimensionDescriptor), 
                parent)
        {
            this.dimensions = new List<IDimension>();
            int pos = 1;
            ComponentsType components = keyFamily.Components;
            try
            {
                if (components != null)
                {
                    foreach (DimensionType currentDimension in components.Dimension)
                    {
                        this.dimensions.Add(new DimensionCore(currentDimension, this, pos));
                        pos++;
                    }

                    if (components.TimeDimension != null)
                    {
                        this.dimensions.Add(new DimensionCore(components.TimeDimension, this, pos));
                    }
                }
            }
            catch (SdmxSemmanticException ex)
            {
                throw new SdmxSemmanticException(ex, ExceptionCode.ObjectStructureConstructionError, this.Urn);
            }
            catch (Exception th)
            {
                throw new SdmxException(th, ExceptionCode.ObjectStructureConstructionError, this.Urn);
            }

            this.ValidateDimensionList();
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="DimensionListCore"/> class.
        /// </summary>
        /// <param name="dimensionList">
        /// The dimension list. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public DimensionListCore(DimensionListType dimensionList, IMaintainableObject parent)
            : base(dimensionList, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.DimensionDescriptor), parent)
        {
            this.dimensions = new List<IDimension>();
            int pos = 1;
            if (dimensionList.Dimension != null)
            {
                foreach (Dimension dimension in dimensionList.Dimension)
                {
                    this.dimensions.Add(new DimensionCore(dimension.Content, this, pos));
                    pos++;
                }
            }

            if (ObjectUtil.ValidCollection(dimensionList.MeasureDimension))
            {
                if (dimensionList.MeasureDimension.Count > 1)
                {
                    throw new SdmxSemmanticException("Can not have more then one measure dimension");
                }

                this.dimensions.Add(new DimensionCore(dimensionList.MeasureDimension[0].Content, this, pos));
                pos++;
            }

            if (ObjectUtil.ValidCollection(dimensionList.TimeDimension))
            {
                if (dimensionList.TimeDimension.Count > 1)
                {
                    throw new SdmxSemmanticException("Can not have more then one time dimension");
                }

                this.dimensions.Add(new DimensionCore(dimensionList.TimeDimension[0].Content, this, pos));
            }

            this.ValidateDimensionList();
        }
		public MaintainableMutableObjectBaseCore(IMaintainableObject maintainable) : base(maintainable) {
			this._agencyId = maintainable.AgencyId;
			this._version = maintainable.Version;
			this._isIsFinal = maintainable.IsFinal().IsTrue;
			this._isStub = maintainable.Stub;
		}
        /// <summary>
        /// Validates a structure is compliant to the 2.1 SDMX schema, by writing it out as SDMX and validating against the schema.
        ///     WARNING: This implementation writes temporary to memory.
        /// </summary>
        /// <param name="maintainableBean">
        /// The maintainable object
        /// </param>
        public virtual void ValidateStructure(IMaintainableObject maintainableBean)
        {
            using (var memoryStream = new MemoryStream())
            {
                this._structureWritingManager.WriteStructure(maintainableBean, null, new SdmxStructureFormat(_outputFormat), memoryStream);
                memoryStream.Position = 0;

                using (IReadableDataLocation dataLocation = this._readableDataLocationFactory.GetReadableDataLocation(memoryStream.ToArray()))
                {
                    this._structureParsingManager.ParseStructures(dataLocation);
                }
            }
        }
示例#17
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V1.0 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="AttributeListCore"/> class.
        /// </summary>
        /// <param name="keyFamily">
        /// The sdmxObject. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        public AttributeListCore(
            Org.Sdmx.Resources.SdmxMl.Schemas.V10.structure.KeyFamilyType keyFamily, IMaintainableObject parent)
            : base(
                AttributeListObject.FixedId, 
                SdmxStructureType.GetFromEnum(SdmxStructureEnumType.AttributeDescriptor), 
                parent)
        {
            this.attributes = new List<IAttributeObject>();
            if (keyFamily.Components != null && keyFamily.Components.Attribute != null)
            {
                foreach (Org.Sdmx.Resources.SdmxMl.Schemas.V10.structure.AttributeType currentAttribute in
                    keyFamily.Components.Attribute)
                {
                    this.attributes.Add(new AttributeObjectCore(currentAttribute, this));
                }
            }
        }
示例#18
0
 /// <summary>
 /// Generate a key using the following format AgencyID+ID+Version
 /// </summary>
 /// <param name="artefact">
 /// The artefact to generate the key for
 /// </param>
 /// <returns>
 /// The key
 /// </returns>
 public static string MakeKey(IMaintainableObject artefact)
 {
     return(MakeKey(artefact.Id, artefact.AgencyId, artefact.Version));
 }
        /// <summary>
        /// Increments the version of the old maintainable
        /// </summary>
        /// <param name="currentMaint">
        /// current maintainable
        /// </param>
        /// <param name="incrementFromVersion">
        /// the increment from version
        /// </param>
        /// <param name="majorIncrement">
        /// the major increment
        /// </param>
        /// <returns>
        /// The mantainable object with incremented version
        /// </returns>
        private IMaintainableObject IncrmentVersion(
            IMaintainableObject currentMaint, String incrementFromVersion, bool majorIncrement)
        {
            IMaintainableMutableObject mutable = currentMaint.MutableInstance;
            String newVersion = VersionableUtil.IncrementVersion(incrementFromVersion, majorIncrement);
            mutable.Version = newVersion;

            IMaintainableObject newMaint = mutable.ImmutableInstance;
            return newMaint;
        }
		private ISet<IProvisionAgreementObject> GetByReference(IMaintainableObject bean) {
			ISet<IMaintainableObject> provisions = beans
					.GetMaintinables(Org.Sdmxsource.Sdmx.Api.Constants.SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ProvisionAgreement));
			ISet<IProvisionAgreementObject> returnSet = new HashSet<IProvisionAgreementObject>();
			/* foreach */
			foreach (IMaintainableObject currentProvision  in  provisions) {
				IProvisionAgreementObject provision = (IProvisionAgreementObject) currentProvision;
				if (IsMatch(provision, bean)) {
					returnSet.Add(provision);
				}
			}
			return returnSet;
		}
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="MeasureListCore"/> class.
        /// </summary>
        /// <param name="primaryMeasure">
        /// The primary measure. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        public MeasureListCore(
            Org.Sdmx.Resources.SdmxMl.Schemas.V10.structure.PrimaryMeasureType primaryMeasure, 
            IMaintainableObject parent)
            : base(
                MeasureList.FixedId, 
                SdmxStructureType.GetFromEnum(SdmxStructureEnumType.MeasureDescriptor), 
                parent)
        {
            this.primaryMeasure = new PrimaryMeasureCore(primaryMeasure, this);
        }
示例#22
0
 /// <summary>
 /// Insert the specified <paramref name="artefact"/> to MAPPING STORE
 /// </summary>
 /// <param name="state">
 /// The Mapping Store connection and transaction state
 /// </param>
 /// <param name="artefact">
 /// The artefact.
 /// </param>
 /// <returns>
 /// The <see cref="ArtefactImportStatus"/>.
 /// </returns>
 protected override ArtefactImportStatus InsertArtefact(DbTransactionState state, IMaintainableObject artefact)
 {
     return(this.Insert(state, (T)artefact));
 }
 /// <summary>
 /// The write structure.
 /// </summary>
 /// <param name="bean">
 /// The bean.
 /// </param>
 public virtual void WriteStructure(IMaintainableObject bean)
 {
     ISdmxObjects beans = new SdmxObjectsImpl();
     beans.AddIdentifiable(bean);
     this.WriteStructures(beans);
 }
 public void WriteStructure(IMaintainableObject maintainableObject)
 {
     PrintMaintainable(maintainableObject);
     Close();
 }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="DimensionListCore"/> class.
        /// </summary>
        /// <param name="keyFamily">
        /// The agencyScheme. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        public DimensionListCore(
            Org.Sdmx.Resources.SdmxMl.Schemas.V10.structure.KeyFamilyType keyFamily, IMaintainableObject parent)
            : base(
                DimensionList.FixedId, 
                SdmxStructureType.GetFromEnum(SdmxStructureEnumType.DimensionDescriptor), 
                parent)
        {
            this.dimensions = new List<IDimension>();
            Org.Sdmx.Resources.SdmxMl.Schemas.V10.structure.ComponentsType components = keyFamily.Components;
            int pos = 1;
            if (components != null)
            {
                foreach (Org.Sdmx.Resources.SdmxMl.Schemas.V10.structure.DimensionType currentDimension in
                    components.Dimension)
                {
                    this.dimensions.Add(new DimensionCore(currentDimension, this, pos));
                    pos++;
                }

                if (components.TimeDimension != null)
                {
                    this.dimensions.Add(new DimensionCore(components.TimeDimension, this, pos));
                }
            }

            this.ValidateDimensionList();
        }
 /// <summary>
 /// Maps old versus new references.
 /// </summary>
 /// <param name="oldVersionNumber">
 /// The old version number.
 /// </param>
 /// <param name="newVersion">
 /// The new version object.
 /// </param>
 /// <param name="oldVsNew">
 /// The old vs new map.
 /// </param>
 private void AddOldVsNewReferences(
     String oldVersionNumber,
     IMaintainableObject newVersion,
     IDictionary<IStructureReference, IStructureReference> oldVsNew)
 {
     this.AddOldVsNewReferencesToMap(oldVersionNumber, newVersion, oldVsNew);
     foreach (IIdentifiableObject composite in newVersion.IdentifiableComposites)
     {
         this.AddOldVsNewReferencesToMap(oldVersionNumber, composite, oldVsNew);
     }
 }
        /// <summary>
        /// Add <paramref name="maintainable"/> to map.
        /// </summary>
        /// <param name="maintainable">
        /// The maintainable.
        /// </param>
        private void AddMaintainableToMap(IMaintainableObject maintainable)
        {
            if (!this._allIdentifiables.ContainsKey(maintainable.Urn))
            {
                this._allIdentifiables.Add(maintainable.Urn, maintainable);
                foreach (IIdentifiableObject identifiableBean in maintainable.IdentifiableComposites)
                {
                    if (identifiableBean.StructureType.EnumType == SdmxStructureEnumType.Agency)
                    {
                        var acy = (IAgency)identifiableBean;
                        this._agencies.Add(acy.FullId, acy);
                    }

                    this._allIdentifiables.Add(identifiableBean.Urn, identifiableBean);
                }
            }
        }
        /// <summary>
        /// Gets organisation scheme type.
        /// </summary>
        /// <param name="buildFrom">
        /// The build from.
        /// </param>
        /// <returns>
        /// The <see cref="OrganisationSchemeType"/> .
        /// </returns>
        private OrganisationSchemeType GetOrganisationSchemeType(IMaintainableObject buildFrom)
        {
            var builtObj = new OrganisationSchemeType();

            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.Date;
            }

            if (buildFrom.EndDate != null)
            {
                builtObj.validTo = buildFrom.EndDate.Date;
            }

            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;
            }

            return builtObj;
        }
 /// <summary>
 /// Writes the <paramref name="maintainableObject"/> out to the output location in the format specified by the implementation
 /// </summary>
 /// <param name="maintainableObject">
 /// The maintainableObject.
 /// </param>
 public void WriteStructure(IMaintainableObject maintainableObject)
 {
     IMutableObjects mutableObjects = new MutableObjectsImpl();
     mutableObjects.AddIdentifiable(maintainableObject.MutableInstance);
     IRegistryInfo registry = new RegistryInfo();
     registry.QueryStructureResponse = new QueryStructureResponseInfo { Structure = mutableObjects };
     this.WriteRegistryInterface(registry);
 }
 /// <summary>
 /// Writes the contents of the bean out to the output stream in the version specified.
 /// </summary>
 /// <param name="sdmxObject">
 /// The sdmxObjects to write to the output stream
 /// </param>
 /// <param name="header">
 /// can be null, if null will create a default header
 /// </param>
 /// <param name="outputFormat">
 /// the output format of the message (required)
 /// </param>
 /// <param name="outputStream">
 /// the stream to write to, the stream is NOT closed on completion, this can be null if not required (i.e the outputFormat may contain a writer)
 /// </param>
 public void WriteStructure(IMaintainableObject sdmxObject, IHeader header, IStructureFormat outputFormat, Stream outputStream)
 {
     _log.Debug("Write Structure '" + sdmxObject + "' as " + outputFormat);
     GetStructureWritingEngine(outputFormat, outputStream).WriteStructure(sdmxObject);
 }
示例#31
0
        /// <summary>
        /// Saves the maintainable
        /// </summary>
        /// <param name="maintainable">
        /// The <see cref="IMaintainableObject"/>
        /// </param>
        public void SaveStructure(IMaintainableObject maintainable)
        {
            ISdmxObjects objects = new SdmxObjectsImpl(maintainable);

            this.SaveStructures(objects);
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="MeasureListCore"/> class.
        /// </summary>
        /// <param name="primaryMeasure">
        /// The primary measure. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        public MeasureListCore(PrimaryMeasureType primaryMeasure, IMaintainableObject parent)
            : base(
                MeasureList.FixedId, 
                SdmxStructureType.GetFromEnum(SdmxStructureEnumType.MeasureDescriptor), 
                parent)
        {
            this.primaryMeasure = new PrimaryMeasureCore(primaryMeasure, this);
        }
示例#33
0
 /// <summary>
 /// Writes the <paramref name="maintainableObject"/> out to the output location in the format specified by the implementation
 /// </summary>
 /// <param name="maintainableObject">
 /// The maintainableObject.
 /// </param>
 public void WriteStructure(IMaintainableObject maintainableObject)
 {
     IMutableObjects mutableObjects = new MutableObjectsImpl();
     mutableObjects.AddIdentifiable(maintainableObject.MutableInstance);
     this.WriteStructure(mutableObjects, null);
 }
 /// <summary>
 /// Gets the reference from the specified <paramref name="dataStructureObject"/>
 /// </summary>
 /// <param name="dataStructureObject">
 /// The maintainable reference
 /// </param>
 /// <returns>
 /// The <see cref="string"/>.
 /// </returns>
 protected static string GetRef(IMaintainableObject dataStructureObject)
 {
     // TODO this also used in StartDataSet 
     return string.Format(
         CultureInfo.InvariantCulture, 
         "{0}_{1}_{2}", 
         dataStructureObject.AgencyId, 
         dataStructureObject.Id, 
         dataStructureObject.Version.Replace('.', '_'));
 }
        private static ISet<ICategorisationObject> GetCategorisations(
          IMaintainableObject maintainable, IEnumerable<ICategorisationObject> categorisations)
        {
            ISet<ICategorisationObject> returnSet = new HashSet<ICategorisationObject>();
            if (maintainable.IsExternalReference.IsTrue)
            {
                return returnSet;
            }

            /* foreach */
            foreach (ICategorisationObject cat in categorisations)
            {
                if (cat.IsExternalReference.IsTrue)
                {
                    continue;
                }

                if (cat.StructureReference.TargetReference.EnumType == maintainable.StructureType.EnumType)
                {
                    if (MaintainableUtil<IMaintainableObject>.Match(maintainable, cat.StructureReference))
                    {
                        returnSet.Add(cat);
                    }
                }
            }

            return returnSet;
        }
		private bool IsMatch(IProvisionAgreementObject provision,
				IMaintainableObject bean) {
			/* foreach */
			foreach (ICrossReference currentRef  in  provision.CrossReferences) {
				if (currentRef.IsMatch(bean)) {
					return true;
				}
			}
			return false;
		}
示例#37
0
 /// <summary>
 /// Insert the specified <paramref name="artefact"/> to MAPPING STORE
 /// </summary>
 /// <param name="state">
 /// The Mapping Store connection and transaction state
 /// </param>
 /// <param name="artefact">
 /// The artefact.
 /// </param>
 /// <returns>
 /// The <see cref="ArtefactImportStatus"/>.
 /// </returns>
 protected abstract ArtefactImportStatus InsertArtefact(DbTransactionState state, IMaintainableObject artefact);