use of org.activityinfo.legacy.shared.reports.model.Dimension in project activityinfo by bedatadriven.
the class DimensionTree method updateModelAfterCheckChange.
private void updateModelAfterCheckChange(TreePanelEvent<DimensionModel> event) {
Dimension dim = event.getItem().getDimension();
if (event.isChecked()) {
if (!model.getRowDimensions().contains(dim) && !model.getColumnDimensions().contains(dim)) {
if (model.getRowDimensions().size() > model.getColumnDimensions().size()) {
model.addColDimension(dim);
} else {
model.addRowDimension(dim);
}
}
} else {
model.getRowDimensions().remove(dim);
model.getColumnDimensions().remove(dim);
}
if (fireEvents) {
reportEventBus.fireChange();
}
}
use of org.activityinfo.legacy.shared.reports.model.Dimension in project activityinfo by bedatadriven.
the class DimensionTree method isAttributeDimensionSelected.
private boolean isAttributeDimensionSelected(Dimensions schema, List<Dimension> dims, AttributeGroupDimension dim) {
String name = schema.getAttributeGroupNameSafe(dim.getAttributeGroupId());
for (Dimension selectedDim : dims) {
if (selectedDim instanceof AttributeGroupDimension) {
int selectedId = ((AttributeGroupDimension) selectedDim).getAttributeGroupId();
String selectedName = schema.getAttributeGroupNameSafe(selectedId);
if (selectedName.equalsIgnoreCase(name)) {
return true;
}
}
}
return false;
}
use of org.activityinfo.legacy.shared.reports.model.Dimension in project activityinfo by bedatadriven.
the class PivotTableBinder method executeLoad.
@Override
protected void executeLoad(final AsyncCallback<PivotContent> callback) {
final Filter filter = new Filter(getModel().getFilter());
final Set<Dimension> dimensions = new HashSet<>(getModel().allDimensions());
if (filter.equals(cachedFilter) && dimensions.equals(cachedDimensions)) {
try {
callback.onSuccess(generateElement());
} catch (Exception e) {
callback.onFailure(e);
}
} else {
PivotSites query = new PivotSites(dimensions, filter);
if (query.isTooBroad()) {
callback.onSuccess(new PivotContent());
return;
}
dispatcher.execute(query, new AsyncCallback<PivotSites.PivotResult>() {
@Override
public void onFailure(Throwable throwable) {
callback.onFailure(throwable);
}
@Override
public void onSuccess(PivotSites.PivotResult pivotResult) {
cachedFilter = filter;
cachedDimensions = dimensions;
cachedResult = pivotResult;
try {
callback.onSuccess(generateElement());
} catch (Exception e) {
callback.onFailure(e);
}
}
});
}
}
use of org.activityinfo.legacy.shared.reports.model.Dimension in project activityinfo by bedatadriven.
the class GetPartnersDimensionHandler method execute.
@Override
public void execute(GetPartnersDimension cmd, ExecutionContext context, final AsyncCallback<PartnerResult> callback) {
final Dimension dimension = new Dimension(DimensionType.Partner);
PivotSites query = new PivotSites();
query.setFilter(cmd.getFilter());
query.setDimensions(dimension);
query.setValueType(ValueType.TOTAL_SITES);
if (query.isTooBroad()) {
callback.onSuccess(new PartnerResult());
return;
}
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.legacy.shared.reports.model.Dimension in project activityinfo by bedatadriven.
the class Bucket method toString.
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(" { Value: ").append(doubleValue());
for (Dimension dim : dimensions()) {
DimensionCategory cat = getCategory(dim);
sb.append("\n ").append(dim.toString()).append(": ");
sb.append(cat.toString());
}
sb.append("\n }");
return sb.toString();
}
Aggregations