Search in sources :

Example 11 with ActivityFormDTO

use of org.activityinfo.legacy.shared.model.ActivityFormDTO in project activityinfo by bedatadriven.

the class DeleteTest method testDeleteActivity.

@Test
public void testDeleteActivity() throws CommandException {
    ActivityFormDTO form = execute(new GetActivityForm(1));
    execute(new Delete(form));
    execute(new Delete("Activity", 4));
    SchemaDTO schema = execute(new GetSchema());
    assertNull("delete by entity reference", schema.getActivityById(1));
    assertNull("delete by id", schema.getActivityById(4));
}
Also used : Delete(org.activityinfo.legacy.shared.command.Delete) ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) Test(org.junit.Test)

Example 12 with ActivityFormDTO

use of org.activityinfo.legacy.shared.model.ActivityFormDTO in project activityinfo by bedatadriven.

the class DeleteTest method testDeleteAttribute.

@Test
public void testDeleteAttribute() throws CommandException {
    ActivityFormDTO form = execute(new GetActivityForm(1));
    execute(new Delete(form.getAttributeById(1)));
    form = execute(new GetActivityForm(1));
    assertNull(form.getAttributeById(1));
}
Also used : Delete(org.activityinfo.legacy.shared.command.Delete) ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm) Test(org.junit.Test)

Example 13 with ActivityFormDTO

use of org.activityinfo.legacy.shared.model.ActivityFormDTO in project activityinfo by bedatadriven.

the class AttributeGroupFilterWidgets method draw.

public void draw(final Filter filter) {
    final Filter value = new Filter(filter);
    value.clearRestrictions(DIMENSION_TYPE);
    // prevents executing the same command needlessly
    if (prevFilter == null || !prevFilter.equals(filter)) {
        prevFilter = filter;
        Log.debug("AttributeGroupFilterWidgets called for filter " + filter);
        service.execute(new GetActivityForms(filter), new AsyncCallback<ActivityFormResults>() {

            @Override
            public void onFailure(Throwable caught) {
                GWT.log("Failed to load schema", caught);
            }

            @Override
            public void onSuccess(final ActivityFormResults forms) {
                // clean up old widgets
                for (AttributeGroupFilterWidget widget : widgets) {
                    panel.remove(widget);
                }
                // create new widgets, one for each attributegroup.
                // remember the old selection
                Set<Integer> selection = getSelectedIds();
                widgets = new ArrayList<AttributeGroupFilterWidget>();
                Set<String> attributesByName = Sets.newHashSet();
                for (ActivityFormDTO form : forms.getData()) {
                    for (AttributeGroupDTO group : form.getAttributeGroups()) {
                        String key = group.getName().toLowerCase();
                        if (!attributesByName.contains(key)) {
                            AttributeGroupFilterWidget widget = new AttributeGroupFilterWidget(group);
                            widget.setSelection(selection);
                            if (valueChangeHandler != null) {
                                widget.addValueChangeHandler(valueChangeHandler);
                            }
                            panel.add(widget);
                            widgets.add(widget);
                            attributesByName.add(key);
                        }
                    }
                }
                if (drawCallback != null) {
                    drawCallback.onSuccess(null);
                }
            }
        });
    }
}
Also used : AttributeGroupDTO(org.activityinfo.legacy.shared.model.AttributeGroupDTO) ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) Filter(org.activityinfo.legacy.shared.command.Filter) GetActivityForms(org.activityinfo.legacy.shared.command.GetActivityForms) ActivityFormResults(org.activityinfo.legacy.shared.command.result.ActivityFormResults)

Example 14 with ActivityFormDTO

use of org.activityinfo.legacy.shared.model.ActivityFormDTO 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

ActivityFormDTO (org.activityinfo.legacy.shared.model.ActivityFormDTO)14 GetActivityForm (org.activityinfo.legacy.shared.command.GetActivityForm)10 Test (org.junit.Test)9 AttributeGroupDTO (org.activityinfo.legacy.shared.model.AttributeGroupDTO)5 SchemaDTO (org.activityinfo.legacy.shared.model.SchemaDTO)4 UserDatabaseDTO (org.activityinfo.legacy.shared.model.UserDatabaseDTO)4 Delete (org.activityinfo.legacy.shared.command.Delete)3 SiteDTO (org.activityinfo.legacy.shared.model.SiteDTO)3 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)2 HashMap (java.util.HashMap)2 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)2 ActivityFormResults (org.activityinfo.legacy.shared.command.result.ActivityFormResults)2 SqlResultCallback (com.bedatadriven.rebar.sql.client.SqlResultCallback)1 SqlResultSet (com.bedatadriven.rebar.sql.client.SqlResultSet)1 SqlResultSetRow (com.bedatadriven.rebar.sql.client.SqlResultSetRow)1 SqlTransaction (com.bedatadriven.rebar.sql.client.SqlTransaction)1 Function (com.google.common.base.Function)1 ArrayList (java.util.ArrayList)1 Nullable (javax.annotation.Nullable)1 StreamResult (javax.xml.transform.stream.StreamResult)1