Search in sources :

Example 1 with IValidateName

use of com.servoy.j2db.persistence.IValidateName in project servoy-client by Servoy.

the class I18NMessagesTable method createMessagesTable.

public static ITable createMessagesTable(IServerInternal server, String tablename, int primaryKeySequenceType) throws RepositoryException, SQLException {
    // Create the table in the repository.
    IValidateName validator = DummyValidator.INSTANCE;
    ITable table = server.createNewTable(validator, tablename);
    if (primaryKeySequenceType == ColumnInfo.UUID_GENERATOR) {
        Column column = table.createNewColumn(validator, "message_id", IColumnTypes.TEXT, 36);
        column.setDatabasePK(true);
        column.setSequenceType(primaryKeySequenceType);
        column.setFlag(IBaseColumn.UUID_COLUMN, true);
    } else {
        Column column = table.createNewColumn(validator, "message_id", Types.INTEGER, 0, 0, false, true);
        column.setSequenceType(primaryKeySequenceType);
    }
    table.createNewColumn(validator, "message_key", Types.VARCHAR, 150, 0, false);
    Column messageLanguage = table.createNewColumn(validator, "message_language", Types.VARCHAR, 150, 0, true);
    table.createNewColumn(validator, "message_value", Types.VARCHAR, 2000, 0, true);
    server.syncTableObjWithDB(table, false, false);
    try {
        server.createIndex(table, table.getName() + "_m_l", new Column[] { messageLanguage }, false);
    } catch (Exception e) {
        Debug.error("Failed to create an index on the messages table", e);
    }
    return table;
}
Also used : IBaseColumn(com.servoy.base.persistence.IBaseColumn) Column(com.servoy.j2db.persistence.Column) ITable(com.servoy.j2db.persistence.ITable) IValidateName(com.servoy.j2db.persistence.IValidateName) SQLException(java.sql.SQLException) RepositoryException(com.servoy.j2db.persistence.RepositoryException)

Aggregations

IBaseColumn (com.servoy.base.persistence.IBaseColumn)1 Column (com.servoy.j2db.persistence.Column)1 ITable (com.servoy.j2db.persistence.ITable)1 IValidateName (com.servoy.j2db.persistence.IValidateName)1 RepositoryException (com.servoy.j2db.persistence.RepositoryException)1 SQLException (java.sql.SQLException)1