Changeset 1319
- Timestamp:
- 05/16/11 13:30:28 (13 years ago)
- Location:
- ComponentRegistry/trunk/ComponentRegistry/src
- Files:
-
- 3 added
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/AbstractDescriptionDao.java
r1318 r1319 13 13 import clarin.cmdi.componentregistry.model.AbstractDescription; 14 14 import org.springframework.jdbc.core.simple.ParameterizedSingleColumnRowMapper; 15 import org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport;16 import static clarin.cmdi.componentregistry.impl.database.ComponentDescriptionDatabase.*;17 15 18 16 /** … … 20 18 * @author Twan Goosen <twan.goosen@mpi.nl> 21 19 */ 22 public abstract class AbstractDescriptionDao<T extends AbstractDescription> 23 extends SimpleJdbcDaoSupport { 20 public abstract class AbstractDescriptionDao<T extends AbstractDescription> extends ComponentRegistryDao<T> { 24 21 25 22 private final static Logger LOG = LoggerFactory.getLogger( … … 116 113 public List<T> getUserspaceDescriptions(Number userId) { 117 114 String select = getSelectStatement(). 118 append(" JOIN " + ComponentDescriptionDatabase.TABLE_REGISTRY_USER).119 append(" ON user_id = " + ComponentDescriptionDatabase.TABLE_REGISTRY_USER + ".id").120 append(" WHERE is_deleted = false AND is_public = FALSE and " + ComponentDescriptionDatabase.TABLE_REGISTRY_USER + "." + COLUMN_ID + " = :userId").115 append(" JOIN " + TABLE_REGISTRY_USER). 116 append(" ON user_id = " + TABLE_REGISTRY_USER + ".id"). 117 append(" WHERE is_deleted = false AND is_public = FALSE and " + TABLE_REGISTRY_USER + "." + COLUMN_ID + " = :userId"). 121 118 toString(); 122 119 return getList(select, userId); … … 140 137 getSimpleJdbcTemplate().update(update, Collections.singletonMap("id", id)); 141 138 } 139 142 140 /* 143 * DAO HELPER METHODS (may well be moved to some other place in class hierarchy at a later time)141 * DAO HELPER METHODS 144 142 */ 145 146 private T getFirstOrNull(StringBuilder selectQuery, Object... args) {147 return getFirstOrNull(selectQuery.toString(), args);148 }149 150 private T getFirstOrNull(String selectQuery, Object... args) {151 List<T> list = getList(selectQuery, args);152 if (list.size() > 0) {153 return list.get(0);154 } else {155 return null;156 }157 }158 159 private List<T> getList(StringBuilder selectQuery, Object... args) {160 return getList(selectQuery.toString(), args);161 }162 163 private List<T> getList(String selectQuery, Object... args) {164 return getSimpleJdbcTemplate().query(selectQuery, getRowMapper(), args);165 }166 143 167 144 private StringBuilder getSelectStatement(String... where) { … … 185 162 return "name, description, " + getCMDIdColumn(); 186 163 } 164 165 /** 166 * @return the rowMapper 167 */ 168 protected ParameterizedRowMapper<T> getRowMapper() { 169 return rowMapper; 170 } 187 171 188 172 private final ParameterizedRowMapper<T> rowMapper = new ParameterizedRowMapper<T>() { … … 205 189 } 206 190 }; 207 208 /**209 * @return the rowMapper210 */211 protected ParameterizedRowMapper<T> getRowMapper() {212 return rowMapper;213 }214 191 } -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentDescriptionDao.java
r1303 r1319 3 3 import clarin.cmdi.componentregistry.model.ComponentDescription; 4 4 import java.util.List; 5 import static clarin.cmdi.componentregistry.impl.database.ComponentDescriptionDatabase.*;6 5 7 6 /** -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryFactoryDbImpl.java
r1308 r1319 17 17 public class ComponentRegistryFactoryDbImpl implements ComponentRegistryFactory { 18 18 19 @Autowired20 private Configuration configuration;21 19 @Autowired 22 20 ComponentRegistryBeanFactory componentRegistryBeanFactory; -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ProfileDescriptionDao.java
r1303 r1319 3 3 import clarin.cmdi.componentregistry.model.ProfileDescription; 4 4 import java.util.List; 5 import static clarin.cmdi.componentregistry.impl.database.ComponentDescriptionDatabase.*;6 5 7 6 /** -
ComponentRegistry/trunk/ComponentRegistry/src/main/webresources/WEB-INF/spring-config/persistence.xml
r1289 r1319 6 6 "> 7 7 8 <bean id="profileDescriptionDao" class="clarin.cmdi.componentregistry.impl.database.ProfileDescriptionDaoImpl"> 8 <bean id="profileDescriptionDao" class="clarin.cmdi.componentregistry.impl.database.ProfileDescriptionDao"> 9 <property name="dataSource" ref="dataSource"/> 10 </bean> 11 <bean id="componentDescriptionDao" class="clarin.cmdi.componentregistry.impl.database.ComponentDescriptionDao"> 12 <property name="dataSource" ref="dataSource"/> 13 </bean> 14 <bean id="userDao" class="clarin.cmdi.componentregistry.impl.database.UserDao"> 9 15 <property name="dataSource" ref="dataSource"/> 10 16 </bean> -
ComponentRegistry/trunk/ComponentRegistry/src/test/resources/spring-config/persistence.xml
r1291 r1319 12 12 <property name="dataSource" ref="dataSource"/> 13 13 </bean> 14 <bean id="userDao" class="clarin.cmdi.componentregistry.impl.database.UserDao"> 15 <property name="dataSource" ref="dataSource"/> 16 </bean> 14 17 15 18 </beans>
Note: See TracChangeset
for help on using the changeset viewer.