use of org.hisp.dhis.common.DimensionalObject in project dhis2-core by dhis2.
the class DefaultDimensionService method getCanReadDimensionItems.
//--------------------------------------------------------------------------
// DimensionService implementation
//--------------------------------------------------------------------------
public List<DimensionalItemObject> getCanReadDimensionItems(String uid) {
DimensionalObject dimension = idObjectManager.get(DimensionalObject.DYNAMIC_DIMENSION_CLASSES, uid);
List<DimensionalItemObject> items = new ArrayList<>();
if (dimension != null && dimension.hasItems()) {
User user = currentUserService.getCurrentUser();
items.addAll(getCanReadObjects(user, dimension.getItems()));
}
return items;
}
use of org.hisp.dhis.common.DimensionalObject in project dhis2-core by dhis2.
the class DimensionController method getDimensionsForDataSet.
@RequestMapping(value = "/dataSet/{uid}", method = RequestMethod.GET)
@ResponseBody
public RootNode getDimensionsForDataSet(@PathVariable String uid, @RequestParam(value = "links", defaultValue = "true", required = false) Boolean links, Model model, HttpServletResponse response) throws WebMessageException {
WebMetadata metadata = new WebMetadata();
List<String> fields = Lists.newArrayList(contextService.getParameterValues("fields"));
DataSet dataSet = identifiableObjectManager.get(DataSet.class, uid);
if (dataSet == null) {
throw new WebMessageException(WebMessageUtils.notFound("DataSet not found for uid: " + uid));
}
if (!dataSet.hasCategoryCombo()) {
throw new WebMessageException(WebMessageUtils.conflict("Data set does not have a category combination: " + uid));
}
List<DimensionalObject> dimensions = new ArrayList<>();
dimensions.addAll(dataSet.getCategoryCombo().getCategories());
dimensions.addAll(dataSet.getCategoryOptionGroupSets());
dimensions = dimensionService.getCanReadObjects(dimensions);
for (DimensionalObject dim : dimensions) {
metadata.getDimensions().add(dimensionService.getDimensionalObjectCopy(dim.getUid(), true));
}
if (links) {
linkService.generateLinks(metadata, false);
}
RootNode rootNode = NodeUtils.createMetadata();
rootNode.addChild(fieldFilterService.filter(getEntityClass(), metadata.getDimensions(), fields));
return rootNode;
}
use of org.hisp.dhis.common.DimensionalObject in project dhis2-core by dhis2.
the class DimensionController method getDimensionConstraints.
@RequestMapping(value = "/constraints", method = RequestMethod.GET)
@ResponseBody
public RootNode getDimensionConstraints(@RequestParam(value = "links", defaultValue = "true", required = false) Boolean links) {
List<String> fields = Lists.newArrayList(contextService.getParameterValues("fields"));
List<DimensionalObject> dimensionConstraints = dimensionService.getDimensionConstraints();
if (links) {
linkService.generateLinks(dimensionConstraints, false);
}
RootNode rootNode = NodeUtils.createMetadata();
rootNode.addChild(fieldFilterService.filter(getEntityClass(), dimensionConstraints, fields));
return rootNode;
}
use of org.hisp.dhis.common.DimensionalObject in project dhis2-core by dhis2.
the class DimensionController method getEntityList.
// -------------------------------------------------------------------------
// Controller
// -------------------------------------------------------------------------
@Override
@SuppressWarnings("unchecked")
@ResponseBody
protected List<DimensionalObject> getEntityList(WebMetadata metadata, WebOptions options, List<String> filters, List<Order> orders) throws QueryParserException {
List<DimensionalObject> dimensionalObjects;
Query query = queryService.getQueryFromUrl(DimensionalObject.class, filters, orders, options.getRootJunction());
query.setDefaultOrder();
query.setObjects(dimensionService.getAllDimensions());
dimensionalObjects = (List<DimensionalObject>) queryService.query(query);
return dimensionalObjects;
}
use of org.hisp.dhis.common.DimensionalObject in project dhis2-core by dhis2.
the class DefaultAnalyticsService method getAggregatedDataValueMap.
/**
* Returns a mapping between dimension items and values for the given data
* query and list of indicators. The dimensional items part of the indicator
* numerators and denominators are used as dimensional item for the aggregated
* values being retrieved.
*
* @param params the {@link DataQueryParams}.
* @param indicators the list of indicators.
* @return a dimensional items to aggregate values map.
*/
private Map<String, Double> getAggregatedDataValueMap(DataQueryParams params, List<Indicator> indicators) {
List<DimensionalItemObject> items = Lists.newArrayList(expressionService.getDimensionalItemObjectsInIndicators(indicators));
items = DimensionalObjectUtils.replaceOperandTotalsWithDataElements(items);
DimensionalObject dimension = new BaseDimensionalObject(DimensionalObject.DATA_X_DIM_ID, DimensionType.DATA_X, null, DISPLAY_NAME_DATA_X, items);
DataQueryParams dataSourceParams = DataQueryParams.newBuilder(params).replaceDimension(dimension).withIncludeNumDen(false).withSkipHeaders(true).withSkipMeta(true).build();
Grid grid = getAggregatedDataValueGridInternal(dataSourceParams);
return grid.getAsMap(grid.getWidth() - 1, DimensionalObject.DIMENSION_SEP);
}
Aggregations