use of org.activityinfo.shared.report.content.EntityCategory in project activityinfo by bedatadriven.
the class PivotSitesHandlerTest method testIndicatorOrder.
@Test
public void testIndicatorOrder() {
withIndicatorAsDimension();
filter.addRestriction(DimensionType.Indicator, 1);
filter.addRestriction(DimensionType.Indicator, 2);
execute();
assertEquals(2, buckets.size());
Bucket indicator1 = findBucketsByCategory(buckets, indicatorDim, new EntityCategory(1)).get(0);
Bucket indicator2 = findBucketsByCategory(buckets, indicatorDim, new EntityCategory(2)).get(0);
EntityCategory cat1 = (EntityCategory) indicator1.getCategory(indicatorDim);
EntityCategory cat2 = (EntityCategory) indicator2.getCategory(indicatorDim);
assertEquals(2, cat1.getSortOrder().intValue());
assertEquals(OWNER_USER_ID, cat2.getSortOrder().intValue());
}
use of org.activityinfo.shared.report.content.EntityCategory in project activityinfo by bedatadriven.
the class SearchResultItem method setChilds.
public void setChilds(List<Axis> childList) {
for (Axis axis : childList) {
VerticalPanel panelAll = new VerticalPanel();
HorizontalPanel panelChild = new HorizontalPanel();
HorizontalPanel spacer = new HorizontalPanel();
spacer.setWidth(20);
panelChild.add(spacer);
Image image = IconImageBundle.ICONS.activity().createImage();
panelChild.add(image);
panelAll.add(panelChild);
EntityCategory activity = (EntityCategory) axis.getCategory();
Hyperlink link = new Hyperlink(axis.getLabel(), PageStateSerializer.serialize(new DataEntryPlace(Filter.filter().onActivity(activity.getId()))));
link.setStylePrimaryName("link");
panelChild.add(link);
for (Axis childAxis : axis.getChildren()) {
HorizontalPanel panelIndicator = new HorizontalPanel();
HorizontalPanel spacerIndicator = new HorizontalPanel();
spacerIndicator.setWidth(40);
panelIndicator.add(spacerIndicator);
panelIndicator.add(IconImageBundle.ICONS.indicator().createImage());
// Hyperlink linkIndicator = new Hyperlink(childAxis.getLabel(),
// "site-grid/" +
// ((EntityCategory)childAxis.getCategory()).getId());
// linkIndicator.setStylePrimaryName("link");
// panelIndicator.add(linkIndicator);
LabelField labelIndicator = new LabelField(childAxis.getLabel());
panelIndicator.add(labelIndicator);
panelAll.add(panelIndicator);
indicatorCount++;
}
activityCount++;
childPanel.add(panelAll);
}
}
use of org.activityinfo.shared.report.content.EntityCategory in project activityinfo by bedatadriven.
the class PiechartLayerGenerator method calulateSlices.
private void calulateSlices(PointValue pv, SiteDTO site) {
pv.setSlices(new ArrayList<PieMapMarker.SliceValue>());
for (Slice slice : layer.getSlices()) {
EntityCategory indicatorCategory = new EntityCategory(slice.getIndicatorId());
Double value = site.getIndicatorValue(slice.getIndicatorId());
if (value != null && value != 0) {
PieMapMarker.SliceValue sliceValue = new PieMapMarker.SliceValue();
sliceValue.setValue(value);
sliceValue.setCategory(indicatorCategory);
sliceValue.setColor(slice.getColor());
sliceValue.setIndicatorId(slice.getIndicatorId());
pv.getSlices().add(sliceValue);
}
}
}
use of org.activityinfo.shared.report.content.EntityCategory in project activityinfo by bedatadriven.
the class GetPartnersDimensionHandler method execute.
@Override
public void execute(GetPartnersDimension cmd, ExecutionContext context, final AsyncCallback<PartnerResult> callback) {
// if the filter doesn't contain any activity, database or indicator values, just return an empty list
if (!cmd.getFilter().isRestricted(DimensionType.Database) && !cmd.getFilter().isRestricted(DimensionType.Activity) && !cmd.getFilter().isRestricted(DimensionType.Indicator)) {
callback.onSuccess(new PartnerResult());
return;
}
final Dimension dimension = new Dimension(DimensionType.Partner);
PivotSites query = new PivotSites();
query.setFilter(cmd.getFilter());
query.setDimensions(dimension);
query.setValueType(ValueType.DIMENSION);
context.execute(query, new AsyncCallback<PivotSites.PivotResult>() {
@Override
public void onSuccess(PivotSites.PivotResult result) {
Set<PartnerDTO> partners = new HashSet<PartnerDTO>();
for (Bucket bucket : result.getBuckets()) {
EntityCategory category = (EntityCategory) bucket.getCategory(dimension);
if (category == null) {
Log.debug("Partner is null: " + bucket.toString());
} else {
PartnerDTO partner = new PartnerDTO();
partner.setId(category.getId());
partner.setName(category.getLabel());
partners.add(partner);
}
}
// sort partners by name (fallback on id)
List<PartnerDTO> list = new ArrayList<PartnerDTO>(partners);
Collections.sort(list, new Comparator<PartnerDTO>() {
@Override
public int compare(PartnerDTO p1, PartnerDTO p2) {
int result = p1.getName().compareToIgnoreCase(p2.getName());
if (result != 0) {
return result;
} else {
return ((Integer) p1.getId()).compareTo(p2.getId());
}
}
});
callback.onSuccess(new PartnerResult(list));
}
@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
});
}
use of org.activityinfo.shared.report.content.EntityCategory in project activityinfo by bedatadriven.
the class DimensionAdapter method unmarshal.
@Override
public Dimension unmarshal(DimensionElement element) {
Dimension dim = createDim(element);
for (CategoryElement category : element.categories) {
CategoryProperties props = new CategoryProperties();
props.setLabel(category.label);
if (category.color != null) {
props.setColor(decodeColor(category.color));
}
EntityCategory entityCategory = new EntityCategory(Integer.parseInt(category.name));
dim.getCategories().put(entityCategory, props);
dim.getOrdering().add(entityCategory);
}
return dim;
}
Aggregations