private CsdlEnumType getEnumType(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.getEnumType(name.substring(idx+1)); } return getDefaultSchema(metadata).getEnumType(name); }
@Override public CsdlEnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException { CsdlSchema schema = xmlSchemas.get(enumTypeName.getNamespace()); if (schema != null) { return schema.getEnumType(enumTypeName.getName()); } return null; }
@Override public CsdlEnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException { CsdlSchema schema = xmlSchemas.get(enumTypeName.getNamespace()); if (schema != null) { return schema.getEnumType(enumTypeName.getName()); } return null; }
@Override public CsdlEnumType getEnumType(final FullQualifiedName enumTypeNameFQN) throws ODataException { for (final CsdlSchema schema : serviceDocument.getEdmSchemas()) { if (schema.getNamespace().equals(enumTypeNameFQN.getNamespace())) { return schema.getEnumType(enumTypeNameFQN.getName()); } } return null; }
@Override public CsdlEnumType getEnumType(FullQualifiedName enumTypeName) throws ODataException { /*-- Try to fetch the EntityType from the Current Schema --*/ List<CsdlSchema> csdlSchemas = xmlMetadata.getSchemas(); CsdlEnumType csdlEnumType = null; for (CsdlSchema csdlSchema : csdlSchemas) { if (csdlSchema.getNamespace().equals(enumTypeName.getNamespace())) { return csdlSchema.getEnumType(enumTypeName.getName()); } } /*--Fallback: Try to fetch the EntityType from the other Schema(s) --*/ String referenceNamespace = enumTypeName.getNamespace(); /*-- Service Name will be Null of it is a Vocabulary File --*/ 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); csdlEnumType = refSchema.getEnumType(enumTypeName.getName()); } return csdlEnumType; }