/** * Write an {@code <EntitySet>} element for a given {@code EntitySet}. * * @param entitySet The given {@code EntitySet}. It can not be {@code null}. * @throws javax.xml.stream.XMLStreamException If unable to write to stream */ public void write(EntitySet entitySet) throws XMLStreamException { LOG.debug("Writing entity set {} of type {}", entitySet.getName(), entitySet.getTypeName()); xmlWriter.writeStartElement(ENTITY_SET); xmlWriter.writeAttribute(NAME, entitySet.getName()); xmlWriter.writeAttribute(ENTITY_TYPE, entitySet.getTypeName()); for (NavigationPropertyBinding navPropertyBinding : entitySet.getNavigationPropertyBindings()) { xmlWriter.writeStartElement(NAVIGATION_PROPERTY_BINDING); xmlWriter.writeAttribute(PATH, navPropertyBinding.getPath()); xmlWriter.writeAttribute(TARGET, navPropertyBinding.getTarget()); xmlWriter.writeEndElement(); } xmlWriter.writeEndElement(); } }
/** * Write an {@code <EntitySet>} element for a given {@code EntitySet}. * * @param entitySet The given {@code EntitySet}. It can not be {@code null}. * @throws javax.xml.stream.XMLStreamException If unable to write to stream */ public void write(EntitySet entitySet) throws XMLStreamException { LOG.debug("Writing entity set {} of type {}", entitySet.getName(), entitySet.getTypeName()); xmlWriter.writeStartElement(ENTITY_SET); xmlWriter.writeAttribute(NAME, entitySet.getName()); xmlWriter.writeAttribute(ENTITY_TYPE, entitySet.getTypeName()); for (NavigationPropertyBinding navPropertyBinding : entitySet.getNavigationPropertyBindings()) { xmlWriter.writeStartElement(NAVIGATION_PROPERTY_BINDING); xmlWriter.writeAttribute(PATH, navPropertyBinding.getPath()); xmlWriter.writeAttribute(TARGET, navPropertyBinding.getTarget()); xmlWriter.writeEndElement(); } xmlWriter.writeEndElement(); } }
/** * This methods write @odata.type of complex type. * If complex type has root-level, @odata.type won't be written. * * @param structuredType structuredType */ private void writeODataType(StructuredType structuredType) throws IOException { if (entitySet != null) { String typeName = entitySet.getTypeName(); String type = typeName.substring(typeName.lastIndexOf(".") + 1, typeName.length()); if (!type.equals(structuredType.getName())) { jsonGenerator.writeStringField(TYPE, String.format("#%s.%s", structuredType.getNamespace(), structuredType.getName())); } else { LOG.trace("{} has root level. {} won't be written here", entitySet.getName(), TYPE); } } }
/** * This methods write @odata.type of complex type. * If complex type has root-level, @odata.type won't be written. * * @param structuredType structuredType */ private void writeODataType(StructuredType structuredType) throws IOException { if (entitySet != null) { String typeName = entitySet.getTypeName(); String type = typeName.substring(typeName.lastIndexOf(".") + 1, typeName.length()); if (!type.equals(structuredType.getName())) { jsonGenerator.writeStringField(TYPE, String.format("#%s.%s", structuredType.getNamespace(), structuredType.getName())); } else { LOG.trace("{} has root level. {} won't be written here", entitySet.getName(), TYPE); } } }
/** * Get the Entity Set for a given Entity Type name through the Entity Data Model. * * @param entityDataModel The Entity Data Model. * @param entityTypeName The Entity Type name. * @return The Entity Set. * @throws ODataEdmException if unable to get entity set in entity data model */ public static EntitySet getEntitySetByEntityTypeName(EntityDataModel entityDataModel, String entityTypeName) throws ODataEdmException { for (EntitySet entitySet : entityDataModel.getEntityContainer().getEntitySets()) { if (entitySet.getTypeName().equals(entityTypeName)) { return entitySet; } } throw new ODataSystemException("Entity set not found in the entity data model for type: " + entityTypeName); }
/** * Get the Entity Set for a given Entity Type name through the Entity Data Model. * * @param entityDataModel The Entity Data Model. * @param entityTypeName The Entity Type name. * @return The Entity Set. * @throws ODataEdmException if unable to get entity set in entity data model */ public static EntitySet getEntitySetByEntityTypeName(EntityDataModel entityDataModel, String entityTypeName) throws ODataEdmException { for (EntitySet entitySet : entityDataModel.getEntityContainer().getEntitySets()) { if (entitySet.getTypeName().equals(entityTypeName)) { return entitySet; } } throw new ODataSystemException("Entity set not found in the entity data model for type: " + entityTypeName); }
private EntitySet getEntitySet(Object entity) { String entityTypeName = getEntityType(entity).getFullyQualifiedName(); for (EntitySet eSet : entityDataModel.getEntityContainer().getEntitySets()) { if (eSet.getTypeName().equals(entityTypeName)) { return eSet; } } return null; }
private EntitySet getEntitySet(Object entity) { String entityTypeName = getEntityType(entity).getFullyQualifiedName(); for (EntitySet eSet : entityDataModel.getEntityContainer().getEntitySets()) { if (eSet.getTypeName().equals(entityTypeName)) { return eSet; } } return null; }
/** * 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 (entitySet.getTypeName().equals(entityType.getFullyQualifiedName())) { entityName = entitySet.getName(); break;
if (entitySet.getTypeName().equals(entityType.getFullyQualifiedName())) { entityName = entitySet.getName(); break;