mirror of
https://github.com/sismics/docs.git
synced 2026-02-20 02:58:53 +00:00
Search criterias on full content and specific date
This commit is contained in:
@@ -207,10 +207,14 @@ public class DocumentResource extends BaseResource {
|
||||
DateTimeFormat.forPattern("yyyy").getParser(),
|
||||
DateTimeFormat.forPattern("yyyy-MM").getParser(),
|
||||
DateTimeFormat.forPattern("yyyy-MM-dd").getParser() };
|
||||
DateTimeFormatter yearFormatter = new DateTimeFormatter(null, parsers[0]);
|
||||
DateTimeFormatter monthFormatter = new DateTimeFormatter(null, parsers[1]);
|
||||
DateTimeFormatter dayFormatter = new DateTimeFormatter(null, parsers[2]);
|
||||
DateTimeFormatter formatter = new DateTimeFormatterBuilder().append( null, parsers ).toFormatter();
|
||||
|
||||
String[] criteriaList = search.split(" *");
|
||||
List<String> query = new ArrayList<>();
|
||||
List<String> fullQuery = new ArrayList<>();
|
||||
for (String criteria : criteriaList) {
|
||||
String[] params = criteria.split(":");
|
||||
if (params.length != 2 || Strings.isNullOrEmpty(params[0]) || Strings.isNullOrEmpty(params[1])) {
|
||||
@@ -233,7 +237,7 @@ public class DocumentResource extends BaseResource {
|
||||
documentCriteria.getTagIdList().add(tag.getId());
|
||||
}
|
||||
} else if (params[0].equals("after") || params[0].equals("before")) {
|
||||
// New date criteria
|
||||
// New date span criteria
|
||||
try {
|
||||
DateTime date = formatter.parseDateTime(params[1]);
|
||||
if (params[0].equals("before")) documentCriteria.setCreateDateMax(date.toDate());
|
||||
@@ -241,22 +245,45 @@ public class DocumentResource extends BaseResource {
|
||||
} catch (IllegalArgumentException e) {
|
||||
// NOP
|
||||
}
|
||||
} else if (params[0].equals("at")) {
|
||||
// New specific date criteria
|
||||
try {
|
||||
if (params[1].length() == 10) {
|
||||
DateTime date = dayFormatter.parseDateTime(params[1]);
|
||||
documentCriteria.setCreateDateMin(date.toDate());
|
||||
documentCriteria.setCreateDateMax(date.plusDays(1).toDate());
|
||||
} else if (params[1].length() == 7) {
|
||||
DateTime date = monthFormatter.parseDateTime(params[1]);
|
||||
documentCriteria.setCreateDateMin(date.toDate());
|
||||
documentCriteria.setCreateDateMax(date.plusMonths(1).toDate());
|
||||
} else if (params[1].length() == 4) {
|
||||
DateTime date = yearFormatter.parseDateTime(params[1]);
|
||||
documentCriteria.setCreateDateMin(date.toDate());
|
||||
documentCriteria.setCreateDateMax(date.plusYears(1).toDate());
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
// NOP
|
||||
}
|
||||
} else if (params[0].equals("shared")) {
|
||||
// New shared state criteria
|
||||
if (params[1].equals("yes")) {
|
||||
documentCriteria.setShared(true);
|
||||
}
|
||||
} else if (params[0].equals("lang")) {
|
||||
// New shared state criteria
|
||||
// New language criteria
|
||||
if (Constants.SUPPORTED_LANGUAGES.contains(params[1])) {
|
||||
documentCriteria.setLanguage(params[1]);
|
||||
}
|
||||
} else if (params[0].equals("full")) {
|
||||
// New full content search criteria
|
||||
fullQuery.add(params[1]);
|
||||
} else {
|
||||
query.add(criteria);
|
||||
}
|
||||
}
|
||||
|
||||
documentCriteria.setSearch(Joiner.on(" ").join(query));
|
||||
documentCriteria.setFullSearch(Joiner.on(" ").join(fullQuery));
|
||||
return documentCriteria;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary" ng-disabled="!documentForm.$valid" ng-click="edit()">{{ isEdit() ? 'Edit' : 'Add' }}</button>
|
||||
<button type="submit" class="btn btn-primary" ng-disabled="!documentForm.$valid || fileIsUploading" ng-click="edit()">{{ isEdit() ? 'Edit' : 'Add' }}</button>
|
||||
<button type="submit" class="btn" ng-click="cancel()">Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -7,7 +7,16 @@
|
||||
</p>
|
||||
|
||||
<p class="input-prepend text-center input-block-level">
|
||||
<span class="add-on"><span class="icon-search"></span></span>
|
||||
<span class="add-on"><span class="icon-search"
|
||||
tooltip-placement="bottom"
|
||||
tooltip-html-unsafe="before:2012-05<br/>
|
||||
after:2012-05<br/>
|
||||
at:2012-05<br/>
|
||||
tag:car<br/>
|
||||
full:led<br/>
|
||||
shared:yes<br/>
|
||||
lang:fra"
|
||||
></span></span>
|
||||
<input type="text" placeholder="Search" ng-model="search" class="span10" />
|
||||
</p>
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<li class="span2 text-center thumbnail-container" ng-repeat="file in files">
|
||||
<div class="thumbnail">
|
||||
<a ng-click="openFile(file)">
|
||||
<img class="thumbnail-file" ng-src="api/file/{{ file.id }}/data?thumbnail=true" tooltip="{{ file.mimetype }}" tooltip-placement="top" />
|
||||
<img class="thumbnail-file" ng-src="api/file/{{ file.id }}/data?size=thumb" tooltip="{{ file.mimetype }}" tooltip-placement="top" />
|
||||
</a>
|
||||
<div class="caption">
|
||||
<div class="pull-left">
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
</div>
|
||||
|
||||
<div class="btn-group pull-right">
|
||||
<button type="button" class="btn" ng-click="openFile()"><span class="icon-share"></span></button>
|
||||
<button type="button" class="btn" ng-click="openFile()"><span class="icon-download-alt"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<img ng-if="$stateParams.fileId && (file.mimetype == 'image/png' || file.mimetype == 'image/jpeg' || file.mimetype == 'image/gif')" ng-src="api/file/{{ $stateParams.fileId }}/data" />
|
||||
<img ng-if="$stateParams.fileId && (file.mimetype == 'image/png' || file.mimetype == 'image/jpeg' || file.mimetype == 'image/gif')" ng-src="api/file/{{ $stateParams.fileId }}/data?size=web" />
|
||||
|
||||
<div class="text-center" ng-if="$stateParams.fileId && file.mimetype == 'application/pdf'">
|
||||
<img ng-src="api/file/{{ $stateParams.fileId }}/data?thumbnail=true" />
|
||||
<img ng-src="api/file/{{ $stateParams.fileId }}/data?size=web" />
|
||||
</div>
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
</div>
|
||||
|
||||
<div class="btn-group pull-right">
|
||||
<button type="button" class="btn" ng-click="openFile()"><span class="icon-share"></span></button>
|
||||
<button type="button" class="btn" ng-click="openFile()"><span class="icon-download-alt"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<img ng-if="$stateParams.fileId && (file.mimetype == 'image/png' || file.mimetype == 'image/jpeg' || file.mimetype == 'image/gif')" ng-src="api/file/{{ $stateParams.fileId }}/data?share={{ $stateParams.shareId }}" />
|
||||
<img ng-if="$stateParams.fileId && (file.mimetype == 'image/png' || file.mimetype == 'image/jpeg' || file.mimetype == 'image/gif')" ng-src="api/file/{{ $stateParams.fileId }}/data?size=web&share={{ $stateParams.shareId }}" />
|
||||
|
||||
<div class="text-center" ng-if="$stateParams.fileId && file.mimetype == 'application/pdf'">
|
||||
<img ng-src="api/file/{{ $stateParams.fileId }}/data?thumbnail=true&share={{ $stateParams.shareId }}" />
|
||||
<img ng-src="api/file/{{ $stateParams.fileId }}/data?size=web&share={{ $stateParams.shareId }}" />
|
||||
</div>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<li class="span2 text-center thumbnail-container" ng-repeat="file in files">
|
||||
<div class="thumbnail">
|
||||
<a ng-click="openFile(file)">
|
||||
<img class="thumbnail-file" ng-src="api/file/{{ file.id }}/data?thumbnail=true&share={{ $stateParams.shareId }}" tooltip="{{ file.mimetype }}" tooltip-placement="top" />
|
||||
<img class="thumbnail-file" ng-src="api/file/{{ file.id }}/data?size=thumb&share={{ $stateParams.shareId }}" tooltip="{{ file.mimetype }}" tooltip-placement="top" />
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user