public SubscriptionBeanImpl()

in SdmxBeans/src/main/java/org/sdmxsource/sdmx/sdmxbeans/model/beans/registry/SubscriptionBeanImpl.java [123:228]


    public SubscriptionBeanImpl(SubscriptionType subscription) {
        super(subscription, SDMX_STRUCTURE_TYPE.SUBSCRIPTION,
                null,
                null,
                DEFAULT_VERSION,
                TERTIARY_BOOL.UNSET,
                getSubAgencyId(subscription),
                getSubId(subscription), null, null, null, null, null);
        LOG.debug("Building Subscription from 2.1 SDMX");
        if (subscription.getOrganisation() != null) {
            this.owner = RefUtil.createReference(this, subscription.getOrganisation());
        }
        if (subscription.getValidityPeriod() != null) {
            if (subscription.getValidityPeriod().getStartDate() != null) {
                this.startDate = new SdmxDateImpl(subscription.getValidityPeriod().getStartDate().getTime(), TIME_FORMAT.DATE_TIME);
            }
            if (subscription.getValidityPeriod().getEndDate() != null) {
                this.endDate = new SdmxDateImpl(subscription.getValidityPeriod().getEndDate().getTime(), TIME_FORMAT.DATE_TIME);
            }
        }
        if (subscription.getNotificationHTTPList() != null) {
            for (NotificationURLType not : subscription.getNotificationHTTPList()) {
                this.HTTPPostTo.add(not.getStringValue());
            }
        }
        if (subscription.getNotificationMailToList() != null) {
            for (NotificationURLType not : subscription.getNotificationMailToList()) {
                this.mailTo.add(not.getStringValue());
            }
        }
        if (subscription.getEventSelector() != null) {
            EventSelectorType eventSelector = subscription.getEventSelector();
            for (StructuralRepositoryEventsType repositoryEvent : eventSelector.getStructuralRepositoryEventsList()) {
                setSubscriptionType(SUBSCRIPTION_TYPE.STRUCTURE);

                List<String> agencies = repositoryEvent.getAgencyIDList();
                for (String currentAgency : agencies) {
                    //If any of the agencies is a wildcard, then make the list null as it is not important
                    if (currentAgency.equals(WILDCARD)) {
                        agencies = null;
                        break;
                    }
                }
                if (repositoryEvent.getAllEvents() != null) {
                    if (!ObjectUtil.validCollection(agencies)) {
                        references.add(new StructureReferenceBeanImpl(null, null, null, SDMX_STRUCTURE_TYPE.ANY));
                    } else {
                        for (String currentAgency : agencies) {
                            references.add(new StructureReferenceBeanImpl(currentAgency, null, null, SDMX_STRUCTURE_TYPE.ANY));
                        }
                    }
                    //No need to process any more information, this is a subscription for everything
                    break;
                }
                addEventSubscriptions(repositoryEvent.getAgencySchemeList(), agencies, SDMX_STRUCTURE_TYPE.AGENCY_SCHEME);
                addEventSubscriptions(repositoryEvent.getAttachmentConstraintList(), agencies, SDMX_STRUCTURE_TYPE.ATTACHMENT_CONSTRAINT);
                //addEventSubscriptions(repositoryEvent.getCategorisationList(), agencies, SDMX_STRUCTURE_TYPE.C);
                addEventSubscriptions(repositoryEvent.getCategorySchemeList(), agencies, SDMX_STRUCTURE_TYPE.CATEGORY_SCHEME);
                addEventSubscriptions(repositoryEvent.getCodelistList(), agencies, SDMX_STRUCTURE_TYPE.CODE_LIST);
                addEventSubscriptions(repositoryEvent.getConceptSchemeList(), agencies, SDMX_STRUCTURE_TYPE.CONCEPT_SCHEME);
                addEventSubscriptions(repositoryEvent.getContentConstraintList(), agencies, SDMX_STRUCTURE_TYPE.CONTENT_CONSTRAINT);
                addEventSubscriptions(repositoryEvent.getDataProviderSchemeList(), agencies, SDMX_STRUCTURE_TYPE.DATA_PROVIDER_SCHEME);
                addEventSubscriptions(repositoryEvent.getDataConsmerSchemeList(), agencies, SDMX_STRUCTURE_TYPE.DATA_CONSUMER_SCHEME);
                addEventSubscriptions(repositoryEvent.getDataflowList(), agencies, SDMX_STRUCTURE_TYPE.DATAFLOW);
                addEventSubscriptions(repositoryEvent.getHierarchicalCodelistList(), agencies, SDMX_STRUCTURE_TYPE.HIERARCHICAL_CODELIST);
                addEventSubscriptions(repositoryEvent.getKeyFamilyList(), agencies, SDMX_STRUCTURE_TYPE.DSD);
                addEventSubscriptions(repositoryEvent.getMetadataflowList(), agencies, SDMX_STRUCTURE_TYPE.METADATA_FLOW);
                addEventSubscriptions(repositoryEvent.getMetadataStructureDefinitionList(), agencies, SDMX_STRUCTURE_TYPE.MSD);
                addEventSubscriptions(repositoryEvent.getOrganisationUnitSchemeList(), agencies, SDMX_STRUCTURE_TYPE.ORGANISATION_UNIT_SCHEME);
                addEventSubscriptions(repositoryEvent.getProcessList(), agencies, SDMX_STRUCTURE_TYPE.PROCESS);
                addEventSubscriptions(repositoryEvent.getProvisionAgreementList(), agencies, SDMX_STRUCTURE_TYPE.PROVISION_AGREEMENT);
                addEventSubscriptions(repositoryEvent.getReportingTaxonomyList(), agencies, SDMX_STRUCTURE_TYPE.REPORTING_TAXONOMY);
                addEventSubscriptions(repositoryEvent.getStructureSetList(), agencies, SDMX_STRUCTURE_TYPE.STRUCTURE_SET);
            }
            for (DataRegistrationEventsType repositoryEvent : eventSelector.getDataRegistrationEventsList()) {
                setSubscriptionType(SUBSCRIPTION_TYPE.DATA_REGISTRATION);
                if (repositoryEvent.getAllEvents() != null) {
                    references.add(new StructureReferenceBeanImpl(SDMX_STRUCTURE_TYPE.ANY));
                    //No need to process any more information, this is a subscription for everything
                    break;
                }
                addEventSubscriptions(repositoryEvent.getDataflowReferenceList(), SDMX_STRUCTURE_TYPE.DATAFLOW);
                addEventSubscriptions(repositoryEvent.getKeyFamilyReferenceList(), SDMX_STRUCTURE_TYPE.DSD);
                addEventSubscriptions(repositoryEvent.getProvisionAgreementList());
                addEventSubscriptions(repositoryEvent.getCategoryList());
                addEventSubscriptions(repositoryEvent.getDataProviderList());
            }
            for (MetadataRegistrationEventsType repositoryEvent : eventSelector.getMetadataRegistrationEventsList()) {
                setSubscriptionType(SUBSCRIPTION_TYPE.METADATA_REGISTRATION);
                if (repositoryEvent.getAllEvents() != null) {
                    references.add(new StructureReferenceBeanImpl(SDMX_STRUCTURE_TYPE.ANY));
                    //No need to process any more information, this is a subscription for everything
                    break;
                }
                addEventSubscriptions(repositoryEvent.getMetadataflowReferenceList(), SDMX_STRUCTURE_TYPE.METADATA_FLOW);
                addEventSubscriptions(repositoryEvent.getMetadataStructureDefinitionReferenceList(), SDMX_STRUCTURE_TYPE.MSD);
                addEventSubscriptions(repositoryEvent.getProvisionAgreementList());
                addEventSubscriptions(repositoryEvent.getCategoryList());
                addEventSubscriptions(repositoryEvent.getDataProviderList());
            }
        }
        validate();
        if (LOG.isDebugEnabled()) {
            LOG.debug("subscription Built " + this.getUrn());
        }
    }