Examples of DBTableColumn


Examples of org.apache.empire.db.DBTableColumn

    sql.append(" (");
    boolean addSeparator = false;
    Iterator<DBColumn> columns = t.getColumns().iterator();
    while (columns.hasNext())
    {
      DBTableColumn c = (DBTableColumn) columns.next();
      if (c.getDataType() == DataType.UNKNOWN)
        continue; // Ignore and continue;
      // Append column
      sql.append((addSeparator) ? ",\r\n   " : "\r\n   ");
      appendColumnDesc(c, false, sql);
      addSeparator = true;
View Full Code Here

Examples of org.apache.empire.db.DBTableColumn

        {
            DBTable table = seqtabs.next();
            Iterator<DBColumn> cols = table.getColumns().iterator();
            while (cols.hasNext())
            {
                DBTableColumn c = (DBTableColumn) cols.next();
                if (c.getDataType() == DataType.AUTOINC)
                {
                    createSequence(db, c, script);
                }
            }
        }
View Full Code Here

Examples of org.apache.empire.db.DBTableColumn

        // Enable Column default for the database
        // This is needed for adding required fields to non-empty tables
        db.getDriver().setDDLColumnDefaults(true);

        // First, add a new column to the Table object
        DBTableColumn C_FOO = db.T_EMPLOYEES.addColumn("FOO", DataType.TEXT, 20, DataMode.Nullable);

        // Now create the corresponding DDL statement
        System.out.println("Creating new column named FOO as varchar(20) for the EMPLOYEES table:");
        DBSQLScript script = new DBSQLScript();
        db.getDriver().getDDLScript(DBCmdType.CREATE, C_FOO, script);
        script.run(db.getDriver(), conn, false);
       
        // Now load a record from that table and set the value for foo
        System.out.println("Changing the value for the FOO field of a particular employee:");
        DBRecord rec = new DBRecord();
        rec.read(db.T_EMPLOYEES, idTestPerson, conn);
        rec.setValue(C_FOO, "Hello World");
        rec.update(conn);
       
        // Now extend the size of the field from 20 to 40 characters
        System.out.println("Extending size of column FOO to 40 characters:");
        C_FOO.setSize(40);
        script.clear();
        db.getDriver().getDDLScript(DBCmdType.ALTER, C_FOO, script);
        script.run(db.getDriver(), conn, false);

        // Now set a longer value for the record
View Full Code Here

Examples of org.apache.empire.db.DBTableColumn

  /**
   * Returns the empire DataType of the given DBColumn.
   */
  public DataType getDataType(DBColumn c)
  {
    DBTableColumn dbC = (DBTableColumn) c;
    return dbC.getDataType();
  }
View Full Code Here

Examples of org.apache.empire.db.DBTableColumn

  /**
   * Returns the default value of the given DBColumn.
   */
  public String getDefaultValue(DBColumn c)
  {
    DBTableColumn dbC = (DBTableColumn) c;
    Object val = dbC.getDefaultValue();
    if (val == null)
    {
      return "null";
    }

View Full Code Here

Examples of org.apache.empire.db.DBTableColumn

  }
 
  private void gatherRelations(DBDatabase db, DatabaseMetaData dbMeta, ArrayList<String> tables) throws SQLException{
    ResultSet relations = null;
    String fkTableName, pkTableName, fkColName, pkColName, relName;
    DBTableColumn fkCol, pkCol;
    DBTable fkTable, pkTable;
    DBColumn col;
   
    // Add all Relations
    for (String tableName :tables) {
     
      // check for foreign-keys
      relations = dbMeta.getImportedKeys(config.getDbCatalog(), config .getDbSchema(), tableName);
      while (relations.next()) {
        pkCol=fkCol=null;
       
        fkTableName=relations.getString("FKTABLE_NAME");
        pkTableName=relations.getString("PKTABLE_NAME");
        fkColName=relations.getString("FKCOLUMN_NAME");
        pkColName=relations.getString("PKCOLUMN_NAME");

        // Detect relation name
        relName=relations.getString("FK_NAME");
        if (StringUtils.isEmpty(relName))
          relName=fkTableName+"."+fkColName+"-"+pkTableName+"."+pkColName;
       
        pkTable = db.getTable(pkTableName);
        fkTable = db.getTable(fkTableName);
       
        // check if both tables really exist in the model
        if(pkTable==null || fkTable==null){
          log.error("Unable to add the relation \""+relName+"\"! One of the tables could not be found.");
          continue;
        }
       
        col=pkTable.getColumn(pkColName);
        if(col instanceof DBTableColumn)
          pkCol = (DBTableColumn) col;
 
        col=fkTable.getColumn(fkColName);
        if(col instanceof DBTableColumn)
          fkCol = (DBTableColumn) col;
       
        // check if both columns really exist in the model
        if(fkCol==null || pkCol==null){
          log.error("Unable to add the relation \""+relName+"\"! One of the columns could not be found.");
          continue;
        }
       
        // add the relation
        DBRelation.DBReference reference = fkCol.referenceOn(pkCol);
        DBRelation.DBReference[] refs = null;
          DBRelation r = db.getRelation(relName);
            if (r!=null) {
              DBRelation.DBReference[] refsOld = r.getReferences();
              refs = new DBRelation.DBReference[refsOld.length+1];
View Full Code Here

Examples of org.apache.empire.db.DBTableColumn

    try {
      rs = dbMeta.getColumns(config.getDbCatalog(), config.getDbSchema(),
          t.getName(), null);
          int i=0;
      while (rs.next()) {
        DBTableColumn c = addColumn(t, rs);
        // check if it is a KeyColumn
        if (pkCols.contains(c.getName()))
          keys[i++] = c;
       
        // check if it is the Timestamp/Locking Column
        if (lockColName!=null && c.getName().equalsIgnoreCase(lockColName))
          t.setTimestampColumn(c);
      }
          // Check whether all key columns have been set
          for (i=0; i<keys.length; i++)
              if (keys[i]==null){
View Full Code Here

Examples of org.apache.empire.db.DBTableColumn

   
    // Move from the return statement below so we can add
    // some AUTOINC meta data to the column to be used by
    // the ParserUtil and ultimately the template.
    log.info("\tCOLUMN:\t" + name + " ("+empireType+")");
    DBTableColumn col = t.addColumn(name, empireType, colSize, required, defaultValue);
   
    // We still need to know the base data type for this AUTOINC
    // because the Record g/setters need to know this, right?
    // So, let's add it as meta data every time the column is AUTOINC
    // and reference it in the template.
    if(empireType.equals(DataType.AUTOINC))
      col.setAttribute("AutoIncDataType", originalType);
    return col;
   
  }
View Full Code Here

Examples of org.apache.empire.db.DBTableColumn

        sql.append(" (");
        boolean addSeparator = false;
        Iterator<DBColumn> columns = t.getColumns().iterator();
        while (columns.hasNext())
        {
            DBTableColumn c = (DBTableColumn) columns.next();
            sql.append((addSeparator) ? ",\r\n   " : "\r\n   ");
            if (appendColumnDesc(c, sql)==false)
                continue; // Ignore and continue;
            addSeparator = true;
        }
View Full Code Here

Examples of org.apache.empire.db.DBTableColumn

        sql.append(" (");
        boolean addSeparator = false;
        Iterator<DBColumn> columns = t.getColumns().iterator();
        while (columns.hasNext())
        {
            DBTableColumn c = (DBTableColumn) columns.next();
            sql.append((addSeparator) ? ",\r\n   " : "\r\n   ");
            if (appendColumnDesc(c, sql)==false)
                continue; // Ignore and continue;
            addSeparator = true;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.