Source:
<code>public void addOrUpdateReport(final Report report, final Organization organization) { final models.ebean.Report ebeanReport = internalModelToBean(report); final models.ebean.Organization ebeanOrg = models.ebean.Organization.findByOrganization(organization); if (ebeanOrg == null) { throw new EntityNotFoundException("Organization not found: " + organization.getId()); } ebeanReport.setOrganization(ebeanOrg); <START> assertIsOpen(); <END> LOGGER.debug() .setMessage("Upserting report") .addData("report", ebeanReport) .addData("organization.uuid", organization.getId()) .log(); try (Transaction transaction = Ebean.beginTransaction()) { addOrUpdateReportSource(ebeanReport.getReportSource()); for (ReportRecipientGroup group : ebeanReport.getRecipientGroups()) { addOrUpdateRecipientGroup(group); } final Optional<models.ebean.Report> existingReport = getBeanReport(report.getId(), organization); final boolean created = !existingReport.isPresent(); LOGGER.debug() .setMessage("Attempting save report") .addData("reportSource.id", ebeanReport.getReportSource().getId()) .addData("reportSource.uuid", ebeanReport.getReportSource().getUuid()) .addData("created", created) .log(); if (existingReport.isPresent()) { ebeanReport.setId(existingReport.get().getId()); Ebean.update(ebeanReport); } else { Ebean.save(ebeanReport); } transaction.commit(); LOGGER.debug() .setMessage("Upserted report") .addData("report", ebeanReport) .addData("created", created) .log(); } catch (final RuntimeException e) { LOGGER.error() .setMessage("Failed to upsert report") .addData("report", ebeanReport) .addData("organization.uuid", organization.getId()) .setThrowable(e) .log(); throw new PersistenceException(e); } }</code><technical_language>this done looking-up organization</technical_language>

Target:
public void addOrUpdateReport(final Report report, final Organization organization) { assertIsOpen(); final models.ebean.Report ebeanReport = internalModelToBean(report); final models.ebean.Organization ebeanOrg = models.ebean.Organization.findByOrganization(organization); if (ebeanOrg == null) { throw new EntityNotFoundException("Organization not found: " + organization.getId()); } ebeanReport.setOrganization(ebeanOrg); LOGGER.debug() .setMessage("Upserting report") .addData("report", ebeanReport) .addData("organization.uuid", organization.getId()) .log(); try (Transaction transaction = Ebean.beginTransaction()) { addOrUpdateReportSource(ebeanReport.getReportSource()); final Optional<models.ebean.Report> existingReport = getBeanReport(report.getId(), organization); final boolean created = !existingReport.isPresent(); LOGGER.debug() .setMessage("Attempting save report") .addData("reportSource.id", ebeanReport.getReportSource().getId()) .addData("reportSource.uuid", ebeanReport.getReportSource().getUuid()) .addData("created", created) .log(); if (existingReport.isPresent()) { ebeanReport.setId(existingReport.get().getId()); Ebean.update(ebeanReport); } else { Ebean.save(ebeanReport); } transaction.commit(); LOGGER.debug() .setMessage("Upserted report") .addData("report", ebeanReport) .addData("created", created) .log(); } catch (final RuntimeException e) { LOGGER.error() .setMessage("Failed to upsert report") .addData("report", ebeanReport) .addData("organization.uuid", organization.getId()) .setThrowable(e) .log(); throw new PersistenceException(e); } }