use of db.JDBCTable in project common by zenlunatics.
the class Pages method init.
// --------------------------------------------------------------------
@Override
public void init(DBConnection db) {
JDBCTable table_def = new JDBCTable().add(new JDBCColumn("name", Types.VARCHAR));
db.getTable("designs", true).createMissingColumns(table_def, db).dropExtraColumns(table_def, db);
table_def = new JDBCTable().add(new JDBCColumn("designs")).add(new JDBCColumn("description", Types.VARCHAR)).add(new JDBCColumn("type", Types.VARCHAR)).add(new JDBCColumn("data", Types.VARCHAR)).add(new JDBCColumn("_order_", Types.INTEGER));
db.getTable("designs_items", true).createMissingColumns(table_def, db).dropExtraColumns(table_def, db);
table_def = new JDBCTable().add(new JDBCColumn("designs")).add(new JDBCColumn("filename", Types.VARCHAR));
db.getTable("designs_css_files", true).createMissingColumns(table_def, db).dropExtraColumns(table_def, db);
table_def = new JDBCTable().add(new JDBCColumn("designs")).add(new JDBCColumn("filename", Types.VARCHAR));
db.getTable("designs_js_files", true).createMissingColumns(table_def, db).dropExtraColumns(table_def, db);
DBObject.init("pages", Page.class, db);
table_def = new JDBCTable().add(new JDBCColumn("pages")).add(new JDBCColumn("description", Types.VARCHAR)).add(new JDBCColumn("type", Types.VARCHAR)).add(new JDBCColumn("data", Types.VARCHAR)).add(new JDBCColumn("_order_", Types.INTEGER));
db.getTable("pages_items", true).createMissingColumns(table_def, db).dropExtraColumns(table_def, db);
try {
ResultSet rs = db.select(new Select("*").from("pages"));
while (rs.next()) {
Page page = new Page();
DBObject.load(page, rs);
m_pages.put(page.getName().toLowerCase(), page);
}
rs.getStatement().close();
} catch (SQLException e) {
m_site.log(e);
}
}
use of db.JDBCTable in project common by zenlunatics.
the class People method init.
// --------------------------------------------------------------------------
@Override
public void init(DBConnection db) {
JDBCTable table_def = new JDBCTable().add(new JDBCColumn("data", Types.VARCHAR)).add(new JDBCColumn("data_keys", Types.VARCHAR)).add(new JDBCColumn("email", Types.VARCHAR)).add(new JDBCColumn("first", Types.VARCHAR)).add(new JDBCColumn("last", Types.VARCHAR)).add(new JDBCColumn("last_login", Types.TIMESTAMP)).add(new JDBCColumn("password", Types.VARCHAR)).add(new JDBCColumn("user_name", Types.VARCHAR).setUnique(true));
for (JDBCColumn column : m_additional_columns) table_def.add(column);
db.getTable("people", true).matchColumns(table_def, db);
db.createManyTable("people", "user_roles", "user_name VARCHAR REFERENCES people(user_name) ON UPDATE CASCADE, role VARCHAR");
if (!db.exists("people", null)) {
int id = db.insert("people", "first,user_name,password", "'Administrator','admin','admin'");
db.insert("user_roles", "people_id,user_name,role", id + ",'admin','administrator'");
if (m_site.getDefaultRole() != null)
db.insert("user_roles", "people_id,user_name,role", id + ",'admin','" + m_site.getDefaultRole() + "'");
}
Roles.add("people", m_site, db);
}
Aggregations