use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.GEOMETRY in project dhis2-core by dhis2.
the class EventGeometryCheck method check.
@Override
public ImportSummary check(ImmutableEvent event, WorkContext ctx) {
IdScheme scheme = ctx.getImportOptions().getIdSchemes().getProgramStageIdScheme();
ProgramStage programStage = ctx.getProgramStage(scheme, event.getProgramStage());
if (Objects.nonNull(event.getGeometry()) && programStageFeatureCompatibleWithEventGeometry(event, programStage)) {
return new ImportSummary(ImportStatus.ERROR, "Geometry (" + event.getGeometry().getGeometryType() + ") does not conform to the feature type (" + programStage.getFeatureType().value() + ") specified for the program stage: " + programStage.getUid()).setReference(event.getEvent()).incrementIgnored();
}
return success();
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.GEOMETRY 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.GEOMETRY in project dhis2-core by dhis2.
the class TrackedEntityInstanceRowCallbackHandler method getTei.
private TrackedEntityInstance getTei(ResultSet rs) throws SQLException {
TrackedEntityInstance tei = new TrackedEntityInstance();
tei.setTrackedEntityInstance(rs.getString(getColumnName(UID)));
tei.setOrgUnit(rs.getString(getColumnName(ORGUNIT_UID)));
tei.setTrackedEntityType(rs.getString(getColumnName(TYPE_UID)));
tei.setCreated(DateUtils.getIso8601NoTz(rs.getTimestamp(getColumnName(CREATED))));
tei.setCreatedAtClient(DateUtils.getIso8601NoTz(rs.getTimestamp(getColumnName(CREATEDCLIENT))));
setUserInfoSnapshot(rs, getColumnName(CREATED_BY), tei::setCreatedByUserInfo);
tei.setLastUpdated(DateUtils.getIso8601NoTz(rs.getTimestamp(getColumnName(UPDATED))));
tei.setLastUpdatedAtClient(DateUtils.getIso8601NoTz(rs.getTimestamp(getColumnName(UPDATEDCLIENT))));
setUserInfoSnapshot(rs, getColumnName(LAST_UPDATED_BY), tei::setLastUpdatedByUserInfo);
tei.setInactive(rs.getBoolean(getColumnName(INACTIVE)));
tei.setDeleted(rs.getBoolean(getColumnName(DELETED)));
Optional<Geometry> geo = MapperGeoUtils.resolveGeometry(rs.getBytes(getColumnName(GEOMETRY)));
if (geo.isPresent()) {
tei.setGeometry(geo.get());
tei.setFeatureType(FeatureType.getTypeFromName(geo.get().getGeometryType()));
tei.setCoordinates(GeoUtils.getCoordinatesFromGeometry(geo.get()));
}
return tei;
}
Aggregations