use of db.Select in project common by zenlunatics.
the class EventProvider method selectEvents.
// --------------------------------------------------------------------------
private ResultSet selectEvents(Calendar from, Calendar to, String category, String location, int num_events, Request request) {
if (category != null && !m_events_have_category)
return null;
if (location != null && m_locations == null)
return null;
Select q = new Select("*").from(m_events_table).where("date>='" + DBConnection.dateString(from) + "'").orderBy(num_events > 0 ? "date" : null);
if (to != null)
q.andWhere("date<'" + DBConnection.dateString(to) + "'");
andFilters(q);
if (category != null && !category.equals("All"))
q.andWhere(m_events_table + "_categories_id=" + request.db.lookupInt("id", m_events_table + "_categories", "text='" + DBConnection.escape(category) + "'", -1));
if (location != null && !location.equals("All")) {
String locations_table = getLocationsTable();
q.andWhere(locations_table + "_id=" + request.db.lookupInt("id", locations_table, "text='" + DBConnection.escape(location) + "'", -1));
}
if (m_events_can_repeat)
q.andWhere("repeat='never'");
if (num_events > 0)
q.limit(num_events);
return request.db.select(q.toString());
}
use of db.Select in project common by zenlunatics.
the class EventProvider method writeFilters.
// --------------------------------------------------------------------------
void writeFilters(Request request) throws IOException {
HTMLWriter writer = request.writer;
writer.write("<span id=\"calendar_filters\">");
if (m_events_have_category) {
writer.write("<span>View categories: ");
web.Select select = new web.Select("calendar_categories", m_categories);
select.addFirstOption("All", "All");
select.setOnChange("$('calendar').calendar.set_category(this.options[this.selectedIndex].text)");
select.write(request);
writer.write("</span> ");
}
if (m_events_have_location) {
writer.write("<span>View locations: ");
web.Select select = new web.Select("calendar_locations", m_locations);
select.addFirstOption("All", "All");
select.setOnChange("$('calendar').calendar.set_location(this.options[this.selectedIndex].text)");
select.write(request);
writer.write("</span> ");
}
writer.write("</span>");
}
use of db.Select in project common by zenlunatics.
the class EventProvider method addAllEvents.
// --------------------------------------------------------------------------
public void addAllEvents(ArrayList<Event> events, Request request) {
String where = "date>=current_date";
if (m_events_can_repeat)
where += " OR (repeat!='never' AND (end_date IS NULL OR end_date>=current_date))";
Select query = new Select("*").from(m_events_table).where(where);
andFilters(query);
ResultSet rs = request.db.select(query);
try {
while (rs.next()) events.add(readEvent(rs, request));
rs.getStatement().close();
} catch (SQLException e) {
request.abort(e);
}
if (m_event_providers != null)
for (EventProvider event_provider : m_event_providers) if (event_provider.isActive())
event_provider.addAllEvents(events, request);
}
use of db.Select in project common by zenlunatics.
the class EventViewDef method newView.
// --------------------------------------------------------------------------
@Override
public View newView(Request request) {
View view = super.newView(request);
String id = view.getKeyValue();
if (m_support_registrations && view.getMode() != View.Mode.ADD_FORM && id != null && request.db.lookupBoolean(new Select("register_people").from(m_from).whereIdEquals(id)))
view.addRelationship(new OneToMany(m_name + "_registrations"));
return view;
}
use of db.Select in project common by zenlunatics.
the class Design method getHead.
// --------------------------------------------------------------------------
public Head getHead(Request request) throws IOException {
Head head = new Head(request, request.site.getDisplayName());
List<String> css_files = request.db.readValues(new Select("filename").from("designs_css_files").where("designs_id=" + m_id));
for (String css_file : css_files) head.styleSheet(css_file);
List<String> js_files = request.db.readValues(new Select("filename").from("designs_js_files").where("designs_id=" + m_id));
for (String js_file : js_files) head.script(js_file);
return head;
}
Aggregations