private Set<Integer> getRelevantSources( DataSet dataSet, Set<Integer> sources, Set<OrganisationUnitGroup> groups ) { Set<Integer> dataSetSources = new HashSet<>( getIdentifiers( dataSet.getSources() ) ); if ( groups != null ) { for ( OrganisationUnitGroup group : groups ) { List<Integer> ids = getIdentifiers( group.getMembers() ); dataSetSources.retainAll( ids ); } } return Sets.intersection( dataSetSources, sources ); } }
private static String commaDelimitedIds( Collection<? extends IdentifiableObject> idObjects ) { return TextUtils.getCommaDelimitedString( IdentifiableObjectUtils.getIdentifiers( idObjects ) ); }
String dataElementIds = getCommaDelimitedString( getIdentifiers( dataElements ) ); String periodIds = getCommaDelimitedString( getIdentifiers( periods ) ); String categoryOptionComboIds = getCommaDelimitedString( getIdentifiers( categoryOptionCombos ) );
@Override public PeriodHierarchy getPeriodHierarchy( Collection<Period> periods ) { PeriodHierarchy hierarchy = new PeriodHierarchy(); for ( Period period : periods ) { hierarchy.getIntersectingPeriods().put( period.getId(), new HashSet<>( getIdentifiers( getIntersectingPeriods( period.getStartDate(), period.getEndDate() ) ) ) ); hierarchy.getPeriodsBetween().put( period.getId(), new HashSet<>( getIdentifiers( getPeriodsBetweenDates( period.getStartDate(), period.getEndDate() ) ) ) ); } return hierarchy; }
private String getCategoryOptionSharingForUser( User user ) { List<Integer> userGroupIds = getIdentifiers( user.getGroups() ); String sql = " left join ( "; sql += "select categoryoptioncomboid, count(categoryoptioncomboid) as option_size from categoryoptioncombos_categoryoptions group by categoryoptioncomboid) " + "as cocount on coc.categoryoptioncomboid = cocount.categoryoptioncomboid " + "left join (" + "select deco.categoryoptionid as deco_id, deco.uid as deco_uid, deco.publicaccess AS deco_publicaccess, " + "couga.usergroupaccessid as uga_id, coua.useraccessid as ua_id, uga.access as uga_access, uga.usergroupid AS usrgrp_id, " + "ua.access as ua_access, ua.userid as usr_id from dataelementcategoryoption deco " + "left join dataelementcategoryoptionusergroupaccesses couga on deco.categoryoptionid = couga.categoryoptionid " + "left join dataelementcategoryoptionuseraccesses coua on deco.categoryoptionid = coua.categoryoptionid " + "left join usergroupaccess uga on couga.usergroupaccessid = uga.usergroupaccessid " + "left join useraccess ua on coua.useraccessid = ua.useraccessid " + " where ua.userid=" + user.getId(); if ( userGroupIds != null && !userGroupIds.isEmpty() ) { sql += " or uga.usergroupid in (" + getCommaDelimitedString( userGroupIds ) + ") "; } sql += " ) as decoa on cocco.categoryoptionid = decoa.deco_id "; return sql; }
String dataElementIds = getCommaDelimitedString( getIdentifiers( dataElements ) ); String periodIds = getCommaDelimitedString( getIdentifiers( periods ) ); String categoryOptionComboIds = getCommaDelimitedString( getIdentifiers( categoryOptionCombos ) );
sql += hlp.whereAnd() + " ds.datasetid in (" + StringUtils.join( IdentifiableObjectUtils.getIdentifiers( dataSets ), "," ) + ") ";
isReadable( "co", user ) + " and exists (select 'x' from Category c where co in elements(c.categoryOptions)" + " and c.id in (" + StringUtils.join( IdentifiableObjectUtils.getIdentifiers( categories ), "," ) + ") )"; " join g.groupSets s" + " where g.id in elements(co.groups)" + " and s.id in (" + StringUtils.join( IdentifiableObjectUtils.getIdentifiers( cogsets ), "," ) + ")" + " and " + isReadable( "g", user ) + " )";
@Override @Transactional public List<DataSetCompletenessResult> getDataSetCompleteness( int periodId, Collection<Integer> organisationUnitIds, int dataSetId, Set<Integer> groupIds ) { final DataSet dataSet = dataSetService.getDataSet( dataSetId ); final Period period = periodService.getPeriod( periodId ); final List<Integer> periodsBetweenDates = getIdentifiers( periodService.getPeriodsBetweenDates( dataSet.getPeriodType(), period.getStartDate(), period.getEndDate() ) ); final Map<Integer, OrganisationUnit> orgUnits = Maps.uniqueIndex( organisationUnitService.getOrganisationUnits( organisationUnitIds ), OrganisationUnit::getId ); final Set<OrganisationUnitGroup> groups = groupIds != null ? Sets.newHashSet( idObjectManager.getObjects( OrganisationUnitGroup.class, groupIds ) ) : null; final List<DataSetCompletenessResult> results = new ArrayList<>(); for ( final Integer unitId : organisationUnitIds ) { final OrganisationUnit unit = orgUnits.get( unitId ); final Set<Integer> children = organisationUnitService.getOrganisationUnitHierarchy().getChildren( unit.getId() ); final Set<Integer> relevantSources = getRelevantSources( dataSet, children, groups ); final DataSetCompletenessResult result = getDataSetCompleteness( period, periodsBetweenDates, unit, relevantSources, dataSet ); if ( result.getSources() > 0 ) { results.add( result ); } } return results; }
Map<Integer, Integer> upperBoundMap ) String periodIds = TextUtils.getCommaDelimitedString( getIdentifiers( periods ) );
"inner join categoryoptioncombo coc on dv.categoryoptioncomboid = coc.categoryoptioncomboid " + "inner join categoryoptioncombo aoc on dv.attributeoptioncomboid = aoc.categoryoptioncomboid " + "where dv.dataelementid in (" + StringUtils.join( IdentifiableObjectUtils.getIdentifiers( dataElements ), "," ) + ") " + "and (";
String catOptionComboIds = TextUtils.getCommaDelimitedString( getIdentifiers( categoryOptionCombos ) );
financialYearStart ); String periodString = getCommaDelimitedString( getIdentifiers( periodService.reloadPeriods( relativePeriods ) ) ); String isoPeriodString = getCommaDelimitedString( IdentifiableObjectUtils.getUids( relativePeriods ) );
.setParameterList( "dataElements", getIdentifiers( dataElements ) ); .collect( Collectors.toSet() ); query.setParameterList( "periods", getIdentifiers( periods ) ); query.setParameterList( "orgUnits", getIdentifiers( organisationUnits ) ); query.setParameterList( "attributeOptionCombos", getIdentifiers( params.getAttributeOptionCombos() ) );
String dataElementIdList = getCommaDelimitedString( getIdentifiers( params.getDataElements() ) ); String periodIdList = getCommaDelimitedString( getIdentifiers( params.getPeriods() ) ); String orgUnitIdList = getCommaDelimitedString( getIdentifiers( params.getOrganisationUnits() ) ); String aocIdList = getCommaDelimitedString( getIdentifiers( params.getAttributeOptionCombos() ) ); String coDimConstraintsList = getCommaDelimitedString( getIdentifiers( params.getCoDimensionConstraints() ) ); String cogDimConstraintsList = getCommaDelimitedString( getIdentifiers( params.getCogDimensionConstraints() ) );
final List<Integer> periodsBetweenDates = getIdentifiers( periodService.getPeriodsBetweenDates( dataSet.getPeriodType(), period.getStartDate(), period.getEndDate() ) );
String cocScheme = idScheme.getCategoryOptionComboIdScheme().getIdentifiableString().toLowerCase(); String dataElements = getCommaDelimitedString( getIdentifiers( params.getAllDataElements() ) ); String orgUnits = getCommaDelimitedString( getIdentifiers( params.getOrganisationUnits() ) ); String orgUnitGroups = getCommaDelimitedString( getIdentifiers( params.getOrganisationUnitGroups() ) ); sql += "and dv.periodid in (" + getCommaDelimitedString( getIdentifiers( params.getPeriods() ) ) + ") "; sql += "and dv.attributeoptioncomboid in (" + getCommaDelimitedString( getIdentifiers( params.getAttributeOptionCombos() ) ) + ") ";
+ getCommaDelimitedString( getIdentifiers( organisationUnits ) ) + ") ";
query.setParameterList( "groupIds", IdentifiableObjectUtils.getIdentifiers( params.getGroups() ) );
+ getCommaDelimitedString( getIdentifiers( params.getOrganisationUnits() ) ) + ") ";