Package mydatagenerator.model.bean

Examples of mydatagenerator.model.bean.MetadataTableInfoBean


          String valuesList = "'";
       
          // 3 for each field, depending on his data type choose the right generator type to use
          for(int j=0;j<tableFieldsInfoList.size();j++)
          {         
            MetadataTableInfoBean field = tableFieldsInfoList.get(j);           
            currentFieldName = field.getFieldName();
           
            fieldHasChild = false
           
            // the type of the current field ( eg varchar(10) bigint(10) )
            String fieldType = field.getFieldType();
            String childColumn = null;
            String childTable = null;
           
            if(Log4jManager.IS_LOGGING_CONFIGURED)
               logger.debug("Current field: "+currentFieldName +" of Type:"+fieldType);
           
            // check if the current field has child
            for(TableFKconstraintsBean fkInfoList:tableFKinfoList)
            {             
              //true if the current field point another table
              if(fkInfoList.getParentColumnName().equalsIgnoreCase(currentFieldName)) {
               
                fieldHasChild = true;
               
                //get who is the referenced column+table pair
                childColumn = fkInfoList.getReferencedColumnName();               
                childTable = fkInfoList.getReferencedTableName();
              }               
            } 
           
            /**
             * Note the child table is already filled because our table list is in the filling order
             */
            if(fieldHasChild && childTable !=null && childColumn !=null)
            {
              if(Log4jManager.IS_LOGGING_CONFIGURED)
                 logger.info("- Table "+currentTable+"("+currentFieldName+") references the Table:"+childTable+"("+childColumn+") ");
             
              /* the fields with "auto_increment" option don't appear in the insert query: is mysql that generate his value */
              if(!field.getExtraInfo().equalsIgnoreCase("auto_increment")) {
                  columnNameList += field.getFieldName()+",";
             
                // Get the allowed values for the current field from the child column
                ArrayList<String> allowedValues = databaseTableUtils.getColumnValue(childTable,childColumn);
               
                String chosenValue = allowedValues.get(k); //use the 'k' index because all the table have the same total row
                valuesList +=chosenValue+"','";
              }
             
            }else
                fieldHasChild = false// current field has no child to other tables
               
                if(Log4jManager.IS_LOGGING_CONFIGURED)
                   logger.info("The field: "+currentFieldName+" has no references to other tables");
               
                //TODO: next release improve the field type above....
               
                /* fields with "auto_increment" option don't appear in the insert query: is mysql that generate their value */
                if(!field.getExtraInfo().equalsIgnoreCase("auto_increment"))
                {
                  columnNameList += field.getFieldName()+",";
                  
                  /* PREMISE: the dimension of a some field is not mandatory, depends on the field type */
                 
                  if(fieldType.startsWith("tinyint")){  //tinyint(x) values 0-255 (or -128 to 127) 
                   
View Full Code Here


         String keyColumn = tableFieldsResultset.getString("Key"); //PRI if primary key, MUL if there is an index on the column
         String defaultColumn = tableFieldsResultset.getString("Default")
         String extraInfo = tableFieldsResultset.getString("Extra"); //eg auto_increment
        
         // bean that represents a table row
         MetadataTableInfoBean tableFieldInfoBean = new MetadataTableInfoBean();
        
         tableFieldInfoBean.setFieldName(fieldColumn);
         tableFieldInfoBean.setFieldType(typeColumn);
         tableFieldInfoBean.setFieldNullable(nullColumn);
         tableFieldInfoBean.setIsPK(keyColumn);
         tableFieldInfoBean.setDefaultValue(defaultColumn);
         tableFieldInfoBean.setExtraInfo(extraInfo);
        
         //logger.info("** -Field:"+fieldColumn+" -Type:"+typeColumn+" -Nullable: "+nullColumn+" -isPK: "+keyColumn+" -Default: "+defaultColumn+ " Extra: "+extraInfo);
        
         tableFieldInfoBeanList.add(tableFieldInfoBean);
      }
View Full Code Here

  /**
   * Return the value to insert in a cell, depending on the column index
   */
  public Object getValueAt(int row, int col) {
   
    MetadataTableInfoBean tb = tableFieldInfoBeanList.get(row);
   
    switch (col) {
        case 0:
          return tb.getFieldName();
        case 1:
          return tb.getFieldType();
        case 2:
          return tb.getFieldNullable();
        case 3:
          return tb.getIsPK();
        case 4:
        return tb.getDefaultValue();
        case 5:
          return tb.getExtraInfo();
        default:
          return null;
     }   
  }
View Full Code Here

TOP

Related Classes of mydatagenerator.model.bean.MetadataTableInfoBean

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.