mirror of
https://github.com/sismics/docs.git
synced 2025-12-13 09:46:17 +00:00
Closes #227: fix searching by tag
This commit is contained in:
@@ -2,6 +2,7 @@ package com.sismics.docs.rest.resource;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sismics.docs.core.constant.AclType;
|
||||
import com.sismics.docs.core.constant.ConfigType;
|
||||
import com.sismics.docs.core.constant.Constants;
|
||||
@@ -452,14 +453,17 @@ public class DocumentResource extends BaseResource {
|
||||
}
|
||||
if (tagDtoList.isEmpty()) {
|
||||
// No tag found, the request must returns nothing
|
||||
documentCriteria.getTagIdList().add(UUID.randomUUID().toString());
|
||||
}
|
||||
for (TagDto tagDto : tagDtoList) {
|
||||
documentCriteria.getTagIdList().add(tagDto.getId());
|
||||
List<TagDto> childrenTagDtoList = TagUtil.findChildren(tagDto, allTagDtoList);
|
||||
for (TagDto childrenTagDto : childrenTagDtoList) {
|
||||
documentCriteria.getTagIdList().add(childrenTagDto.getId());
|
||||
documentCriteria.getTagIdList().add(Lists.newArrayList(UUID.randomUUID().toString()));
|
||||
} else {
|
||||
List<String> tagIdList = Lists.newArrayList();
|
||||
for (TagDto tagDto : tagDtoList) {
|
||||
tagIdList.add(tagDto.getId());
|
||||
List<TagDto> childrenTagDtoList = TagUtil.findChildren(tagDto, allTagDtoList);
|
||||
for (TagDto childrenTagDto : childrenTagDtoList) {
|
||||
tagIdList.add(childrenTagDto.getId());
|
||||
}
|
||||
}
|
||||
documentCriteria.getTagIdList().add(tagIdList);
|
||||
}
|
||||
break;
|
||||
case "after":
|
||||
|
||||
@@ -188,7 +188,7 @@ public class TestDocumentResource extends BaseJerseyTest {
|
||||
Assert.assertEquals(2, searchDocuments("uat:" + DateTimeFormat.forPattern("yyyy-MM-dd").print(new Date().getTime()), document1Token));
|
||||
Assert.assertEquals(2, searchDocuments("uafter:2010 ubefore:2040-08", document1Token));
|
||||
Assert.assertEquals(1, searchDocuments("tag:super", document1Token));
|
||||
// TODO waiting for #227 Assert.assertEquals(1, searchDocuments("tag:super tag:hr", document1Token));
|
||||
Assert.assertEquals(1, searchDocuments("tag:super tag:hr", document1Token));
|
||||
Assert.assertEquals(1, searchDocuments("shared:yes", document1Token));
|
||||
Assert.assertEquals(2, searchDocuments("lang:eng", document1Token));
|
||||
Assert.assertEquals(1, searchDocuments("after:2010 before:2040-08 tag:super shared:yes lang:eng title description full:uranium", document1Token));
|
||||
|
||||
Reference in New Issue
Block a user