use of db.JDBCColumn in project common by zenlunatics.
the class News method init.
// --------------------------------------------------------------------------
@Override
public void init(DBConnection db) {
JDBCTable table_def = new JDBCTable().add(new JDBCColumn("provider", Types.VARCHAR)).add(new JDBCColumn("item_id", Types.INTEGER)).add(new JDBCColumn("_owner_", "people")).add(new JDBCColumn("_timestamp_", Types.TIMESTAMP)).add(new JDBCColumn("last_update", Types.TIMESTAMP));
for (JDBCColumn column : m_additional_columns) table_def.add(column);
db.getTable("news", true).createMissingColumns(table_def, db).dropExtraColumns(table_def, db);
}
use of db.JDBCColumn in project common by zenlunatics.
the class NewsFeed method init.
// --------------------------------------------------------------------------
@Override
public void init(DBConnection db) {
JDBCTable table_def = new JDBCTable().add(new JDBCColumn("_owner_", "people")).add(new JDBCColumn("text", Types.VARCHAR)).add(new JDBCColumn("_timestamp_", Types.TIMESTAMP));
addColumns(table_def);
db.getTable(m_table, true).createMissingColumns(table_def, db).dropExtraColumns(table_def, db);
}
use of db.JDBCColumn in project common by zenlunatics.
the class Discussions method init.
// --------------------------------------------------------------------------
@Override
public void init(DBConnection db) {
JDBCTable table_def = new JDBCTable().add(new JDBCColumn("title", Types.VARCHAR, 60)).add(new JDBCColumn("text", Types.VARCHAR)).add(new JDBCColumn("_timestamp_", Types.TIMESTAMP)).add(new JDBCColumn("_owner_", "people"));
addColumns(table_def);
db.getTable(m_table, true).createMissingColumns(table_def, db).dropExtraColumns(table_def, db);
db.createManyTable(m_table, m_table + "_attachments", "filename VARCHAR");
}
use of db.JDBCColumn in project common by zenlunatics.
the class Documents method init.
// --------------------------------------------------------------------------
@Override
public void init(DBConnection db) {
JDBCTable table_def = new JDBCTable().add(new JDBCColumn("filename", Types.VARCHAR, 60)).add(new JDBCColumn("title", Types.VARCHAR, 60)).add(new JDBCColumn("type", Types.VARCHAR)).add(new JDBCColumn("url", Types.BOOLEAN)).add(new JDBCColumn("_timestamp_", Types.TIMESTAMP));
if (m_extra_columns != null)
for (JDBCColumn column : m_extra_columns) table_def.add(column);
addColumns(table_def);
db.getTable("documents", true).createMissingColumns(table_def, db).dropExtraColumns(table_def, db);
db.createTable("documents_types", "text VARCHAR");
m_site.addObjects(new Options(new Select("text").from("documents_types").orderBy("text"), true, m_site).setAllowEditing(true));
Roles.add("docs", m_site, db);
m_site.addUserDropdownItem(new Page("Edit Documents", m_site) {
@Override
public void write(Request request) throws IOException {
request.site.writePageOpen("Edit Documents", request);
request.site.newView("edit documents", request).writeComponent();
request.writer.br();
request.close();
}
}.setRole("docs"), db);
}
use of db.JDBCColumn in project common by zenlunatics.
the class ColumnBase method writeInput.
// --------------------------------------------------------------------------
public static void writeInput(String column_name, String default_value, View view, Request request) throws IOException {
JDBCColumn jdbc_column = request.db.getTable(view.getViewDef().getFrom()).getColumn(column_name);
if (jdbc_column == null)
throw new RuntimeException("column " + column_name + " not found in table " + view.getViewDef().getFrom());
String value = getValue(jdbc_column, default_value, view, request);
HTMLWriter writer = request.writer;
if (jdbc_column.isBinary())
TextAreaColumn.writeTextArea(column_name, DBConnection.decodeBinary(value), 40, 5, view, writer);
else if (jdbc_column.isBoolean()) {
writer.checkbox(column_name, column_name.replace('_', ' '), null, value != null && (value.equals("yes") || value.equals("t")), false);
writer.hiddenInput("db_boolean" + writer.newID(), column_name);
} else if (jdbc_column.isDate())
writer.dateInput(column_name, value);
else if (jdbc_column.isInteger())
writer.numberInput(column_name, null, null, value);
else if (jdbc_column.isText())
writer.textAreaExpanding(column_name, "min-width:100px", value);
else if (jdbc_column.isTime()) {
Calendar time = null;
if (view.getMode() == View.Mode.EDIT_FORM) {
Time t = view.data().getTime(column_name);
if (t != null) {
time = Calendar.getInstance();
time.setTime(t);
}
} else if (value != null)
try {
time = Calendar.getInstance();
time.setTime(new SimpleDateFormat("hh:mm a").parse(value));
} catch (ParseException e) {
}
writer.timeInput(column_name, time);
} else
writer.textInput(column_name, Integer.toString(jdbc_column.size), value);
}
Aggregations