use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.DELETED in project dhis2-core by dhis2.
the class MinMaxDataElementController method deleteObject.
//--------------------------------------------------------------------------
// DELETE
//--------------------------------------------------------------------------
@RequestMapping(method = RequestMethod.DELETE, consumes = "application/json")
@PreAuthorize("hasRole('ALL') or hasRole('F_MINMAX_DATAELEMENT_DELETE')")
public void deleteObject(HttpServletRequest request, HttpServletResponse response) throws Exception {
MinMaxDataElement minMax = renderService.fromJson(request.getInputStream(), MinMaxDataElement.class);
validate(minMax);
minMax = getReferences(minMax);
MinMaxDataElement persisted = minMaxService.getMinMaxDataElement(minMax.getSource(), minMax.getDataElement(), minMax.getOptionCombo());
if (Objects.isNull(persisted)) {
throw new WebMessageException(WebMessageUtils.notFound("Can not find MinMaxDataElement."));
}
minMaxService.deleteMinMaxDataElement(persisted);
webMessageService.send(WebMessageUtils.ok("MinMaxDataElement deleted."), response, request);
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.DELETED in project dhis2-core by dhis2.
the class SpringDataValueSetStore method writeDataValueSet.
private void writeDataValueSet(String sql, DataExportParams params, Date completeDate, final DataValueSet dataValueSet) {
if (params.isSingleDataValueSet()) {
IdSchemes idScheme = params.getOutputIdSchemes() != null ? params.getOutputIdSchemes() : new IdSchemes();
IdScheme ouScheme = idScheme.getOrgUnitIdScheme();
IdScheme dataSetScheme = idScheme.getDataSetIdScheme();
dataValueSet.setDataSet(params.getFirstDataSet().getPropertyValue(dataSetScheme));
dataValueSet.setCompleteDate(getLongGmtDateString(completeDate));
dataValueSet.setPeriod(params.getFirstPeriod().getIsoDate());
dataValueSet.setOrgUnit(params.getFirstOrganisationUnit().getPropertyValue(ouScheme));
}
final Calendar calendar = PeriodType.getCalendar();
jdbcTemplate.query(sql, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
DataValue dataValue = dataValueSet.getDataValueInstance();
PeriodType pt = PeriodType.getPeriodTypeByName(rs.getString("ptname"));
boolean deleted = rs.getBoolean("deleted");
dataValue.setDataElement(rs.getString("deid"));
dataValue.setPeriod(pt.createPeriod(rs.getDate("pestart"), calendar).getIsoDate());
dataValue.setOrgUnit(rs.getString("ouid"));
dataValue.setCategoryOptionCombo(rs.getString("cocid"));
dataValue.setAttributeOptionCombo(rs.getString("aocid"));
dataValue.setValue(rs.getString("value"));
dataValue.setStoredBy(rs.getString("storedby"));
dataValue.setCreated(getLongGmtDateString(rs.getTimestamp("created")));
dataValue.setLastUpdated(getLongGmtDateString(rs.getTimestamp("lastupdated")));
dataValue.setComment(rs.getString("comment"));
dataValue.setFollowup(rs.getBoolean("followup"));
if (deleted) {
dataValue.setDeleted(deleted);
}
dataValue.close();
}
});
dataValueSet.close();
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.DELETED in project dhis2-core by dhis2.
the class DataValueController method deleteDataValue.
// ---------------------------------------------------------------------
// DELETE
// ---------------------------------------------------------------------
@PreAuthorize("hasRole('ALL') or hasRole('F_DATAVALUE_DELETE')")
@RequestMapping(method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteDataValue(@RequestParam String de, @RequestParam(required = false) String co, @RequestParam(required = false) String cc, @RequestParam(required = false) String cp, @RequestParam String pe, @RequestParam String ou, HttpServletResponse response) throws WebMessageException {
// ---------------------------------------------------------------------
// Input validation
// ---------------------------------------------------------------------
DataElement dataElement = getAndValidateDataElement(de);
DataElementCategoryOptionCombo categoryOptionCombo = getAndValidateCategoryOptionCombo(co, false);
DataElementCategoryOptionCombo attributeOptionCombo = getAndValidateAttributeOptionCombo(cc, cp);
Period period = getAndValidatePeriod(pe);
OrganisationUnit organisationUnit = getAndValidateOrganisationUnit(ou);
// ---------------------------------------------------------------------
// Locking validation
// ---------------------------------------------------------------------
validateDataSetNotLocked(dataElement, period, organisationUnit, attributeOptionCombo);
// ---------------------------------------------------------------------
// Period validation
// ---------------------------------------------------------------------
validateDataInputPeriodForDataElementAndPeriod(dataElement, period);
// ---------------------------------------------------------------------
// Delete data value
// ---------------------------------------------------------------------
DataValue dataValue = dataValueService.getDataValue(dataElement, period, organisationUnit, categoryOptionCombo, attributeOptionCombo);
if (dataValue == null) {
throw new WebMessageException(WebMessageUtils.conflict("Data value cannot be deleted because it does not exist"));
}
dataValueService.deleteDataValue(dataValue);
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.DELETED in project dhis2-core by dhis2.
the class KeyJsonValueController method deleteKeyJsonValue.
/**
* Delete a key from the given namespace.
*/
@RequestMapping(value = "/{namespace}/{key}", method = RequestMethod.DELETE, produces = "application/json")
public void deleteKeyJsonValue(@PathVariable String namespace, @PathVariable String key, HttpServletResponse response) throws WebMessageException {
if (!hasAccess(namespace)) {
throw new WebMessageException(WebMessageUtils.forbidden("The namespace '" + namespace + "' is protected, and you don't have the right authority to access it."));
}
KeyJsonValue keyJsonValue = keyJsonValueService.getKeyJsonValue(namespace, key);
if (keyJsonValue == null) {
throw new WebMessageException(WebMessageUtils.notFound("The key '" + key + "' was not found in the namespace '" + namespace + "'."));
}
keyJsonValueService.deleteKeyJsonValue(keyJsonValue);
messageService.sendJson(WebMessageUtils.ok("Key '" + key + "' deleted from namespace '" + namespace + "'."), response);
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.DELETED in project dhis2-core by dhis2.
the class JdbcEventStore method delete.
@Override
public void delete(final List<Event> events) {
if (isNotEmpty(events)) {
final List<String> psiUids = events.stream().map(event -> "'" + event.getEvent() + "'").collect(toList());
final String uids = Joiner.on(",").join(psiUids);
jdbcTemplate.execute("UPDATE programstageinstance SET deleted = true where uid in ( " + uids + ")");
}
}
Aggregations