Esempio n. 1
0
        protected override void Delete(SimpleActionExecuteEventArgs args)
        {
            //окно с предупреждением уже прошло
            //здесь будет проверка на возможность удаления объекта
            //если элемент нужно снять с регистрации, то это лучше сделать здесь


            int _idTypeDirectory = 0;
            int _idCataloge      = 0;

            IRegistrationObject _regObject = args.CurrentObject as IRegistrationObject;

            if (_regObject != null)
            {
                _idTypeDirectory = _regObject.GetIdTypeDirectory();
                _idCataloge      = _regObject.GetIdCatalog();
            }


            base.Delete(args);

            if (_idTypeDirectory > 0 && _idCataloge > 0)
            {
                if (!DbMethods.UnRegistration(
                        _idTypeDirectory,
                        _idCataloge
                        ))
                {
                    return;
                }
            }
        }
		public virtual IProvisionAgreementObject GetProvision(IRegistrationObject registration) {
			ISet<IProvisionAgreementObject> provisions = GetProvisions(registration
					.ProvisionAgreementRef);
			if (Org.Sdmxsource.Util.ObjectUtil.ValidCollection(provisions)) {
				if (provisions.Count > 1) {
					throw new Exception(
							"Only one provision agreement expected from reference : "
									+ registration.ProvisionAgreementRef);
				}
				return (IProvisionAgreementObject) ILOG.J2CsMapping.Collections.Generics.Collections.ToArray(provisions)[0];
			}
			return null;
		}
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="NotificationEventCore"/> class.
        /// </summary>
        /// <param name="notification">
        /// The notification. 
        /// </param>
        public NotificationEventCore(NotifyRegistryEventType notification)
        {
            this._eventTime = notification.EventTime; //TODO: True param DateUtil
            this._objectUrn = notification.ObjectURN;
            this._subscriptionUrn = notification.SubscriptionURN;
            this._action = (DatasetAction)Enum.Parse(typeof(DatasetAction), notification.EventAction.ToUpperInvariant());
            if (notification.RegistrationEvent != null)
            {
                this._registration = new RegistrationObjectCore(notification.RegistrationEvent.Registration);
            }
            else
            {
                this.objects = new SdmxObjectsImpl();
                StructuresType structures = notification.StructuralEvent.Structures.Content;
                if (structures.Categorisations != null)
                {
                    foreach (CategorisationType type in structures.Categorisations.Categorisation)
                    {
                        this.objects.AddCategorisation(new CategorisationObjectCore(type));
                    }
                }

                if (structures.CategorySchemes != null)
                {
                    foreach (CategorySchemeType type0 in structures.CategorySchemes.CategoryScheme)
                    {
                        this.objects.AddCategoryScheme(new CategorySchemeObjectCore(type0));
                    }
                }

                if (structures.Codelists != null)
                {
                    foreach (CodelistType type1 in structures.Codelists.Codelist)
                    {
                        this.objects.AddCodelist(new CodelistObjectCore(type1));
                    }
                }

                if (structures.Concepts != null)
                {
                    foreach (ConceptSchemeType type2 in structures.Concepts.ConceptScheme)
                    {
                        this.objects.AddConceptScheme(new ConceptSchemeObjectCore(type2));
                    }
                }

                if (structures.Constraints != null)
                {
                    foreach (AttachmentConstraintType type3 in structures.Constraints.AttachmentConstraint)
                    {
                        this.objects.AddAttachmentConstraint(new AttachmentConstraintObjectCore(type3));
                    }

                    foreach (ContentConstraintType type4 in structures.Constraints.ContentConstraint)
                    {
                        this.objects.AddContentConstraintObject(new ContentConstraintObjectCore(type4));
                    }
                }

                if (structures.Dataflows != null)
                {
                    foreach (DataflowType type5 in structures.Dataflows.Dataflow)
                    {
                        this.objects.AddDataflow(new DataflowObjectCore(type5));
                    }
                }

                if (structures.DataStructures != null)
                {
                    foreach (DataStructureType type6 in structures.DataStructures.DataStructure)
                    {
                        this.objects.AddDataStructure(new DataStructureObjectCore(type6));
                    }
                }

                if (structures.HierarchicalCodelists != null)
                {
                    foreach (HierarchicalCodelistType type7 in structures.HierarchicalCodelists.HierarchicalCodelist)
                    {
                        this.objects.AddHierarchicalCodelist(new HierarchicalCodelistObjectCore(type7));
                    }
                }

                if (structures.Metadataflows != null)
                {
                    foreach (MetadataflowType type8 in structures.Metadataflows.Metadataflow)
                    {
                        this.objects.AddMetadataFlow(new MetadataflowObjectCore(type8));
                    }
                }

                if (structures.MetadataStructures != null)
                {
                    foreach (MetadataStructureType type9 in structures.MetadataStructures.MetadataStructure)
                    {
                        this.objects.AddMetadataStructure(new MetadataStructureDefinitionObjectCore(type9));
                    }
                }

                if (structures.OrganisationSchemes != null)
                {
                    foreach (AgencySchemeType type10 in structures.OrganisationSchemes.AgencyScheme)
                    {
                        this.objects.AddAgencyScheme(new AgencySchemeCore(type10));
                    }

                    foreach (DataConsumerSchemeType type11 in structures.OrganisationSchemes.DataConsumerScheme)
                    {
                        this.objects.AddDataConsumerScheme(new DataConsumerSchemeCore(type11));
                    }

                    foreach (DataProviderSchemeType type12 in structures.OrganisationSchemes.DataProviderScheme)
                    {
                        this.objects.AddDataProviderScheme(new DataProviderSchemeCore(type12));
                    }

                    foreach (OrganisationUnitSchemeType type13 in structures.OrganisationSchemes.OrganisationUnitScheme)
                    {
                        this.objects.AddOrganisationUnitScheme(new OrganisationUnitSchemeObjectCore(type13));
                    }
                }

                if (structures.Processes != null)
                {
                    foreach (ProcessType type14 in structures.Processes.Process)
                    {
                        this.objects.AddProcess(new ProcessObjectCore(type14));
                    }
                }

                if (structures.ProvisionAgreements != null)
                {
                    foreach (ProvisionAgreementType type15 in structures.ProvisionAgreements.ProvisionAgreement)
                    {
                        this.objects.AddProvisionAgreement(new ProvisionAgreementObjectCore(type15));
                    }
                }

                if (structures.ReportingTaxonomies != null)
                {
                    foreach (ReportingTaxonomyType type16 in structures.ReportingTaxonomies.ReportingTaxonomy)
                    {
                        this.objects.AddReportingTaxonomy(new ReportingTaxonomyObjectCore(type16));
                    }
                }

                if (structures.StructureSets != null)
                {
                    foreach (StructureSetType type17 in structures.StructureSets.StructureSet)
                    {
                        this.objects.AddStructureSet(new StructureSetObjectCore(type17));
                    }
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SubmitRegistrationResponseImpl"/> class.
 /// </summary>
 /// <param name="registration">
 /// The registration. 
 /// </param>
 /// <param name="errors">
 /// The errors. 
 /// </param>
 public SubmitRegistrationResponseImpl(IRegistrationObject registration, IErrorList errors)
 {
     this._registration = registration;
     this._errors = errors;
 }
        /// <summary>
        /// Build <see cref="RegistrationType"/> from <paramref name="buildFrom"/>.
        /// </summary>
        /// <param name="buildFrom">
        /// The build from.
        /// </param>
        /// <returns>
        /// The <see cref="RegistrationType"/> from <paramref name="buildFrom"/> .
        /// </returns>
        public RegistrationType Build(IRegistrationObject buildFrom)
        {
            var builtObj = new RegistrationType();
            if (buildFrom.LastUpdated != null)
            {
                builtObj.LastUpdated = buildFrom.LastUpdated.Date;
            }

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

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

            if (buildFrom.ProvisionAgreementRef != null)
            {
                ICrossReference provRefBean = buildFrom.ProvisionAgreementRef;
                var provRefType = new ProvisionAgreementRefType();
                builtObj.ProvisionAgreementRef = provRefType;

                if (provRefBean.TargetReference.EnumType == SdmxStructureEnumType.ProvisionAgreement)
                {
                    if (ObjectUtil.ValidString(provRefBean.TargetUrn))
                    {
                        provRefType.URN = provRefBean.TargetUrn;
                    }
                }
            }

            if (buildFrom.DataSource != null)
            {
                IDataSource datasourceBean = buildFrom.DataSource;
                var datasourceType = new DatasourceType();
                builtObj.Datasource = datasourceType;
                if (datasourceBean.SimpleDatasource)
                {
                    datasourceType.SimpleDatasource = datasourceBean.DataUrl;
                }
                else
                {
                    var qdst = new QueryableDatasourceType();
                    datasourceType.QueryableDatasource = qdst;
                    qdst.isRESTDatasource = datasourceBean.RESTDatasource;
                    qdst.isWebServiceDatasource = datasourceBean.WebServiceDatasource;
                    qdst.DataUrl = datasourceBean.DataUrl;
                }
            }

            return builtObj;
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.0 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="NotificationEventCore"/> class.
        /// </summary>
        /// <param name="notification">
        /// The notification. 
        /// </param>
        public NotificationEventCore(
            Org.Sdmx.Resources.SdmxMl.Schemas.V20.registry.NotifyRegistryEventType notification)
        {
            this._eventTime = notification.EventTime;
            this._objectUrn = notification.ObjectURN;
            this._subscriptionUrn = notification.SubscriptionURN;
            this._action = (DatasetAction)Enum.Parse(typeof(DatasetAction), notification.EventAction.ToUpperInvariant());
            if (notification.RegistrationEvent != null)
            {
                this._registration = new RegistrationObjectCore(notification.RegistrationEvent.Registration);
            }
        }
		public RegistrationObjectBaseCore(IRegistrationObject reigstrationbean,
				IProvisionAgreementObjectBase provObject) : base(reigstrationbean) {
			this._prov = provObject;
			this._builtFrom = reigstrationbean;
		}
        /// <summary>
        /// Process the response.
        /// </summary>
        /// <param name="returnType">
        /// The return type.
        /// </param>
        /// <param name="registrationBean">
        /// The registration bean.
        /// </param>
        /// <param name="exception">
        /// The exception.
        /// </param>
        private void ProcessResponse(
            SubmitRegistrationsResponseType returnType, IRegistrationObject registrationBean, Exception exception)
        {
            var registrationStatusType = new RegistrationStatusType();
            returnType.RegistrationStatus.Add(registrationStatusType);
            var statusMessageType = new StatusMessageType();
            registrationStatusType.StatusMessage = statusMessageType;

            this.AddStatus(statusMessageType, exception);
            var registrationType = new RegistrationType();
            registrationStatusType.Registration = registrationType;
            registrationType.id = registrationBean.Id;
            if (registrationBean.DataSource != null)
            {
                IDataSource datasourceBean = registrationBean.DataSource;
                var datasourceType = new DataSourceType();
                registrationType.Datasource = datasourceType;

                if (datasourceBean.SimpleDatasource)
                {
                    Uri simpleDatasourceType = datasourceBean.DataUrl;
                    datasourceType.SimpleDataSource.Add(simpleDatasourceType);
                }
                else
                {
                    var queryableDatasource = new QueryableDataSourceType();
                    datasourceType.QueryableDataSource.Add(queryableDatasource);
                    queryableDatasource.isRESTDatasource = datasourceBean.RESTDatasource;
                    queryableDatasource.isWebServiceDatasource = datasourceBean.WebServiceDatasource;
                    queryableDatasource.DataURL = datasourceBean.DataUrl;
                    if (datasourceBean.WsdlUrl != null)
                    {
                        queryableDatasource.WSDLURL = datasourceBean.WsdlUrl;
                    }

                    if (datasourceBean.WadlUrl != null)
                    {
                        queryableDatasource.WADLURL = datasourceBean.WadlUrl;
                    }
                }
            }

            if (registrationBean.ProvisionAgreementRef != null)
            {
                var refType = new ProvisionAgreementReferenceType();
                registrationType.ProvisionAgreement = refType;
                refType.URN.Add(registrationBean.ProvisionAgreementRef.TargetUrn);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RegistrationInformationImpl"/> class.
 /// </summary>
 /// <param name="action">
 /// The action. 
 /// </param>
 /// <param name="registration">
 /// The registration codelistRef. 
 /// </param>
 public RegistrationInformationImpl(DatasetAction action, IRegistrationObject registration)
 {
     this._action = action;
     this._registration = registration;
 }
        /// <summary>
        /// The process response.
        /// </summary>
        /// <param name="returnType">
        /// The return type.
        /// </param>
        /// <param name="registration">
        /// The registration.
        /// </param>
        /// <param name="exception">
        /// The exception.
        /// </param>
        private void ProcessResponse(
            SubmitRegistrationResponseType returnType, IRegistrationObject registration, Exception exception)
        {
            var registrationStatusType = new RegistrationStatusType();
            returnType.RegistrationStatus.Add(registrationStatusType);
            registrationStatusType.StatusMessage = new StatusMessageType();
            this.AddStatus(registrationStatusType.StatusMessage, exception);
            if (registration.DataSource != null)
            {
                var datasourceType = new DatasourceType();
                registrationStatusType.Datasource = datasourceType;
                this.AddDatasource(registration.DataSource, datasourceType);
            }

            if (registration.ProvisionAgreementRef != null)
            {
                ICrossReference provRef = registration.ProvisionAgreementRef;
                var provRefType = new ProvisionAgreementRefType();
                registrationStatusType.ProvisionAgreementRef = provRefType;
                if (provRef.TargetUrn != null)
                {
                    provRefType.URN = provRef.TargetUrn;
                }
            }
        }
        /// <summary>
        ///   Returns a set of IdentifiableBeans that are directly referenced from this registration
        /// </summary>
        /// <param name="registation"> - the registration to resolve the references for </param>
        /// <param name="structRetrievalManager"> - Used to resolve the structure references. can be null if level = 1 and registration is linked to a provision (as only the provision manager is needed) </param>
        /// <param name="provRetrievalManager"> - Used to resolve the provision references. Can be null if registration is not linked to a provision </param>
        /// <returns> a set of IdentifiableBeans that are directly referenced from this registration </returns>
        public virtual ISet<IIdentifiableObject> ResolveReferences(
            IRegistrationObject registation,
            IProvisionRetrievalManager provRetrievalManager)
        {
            ISet<IIdentifiableObject> returnSet = new HashSet<IIdentifiableObject>();

            if (registation.ProvisionAgreementRef != null)
            {
                if (provRetrievalManager == null)
                {
                    throw new ArgumentException("ProvisionRetrievalManager can not be null");
                }

                IProvisionAgreementObject provision = provRetrievalManager.GetProvision(registation);
                if (provision == null)
                {
                    throw new CrossReferenceException(
                        registation.ProvisionAgreementRef);
                }

                returnSet.Add(provision);
            }

            return returnSet;
        }
        /// <summary>
        /// Returns a set of IdentifiableBeans that are directly referenced from this registration
        /// </summary>
        /// <param name="registation">
        /// - the registration to resolve the references for 
        /// </param>
        /// <param name="structRetrievalManager">
        /// - Used to resolve the structure references. can be null if level = 1 and registration is linked to a provision (as only the provision manager is needed) 
        /// </param>
        /// <param name="provRetrievalManager">
        /// - Used to resolve the provision references. Can be null if registration is not linked to a provision 
        /// </param>
        /// <returns>
        /// a set of IdentifiableBeans that are directly referenced from this registration
        /// </returns>
        public virtual ISet<IIdentifiableObject> ResolveReferences(
            IRegistrationObject registation, 
            ISdmxRetrievalManager structRetrievalManager, 
            IProvisionRetrievalManager provRetrievalManager)
        {
            ISet<IIdentifiableObject> returnSet = new HashSet<IIdentifiableObject>();

            if (registation.ProvisionAgreementRef != null)
            {
                if (provRetrievalManager == null)
                {
                    throw new ArgumentException("ProvisionRetrievalManager can not be null");
                }

                IProvisionAgreementObject provision = provRetrievalManager.GetProvision(registation);
                if (provision == null)
                {
                    throw new ReferenceException(
                        ExceptionCode.ReferenceErrorUnresolvable, 
                        SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ProvisionAgreement).ToString(), 
                        registation.ProvisionAgreementRef);
                }

                returnSet.Add(provision);
            }

            return returnSet;
        }
		public void DeleteRegistration(IRegistrationObject registration) {
			registrations.Remove(registration);
		}