in SdmxStructureParser/src/main/java/org/sdmxsource/sdmx/structureparser/builder/sdmxbeans/impl/SdmxBeansV2RegDocBuilder.java [97:266]
public SdmxBeans build(StructureType structures, SdmxBeans beans) throws SdmxException {
Set<String> urns = new HashSet<String>();
//CATEGORY SCHEMES
processCategorySchemes(structures.getCategorySchemes(), beans);
if (structures.getCodeLists() != null && structures.getCodeLists().getCodeListList() != null) {
for (CodeListType currentType : structures.getCodeLists().getCodeListList()) {
try {
addIfNotDuplicateURN(beans, urns, new CodelistBeanImpl(currentType));
} catch (Throwable th) {
throw new MaintainableBeanException(th, SDMX_STRUCTURE_TYPE.CODE_LIST, currentType.getAgencyID(), currentType.getId(), currentType.getVersion());
}
}
}
if (structures.getConcepts() != null && structures.getConcepts().getConceptSchemeList() != null) {
for (ConceptSchemeType currentType : structures.getConcepts().getConceptSchemeList()) {
try {
addIfNotDuplicateURN(beans, urns, new ConceptSchemeBeanImpl(currentType));
} catch (Throwable th) {
throw new MaintainableBeanException(th, SDMX_STRUCTURE_TYPE.CONCEPT_SCHEME, currentType.getAgencyID(), currentType.getId(), currentType.getVersion());
}
}
}
//CONCEPTS
Map<String, List<ConceptType>> conceptAgencyMap = new HashMap<String, List<ConceptType>>();
if (structures.getConcepts() != null && structures.getConcepts().getConceptList() != null) {
for (ConceptType currentType : structures.getConcepts().getConceptList()) {
List<ConceptType> concepts;
if (conceptAgencyMap.containsKey(currentType.getAgencyID())) {
concepts = conceptAgencyMap.get(currentType.getAgencyID());
} else {
concepts = new ArrayList<ConceptType>();
conceptAgencyMap.put(currentType.getAgencyID(), concepts);
}
concepts.add(currentType);
}
}
for (String currentConceptAgency : conceptAgencyMap.keySet()) {
try {
addIfNotDuplicateURN(beans, urns, new ConceptSchemeBeanImpl(conceptAgencyMap.get(currentConceptAgency), currentConceptAgency));
} catch (Throwable th) {
throw new MaintainableBeanException(th, SDMX_STRUCTURE_TYPE.CONCEPT_SCHEME, currentConceptAgency, ConceptSchemeBean.DEFAULT_SCHEME_ID, MaintainableBean.DEFAULT_VERSION);
}
}
//DATAFLOWS
processDataflows(structures.getDataflows(), beans);
if (structures.getHierarchicalCodelists() != null && structures.getHierarchicalCodelists().getHierarchicalCodelistList() != null) {
for (HierarchicalCodelistType currentType : structures.getHierarchicalCodelists().getHierarchicalCodelistList()) {
try {
addIfNotDuplicateURN(beans, urns, new HierarchicalCodelistBeanImpl(currentType));
} catch (Throwable th) {
throw new MaintainableBeanException(th, SDMX_STRUCTURE_TYPE.HIERARCHICAL_CODELIST, currentType.getAgencyID(), currentType.getId(), currentType.getVersion());
}
}
}
if (structures.getKeyFamilies() != null && structures.getKeyFamilies().getKeyFamilyList() != null) {
for (KeyFamilyType currentType : structures.getKeyFamilies().getKeyFamilyList()) {
try {
//if(currentType.getComponents() != null && ObjectUtil.validCollection(currentType.getComponents().getCrossSectionalMeasureList())) {
if (isXsDataStructure(currentType)) {
//HACK HORRIBLE HACK
CrossSectionalDataStructureBean xsdBean = new CrossSectionalDataStructureBeanImpl(currentType);
if (!xsdBean.getDimensions(SDMX_STRUCTURE_TYPE.MEASURE_DIMENSION).isEmpty()) {
CrossSectionalDataStructureMutableBean mutable = xsdBean.getMutableInstance();
CrossSectionalMeasureMutableBean xsMutable = mutable.getCrossSectionalMeasures().get(0);
StructureReferenceBean sRef = xsMutable.getConceptRef();
Map<String, StructureReferenceBean> mapping = new HashMap<String, StructureReferenceBean>();
StructureReferenceBean cocneptSchemeRef = new StructureReferenceBeanImpl(sRef.getMaintainableReference(), SDMX_STRUCTURE_TYPE.CONCEPT_SCHEME);
for (DimensionMutableBean dim : mutable.getDimensions()) {
if (dim.isMeasureDimension()) {
mapping.put(dim.getId(), dim.getRepresentation().getRepresentation());
dim.getRepresentation().setRepresentation(cocneptSchemeRef);
}
}
mutable.setMeasureDimensionCodelistMapping(mapping);
xsdBean = mutable.getImmutableInstance();
}
addIfNotDuplicateURN(beans, urns, xsdBean);
} else {
addIfNotDuplicateURN(beans, urns, new DataStructureBeanImpl(currentType));
}
} catch (Throwable th) {
throw new MaintainableBeanException(th, SDMX_STRUCTURE_TYPE.DSD, currentType.getAgencyID(), currentType.getId(), currentType.getVersion());
}
}
}
//METADATA FLOWS
processMetadataFlows(structures.getMetadataflows(), beans);
//METADATA STRUCTURES
if (structures.getMetadataStructureDefinitions() != null && structures.getMetadataStructureDefinitions().getMetadataStructureDefinitionList() != null) {
for (MetadataStructureDefinitionType currentType : structures.getMetadataStructureDefinitions().getMetadataStructureDefinitionList()) {
try {
addIfNotDuplicateURN(beans, urns, new MetadataStructureDefinitionBeanImpl(currentType));
} catch (Throwable th) {
throw new MaintainableBeanException(th, SDMX_STRUCTURE_TYPE.MSD, currentType.getAgencyID(), currentType.getId(), currentType.getVersion());
}
}
//throw new SdmxNotImplementedException(ExceptionCode.UNSUPPORTED, "Metadata Structure Definition at SMDX v2.0 - please use SDMX v2.1");
}
//ORGANISATION SCHEMES
if (structures.getOrganisationSchemes() != null) {
for (OrganisationSchemeType orgSchemeType : structures.getOrganisationSchemes().getOrganisationSchemeList()) {
if (ObjectUtil.validCollection(orgSchemeType.getAgenciesList())) {
try {
addIfNotDuplicateURN(beans, urns, new AgencySchemeBeanImpl(orgSchemeType));
} catch (Throwable th) {
throw new MaintainableBeanException(th, SDMX_STRUCTURE_TYPE.AGENCY_SCHEME, orgSchemeType.getAgencyID(), orgSchemeType.getId(), orgSchemeType.getVersion());
}
}
if (ObjectUtil.validCollection(orgSchemeType.getDataConsumersList())) {
try {
addIfNotDuplicateURN(beans, urns, new DataConsumerSchemeBeanImpl(orgSchemeType));
} catch (Throwable th) {
throw new MaintainableBeanException(th, SDMX_STRUCTURE_TYPE.DATA_CONSUMER_SCHEME, orgSchemeType.getAgencyID(), orgSchemeType.getId(), orgSchemeType.getVersion());
}
}
if (ObjectUtil.validCollection(orgSchemeType.getDataProvidersList())) {
try {
addIfNotDuplicateURN(beans, urns, new DataProviderSchemeBeanImpl(orgSchemeType));
} catch (Throwable th) {
throw new MaintainableBeanException(th, SDMX_STRUCTURE_TYPE.DATA_PROVIDER_SCHEME, orgSchemeType.getAgencyID(), orgSchemeType.getId(), orgSchemeType.getVersion());
}
}
// If the organisation scheme contains no elements, then this is an error
if (orgSchemeType.getAgenciesList().isEmpty() &&
orgSchemeType.getDataConsumersList().isEmpty() &&
orgSchemeType.getDataProvidersList().isEmpty()) {
throw new SdmxSemmanticException(ExceptionCode.STRUCTURE_INVALID_ORGANISATION_SCHEME_NO_CONTENT, orgSchemeType.getAgencyID(), orgSchemeType.getId());
}
}
}
if (structures.getProcesses() != null && structures.getProcesses().getProcessList() != null) {
for (ProcessType currentType : structures.getProcesses().getProcessList()) {
try {
addIfNotDuplicateURN(beans, urns, new ProcessBeanImpl(currentType));
} catch (Throwable th) {
throw new MaintainableBeanException(th, SDMX_STRUCTURE_TYPE.PROCESS, currentType.getAgencyID(), currentType.getId(), currentType.getVersion());
}
}
}
if (structures.getReportingTaxonomies() != null && structures.getReportingTaxonomies().getReportingTaxonomyList() != null) {
for (ReportingTaxonomyType currentType : structures.getReportingTaxonomies().getReportingTaxonomyList()) {
try {
addIfNotDuplicateURN(beans, urns, new ReportingTaxonomyBeanImpl(currentType));
} catch (Throwable th) {
throw new MaintainableBeanException(th, SDMX_STRUCTURE_TYPE.REPORTING_TAXONOMY, currentType.getAgencyID(), currentType.getId(), currentType.getVersion());
}
}
}
if (structures.getStructureSets() != null && structures.getStructureSets().getStructureSetList() != null) {
for (StructureSetType currentType : structures.getStructureSets().getStructureSetList()) {
try {
addIfNotDuplicateURN(beans, urns, new StructureSetBeanImpl(currentType));
} catch (Throwable th) {
throw new MaintainableBeanException(th, SDMX_STRUCTURE_TYPE.STRUCTURE_SET, currentType.getAgencyID(), currentType.getId(), currentType.getVersion());
}
}
}
return beans;
}