Return file count on GET /document/list

This commit is contained in:
jendib 2013-08-22 17:59:24 +02:00
parent 62a5840777
commit 870a44da0d
6 changed files with 26 additions and 3 deletions

View File

@ -145,7 +145,8 @@ public class DocumentDao {
Map<String, Object> parameterMap = new HashMap<String, Object>(); Map<String, Object> parameterMap = new HashMap<String, Object>();
List<String> criteriaList = new ArrayList<String>(); List<String> criteriaList = new ArrayList<String>();
StringBuilder sb = new StringBuilder("select distinct d.DOC_ID_C c0, d.DOC_TITLE_C c1, d.DOC_DESCRIPTION_C c2, d.DOC_CREATEDATE_D c3, d.DOC_LANGUAGE_C c4, s.SHA_ID_C is not null c5 "); StringBuilder sb = new StringBuilder("select distinct d.DOC_ID_C c0, d.DOC_TITLE_C c1, d.DOC_DESCRIPTION_C c2, d.DOC_CREATEDATE_D c3, d.DOC_LANGUAGE_C c4, s.SHA_ID_C is not null c5, ");
sb.append(" (select count(f.FIL_ID_C) from T_FILE f where f.FIL_DELETEDATE_D is null and f.FIL_IDDOC_C = d.DOC_ID_C) c6 ");
sb.append(" from T_DOCUMENT d "); sb.append(" from T_DOCUMENT d ");
sb.append(" left join T_SHARE s on s.SHA_IDDOCUMENT_C = d.DOC_ID_C and s.SHA_DELETEDATE_D is null "); sb.append(" left join T_SHARE s on s.SHA_IDDOCUMENT_C = d.DOC_ID_C and s.SHA_DELETEDATE_D is null ");
@ -211,6 +212,7 @@ public class DocumentDao {
documentDto.setCreateTimestamp(((Timestamp) o[i++]).getTime()); documentDto.setCreateTimestamp(((Timestamp) o[i++]).getTime());
documentDto.setLanguage((String) o[i++]); documentDto.setLanguage((String) o[i++]);
documentDto.setShared((Boolean) o[i++]); documentDto.setShared((Boolean) o[i++]);
documentDto.setFileCount(((Number) o[i++]).intValue());
documentDtoList.add(documentDto); documentDtoList.add(documentDto);
} }

View File

@ -39,6 +39,8 @@ public class DocumentDto {
*/ */
private Boolean shared; private Boolean shared;
private Integer fileCount;
/** /**
* Getter de id. * Getter de id.
* *
@ -146,4 +148,20 @@ public class DocumentDto {
public void setLanguage(String language) { public void setLanguage(String language) {
this.language = language; this.language = language;
} }
/**
* Getter of fileCount.
* @return fileCount
*/
public Integer getFileCount() {
return fileCount;
}
/**
* Setter of fileCount.
* @param fileCount fileCount
*/
public void setFileCount(Integer fileCount) {
this.fileCount = fileCount;
}
} }

View File

@ -1 +1 @@
- Show number of files on documents list (client/server) - Show number of files on documents list (client)

View File

@ -171,6 +171,7 @@ public class DocumentResource extends BaseResource {
document.put("create_date", documentDto.getCreateTimestamp()); document.put("create_date", documentDto.getCreateTimestamp());
document.put("shared", documentDto.getShared()); document.put("shared", documentDto.getShared());
document.put("language", documentDto.getLanguage()); document.put("language", documentDto.getLanguage());
document.put("file_count", documentDto.getFileCount());
// Get tags // Get tags
List<TagDto> tagDtoList = tagDao.getByDocumentId(documentDto.getId()); List<TagDto> tagDtoList = tagDao.getByDocumentId(documentDto.getId());

View File

@ -16,7 +16,8 @@ App.controller('Navigation', function($scope, $http, $state, $rootScope, User, R
setInterval(function() { setInterval(function() {
$scope.$apply(function() { $scope.$apply(function() {
Restangular.one('app/log').get({ Restangular.one('app/log').get({
limit: 100, // Error count will be wrong if there is more than 10 errors in 10 seconds
limit: 10,
level: 'ERROR' level: 'ERROR'
}).then(function(data) { }).then(function(data) {
// Add new errors // Add new errors

View File

@ -109,6 +109,7 @@ public class TestDocumentResource extends BaseJerseyTest {
Assert.assertTrue(documents.length() == 1); Assert.assertTrue(documents.length() == 1);
Assert.assertEquals(document1Id, documents.getJSONObject(0).getString("id")); Assert.assertEquals(document1Id, documents.getJSONObject(0).getString("id"));
Assert.assertEquals("eng", documents.getJSONObject(0).getString("language")); Assert.assertEquals("eng", documents.getJSONObject(0).getString("language"));
Assert.assertEquals(1, documents.getJSONObject(0).getInt("file_count"));
Assert.assertEquals(1, tags.length()); Assert.assertEquals(1, tags.length());
Assert.assertEquals(tag1Id, tags.getJSONObject(0).getString("id")); Assert.assertEquals(tag1Id, tags.getJSONObject(0).getString("id"));
Assert.assertEquals("SuperTag", tags.getJSONObject(0).getString("name")); Assert.assertEquals("SuperTag", tags.getJSONObject(0).getString("name"));