use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.CREATED in project dhis2-core by dhis2.
the class DashboardController method postJsonItemContent.
@RequestMapping(value = "/{dashboardUid}/items/content", method = RequestMethod.POST)
public void postJsonItemContent(HttpServletResponse response, HttpServletRequest request, @PathVariable String dashboardUid, @RequestParam DashboardItemType type, @RequestParam("id") String contentUid) throws Exception {
Dashboard dashboard = dashboardService.getDashboard(dashboardUid);
if (dashboard == null) {
throw new WebMessageException(WebMessageUtils.notFound("Dashboard does not exist: " + dashboardUid));
}
if (!aclService.canUpdate(currentUserService.getCurrentUser(), dashboard)) {
throw new UpdateAccessDeniedException("You don't have the proper permissions to update this dashboard.");
}
DashboardItem item = dashboardService.addItemContent(dashboardUid, type, contentUid);
if (item == null) {
throw new WebMessageException(WebMessageUtils.conflict("Max number of dashboard items reached: " + MAX_ITEMS));
} else {
response.addHeader("Location", DashboardItemSchemaDescriptor.API_ENDPOINT + "/" + item.getUid());
webMessageService.send(WebMessageUtils.created("Dashboard item created"), response, request);
}
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.CREATED in project dhis2-core by dhis2.
the class AbstractEnrollmentService method saveTrackedEntityComment.
private void saveTrackedEntityComment(ProgramInstance programInstance, Enrollment enrollment, User user) {
for (Note note : enrollment.getNotes()) {
String noteUid = CodeGenerator.isValidUid(note.getNote()) ? note.getNote() : CodeGenerator.generateUid();
if (!commentService.trackedEntityCommentExists(noteUid) && !StringUtils.isEmpty(note.getValue())) {
TrackedEntityComment comment = new TrackedEntityComment();
comment.setUid(noteUid);
comment.setCommentText(note.getValue());
comment.setCreator(StringUtils.isEmpty(note.getStoredBy()) ? user.getUsername() : note.getStoredBy());
Date created = DateUtils.parseDate(note.getStoredDate());
if (created == null) {
created = new Date();
}
comment.setCreated(created);
comment.setLastUpdatedBy(user);
comment.setLastUpdated(new Date());
commentService.addTrackedEntityComment(comment);
programInstance.getComments().add(comment);
programInstanceService.updateProgramInstance(programInstance, user);
teiService.updateTrackedEntityInstance(programInstance.getEntityInstance(), user);
}
}
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.CREATED in project dhis2-core by dhis2.
the class AbstractTrackedEntityInstanceService method mergeOrDeleteTrackedEntityInstances.
// -------------------------------------------------------------------------
// CREATE, UPDATE or DELETE
// -------------------------------------------------------------------------
@Override
@Transactional
public ImportSummaries mergeOrDeleteTrackedEntityInstances(List<TrackedEntityInstance> trackedEntityInstances, ImportOptions importOptions, JobConfiguration jobId) {
notifier.clear(jobId).notify(jobId, "Importing tracked entities");
try {
ImportSummaries importSummaries = new ImportSummaries();
importOptions = updateImportOptions(importOptions);
List<TrackedEntityInstance> create = new ArrayList<>();
List<TrackedEntityInstance> update = new ArrayList<>();
List<TrackedEntityInstance> delete = new ArrayList<>();
// TODO: Check whether relationships are modified during
// create/update/delete TEI logic. Decide whether logic below can be
// removed
List<Relationship> relationships = getRelationships(trackedEntityInstances);
setTrackedEntityListByStrategy(trackedEntityInstances, importOptions, create, update, delete);
importSummaries.addImportSummaries(addTrackedEntityInstances(create, importOptions));
importSummaries.addImportSummaries(updateTrackedEntityInstances(update, importOptions));
importSummaries.addImportSummaries(deleteTrackedEntityInstances(delete, importOptions));
// TODO: Created importSummaries don't contain correct href (TEI
// endpoint instead of relationships is used)
importSummaries.addImportSummaries(relationshipService.processRelationshipList(relationships, importOptions));
if (ImportReportMode.ERRORS == importOptions.getReportMode()) {
importSummaries.getImportSummaries().removeIf(is -> !is.hasConflicts());
}
notifier.notify(jobId, NotificationLevel.INFO, "Import done", true).addJobSummary(jobId, importSummaries, ImportSummaries.class);
return importSummaries;
} catch (RuntimeException ex) {
log.error(DebugUtils.getStackTrace(ex));
notifier.notify(jobId, ERROR, "Process failed: " + ex.getMessage(), true);
return new ImportSummaries().addImportSummary(new ImportSummary(ImportStatus.ERROR, "The import process failed: " + ex.getMessage()));
}
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.CREATED in project dhis2-core by dhis2.
the class EnrollmentRowCallbackHandler method getEnrollment.
private Enrollment getEnrollment(ResultSet rs) throws SQLException {
Enrollment enrollment = new Enrollment();
enrollment.setEnrollment(rs.getString(getColumnName(UID)));
MapperGeoUtils.resolveGeometry(rs.getBytes(getColumnName(GEOMETRY))).ifPresent(enrollment::setGeometry);
enrollment.setTrackedEntityType(rs.getString(getColumnName(TEI_TYPE_UID)));
enrollment.setTrackedEntityInstance(rs.getString(getColumnName(TEI_UID)));
enrollment.setOrgUnit(rs.getString(getColumnName(ORGUNIT_UID)));
enrollment.setOrgUnitName(rs.getString(getColumnName(ORGUNIT_NAME)));
enrollment.setCreated(DateUtils.getIso8601NoTz(rs.getTimestamp(getColumnName(CREATED))));
enrollment.setCreatedAtClient(DateUtils.getIso8601NoTz(rs.getTimestamp(getColumnName(CREATEDCLIENT))));
setUserInfoSnapshot(rs, getColumnName(CREATED_BY), enrollment::setCreatedByUserInfo);
enrollment.setLastUpdated(DateUtils.getIso8601NoTz(rs.getTimestamp(getColumnName(UPDATED))));
enrollment.setLastUpdatedAtClient(DateUtils.getIso8601NoTz(rs.getTimestamp(getColumnName(UPDATEDCLIENT))));
setUserInfoSnapshot(rs, getColumnName(LAST_UPDATED_BY), enrollment::setLastUpdatedByUserInfo);
enrollment.setProgram(rs.getString(getColumnName(PROGRAM_UID)));
enrollment.setStatus(EnrollmentStatus.fromStatusString(rs.getString(getColumnName(STATUS))));
enrollment.setEnrollmentDate(rs.getTimestamp(getColumnName(ENROLLMENTDATE)));
enrollment.setIncidentDate(rs.getTimestamp(getColumnName(INCIDENTDATE)));
final boolean followup = rs.getBoolean(getColumnName(FOLLOWUP));
enrollment.setFollowup(rs.wasNull() ? null : followup);
enrollment.setCompletedDate(rs.getTimestamp(getColumnName(COMPLETED)));
enrollment.setCompletedBy(rs.getString(getColumnName(COMPLETEDBY)));
enrollment.setStoredBy(rs.getString(getColumnName(STOREDBY)));
enrollment.setDeleted(rs.getBoolean(getColumnName(DELETED)));
enrollment.setId(rs.getLong(getColumnName(ID)));
return enrollment;
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.CREATED in project dhis2-core by dhis2.
the class RelationshipRowCallbackHandler method getRelationship.
private Relationship getRelationship(ResultSet rs) throws SQLException {
Relationship relationship = new Relationship();
relationship.setRelationship(rs.getString("rel_uid"));
relationship.setRelationshipType(rs.getString("reltype_uid"));
relationship.setRelationshipName(rs.getString("reltype_name"));
relationship.setFrom(createItem(rs.getString("from_uid")));
relationship.setTo(createItem(rs.getString("to_uid")));
relationship.setBidirectional(rs.getBoolean("reltype_bi"));
relationship.setCreated(DateUtils.getIso8601NoTz(rs.getTimestamp("created")));
relationship.setLastUpdated(DateUtils.getIso8601NoTz(rs.getTimestamp("lastupdated")));
return relationship;
}
Aggregations