Package org.apache.empire.data

Examples of org.apache.empire.data.Column


    {
        // 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);
        }
        if (type==DataType.DECIMAL || type==DataType.FLOAT)
        {   NumberFormat nf = NumberFormat.getNumberInstance(ii.getLocale());
            return parseNumber(value, nf);
        }
        if (type==DataType.DATE || type==DataType.DATETIME)
        {   return parseDate(value, getDateFormat(column.getDataType(), ii, column));
        }
        if (type==DataType.BOOL)
        {   return ObjectUtils.getBoolean(value);
        }
        if (type==DataType.AUTOINC)
View Full Code Here


                return formatValue(nullValue, vi);
            // 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

        // Is unit supplied as a format option
        String format = getFormatString(vi, FORMAT_UNIT, FORMAT_UNIT_ATTRIBUTE);
        if (format!=null)
            return format;
        // Is it a currency column
        Column column = vi.getColumn();
        if (column!=null && column.getDataType()==DataType.DECIMAL)
        {
            String numberType = StringUtils.toString(column.getAttribute(InputControl.NUMBER_TYPE_ATTRIBUTE));
            if (numberType!=null)
            {
                if (numberType.equalsIgnoreCase("Currency"))
                {
                    String currencyCode = StringUtils.toString(column.getAttribute(InputControl.CURRENCY_CODE_ATTRIBUTE));
                    if (currencyCode!=null)
                    {   // nf = NumberFormat.getCurrencyInstance(locale);
                        Currency currency = Currency.getInstance(currencyCode);
                        return (currency!=null) ? currency.getSymbol() : null;
                    }
View Full Code Here

   
    private String getTextValue()
    {
        if (value instanceof ColumnExpr)
        {   // Get Column Title
            Column column = ((ColumnExpr)value).getSourceColumn();
            if (column!=null)
                return getTranslation( column.getTitle() );
        }
        if (value!=null)
        {   // Get Value
            String val = getString(value);
            return ((val!=null && val.length()>0) ? val : defValue);
View Full Code Here

    {
        // Add all Columns
        int count = 0;
        for (int i = 0; i < getFieldCount(); i++)
        { // Check Property
            Column column = getColumn(i);
            if (column.isReadOnly())
                continue;
            if (ignoreList != null && ignoreList.contains(column))
                continue; // ignore this property
            // Get Property Name
            setBeanPropertyValue(bean, column, getValue(i));
View Full Code Here

    {
        // Add all Columns
        int count = 0;
        for (int i = 0; i < getFieldCount(); i++)
        { // Check Property
            Column column = getColumn(i);
            if (column.isReadOnly())
                continue;
            if (ignoreList != null && ignoreList.contains(column))
                continue; // ignore this property
            // Get Property Name
            String property = column.getBeanPropertyName();
            Object value = getBeanPropertyValue(bean, property);
            if (value==null && this.hasError())
                continue;
            if (setValue(column, value))
                count++;
View Full Code Here

        Column[] keyColumns = record.getKeyColumns();
        // Pull all field values
        int fieldCount = record.getFieldCount();
        for (int i = 0; i < fieldCount; i++)
        {
            Column col = record.getColumn(i);
            // Check wether it is a key column
            if (ObjectUtils.contains(keyColumns, col))
                continue;
            // Get the value from the input control
            Object value = null;
            String field = getRequestFieldName(col);
            InputControl control = null;
            if (record.isFieldReadOnly(col)==false)
                control = InputControlManager.getControl(col.getControlType());
            // Get Value from Control first
            if (control!=null && (value=control.getFieldValue(field, action, locale, col))!=null)
            {   // Check for Error
                if (value instanceof InputControl.FieldValueError)
                {
                    InputControl.FieldValueError fieldError = (InputControl.FieldValueError)value;
                    // Error
                    String errorValue = fieldError.getValue();
                    addFieldError(field, col, fieldError, errorValue);
                    setRecordFieldValue(i, errorValue, false);
                    valid = false;
                    continue;
                }
                // Check Value
                if (value.equals(InputControl.NULL_VALUE) && col.isRequired())
                {   // Oops, columns is required
                    InputControl.FieldValueError fieldError = new InputControl.FieldValueError(WebErrors.InputValueRequired, null, "", control.getClass());
                    addFieldError(field, col, fieldError, value);
                    valid = false;
                    continue;
                }
                // Set Value
                if (log.isInfoEnabled())
                    log.info("SetUpdateFields: setting field '" + col.getName() + "' to " + String.valueOf(value));
                // Feldwert setzen
                if (!setRecordFieldValue(i, value, true))
                {   // Force to set field value
                    if (record instanceof ErrorInfo)
                        addFieldError(field, col, (ErrorInfo)record, value);
                    else
                        addFieldError(field, col, new ActionError(WebErrors.InputInvalidValue), value);
                    // set Value
                    setRecordFieldValue(i, value, false);
                    valid = false;
                }
            }
            else if ((value=action.getRequestParam(field + "!"))!=null)
            {   // hidden value
                if (col.getDataType()==DataType.DATE || col.getDataType()==DataType.DATETIME)
                {   // Special for Dates and timestamps
                    if (value.equals(sysdate)==false)
                    {   // Parse Date Time
                        String format = (col.getDataType()==DataType.DATE) ? "yyyy-MM-dd" : "yyyy-MM-dd HH:mm:ss.S";
                        SimpleDateFormat sdf = new SimpleDateFormat(format);
                        try {
                            value = sdf.parseObject(value.toString());
                        } catch(ParseException e) {
                            log.error("Failed to parse date for record", e);
                            continue;
                        }
                    }
                }
                // Set Value
                if (log.isInfoEnabled())
                    log.info("SetUpdateFields: directly setting field '" + col.getName() + "' to " + String.valueOf(value));
                // Has Value changed?
                if (ObjectUtils.compareEqual(record.getValue(i), value)==false)
                {   // Modify Value
                    setRecordFieldValue(i, value, false);
                }
View Full Code Here

    }
   
    protected String getControlType()
    {
        // Detect control type and readOnly state
        Column column = getColumn();
        if (column==null)
        {   // log.debug("No Column supplied. Unable to detect control type. Using default.");
            return "text";
        }
        return column.getControlType();
    }
View Full Code Here

                return formatValue(vi.getNullValue(), vi, false);
            // 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

        // Is unit supplied as a format option
        String format = getFormatOption(vi, FORMAT_UNIT);
        if (format!=null)
            return format;
        // Is it a currency column
        Column column = vi.getColumn();
        if (column!=null && column.getDataType()==DataType.DECIMAL)
        {
            String numberType = StringUtils.toString(column.getAttribute(InputControl.NUMBER_FORMAT_ATTRIBUTE));
            if (numberType!=null)
            {
                if (numberType.equalsIgnoreCase("Currency"))
                {
                    String currencyCode = StringUtils.toString(column.getAttribute(InputControl.CURRENCY_CODE_ATTRIBUTE));
                    if (currencyCode!=null)
                    {   // nf = NumberFormat.getCurrencyInstance(locale);
                        Currency currency = Currency.getInstance(currencyCode);
                        return (currency!=null) ? currency.getSymbol() : null;
                    }
View Full Code Here

TOP

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

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.