Source:
<code>public DiffPreferencesInfo apply(AccountResource rsrc, Input input) throws AuthException, OrmException { if (self.get() != rsrc.getUser() && !self.get().getCapabilities().canAdministrateServer()) { throw new AuthException("restricted to administrator"); } if (input == null) { input = new Input(); } <START> AccountDiffPreference p = rsrc.getUser().getAccountDiffPreference(); <END> p.setContext(input.context); p.setExpandAllComments(input.expandAllComments); p.setIgnoreWhitespace(Objects.firstNonNull(input.ignoreWhitespace, AccountDiffPreference.DEFAULT_IGNORE_WHITESPACE)); p.setIntralineDifference(input.intralineDifference); p.setLineLength(input.lineLength); p.setManualReview(input.manualReview); p.setRetainHeader(input.retainHeader); p.setShowLineEndings(input.showLineEndings); p.setShowTabs(input.showTabs); p.setShowWhitespaceErrors(input.showWhitespaceErrors); p.setSkipDeleted(input.skipDeleted); p.setSkipUncommented(input.skipUncommented); p.setSyntaxHighlighting(input.syntaxHighlighting); p.setTabSize(input.tabSize); db.accountDiffPreferences().upsert(Collections.singleton(p)); return DiffPreferencesInfo.parse(p); }</code><technical_language>Load this database AccountCache. For database I do this in a transaction: db.accounts().beginTransaction(rsrc.getAccountId()); try { p = db.accountDiffPreferences().get(rsrc.getAccountId()); if (p == null) { p = new AccountDiffPreferences(); } db.accountDiffPreferences().upsert(Collections.singleton(p)); db.commit(); } finally { db.rollback(); }</technical_language>

Target:
public DiffPreferencesInfo apply(AccountResource rsrc, Input input) throws AuthException, OrmException { if (self.get() != rsrc.getUser() && !self.get().getCapabilities().canAdministrateServer()) { throw new AuthException("restricted to administrator"); } if (input == null) { input = new Input(); } Account.Id accountId = rsrc.getUser().getAccountId(); AccountDiffPreference p; db.accounts().beginTransaction(accountId); try { p = db.accountDiffPreferences().get(accountId); if (p == null) { p = new AccountDiffPreference(accountId); } if (input.context != null) { p.setContext(input.context); } if (input.ignoreWhitespace != null) { p.setIgnoreWhitespace(input.ignoreWhitespace); } if (input.expandAllComments != null) { p.setExpandAllComments(input.expandAllComments); } if (input.intralineDifference != null) { p.setIntralineDifference(input.intralineDifference); } if (input.lineLength != null) { p.setLineLength(input.lineLength); } if (input.manualReview != null) { p.setManualReview(input.manualReview); } if (input.retainHeader != null) { p.setRetainHeader(input.retainHeader); } if (input.showLineEndings != null) { p.setShowLineEndings(input.showLineEndings); } if (input.showTabs != null) { p.setShowTabs(input.showTabs); } if (input.showWhitespaceErrors != null) { p.setShowWhitespaceErrors(input.showWhitespaceErrors); } if (input.skipDeleted != null) { p.setSkipDeleted(input.skipDeleted); } if (input.skipUncommented != null) { p.setSkipUncommented(input.skipUncommented); } if (input.syntaxHighlighting != null) { p.setSyntaxHighlighting(input.syntaxHighlighting); } if (input.tabSize != null) { p.setTabSize(input.tabSize); } db.accountDiffPreferences().upsert(Collections.singleton(p)); db.commit(); } finally { db.rollback(); } return DiffPreferencesInfo.parse(p); }