Skip to content

Commit

Permalink
Merge branch 'release/0.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
paul.rutledge committed Jul 19, 2016
2 parents f8e30a5 + 12ef289 commit c07e1c3
Show file tree
Hide file tree
Showing 39 changed files with 1,523 additions and 335 deletions.
85 changes: 85 additions & 0 deletions manage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash

function unit_tests() {
mvn clean test
}

function integration_test() {
mvn clean install failsafe:integration-test
}

function snapshot() {
read -p "This will reset your current working tree to origin/develop, is this okay? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
git fetch
git reset --hard origin/develop

echo "Deploying new release artifacts to sonatype repository."
mvn clean deploy -P release
fi
}


function release() {
read -p "This will reset your current working tree to origin/develop, is this okay? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
git fetch
git reset --hard origin/develop

echo "Creating the release branch"
mvn -Prelease jgitflow:release-start -DpushReleases=true -DautoVersionSubmodules=true

echo "Merging the release branch into develop & master, pushing changes, and tagging new version off of master"
mvn -Prelease jgitflow:release-finish -DnoReleaseBuild=true -DpushReleases=true -DnoDeploy=true

echo "Checking out latest version of master."
git fetch
git checkout origin/master

echo "Deploying new release artifacts to sonatype repository."
mvn clean deploy -P release
fi
}

function upgrade_dependencies() {
echo "Checking for a newer version of a parent pom.xml file"
mvn versions:update-parent

echo "Updating all pom.xml files to the latest available from their respective repositories. No changes will be committed."
mvn versions:use-latest-releases

echo "Checking for properties used to manage dependency versions and updating them as well. No changes will be committed."
mvn versions:update-properties
}

case "$1" in
integration-test)
echo -n "Starting integration tests..."
integration_test
echo ""
;;
release)
echo -n "Preparing to release a new version of the app..."
release
echo ""
;;
unit-test)
echo "Starting unit tests..."
unit_tests
echo ""
;;
upgrade)
echo -n "Checking for new versions of dependencies..."
upgrade_dependencies
echo ""
;;
*)
echo "Usage: ./manage.sh integration-test|release|unit-test|upgrade"
exit 1
esac

exit 0
26 changes: 12 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand All @@ -11,7 +9,7 @@
</parent>

<artifactId>rest-query-engine</artifactId>
<version>1.0-SNAPSHOT</version>
<version>0.7</version>

<name>rest-query-engine</name>
<url>http://github.com/rutledgepaulv/rest-query-engine</url>
Expand Down Expand Up @@ -43,7 +41,13 @@
<dependency>
<groupId>com.github.rutledgepaulv</groupId>
<artifactId>q-builders</artifactId>
<version>1.1</version>
<version>1.4</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.1.RELEASE</version>
</dependency>

<!-- being used for the field type resolution for now. Would like to remove a dependency
Expand All @@ -53,20 +57,14 @@
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.8.2.RELEASE</version>
<version>1.9.2.RELEASE</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.2.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.7.1</version>
<version>2.3.4</version>
<scope>test</scope>
</dependency>

Expand Down
53 changes: 52 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Build Status](https://travis-ci.org/RutledgePaulV/rest-query-engine.svg)](https://travis-ci.org/RutledgePaulV/rest-query-engine)
[![Coverage Status](https://coveralls.io/repos/github/RutledgePaulV/rest-query-engine/badge.svg?branch=master)](https://coveralls.io/github/RutledgePaulV/rest-query-engine?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/RutledgePaulV/rest-query-engine/badge.svg?branch=develop)](https://coveralls.io/github/RutledgePaulV/rest-query-engine?branch=develop)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.rutledgepaulv/rest-query-engine/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.rutledgepaulv/rest-query-engine)


Expand Down Expand Up @@ -70,6 +70,57 @@ public void predicate() {

```

### Installation

#### Release Versions
```xml
<!-- production version not yet released -->
```

#### Snapshot Version
```xml
<dependencies>
<dependency>
<groupId>com.github.rutledgepaulv</groupId>
<artifactId>rest-query-engine</artifactId>
<version>0.6.3-SNAPSHOT</version>
</dependency>
</dependencies>


<repositories>
<repository>
<id>ossrh</id>
<name>Repository for snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
```


#### Optional dependencies
```xml
<dependencies>

<!-- only necessary if you're using the elasticsearch filter builder target type -->
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.2.0</version>
</dependency>

<!-- only necessary if you're using the java.util.function.Predicate target type -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.7.1</version>
</dependency>

</dependencies>
```

### License

Expand Down
23 changes: 0 additions & 23 deletions release.sh

This file was deleted.

12 changes: 0 additions & 12 deletions snapshot.sh

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.github.rutledgepaulv.rqe.adapters;

import com.github.rutledgepaulv.qbuilders.builders.GeneralQueryBuilder;
import com.github.rutledgepaulv.qbuilders.conditions.Condition;
import com.github.rutledgepaulv.qbuilders.nodes.AbstractNode;
import com.github.rutledgepaulv.qbuilders.nodes.AndNode;
import com.github.rutledgepaulv.qbuilders.nodes.ComparisonNode;
import com.github.rutledgepaulv.qbuilders.nodes.OrNode;
import com.github.rutledgepaulv.qbuilders.visitors.NodeVisitor;
import com.github.rutledgepaulv.qbuilders.nodes.*;
import com.github.rutledgepaulv.qbuilders.visitors.AbstractVoidContextNodeVisitor;

import java.util.function.Function;

import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.*;

/**
* This adapter allows for converting between a general tree with logical and leaf nodes into a
Expand All @@ -23,7 +21,7 @@ public Condition<GeneralQueryBuilder> apply(AbstractNode tree) {
}


private class QBuilderVisitor extends NodeVisitor<Condition<GeneralQueryBuilder>> {
private class QBuilderVisitor extends AbstractVoidContextNodeVisitor<Condition<GeneralQueryBuilder>> {

@Override
protected Condition<GeneralQueryBuilder> visit(AndNode node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public ConverterChain(Iterable<ArgConverter> converters) {

public ConverterChain(ConverterChain clone) {
clone.converters.forEach(this::appendInternal);
clone.switchBoard.entrySet().stream().forEach(entry -> switchBoard.put(entry.getKey(), entry.getValue()));
clone.switchBoard.entrySet().stream().forEach(entry ->
switchBoard.put(entry.getKey(), entry.getValue()));
}

public ConverterChain disable(Class<? extends ArgConverter> clazz) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package com.github.rutledgepaulv.rqe.argconverters;

import com.github.rutledgepaulv.qbuilders.structures.FieldPath;
import com.github.rutledgepaulv.rqe.contexts.ArgConversionContext;
import com.github.rutledgepaulv.rqe.contexts.PropertyPath;
import com.github.rutledgepaulv.rqe.conversions.StringToTypeConverter;

import java.util.List;
import java.util.function.BiFunction;

import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.*;

public class EntityFieldTypeConverter implements ArgConverter {

private BiFunction<PropertyPath, Class<?>, Class<?>> fieldTypeResolver;
private BiFunction<FieldPath, Class<?>, Class<?>> fieldTypeResolver;
private StringToTypeConverter converter;

public EntityFieldTypeConverter(BiFunction<PropertyPath, Class<?>, Class<?>> fieldTypeResolver, StringToTypeConverter converter) {
public EntityFieldTypeConverter(BiFunction<FieldPath, Class<?>, Class<?>> fieldTypeResolver, StringToTypeConverter converter) {
this.fieldTypeResolver = fieldTypeResolver;
this.converter = converter;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
package com.github.rutledgepaulv.rqe.argconverters;

import com.github.rutledgepaulv.qbuilders.nodes.AbstractNode;
import com.github.rutledgepaulv.qbuilders.structures.FieldPath;
import com.github.rutledgepaulv.rqe.contexts.ArgConversionContext;
import com.github.rutledgepaulv.rqe.contexts.ParseTreeContext;
import com.github.rutledgepaulv.rqe.exceptions.UnsupportedQueryOperatorException;
import com.github.rutledgepaulv.rqe.utils.TriFunction;

import java.util.List;
import java.util.function.Function;
import java.util.function.BiFunction;

import static java.util.Collections.singletonList;
import static java.util.stream.Collectors.toList;
import static java.util.Collections.*;
import static java.util.stream.Collectors.*;

public class OperatorSpecificConverter implements ArgConverter {

private Function<String, AbstractNode> subqueryPipeline;
private TriFunction<String, Class<?>, ParseTreeContext, AbstractNode> subqueryPipeline;
private BiFunction<FieldPath, Class<?>, Class<?>> resolver;

public OperatorSpecificConverter(Function<String, AbstractNode> subqueryPipeline) {
public OperatorSpecificConverter(TriFunction<String, Class<?>, ParseTreeContext, AbstractNode> subqueryPipeline,
BiFunction<FieldPath, Class<?>, Class<?>> resolver) {
this.subqueryPipeline = subqueryPipeline;
this.resolver = resolver;
}

@Override
Expand All @@ -29,14 +35,22 @@ public List<?> apply(ArgConversionContext context) {
case EXISTS:
return context.getValues().stream().map(Boolean::valueOf).collect(toList());
case SUBQUERY_ANY:
return singletonList(parse(context.getValues().iterator().next()));
return singletonList(parse(context));
default:
throw new UnsupportedQueryOperatorException("This converter cannot handle the operator " + context.getQueryOperator());
}
}

private AbstractNode parse(String value) {
return subqueryPipeline.apply(value);
private AbstractNode parse(ArgConversionContext context) {
ParseTreeContext subqueryContext = new ParseTreeContext();
subqueryContext.setParentPath(context.getPropertyPath());

return subqueryPipeline.apply(context.getValues().iterator().next(),
subType(context.getPropertyPath(), context.getEntityType()), subqueryContext);
}

private Class<?> subType(FieldPath propertyPath, Class<?> entityType) {
return resolver.apply(propertyPath, entityType);
}

}
Loading

0 comments on commit c07e1c3

Please sign in to comment.