/** * This writes all singletons in entity data model as collection of "metadata:singleton". * * @param writer which writes to stream. * @throws XMLStreamException in case of any xml errors * @throws ODataRenderException if entity container is null. */ private void writeSingleton(XMLStreamWriter writer) throws XMLStreamException, ODataRenderException { List<Singleton> singletons = getEntityContainer().getSingletons(); LOG.debug("Number of singletons to be written in service document are {}", singletons.size()); for (Singleton singleton : singletons) { writeElement(writer, METADATA, SERVICE_SINGLETON, ODATA_METADATA_NS, singleton.getName(), singleton.getName()); } }
/** * This writes all singletons in entity data model as collection of "metadata:singleton". * * @param writer which writes to stream. * @throws XMLStreamException in case of any xml errors * @throws ODataRenderException if entity container is null. */ private void writeSingleton(XMLStreamWriter writer) throws XMLStreamException, ODataRenderException { List<Singleton> singletons = getEntityContainer().getSingletons(); LOG.debug("Number of singletons to be written in service document are {}", singletons.size()); for (Singleton singleton : singletons) { writeElement(writer, METADATA, SERVICE_SINGLETON, ODATA_METADATA_NS, singleton.getName(), singleton.getName()); } }
/** * Write the 'Entity Container'. * <p> * Note: The entity container is written only for the 'Schema' which namespace matches the name of the entity * container itself. This entity container contains the types for all the schemas contained by the Entity Data * Model though. * </p> * * @param entityContainer The 'Entity Container' to write. * @throws XMLStreamException */ private void writeEntityContainer(EntityContainer entityContainer) throws XMLStreamException { xmlWriter.writeStartElement(ENTITY_CONTAINER); xmlWriter.writeAttribute(NAME, entityContainer.getName()); for (EntitySet entitySet : entityContainer.getEntitySets()) { entitySetWriter.write(entitySet); } for (Singleton singleton : entityContainer.getSingletons()) { singletonWriter.write(singleton); } xmlWriter.writeEndElement(); }
/** * Write the 'Entity Container'. * <p> * Note: The entity container is written only for the 'Schema' which namespace matches the name of the entity * container itself. This entity container contains the types for all the schemas contained by the Entity Data * Model though. * </p> * * @param entityContainer The 'Entity Container' to write. * @throws XMLStreamException */ private void writeEntityContainer(EntityContainer entityContainer) throws XMLStreamException { xmlWriter.writeStartElement(ENTITY_CONTAINER); xmlWriter.writeAttribute(NAME, entityContainer.getName()); for (EntitySet entitySet : entityContainer.getEntitySets()) { entitySetWriter.write(entitySet); } for (Singleton singleton : entityContainer.getSingletons()) { singletonWriter.write(singleton); } 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; }
List<Singleton> singletons = entityDataModel.getEntityContainer().getSingletons(); for (Singleton singleton : singletons) { writeObject(jsonGenerator, singleton);
List<Singleton> singletons = entityDataModel.getEntityContainer().getSingletons(); for (Singleton singleton : singletons) { writeObject(jsonGenerator, singleton);
/** * 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); }
for (Singleton singleton : entityDataModel.getEntityContainer().getSingletons()) { if (singleton.getTypeName().equals(entityType.getFullyQualifiedName())) { entityName = singleton.getName();
for (Singleton singleton : entityDataModel.getEntityContainer().getSingletons()) { if (singleton.getTypeName().equals(entityType.getFullyQualifiedName())) { entityName = singleton.getName();