Search in sources :

Example 16 with GetActivityForm

use of org.activityinfo.legacy.shared.command.GetActivityForm in project activityinfo by bedatadriven.

the class KmlDataServlet method writeDocument.

protected void writeDocument(PrintWriter out, int activityId) throws SAXException, TransformerConfigurationException {
    XmlBuilder xml = new XmlBuilder(new StreamResult(out));
    List<SiteDTO> sites = querySites(activityId);
    xml.startDocument();
    KMLNamespace kml = new KMLNamespace(xml);
    kml.startKml();
    ActivityFormDTO activity = dispatcher.execute(new GetActivityForm(activityId));
    kml.startDocument();
    kml.startStyle().at("id", "noDirectionsStyle");
    kml.startBalloonStyle();
    kml.text("$[description]");
    xml.close();
    xml.close();
    for (SiteDTO pm : sites) {
        if (pm.hasLatLong()) {
            kml.startPlaceMark();
            kml.styleUrl("#noDirectionsStyle");
            kml.name(pm.getLocationName());
            kml.startSnippet();
            xml.cdata(renderSnippet(activity, pm));
            // Snippet
            xml.close();
            kml.startDescription();
            xml.cdata(renderDescription(activity, pm));
            // Description
            xml.close();
            kml.startTimeSpan();
            if (pm.getDate1() != null) {
                kml.begin(pm.getDate1().atMidnightInMyTimezone());
                kml.end(pm.getDate2().atMidnightInMyTimezone());
                // Timespan
                xml.close();
            }
            kml.startPoint();
            kml.coordinates(pm.getLongitude(), pm.getLatitude());
            // Point
            xml.close();
            // Placemark
            xml.close();
        }
    }
    // Document
    xml.close();
    // kml
    xml.close();
    xml.endDocument();
}
Also used : StreamResult(javax.xml.transform.stream.StreamResult) ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) XmlBuilder(org.activityinfo.server.endpoint.kml.xml.XmlBuilder) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm)

Aggregations

GetActivityForm (org.activityinfo.legacy.shared.command.GetActivityForm)16 ActivityFormDTO (org.activityinfo.legacy.shared.model.ActivityFormDTO)10 Test (org.junit.Test)8 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)6 UserDatabaseDTO (org.activityinfo.legacy.shared.model.UserDatabaseDTO)4 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)3 Delete (org.activityinfo.legacy.shared.command.Delete)3 AttributeGroupDTO (org.activityinfo.legacy.shared.model.AttributeGroupDTO)3 SchemaDTO (org.activityinfo.legacy.shared.model.SchemaDTO)3 HashMap (java.util.HashMap)2 SiteDTO (org.activityinfo.legacy.shared.model.SiteDTO)2 MaskingAsyncMonitor (org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 StreamResult (javax.xml.transform.stream.StreamResult)1 CreateEntity (org.activityinfo.legacy.shared.command.CreateEntity)1 Filter (org.activityinfo.legacy.shared.command.Filter)1 UpdateEntity (org.activityinfo.legacy.shared.command.UpdateEntity)1 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)1 ActivityDTO (org.activityinfo.legacy.shared.model.ActivityDTO)1