public Builder addSingleton(Singleton singleton) { this.singletonsBuilder.put(singleton.getName(), singleton); return this; }
public Builder addSingleton(Singleton singleton) { this.singletonsBuilder.put(singleton.getName(), singleton); return this; }
/** * Writes the name of the entity * It is a MUST element. * * @param jsonGenerator jsonGenerator * @param entity entity from the container */ private void writeName(JsonGenerator jsonGenerator, Object entity) throws IOException { jsonGenerator.writeFieldName(NAME); if (entity instanceof EntitySet) { jsonGenerator.writeObject(((EntitySet) entity).getName()); } else { jsonGenerator.writeObject(((Singleton) entity).getName()); } }
/** * Writes the name of the entity * It is a MUST element. * * @param jsonGenerator jsonGenerator * @param entity entity from the container */ private void writeName(JsonGenerator jsonGenerator, Object entity) throws IOException { jsonGenerator.writeFieldName(NAME); if (entity instanceof EntitySet) { jsonGenerator.writeObject(((EntitySet) entity).getName()); } else { jsonGenerator.writeObject(((Singleton) entity).getName()); } }
/** * Writes the url of the entity * It is a MUST element. * * @param jsonGenerator jsonGenerator * @param entity entity from the container */ private void writeURL(JsonGenerator jsonGenerator, Object entity) throws IOException { // It is exactly the same as the 'name' property. jsonGenerator.writeFieldName(URL); if (entity instanceof EntitySet) { jsonGenerator.writeObject(((EntitySet) entity).getName()); } else { jsonGenerator.writeObject(((Singleton) entity).getName()); } } }
/** * Writes the url of the entity * It is a MUST element. * * @param jsonGenerator jsonGenerator * @param entity entity from the container */ private void writeURL(JsonGenerator jsonGenerator, Object entity) throws IOException { // It is exactly the same as the 'name' property. jsonGenerator.writeFieldName(URL); if (entity instanceof EntitySet) { jsonGenerator.writeObject(((EntitySet) entity).getName()); } else { jsonGenerator.writeObject(((Singleton) entity).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()); } }
/** * 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 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(); } }
/** * 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(); break;
for (Singleton singleton : entityDataModel.getEntityContainer().getSingletons()) { if (singleton.getTypeName().equals(entityType.getFullyQualifiedName())) { entityName = singleton.getName(); break;