Search in sources :

Example 36 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime in project clinical_quality_language by cqframework.

the class DateTimeInvocation method getOperands.

@Override
public Iterable<Expression> getOperands() {
    DateTime dt = (DateTime) expression;
    List<Expression> opList = Arrays.asList(dt.getYear(), dt.getMonth(), dt.getDay(), dt.getHour(), dt.getMinute(), dt.getSecond(), dt.getMillisecond(), dt.getTimezoneOffset());
    // If the last expression is null, we should trim this down
    int i;
    for (i = 7; i > 0 && opList.get(i) == null; i--) ;
    return opList.subList(0, i + 1);
}
Also used : Expression(org.hl7.elm.r1.Expression) DateTime(org.hl7.elm.r1.DateTime)

Example 37 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime in project jaxdb by jaxdb.

the class Compiler method createColumn.

private CreateStatement createColumn(final LinkedHashSet<CreateStatement> alterStatements, final $Table table, final $Column column, final Map<String, Map<String, String>> tableNameToEnumToOwner) {
    final StringBuilder builder = new StringBuilder();
    builder.append(q(column.getName$().text())).append(' ');
    // FIXME: Passing null to compile*() methods will throw a NPE
    if (column instanceof $Char) {
        final $Char type = ($Char) column;
        builder.append(getDialect().compileChar(type.getVarying$() != null && type.getVarying$().text(), type.getLength$() == null ? null : type.getLength$().text()));
    } else if (column instanceof $Binary) {
        final $Binary type = ($Binary) column;
        builder.append(getDialect().compileBinary(type.getVarying$() != null && type.getVarying$().text(), type.getLength$() == null ? null : type.getLength$().text()));
    } else if (column instanceof $Blob) {
        final $Blob type = ($Blob) column;
        builder.append(getDialect().compileBlob(type.getLength$() == null ? null : type.getLength$().text()));
    } else if (column instanceof $Clob) {
        final $Clob type = ($Clob) column;
        builder.append(getDialect().compileClob(type.getLength$() == null ? null : type.getLength$().text()));
    } else if (column instanceof $Integer) {
        builder.append(createIntegerColumn(($Integer) column));
    } else if (column instanceof $Float) {
        final $Float type = ($Float) column;
        builder.append(getDialect().declareFloat(type.getMin$() == null ? null : type.getMin$().text()));
    } else if (column instanceof $Double) {
        final $Double type = ($Double) column;
        builder.append(getDialect().declareDouble(type.getMin$() == null ? null : type.getMin$().text()));
    } else if (column instanceof $Decimal) {
        final $Decimal type = ($Decimal) column;
        builder.append(getDialect().declareDecimal(type.getPrecision$() == null ? null : type.getPrecision$().text(), type.getScale$() == null ? null : type.getScale$().text(), type.getMin$() == null ? null : type.getMin$().text()));
    } else if (column instanceof $Date) {
        builder.append(getDialect().declareDate());
    } else if (column instanceof $Time) {
        final $Time type = ($Time) column;
        builder.append(getDialect().declareTime(type.getPrecision$() == null ? null : type.getPrecision$().text()));
    } else if (column instanceof $Datetime) {
        final $Datetime type = ($Datetime) column;
        builder.append(getDialect().declareDateTime(type.getPrecision$() == null ? null : type.getPrecision$().text()));
    } else if (column instanceof $Boolean) {
        builder.append(getDialect().declareBoolean());
    } else if (column instanceof $Enum) {
        builder.append(getDialect().declareEnum(($Enum) column, tableNameToEnumToOwner));
    }
    final String autoIncrementFragment = column instanceof $Integer ? $autoIncrement(alterStatements, table, ($Integer) column) : null;
    if (autoIncrementFragment == null || autoIncrementFragment.length() == 0) {
        final String defaultFragment = $default(column);
        if (defaultFragment != null && defaultFragment.length() > 0)
            builder.append(" DEFAULT ").append(defaultFragment);
    }
    final String nullFragment = $null(table, column);
    if (nullFragment != null && nullFragment.length() > 0)
        builder.append(' ').append(nullFragment);
    if (autoIncrementFragment != null && autoIncrementFragment.length() > 0)
        builder.append(' ').append(autoIncrementFragment);
    return new CreateStatement(builder.toString());
}
Also used : org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Char(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Char) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Decimal(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Decimal) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Float(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Float) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Double(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Double) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Enum(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Enum) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Boolean(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Boolean) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Clob(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Clob) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Binary(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Binary)

Example 38 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime in project jaxdb by jaxdb.

the class SQLiteDecompiler method makeColumn.

@Override
$Column makeColumn(final String columnName, final String typeName, final long size, final int decimalDigits, final String _default, final Boolean nullable, final Boolean autoIncrement) {
    final $Column column;
    if (typeName.startsWith("BIGINT")) {
        final $Bigint type = newColumn($Bigint.class);
        if (size != 2000000000)
            type.setPrecision$(new $Bigint.Precision$((byte) size));
        if (_default != null)
            type.setDefault$(new $Bigint.Default$(Long.valueOf(_default)));
        if (autoIncrement != null && autoIncrement)
            type.setGenerateOnInsert$(new $Bigint.GenerateOnInsert$($Integer.GenerateOnInsert$.AUTO_5FINCREMENT));
        column = type;
    } else if (typeName.startsWith("BINARY")) {
        final $Binary type = newColumn($Binary.class);
        final Long length = getLength(typeName);
        if (length != null)
            type.setLength$(new $Binary.Length$(length));
        column = type;
    } else if (typeName.startsWith("BLOB")) {
        final $Blob type = newColumn($Blob.class);
        final Long length = getLength(typeName);
        if (length != null)
            type.setLength$(new $Blob.Length$(length));
        column = type;
    } else if ("BOOLEAN".equals(typeName)) {
        final $Boolean type = newColumn($Boolean.class);
        if (_default != null)
            type.setDefault$(new $Boolean.Default$(Boolean.parseBoolean(_default)));
        column = type;
    } else if (typeName.startsWith("VARCHAR") || typeName.startsWith("CHARACTER")) {
        final $Char type = newColumn($Char.class);
        if (typeName.startsWith("VARCHAR"))
            type.setVarying$(new $Char.Varying$(true));
        final Long length = getLength(typeName);
        if (length != null)
            type.setLength$(new $Char.Length$(length));
        if (_default != null)
            type.setDefault$(new $Char.Default$(_default.substring(1, _default.length() - 1)));
        column = type;
    } else if (typeName.startsWith("TEXT")) {
        final $Clob type = newColumn($Clob.class);
        final Long length = getLength(typeName);
        if (length != null)
            type.setLength$(new $Clob.Length$(length));
        column = type;
    } else if ("DATE".equals(typeName)) {
        final $Date type = newColumn($Date.class);
        if (_default != null)
            type.setDefault$(new $Date.Default$(_default.substring(1, _default.length() - 1)));
        column = type;
    } else if ("DATETIME".equals(typeName)) {
        final $Datetime type = newColumn($Datetime.class);
        if (size != 2000000000)
            type.setPrecision$(new $Datetime.Precision$((byte) size));
        if (_default != null)
            type.setDefault$(new $Datetime.Default$(_default.substring(1, _default.length() - 1)));
        column = type;
    } else if (typeName.startsWith("DECIMAL")) {
        final $Decimal type = newColumn($Decimal.class);
        if (!"DECIMAL(15,0)".equals(typeName)) {
            final int open = typeName.indexOf('(');
            if (open > 0) {
                final int comma = typeName.indexOf(',', open + 1);
                if (comma > open) {
                    final int close = typeName.indexOf(')', comma + 1);
                    if (close > comma) {
                        type.setPrecision$(new $Decimal.Precision$(Integer.valueOf(typeName.substring(open + 1, comma).trim())));
                        type.setScale$(new $Decimal.Scale$(Integer.valueOf(typeName.substring(comma + 1, close).trim())));
                    }
                }
            }
        }
        if (_default != null)
            type.setDefault$(new $Decimal.Default$(new BigDecimal(_default)));
        column = type;
    } else if ("DOUBLE".equals(typeName)) {
        final $Double type = newColumn($Double.class);
        if (_default != null)
            type.setDefault$(new $Double.Default$(Double.valueOf(_default)));
        column = type;
    } else // }
    if ("FLOAT".equals(typeName)) {
        final $Float type = newColumn($Float.class);
        if (_default != null)
            type.setDefault$(new $Float.Default$(Float.valueOf(_default)));
        column = type;
    } else if (typeName.startsWith("INT") || typeName.startsWith("MEDIUMINT")) {
        final $Int type = newColumn($Int.class);
        if (size != 2000000000)
            type.setPrecision$(new $Int.Precision$((byte) size));
        if (_default != null)
            type.setDefault$(new $Int.Default$(Integer.valueOf(_default)));
        if ("INTEGER".equals(typeName))
            type.setGenerateOnInsert$(new $Int.GenerateOnInsert$($Integer.GenerateOnInsert$.AUTO_5FINCREMENT));
        column = type;
    } else if ("SMALLINT".equals(typeName)) {
        final $Smallint type = newColumn($Smallint.class);
        if (size != 2000000000)
            type.setPrecision$(new $Smallint.Precision$((byte) size));
        if (_default != null)
            type.setDefault$(new $Smallint.Default$(Short.valueOf(_default)));
        if (autoIncrement != null && autoIncrement)
            type.setGenerateOnInsert$(new $Smallint.GenerateOnInsert$($Integer.GenerateOnInsert$.AUTO_5FINCREMENT));
        column = type;
    } else if ("TIME".equals(typeName)) {
        final $Time type = newColumn($Time.class);
        if (size != 2000000000)
            type.setPrecision$(new $Time.Precision$((byte) size));
        if (_default != null)
            type.setDefault$(new $Time.Default$(_default.substring(1, _default.length() - 1)));
        column = type;
    } else if ("TINYINT".equals(typeName)) {
        final $Tinyint type = newColumn($Tinyint.class);
        if (size != 2000000000)
            type.setPrecision$(new $Tinyint.Precision$((byte) size));
        if (_default != null)
            type.setDefault$(new $Tinyint.Default$(Byte.valueOf(_default)));
        if (autoIncrement != null && autoIncrement)
            type.setGenerateOnInsert$(new $Tinyint.GenerateOnInsert$($Integer.GenerateOnInsert$.AUTO_5FINCREMENT));
        column = type;
    } else {
        throw new UnsupportedOperationException("Unsupported column type: " + typeName);
    }
    column.setName$(new $Column.Name$(columnName));
    if (nullable != null && !nullable)
        column.setNull$(new $Column.Null$(false));
    return column;
}
Also used : org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Char(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Char) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Decimal(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Decimal) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Tinyint(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Tinyint) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Boolean(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Boolean) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Clob(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Clob) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Float(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Float) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Double(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Double) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Tinyint(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Tinyint) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint) BigDecimal(java.math.BigDecimal) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Int(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Int) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Binary(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Binary)

Aggregations

LinkedHashSet (java.util.LinkedHashSet)20 Set (java.util.Set)10 Before (org.junit.Before)10 Test (org.junit.Test)10 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Binary (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Binary)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Boolean (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Boolean)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Char (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Char)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Clob (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Clob)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Decimal (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Decimal)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Double (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Double)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Float (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Float)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Int (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Int)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time)4 BooleanValue (com.google.api.ads.admanager.jaxws.v202205.BooleanValue)3 DateTime (com.google.api.ads.admanager.jaxws.v202205.DateTime)3