/** * Write a {@code <link>} element for a given entity. * * @param entity The given entity. * @throws XMLStreamException If unable to write to stream * @throws ODataEdmException if unable to check entity types */ public void writeEntryEntityLink(Object entity) throws XMLStreamException, ODataEdmException { EntityType entityType = getAndCheckEntityType(entityDataModel, entity.getClass()); xmlWriter.writeStartElement(ATOM_LINK); if (entityType.isReadOnly()) { xmlWriter.writeAttribute(REL, SELF); } else { xmlWriter.writeAttribute(REL, EDIT); } xmlWriter.writeAttribute(TITLE, entityType.getName()); xmlWriter.writeAttribute(HREF, getEntityWithKey(entity)); xmlWriter.writeEndElement(); }
/** * Write a {@code <link>} element for a given entity. * * @param entity The given entity. * @throws XMLStreamException If unable to write to stream * @throws ODataEdmException if unable to check entity types */ public void writeEntryEntityLink(Object entity) throws XMLStreamException, ODataEdmException { EntityType entityType = getAndCheckEntityType(entityDataModel, entity.getClass()); xmlWriter.writeStartElement(ATOM_LINK); if (entityType.isReadOnly()) { xmlWriter.writeAttribute(REL, SELF); } else { xmlWriter.writeAttribute(REL, EDIT); } xmlWriter.writeAttribute(TITLE, entityType.getName()); xmlWriter.writeAttribute(HREF, getEntityWithKey(entity)); xmlWriter.writeEndElement(); }
LOG.debug("Writing type {} of type {}", type.getName(), type.getMetaType()); try { xmlWriter.writeStartElement(ENTITY_TYPE); xmlWriter.writeAttribute(HAS_STREAM, Boolean.toString(type.hasStream())); xmlWriter.writeAttribute(NAME, type.getName()); if (type.isAbstract()) { xmlWriter.writeAttribute(ABSTRACT, "true"); xmlWriter.writeEndElement(); } catch (XMLStreamException e) { throw new ODataRenderException("Error while writing entity type: " + type.getName(), e);
LOG.debug("Writing type {} of type {}", type.getName(), type.getMetaType()); try { xmlWriter.writeStartElement(ENTITY_TYPE); xmlWriter.writeAttribute(HAS_STREAM, Boolean.toString(type.hasStream())); xmlWriter.writeAttribute(NAME, type.getName()); if (type.isAbstract()) { xmlWriter.writeAttribute(ABSTRACT, "true"); xmlWriter.writeEndElement(); } catch (XMLStreamException e) { throw new ODataRenderException("Error while writing entity type: " + type.getName(), e);
public void addEntityType(Class<?> cls, EntityType entityType) { EdmSingleton singletonAnno = cls.getAnnotation(EdmSingleton.class); if (singletonAnno == null) { return; } String singletonName = singletonAnno.name(); if (isNullOrEmpty(singletonName)) { singletonName = singletonAnno.value(); if (isNullOrEmpty(singletonName)) { // Use simple name of entity type if no name for the singleton is specified singletonName = entityType.getName(); } } String entityTypeName = entityType.getFullyQualifiedName(); LOG.debug("Creating Singleton named: {} for entity type: {}", singletonName, entityTypeName); builders.put(entityTypeName, new SingletonImpl.Builder() .setName(singletonName) .setTypeName(entityTypeName)); }
public void addEntityType(Class<?> cls, EntityType entityType) { EdmSingleton singletonAnno = cls.getAnnotation(EdmSingleton.class); if (singletonAnno == null) { return; } String singletonName = singletonAnno.name(); if (isNullOrEmpty(singletonName)) { singletonName = singletonAnno.value(); if (isNullOrEmpty(singletonName)) { // Use simple name of entity type if no name for the singleton is specified singletonName = entityType.getName(); } } String entityTypeName = entityType.getFullyQualifiedName(); LOG.debug("Creating Singleton named: {} for entity type: {}", singletonName, entityTypeName); builders.put(entityTypeName, new SingletonImpl.Builder() .setName(singletonName) .setTypeName(entityTypeName)); }
public void addEntityType(Class<?> cls, EntityType entityType) { EdmEntitySet entitySetAnno = cls.getAnnotation(EdmEntitySet.class); if (entitySetAnno == null) { return; } String entitySetName = entitySetAnno.name(); if (isNullOrEmpty(entitySetName)) { entitySetName = entitySetAnno.value(); if (isNullOrEmpty(entitySetName)) { // Use automatically pluralized simple name of entity type if no name for the entity set is specified entitySetName = pluralize(entityType.getName()); } } String entityTypeName = entityType.getFullyQualifiedName(); LOG.trace("Creating EntitySet named: {} for entity type: {}", entitySetName, entityTypeName); builders.put(entityTypeName, new EntitySetImpl.Builder() .setName(entitySetName) .setTypeName(entityTypeName) .setIsIncludedInServiceDocument(entitySetAnno.includedInServiceDocument())); }
public void addEntityType(Class<?> cls, EntityType entityType) { EdmEntitySet entitySetAnno = cls.getAnnotation(EdmEntitySet.class); if (entitySetAnno == null) { return; } String entitySetName = entitySetAnno.name(); if (isNullOrEmpty(entitySetName)) { entitySetName = entitySetAnno.value(); if (isNullOrEmpty(entitySetName)) { // Use automatically pluralized simple name of entity type if no name for the entity set is specified entitySetName = pluralize(entityType.getName()); } } String entityTypeName = entityType.getFullyQualifiedName(); LOG.trace("Creating EntitySet named: {} for entity type: {}", entitySetName, entityTypeName); builders.put(entityTypeName, new EntitySetImpl.Builder() .setName(entitySetName) .setTypeName(entityTypeName) .setIsIncludedInServiceDocument(entitySetAnno.includedInServiceDocument())); }