Package org.apache.empire.data

Examples of org.apache.empire.data.Column


        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(FieldErrors.InputValueRequired, null, "");
                    addFieldError(field, col, fieldError, value);
                    valid = false;
                    continue;
                }
                // set field value now
                if (log.isInfoEnabled())
                    log.info("SetUpdateFields: setting field '" + col.getName() + "' to " + String.valueOf(value));
                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(FieldErrors.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


                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

    }
   
    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

    {
        // 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

            return super.formatValue(value, vi);
        }
        // Check for Abbreviation
        if (hasFormatOption(vi, "short"))
        {
            Column column = vi.getColumn();
            if (column!=null)
            {   // Check for Abbreviation option list
                Object attrValue = column.getAttribute(COLATTR_ABBR_OPTIONS);
                if (attrValue instanceof Options)
                { // Check for Options
                    String text = ((Options)attrValue).get(value);
                    if (text != null)
                        return vi.getText(text);
View Full Code Here

        }
       
        @Override
        public String getInputId()
        {
            Column c = getColumn();
            return c.getName(); // (c instanceof DBColumn) ? ((DBColumn)c).getFullName() : c.getName();
        }
View Full Code Here

    {
        // add label and input components when the view is loaded for the first time
        super.encodeBegin(context);

        // Create
        Column column = helper.getColumn();
        if (column==null)
            throw new InvalidArgumentException("column", column);
       
        // Tooltip title
        String title = helper.getLabelTooltip(column);
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.