@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; }
"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() + " );";
@Override public int addCategoryOption( CategoryOption dataElementCategoryOption ) { categoryOptionStore.save( dataElementCategoryOption ); return dataElementCategoryOption.getId(); }
@Override public CategoryOptionCombo getCategoryOptionCombo( CategoryCombo categoryCombo, Set<CategoryOption> categoryOptions ) { String hql = "from CategoryOptionCombo co where co.categoryCombo = :categoryCombo"; for ( CategoryOption option : categoryOptions ) { hql += " and :option" + option.getId() + " in elements (co.categoryOptions)"; } Query query = getQuery( hql ); query.setParameter( "categoryCombo", categoryCombo ); for ( CategoryOption option : categoryOptions ) { query.setParameter( "option" + option.getId(), option ); } return (CategoryOptionCombo) query.uniqueResult(); }
private boolean checkOptionComboSharingPermission( User user, IdentifiableObject object, Permission permission ) { CategoryOptionCombo optionCombo = (CategoryOptionCombo) object; if ( optionCombo.isDefault() || optionCombo.getCategoryOptions().isEmpty() ) { return true; } List<Integer> accessibleOptions = new ArrayList<>(); for ( CategoryOption option : optionCombo.getCategoryOptions() ) { if ( checkSharingPermission( user, option, permission ) ) { accessibleOptions.add( option.getId() ); } } return accessibleOptions.size() == optionCombo.getCategoryOptions().size(); } }