@Override public String allowDeleteCategoryOptionGroupSet( CategoryOptionGroupSet categoryOptionGroupSet ) { String sql = "select count(*) from dataapprovallevel where categoryoptiongroupsetid=" + categoryOptionGroupSet.getId(); return jdbcTemplate.queryForObject( sql, Integer.class ) == 0 ? null : ERROR; }
/** * Returns the name of the category option group set for this data approval * level, or an empty string if there is no category option group set. * * @return name of this approval level's category option group set. */ public String getCategoryOptionGroupSetName() { return categoryOptionGroupSet == null ? "" : categoryOptionGroupSet.getName(); }
/** * @param categoryGroupSetUniqueIdentifier A unique character to identify the * category option group set. * @param categoryOptionGroups the category option groups. * @return CategoryOptionGroupSet */ public static CategoryOptionGroupSet createCategoryOptionGroupSet( char categoryGroupSetUniqueIdentifier, CategoryOptionGroup... categoryOptionGroups ) { CategoryOptionGroupSet categoryOptionGroupSet = new CategoryOptionGroupSet( "CategoryOptionGroupSet" + categoryGroupSetUniqueIdentifier ); categoryOptionGroupSet.setAutoFields(); for ( CategoryOptionGroup categoryOptionGroup : categoryOptionGroups ) { categoryOptionGroupSet.addCategoryOptionGroup( categoryOptionGroup ); } return categoryOptionGroupSet; }
"inner join categoryoptiongroupsetmembers cogsm on cogm.categoryoptiongroupid = cogsm.categoryoptiongroupid " + "where coc.categoryoptioncomboid = cocco.categoryoptioncomboid " + "and cogsm.categoryoptiongroupsetid = " + groupSet.getId() + " " + "limit 1) as " + quote( groupSet.getName() ) + ", "; "inner join categoryoptiongroupsetmembers cogsm on cogm.categoryoptiongroupid = cogsm.categoryoptiongroupid " + "where coc.categoryoptioncomboid = cocco.categoryoptioncomboid " + "and cogsm.categoryoptiongroupsetid = " + groupSet.getId() + " " + "limit 1) as " + quote( groupSet.getUid() ) + ", ";
columns.add( new AnalyticsTableColumn( quote( groupSet.getUid() ), "character(11)", "acs." + quote( groupSet.getUid() ), groupSet.getCreated() ) );
@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; }
@Override public void deleteCategoryOptionGroup( CategoryOptionGroup categoryOptionGroup ) { for ( CategoryOptionGroupSet groupSet : categoryOptionGroup.getGroupSets() ) { groupSet.getMembers().remove( categoryOptionGroup ); idObjectManager.updateNoAcl( groupSet ); } } }
/** * Returns the dimensions to use as constrains (filters) in data analytics * aggregation. */ public Set<DimensionalObject> getDimensionConstraints() { Set<DimensionalObject> constraints = new HashSet<>(); for ( CategoryOptionGroupSet cogs : cogsDimensionConstraints ) { cogs.setDimensionType( DimensionType.CATEGORY_OPTION_GROUP_SET ); constraints.add( cogs ); } for ( Category cat : catDimensionConstraints ) { cat.setDimensionType( DimensionType.CATEGORY ); constraints.add( cat ); } return constraints; }
/** * Indicates whether the given approval level represents the same level as this. */ public boolean levelEquals( DataApprovalLevel other ) { if ( other == null ) { return false; } if ( level != other.getLevel() ) { return false; } if ( categoryOptionGroupSet != null ? !categoryOptionGroupSet.equals( other.getCategoryOptionGroupSet() ) : other.getCategoryOptionGroupSet() != null ) { return false; } return true; }
columns.add( new AnalyticsTableColumn( quote( groupSet.getUid() ), "character(11)", "acs." + quote( groupSet.getUid() ), groupSet.getCreated() ) );
for ( CategoryOptionGroup group : groupSet.getMembers() )
columns.add( new AnalyticsTableColumn( quote( groupSet.getUid() ), "character(11)", "dcs." + quote( groupSet.getUid() ), groupSet.getCreated() ) ); columns.add( new AnalyticsTableColumn( quote( groupSet.getUid() ), "character(11)", "acs." + quote( groupSet.getUid() ), groupSet.getCreated() ) );
@Override public String toString() { return "DataApprovalLevel{" + "name=" + name + ", level=" + level + ", orgUnitLevel=" + orgUnitLevel + ", categoryOptionGroupSet='" + (categoryOptionGroupSet == null ? "(null)" : categoryOptionGroupSet.getName()) + "'" + ", created=" + created + ", lastUpdated=" + lastUpdated + '}'; }
@Override public int saveCategoryOptionGroupSet( CategoryOptionGroupSet group ) { categoryOptionGroupSetStore.save( group ); return group.getId(); }
columns.add( new AnalyticsTableColumn( quote( groupSet.getUid() ), "character(11)", "acs." + quote( groupSet.getUid() ), groupSet.getCreated() ) );
@Override public List<CategoryOptionGroup> getCategoryOptionGroups( CategoryOptionGroupSet groupSet ) { CriteriaBuilder builder = getCriteriaBuilder(); JpaQueryParameters<CategoryOptionGroup> parameters = newJpaParameters() .addPredicates( getSharingPredicates( builder ) ) .addPredicate( root -> { Join<Object, Object> groupSets = root.join( "groupSets" ); return builder.or( builder.equal( groupSets.get( "id" ) , groupSet.getId() ), builder.isNull( groupSets.get( "id" ) ) ); }); return getList( builder, parameters ); } }