Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repository insert/update returns a Future[Unit] #11

Merged
merged 5 commits into from
Oct 27, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
target
.cache
.classpath
.idea
.idea_modules
.history
.orig
.project
.settings
.target
*~
target
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version := "0.9.1"
version := "0.9.2"

name := "dsl-client-scala"

organization := "com.dslplatform"

publishTo := Some(if (version.value endsWith "SNAPSHOT") Opts.resolver.sonatypeSnapshots else Opts.resolver.sonatypeStaging)
publishTo := Some(if (version.value endsWith "-SNAPSHOT") Opts.resolver.sonatypeSnapshots else Opts.resolver.sonatypeStaging)

licenses += ("BSD-style", url("http://opensource.org/licenses/BSD-3-Clause"))

Expand Down
4 changes: 0 additions & 4 deletions continuous-compilation.bat

This file was deleted.

4 changes: 0 additions & 4 deletions continuous-compilation.sh

This file was deleted.

4 changes: 0 additions & 4 deletions core/continuous-compilation.bat

This file was deleted.

4 changes: 0 additions & 4 deletions core/continuous-compilation.sh

This file was deleted.

4 changes: 0 additions & 4 deletions core/cross-publish.bat

This file was deleted.

4 changes: 0 additions & 4 deletions core/cross-publish.sh

This file was deleted.

4 changes: 0 additions & 4 deletions core/open-console.bat

This file was deleted.

4 changes: 0 additions & 4 deletions core/open-console.sh

This file was deleted.

7 changes: 0 additions & 7 deletions core/sbt.bat

This file was deleted.

6 changes: 0 additions & 6 deletions core/sbt.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,32 @@ package com.dslplatform.api.client
import scala.concurrent.Future
import scala.reflect.ClassTag

/**
* Proxy service to remote RPC-like API.
* <p>
* Remote services can be called using their name.
*/
/** Proxy service to remote RPC-like API.
*
* Remote services can be called using their name.
*/
trait ApplicationProxy {
/**
* If remote service doesn't require any arguments it can be called using get method.
* Provide class of result for deserialization.
*
* @tparam TResult result type
* @param command remote service name
* @param expectedStatus expected status from remote call
* @return future with deserialized result
*/
/** If remote service doesn't require any arguments it can be called using get method.
* Provide class of result for deserialization.
*
* @tparam TResult result type
* @param command remote service name
* @param expectedStatus expected status from remote call
* @return future with deserialized result
*/
def get[TResult: ClassTag](
command: String,
expectedStatus: Set[Int]): Future[TResult]

/**
* When remote service require an argument message with serialized payload will be sent.
* Provide class of result for deserialization.
*
* @tparam TResult result type
* @param command remote service name
* @param argument remote service argument
* @param expectedStatus expected status from remote call
* @return future with deserialized result
*/
/** When remote service require an argument message with serialized payload will be sent.
* Provide class of result for deserialization.
*
* @tparam TResult result type
* @param command remote service name
* @param argument remote service argument
* @param expectedStatus expected status from remote call
* @return future with deserialized result
*/
def post[TArgument, TResult: ClassTag](
command: String,
argument: TArgument,
Expand Down
71 changes: 33 additions & 38 deletions core/src/main/scala/com/dslplatform/api/client/CrudProxy.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,49 @@ import com.dslplatform.api.patterns.Identifiable
import scala.concurrent.Future
import scala.reflect.ClassTag

/**
* Proxy service to remote CRUD REST-like API.
* Single aggregate root instance can be used.
* New object instance will be returned when doing modifications.
* Use {@link StandardProxy standard proxy} if response is not required from the server.
* <p>
* It is preferred to use domain patterns instead of this proxy service.
*/
/** Proxy service to remote CRUD REST-like API.
* Single aggregate root instance can be used.
* New object instance will be returned when doing modifications.
* Use {@link StandardProxy standard proxy} if response is not required from the server.
*
* It is preferred to use domain patterns instead of this proxy service.
*/
trait CrudProxy {
/**
* Get domain object from remote server using provided identity.
* If domain object is not found an exception will be thrown.
*
* @param uri domain object identity
* @return future to found domain object
*/
/** Get domain object from remote server using provided identity.
* If domain object is not found an exception will be thrown.
*
* @param uri domain object identity
* @return future to found domain object
*/
def read[TIdentifiable <: Identifiable: ClassTag](
uri: String): Future[TIdentifiable]

/**
* Create new aggregate root on the remote server.
* Created object will be returned with its identity
* and all calculated properties evaluated.
*
* @param aggregate new aggregate root
* @return future to aggregate root with new identity
*/
/** Create new aggregate root on the remote server.
* Created object will be returned with its identity
* and all calculated properties evaluated.
*
* @param aggregate new aggregate root
* @return future to aggregate root with new identity
*/
def create[TAggregateRoot <: AggregateRoot: ClassTag](
aggregate: TAggregateRoot): Future[TAggregateRoot]

/**
* Modify existing aggregate root on the remote server.
* Aggregate root will be saved and all calculated properties evaluated.
*
* @param aggregate modified aggregate root
* @return future to aggregate root with updated attributes
*/
/** Modify existing aggregate root on the remote server.
* Aggregate root will be saved and all calculated properties evaluated.
*
* @param aggregate modified aggregate root
* @return future to aggregate root with updated attributes
*/
def update[TAggregateRoot <: AggregateRoot: ClassTag](
aggregate: TAggregateRoot): Future[TAggregateRoot]

/**
* Delete existing aggregate root from the remote server.
* If possible, aggregate root will be deleted and it's instance
* will be provided.
*
* @param uri aggregate root identity
* @return future to deleted aggregate root instance
*/
/** Delete existing aggregate root from the remote server.
* If possible, aggregate root will be deleted and it's instance
* will be provided.
*
* @param uri aggregate root identity
* @return future to deleted aggregate root instance
*/
def delete[TAggregateRoot <: AggregateRoot: ClassTag](
uri: String): Future[TAggregateRoot]
}
135 changes: 62 additions & 73 deletions core/src/main/scala/com/dslplatform/api/client/DomainProxy.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,107 +10,96 @@ import com.dslplatform.api.patterns.Specification
import scala.reflect.ClassTag
import scala.concurrent.Future

/**
* Proxy service to remote REST-like API for basic domain operations
* such as searching, counting and event sourcing.
* <p>
* It is preferred to use domain patterns instead of this proxy service.
*/
/** Proxy service to remote REST-like API for basic domain operations
* such as searching, counting and event sourcing.
*
* It is preferred to use domain patterns instead of this proxy service.
*/
trait DomainProxy {
/**
* Returns a IndexedSeq of domain objects uniquely represented with their URIs.
* Only found objects will be returned (IndexedSeq will be empty if no objects are found).
*
* @tparam TSearchable domain object class
* @param uris sequence of unique identifiers
* @return future to found domain objects
*/
/** Returns a IndexedSeq of domain objects uniquely represented with their URIs.
* Only found objects will be returned (IndexedSeq will be empty if no objects are found).
*
* @tparam TSearchable domain object class
* @param uris sequence of unique identifiers
* @return future to found domain objects
*/
def find[TSearchable <: Identifiable: ClassTag](
uris: TraversableOnce[String]): Future[IndexedSeq[TSearchable]]

/**
* Returns a IndexedSeq of domain objects satisfying optional {@link Specification specification}
* with up to optional <code>limit</code> results.
* Optional <code>offset</code> can be used to skip initial results.
* Optional <code>order</code> should be given as a IndexedSeq of pairs of
* <code>{@literal <String, Boolean>}</code>
* where first is a property name and second is whether it should be sorted
* ascending over this property.
*
* @param specification search predicate
* @param limit maximum number of results
* @param offset number of results to be skipped
* @param order custom ordering
* @return future to domain objects which satisfy search predicate
*/
/** Returns a IndexedSeq of domain objects satisfying optional {@link Specification specification}
* with up to optional `limit` results.
* Optional `offset` can be used to skip initial results.
* Optional `order` should be given as a IndexedSeq of `(String, Boolean)` pairs where first
* is a property name and second is whether it should be sorted ascending over this property.
*
* @param specification search predicate
* @param limit maximum number of results
* @param offset number of results to be skipped
* @param order custom ordering
* @return future to domain objects which satisfy search predicate
*/
def search[TSearchable <: Searchable: ClassTag](
specification: Option[Specification[TSearchable]] = None,
limit: Option[Int] = None,
offset: Option[Int] = None,
order: Map[String, Boolean] = Map.empty): Future[IndexedSeq[TSearchable]]

/**
* Helper method for searching domain objects.
* Returns a IndexedSeq of domain objects satisfying {@link Specification specification}
*
* @param specification search predicate
* @return future to domain objects which satisfy search predicate
*/
/** Helper method for searching domain objects.
* Returns a IndexedSeq of domain objects satisfying {@link Specification specification}
*
* @param specification search predicate
* @return future to domain objects which satisfy search predicate
*/
def search[TSearchable <: Searchable: ClassTag](
specification: Specification[TSearchable]): Future[IndexedSeq[TSearchable]] =
search(Some(specification))

/**
* Helper method for searching domain objects.
* Returns a IndexedSeq of domain objects satisfying {@link Specification specification}
* with up to <code>limit</code> results.
*
* @param specification search predicate
* @param limit search maximum number of results
* @return future to domain objects which satisfy search predicate
*/
/** Helper method for searching domain objects.
* Returns a IndexedSeq of domain objects satisfying {@link Specification specification}
* with up to <code>limit</code> results.
*
* @param specification search predicate
* @param limit search maximum number of results
* @return future to domain objects which satisfy search predicate
*/
def search[TSearchable <: Searchable: ClassTag](
specification: Specification[TSearchable],
limit: Int): Future[IndexedSeq[TSearchable]] =
search(Some(specification), Some(limit))

/**
* Returns a number of elements satisfying optionally provided specification.
*
* @param specification search predicate
* @return future to number of domain objects which satisfy specification
*/
/** Returns a number of elements satisfying optionally provided specification.
*
* @param specification search predicate
* @return future to number of domain objects which satisfy specification
*/
def count[TSearchable <: Searchable: ClassTag](
specification: Option[Specification[TSearchable]] = None): Future[Long]

/**
* Helper method for counting domain objects.
* Returns a number of elements satisfying provided specification.
*
* @param specification search predicate
* @return future to number of domain objects which satisfy specification
*/
/** Helper method for counting domain objects.
* Returns a number of elements satisfying provided specification.
*
* @param specification search predicate
* @return future to number of domain objects which satisfy specification
*/
def count[TSearchable <: Searchable: ClassTag](
specification: Specification[TSearchable]): Future[Long] =
count(Some(specification))

/**
* Send domain event to the server. Server will return identity under which it was stored.
* Events can't be modified once they are submitted. Only new events can be created.
*
* @param domainEvent event to raise
* @return future containing string value of event URI
*/
/** Send domain event to the server. Server will return identity under which it was stored.
* Events can't be modified once they are submitted. Only new events can be created.
*
* @param domainEvent event to raise
* @return future containing string value of event URI
*/
def submit[TEvent <: DomainEvent](domainEvent: TEvent): Future[String]

/**
* Apply domain event to a single aggregate. Server will return modified aggregate root.
* Events can't be modified once they are submitted. Only new events can be created.
*
* @param domainEvent event to apply
* @param uri aggregate root uri
* @return future containing modified aggregate root
*/
/** Apply domain event to a single aggregate. Server will return modified aggregate root.
* Events can't be modified once they are submitted. Only new events can be created.
*
* @param domainEvent event to apply
* @param uri aggregate root uri
* @return future containing modified aggregate root
*/
def submit[TAggregate <: AggregateRoot: ClassTag, TEvent <: AggregateDomainEvent[TAggregate]](
domainEvent: TEvent,
uri: String): Future[TAggregate]
Expand Down
Loading