Package org.apache.empire.data

Examples of org.apache.empire.data.DataType


        // Trim
        if (hasFormatOption(ii, "notrim")==false)
            value = value.trim();
        // Check Data Type
        Column column = ii.getColumn();
        DataType type = column.getDataType();
        if (type.isText())
            return value;
        // Check other types
        if (type==DataType.INTEGER)
        {   NumberFormat nf = NumberFormat.getIntegerInstance(ii.getLocale());
            return parseNumber(value, nf);
View Full Code Here


            // Empty String
            return "";
        }
        // Format Value
        Column column = vi.getColumn();
        DataType dataType = getValueType(value, (column != null) ? column.getDataType() : DataType.UNKNOWN);
        if (dataType == DataType.TEXT || dataType == DataType.UNKNOWN)
        { // String
            String s = String.valueOf(value);
            if (hasFormatOption(vi, "noencode"))
                return s;
View Full Code Here

    // ------- Input Helpers -------

    protected int getMaxInputLength(Column col)
    {
        // cast to DBTableColumn
        DataType type = col.getDataType();
        if (type==DataType.CHAR ||
            type==DataType.TEXT)
            return (int)Math.round(col.getSize());
        if (type==DataType.AUTOINC ||
            type==DataType.INTEGER)
View Full Code Here

        if (StringUtils.isEmpty(tag))
            tag="span";
        writer.startElement(tag, this);
        // Detect type and additional style
        String addlStyle = null;
        DataType dataType = vi.getColumn().getDataType();
        if (dataType.isNumeric())
        {   try {
                Object val = helper.getDataValue(true);
                if (val!=null && ObjectUtils.getInteger(val)<0)
                    addlStyle = "eValNeg";
            } catch(Exception e) {
View Full Code Here

    {
        boolean hasColumn = helper.hasColumn();
        Object value = getLinkValue(hasColumn);
        link.setValue(value);
        // css Style
        DataType dataType = (hasColumn ? helper.getColumn().getDataType() : DataType.UNKNOWN);
        link.setStyleClass(helper.getTagStyleClass(dataType, null, getLinkStyleClass()));
        // Set Attributes
        Map<String,Object> attr = getAttributes();
        // Set outcome
        String outcome = StringUtils.toString(attr.get("page"));
View Full Code Here

   *
   * @param column the column to get the type for
   */
  public Class<?> getJavaType(DBColumn column)
  {
    DataType type = getDataType(column);
    // We added the attribute of original datatype to AUTOINC columns
    // in CodeGenParser.addColumn(). Now we need to use it so that
    // the g/setters deal with the right Java type.
   
    // If the original data type was not set as an attribute for some
    // reason this will just fall through to the bottom and
    // return "Byte[]", so no problem.
    if (DataType.AUTOINC.equals(type) && null != column.getAttribute("AutoIncDataType"))
    {
      type = (DataType)column.getAttribute("AutoIncDataType");
    }
   
    // TODO might be better to add this to the enum
    // TODO use primitives for non-nullable columns?
    switch(type){
    case INTEGER:
      return Long.class;
    case TEXT:
      return String.class;
    case DATE:
      return Date.class;
    case DATETIME:
      return Date.class;
    case CHAR:
      return String.class;
    case FLOAT:
      return Double.class;
    case DECIMAL:
      return BigDecimal.class;
    case BOOL:
      return Boolean.class;
    case CLOB:
      return String.class;
    case BLOB:
      return Byte[].class;
    case UNKNOWN:
      return Byte[].class;
    default:
      log.warn("SQL column type " + type.toString() + " not supported, falling back to byte array.");
      return Byte[].class;
    }
  }
View Full Code Here

        String tbl = getName().toLowerCase();  
        String key = MESSAGE_KEY_PREFIX + tbl + "." + col;
        column.setTitle(key);

        // Set Default Control Type
        DataType type = column.getDataType();
        column.setControlType((type==DataType.BOOL) ? "checkbox" : "text");

        // Add Column
        super.addColumn(column);
    }
View Full Code Here

        {   // Auto-detect
            if (getValueOptions()!=null)
                controlType = SelectInputControl.NAME;
            else
            {   // get from data type
                DataType dataType = column.getDataType();
                controlType = FacesUtils.getFacesApplication().getDefaultControlType(dataType);
            }
            // get default control
            control = InputControlManager.getControl(controlType);
            // Still not? Use Text Control
View Full Code Here

   * the given ResultSet
   */
  private DBTableColumn addColumn(DBTable t, ResultSet rs)
      throws SQLException {
    String name = rs.getString("COLUMN_NAME");
    DataType empireType = getEmpireDataType(rs.getInt("DATA_TYPE"));
    double colSize = Double.parseDouble(""+rs.getInt("COLUMN_SIZE") + '.' +rs.getInt("DECIMAL_DIGITS"));
    boolean required = false;
    String defaultValue = rs.getString("COLUMN_DEF");
    if (rs.getString("IS_NULLABLE").equalsIgnoreCase("NO"))
      required = true;
   
    // The following is a hack for MySQL which currently gets sent a string "CURRENT_TIMESTAMP" from the Empire-db driver for MySQL.
    // This will avoid the driver problem because CURRENT_TIMESTAMP in the db will just do the current datetime.
    // Essentially, Empire-db needs the concept of default values of one type that get mapped to another.
    // In this case, MySQL "CURRENT_TIMESTAMP" for Types.TIMESTAMP needs to emit from the Empire-db driver the null value and not "CURRENT_TIMESTAMP".
    if(rs.getInt("DATA_TYPE") == Types.TIMESTAMP && defaultValue != null && defaultValue.equals("CURRENT_TIMESTAMP")){
      required = false; // It is in fact not required even though MySQL schema is required because it has a default value. Generally, should Empire-db emit (required && defaultValue != null) to truly determine if a column is required?
      defaultValue = null; // If null (and required per schema?) MySQL will apply internal default value.
    }
   
    // AUTOINC indicator is not in java.sql.Types but rather meta data from DatabaseMetaData.getColumns()
    // getEmpireDataType() above is not enough to support AUTOINC as it will only return DataType.INTEGER
    DataType originalType = empireType;
    ResultSetMetaData metaData = rs.getMetaData();
    int colCount = metaData.getColumnCount();
    String colName;
    for (int i = 1; i <= colCount; i++) {
      colName = metaData.getColumnName(i);
View Full Code Here

   * the given ResultSet
   */
  private DBViewColumn addColumn(InMemoryView v, ResultSet rs)
      throws SQLException {
    String name = rs.getString("COLUMN_NAME");
    DataType empireType = getEmpireDataType(rs.getInt("DATA_TYPE"));
   
    log.info("\tCOLUMN:\t" + name + " ("+empireType+")");
    return v.addCol(name, empireType);
  }
View Full Code Here

TOP

Related Classes of org.apache.empire.data.DataType

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.