Search in sources :

Example 11 with LegendSet

use of org.hisp.dhis.legend.LegendSet in project dhis2-core by dhis2.

the class LegendSetController method deleteObject.

@Override
@RequestMapping(value = "/{uid}", method = RequestMethod.DELETE)
@PreAuthorize("hasRole('F_GIS_ADMIN') or hasRole('F_LEGEND_SET_DELETE') or hasRole('ALL')")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteObject(@PathVariable String uid, HttpServletRequest request, HttpServletResponse response) throws Exception {
    LegendSet legendSet = legendSetService.getLegendSet(uid);
    if (legendSet == null) {
        throw new WebMessageException(WebMessageUtils.notFound("Legend set does not exist: " + uid));
    }
    legendSet.getLegends().clear();
    legendSetService.deleteLegendSet(legendSet);
}
Also used : WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) LegendSet(org.hisp.dhis.legend.LegendSet) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with LegendSet

use of org.hisp.dhis.legend.LegendSet in project dhis2-core by dhis2.

the class DhisConvenienceTest method createLegendSet.

public static LegendSet createLegendSet(char uniqueCharacter) {
    LegendSet legendSet = new LegendSet();
    legendSet.setAutoFields();
    legendSet.setName("LegendSet" + uniqueCharacter);
    return legendSet;
}
Also used : LegendSet(org.hisp.dhis.legend.LegendSet)

Example 13 with LegendSet

use of org.hisp.dhis.legend.LegendSet in project dhis2-core by dhis2.

the class DataSetDeletionHandler method deleteLegendSet.

@Override
public void deleteLegendSet(LegendSet legendSet) {
    for (DataSet dataSet : idObjectManager.getAllNoAcl(DataSet.class)) {
        for (LegendSet ls : dataSet.getLegendSets()) {
            if (legendSet.equals(ls)) {
                dataSet.getLegendSets().remove(ls);
                idObjectManager.updateNoAcl(dataSet);
            }
        }
    }
}
Also used : LegendSet(org.hisp.dhis.legend.LegendSet)

Aggregations

LegendSet (org.hisp.dhis.legend.LegendSet)13 DhisSpringTest (org.hisp.dhis.DhisSpringTest)3 Test (org.junit.Test)3 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)3 List (java.util.List)2 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)2 DataElement (org.hisp.dhis.dataelement.DataElement)2 ObjectBundleValidationReport (org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport)2 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)2 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)2 ClassPathResource (org.springframework.core.io.ClassPathResource)2 AnalyticsTableColumn (org.hisp.dhis.analytics.AnalyticsTableColumn)1 ValueType (org.hisp.dhis.common.ValueType)1 UniqueArrayList (org.hisp.dhis.commons.collection.UniqueArrayList)1 CategoryOptionGroupSet (org.hisp.dhis.dataelement.CategoryOptionGroupSet)1 DataElementCategory (org.hisp.dhis.dataelement.DataElementCategory)1 MetadataImportParams (org.hisp.dhis.dxf2.metadata.MetadataImportParams)1 OrganisationUnitGroupSet (org.hisp.dhis.organisationunit.OrganisationUnitGroupSet)1