Changeset 348:d91f6bd7d381 for kraken-dom/src/main/java/org/krakenapps/dom/api/impl/WidgetApiImpl.java
- Timestamp:
- 09/20/11 03:16:11 (8 months ago)
- Branch:
- default
- Convert:
- svn:7c3792e6-d75b-4784-96a6-b298f655ee64/trunk@2782
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kraken-dom/src/main/java/org/krakenapps/dom/api/impl/WidgetApiImpl.java
r2 r348 45 45 @Requires 46 46 private ThreadLocalEntityManagerService entityManagerService; 47 47 48 @Requires 48 49 private ProgramApi programApi; 50 49 51 @Requires 50 52 private AdminApi adminApi; … … 82 84 83 85 @Override 84 public voidremoveWidget(int adminId, int widgetId) throws WidgetNotFoundException {86 public Widget removeWidget(int adminId, int widgetId) throws WidgetNotFoundException { 85 87 Widget widget = removeWidgetInternal(adminId, widgetId); 86 88 fireEntityRemoved(widget); 89 return widget; 87 90 } 88 91 … … 98 101 } 99 102 103 @Override 104 public WidgetConfig setConfig(int adminId, int widgetId, String name, String value) throws WidgetNotFoundException { 105 WidgetConfig config = setConfigInternal(adminId, widgetId, name, value); 106 Widget widget = config.getWidget(); 107 widget.getWidgetConfigs().size(); 108 fireEntityUpdated(widget); 109 return config; 110 } 111 100 112 @Transactional 101 @Override102 public void setConfig(int adminId, int widgetId, String name, String value)throws WidgetNotFoundException {113 private WidgetConfig setConfigInternal(int adminId, int widgetId, String name, String value) 114 throws WidgetNotFoundException { 103 115 EntityManager em = entityManagerService.getEntityManager(); 104 116 … … 121 133 em.persist(config); 122 134 } 135 return config; 123 136 } 124 137 … … 132 145 } 133 146 147 @Override 148 public WidgetConfig unsetConfig(int adminId, int widgetId, String key) throws WidgetConfigNotFoundException { 149 WidgetConfig config = unsetConfigInternal(adminId, widgetId, key); 150 Widget widget = config.getWidget(); 151 widget.getWidgetConfigs().size(); 152 fireEntityUpdated(widget); 153 return config; 154 } 155 134 156 @Transactional 135 @Override136 public void unsetConfig(int adminId, int widgetId, String key)throws WidgetConfigNotFoundException {157 private WidgetConfig unsetConfigInternal(int adminId, int widgetId, String key) 158 throws WidgetConfigNotFoundException { 137 159 EntityManager em = entityManagerService.getEntityManager(); 138 160 try { 139 WidgetConfig config = (WidgetConfig) em .createQuery(140 "FROM WidgetConfig c WHERE c.widget.id = ? AND c.name = ?").setParameter(1, widgetId).setParameter(141 2, key).getSingleResult();161 WidgetConfig config = (WidgetConfig) em 162 .createQuery("FROM WidgetConfig c WHERE c.widget.id = ? AND c.name = ?").setParameter(1, widgetId) 163 .setParameter(2, key).getSingleResult(); 142 164 if (config.getWidget().getAdmin().getId() != adminId) 143 165 throw new WidgetConfigNotFoundException(); 144 166 145 167 em.remove(config); 168 return config; 146 169 } catch (NoResultException e) { 147 170 throw new WidgetConfigNotFoundException();
Note: See TracChangeset
for help on using the changeset viewer.
