mirror of
https://github.com/sismics/docs.git
synced 2024-11-25 15:17:57 +01:00
Closes #66: Search by creator
This commit is contained in:
parent
d8d01b077d
commit
ef3a592807
@ -259,6 +259,10 @@ public class DocumentDao {
|
||||
criteriaList.add("d.DOC_LANGUAGE_C = :language");
|
||||
parameterMap.put("language", criteria.getLanguage());
|
||||
}
|
||||
if (criteria.getCreatorId() != null) {
|
||||
criteriaList.add("d.DOC_IDUSER_C = :creatorId");
|
||||
parameterMap.put("creatorId", criteria.getCreatorId());
|
||||
}
|
||||
|
||||
criteriaList.add("d.DOC_DELETEDATE_D is null");
|
||||
|
||||
|
@ -51,146 +51,79 @@ public class DocumentCriteria {
|
||||
private String language;
|
||||
|
||||
/**
|
||||
* Getter of userId.
|
||||
*
|
||||
* @return userId
|
||||
* Creator ID.
|
||||
*/
|
||||
private String creatorId;
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter of userId.
|
||||
*
|
||||
* @param userId userId
|
||||
*/
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter of search.
|
||||
*
|
||||
* @return the search
|
||||
*/
|
||||
public String getSearch() {
|
||||
return search;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter of search.
|
||||
*
|
||||
* @param search search
|
||||
*/
|
||||
public void setSearch(String search) {
|
||||
this.search = search;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter of fullSearch.
|
||||
*
|
||||
* @return the fullSearch
|
||||
*/
|
||||
public String getFullSearch() {
|
||||
return fullSearch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter of fullSearch.
|
||||
*
|
||||
* @param fullSearch fullSearch
|
||||
*/
|
||||
public void setFullSearch(String fullSearch) {
|
||||
this.fullSearch = fullSearch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter of createDateMin.
|
||||
*
|
||||
* @return the createDateMin
|
||||
*/
|
||||
public Date getCreateDateMin() {
|
||||
return createDateMin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter of createDateMin.
|
||||
*
|
||||
* @param createDateMin createDateMin
|
||||
*/
|
||||
public void setCreateDateMin(Date createDateMin) {
|
||||
this.createDateMin = createDateMin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter of createDateMax.
|
||||
*
|
||||
* @return the createDateMax
|
||||
*/
|
||||
public Date getCreateDateMax() {
|
||||
return createDateMax;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter of createDateMax.
|
||||
*
|
||||
* @param createDateMax createDateMax
|
||||
*/
|
||||
public void setCreateDateMax(Date createDateMax) {
|
||||
this.createDateMax = createDateMax;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter of tagIdList.
|
||||
*
|
||||
* @return the tagIdList
|
||||
*/
|
||||
public List<String> getTagIdList() {
|
||||
return tagIdList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter of tagIdList.
|
||||
*
|
||||
* @param tagIdList tagIdList
|
||||
*/
|
||||
public void setTagIdList(List<String> tagIdList) {
|
||||
this.tagIdList = tagIdList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter of shared.
|
||||
*
|
||||
* @return the shared
|
||||
*/
|
||||
public Boolean getShared() {
|
||||
return shared;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter of shared.
|
||||
*
|
||||
* @param shared shared
|
||||
*/
|
||||
public void setShared(Boolean shared) {
|
||||
this.shared = shared;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter of language.
|
||||
*
|
||||
* @return the language
|
||||
*/
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter of language.
|
||||
*
|
||||
* @param language language
|
||||
*/
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
public String getCreatorId() {
|
||||
return creatorId;
|
||||
}
|
||||
|
||||
public void setCreatorId(String creatorId) {
|
||||
this.creatorId = creatorId;
|
||||
}
|
||||
}
|
||||
|
@ -13,20 +13,10 @@ public class UserCriteria {
|
||||
*/
|
||||
private String search;
|
||||
|
||||
/**
|
||||
* Getter of search.
|
||||
*
|
||||
* @return the search
|
||||
*/
|
||||
public String getSearch() {
|
||||
return search;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter of search.
|
||||
*
|
||||
* @param search search
|
||||
*/
|
||||
public UserCriteria setSearch(String search) {
|
||||
this.search = search;
|
||||
return this;
|
||||
|
@ -295,6 +295,7 @@ public class DocumentResource extends BaseResource {
|
||||
}
|
||||
|
||||
TagDao tagDao = new TagDao();
|
||||
UserDao userDao = new UserDao();
|
||||
DateTimeParser[] parsers = {
|
||||
DateTimeFormat.forPattern("yyyy").getParser(),
|
||||
DateTimeFormat.forPattern("yyyy-MM").getParser(),
|
||||
@ -370,6 +371,16 @@ public class DocumentResource extends BaseResource {
|
||||
if (Constants.SUPPORTED_LANGUAGES.contains(params[1])) {
|
||||
documentCriteria.setLanguage(params[1]);
|
||||
}
|
||||
} else if (params[0].equals("by")) {
|
||||
// New creator criteria
|
||||
User user = userDao.getActiveByUsername(params[1]);
|
||||
if (user == null) {
|
||||
// This user doesn't exists, return nothing
|
||||
documentCriteria.setCreatorId(UUID.randomUUID().toString());
|
||||
} else {
|
||||
// This user exists, search its documents
|
||||
documentCriteria.setCreatorId(user.getId());
|
||||
}
|
||||
} else if (params[0].equals("full")) {
|
||||
// New full content search criteria
|
||||
fullQuery.add(params[1]);
|
||||
|
@ -26,7 +26,8 @@
|
||||
tag:car<br/>
|
||||
full:led<br/>
|
||||
shared:yes<br/>
|
||||
lang:fra"></span>
|
||||
lang:fra<br/>
|
||||
by:user1"></span>
|
||||
</span>
|
||||
<input type="search" class="form-control" placeholder="Search" ng-model="search" />
|
||||
<span class="input-group-addon">
|
||||
|
@ -55,7 +55,7 @@ public class TestDocumentResource extends BaseJerseyTest {
|
||||
String tag1Id = json.getString("id");
|
||||
Assert.assertNotNull(tag1Id);
|
||||
|
||||
// Create a document
|
||||
// Create a document with document1
|
||||
long create1Date = new Date().getTime();
|
||||
json = target().path("/document").request()
|
||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, document1Token)
|
||||
@ -176,6 +176,9 @@ public class TestDocumentResource extends BaseJerseyTest {
|
||||
Assert.assertEquals(1, searchDocuments("software", document1Token));
|
||||
Assert.assertEquals(1, searchDocuments("greenland", document1Token));
|
||||
Assert.assertEquals(1, searchDocuments("public domain", document1Token));
|
||||
Assert.assertEquals(0, searchDocuments("by:document3", document1Token));
|
||||
Assert.assertEquals(1, searchDocuments("by:document1", document1Token));
|
||||
Assert.assertEquals(0, searchDocuments("by:nobody", document1Token));
|
||||
Assert.assertEquals(1, searchDocuments("at:" + DateTimeFormat.forPattern("yyyy").print(new Date().getTime()), document1Token));
|
||||
Assert.assertEquals(1, searchDocuments("at:" + DateTimeFormat.forPattern("yyyy-MM").print(new Date().getTime()), document1Token));
|
||||
Assert.assertEquals(1, searchDocuments("at:" + DateTimeFormat.forPattern("yyyy-MM-dd").print(new Date().getTime()), document1Token));
|
||||
|
Loading…
Reference in New Issue
Block a user