use of db.JDBCColumn in project common by zenlunatics.
the class MailLists method init.
// --------------------------------------------------------------------------
@Override
public void init(DBConnection db) {
JDBCTable table_def = new JDBCTable().add(new JDBCColumn("active", Types.BOOLEAN).setDefaultValue(true)).add(new JDBCColumn("allow_from_outside", Types.BOOLEAN).setDefaultValue(false)).add(new JDBCColumn("allow_from_outside_subscribers", Types.BOOLEAN).setDefaultValue(false)).add(new JDBCColumn("announce_only", Types.BOOLEAN)).add(new JDBCColumn("archive", Types.BOOLEAN).setDefaultValue(true)).add(new JDBCColumn("archives_public", Types.BOOLEAN).setDefaultValue(true)).add(new JDBCColumn("footer", Types.VARCHAR)).add(new JDBCColumn("host", Types.VARCHAR)).add(new JDBCColumn("name", Types.VARCHAR)).add(new JDBCColumn("password", Types.VARCHAR)).add(new JDBCColumn("send_to", Types.VARCHAR)).add(new JDBCColumn("store_on_disk", Types.BOOLEAN)).add(new JDBCColumn("username", Types.VARCHAR));
db.getTable("mail_lists", true).createMissingColumns(table_def, db).dropExtraColumns(table_def, db);
db.createManyToManyLinkTable("mail_lists", "people");
db.createTable("mail_lists_digest", false, "mail_lists_id INTEGER REFERENCES mail_lists ON DELETE CASCADE,people_id INTEGER REFERENCES people ON DELETE CASCADE", null, false);
db.createManyTable("mail_lists", "subscribers", "email VARCHAR(60)");
table_def = new JDBCTable().add(new JDBCColumn("people")).add(new JDBCColumn("email", Types.VARCHAR, 60));
db.getTable("additional_emails", true).createMissingColumns(table_def, db).dropExtraColumns(table_def, db);
Roles.add("mail", m_site, db);
m_site.addUserDropdownItem(new Page("Edit Mail Lists", m_site) {
@Override
public void write(Request request) throws IOException {
request.site.writePageOpen("Edit Mail Lists", request);
request.site.newView("mail_lists", request).writeComponent();
request.close();
}
}.setRole("mail"), db);
}
use of db.JDBCColumn in project common by zenlunatics.
the class ColumnBase method writeInputWithDropdown.
// --------------------------------------------------------------------------
protected static void writeInputWithDropdown(String name, List<String> values, View view, String default_value, Request request) throws IOException {
JDBCColumn jdbc_column = request.db.getTable(view.getViewDef().getFrom()).getColumn(name);
HTMLWriter writer = request.writer;
// flex display is to prevent firefox from expanding div to 100% width
writer.write("<div class=\"input-group\" style=\"display:flex\">");
String id = UUID.randomUUID().toString();
writer.setAttribute("id", id);
if (values.size() > 0)
writer.setAttribute("onkeyup", "fill_choice(this,$(this).getNext().getElement('ul'))");
writer.textInput(name, Integer.toString(jdbc_column.size), getValue(jdbc_column, default_value, view, request));
if (values.size() > 0) {
Dropdown dropdown = new Dropdown(null, "dropdown-toggle", request.writer).setDivClass("input-group-btn").setDropdownMenuRight(true).open();
for (String value : values) dropdown.aOnClick(value, "$(this).ancestor('DIV').getPrevious().value=this.get('text');");
dropdown.close();
}
writer.write("</div>");
}
use of db.JDBCColumn in project common by zenlunatics.
the class ColumnBase method writeInput.
// --------------------------------------------------------------------------
// normally other column types override this method
protected void writeInput(Mode mode, String default_value, View view, Form form, Request request) throws IOException {
JDBCColumn jdbc_column = request.db.getTable(view.getViewDef().getFrom()).getColumn(m_name);
HTMLWriter writer = request.writer;
if (jdbc_column != null && jdbc_column.isBoolean()) {
writer.write("<div class=\"checkbox\" style=\"margin:0;min-height:0;padding-top:0;\"><label style=\"margin:0;\"");
if (m_title != null)
writer.writeAttribute("title", m_title);
writer.write('>');
writer.checkbox(m_name, null, null, mode == View.Mode.EDIT_FORM && view.data().getBoolean(m_name) || mode == View.Mode.ADD_FORM && ("yes".equals(default_value) || "true".equals(default_value)), true);
writer.hiddenInput("db_boolean" + writer.newID(), m_name);
writer.space();
writeLabel(request);
writer.write("</label></div>");
} else {
if (m_title != null)
writer.setAttribute("title", m_title);
writeInput(m_name, default_value, view, request);
}
}
use of db.JDBCColumn in project common by zenlunatics.
the class ColumnBase method _init_.
// --------------------------------------------------------------------------
public static void _init_(DBConnection db) {
JDBCTable table_def = new JDBCTable().add(new JDBCColumn("_views_")).add(new JDBCColumn("type", Types.VARCHAR)).add(new JDBCColumn("type_args", Types.VARCHAR));
DBObject.addColumns(table_def, ColumnBase.class);
db.getTable("_columns_", true).createMissingColumns(table_def, db).dropExtraColumns(table_def, db);
}
use of db.JDBCColumn in project common by zenlunatics.
the class Documents method _newViewDef.
// --------------------------------------------------------------------------
@Override
public ViewDef _newViewDef(String name, Site site) {
if (name.equals("documents")) {
ViewDef view_def = new ViewDef(name);
view_def.setAccessPolicy(new RoleAccessPolicy("docs").add().delete().edit());
view_def.setCenter(false);
view_def.setDefaultOrderBy("title");
view_def.setDialogModes(View.Mode.ADD_FORM, View.Mode.EDIT_FORM, View.Mode.READ_ONLY_FORM);
view_def.setRecordName("Document");
view_def.setRichTextEditId("db_filename_text");
view_def.setShowDoneLink(true);
view_def.setTimestampRecords(true);
ArrayList<String> column_names = new ArrayList<String>();
column_names.add("title");
column_names.add("type");
column_names.add("filename");
if (m_extra_columns != null)
for (JDBCColumn column : m_extra_columns) column_names.add(column.name);
view_def.setColumnNamesForm(column_names.toArray(new String[column_names.size()]));
view_def.setColumnNamesTable(new String[] { "filename" });
FileColumn file_column = new FileColumn("filename", view_def, "documents").setTitleColumn("title");
if (m_dir_column != null)
file_column.setDirColumn(m_dir_column);
view_def.setColumn(file_column.setDisplayName("document").setPrintUrl("/Documents?db_key_value="));
view_def.setColumn(new Column("title").setIsRequired(true).setOrderBy("lower(title)"));
view_def.setColumn(((Options) site.getObjects("documents_types")).newColumn("type"));
return addHooks(view_def);
}
if (name.equals("documents_types"))
return site.getObjects(name).newViewDef(name, site).setRecordName("Type").setShowNumRecords(false).setColumn(new Column("text").setIsRequired(true));
return null;
}
Aggregations