r7516 - in dumbhippo/trunk/server/src/com/dumbhippo: persistence server/dm



Author: marinaz
Date: 2008-09-29 17:17:31 -0500 (Mon, 29 Sep 2008)
New Revision: 7516

Modified:
   dumbhippo/trunk/server/src/com/dumbhippo/persistence/ExternalAccount.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ExternalAccountDMO.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/dm/UserDMO.java
Log:
Make changes for sending all loved accounts to the client.
Sort the list by the account type full name. 

Modified: dumbhippo/trunk/server/src/com/dumbhippo/persistence/ExternalAccount.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/persistence/ExternalAccount.java	2008-09-25 21:54:25 UTC (rev 7515)
+++ dumbhippo/trunk/server/src/com/dumbhippo/persistence/ExternalAccount.java	2008-09-29 22:17:31 UTC (rev 7516)
@@ -240,11 +240,18 @@
 	}
 	
 	@Transient
+	public String getFullName() {
+		return onlineAccountType.getFullName();
+	}
+	
+	@Transient
 	public String getLink() {
-		if (hasAccountInfo())
+		// TODO: probably need to have another field in OnlineAccountType to get a format
+		// of the profile link, given the handle
+		if (accountType != null && hasAccountInfo())
 			return accountType.getLink(handle, extra);
 		else
-			throw new RuntimeException("can't getLink() on account without handle/extra");
+			return onlineAccountType.getSite();
 	}
 	
 	@Transient
@@ -311,6 +318,11 @@
 	public boolean isLovedAndEnabled() {
 		return hasLovedAndEnabledType(accountType);
 	}
+		
+	@Transient
+	public boolean isGnomeLovedAndEnabled() {
+		return getSentiment() == Sentiment.LOVE && getAccount().isActive() && hasAccountInfo();
+	}
 	
 	/** 
 	 * I think we've declared this deprecated on the grounds that if sentiment is LOVE then 

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ExternalAccountDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ExternalAccountDMO.java	2008-09-25 21:54:25 UTC (rev 7515)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ExternalAccountDMO.java	2008-09-29 22:17:31 UTC (rev 7516)
@@ -52,7 +52,7 @@
 	// FIXME: probably should add enum support and only convert to string when going to XML
 	@DMProperty(defaultInclude=true)
 	public String getAccountType() {
-		return externalAccount.getAccountType().toString();
+		return externalAccount.getOnlineAccountType().getName();
 	}
 	
 	// FIXME: probably should add enum support and only convert to string when going to XML
@@ -71,7 +71,7 @@
 	
 	@DMProperty(defaultInclude=true, type=PropertyType.URL)
 	public String getLink() {
-		if (externalAccount.isLovedAndEnabled())
+		if (externalAccount.isGnomeLovedAndEnabled())
 			return externalAccount.getLink();
 		else
 			return null;
@@ -79,7 +79,12 @@
 	
 	@DMProperty(defaultInclude=true, type=PropertyType.URL)
 	public String getIconUrl() {
-		return "/images3/" + externalAccount.getIconName();
+		String iconName = externalAccount.getIconName();
+		// TODO: need a generic favicon icon or use favicon scraping
+		if (iconName.isEmpty())
+			return "/images3/feed_icon16x16.png";
+		else 	
+		    return "/images3/" + externalAccount.getIconName();
 	}
 
 	@DMProperty(defaultInclude=true)

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/UserDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/UserDMO.java	2008-09-25 21:54:25 UTC (rev 7515)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/UserDMO.java	2008-09-29 22:17:31 UTC (rev 7516)
@@ -16,6 +16,7 @@
 import com.dumbhippo.GlobalSetup;
 import com.dumbhippo.Pair;
 import com.dumbhippo.Site;
+import com.dumbhippo.SortUtils;
 import com.dumbhippo.dm.DMFeed;
 import com.dumbhippo.dm.DMFeedItem;
 import com.dumbhippo.dm.DMObject;
@@ -136,9 +137,13 @@
 	@DMProperty
 	public List<ExternalAccountDMO> getLovedAccounts() {
 		List<ExternalAccountDMO> result = new ArrayList<ExternalAccountDMO>();
-		
-		for (ExternalAccount externalAccount : user.getAccount().getExternalAccounts()) {
-			if (externalAccount.isLovedAndEnabled())
+
+		Set<ExternalAccount> allAccounts = user.getAccount().getExternalAccounts();
+		List<ExternalAccount> alphabetizedAccounts = 
+			SortUtils.sortCollection(allAccounts.toArray(new ExternalAccount[allAccounts.size()]), "getFullName");
+
+		for (ExternalAccount externalAccount : alphabetizedAccounts) {
+			if (externalAccount.isGnomeLovedAndEnabled())
 				result.add(session.findUnchecked(ExternalAccountDMO.class, new ExternalAccountKey(externalAccount)));
 		}
 		



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]