Skip to content

Commit

Permalink
Merge pull request #6 from RedRoma/release/1.0
Browse files Browse the repository at this point in the history
Release/1.0
  • Loading branch information
SirWellington committed May 11, 2016
2 parents 18e5b2b + ece07e2 commit 1cca00f
Show file tree
Hide file tree
Showing 92 changed files with 3,744 additions and 694 deletions.
46 changes: 40 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,47 @@
Banana Service Data Operations
Aroma Service Data Operations
==============================================

[<img src="https://raw.githubusercontent.com/RedRoma/banana/develop/Graphics/Logo.png" width="300">](https://github.com/RedRoma/banana)
[<img src="https://raw.githubusercontent.com/RedRoma/aroma/develop/Graphics/Logo.png" width="300">](http://aroma.redroma.tech/)

[![Build Status](http://jenkins.sirwellington.tech/job/Banana%20Data%20Operations/badge/icon)](http://jenkins.sirwellington.tech/job/Banana%20Data%20Operations/)
[![Build Status](http://jenkins.redroma.tech/job/Aroma%20Data%20Operations/badge/icon)](http://jenkins.redroma.tech/job/Aroma%20Data%20Operations/)

Defines the Data Interfaces and Operations used by the various Banana Services.
Defines the Data Interfaces and Operations used by the various Aroma Services.

These Data Operations are used by Business Logic living within the various Banana Services.
These Data Operations are used by Business Logic living within the various Aroma Services.

For example, the Application Service needs the MessageRepository to store messages, and the Banana
For example, the Application Service needs the MessageRepository to store messages, and the Aroma
Service needs it to retrieve Messages.


# Download

To use, simply add the following maven dependency.

## Release
```xml
<dependency>
<groupId>tech.aroma</groupId>
<artifactId>aroma-data-operations</artifactId>
<version>1.0</version>
</dependency>
```

## Snapshot

>First add the Snapshot Repository
```xml
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
```

```xml
<dependency>
<groupId>tech.aroma</groupId>
<artifactId>aroma-data-operations</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
```

# [Javadocs](http://www.javadoc.io/doc/tech.aroma/aroma-data-operations/)
43 changes: 25 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>tech.aroma.banana</groupId>
<artifactId>banana</artifactId>
<version>1.3</version>
<groupId>tech.aroma</groupId>
<artifactId>aroma</artifactId>
<version>1.4</version>
</parent>

<artifactId>banana-data-operations</artifactId>
<artifactId>aroma-data-operations</artifactId>
<version>1.0</version>
<name>${project.artifactId}</name>
<packaging>jar</packaging>

<url>https://github.com/RedRoma/banana-data-operations</url>
<url>https://github.com/RedRoma/aroma-data-operations</url>
<description>
Part of the Banana Service Project.
Part of the Aroma Project.
Simplicity is paramount.
Defines the Data Repositories and provides implementations for use in various Banana Services.
Defines the Data Repositories and provides implementations for use in various Aroma Services.
</description>

<issueManagement>
<system>GitHub Issues</system>
<url>https://github.com/RedRoma/banana-data-operations/issues</url>
<url>https://github.com/RedRoma/aroma-data-operations/issues</url>
</issueManagement>

<scm>
<connection>scm:git:[email protected]:RedRoma/banana-data-operations.git</connection>
<developerConnection>scm:git:[email protected]:RedRoma/banana-data-operations.git</developerConnection>
<url>[email protected]:RedRoma/banana-data-operations-annotations.git</url>
<connection>scm:git:[email protected]:RedRoma/aroma-data-operations.git</connection>
<developerConnection>scm:git:[email protected]:RedRoma/aroma-data-operations.git</developerConnection>
<url>[email protected]:RedRoma/aroma-data-operations-annotations.git</url>
</scm>

<inceptionYear>2015</inceptionYear>
Expand Down Expand Up @@ -72,7 +72,6 @@
<dependency>
<groupId>tech.sirwellington.alchemy</groupId>
<artifactId>alchemy-annotations</artifactId>
<version>1.5</version>
</dependency>

<dependency>
Expand All @@ -92,12 +91,19 @@


<!--=======================-->
<!--BANANA DEPENDENCIES-->
<!--AROMA DEPENDENCIES-->
<!--=======================-->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>banana-thrift</artifactId>
<version>1.6</version>
<artifactId>aroma-thrift</artifactId>
<version>1.9</version>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>aroma-thrift-generators</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>


Expand All @@ -108,7 +114,7 @@
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>

<!--Decorater Pattern for Guice-->
<dependency>
<groupId>tech.sirwellington.decorice</groupId>
Expand All @@ -121,8 +127,9 @@
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>2.2.0-rc3</version>
</dependency>

<!--=======================-->
<!--EXPIRING MAP-->
<!--=======================-->
Expand All @@ -139,7 +146,7 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

</dependencies>

<build>
Expand Down
85 changes: 85 additions & 0 deletions src/main/java/tech/aroma/data/ActivityRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright 2016 RedRoma, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


package tech.aroma.data;

import java.util.List;
import org.apache.thrift.TException;
import sir.wellington.alchemy.collections.lists.Lists;
import tech.aroma.thrift.LengthOfTime;
import tech.aroma.thrift.User;
import tech.aroma.thrift.events.Event;
import tech.aroma.thrift.exceptions.InvalidArgumentException;
import tech.aroma.thrift.service.AromaServiceConstants;
import tech.sirwellington.alchemy.annotations.arguments.Required;

import static tech.sirwellington.alchemy.arguments.Arguments.checkThat;
import static tech.sirwellington.alchemy.arguments.assertions.CollectionAssertions.nonEmptyList;


/**
* Responsible for storage of User Activity, represented by Aroma {@linkplain Event Events}.
*
*
* @author SirWellington
*/
public interface ActivityRepository
{
default void saveEvent(Event event, User forUser) throws TException
{
this.saveEvent(event, forUser, AromaServiceConstants.DEFAULT_ACTIVITY_LIFETIME);
}

void saveEvent(Event event, User forUser, LengthOfTime lifetime) throws TException;

default void saveEvents(@Required Event event, List<User> users) throws TException
{
checkThat(users)
.throwing(InvalidArgumentException.class)
.is(nonEmptyList());

List<TException> exceptions = Lists.create();

users.parallelStream().forEach(user ->
{
try
{
this.saveEvent(event, user);
}
catch (TException ex)
{
exceptions.add(ex);
}
});

if (!Lists.isEmpty(exceptions))
{
throw Lists.oneOf(exceptions);
}

}

boolean containsEvent(@Required String eventId, @Required User user) throws TException;

Event getEvent(@Required String eventId, @Required User user) throws TException;

List<Event> getAllEventsFor(@Required User user) throws TException;

void deleteEvent(@Required String eventId, @Required User user) throws TException;

void deleteAllEventsFor(@Required User user) throws TException;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 Aroma Tech.
* Copyright 2016 RedRoma, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,11 +15,11 @@
*/


package tech.aroma.banana.data;
package tech.aroma.data;

import java.util.List;
import org.apache.thrift.TException;
import tech.aroma.banana.thrift.Application;
import tech.aroma.thrift.Application;
import tech.sirwellington.alchemy.annotations.arguments.NonEmpty;
import tech.sirwellington.alchemy.annotations.arguments.Required;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 Aroma Tech.
* Copyright 2016 RedRoma, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,7 +15,7 @@
*/


package tech.aroma.banana.data;
package tech.aroma.data;

import org.apache.thrift.TException;
import tech.sirwellington.alchemy.annotations.arguments.Required;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 Aroma Tech.
* Copyright 2016 RedRoma, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,18 +15,18 @@
*/


package tech.aroma.banana.data;
package tech.aroma.data;

import java.util.List;
import org.apache.thrift.TException;
import tech.aroma.banana.thrift.Application;
import tech.aroma.banana.thrift.User;
import tech.aroma.thrift.Application;
import tech.aroma.thrift.User;
import tech.sirwellington.alchemy.annotations.arguments.Required;


/**
* Contains operations related to the following of Applications by Users.
* ß
*
* @author SirWellington
*/
public interface FollowerRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 Aroma Tech.
* Copyright 2016 RedRoma, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,16 +15,16 @@
*/


package tech.aroma.banana.data;
package tech.aroma.data;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import org.apache.thrift.TException;
import tech.aroma.banana.thrift.LengthOfTime;
import tech.aroma.banana.thrift.Message;
import tech.aroma.banana.thrift.User;
import tech.aroma.banana.thrift.service.BananaServiceConstants;
import tech.aroma.thrift.LengthOfTime;
import tech.aroma.thrift.Message;
import tech.aroma.thrift.User;
import tech.aroma.thrift.service.AromaServiceConstants;
import tech.sirwellington.alchemy.annotations.arguments.Required;


Expand All @@ -38,7 +38,7 @@ public interface InboxRepository
{
default void saveMessageForUser(@Required User user, @Required Message message) throws TException
{
this.saveMessageForUser(user, message, BananaServiceConstants.DEFAULT_INBOX_LIFETIME);
this.saveMessageForUser(user, message, AromaServiceConstants.DEFAULT_INBOX_LIFETIME);
}

void saveMessageForUser(@Required User user, @Required Message message, @Required LengthOfTime lifetime) throws TException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 Aroma Tech.
* Copyright 2016 RedRoma, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,12 +15,12 @@
*/


package tech.aroma.banana.data;
package tech.aroma.data;

import org.apache.thrift.TException;
import tech.aroma.banana.thrift.Dimension;
import tech.aroma.banana.thrift.Image;
import tech.aroma.banana.thrift.exceptions.DoesNotExistException;
import tech.aroma.thrift.Dimension;
import tech.aroma.thrift.Image;
import tech.aroma.thrift.exceptions.DoesNotExistException;
import tech.sirwellington.alchemy.annotations.arguments.NonEmpty;
import tech.sirwellington.alchemy.annotations.arguments.Required;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

package tech.aroma.banana.data;
package tech.aroma.data;

/*
* Copyright 2016 Aroma Tech.
* Copyright 2016 RedRoma, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,9 +20,9 @@
import java.util.List;
import org.apache.thrift.TException;
import sir.wellington.alchemy.collections.lists.Lists;
import tech.aroma.banana.thrift.LengthOfTime;
import tech.aroma.banana.thrift.Message;
import tech.aroma.banana.thrift.TimeUnit;
import tech.aroma.thrift.LengthOfTime;
import tech.aroma.thrift.Message;
import tech.aroma.thrift.TimeUnit;
import tech.sirwellington.alchemy.annotations.arguments.Required;


Expand Down
Loading

0 comments on commit 1cca00f

Please sign in to comment.