Skip to content

Commit

Permalink
Merge pull request #236 from enviroCar/release/1.1.0
Browse files Browse the repository at this point in the history
general merge and release of 1.1.0
  • Loading branch information
matthesrieke committed Aug 11, 2015
2 parents 2163718 + eb1bdfc commit c794e53
Show file tree
Hide file tree
Showing 48 changed files with 1,962 additions and 211 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ language: java
notifications:
email: false
jdk:
- openjdk7
- oraclejdk7
- openjdk6
- oraclejdk8
services: mongodb
after_script:
- "gem query --local | grep bundler >/dev/null || gem install bundler"
Expand Down
5 changes: 2 additions & 3 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<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>
<groupId>org.envirocar.server</groupId>
<artifactId>server</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.1.0</version>
</parent>
<artifactId>core</artifactId>
<name>enviroCar server core</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.joda.time.DateTime;

import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;

Expand Down Expand Up @@ -69,7 +70,7 @@ public boolean isInterval() {

@Override
public String toString() {
return Objects.toStringHelper(TemporalFilter.class)
return MoreObjects.toStringHelper(TemporalFilter.class)
.add("op", getOperator())
.add("begin", getBegin())
.add("end", getEnd())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.envirocar.server.core.dao;

import org.envirocar.server.core.entities.Phenomenon;
import org.envirocar.server.core.entities.Track;
import org.envirocar.server.core.filter.StatisticsFilter;
import org.envirocar.server.core.statistics.Statistic;
import org.envirocar.server.core.statistics.Statistics;
Expand All @@ -30,4 +31,6 @@ public interface StatisticsDao {
Statistics getStatistics(StatisticsFilter request);

Statistic getStatistic(StatisticsFilter request, Phenomenon phenomenon);

public void updateStatisticsOnNewTrack(Track e);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.math.BigDecimal;

import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
Expand Down Expand Up @@ -83,7 +84,7 @@ public double doubleValue() {

@Override
public String toString() {
return Objects.toStringHelper(this)
return MoreObjects.toStringHelper(this)
.add("value", this.value())
.add("unit", this.unit())
.toString();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (C) 2013 The enviroCar project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.envirocar.server.core.guice;

/**
* Listener interface for freeing resources whenever the app is stopped.
*/
public interface ResourceShutdownListener {

void shutdownResources();

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.envirocar.server.core.util.pagination;

import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.base.Optional;

Expand Down Expand Up @@ -119,7 +120,7 @@ public boolean equals(Object obj) {

@Override
public String toString() {
return Objects.toStringHelper(this)
return MoreObjects.toStringHelper(this)
.add("size", this.size)
.add("page", this.page)
.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.envirocar.server.core.util.pagination;

import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Optional;

/**
Expand Down Expand Up @@ -97,7 +97,7 @@ public long getTotalCount() {

@Override
public String toString() {
return Objects.toStringHelper(this)
return MoreObjects.toStringHelper(this)
.add("first", getFirst().orNull())
.add("previous", getPrevious().orNull())
.add("current", getCurrent().orNull())
Expand Down
6 changes: 2 additions & 4 deletions event/pom.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<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>
<groupId>org.envirocar.server</groupId>
<artifactId>server</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.1.0</version>
</parent>
<artifactId>event</artifactId>
<name>enviroCar server event module</name>
Expand Down
9 changes: 6 additions & 3 deletions mongo/pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<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>
<groupId>org.envirocar.server</groupId>
<artifactId>server</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.1.0</version>
</parent>
<artifactId>mongo</artifactId>
<name>enviroCar server mongo backend</name>
Expand Down Expand Up @@ -58,5 +57,9 @@
<artifactId>mongo-java-driver</artifactId>
<groupId>org.mongodb</groupId>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</dependency>
</dependencies>
</project>
27 changes: 9 additions & 18 deletions mongo/src/main/java/org/envirocar/server/mongo/MongoDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@

import javax.annotation.Nullable;

import org.envirocar.server.mongo.entity.MongoMeasurement;

import com.github.jmkgreen.morphia.Datastore;
import com.github.jmkgreen.morphia.Key;
import com.github.jmkgreen.morphia.Morphia;
import com.github.jmkgreen.morphia.converters.DefaultConverters;
import com.github.jmkgreen.morphia.converters.TypeConverter;
import com.github.jmkgreen.morphia.logging.MorphiaLoggerFactory;
import com.github.jmkgreen.morphia.logging.slf4j.SLF4JLogrImplFactory;
Expand All @@ -41,15 +42,12 @@
import com.google.inject.Singleton;
import com.google.inject.name.Named;
import com.mongodb.BasicDBObject;
import com.mongodb.BasicDBObjectBuilder;
import com.mongodb.DBCollection;
import com.mongodb.DBRef;
import com.mongodb.MongoClient;
import com.mongodb.ServerAddress;

import org.envirocar.server.mongo.entity.MongoMeasurement;

import com.mongodb.BasicDBObjectBuilder;

/**
* TODO JavaDoc
*
Expand Down Expand Up @@ -111,25 +109,20 @@ public Mapper getMapper() {
}

private void addConverters(Set<TypeConverter> converters) {
DefaultConverters dc = getMapper().getConverters();
for (TypeConverter tc : converters) {
dc.addConverter(tc);
}
converters.forEach(getMapper().getConverters()::addConverter);
}

private void addMappedClasses(Set<Class<?>> mappedClasses) {
for (Class<?> c : mappedClasses) {
getMapper().addMappedClass(c);
}
mappedClasses.forEach(getMapper()::addMappedClass);
}

/*
* FIXME remove this once 2dsphere indexes are supported by morphia in v1.3.0
*/
private void ensureIndexes() {
DBCollection collection = getDatastore().getCollection(MongoMeasurement.class);
collection.ensureIndex(new BasicDBObject(MongoMeasurement.GEOMETRY, "2dsphere"));
collection.ensureIndex(new BasicDBObjectBuilder()
collection.createIndex(new BasicDBObject(MongoMeasurement.GEOMETRY, "2dsphere"));
collection.createIndex(new BasicDBObjectBuilder()
.append(MongoMeasurement.GEOMETRY, "2dsphere")
.append(MongoMeasurement.TIME, 1)
.get());
Expand All @@ -152,13 +145,11 @@ protected <T> Iterable<T> deref(Class<T> clazz, List<Key<T>> keys) {
List<Iterable<T>> fetched = Lists.newLinkedList();
for (String kind : kindMap.keySet()) {
List<Key<T>> kindKeys = kindMap.get(kind);
List<Object> objIds = new ArrayList<Object>(kindKeys.size());
List<Object> objIds = new ArrayList<>(kindKeys.size());
Class<T> kindClass = clazz == null
? (Class<T>) kindKeys.get(0).getKindClass()
: clazz;
for (Key<T> key : kindKeys) {
objIds.add(key.getId());
}
kindKeys.stream().map(Key::getId).forEach(objIds::add);
fetched.add(getDatastore()
.find(kind, kindClass)
.disableValidation()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2013 The enviroCar project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.envirocar.server.mongo;

import com.google.inject.Inject;
import com.mongodb.Mongo;
import org.envirocar.server.core.guice.ResourceShutdownListener;

/**
*
* @author matthes
*/
public class MongoShutdownListener implements ResourceShutdownListener {

private final Mongo mongo;

@Inject
public MongoShutdownListener(Mongo mongo) {
this.mongo = mongo;
}



@Override
public void shutdownResources() {
if (mongo != null) {
mongo.close();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.envirocar.server.mongo.activities;

import java.util.Objects;

import org.bson.types.ObjectId;
import org.envirocar.server.core.activities.Activity;
import org.envirocar.server.core.activities.ActivityType;
Expand All @@ -33,8 +35,8 @@
import com.github.jmkgreen.morphia.annotations.Transient;
import com.github.jmkgreen.morphia.mapping.Mapper;
import com.github.jmkgreen.morphia.utils.IndexDirection;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.google.inject.assistedinject.AssistedInject;
Expand Down Expand Up @@ -151,7 +153,7 @@ public boolean equals(Object obj) {
return false;
}
final MongoActivity other = (MongoActivity) obj;
return Objects.equal(this.id, other.getId());
return Objects.equals(this.id, other.getId());
}

@Override
Expand All @@ -160,7 +162,7 @@ public String toString() {
}

protected ToStringHelper toStringHelper() {
return Objects.toStringHelper(this)
return MoreObjects.toStringHelper(this)
.omitNullValues()
.add(ID, this.id)
.add(TYPE, this.type)
Expand Down
Loading

0 comments on commit c794e53

Please sign in to comment.