Ejemplo n.º 1
0
 /**
  * To handle generic case where user do not know the type, here we will be looking for a type and
  * then generate EntityResource<E>
  *
  * @param entity
  * @return EntityResource<E>
  */
 public static <E> EntityResource<E> createEntityResource(E entity) {
   GenericEntity<E> ge = new GenericEntity<E>(entity) {};
   Type t =
       com.temenos.interaction.core.command.CommandHelper.getEffectiveGenericType(
           ge.getType(), entity);
   if (ResourceTypeHelper.isType(ge.getRawType(), t, OEntity.class, OEntity.class)) {
     OEntity te = (OEntity) entity;
     String entityName =
         te != null && te.getEntityType() != null ? te.getEntityType().getName() : null;
     return com.temenos.interaction.core.command.CommandHelper.createEntityResource(
         entityName, entity, OEntity.class);
   } else if (ResourceTypeHelper.isType(ge.getRawType(), t, Entity.class, Entity.class)) {
     Entity te = (Entity) entity;
     String entityName = te != null ? te.getName() : null;
     return com.temenos.interaction.core.command.CommandHelper.createEntityResource(
         entityName, entity, Entity.class);
   } else {
     // Call the generic and lets see what happens
     return com.temenos.interaction.core.command.CommandHelper.createEntityResource(entity, null);
   }
 }
Ejemplo n.º 2
0
 /**
  * To help converting Entity object into EntityResource as we are no longer extending the core
  * CommandHelper
  *
  * @param entity
  * @return EntityResource<Entity> EntityResource of parameter type Entity
  */
 public static EntityResource<Entity> createEntityResource(Entity entity) {
   return com.temenos.interaction.core.command.CommandHelper.createEntityResource(entity);
 }
Ejemplo n.º 3
0
 /**
  * Create an OData entity resource (entry)
  *
  * @param e OEntity
  * @return entity resource EntityResource of parameter type OEntity
  */
 public static EntityResource<OEntity> createEntityResource(OEntity e) {
   String entityName = e != null && e.getEntityType() != null ? e.getEntityType().getName() : null;
   return com.temenos.interaction.core.command.CommandHelper.createEntityResource(
       entityName, e, OEntity.class);
 }