use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.CREATED in project dhis2-core by dhis2.
the class MetadataSyncPostProcessor method sendSuccessMailToAdmin.
public void sendSuccessMailToAdmin(MetadataSyncSummary metadataSyncSummary) {
ImportReport importReport = metadataSyncSummary.getImportReport();
StringBuilder text = new StringBuilder("Successful Import Report for the scheduler run for Metadata synchronization \n\n").append("Imported Version Details \n ").append("Version Name: " + metadataSyncSummary.getMetadataVersion().getName() + "\n").append("Version Type: " + metadataSyncSummary.getMetadataVersion().getType() + "\n");
if (importReport.getTypeReportCount() == 0) {
text.append("New Version created. It does not have any metadata changes. \n");
} else {
text.append("Imported Object Details: \n");
importReport.forEachTypeReport(typeReport -> {
Stats stats = typeReport.getStats();
text.append("Metadata Object Type: ").append(typeReport.getKlass()).append("\n").append("Stats: \n").append("total: " + stats.getTotal() + "\n");
if (stats.getCreated() > 0) {
text.append(" created: " + stats.getCreated() + "\n");
}
if (stats.getUpdated() > 0) {
text.append(" updated: " + stats.getUpdated() + "\n");
}
if (stats.getIgnored() > 0) {
text.append(" ignored: " + stats.getIgnored() + "\n");
}
});
text.append("\n\n");
}
if (text.length() > 0) {
log.info("Success mail will be sent with the following message: " + text);
emailService.sendSystemEmail(new Email("Success Notification: Metadata Synchronization", text.toString()));
}
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.CREATED in project dhis2-core by dhis2.
the class DefaultMetadataVersionService method getMetadataExport.
// --------------------------------------------------------------------------
// Private methods
// --------------------------------------------------------------------------
/**
* Generates the metadata export based on the created date of the current
* version.
*/
private ByteArrayOutputStream getMetadataExport(Date minDate) {
ByteArrayOutputStream os;
try {
MetadataExportParams exportParams = new MetadataExportParams();
if (minDate != null) {
List<String> defaultFilterList = new ArrayList<>();
defaultFilterList.add("lastUpdated:gte:" + DateUtils.getLongGmtDateString(minDate));
exportParams.setDefaultFilter(defaultFilterList);
exportParams.setDefaultFields(Lists.newArrayList(":all"));
metadataExportService.validate(exportParams);
}
os = new ByteArrayOutputStream(1024);
ObjectNode metadata = metadataExportService.getMetadataAsNode(exportParams);
renderService.toJson(os, metadata);
} catch (// We have to catch the "Exception" object as no
Exception ex) // specific exception on the contract.
{
String message = "Exception occurred while exporting metadata for capturing a metadata version" + ex.getMessage();
log.error(message, ex);
throw new MetadataVersionServiceException(message, ex);
}
return os;
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.CREATED in project dhis2-core by dhis2.
the class NoteRowCallbackHandler method getNote.
private Note getNote(ResultSet rs) throws SQLException {
Note note = new Note();
note.setNote(rs.getString("uid"));
note.setValue(rs.getString("commenttext"));
note.setStoredBy(rs.getString("creator"));
note.setStoredDate(DateUtils.getIso8601NoTz(rs.getDate("created")));
return note;
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.CREATED in project dhis2-core by dhis2.
the class ProgramStageInstanceMapper method mapForInsert.
public ProgramStageInstance mapForInsert(Event event) {
ImportOptions importOptions = workContext.getImportOptions();
ProgramStageInstance psi = new ProgramStageInstance();
if (importOptions.getIdSchemes().getProgramStageInstanceIdScheme().equals(CODE)) {
psi.setCode(event.getEvent());
} else if (importOptions.getIdSchemes().getProgramStageIdScheme().equals(UID)) {
psi.setUid(event.getUid());
}
// Program Instance
psi.setProgramInstance(this.workContext.getProgramInstanceMap().get(event.getUid()));
// Program Stage
psi.setProgramStage(this.workContext.getProgramStage(importOptions.getIdSchemes().getProgramStageIdScheme(), event.getProgramStage()));
// Org Unit
psi.setOrganisationUnit(this.workContext.getOrganisationUnitMap().get(event.getUid()));
// Status
psi.setStatus(fromInt(event.getStatus().getValue()));
// Attribute Option Combo
psi.setAttributeOptionCombo(this.workContext.getCategoryOptionComboMap().get(event.getUid()));
// Geometry
psi.setGeometry(event.getGeometry());
// Notes
psi.setComments(convertNotes(event, this.workContext));
// Data Values
psi.setEventDataValues(workContext.getEventDataValueMap().get(event.getUid()));
Date dueDate = new Date();
if (event.getDueDate() != null) {
dueDate = parseDate(event.getDueDate());
}
psi.setDueDate(dueDate);
setCompletedDate(event, psi);
// Note that execution date can be null
setExecutionDate(event, psi);
if (psi.getProgramStage() != null && psi.getProgramStage().isEnableUserAssignment()) {
psi.setAssignedUser(this.workContext.getAssignedUserMap().get(event.getUid()));
}
// CREATED AT CLIENT + UPDATED AT CLIENT
psi.setCreatedAtClient(parseDate(event.getCreatedAtClient()));
psi.setLastUpdatedAtClient(parseDate(event.getLastUpdatedAtClient()));
psi.setStoredBy(event.getStoredBy());
psi.setCompletedBy(event.getCompletedBy());
psi.setCreatedByUserInfo(event.getCreatedByUserInfo());
psi.setLastUpdatedByUserInfo(event.getLastUpdatedByUserInfo());
return psi;
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.CREATED in project dhis2-core by dhis2.
the class EventBaseCheck method validateProgramInstance.
private void validateProgramInstance(ImmutableEvent event, WorkContext ctx, List<String> errors) {
ProgramInstance programInstance = ctx.getProgramInstanceMap().get(event.getUid());
ImportOptions importOptions = ctx.getImportOptions();
if (programInstance == null) {
errors.add("No program instance found for event: " + event.getEvent());
} else if (COMPLETED.equals(programInstance.getStatus())) {
if (importOptions == null || importOptions.getUser() == null || importOptions.getUser().isAuthorized(F_EDIT_EXPIRED.getAuthority())) {
return;
}
Date referenceDate = parseDate(event.getCreated());
if (referenceDate == null) {
referenceDate = new Date();
}
referenceDate = removeTimeStamp(referenceDate);
if (referenceDate.after(removeTimeStamp(programInstance.getEndDate()))) {
errors.add("Not possible to add event to a completed enrollment. Event created date ( " + referenceDate + " ) is after enrollment completed date ( " + removeTimeStamp(programInstance.getEndDate()) + " ).");
}
}
}
Aggregations