Search in sources :

Example 1 with IdentifiableObjects

use of org.hisp.dhis.common.IdentifiableObjects in project dhis2-core by dhis2.

the class AbstractCrudController method deleteCollectionItemsJson.

@RequestMapping(value = "/{uid}/{property}", method = RequestMethod.DELETE, consumes = MediaType.APPLICATION_JSON_VALUE)
public void deleteCollectionItemsJson(@PathVariable("uid") String pvUid, @PathVariable("property") String pvProperty, HttpServletRequest request, HttpServletResponse response) throws Exception {
    List<T> objects = getEntity(pvUid);
    IdentifiableObjects identifiableObjects = renderService.fromJson(request.getInputStream(), IdentifiableObjects.class);
    collectionService.delCollectionItems(objects.get(0), pvProperty, Lists.newArrayList(identifiableObjects.getIdentifiableObjects()));
}
Also used : IdentifiableObjects(org.hisp.dhis.common.IdentifiableObjects) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with IdentifiableObjects

use of org.hisp.dhis.common.IdentifiableObjects in project dhis2-core by dhis2.

the class AbstractCrudController method deleteCollectionItemsXml.

@RequestMapping(value = "/{uid}/{property}", method = RequestMethod.DELETE, consumes = MediaType.APPLICATION_XML_VALUE)
public void deleteCollectionItemsXml(@PathVariable("uid") String pvUid, @PathVariable("property") String pvProperty, HttpServletRequest request, HttpServletResponse response) throws Exception {
    List<T> objects = getEntity(pvUid);
    IdentifiableObjects identifiableObjects = renderService.fromXml(request.getInputStream(), IdentifiableObjects.class);
    collectionService.delCollectionItems(objects.get(0), pvProperty, Lists.newArrayList(identifiableObjects.getIdentifiableObjects()));
}
Also used : IdentifiableObjects(org.hisp.dhis.common.IdentifiableObjects) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with IdentifiableObjects

use of org.hisp.dhis.common.IdentifiableObjects in project dhis2-core by dhis2.

the class AbstractCrudController method addCollectionItemsXml.

@RequestMapping(value = "/{uid}/{property}", method = RequestMethod.POST, consumes = MediaType.APPLICATION_XML_VALUE)
public void addCollectionItemsXml(@PathVariable("uid") String pvUid, @PathVariable("property") String pvProperty, HttpServletRequest request, HttpServletResponse response) throws Exception {
    List<T> objects = getEntity(pvUid);
    IdentifiableObjects identifiableObjects = renderService.fromXml(request.getInputStream(), IdentifiableObjects.class);
    collectionService.delCollectionItems(objects.get(0), pvProperty, Lists.newArrayList(identifiableObjects.getDeletions()));
    collectionService.addCollectionItems(objects.get(0), pvProperty, Lists.newArrayList(identifiableObjects.getAdditions()));
}
Also used : IdentifiableObjects(org.hisp.dhis.common.IdentifiableObjects) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with IdentifiableObjects

use of org.hisp.dhis.common.IdentifiableObjects in project dhis2-core by dhis2.

the class AbstractCrudController method replaceCollectionItemsXml.

@RequestMapping(value = "/{uid}/{property}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_XML_VALUE)
public void replaceCollectionItemsXml(@PathVariable("uid") String pvUid, @PathVariable("property") String pvProperty, HttpServletRequest request, HttpServletResponse response) throws Exception {
    List<T> objects = getEntity(pvUid);
    IdentifiableObjects identifiableObjects = renderService.fromXml(request.getInputStream(), IdentifiableObjects.class);
    collectionService.clearCollectionItems(objects.get(0), pvProperty);
    collectionService.addCollectionItems(objects.get(0), pvProperty, Lists.newArrayList(identifiableObjects.getIdentifiableObjects()));
}
Also used : IdentifiableObjects(org.hisp.dhis.common.IdentifiableObjects) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with IdentifiableObjects

use of org.hisp.dhis.common.IdentifiableObjects in project dhis2-core by dhis2.

the class AbstractCrudController method addCollectionItemsJson.

@RequestMapping(value = "/{uid}/{property}", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
public void addCollectionItemsJson(@PathVariable("uid") String pvUid, @PathVariable("property") String pvProperty, HttpServletRequest request, HttpServletResponse response) throws Exception {
    List<T> objects = getEntity(pvUid);
    IdentifiableObjects identifiableObjects = renderService.fromJson(request.getInputStream(), IdentifiableObjects.class);
    collectionService.delCollectionItems(objects.get(0), pvProperty, Lists.newArrayList(identifiableObjects.getDeletions()));
    collectionService.addCollectionItems(objects.get(0), pvProperty, Lists.newArrayList(identifiableObjects.getAdditions()));
}
Also used : IdentifiableObjects(org.hisp.dhis.common.IdentifiableObjects) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

IdentifiableObjects (org.hisp.dhis.common.IdentifiableObjects)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 BaseIdentifiableObject (org.hisp.dhis.common.BaseIdentifiableObject)2 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)2 TypeReport (org.hisp.dhis.feedback.TypeReport)1 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1