Skip to content

Commit

Permalink
Merge remote-tracking branch 'usnistgov/integration' into rel/1.0.X
Browse files Browse the repository at this point in the history
(setversion fix)
  • Loading branch information
RayPlante committed Mar 8, 2018
2 parents e3180fd + 49be82e commit fd47ca4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
4 changes: 3 additions & 1 deletion oar-build/_setversion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ function get_tag {
#opts=
errfile=/tmp/git-describe-$$_err.txt
git describe $opts 2> $errfile || {
grep -qs 'No names found' $errfile || {
grep -qs 'No names found' $errfile || \
grep -qs 'No tags can describe' $errfile || \
{
echo setversion: git describe failed: 1>&2
cat $errfile 1>&2
rm $errfile
Expand Down
28 changes: 20 additions & 8 deletions src/main/java/gov/nist/oar/rmm/utilities/ProcessRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@
import org.bson.conversions.Bson;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.mongodb.client.model.Aggregates;
import com.mongodb.client.model.Filters;
import com.mongodb.client.model.Projections;
import com.mongodb.client.model.Sorts;



/**
* Process the Rest Api request to parse parameters and create mongodb query.
* @author Deoyani Nandrekar-Heinis
Expand Down Expand Up @@ -94,20 +92,25 @@ public int getPageSize(){
* @param serachparams
*/
public void parseSearch(Map<String,String> serachparams ) {

boolean searchInput = false;
logger.info("Query parsing starts");
if(!serachparams.entrySet().isEmpty()){
validateInput(serachparams);
for (Entry<String, String> entry : serachparams.entrySet()) {
treatSearch(entry.getKey(), entry.getValue());
if (entry.getKey().equalsIgnoreCase("searchphrase")) {
if (entry.getValue().length() > 0) {
searchInput = true;
}
}
}
validateProjections();
if(!advMap.isEmpty())
advFilter(advMap);
}

logger.info("Query parsing ends");
createQuerylist();
createQuerylist(searchInput);

}

Expand Down Expand Up @@ -153,15 +156,24 @@ private void checkInteger(String value){
/**
* This is to create aggregate of all the queries
*/
private void createQuerylist(){
private void createQuerylist(Boolean searchInput){


if(filter != null)
queryList.add(Aggregates.match(filter));
if(projections != null)
if(projections != null) {
queryList.add(Aggregates.project(projections));
if(sort != null)
} else {
//queryList.add(Aggregates.project(Projections.metaTextScore("score")));
}

if(sort != null) {
queryList.add(Aggregates.sort(sort));
} else {
if (searchInput) {
queryList.add(Aggregates.sort(Sorts.metaTextScore("score")));
}
}
if(pagenumber >= 0)
queryList.add(Aggregates.skip(pagenumber> 0 ? ((pagenumber-1)*pagesize) : 0));
if(pagesize > 0)
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ dbcollections:
resources: apis
records: record
recordfields: fields


2 changes: 1 addition & 1 deletion src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
<appender-ref ref="SAVE-TO-FILE"/>
</root>

</configuration>
</configuration>

0 comments on commit fd47ca4

Please sign in to comment.