Search in sources :

Example 6 with ColumnFunction

use of com.developmentontheedge.be5.metadata.model.ColumnFunction in project be5 by DevelopmentOnTheEdge.

the class SqlServerTypeManager method getTypeClause.

@Override
public String getTypeClause(ColumnDef column) {
    if (column.getDefaultValue() != null) {
        String defaultValue = getDefaultValue(column);
        ColumnFunction function = new ColumnFunction(defaultValue);
        if (function.isTransformed()) {
            return "";
        }
    }
    return super.getTypeClause(column);
}
Also used : ColumnFunction(com.developmentontheedge.be5.metadata.model.ColumnFunction)

Example 7 with ColumnFunction

use of com.developmentontheedge.be5.metadata.model.ColumnFunction in project be5 by DevelopmentOnTheEdge.

the class OracleTypeManager method getColumnTriggerDefinition.

@Override
public String getColumnTriggerDefinition(ColumnDef column) {
    String defaultValue = column.getDefaultValue();
    if (defaultValue == null)
        return "";
    ColumnFunction function = new ColumnFunction(defaultValue);
    if (ColumnFunction.TRANSFORM_GENERIC.equals(function.getTransform())) {
        return "CREATE OR REPLACE TRIGGER " + getTriggerName(column) + "\nBEFORE INSERT OR UPDATE OF " + normalizeIdentifier(function.getColumnName()) + " ON " + normalizeIdentifier(column.getEntity().getName()) + "\nFOR EACH ROW" + "\nBEGIN" + "\n   :new." + normalizeIdentifier(column.getName()) + " := '" + column.getEntity().getName() + ".' || :new." + normalizeIdentifier(function.getColumnName()) + ";" + "\nEND;\n";
    }
    return "";
}
Also used : ColumnFunction(com.developmentontheedge.be5.metadata.model.ColumnFunction)

Aggregations

ColumnFunction (com.developmentontheedge.be5.metadata.model.ColumnFunction)7 SqlColumnInfo (com.developmentontheedge.be5.metadata.sql.pojo.SqlColumnInfo)3 DbmsConnector (com.developmentontheedge.dbms.DbmsConnector)3 ResultSet (java.sql.ResultSet)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Matcher (java.util.regex.Matcher)3 NoSuchElementException (java.util.NoSuchElementException)1 StringTokenizer (java.util.StringTokenizer)1