Giter Club home page Giter Club logo

repoexpress's Introduction

RepoExpress is a set of thin wrappers to provide a simple and easy way to create domain storage (CRUD persistence) options using the Repository pattern against NoSQL databases. There are various repositories supporting MongoDB, Redis, and Cassandra.

Designed to be utilized in conjunction with RestExpress, but stands alone and does not require RestExpress (except for RestExpress-Common) to be used.

MongoDB Usage

Stable:

		<dependency>
			<groupId>com.strategicgains.repoexpress</groupId>
			<artifactId>repoexpress-mongodb</artifactId>
			<version>0.4.8</version>
		</dependency>

Development:

		<dependency>
			<groupId>com.strategicgains.repoexpress</groupId>
			<artifactId>repoexpress-mongodb</artifactId>
			<version>1.0.0-SNAPSHOT</version>
		</dependency>

Or download the 'stable' jar directly from: http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22RepoExpress%22

Cassandra Usage

Stable:

		<dependency>
			<groupId>com.strategicgains.repoexpress</groupId>
			<artifactId>repoexpress-cassandra</artifactId>
			<version>0.4.8</version>
		</dependency>

Development:

		<dependency>
			<groupId>com.strategicgains.repoexpress</groupId>
			<artifactId>repoexpress-cassandra</artifactId>
			<version>1.0.0-SNAPSHOT</version>
		</dependency>

Redis Usage

Stable:

		<dependency>
			<groupId>com.strategicgains.repoexpress</groupId>
			<artifactId>repoexpress-redis</artifactId>
			<version>0.4.8</version>
		</dependency>

Development:

		<dependency>
			<groupId>com.strategicgains.repoexpress</groupId>
			<artifactId>repoexpress-redis</artifactId>
			<version>1.0.0-SNAPSHOT</version>
		</dependency>

Or download the 'stable' jar directly from: http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22RepoExpress%22

About Maven Snapshots

Note that to use the SNAPSHOT Maven versions mentioned above, you must enable snapshots and a repository in your pom file as follows:

  <profiles>
    <profile>
       <id>allow-snapshots</id>
          <activation><activeByDefault>true</activeByDefault></activation>
       <repositories>
         <repository>
           <id>snapshots-repo</id>
           <url>https://oss.sonatype.org/content/repositories/snapshots</url>
           <releases><enabled>false</enabled></releases>
           <snapshots><enabled>true</enabled></snapshots>
         </repository>
       </repositories>
     </profile>
  </profiles>

Change History:

Release 1.0.0-SNAPSHOT

  • Yuge refactoring for V1. Changed semantics of Identifiable to return a fully-qualified identifier. Entity, which Identifiable, has object ID properties: getId() and setId(T).
  • Introduced Entity interface and AbstractEntity implementation.
  • Introduced CreatedAt and UpdatedAt interfaces. Changed Timestamped to extend them.
  • Format.id(Identifier) now converts all the components to a joined string, shortening UUIDs if requested by Identifiers.useShortUUID().
  • Renamed UuidIdentifiable to UuidEntity and TimestampedUuidIdentifiable to TimestampedUuidEntity.
  • Introduced AbstractTimestampedUuidEntity.
  • Renamed Identifier.primaryKey() to firstComponent(). Added lastComponent(). Removed Identifier.setId(), renamed setId(Identifier) to setIdentifier(Identifier).
  • Renamed AbstractTimestampedIdentifiable to AbstractTimestampedEntity. Changed inheritance hierarchy.
  • InMemoryRepository no longer assigns IDs and, instead, expects the ID to be set on the incoming object. Throws exception if not.
  • Upgraded to Morphia 1.6.1
  • Upgraded to Jedis 3.5.1
  • Upgraded to DataStax driver 4.13.0

Release 0.4.8 - 10 Feb 2016

  • Added Identifiers.useShortUUID() method to support usage of shorter, URL-safe Base64-encoded UUIDs.
  • Introduced Parse and Format utility classes containing static foreign methods to enable formatting of various Identifier types.
  • Updated Cassandra, MongoDB and Redis drivers.

Release 0.4.7 - 28 Jul 2015

  • Set Java output to 1.7 target and source.

Release 0.4.6 - 24 Jul 2015

  • Fixed issue #13 - Added support for :in: filtering on the query string, with support in MongoDB.
  • Updated to Java target and source 1.8.
  • Added test for issue #15. No code changes other than test.
  • Updated database drivers: Cassandra 2.1.7.1, MongoDB 3.0.2, Morphia 1.0.1, Redis 2.7.3

Release 0.4.5 - 13 Mar 2015

  • Upgraded to Morphia 0.110 (MongoDB driver 2.13.0)
  • Upgraded to Jedis 2.6.2

Release 0.4.4 - 02 Dec 2014

  • Upgraded to Cassandra driver 2.1.3
  • Upgraded to Jedis 2.6.1

Release 0.4.3 - 5 Sep 2014

  • Upgraded to RestExpress-Common 0.10.4, cassandra-driver-core to 2.1.0, Jedis 2.5.2, Morphia 0.108, MongoDB repositories now require MongoClient (vs. Mongo) as a constructor parameter.

Release 0.4.2 - 27 May 2014

  • Added ability to change default UUID string format via UuidAdapter.useShortUUID(boolean).
  • Upgraded to RestExpress-Common 0.10.3

Release 0.4.1 - 3 Apr 2014

  • Upgraded Datastax Cassandra driver to 2.0.1
  • Introduced CassandraUuidEntityRepository and CassandraUuidTimestampedEntityRepository.
  • Changed inheritance requirements of CassandraEntityRepository & CassandraTimestampedEntityRepository—to Identifiable (from UuidIdentifiable) and removed UuidIdentifiable, respectively.
  • Exposed deleteStmt to subclasses (protected) in CassandraEntityRepository.java
  • Fixed pattern in string split for cassandra contact points.
  • Added format() methods for Identifier in UuidAdapter class.
  • Changed Identifier.add() to allow duplicate components.
  • Upgrade to RestExpress-Common 0.10.2

Release 0.4.0 - 24 Jan 2014

  • Breaking Change Introduced Identifier class that now supports compound identifiers. This change ripples through the Identifiable interface so that getId() now returns an Identifier instead of a String. Also, setId() now takes an Identifier as an argument.
  • Voldemort Support Removed due to lack of usage and desire to maintain it.
  • Breaking Change Removed AbsractObservableRepository and all identifier adapters since, due to Identifier, adapting IDs is no longer needed (or desired) at the persistence layer. Also changed inheritence hierarchy for MongodbRepository and MongodbEntityRepository which now extend AbstractObservableRepository.
  • Breaking Change refactored IdentifierAdapter methods and type hierarchy. Introduced Identifiers class with static singleton adapters.
  • Upgraded to latest official MongoDB Morphia release (0.105).
  • Introduced TimestampedUuidIdentifiable and Introduced CassandraTimestampedEntityRepository.

Release 0.3.4 - SNAPSHOT (never actually released)

  • Voldemort support is deprecated.
  • Introduced initial Cassandra repository support.

Release 0.3.3 - 17 Jul 2013

  • Fixed issue with MongoDB repository query filter implementation where it converted the value to lower-case erroneously.
  • Added MongodbRepository.find(QueryFilter) method.
  • Changed message in InvalidObjectIdException thrown within StringToByteArrayAdapter.convert().
  • Changed generic type on AbstractRepositoryObserver from T extends TimestampedIdentifiable to T extends Identifiable.
  • Changed generic type on types parameter of MongodbEntityRepository constructor from Class to Class<? extends T> to allow subclasses of T to be passed in.
  • Fixed issued in configureQueryFilter(), removing call to toLowerCase() on the value portion of the contains query.
  • Introduced MongodbUuidEntityRepository and related support classes, including UuidConverter to produce/parse URL-safe UUID instances.
  • Changed MongodbRepository.configureQueryFilter() to leverage FilterOperator settings in FilterComponent and support Object values in FilterComponent.

Release 0.3.2

  • Updated to latest RestExpress-Common, refactoring for QueryFilter addition of operator.

Release 0.3.1

  • Introduced Maven build.
  • Switched to com.github.jmkgreen.morphia version of Morphia (v 1.2.2)

Release 0.3.0

  • Refactored to create separate jars for common functionality and DB-dependent functionality. Now creates 2 jars: RepoExpress...jar and RepoExpress...-mongodb.jar
  • Introduced AbstractTimestampedIdentifiable which has default behavior for TimestampedIdentifiable.
  • Introduced AbstractMongodbPersistable which extends AbstractTimestampedIdentifiable and includes id that is a MongoDB ObjectId. get/set-Id() methods adapt the string to/from an ObjectId.
  • DefaultTimestampedIdentifiableRepositoryObserver now also sets updatedAt on creation.
  • Introduced Voldemort repository.
  • Added Redis repository, using JOhm.

Release 0.2.2

  • Exposed Mongo driver instance in case you need it for something tricky (that Morphia doesn't support) in sub-classes.
  • Fixed issue in MongodbRepository.exists() where it wasn't calling convertId() and using new ObjectId() directly.
  • Added try/catch in MongodbRepository.doDelete(String) to catch InvalidObjectIdException and translate it to NotFoundException.
  • Introduced InvalidObjectIdException to enable implementations of IdentifierAdapter to throw it when it cannot convert the string to an internal identifier. This enables upstream callers to handle it and identify the issue.

Release 0.2

  • Update MongodbRepository to allow use of Replication Sets.

Release 0.1

  • Initial import. Combined concepts from RestExpress and JigForJava full-stack framework.

repoexpress's People

Contributors

fa-at-pulsit avatar grizzlyecollege avatar kevwil avatar tfredrich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

repoexpress's Issues

Cassandra Repository

** Copied from RestExpress **

Cassandra RepoExpress implementation. Consider writing our own object-Cassandra mapper that enhances the Astyanax mapper.

Would like to embrace the DataStax async driver out of the gate if possible. Need a default O/C mapper implementation. Perhaps we can work with the DataStax folks to influence that...

Current thought is that an object mapper is too heavy handed and encourages improper Cassandra use. Need to keep this repo light.

Default ID is UUID to start, perhaps, w/ URL-safe Base 64 encoding

Refactor to Support Other DBs

Refactor the project to utilize separate support jars for different DBs, such as MongoDB, Riak, CouchDB, etc. Thus you can include RepoExpress.jar + the jar for your chosen DB (e.g. RepoExpress-mongo.jar) to create a pluggable library.

CreatedAt Date Changed on Update

The default repository implementation allows the createdAt timestamp to be updated or deleted (set to null) via update(). This should not happen...

Date Filtering and Mongo

I have this scenario in which I need to filter results from a mongodb collection by using the createdAt property.

TimeZone tz = TimeZone.getTimeZone("UTC");
dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.000'Z'");
dateFormatter.setTimeZone(tz);

String start = "2015-02-03T03:20:59.000Z"
filter.addCriteria("createdAt", FilterOperator.GREATER_THAN_OR_EQUAL_TO,dateFormatter.parse(start));

entities = service.readAll(filter, range, order);
long count = service.count(filter);
response.setCollectionResponse(range, entities.size(), count);

Printing the dateFormatter.parse(start) produces: Tue Feb 03 03:20:59 UTC 2015

No rows are returned from mongo using this date. However, if I go in the mongo console and query for:
db.Collection.find({"createdAt": {$gte:ISODate("2015-02-03T03:20:59.000Z")}})
I get valid data.

What am I doing wrong?

MongoDB Timeout/Retry

Recently RepoExpress was refactored slightly to support the injection of a Mongo instance into the constructor. Introduction of a default Mongo instance with MongoOptions that support socket timeouts is needed. The introduction of socket timeouts necessitates the introduction of retry logic. Configurable, of course. :-)

Filter using Contains/Equals (configurable)

Presently, the MongoDB repository uses the 'contains' selector when filtering queries. Other options might be "equals", "startswith", "endswith", etc. Please make them selectable, either via configuration or by passing this in on the query-string.

Perhaps using regex nomenclature would work.

  • Contains by default(e.g. filter=name::todd). This is 'eager' and works like it works currently.
  • Use starts with when preceded by "^" (e.g. filter=name::^todd) or using "", filter=name::todd
  • Use ends with when suffixed by "$" (e.g. filter=name::fredrich$) or maybe PREFIXED? (e.g. "filter=name::$todd" or "filter=name::*todd")
  • Use equals when prefixed with another colon (e.g. filter=name:::todd)

Note that case sensitivity is also an issue here. Toss that in "for free" please... :-)

[MongodbRepository] - public/protected access to morphia object

Hi,
in my pull request i have added public method for morphia object, I understand, that it against idea to make restexpress compatible and easy to switch between different databases. For small queries its perfect but not for advanced. I do mostly project with mongodb, with complicated queries and aggreagation pipelines, and it's realy hard (almost impossible) to do this over restexpress api. And for all this actions, and actions like .map() after aggregation I need a morphia object. Other solution, for example, it's possible to set local variable morphia (in MongodbRepository) to protected..... After that I can extends my implementation of MongodbRepository.
What do you think about it ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.