示例#1
0
 public static Attribute getAttribute(Entity entidad, String atributo) {
   for (Attribute attr : getAllDirectAttributes(entidad)) {
     if (attr.getName().equals(atributo)) {
       return attr;
     }
   }
   return null;
 }
示例#2
0
 public static String getSimpleTipo(Attribute attr) {
   if (attr.getType().getSimple() != null) {
     return attr.getType().getSimple().getType();
   }
   if (attr.getType().getSpecial() != null) {
     return attr.getType().getSpecial().getType();
   }
   return null;
 }
示例#3
0
 public static boolean esColeccion(Attribute attr) {
   if (attr.getType().getCompound() == null) {
     return false;
   }
   if (attr.getType().getCompound().getCollectionType() != null) {
     return true;
   }
   return false;
 }
示例#4
0
 public static boolean esLista(Attribute attr) {
   if (attr.getType().getCompound() == null) {
     return false;
   }
   if (attr.getType().getCompound().getLista() != null) {
     return true;
   }
   return false;
 }
示例#5
0
 /**
  * En el caso de que el atributo sea una referencia, devuelve el tipo de la referencia(OneToOne,
  * OneToMany, ManyToOne, ManyToMany) El tipo por defecto es OneToOne
  *
  * @param attr
  * @return
  */
 public static String getTipoReferencia(Attribute attr) {
   if (!isReferencia(attr)) return null;
   CompoundType c = attr.getType().getCompound();
   if (c.getTipoReferencia() == null) {
     return "OneToOne";
   }
   return c.getTipoReferencia().getType();
 }
示例#6
0
 public static void addId(Entity entidad) {
   if (entidad.getExtends() != null) {
     return;
   }
   for (Attribute attr : entidad.getAttributes()) {
     if (attr.getName().equals("id")) {
       return;
     }
   }
   LedFactory factory = new LedFactoryImpl();
   Attribute id = factory.createAttribute();
   id.setName("id");
   id.setType(factory.createType());
   id.getType().setSimple(new LedFactoryImpl().createSimpleType());
   id.getType().getSimple().setType("Long");
   entidad.getAttributes().add(id);
 }
示例#7
0
 public static boolean isReferencia(Attribute attr) {
   return attr != null
       && attr.getType().getCompound() != null
       && attr.getType().getCompound().getEntidad() != null;
 }
示例#8
0
 public static Entity getEntidad(Attribute attr) {
   if (attr == null || attr.getType().getCompound() == null) {
     return null;
   }
   return attr.getType().getCompound().getEntidad();
 }
示例#9
0
 public static boolean esSimple(Attribute attr) {
   return attr.getType().getSimple() != null || attr.getType().getSpecial() != null;
 }