static void sendEnrollmentChanges(DhisApi dhisApi, Enrollment enrollment, boolean sendEvents) throws APIException { if (enrollment == null) { return; } if (Utils.isLocal( enrollment.getTrackedEntityInstance())) { // don't send enrollment with locally made uid return; } if (enrollment.getCreated() == null) { postEnrollment(enrollment, dhisApi); if (sendEvents) { List<Event> events = TrackerController.getEventsByEnrollment(enrollment.getLocalId()); sendEventChanges(dhisApi, events); } } else { if (sendEvents) { List<Event> events = TrackerController.getEventsByEnrollment(enrollment.getLocalId()); sendEventChanges(dhisApi, events); } putEnrollment(enrollment, dhisApi); } }
@ApiMethod( name = "device.list", path = "device", httpMethod = ApiMethod.HttpMethod.GET, scopes = {TrackerAuthentication.EMAIL_SCOPE}, clientIds = { TrackerAuthentication.OTHER_CLIENT_ID, TrackerAuthentication.APP_ENGINE_CLIENT_ID, com.google.api.server.spi.Constant.API_EXPLORER_CLIENT_ID }) public List<TrackerDevice> deviceList(User user, HttpServletRequest request) throws UnauthorizedException { TrackerAuthentication.authenticateOrThrow(user, request); return TrackerController.getDevices(); }
static void sendTrackedEntityInstanceChanges( DhisApi dhisApi, TrackedEntityInstance trackedEntityInstance, boolean sendEnrollments) throws APIException { if (trackedEntityInstance == null) { return; } if (trackedEntityInstance.getCreated() == null) { postTrackedEntityInstance(trackedEntityInstance, dhisApi); } else { putTrackedEntityInstance(trackedEntityInstance, dhisApi); } if (sendEnrollments) { List<Enrollment> enrollments = TrackerController.getEnrollments(trackedEntityInstance); sendEnrollmentChanges(dhisApi, enrollments, sendEnrollments); } }
@ApiMethod( name = "device.reading.list", path = "device/{address}/reading", httpMethod = ApiMethod.HttpMethod.GET, scopes = {TrackerAuthentication.EMAIL_SCOPE}, clientIds = { TrackerAuthentication.OTHER_CLIENT_ID, TrackerAuthentication.APP_ENGINE_CLIENT_ID, com.google.api.server.spi.Constant.API_EXPLORER_CLIENT_ID }) public SortedSet<TrackerReading> getDeviceReadings( User user, HttpServletRequest request, @Named("address") String address) throws UnauthorizedException, UnsupportedEncodingException { TrackerAuthentication.authenticateOrThrow(user, request); if (SystemProperty.environment.value() != SystemProperty.Environment.Value.Production) { address = URLDecoder.decode(address, "UTF-8"); } return TrackerController.getDeviceReadings(address); }
@ApiMethod( name = "device.reading.add", path = "device/{address}/reading", httpMethod = ApiMethod.HttpMethod.POST, scopes = {TrackerAuthentication.EMAIL_SCOPE}, clientIds = { TrackerAuthentication.OTHER_CLIENT_ID, TrackerAuthentication.APP_ENGINE_CLIENT_ID, com.google.api.server.spi.Constant.API_EXPLORER_CLIENT_ID }) public void add( User user, HttpServletRequest request, @Named("node") String nodeId, @Named("address") String address, @Named("readingValue") Double readingValue) throws UnauthorizedException { TrackerAuthentication.authenticateOrThrow(user, request); if (nodeId.contentEquals(TrackerNodeEndpoint.CurrentString)) { nodeId = request.getRemoteAddr(); } address = URLDecoder.decode(address); TrackerController.addReading(nodeId, address, readingValue); }
static void clearFailedItem(String type, long id) { FailedItem item = TrackerController.getFailedItem(type, id); if (item != null) { item.async().delete(); } }