public List<CategoryOption> getCategoryOptions() { final List<CategoryOption> categoryOptions = new ArrayList<>(); for ( Category category : categories ) { categoryOptions.addAll( category.getCategoryOptions() ); } return categoryOptions; }
private Map<String, Category> getCodeCategoryMap( CategoryCombo categoryCombo ) throws AdxException { Map<String, Category> categoryMap = new HashMap<>(); List<Category> categories = categoryCombo.getCategories(); for ( Category category : categories ) { String categoryCode = category.getCode(); if ( categoryCode == null || !XMLChar.isValidName( categoryCode ) ) { throw new AdxException( "Category code for " + category.getName() + " is missing or invalid: " + categoryCode ); } categoryMap.put( category.getCode(), category ); } return categoryMap; }
/** * @param categoryUniqueIdentifier A unique character to identify the * category. * @param categoryOptions the category options. * @return Category */ public static Category createCategory( char categoryUniqueIdentifier, CategoryOption... categoryOptions ) { Category category = new Category( "Category" + categoryUniqueIdentifier, DataDimensionType.DISAGGREGATION ); category.setAutoFields(); for ( CategoryOption categoryOption : categoryOptions ) { category.addCategoryOption( categoryOption ); } return category; }
columns.add( new AnalyticsTableColumn( quote( category.getUid() ), "character(11)", "acs." + quote( category.getUid() ), category.getCreated() ) );
"inner join categories_categoryoptions cco on co.categoryoptionid = cco.categoryoptionid " + "where coc.categoryoptioncomboid = cocco.categoryoptioncomboid " + "and cco.categoryid = " + category.getId() + " " + "limit 1) as " + quote( category.getName() ) + ", "; "inner join categories_categoryoptions cco on co.categoryoptionid = cco.categoryoptionid " + "where coc.categoryoptioncomboid = cocco.categoryoptioncomboid " + "and cco.categoryid = " + category.getId() + " " + "limit 1) as " + quote( category.getUid() ) + ", ";
Category category = new Category( Category.DEFAULT_NAME, DataDimensionType.DISAGGREGATION ); category.setUid( "GLevLNI9wkl" ); category.setCode( "default" ); category.setDataDimension( false ); category.addCategoryOption( categoryOption ); addCategory( category ); category.setPublicAccess( AccessStringHelper.CATEGORY_NO_DATA_SHARING_DEFAULT ); updateCategory( category );
@Override public String getCreateTempTableStatement() { String statement = "create table " + getTempTableName() + " (" + "categoryoptioncomboid integer not null, " + "categoryoptioncomboname varchar(255), "; for ( Category category : objects ) { quote( category.getName() ); statement += quote( category.getName() ) + " varchar(230), "; statement += quote( category.getUid() ) + " character(11), "; } for ( CategoryOptionGroupSet groupSet : groupSets ) { statement += quote( groupSet.getName() ) + " varchar(230), "; statement += quote( groupSet.getUid() ) + " character(11), "; } statement += "primary key (categoryoptioncomboid))"; return statement; }
if ( category.isDefault() ) if ( !category.isDataDimension() ) log.warn( "Could not get sub-total for category: " + category.getUid() + " for data set report: " + dataSet + ", not a data dimension" ); continue;
if ( category.isDataDimension() ) columns.add( new AnalyticsTableColumn( quote( category.getUid() ), "character(11)", "acs." + quote( category.getUid() ), category.getCreated() ) );
private void addExplodedCategoryAttributes( CategoryOptionCombo coc ) throws AdxException { Map<String, String> categoryAttributes = new HashMap<>(); if ( !coc.isDefault() ) { for ( Category category : coc.getCategoryCombo().getCategories() ) { String categoryCode = category.getCode(); if ( categoryCode == null || !XMLChar.isValidName( categoryCode ) ) { throw new AdxException( "Category code for " + category.getName() + " is missing or invalid: " + categoryCode ); } String catOptCode = category.getCategoryOption( coc ).getCode(); if ( catOptCode == null || catOptCode.isEmpty() ) { throw new AdxException( "CategoryOption code for " + category.getCategoryOption( coc ).getName() + " is missing" ); } categoryAttributes.put( categoryCode, catOptCode ); } } categoryOptionMap.put( coc.getId(), categoryAttributes ); }
/** * Returns meta-data mapping for this analytical object. Includes a identifier * to name mapping for dynamic dimensions. */ public Map<String, String> getMetaData() { final Map<String, String> meta = new HashMap<>(); //TODO use getDimension() instead of getUid() ? dataElementGroupSetDimensions.forEach( dim -> meta.put( dim.getDimension().getUid(), dim.getDimension().getDisplayName() ) ); organisationUnitGroupSetDimensions.forEach( group -> meta.put( group.getDimension().getUid(), group.getDimension().getDisplayName() ) ); categoryDimensions.forEach( dim -> meta.put( dim.getDimension().getUid(), dim.getDimension().getDisplayName() ) ); return meta; }
CategoryOption catopt = category.getCategoryOption( optionCombo ); throw new CategoryComboMapException( "No categoryOption in " + category.getName() + " matching " + optionCombo.getName() );
@Override public String allowDeleteCategory( Category category ) { String sql = "select count(*) from categorydimension where categoryid = " + category.getId(); return jdbcTemplate.queryForObject( sql, Integer.class ) == 0 ? null : ERROR; } }
columns.add( new AnalyticsTableColumn( quote( category.getUid() ), "character(11)", "acs." + quote( category.getUid() ), category.getCreated() ) );
"Category combo " + catCombo.getName() + " must have " + categoryMap.get( category ).getName() );
@Override public int addCategory( Category dataElementCategory ) { categoryStore.save( dataElementCategory ); return dataElementCategory.getId(); }
columns.add( new AnalyticsTableColumn( quote( category.getUid() ), "character(11)", "acs." + quote( category.getUid() ), category.getCreated() ) );
public CategoryOption[][] getCategoryOptionsAsArray() { CategoryOption[][] arrays = new CategoryOption[categories.size()][]; int i = 0; for ( Category category : categories ) { arrays[i++] = new ArrayList<>( category.getCategoryOptions() ).toArray( new CategoryOption[0] ); } return arrays; }