Changeset 1318
- Timestamp:
- 05/16/11 13:05:02 (13 years ago)
- Location:
- ComponentRegistry/trunk/ComponentRegistry/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/AbstractDescriptionDao.java
r1316 r1318 63 63 * @return Id of newly inserted description 64 64 */ 65 public Number insertComponent(final AbstractDescription description, 66 final String content) { 65 public Number insertDescription(AbstractDescription description, String content, boolean isPublic, Number userId) { 67 66 SimpleJdbcInsert insert = new SimpleJdbcInsert(getDataSource()). 68 67 withTableName(TABLE_XML_CONTENT).usingGeneratedKeyColumns( … … 76 75 Map<String, Object> params = new HashMap<String, Object>(); 77 76 params.put("content_id", contentId); 78 params.put("is_public", Boolean.TRUE); 77 params.put("userId", userId); 78 params.put("is_public", isPublic); 79 79 params.put("is_deleted", Boolean.FALSE); 80 80 params.put(getCMDIdColumn(), description.getId()); … … 128 128 */ 129 129 public void setDeleted(String id) { 130 String delete = "UPDATE " + getTableName() + " SET is_deleted = true WHERE " + getCMDIdColumn() + " = :id"; 131 getSimpleJdbcTemplate().update(delete, Collections.singletonMap("id", id)); 132 } 133 130 String update = "UPDATE " + getTableName() + " SET is_deleted = true WHERE " + getCMDIdColumn() + " = :id"; 131 getSimpleJdbcTemplate().update(update, Collections.singletonMap("id", id)); 132 } 133 134 public void setPublished(String id, boolean published) { 135 final String update = "UPDATE " + getTableName() + " SET is_published = :published WHERE " + getCMDIdColumn() + " = :id"; 136 final Map<String, Object> args = new HashMap<String, Object>(); 137 args.put("id", id); 138 args.put("published", published); 139 140 getSimpleJdbcTemplate().update(update, Collections.singletonMap("id", id)); 141 } 134 142 /* 135 143 * DAO HELPER METHODS (may well be moved to some other place in class hierarchy at a later time) 136 144 */ 145 137 146 private T getFirstOrNull(StringBuilder selectQuery, Object... args) { 138 147 return getFirstOrNull(selectQuery.toString(), args); … … 153 162 154 163 private List<T> getList(String selectQuery, Object... args) { 155 return getSimpleJdbcTemplate().query(selectQuery, rowMapper, args);164 return getSimpleJdbcTemplate().query(selectQuery, getRowMapper(), args); 156 165 } 157 166 … … 176 185 return "name, description, " + getCMDIdColumn(); 177 186 } 187 178 188 private final ParameterizedRowMapper<T> rowMapper = new ParameterizedRowMapper<T>() { 179 189 … … 195 205 } 196 206 }; 207 208 /** 209 * @return the rowMapper 210 */ 211 protected ParameterizedRowMapper<T> getRowMapper() { 212 return rowMapper; 213 } 197 214 } -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryDbImpl.java
r1316 r1318 119 119 String xml = os.toString(); 120 120 if (description.isProfile()) { 121 profileDescriptionDao.insert Component(description, xml);121 profileDescriptionDao.insertDescription(description, xml, isPublic(), userId); 122 122 } else { 123 componentDescriptionDao.insert Component(description, xml);123 componentDescriptionDao.insertDescription(description, xml, isPublic(), userId); 124 124 } 125 125 return 0; -
ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/impl/database/AbstractDescriptionDaoTest.java
r1316 r1318 41 41 42 42 String testComponent = RegistryTestHelper.getComponentTestContentString(); 43 Number newId = getDao().insert Component(description, testComponent);43 Number newId = getDao().insertDescription(description, testComponent, true, null); 44 44 assertNotNull(newId); 45 45 assertNotNull(getDao().getById(newId)); … … 67 67 int count = getDao().getPublicDescriptions().size(); 68 68 // insert 69 getDao().insert Component(description, testComponent);69 getDao().insertDescription(description, testComponent, true, null); 70 70 assertEquals(count+1, getDao().getPublicDescriptions().size()); 71 71
Note: See TracChangeset
for help on using the changeset viewer.