class MonitoringOfficerServiceImpl extends RootTransactionalService implements MonitoringOfficerService {

    @Override
    public ServiceResult<MonitoringOfficerResource> findMonitoringOfficerForProject(long projectId) {
        Optional<MonitoringOfficer> monitoringOfficer = monitoringOfficerRepository.findOneByProjectIdAndRole(projectId, ProjectParticipantRole.MONITORING_OFFICER);
        if (monitoringOfficer.isPresent()) {
            return toMonitoringOfficerResource(monitoringOfficer.get(), projectId);
        } else {
            return legacyMonitoringOfficer(projectId);
        }
    }

}