r7137 - in dumbhippo/trunk/server/src/com/dumbhippo/server: blocks dm
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r7137 - in dumbhippo/trunk/server/src/com/dumbhippo/server: blocks dm
- Date: Mon, 7 Jan 2008 11:39:18 -0600 (CST)
Author: otaylor
Date: 2008-01-07 11:39:18 -0600 (Mon, 07 Jan 2008)
New Revision: 7137
Added:
dumbhippo/trunk/server/src/com/dumbhippo/server/dm/AccountQuestionBlockDMO.java
Modified:
dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AbstractBlockHandlerBean.java
dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockHandlerBean.java
dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockView.java
dumbhippo/trunk/server/src/com/dumbhippo/server/dm/BlockDMO.java
dumbhippo/trunk/server/src/com/dumbhippo/server/dm/DataService.java
Log:
AbstractBlockHandlerBean AccountQuestionBlockDMO: Allow creating/populating ONLY_WHEN_VIEWING_SELF
blocks from SystemViewpoint, since we use that when computing data model properties
AccountQuestionBlockDMO BlockDMO DataService: Expose account question blocks in the data model
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AbstractBlockHandlerBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AbstractBlockHandlerBean.java 2008-01-07 17:35:03 UTC (rev 7136)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AbstractBlockHandlerBean.java 2008-01-07 17:39:18 UTC (rev 7137)
@@ -80,6 +80,11 @@
}
private void checkCreationInvariants(Viewpoint viewpoint, Block block) throws BlockNotVisibleException {
+ // A bit of a hack... when we load block views to backend the data model, we always
+ // do it with the SystemViewpoint, even for ONLY_WHEN_VIEWING_SELF blocks
+ if (viewpoint instanceof SystemViewpoint)
+ return;
+
UserViewpoint userview = null;
if (viewpoint instanceof UserViewpoint)
userview = (UserViewpoint) viewpoint;
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockHandlerBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockHandlerBean.java 2008-01-07 17:35:03 UTC (rev 7136)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockHandlerBean.java 2008-01-07 17:39:18 UTC (rev 7137)
@@ -22,6 +22,10 @@
import com.dumbhippo.persistence.UserBlockData;
import com.dumbhippo.server.AccountSystem;
import com.dumbhippo.server.NotFoundException;
+import com.dumbhippo.server.dm.BlockDMO;
+import com.dumbhippo.server.dm.BlockDMOKey;
+import com.dumbhippo.server.dm.DataService;
+import com.dumbhippo.server.views.SystemViewpoint;
import com.dumbhippo.server.views.UserViewpoint;
import com.dumbhippo.server.views.Viewpoint;
import com.dumbhippo.tx.RetryException;
@@ -64,7 +68,7 @@
Viewpoint viewpoint = blockView.getViewpoint();
String answer = null;
- if (!viewpoint.isOfUser(getData1User(blockView.getBlock())))
+ if (!(viewpoint instanceof SystemViewpoint || viewpoint.isOfUser(getData1User(blockView.getBlock()))))
throw new BlockNotVisibleException("AccountQuestion block only visible to the user it was sent to");
switch (blockView.getQuestion()) {
@@ -173,6 +177,9 @@
logger.warn("UserBlockData didn't exist for the account's owner when answering an account question", e);
}
+ BlockDMOKey dmoKey = new BlockDMOKey(block);
+ DataService.currentSessionRW().changed(BlockDMO.class, dmoKey, "answer");
+ DataService.currentSessionRW().changed(BlockDMO.class, dmoKey, "buttons");
// The call to blockClicked wont restack block since the clicked count
// can only ever be 1, so we need restack the block ourselves to change
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockView.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockView.java 2008-01-07 17:35:03 UTC (rev 7136)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockView.java 2008-01-07 17:39:18 UTC (rev 7137)
@@ -84,4 +84,8 @@
public String getHomeUrl() {
return "/person?who=" + getUserBlockData().getUser().getId();
}
+
+ public String getAnswer() {
+ return answer;
+ }
}
Added: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/AccountQuestionBlockDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/AccountQuestionBlockDMO.java 2008-01-07 17:35:03 UTC (rev 7136)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/AccountQuestionBlockDMO.java 2008-01-07 17:39:18 UTC (rev 7137)
@@ -0,0 +1,49 @@
+package com.dumbhippo.server.dm;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.dumbhippo.dm.annotations.DMO;
+import com.dumbhippo.dm.annotations.DMProperty;
+import com.dumbhippo.dm.annotations.PropertyType;
+import com.dumbhippo.server.blocks.AccountQuestionBlockView;
+import com.dumbhippo.server.blocks.AccountQuestionButton;
+
+ DMO(classId="http://mugshot.org/p/o/accountQuestionBlock")
+public abstract class AccountQuestionBlockDMO extends BlockDMO {
+ protected AccountQuestionBlockDMO(BlockDMOKey key) {
+ super(key);
+ }
+
+ @Override
+ public String getTitle() {
+ return ((AccountQuestionBlockView)blockView).getQuestion().getTitle();
+ }
+
+ @Override
+ public String getDescription() {
+ AccountQuestionBlockView questionBlockView = (AccountQuestionBlockView)blockView;
+
+ return questionBlockView.getQuestion().getDescription(questionBlockView.getAnswer());
+ }
+
+ @DMProperty(defaultInclude=true, type=PropertyType.URL)
+ public String getMoreLink() {
+ return ((AccountQuestionBlockView)blockView).getQuestion().getMoreLink();
+ }
+
+ @DMProperty(defaultInclude=true)
+ public String getAnswer() {
+ return ((AccountQuestionBlockView)blockView).getAnswer();
+ }
+
+ @DMProperty(defaultInclude=true)
+ public List<String> getButtons() {
+ List<String> result = new ArrayList<String>();
+ for (AccountQuestionButton button : ((AccountQuestionBlockView)blockView).getQuestion().getButtons()) {
+ result.add(button.getResponse() + ":" + button.getText());
+ }
+
+ return result;
+ }
+}
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/BlockDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/BlockDMO.java 2008-01-07 17:35:03 UTC (rev 7136)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/BlockDMO.java 2008-01-07 17:39:18 UTC (rev 7137)
@@ -82,6 +82,9 @@
case GOOGLE_READER_SHARED_ITEM:
return BlockDMO.class;
+ case ACCOUNT_QUESTION:
+ return AccountQuestionBlockDMO.class;
+
case POST:
return PostBlockDMO.class;
@@ -99,7 +102,6 @@
case MUSIC_CHAT:
case GROUP_REVISION:
case NETFLIX_MOVIE:
- case ACCOUNT_QUESTION:
case AMAZON_REVIEW:
case AMAZON_WISH_LIST_ITEM:
case OBSOLETE_EXTERNAL_ACCOUNT_UPDATE:
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/DataService.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/DataService.java 2008-01-07 17:35:03 UTC (rev 7136)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/DataService.java 2008-01-07 17:39:18 UTC (rev 7137)
@@ -89,6 +89,7 @@
model.addDMClass(ApplicationDMO.class);
model.addDMClass(BlockDMO.class);
+ model.addDMClass(AccountQuestionBlockDMO.class);
model.addDMClass(GroupChatBlockDMO.class);
model.addDMClass(ThumbnailsBlockDMO.class);
model.addDMClass(PicasaPersonBlockDMO.class);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]