Search in sources :

Example 6 with EntityCategory

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());
}
Also used : Bucket(org.activityinfo.shared.command.result.Bucket) EntityCategory(org.activityinfo.shared.report.content.EntityCategory) Test(org.junit.Test)

Example 7 with EntityCategory

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);
    }
}
Also used : VerticalPanel(com.extjs.gxt.ui.client.widget.VerticalPanel) DataEntryPlace(org.activityinfo.client.page.entry.place.DataEntryPlace) HorizontalPanel(com.extjs.gxt.ui.client.widget.HorizontalPanel) Image(com.google.gwt.user.client.ui.Image) EntityCategory(org.activityinfo.shared.report.content.EntityCategory) LabelField(com.extjs.gxt.ui.client.widget.form.LabelField) Axis(org.activityinfo.shared.report.content.PivotTableData.Axis) Hyperlink(com.google.gwt.user.client.ui.Hyperlink)

Example 8 with EntityCategory

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);
        }
    }
}
Also used : Slice(org.activityinfo.shared.report.model.layers.PiechartMapLayer.Slice) PieMapMarker(org.activityinfo.shared.report.content.PieMapMarker) EntityCategory(org.activityinfo.shared.report.content.EntityCategory)

Example 9 with EntityCategory

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);
        }
    });
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) Dimension(org.activityinfo.shared.report.model.Dimension) GetPartnersDimension(org.activityinfo.shared.command.GetPartnersDimension) Comparator(java.util.Comparator) PivotSites(org.activityinfo.shared.command.PivotSites) Bucket(org.activityinfo.shared.command.result.Bucket) ArrayList(java.util.ArrayList) List(java.util.List) EntityCategory(org.activityinfo.shared.report.content.EntityCategory) PartnerResult(org.activityinfo.shared.command.result.PartnerResult)

Example 10 with EntityCategory

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;
}
Also used : CategoryProperties(org.activityinfo.shared.report.model.CategoryProperties) Dimension(org.activityinfo.shared.report.model.Dimension) AttributeGroupDimension(org.activityinfo.shared.report.model.AttributeGroupDimension) AdminDimension(org.activityinfo.shared.report.model.AdminDimension) DateDimension(org.activityinfo.shared.report.model.DateDimension) EntityCategory(org.activityinfo.shared.report.content.EntityCategory)

Aggregations

EntityCategory (org.activityinfo.shared.report.content.EntityCategory)15 Bucket (org.activityinfo.shared.command.result.Bucket)9 Dimension (org.activityinfo.shared.report.model.Dimension)9 AdminDimension (org.activityinfo.shared.report.model.AdminDimension)8 Test (org.junit.Test)8 DateDimension (org.activityinfo.shared.report.model.DateDimension)7 AttributeGroupDimension (org.activityinfo.shared.report.model.AttributeGroupDimension)5 OnDataSet (org.activityinfo.server.database.OnDataSet)4 PivotSites (org.activityinfo.shared.command.PivotSites)3 Axis (org.activityinfo.shared.report.content.PivotTableData.Axis)3 ArrayList (java.util.ArrayList)2 Comparator (java.util.Comparator)2 List (java.util.List)2 DummyPivotTableData (org.activityinfo.server.report.DummyPivotTableData)2 PivotContent (org.activityinfo.shared.report.content.PivotContent)2 PivotTableData (org.activityinfo.shared.report.content.PivotTableData)2 ReportContent (org.activityinfo.shared.report.content.ReportContent)2 SimpleCategory (org.activityinfo.shared.report.content.SimpleCategory)2 PivotTableReportElement (org.activityinfo.shared.report.model.PivotTableReportElement)2 Report (org.activityinfo.shared.report.model.Report)2