public static CategoryOption createCategoryOption( char uniqueIdentifier ) { CategoryOption categoryOption = new CategoryOption( "CategoryOption" + uniqueIdentifier ); categoryOption.setAutoFields(); return categoryOption; }
public CategoryOption getCategoryOption( CategoryOptionCombo categoryOptionCombo ) { for ( CategoryOption categoryOption : categoryOptions ) { if ( categoryOption.getCategoryOptionCombos().contains( categoryOptionCombo ) ) { return categoryOption; } } return null; }
public void removeAllCategoryOptions() { for ( CategoryOption categoryOption : categoryOptions ) { categoryOption.getCategories().remove( this ); } categoryOptions.clear(); }
public Date getEarliestEndDate() { Date earliestEndDate = null; for ( CategoryOption co : getCategoryOptions() ) { if ( co.getEndDate() != null ) { earliestEndDate = (earliestEndDate == null || earliestEndDate.after( co.getEndDate() ) ? co.getStartDate() : earliestEndDate); } } return earliestEndDate; }
@Override public List<String> canRead( User user, CategoryOptionCombo optionCombo ) { List<String> errors = new ArrayList<>(); if ( user == null || user.isSuper() ) { return errors; } Set<CategoryOption> options = optionCombo.getCategoryOptions(); options.forEach( attrOption -> { if ( !aclService.canDataRead( user, attrOption ) ) { errors.add( "User has no data read access for CategoryOption: " + attrOption.getUid() ); } } ); return errors; }
private List<CategoryOption> categoryOptionsFromCsv( CsvReader reader ) throws IOException { List<CategoryOption> list = new ArrayList<>(); while ( reader.readRecord() ) { String[] values = reader.getValues(); if ( values != null && values.length > 0 ) { CategoryOption object = new CategoryOption(); setIdentifiableObject( object, values ); object.setShortName( getSafe( values, 3, object.getName(), 50 ) ); list.add( object ); } } return list; }
CategoryOption categoryOption = new CategoryOption( CategoryOption.DEFAULT_NAME ); categoryOption.setUid( "xYerKDKCefk" ); categoryOption.setCode( "default" ); categoryOption.setPublicAccess( AccessStringHelper.CATEGORY_OPTION_DEFAULT ); updateCategoryOption( categoryOption ); categoryOption.setCategoryOptionCombos( categoryOptionCombos ); updateCategoryOption( categoryOption );
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 ); }
@Override public String allowDeleteCategoryOption( CategoryOption categoryOption ) { String sql = "select count(*) from categorydimension_items where categoryoptionid = " + categoryOption.getId(); return jdbcTemplate.queryForObject( sql, Integer.class ) == 0 ? null : ERROR; }
public void addCategoryOption( CategoryOption categoryOption ) { members.add( categoryOption ); categoryOption.getGroups().add( this ); }
/** * @param categoryComboUniqueIdentifier A unique character to identify the * category combo. * @param categoryOptionUniqueIdentifiers Unique characters to identify the * category options. * @return CategoryOptionCombo */ public static CategoryOptionCombo createCategoryOptionCombo( char categoryComboUniqueIdentifier, char... categoryOptionUniqueIdentifiers ) { CategoryOptionCombo categoryOptionCombo = new CategoryOptionCombo(); categoryOptionCombo.setAutoFields(); categoryOptionCombo.setCategoryCombo( new CategoryCombo( "CategoryCombo" + categoryComboUniqueIdentifier, DataDimensionType.DISAGGREGATION ) ); for ( char identifier : categoryOptionUniqueIdentifiers ) { categoryOptionCombo.getCategoryOptions() .add( new CategoryOption( "CategoryOption" + identifier ) ); } return categoryOptionCombo; }
/** * Returns a set of category option group sets which are linked to this data * set through its category combination. */ public Set<CategoryOptionGroupSet> getCategoryOptionGroupSets() { Set<CategoryOptionGroupSet> groupSets = new HashSet<>(); if ( categoryCombo != null ) { for ( Category category : categoryCombo.getCategories() ) { for ( CategoryOption categoryOption : category.getCategoryOptions() ) { groupSets.addAll( categoryOption.getGroupSets() ); } } } return groupSets; }
@Override public List<String> canWrite( User user, CategoryOptionCombo optionCombo ) { List<String> errors = new ArrayList<>(); if ( user == null || user.isSuper() ) { return errors; } Set<CategoryOption> options = optionCombo.getCategoryOptions(); options.forEach( attrOption -> { if ( !aclService.canDataWrite( user, attrOption ) ) { errors.add( "User has no data write access for CategoryOption: " + attrOption.getUid() ); } } ); return errors; }
/** * Gets a range of valid dates for this (attribute) cateogry option combo. * <p> * The earliest valid date is the latest start date (if any) from all the * category options associated with this option combo. * <p> * The latest valid date is the earliest end date (if any) from all the * category options associated with this option combo. * * @return valid date range for this (attribute) category option combo. */ public DateRange getDateRange() { Date latestStartDate = null; Date earliestEndDate = null; for ( CategoryOption option : getCategoryOptions() ) { if ( option.getStartDate() != null && (latestStartDate == null || option.getStartDate().compareTo( latestStartDate ) > 0) ) { latestStartDate = option.getStartDate(); } if ( option.getEndDate() != null && (earliestEndDate == null || option.getStartDate().compareTo( earliestEndDate ) < 0) ) { earliestEndDate = option.getEndDate(); } } return new DateRange( latestStartDate, earliestEndDate ); }
"where dv.categoryoptioncomboid in ( " + "select cc.categoryoptioncomboid from categoryoptioncombos_categoryoptions cc " + "where cc.categoryoptionid = " + categoryOption.getId() + " ) " + "or dv.attributeoptioncomboid in ( " + "select cc.categoryoptioncomboid from categoryoptioncombos_categoryoptions cc " + "where cc.categoryoptionid = " + categoryOption.getId() + " );"; "where cdr.attributeoptioncomboid in ( " + "select cc.categoryoptioncomboid from categoryoptioncombos_categoryoptions cc " + "where cc.categoryoptionid = " + categoryOption.getId() + " );";
public void removeCategoryOption( CategoryOption categoryOption ) { members.remove( categoryOption ); categoryOption.getGroups().remove( this ); } }
if ( option.getGroupSets() != null ) cogSets.addAll( option.getGroupSets() );
@Override public List<String> canRead( User user, CategoryOptionCombo categoryOptionCombo ) { List<String> errors = new ArrayList<>(); if ( user == null || user.isSuper() || categoryOptionCombo == null ) { return errors; } for ( CategoryOption categoryOption : categoryOptionCombo.getCategoryOptions() ) { if ( !aclService.canDataRead( user, categoryOption ) ) { errors.add( "User has no read access to category option: " + categoryOption.getUid() ); } } return errors; }