use of edu.cornell.kfs.sys.businessobject.FavoriteAccount in project cu-kfs by CU-CommunityApps.
the class UserProcurementProfileLookupableHelperServiceImpl method getSearchResultsNoAcctCriteria.
private List<PersistableBusinessObject> getSearchResultsNoAcctCriteria(List<PersistableBusinessObject> searchResults) {
List<PersistableBusinessObject> returnResults = new ArrayList<PersistableBusinessObject>();
for (PersistableBusinessObject pbo : searchResults) {
UserProcurementProfile userProfile = (UserProcurementProfile) pbo;
if (CollectionUtils.isEmpty(userProfile.getFavoriteAccounts())) {
userProfile.setResultAccount(new FavoriteAccount());
returnResults.add(userProfile);
} else {
for (FavoriteAccount account : userProfile.getFavoriteAccounts()) {
returnResults.add(buildUserProfile(userProfile, account));
}
}
}
sortList(returnResults);
return returnResults;
}
use of edu.cornell.kfs.sys.businessobject.FavoriteAccount in project cu-kfs by CU-CommunityApps.
the class FavoriteAccountValuesFinder method getUserFavoriteAccounts.
/*
* get user favoriteacounts with primary account sorted first
*/
private List<FavoriteAccount> getUserFavoriteAccounts() {
Map<String, Object> fieldValues = new HashMap<String, Object>();
fieldValues.put("principalId", GlobalVariables.getUserSession().getPrincipalId());
List<UserProcurementProfile> userProfiles = (List<UserProcurementProfile>) SpringContext.getBean(BusinessObjectService.class).findMatching(UserProcurementProfile.class, fieldValues);
if (CollectionUtils.isNotEmpty(userProfiles)) {
UserProcurementProfile userProfile = userProfiles.get(0);
fieldValues = new HashMap<String, Object>();
fieldValues.put("userProfileId", userProfile.getUserProfileId());
// retrieve from db for sorting purpose.
return (List<FavoriteAccount>) SpringContext.getBean(BusinessObjectService.class).findMatchingOrderBy(FavoriteAccount.class, fieldValues, "primaryInd", false);
}
return null;
}
use of edu.cornell.kfs.sys.businessobject.FavoriteAccount in project cu-kfs by CU-CommunityApps.
the class FavoriteAccountLineBuilderTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
userProcurementProfileValidationService = new UserProcurementProfileValidationServiceImpl();
userFavoriteAccountService = new ExtendedTestUserFavoriteAccountService();
reqsAccounts = new ArrayList<PurApAccountingLine>();
poAccounts = new ArrayList<PurApAccountingLine>();
reqsItem = new RequisitionItem();
poItem = new PurchaseOrderItem();
reqsDoc = getMockedDocument(CuRequisitionDocument.class);
poDoc = getMockedDocument(PurchaseOrderDocument.class);
iwntDoc = getMockedDocument(IWantDocument.class);
iwntDoc.setAccounts(new ArrayList<IWantAccount>());
// Favorite Account with only some fields populated.
testFavoriteAccount = new FavoriteAccount();
testFavoriteAccount.setAccountLineIdentifier(TEST_FAVORITE_ACCOUNT_LINE_ID);
testFavoriteAccount.setUserProfileId(TEST_USER_PROFILE_ID);
testFavoriteAccount.setChartOfAccountsCode(TEST_CHART_CODE);
testFavoriteAccount.setAccountNumber(TEST_ACCOUNT_NUMBER);
testFavoriteAccount.setFinancialObjectCode(TEST_OBJECT_CODE);
// Favorite Account with all fields populated (except reference objects or object ID or version number).
testAltFavoriteAccount = new FavoriteAccount();
testAltFavoriteAccount.setAccountLineIdentifier(TEST_ALT_FAVORITE_ACCOUNT_LINE_ID);
testAltFavoriteAccount.setUserProfileId(TEST_ALT_USER_PROFILE_ID);
testAltFavoriteAccount.setChartOfAccountsCode(TEST_ALT_CHART_CODE);
testAltFavoriteAccount.setAccountNumber(TEST_ALT_ACCOUNT_NUMBER);
testAltFavoriteAccount.setSubAccountNumber(TEST_ALT_SUB_ACCOUNT_NUMBER);
testAltFavoriteAccount.setFinancialObjectCode(TEST_ALT_OBJECT_CODE);
testAltFavoriteAccount.setFinancialSubObjectCode(TEST_ALT_SUB_OBJECT_CODE);
testAltFavoriteAccount.setProjectCode(TEST_ALT_PROJECT_CODE);
testAltFavoriteAccount.setOrganizationReferenceId(TEST_ALT_ORG_REF_ID);
GlobalVariables.setMessageMap(new MessageMap());
}
use of edu.cornell.kfs.sys.businessobject.FavoriteAccount in project cu-kfs by CU-CommunityApps.
the class CuUserFavoriteAccountServiceImplTest method testPrimaryFavoriteAccount.
@Test
public void testPrimaryFavoriteAccount() {
final String principalId = FavoriteAccountFixture.FAVORITE_ACCOUNT_1.createFavoriteAccount().getUserProcurementProfile().getPrincipalId();
FavoriteAccount favoriteAccount = userFavoriteAccountService.getFavoriteAccount(principalId);
Assert.assertTrue("Favorite Account should exist", favoriteAccount != null);
Assert.assertTrue("should be Primary favorite account", favoriteAccount.getPrimaryInd());
favoriteAccount = userFavoriteAccountService.getFavoriteAccount("2");
Assert.assertTrue("Favorite Account should not exist", favoriteAccount == null);
}
use of edu.cornell.kfs.sys.businessobject.FavoriteAccount in project cu-kfs by CU-CommunityApps.
the class CuUserFavoriteAccountServiceImplTest method testSelectedFavoriteAccount.
@Test
public void testSelectedFavoriteAccount() {
FavoriteAccount favoriteAccount1 = FavoriteAccountFixture.FAVORITE_ACCOUNT_1.createFavoriteAccount();
FavoriteAccount favoriteAccount2 = userFavoriteAccountService.getSelectedFavoriteAccount(favoriteAccount1.getAccountLineIdentifier());
Assert.assertTrue("Favorite Account should exist", favoriteAccount2 != null);
Assert.assertTrue("should have the same PK", favoriteAccount1.getAccountLineIdentifier().equals(favoriteAccount2.getAccountLineIdentifier()));
}
Aggregations