/** * EntityWithNameSpaceSample. */ @EdmEntity(namespace = "ODataDemo.SampleContainer", key = { "Id" }) @EdmEntitySet("EntityWithNameSpaceSamples") public class EntityWithNameSpaceSample { }
private static String getTypeName(EdmEntity entityAnno, Class<?> entityClass) { String name = entityAnno.name(); if (isNullOrEmpty(name)) { // Use class name if name is not specified in EdmEntity annotation name = entityClass.getSimpleName(); } return name; }
private static String getNamespace(EdmEntity entityAnno, Class<?> entityClass) { String namespace = entityAnno.namespace(); if (isNullOrEmpty(namespace)) { // Use package name if namespace is not specified in EdmEntity annotation namespace = entityClass.getPackage().getName(); } return namespace; }
String[] keyPropertyNames = entityAnno.key(); if (keyPropertyNames.length > 0) { for (String keyPropertyName : keyPropertyNames) { for (EdmPropertyRef propertyRefAnno : entityAnno.keyRef()) { propertyRefBuilder.add(new PropertyRefImpl(propertyRefAnno.path(), isNullOrEmpty(propertyRefAnno.alias()) ? null : propertyRefAnno.alias())); .setIsAbstract(Modifier.isAbstract(cls.getModifiers())) .addStructuralProperties(buildStructuralProperties(cls)) .setIsOpen(entityAnno.open()) .setKey(key) .build();
private String buildEntityTypes(AnnotationEntitySetFactory entitySetFactory, AnnotationSingletonFactory singletonFactory) { AnnotationEntityTypeFactory entityTypeFactory = new AnnotationEntityTypeFactory(TYPE_NAME_RESOLVER); String entityContainerName = null; for (Class<?> entityClass : entityClasses) { EntityType entityType = entityTypeFactory.build(entityClass); getSchemaBuilder(entityType.getNamespace()).addType(entityType); if (isNullOrEmpty(entityContainerName)) { EdmEntity edmEntity = entityClass.getAnnotation(EdmEntity.class); if (edmEntity != null) { entityContainerName = edmEntity.containerName(); } } // Create and add EntitySet if an @EdmEntitySet annotation is present on the entity class entitySetFactory.addEntityType(entityClass, entityType); // Create and add Singleton if an @EdmSingleton annotation is present on the entity class singletonFactory.addEntityType(entityClass, entityType); } return entityContainerName; }
String[] keyPropertyNames = entityAnno.key(); if (keyPropertyNames.length > 0) { for (String keyPropertyName : keyPropertyNames) { for (EdmPropertyRef propertyRefAnno : entityAnno.keyRef()) { propertyRefBuilder.add(new PropertyRefImpl(propertyRefAnno.path(), isNullOrEmpty(propertyRefAnno.alias()) ? null : propertyRefAnno.alias())); .setIsAbstract(Modifier.isAbstract(cls.getModifiers())) .addStructuralProperties(buildStructuralProperties(cls)) .setIsOpen(entityAnno.open()) .setKey(key) .build();
private String buildEntityTypes(AnnotationEntitySetFactory entitySetFactory, AnnotationSingletonFactory singletonFactory) { AnnotationEntityTypeFactory entityTypeFactory = new AnnotationEntityTypeFactory(TYPE_NAME_RESOLVER); String entityContainerName = null; for (Class<?> entityClass : entityClasses) { EntityType entityType = entityTypeFactory.build(entityClass); getSchemaBuilder(entityType.getNamespace()).addType(entityType); if (isNullOrEmpty(entityContainerName)) { EdmEntity edmEntity = entityClass.getAnnotation(EdmEntity.class); if (edmEntity != null) { entityContainerName = edmEntity.containerName(); } } // Create and add EntitySet if an @EdmEntitySet annotation is present on the entity class entitySetFactory.addEntityType(entityClass, entityType); // Create and add Singleton if an @EdmSingleton annotation is present on the entity class singletonFactory.addEntityType(entityClass, entityType); } return entityContainerName; }
/** * EntityWithNameSpaceSample. */ @EdmEntity(namespace = "ODataDemo.SampleContainer", key = { "Id" }) @EdmEntitySet("EntityWithNameSpaceSamples") public class EntityWithNameSpaceSample { }
private static String getNamespace(EdmEntity entityAnno, Class<?> entityClass) { String namespace = entityAnno.namespace(); if (isNullOrEmpty(namespace)) { // Use package name if namespace is not specified in EdmEntity annotation namespace = entityClass.getPackage().getName(); } return namespace; }
private static String getTypeName(EdmEntity entityAnno, Class<?> entityClass) { String name = entityAnno.name(); if (isNullOrEmpty(name)) { // Use class name if name is not specified in EdmEntity annotation name = entityClass.getSimpleName(); } return name; }
@EdmEntity(namespace = "ODataDemo", key = { "id" }) @EdmSingleton("SingletonWithName") public class NamedSingleton {
@EdmEntity(namespace = "ODataDemo", key = { "id" }) @EdmSingleton public class SingletonSample {
@EdmEntity(namespace = "ODataDemo", key = { "id" }) @EdmSingleton public class SingletonSample {
@EdmEntity(namespace = "ODataDemo", key = { "id" }) @EdmSingleton("SingletonWithName") public class NamedSingleton {
@EdmEntity(namespace = "ODataDemo", key = {"iban" }) @EdmEntitySet("BankAccounts") public class BankAccount {
@EdmEntity(namespace = "ODataDemo", key = {"iban" }) @EdmEntitySet("BankAccounts") public class BankAccount {
@EdmEntity(namespace = "ODataDemo", key = { "InheritedId" }) @EdmEntitySet("AbstractEntityTypeSamples") public abstract class AbstractEntityTypeSample {
@EdmEntity(namespace = "ODataDemo", key = {"id" }) @EdmEntitySet("VIPCustomer") public class VIPCustomer extends Customer {
@EdmEntity(namespace = "ODataSample", key = {"ID" }) @EdmEntitySet public class IdNamePairSample {
@EdmEntity(namespace = "ODataDemo", key = {"id" }) @EdmEntitySet("VIPCustomer") public class VIPCustomer extends Customer {