use of org.activityinfo.shared.dto.AdminLevelDTO in project activityinfo by bedatadriven.
the class ColumnBindingFactory method forActivity.
public static List<ColumnBinding> forActivity(ActivityDTO activity) {
List<ColumnBinding> bindings = Lists.newArrayList();
bindings.add(Ignore.INSTANCE);
bindings.add(new DateBinding());
for (AdminLevelDTO level : activity.getAdminLevels()) {
bindings.add(new AdminBinding(level));
}
if (!activity.getLocationType().isAdminLevel()) {
bindings.add(new LocationNameBinding(activity.getLocationType()));
}
for (IndicatorDTO indicator : activity.getIndicators()) {
bindings.add(new IndicatorBinding(indicator));
}
for (AttributeGroupDTO attributeGroup : activity.getAttributeGroups()) {
bindings.add(new AttributeBinding(attributeGroup));
}
bindings.add(new CommentsBinding());
return bindings;
}
use of org.activityinfo.shared.dto.AdminLevelDTO in project activityinfo by bedatadriven.
the class AdminColumnRenderer method render.
private Object render(SiteDTO model) {
StringBuilder qtip = new StringBuilder();
SafeHtmlBuilder summary = new SafeHtmlBuilder();
// we use this set to keep track of names that we've added
// to the summary to avoid duplication that is common between
// territories, zones de sante, provinces and districts, etc
seen.clear();
int summaryLines = 0;
for (AdminLevelDTO level : levels) {
AdminEntityDTO entity = model.getAdminEntity(level.getId());
if (entity != null) {
String name = entity.getName();
if (qtip.length() > 0) {
qtip.append("<br>");
}
qtip.append(level.getName()).append(": ").append(name);
if (summaryLines < 3 && !seen.contains(name)) {
if (summaryLines > 0) {
summary.appendHtmlConstant("<br/>");
}
summary.appendEscaped(name);
seen.add(name);
summaryLines++;
}
}
}
// return summary.toSafeHtml().asString();
return ColumnTemplates.INSTANCE.adminCell(qtip.toString(), summary.toSafeHtml()).asString();
}
use of org.activityinfo.shared.dto.AdminLevelDTO in project activityinfo by bedatadriven.
the class BoundLocationSection method newLocation.
private void newLocation() {
location = new LocationDTO(location);
location.setId(new KeyGenerator().generateInt());
location.setName(leafComboBox.getValue().getName());
for (AdminLevelDTO level : adminFieldSet.getAdminLevels()) {
location.setAdminEntity(level.getId(), adminFieldSet.getAdminEntity(level));
}
}
use of org.activityinfo.shared.dto.AdminLevelDTO in project activityinfo by bedatadriven.
the class SiteRenderer method renderLocation.
public String renderLocation(SiteDTO site, ActivityDTO activity) {
StringBuilder html = new StringBuilder();
html.append("<table cellspacing='0'>");
if (!activity.getLocationType().isAdminLevel()) {
html.append("<tr><td>");
html.append(activity.getLocationType().getName()).append(": ");
html.append("</td><td>");
html.append(site.getLocationName());
if (!Strings.isNullOrEmpty(site.getLocationAxe())) {
html.append("<br>").append(site.getLocationAxe());
}
html.append("</td></tr>");
}
for (AdminLevelDTO level : activity.getAdminLevels()) {
AdminEntityDTO entity = site.getAdminEntity(level.getId());
if (entity != null) {
html.append("<tr><td>");
html.append(level.getName()).append(":</td><td>");
html.append(entity.getName());
html.append("</td></tr>");
}
}
html.append("</table>");
return html.toString();
}
use of org.activityinfo.shared.dto.AdminLevelDTO in project activityinfo by bedatadriven.
the class LocationForm method saveNewLocation.
private void saveNewLocation() {
if (coordinateFields.validate() && nameField.validate()) {
LocationDTO newLocation = new LocationDTO();
newLocation.setId(new KeyGenerator().generateInt());
newLocation.setLocationTypeId(locationType.getId());
newLocation.setName(nameField.getValue());
newLocation.setAxe(axeField.getValue());
newLocation.setLatitude(coordinateFields.getLatitudeField().getValue());
newLocation.setLongitude(coordinateFields.getLongitudeField().getValue());
for (AdminLevelDTO level : adminPresenter.getAdminLevels()) {
newLocation.setAdminEntity(level.getId(), adminPresenter.getAdminEntity(level));
}
newLocationPresenter.accept(newLocation);
}
}
Aggregations