Package org.apache.torque.templates.platform

Examples of org.apache.torque.templates.platform.Platform


            ControllerState controllerState,
            String size,
            String scale,
            String defaultValue)
    {
        Platform platform = PlatformFactory.getPlatformFor(
                controllerState.getStringOption(TemplateOptionName.DATABASE));
        SqlType platformSqlType = platform.getSqlTypeForSchemaType(schemaType);
        if (domainType != null)
        {
            if (size == null)
            {
                size = domainType.getSize();
View Full Code Here


                domainType,
                controllerState,
                ObjectUtils.toString(size, null),
                ObjectUtils.toString(scale, null),
                ObjectUtils.toString(defaultValue, null));
        Platform platform = getPlatform(controllerState);

        List<String> resultList = new ArrayList<String>();

        String sqlTypeName = sqlType.getSqlTypeName();

        if (platform.hasSize(sqlTypeName))
        {
            sqlTypeName += sqlType.printSize(
                    platform.getSizeSuffix(sqlTypeName));
        }

        resultList.add(sqlTypeName);

        if (StringUtils.isNotEmpty(sqlType.getDefaultValue()))
        {
            resultList.add("default");

            if ((SchemaType.DATE == schemaType
                    || SchemaType.TIME == schemaType
                    || SchemaType.TIMESTAMP == schemaType))
            {
                if (sqlType.getDefaultValue().startsWith("CURRENT_"))
                {
                    resultList.add(sqlType.getDefaultValue());
                }
                else
                {
                    Date defaultDate
                            = OMColumnTransformer.getDefaultValueAsDate(
                                    sqlType.getDefaultValue());
                    if (SchemaType.DATE == schemaType)
                    {
                        resultList.add(platform.getDateString(defaultDate));
                    }
                    else if (SchemaType.TIME == schemaType)
                    {
                        resultList.add(platform.getTimeString(defaultDate));
                    }
                    else
                    {
                        resultList.add(platform.getTimestampString(
                                defaultDate));
                    }
                }
            }
            else if (TypeMap.isTextType(schemaType))
            {
                resultList.add(platform.quoteAndEscape(
                        sqlType.getDefaultValue()));
            }
            else
            {
                resultList.add(sqlType.getDefaultValue());
            }
        }

        boolean primaryKey;
        {
            String primaryKeyString = (String) columnElement.getAttribute(
                    TorqueSchemaAttributeName.PRIMARY_KEY);
            primaryKey = Boolean.parseBoolean(primaryKeyString);
        }
        boolean required;
        {
            String requiredString = (String) columnElement.getAttribute(
                    TorqueSchemaAttributeName.REQUIRED);
            required = Boolean.parseBoolean(requiredString);
        }
        boolean isNotNull = primaryKey || required;
        String isNotNullString = platform.getNullString(isNotNull);

        if (platform.createNotNullBeforeAutoincrement()
            && StringUtils.isNotEmpty(isNotNullString))
        {
            resultList.add(isNotNullString);
        }
        // if idMethod was not set explicitly by the user,
        // the transformTable() method sets the attribute from the
        // defaultIdMethod of the database, so this always returns
        // the id method
        Object idMethod = columnElement.getParent().getAttribute(
                TorqueSchemaAttributeName.ID_METHOD);
        if (primaryKey
                && TorqueSchemaIdMethod.NATIVE.getName().equals(idMethod))
        {
            String autoIncrement = platform.getAutoIncrement();
            if (StringUtils.isNotEmpty(autoIncrement))
            {
                resultList.add(autoIncrement);
            }
        }
        if (!platform.createNotNullBeforeAutoincrement()
                && StringUtils.isNotEmpty(isNotNullString))
        {
            resultList.add(isNotNullString);
        }
        return StringUtils.join(resultList.iterator(), ' ');
View Full Code Here

        return StringUtils.join(resultList.iterator(), ' ');
    }

    private Platform getPlatform(ControllerState controllerState)
    {
        Platform platform = PlatformFactory.getPlatformFor(
                controllerState.getStringOption(
                        TemplateOptionName.DATABASE));
        return platform;
    }
View Full Code Here

    private void addDatabaseSchemaElements(
            SourceElement databaseElement,
            ControllerState controllerState)
    {
        Platform platform = getPlatform(controllerState);
        if (!platform.usesStandaloneSchema())
        {
            return;
        }
        List<String> databaseSchemaNames = new ArrayList<String>();
        List<SourceElement> allTables
View Full Code Here

TOP

Related Classes of org.apache.torque.templates.platform.Platform

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.