Package org.byteliberi.easydriver.generator.model

Examples of org.byteliberi.easydriver.generator.model.PropertyModel


        final int dataType = rs.getInt(5);
        fpa.setNullable( "YES".equals( rs.getString(18) ) );
       
        switch (dataType) {
        case Types.NUMERIC: case Types.DECIMAL:
          fpa.setProp(new PropertyModel(Visibility.PRIVATE, BigDecimalField.class.getSimpleName(), propName));
          break;
        case Types.BIT: case Types.BOOLEAN:
          fpa.setProp(new PropertyModel(Visibility.PRIVATE, BooleanField.class.getSimpleName(), propName));         
          break;
        case Types.CHAR:
          fpa.setProp(new PropertyModel(Visibility.PRIVATE, CharField.class.getSimpleName(), propName));
          break;
        case Types.DATE:
          fpa.setProp(new PropertyModel(Visibility.PRIVATE, DateField.class.getSimpleName(), propName));
          break;
        case Types.DOUBLE:
          fpa.setProp(new PropertyModel(Visibility.PRIVATE, DoubleField.class.getSimpleName(), propName));
          break;
        case Types.INTEGER:
          fpa.setProp(new PropertyModel(Visibility.PRIVATE, IntField.class.getSimpleName(), propName));
          break;
        case Types.TIMESTAMP:
          fpa.setProp(new PropertyModel(Visibility.PRIVATE, TimestampField.class.getSimpleName(), propName));
          break;
        case Types.BINARY:
          fpa.setProp(new PropertyModel(Visibility.PRIVATE, ByteArrayField.class.getSimpleName(), propName));
          break;
        case Types.OTHER:  // TODO What if it is not UUID ?
          fpa.setProp(new PropertyModel(Visibility.PRIVATE, UUIDField.class.getSimpleName(), propName));
          break;
        case Types.VARCHAR:
          fpa.setProp(new PropertyModel(Visibility.PRIVATE, VarcharField.class.getSimpleName(), propName));
          break;
        default:
          Logger.getLogger(MetaEasyDriverFactory.class.getSimpleName()).severe(columnName + " " + rs.getString(6) + " " + dataType);
        }
     
View Full Code Here


      final Set<Entry<String,String>> fksEntries = fks.entrySet();
      for (Entry<String, String> fksEntry : fksEntries) {
        final String examinedClass = Utils.getCamelNameFirstCapital( fksEntry.getValue() ) + "ObjectModel";
        if (!usedClasses.contains(examinedClass)) {
          usedClasses.add(examinedClass);
          classModel.addProperty(new PropertyModel(Visibility.PRIVATE, examinedClass, fksEntry.getKey()));
        }
      }
     
      // Let's add the properties for the columns
      for (PropertyModel prop : tableInfo.getProperties()) {
        if (!fks.containsKey(prop.getName()))
          classModel.addProperty(prop);
      }
     
      final List<PropertyModel> primaryKeys = new LinkedList<PropertyModel>();
      final List<PropertyModel> presentProps = classModel.getProperties();
      for(PropertyModel primaryKey : tableInfo.getPrimaryKey()) {
        final String key = primaryKey.getName();
        for (PropertyModel presentProp : presentProps) {
           if (presentProp.getName().equals(key)) {
             primaryKeys.add(new PropertyModel(Visibility.PRIVATE, presentProp.getPropertyClass(), key));
           }
        }
      }
     
      classModel.setConstructorGenerator(new PrimaryKeyConstructor(className, primaryKeys));
View Full Code Here

      classModel.setEnumList("INSTANCE");
      classModel.setPackageName(this.packageName);
      classModel.addImport("org.byteliberi.easydriver.*")
      classModel.addImport("org.byteliberi.easydriver.fields.*");
     
      classModel.addProperty(new PropertyModel(Visibility.PRIVATE, DBTable.class.getSimpleName(), "table"));

      // Let's look for the fields       
      final List<FieldPropertyAssociation> fieldAssoc = tableInfo.getFields();
      final HashSet<String> usedFields = new HashSet<String>();
     
      for (FieldPropertyAssociation fa : fieldAssoc) {
        final String fieldName = fa.getFieldName();
        if (!usedFields.contains(fieldName)) {
          classModel.addProperty(fa.getProp());
          usedFields.add(fieldName);
        }
      }
       
      // Let's look for the relationships
      final Collection<List<RelationModel>> rels = tableInfo.getRelationships();
      // Now we add the properties for the relationships that we have found         
     
      final HashSet<String> ext = new HashSet<String>();
      if ((rels != null) && (rels.size() > 0)) {
        Iterator<List<RelationModel>> relsIterator = rels.iterator();
        while (relsIterator.hasNext()) {
          final List<RelationModel> relList = relsIterator.next();
          if (relList.size() > 0) {
            final String oneTable = relList.get(0).getOneTable();
            ext.add(oneTable);
          }
        }       
      } 
     
      for (String name : ext) {
        classModel.addProperty(new PropertyModel(Visibility.PRIVATE,
                             ManyToOne.class.getSimpleName(),
                             "fk" + Utils.getCamelNameFirstCapital(name)));
      }
       
      classModel.setConstructorGenerator(new TableStructureConstructor(tableName, fieldAssoc, rels, tableInfo.getPrimaryKey()));
View Full Code Here

TOP

Related Classes of org.byteliberi.easydriver.generator.model.PropertyModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.