public static String getEntityName ( EntityDataModel entityDataModel , Object entity ) throws ODataEdmException { // Get the entity type EntityType entityType = getAndCheckEntityType ( entityDataModel , entity . getClass ( ) ) ; // Check if the entity belongs to an Entity Set String entityName = null ; for ( EntitySet entitySet : entityDataModel . getEntityContainer ( ) . getEntitySets ( ) ) { if ( entitySet . getTypeName ( ) . equals ( entityType . getFullyQualifiedName ( ) ) ) { entityName = entitySet . getName ( ) ; break ; } } if ( entityName == null ) { for ( Singleton singleton : entityDataModel . getEntityContainer ( ) . getSingletons ( ) ) { if ( singleton . getTypeName ( ) . equals ( entityType . getFullyQualifiedName ( ) ) ) { entityName = singleton . getName ( ) ; break ; } } if ( entityName == null ) { throw new ODataSystemException ( "Entity not found in the entity data model for type: " + entityType . getFullyQualifiedName ( ) ) ; } } return entityName ; }
Get the entity name in the entity data model for the given entity .