Search in sources :

Example 1 with Select

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());
}
Also used : Select(db.Select)

Example 2 with Select

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:&nbsp;");
        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:&nbsp;");
        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>");
}
Also used : HTMLWriter(web.HTMLWriter) Select(db.Select)

Example 3 with Select

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);
}
Also used : SQLException(java.sql.SQLException) Select(db.Select) ResultSet(java.sql.ResultSet)

Example 4 with Select

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;
}
Also used : Select(db.Select) OneToMany(db.OneToMany) View(db.View)

Example 5 with Select

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;
}
Also used : Head(web.Head) Select(db.Select)

Aggregations

Select (db.Select)67 SQLException (java.sql.SQLException)24 ResultSet (java.sql.ResultSet)21 HTMLWriter (web.HTMLWriter)18 ArrayList (java.util.ArrayList)9 JDBCColumn (db.JDBCColumn)7 File (java.io.File)7 IOException (java.io.IOException)6 MessagingException (javax.mail.MessagingException)6 MimeMessage (javax.mail.internet.MimeMessage)6 AdminTask (web.AdminTask)6 FilePathStringBuilder (web.FilePathStringBuilder)6 Person (app.Person)5 JDBCTable (db.JDBCTable)5 NameValuePairs (db.NameValuePairs)5 View (db.View)5 DBObject (db.DBObject)4 ViewDef (db.ViewDef)4 InternetAddress (javax.mail.internet.InternetAddress)4 Page (app.Page)3