Search in sources :

Example 41 with SiteDTO

use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.

the class SiteDialogLauncher method chooseLocationThenAddSite.

private void chooseLocationThenAddSite(final ActivityDTO activity, final SiteDialogCallback callback) {
    LocationDialog dialog = new LocationDialog(dispatcher, activity.getDatabase().getCountry(), activity.getLocationType());
    dialog.show(new LocationDialog.Callback() {

        @Override
        public void onSelected(LocationDTO location, boolean isNew) {
            SiteDTO newSite = new SiteDTO();
            newSite.setActivityId(activity.getId());
            newSite.setLocation(location);
            SiteDialog dialog = new SiteDialog(dispatcher, activity);
            dialog.showNew(newSite, location, isNew, callback);
        }
    });
}
Also used : LocationDialog(org.activityinfo.client.page.entry.location.LocationDialog) SiteDTO(org.activityinfo.shared.dto.SiteDTO) LocationDTO(org.activityinfo.shared.dto.LocationDTO)

Example 42 with SiteDTO

use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.

the class SiteExporter method createDataRows.

private void createDataRows(ActivityDTO activity, Filter filter, Sheet sheet) {
    int rowIndex = 2;
    for (SiteDTO site : querySites(activity, filter)) {
        Row row = sheet.createRow(rowIndex++);
        int column = 0;
        createCell(row, column++, site.getDate1());
        createCell(row, column++, site.getDate2());
        createCell(row, column++, site.getPartnerName());
        createCell(row, column++, site.getLocationName());
        createCell(row, column++, site.getLocationAxe());
        for (Integer indicatorId : indicators) {
            createIndicatorValueCell(row, column++, site.getIndicatorValue(indicatorId));
        }
        for (Integer attribId : attributes) {
            Boolean value = site.getAttributeValue(attribId);
            if (value != null) {
                Cell valueCell = createCell(row, column, value);
                valueCell.setCellStyle(attribValueStyle);
            }
            column++;
        }
        for (Integer levelId : levels) {
            AdminEntityDTO entity = site.getAdminEntity(levelId);
            if (entity != null) {
                createCell(row, column, "");
                createCell(row, column + 1, entity.getName());
            }
            column += 2;
        }
        if (site.hasLatLong()) {
            createCoordCell(row, column, site.getLongitude());
            createCoordCell(row, column + 1, site.getLatitude());
        }
        column += 2;
        if (!Strings.isNullOrEmpty(site.getComments())) {
            createCell(row, column, site.getComments());
        }
        column++;
    }
}
Also used : AdminEntityDTO(org.activityinfo.shared.dto.AdminEntityDTO) SiteDTO(org.activityinfo.shared.dto.SiteDTO) Row(org.apache.poi.ss.usermodel.Row) Cell(org.apache.poi.ss.usermodel.Cell)

Example 43 with SiteDTO

use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.

the class KmlDataServlet method writeDocument.

protected void writeDocument(User user, PrintWriter out, int actvityId) throws TransformerConfigurationException, SAXException, CommandException {
    // TODO: rewrite using FreeMarker
    DomainFilters.applyUserFilter(user, entityManager.get());
    XmlBuilder xml = new XmlBuilder(new StreamResult(out));
    SchemaDTO schema = dispatcher.execute(new GetSchema());
    List<SiteDTO> sites = querySites(user, schema, actvityId);
    xml.startDocument();
    KMLNamespace kml = new KMLNamespace(xml);
    kml.startKml();
    ActivityDTO activity = schema.getActivityById(actvityId);
    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) XmlBuilder(org.activityinfo.server.util.xml.XmlBuilder) SiteDTO(org.activityinfo.shared.dto.SiteDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema)

Example 44 with SiteDTO

use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.

the class SitesResources method queryPoints.

@GET
@Path("/points")
public Response queryPoints(@QueryParam("activity") List<Integer> activityIds, @QueryParam("database") List<Integer> databaseIds, @QueryParam("callback") String callback) throws JsonGenerationException, IOException {
    Filter filter = new Filter();
    filter.addRestriction(DimensionType.Activity, activityIds);
    filter.addRestriction(DimensionType.Database, databaseIds);
    List<SiteDTO> sites = dispatcher.execute(new GetSites(filter)).getData();
    StringWriter writer = new StringWriter();
    JsonGenerator json = Jackson.createJsonFactory(writer);
    writeGeoJson(sites, json);
    if (Strings.isNullOrEmpty(callback)) {
        return Response.ok(writer.toString()).type(MediaType.APPLICATION_JSON_TYPE).build();
    } else {
        return Response.ok(callback + "(" + writer.toString() + ");").type("application/javascript; charset=UTF-8").build();
    }
}
Also used : StringWriter(java.io.StringWriter) Filter(org.activityinfo.shared.command.Filter) GetSites(org.activityinfo.shared.command.GetSites) JsonGenerator(org.codehaus.jackson.JsonGenerator) SiteDTO(org.activityinfo.shared.dto.SiteDTO) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 45 with SiteDTO

use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.

the class SitesResources method query.

@GET
@Produces(MediaType.APPLICATION_JSON)
public String query(@QueryParam("activity") List<Integer> activityIds, @QueryParam("database") List<Integer> databaseIds, @QueryParam("format") String format) throws IOException {
    Filter filter = new Filter();
    filter.addRestriction(DimensionType.Activity, activityIds);
    filter.addRestriction(DimensionType.Database, databaseIds);
    List<SiteDTO> sites = dispatcher.execute(new GetSites(filter)).getData();
    StringWriter writer = new StringWriter();
    JsonGenerator json = Jackson.createJsonFactory(writer);
    writeJson(sites, json);
    return writer.toString();
}
Also used : StringWriter(java.io.StringWriter) Filter(org.activityinfo.shared.command.Filter) GetSites(org.activityinfo.shared.command.GetSites) JsonGenerator(org.codehaus.jackson.JsonGenerator) SiteDTO(org.activityinfo.shared.dto.SiteDTO) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

SiteDTO (org.activityinfo.shared.dto.SiteDTO)71 Test (org.junit.Test)32 GetSites (org.activityinfo.shared.command.GetSites)16 SiteResult (org.activityinfo.shared.command.result.SiteResult)11 CreateSite (org.activityinfo.shared.command.CreateSite)9 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)8 SortInfo (com.extjs.gxt.ui.client.data.SortInfo)7 ArrayList (java.util.ArrayList)7 CreateResult (org.activityinfo.shared.command.result.CreateResult)7 Date (java.util.Date)6 OnDataSet (org.activityinfo.server.database.OnDataSet)6 PartnerDTO (org.activityinfo.shared.dto.PartnerDTO)6 AiLatLng (org.activityinfo.shared.report.content.AiLatLng)6 ColumnConfig (com.extjs.gxt.ui.client.widget.grid.ColumnConfig)5 ColumnData (com.extjs.gxt.ui.client.widget.grid.ColumnData)5 KeyGenerator (org.activityinfo.client.local.command.handler.KeyGenerator)5 UpdateSite (org.activityinfo.shared.command.UpdateSite)5 LocationDTO (org.activityinfo.shared.dto.LocationDTO)5 PointValue (org.activityinfo.shared.report.model.PointValue)5 SqlResultCallback (com.bedatadriven.rebar.sql.client.SqlResultCallback)4