Skip to content

Commit

Permalink
chore: Remove unused code (dhis2#19623)
Browse files Browse the repository at this point in the history
  • Loading branch information
larshelge authored Jan 8, 2025
1 parent c5a6a4c commit 68dac3a
Show file tree
Hide file tree
Showing 20 changed files with 5 additions and 588 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,6 @@ public interface CategoryService {
*/
Category getCategoryByName(String name, UserDetails userDetails);

/**
* Returns all DataElementCategories.
*
* @return a list of all DataElementCategories.
*/
List<Category> getAllDataElementCategories();

/**
* Retrieves all DataElementCategories of dimension type disaggregation.
*
Expand Down Expand Up @@ -330,24 +323,6 @@ SetValuedMap<String, String> getCategoryOptionOrganisationUnitsAssociations(
*/
List<CategoryCombo> getAttributeCategoryCombos();

/**
* Validates the category combo. Possible return values are:
*
* <p>
*
* <ul>
* <li>category_combo_is_null
* <li>category_combo_must_have_at_least_one_category
* <li>category_combo_cannot_have_duplicate_categories
* <li>categories_must_have_at_least_one_category_option
* <li>categories_cannot_share_category_options
* </ul>
*
* @param categoryCombo the category combo to validate.
* @return null if valid, non-empty string if invalid.
*/
String validateCategoryCombo(CategoryCombo categoryCombo);

// -------------------------------------------------------------------------
// CategoryOptionCombo
// -------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@
import java.util.Collection;
import java.util.List;
import javax.annotation.Nonnull;
import org.hisp.dhis.category.CategoryCombo;
import org.hisp.dhis.common.IllegalQueryException;
import org.hisp.dhis.common.UID;
import org.hisp.dhis.common.ValueType;
import org.hisp.dhis.hierarchy.HierarchyViolationException;
import org.hisp.dhis.period.PeriodType;

/**
* Defines service functionality for DataElements and DataElementGroups.
Expand Down Expand Up @@ -110,39 +106,6 @@ public interface DataElementService {
*/
List<DataElement> getAllDataElements();

/**
* Returns all DataElements of a given type.
*
* @param valueType the value type restriction
* @return a list of all DataElements with the given value type, or an empty list if there are no
* DataElements.
*/
List<DataElement> getAllDataElementsByValueType(ValueType valueType);

/**
* Returns all DataElements with the given domain type.
*
* @param domainType the DataElementDomainType.
* @return all DataElements with the given domainType.
*/
List<DataElement> getDataElementsByDomainType(DataElementDomain domainType);

/**
* Returns the DataElements with the given PeriodType.
*
* @param periodType the PeriodType.
* @return a list of DataElements.
*/
List<DataElement> getDataElementsByPeriodType(PeriodType periodType);

/**
* Returns all DataElements with the given category combo.
*
* @param categoryCombo the CategoryCombo.
* @return all DataElements with the given category combo.
*/
List<DataElement> getDataElementByCategoryCombo(CategoryCombo categoryCombo);

/**
* Returns all DataElements which are not member of any DataElementGroups.
*
Expand Down Expand Up @@ -246,14 +209,6 @@ public interface DataElementService {
*/
List<DataElementGroup> getAllDataElementGroups();

/**
* Returns all DataElements which zeroIsSignificant property is true or false.
*
* @param zeroIsSignificant whether zero is significant is true for this query.
* @return a collection of DataElements.
*/
List<DataElement> getDataElementsByZeroIsSignificant(boolean zeroIsSignificant);

// -------------------------------------------------------------------------
// DataElementGroupSet
// -------------------------------------------------------------------------
Expand All @@ -267,14 +222,4 @@ public interface DataElementService {
DataElementGroupSet getDataElementGroupSet(long id);

DataElementGroupSet getDataElementGroupSet(String uid);

DataElementGroupSet getDataElementGroupSetByName(String name);

List<DataElementGroupSet> getAllDataElementGroupSets();

List<DataElement> getByAttributeAndValue(UID attribute, String value);

List<DataElement> getByAttribute(UID attribute);

DataElement getByUniqueAttributeValue(UID attribute, String value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.List;
import org.hisp.dhis.category.CategoryCombo;
import org.hisp.dhis.common.GenericDimensionalObjectStore;
import org.hisp.dhis.common.ValueType;
import org.hisp.dhis.user.User;

/**
Expand All @@ -53,30 +52,6 @@ public interface DataElementStore extends GenericDimensionalObjectStore<DataElem
*/
List<DataElement> getDataElementByCategoryCombo(CategoryCombo categoryCombo);

/**
* Returns all DataElement which zeroIsSignificant property is true or false
*
* @param zeroIsSignificant is zeroIsSignificant property
* @return a collection of all DataElement
*/
List<DataElement> getDataElementsByZeroIsSignificant(boolean zeroIsSignificant);

/**
* Returns all DataElements of the given domain type.
*
* @param domainType the domain type.
* @return all DataElements of the given domain type.
*/
List<DataElement> getDataElementsByDomainType(DataElementDomain domainType);

/**
* Returns all DataElements of the given value type.
*
* @param valueType the value type.
* @return all DataElements of the given value type.
*/
List<DataElement> getDataElementsByValueType(ValueType valueType);

/**
* Returns all DataElements which are not member of any DataElementGroups.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.hisp.dhis.dataentryform.DataEntryForm;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserDetails;

Expand Down Expand Up @@ -108,14 +107,6 @@ public interface DataSetService extends DataSetDataIntegrityProvider {
*/
List<DataSet> getAllDataSets();

/**
* Gets all DataSets associated with the given PeriodType.
*
* @param periodType the PeriodType.
* @return a list of DataSets.
*/
List<DataSet> getDataSetsByPeriodType(PeriodType periodType);

/**
* Returns the data sets which given user have READ access. If the current user has the ALL
* authority then all data sets are returned.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,12 @@
import org.hisp.dhis.common.IdentifiableObjectStore;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataentryform.DataEntryForm;
import org.hisp.dhis.period.PeriodType;

/**
* @author Kristian Nordal
*/
public interface DataSetStore
extends IdentifiableObjectStore<DataSet>, DataSetDataIntegrityProvider {
String ID = DataSetStore.class.getName();

// -------------------------------------------------------------------------
// DataSet
// -------------------------------------------------------------------------

/**
* Gets all DataSets associated with the given PeriodType.
*
* @param periodType the PeriodType.
* @return a list of DataSets.
*/
List<DataSet> getDataSetsByPeriodType(PeriodType periodType);

/**
* Gets all DataSets associated with the given DataEntryForm.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public class OrganisationUnit extends BaseDimensionalItemObject

private Geometry geometry;

/** A reference to the Image file associated with this OrganisationUnit. */
/** A reference to the image file resource associated with this {@link OrganisationUnit}. */
private FileResource image;

// -------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,6 @@ List<OrganisationUnit> getOrganisationUnitsAtLevels(
Long getOrganisationUnitHierarchyMemberCount(
OrganisationUnit parent, Object member, String collectionName) throws BadRequestException;

OrganisationUnitDataSetAssociationSet getOrganisationUnitDataSetAssociationSet(User user);

/**
* Returns the level of the given org unit level. The level parameter string can either represent
* a numerical level, or a UID referring to an {@link OrganisationUnitLevel} object.
Expand Down Expand Up @@ -385,19 +383,6 @@ List<OrganisationUnit> getOrganisationUnitByCoordinate(
@Deprecated(forRemoval = true)
boolean isInUserDataViewHierarchy(User user, OrganisationUnit organisationUnit);

/**
* Equal to {@link OrganisationUnitService#isInUserSearchHierarchy(User, OrganisationUnit)} except
* adds a caching layer on top. Use this method when performance is imperative and the risk of a
* stale result is tolerable.
*
* @param user the user to check for.
* @param organisationUnit the organisation unit.
* @return true if the given organisation unit is part of the hierarchy.
* @deprecated Use {@link org.hisp.dhis.user.UserDetails#isInUserSearchHierarchy(String)} instead
*/
@Deprecated(forRemoval = true)
boolean isInUserSearchHierarchyCached(User user, OrganisationUnit organisationUnit);

/**
* @deprecated Use {@link org.hisp.dhis.user.UserDetails#isInUserSearchHierarchy(String)} instead
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.hisp.dhis.common.IdentifiableObjectStore;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.program.Program;
Expand Down Expand Up @@ -130,18 +128,6 @@ Long getOrganisationUnitHierarchyMemberCount(
*/
List<OrganisationUnit> getOrganisationUnits(OrganisationUnitQueryParams params);

/**
* Creates a mapping between organisation unit UID and set of data set UIDs being assigned to the
* organisation unit.
*
* @param organisationUnits the parent organisation units of the hierarchy to include, ignored if
* null.
* @param dataSets the data set to include, ignored if null.
* @return a map of sets.
*/
Map<String, Set<String>> getOrganisationUnitDataSetAssocationMap(
Collection<OrganisationUnit> organisationUnits, Collection<DataSet> dataSets);

/**
* Retrieves the objects where its coordinate is within the 4 area points. 4 area points are Index
* 0: Maximum latitude (north edge of box shape) Index 1: Maxium longitude (east edge of box
Expand All @@ -153,8 +139,10 @@ Map<String, Set<String>> getOrganisationUnitDataSetAssocationMap(
*/
List<OrganisationUnit> getWithinCoordinateArea(double[] box);

/** Updates the <code>path</code> property of all org units. */
void updatePaths();

/** Explicitly updates the <code>path</code> property of all org units. */
void forceUpdatePaths();

/**
Expand All @@ -166,25 +154,10 @@ Map<String, Set<String>> getOrganisationUnitDataSetAssocationMap(
int getMaxLevel();

/**
* Check if the number of orgunits that satisfies the conditions in the queryParams is greater
* than the threshold provided. Note: groups, maxLevels and levels are not supported yet.
* Sets the geometry field for org units to null.
*
* @param params The Org unit query params
* @param threshold the threshold count to check against
* @return true if the org units satisfying the params criteria is above the threshold, false
* otherwise.
* @return then number of affected org units.
*/
boolean isOrgUnitCountAboveThreshold(OrganisationUnitQueryParams params, int threshold);

/**
* Get list of organisation unit uids satisfying the query params. Note: groups, maxLevels and
* levels are not supported yet.
*
* @param params The Org unit query params
* @return the list of org unit uids satisfying the params criteria
*/
List<String> getOrganisationUnitUids(OrganisationUnitQueryParams params);

int updateAllOrganisationUnitsGeometryToNull();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
package org.hisp.dhis.category;

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
Expand Down Expand Up @@ -132,12 +131,6 @@ public void deleteCategory(Category dataElementCategory) {
categoryStore.delete(dataElementCategory);
}

@Override
@Transactional(readOnly = true)
public List<Category> getAllDataElementCategories() {
return categoryStore.getAll();
}

@Override
@Transactional(readOnly = true)
public Category getCategory(long id) {
Expand Down Expand Up @@ -421,38 +414,6 @@ public List<CategoryCombo> getAttributeCategoryCombos() {
return categoryComboStore.getCategoryCombosByDimensionType(DataDimensionType.ATTRIBUTE);
}

@Override
@Transactional(readOnly = true)
public String validateCategoryCombo(CategoryCombo categoryCombo) {
if (categoryCombo == null) {
return "category_combo_is_null";
}

if (categoryCombo.getCategories() == null || categoryCombo.getCategories().isEmpty()) {
return "category_combo_must_have_at_least_one_category";
}

if (Sets.newHashSet(categoryCombo.getCategories()).size()
< categoryCombo.getCategories().size()) {
return "category_combo_cannot_have_duplicate_categories";
}

Set<CategoryOption> categoryOptions = new HashSet<>();

for (Category category : categoryCombo.getCategories()) {
if (category == null || category.getCategoryOptions().isEmpty()) {
return "categories_must_have_at_least_one_category_option";
}

if (!Sets.intersection(categoryOptions, Sets.newHashSet(category.getCategoryOptions()))
.isEmpty()) {
return "categories_cannot_share_category_options";
}
}

return null;
}

// -------------------------------------------------------------------------
// CategoryOptionCombo
// -------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 68dac3a

Please sign in to comment.