private CsdlComplexType getComplexType(XMLMetadata metadata, String name) throws TranslatorException { if (name.contains(".")) { int idx = name.lastIndexOf('.'); CsdlSchema schema = metadata.getSchema(name.substring(0, idx)); if (schema == null) { throw new TranslatorException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID17021, name)); } return schema.getComplexType(name.substring(idx+1)); } return getDefaultSchema(metadata).getComplexType(name); }
@Override public CsdlComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException { CsdlSchema schema = xmlSchemas.get(complexTypeName.getNamespace()); if (schema != null) { return schema.getComplexType(complexTypeName.getName()); } return null; }
@Override public CsdlComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException { CsdlSchema schema = xmlSchemas.get(complexTypeName.getNamespace()); if (schema != null) { return schema.getComplexType(complexTypeName.getName()); } return null; }
@Override public CsdlComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException { for (final CsdlSchema schema : serviceDocument.getAllSchemas()) { if (schema.getNamespace().equals(complexTypeName.getNamespace()) || schema.getAlias() != null && schema.getAlias().equals(complexTypeName.getNamespace())) { return schema.getComplexType(complexTypeName.getName()); } } return null; }
@Override public CsdlComplexType getComplexType(FullQualifiedName complexTypeName) throws ODataException { /*-- Try to fetch the ComplexType from the Current Schema --*/ List<CsdlSchema> csdlSchemas = xmlMetadata.getSchemas(); CsdlComplexType csdlComplexType = null; for (CsdlSchema csdlSchema : csdlSchemas) { if (csdlSchema.getNamespace().equals(complexTypeName.getNamespace())) { return csdlSchema.getComplexType(complexTypeName.getName()); } } /*--Fallback: Try to fetch the Complex type from the other Schema(s) --*/ String referenceNamespace = complexTypeName.getNamespace(); String serviceName = ServiceRepository.getInstance().getServicebyNamespace(referenceNamespace); if (serviceName == null || "".equals(serviceName)) { /*--- No Service found with the namespace (Alias) asked for ---*/ return null; } CDXEdmProvider referenceProvider = ServiceRepository.getInstance().getEdmxMetadataProvider(serviceName); if (referenceProvider != null) { XMLMetadata refXmlMetadata = referenceProvider.getXMLMetadata(); CsdlSchema refSchema = refXmlMetadata.getSchema(referenceNamespace); csdlComplexType = refSchema.getComplexType(complexTypeName.getName()); } return csdlComplexType; }