/** * Write a {@code <Singleton>} element for a given {@code Singleton}. * * @param singleton The given {@code Singleton}. It can not be {@code null}. * @throws javax.xml.stream.XMLStreamException if unable to write to stream */ public void write(Singleton singleton) throws XMLStreamException { LOG.debug("Writing singleton {} of type {}", singleton.getName(), singleton.getTypeName()); xmlWriter.writeStartElement(SINGLETON); xmlWriter.writeAttribute(NAME, singleton.getName()); xmlWriter.writeAttribute(TYPE, singleton.getTypeName()); for (NavigationPropertyBinding navPropertyBinding : singleton.getNavigationPropertyBindings()) { xmlWriter.writeStartElement(NAVIGATION_PROPERTY_BINDING); xmlWriter.writeAttribute(PATH, navPropertyBinding.getPath()); xmlWriter.writeAttribute(TARGET, navPropertyBinding.getTarget()); xmlWriter.writeEndElement(); } xmlWriter.writeEndElement(); } }
/** * Write a {@code <Singleton>} element for a given {@code Singleton}. * * @param singleton The given {@code Singleton}. It can not be {@code null}. * @throws javax.xml.stream.XMLStreamException if unable to write to stream */ public void write(Singleton singleton) throws XMLStreamException { LOG.debug("Writing singleton {} of type {}", singleton.getName(), singleton.getTypeName()); xmlWriter.writeStartElement(SINGLETON); xmlWriter.writeAttribute(NAME, singleton.getName()); xmlWriter.writeAttribute(TYPE, singleton.getTypeName()); for (NavigationPropertyBinding navPropertyBinding : singleton.getNavigationPropertyBindings()) { xmlWriter.writeStartElement(NAVIGATION_PROPERTY_BINDING); xmlWriter.writeAttribute(PATH, navPropertyBinding.getPath()); xmlWriter.writeAttribute(TARGET, navPropertyBinding.getTarget()); xmlWriter.writeEndElement(); } xmlWriter.writeEndElement(); } }
/** * Check if the given entity is a Singleton entity. * * @param entityDataModel The Entity Data Model. * @param entity The given entity. * @return true if singleton, false if not * @throws ODataEdmException if unable to determine if entity is singleton */ public static boolean isSingletonEntity(EntityDataModel entityDataModel, Object entity) throws ODataEdmException { // Get the entity type EntityType entityType = getAndCheckEntityType(entityDataModel, entity.getClass()); boolean isSingletonEntity = false; for (Singleton singleton : entityDataModel.getEntityContainer().getSingletons()) { if (singleton.getTypeName().equals(entityType.getFullyQualifiedName())) { isSingletonEntity = true; break; } } return isSingletonEntity; }
/** * Check if the given entity is a Singleton entity. * * @param entityDataModel The Entity Data Model. * @param entity The given entity. * @return true if singleton, false if not * @throws ODataEdmException if unable to determine if entity is singleton */ public static boolean isSingletonEntity(EntityDataModel entityDataModel, Object entity) throws ODataEdmException { // Get the entity type EntityType entityType = getAndCheckEntityType(entityDataModel, entity.getClass()); boolean isSingletonEntity = false; for (Singleton singleton : entityDataModel.getEntityContainer().getSingletons()) { if (singleton.getTypeName().equals(entityType.getFullyQualifiedName())) { isSingletonEntity = true; break; } } return isSingletonEntity; }
/** * Get the Entity Name for a given Entity Type name through the Entity Data Model. * This looks for entity in both EntitySets and Singletons in the container * * @param entityDataModel The Entity Data Model. * @param entityTypeName The Entity Type name. * @return The Entity name * @throws ODataEdmException if unable to find entity name in entity data model */ public static String getEntityNameByEntityTypeName(EntityDataModel entityDataModel, String entityTypeName) throws ODataEdmException { for (EntitySet entitySet : entityDataModel.getEntityContainer().getEntitySets()) { if (entitySet.getTypeName().equals(entityTypeName)) { return entitySet.getName(); } } //If not found in EntitySet, try to find in Singletons for (Singleton singleton : entityDataModel.getEntityContainer().getSingletons()) { if (singleton.getTypeName().equals(entityTypeName)) { return singleton.getName(); } } throw new ODataSystemException("Entity name not found in the entity data model for type: " + entityTypeName); }
/** * Get the Entity Name for a given Entity Type name through the Entity Data Model. * This looks for entity in both EntitySets and Singletons in the container * * @param entityDataModel The Entity Data Model. * @param entityTypeName The Entity Type name. * @return The Entity name * @throws ODataEdmException if unable to find entity name in entity data model */ public static String getEntityNameByEntityTypeName(EntityDataModel entityDataModel, String entityTypeName) throws ODataEdmException { for (EntitySet entitySet : entityDataModel.getEntityContainer().getEntitySets()) { if (entitySet.getTypeName().equals(entityTypeName)) { return entitySet.getName(); } } //If not found in EntitySet, try to find in Singletons for (Singleton singleton : entityDataModel.getEntityContainer().getSingletons()) { if (singleton.getTypeName().equals(entityTypeName)) { return singleton.getName(); } } throw new ODataSystemException("Entity name not found in the entity data model for type: " + entityTypeName); }
private String getEntityTypeName(QueryOperation operation, EntityDataModel entityDataModel) { EntitySet entitySet = entityDataModel.getEntityContainer().getEntitySet(operation.entitySetName()); // If the supplied entity is an EntitySet, return entity set type. Else check for Singleton if (entitySet != null) { return entitySet.getTypeName(); } else { Singleton singleton = entityDataModel.getEntityContainer().getSingleton(operation.entitySetName()); if (singleton != null) { return singleton.getTypeName(); } } return null; } }
private String getEntityTypeName(QueryOperation operation, EntityDataModel entityDataModel) { EntitySet entitySet = entityDataModel.getEntityContainer().getEntitySet(operation.entitySetName()); // If the supplied entity is an EntitySet, return entity set type. Else check for Singleton if (entitySet != null) { return entitySet.getTypeName(); } else { Singleton singleton = entityDataModel.getEntityContainer().getSingleton(operation.entitySetName()); if (singleton != null) { return singleton.getTypeName(); } } return null; } }
if (singleton.getTypeName().equals(entityType.getFullyQualifiedName())) { entityName = singleton.getName(); break;
if (singleton.getTypeName().equals(entityType.getFullyQualifiedName())) { entityName = singleton.getName(); break;