/** * Retrieves and sets the default values for the entry. Some of these values (e.g. PI, and Funding * Source) are set by individual users as part of their personal preferences * * @param userId Unique identifier for user requesting the values. * @param type entry type * @return PartData object with the retrieve part defaults */ public PartData getPartDefaults(String userId, EntryType type) { PartData partData = new PartData(type); PreferencesController preferencesController = new PreferencesController(); // pi defaults String value = preferencesController.getPreferenceValue( userId, PreferenceKey.PRINCIPAL_INVESTIGATOR.name()); if (value != null) { Account piAccount = accountController.getByEmail(value); if (piAccount == null) { partData.setPrincipalInvestigator(value); } else { partData.setPrincipalInvestigator(piAccount.getFullName()); partData.setPrincipalInvestigatorEmail(piAccount.getEmail()); partData.setPrincipalInvestigatorId(piAccount.getId()); } } // funding source defaults value = preferencesController.getPreferenceValue(userId, PreferenceKey.FUNDING_SOURCE.name()); if (value != null) { partData.setFundingSource(value); } // owner and creator details Account account = accountController.getByEmail(userId); if (account != null) { partData.setOwner(account.getFullName()); partData.setOwnerEmail(account.getEmail()); partData.setCreator(partData.getOwner()); partData.setCreatorEmail(partData.getOwnerEmail()); } // set the entry type defaults return EntryUtil.setPartDefaults(partData); }