Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 57ab9b3e01 | |||
| 487eb48322 | |||
| 8955933a47 | |||
| 0626395b9f | |||
| a78cdb24fd | |||
| 1b1bde8c76 | |||
| ddb5012b95 |
38
pom.xml
38
pom.xml
@ -48,23 +48,6 @@
|
|||||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- GraghQL -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.graphql-java</groupId>
|
|
||||||
<artifactId>graphql-spring-boot-starter</artifactId>
|
|
||||||
<version>5.0.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.graphql-java</groupId>
|
|
||||||
<artifactId>graphql-java-tools</artifactId>
|
|
||||||
<version>5.2.4</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.graphql-java</groupId>
|
|
||||||
<artifactId>graphiql-spring-boot-starter</artifactId>
|
|
||||||
<version>5.0.2</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Local database -->
|
<!-- Local database -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
@ -84,6 +67,23 @@
|
|||||||
<version>4.3.8.Final</version>
|
<version>4.3.8.Final</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- GraghQL -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.graphql-java</groupId>
|
||||||
|
<artifactId>graphql-spring-boot-starter</artifactId>
|
||||||
|
<version>5.0.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.graphql-java</groupId>
|
||||||
|
<artifactId>graphql-java-tools</artifactId>
|
||||||
|
<version>5.2.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.graphql-java</groupId>
|
||||||
|
<artifactId>graphiql-spring-boot-starter</artifactId>
|
||||||
|
<version>5.0.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Artemis -->
|
<!-- Artemis -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
@ -98,6 +98,10 @@
|
|||||||
<version>1.18.8</version>
|
<version>1.18.8</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!--- Logging -->
|
<!--- Logging -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@ -78,7 +78,7 @@ public class PriceConsumer {
|
|||||||
JsonNode messageJson = objectMapper.readTree(message.getText());
|
JsonNode messageJson = objectMapper.readTree(message.getText());
|
||||||
cryptoPriceModel = objectMapper.readValue(messageJson.traverse(), CryptoPriceModel.class);
|
cryptoPriceModel = objectMapper.readValue(messageJson.traverse(), CryptoPriceModel.class);
|
||||||
|
|
||||||
logger.info("Message with syncId of [{}] is for customer [{}]", syncId, cryptoPriceModel);
|
logger.info("Message with syncId of [{}] is for [{}]", syncId, cryptoPriceModel);
|
||||||
|
|
||||||
priceService.createRecord(cryptoPriceModel, correlationId, message);
|
priceService.createRecord(cryptoPriceModel, correlationId, message);
|
||||||
|
|
||||||
|
|||||||
@ -77,7 +77,7 @@ public class TweetConsumer {
|
|||||||
JsonNode messageJson = objectMapper.readTree(message.getText());
|
JsonNode messageJson = objectMapper.readTree(message.getText());
|
||||||
sentimentModel = objectMapper.readValue(messageJson.traverse(), SentimentModel.class);
|
sentimentModel = objectMapper.readValue(messageJson.traverse(), SentimentModel.class);
|
||||||
|
|
||||||
logger.info("Message with syncId of [{}] is for customer [{}]", syncId, sentimentModel);
|
logger.info("Message with syncId of [{}] is for [{}]", syncId, sentimentModel);
|
||||||
|
|
||||||
sentimentService.createRecord(sentimentModel, correlationId, message);
|
sentimentService.createRecord(sentimentModel, correlationId, message);
|
||||||
|
|
||||||
|
|||||||
@ -1,26 +0,0 @@
|
|||||||
package cryptosky.me.pricing.graphql.mutations;
|
|
||||||
|
|
||||||
import com.coxautodev.graphql.tools.GraphQLMutationResolver;
|
|
||||||
import cryptosky.me.pricing.models.entities.BtcPriceModel;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import cryptosky.me.pricing.service.PriceService;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class BtcPriceMutation implements GraphQLMutationResolver {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private PriceService priceService;
|
|
||||||
|
|
||||||
public BtcPriceModel createBtc(final String createdDate, final String type,
|
|
||||||
final float av_price,
|
|
||||||
final float h_price,
|
|
||||||
final float l_price,
|
|
||||||
final float o_price,
|
|
||||||
final float c_price,
|
|
||||||
final float volume ) {
|
|
||||||
return this.priceService.createBtc(createdDate, type, av_price, h_price, l_price, o_price, c_price, volume);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -2,7 +2,6 @@ package cryptosky.me.pricing.graphql.queries;
|
|||||||
|
|
||||||
import com.coxautodev.graphql.tools.GraphQLQueryResolver;
|
import com.coxautodev.graphql.tools.GraphQLQueryResolver;
|
||||||
import cryptosky.me.pricing.models.entities.BtcPriceModel;
|
import cryptosky.me.pricing.models.entities.BtcPriceModel;
|
||||||
import cryptosky.me.pricing.models.entities.CryptoPriceModel;
|
|
||||||
import cryptosky.me.pricing.service.PriceService;
|
import cryptosky.me.pricing.service.PriceService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|||||||
@ -9,7 +9,6 @@ import cryptosky.me.pricing.models.entities.CryptoPriceModel;
|
|||||||
import cryptosky.me.pricing.models.repositories.BtcPriceRepository;
|
import cryptosky.me.pricing.models.repositories.BtcPriceRepository;
|
||||||
|
|
||||||
import cryptosky.me.exceptions.NotSupportedCurrencyTypeException;
|
import cryptosky.me.exceptions.NotSupportedCurrencyTypeException;
|
||||||
import cryptosky.me.exceptions.DatabaseViolationException;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -22,11 +21,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import javax.jms.JMSException;
|
import javax.jms.JMSException;
|
||||||
import javax.jms.TextMessage;
|
import javax.jms.TextMessage;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
import static cryptosky.me.ArtemisSyncMessaging.*;
|
import static cryptosky.me.ArtemisSyncMessaging.*;
|
||||||
import static cryptosky.me.SupportedCurrencies.*;
|
import static cryptosky.me.SupportedCurrencies.*;
|
||||||
@ -55,29 +52,6 @@ public class PriceService {
|
|||||||
this.dlqName = dlqName;
|
this.dlqName = dlqName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public BtcPriceModel createBtc(final String createdDate, final String type,
|
|
||||||
final float av_price,
|
|
||||||
final float h_price,
|
|
||||||
final float l_price,
|
|
||||||
final float o_price,
|
|
||||||
final float c_price,
|
|
||||||
final float volume ) {
|
|
||||||
|
|
||||||
final BtcPriceModel btcPrice = new BtcPriceModel();
|
|
||||||
btcPrice.setTimestamp(LocalDateTime.parse((createdDate)));
|
|
||||||
btcPrice.setType(type);
|
|
||||||
btcPrice.setAverage_price(av_price);
|
|
||||||
btcPrice.setHigh_price(h_price);
|
|
||||||
btcPrice.setLow_price(l_price);
|
|
||||||
btcPrice.setOpen_price(o_price);
|
|
||||||
btcPrice.setClose_price(c_price);
|
|
||||||
btcPrice.setVolume(volume);
|
|
||||||
|
|
||||||
return btcPrice;
|
|
||||||
// return this.btcPriceRepository.save(btcPrice);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void createRecord(CryptoPriceModel cryptoPriceModel, String correlationId, TextMessage message) {
|
public void createRecord(CryptoPriceModel cryptoPriceModel, String correlationId, TextMessage message) {
|
||||||
String syncId = randomUUID().toString();
|
String syncId = randomUUID().toString();
|
||||||
|
|||||||
@ -14,7 +14,6 @@ public class SentimentModel {
|
|||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "ID", nullable = false)
|
@Column(name = "ID", nullable = false)
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
@Column(name = "timestamp",nullable = false)
|
@Column(name = "timestamp",nullable = false)
|
||||||
|
|||||||
@ -17,7 +17,7 @@ spring:
|
|||||||
platform: postgres
|
platform: postgres
|
||||||
jpa:
|
jpa:
|
||||||
hibernate:
|
hibernate:
|
||||||
ddl-auto: update
|
ddl-auto: validate
|
||||||
show-sql: false
|
show-sql: false
|
||||||
properties:
|
properties:
|
||||||
org.hibernate.envers.revision_field_name: revision_id
|
org.hibernate.envers.revision_field_name: revision_id
|
||||||
|
|||||||
@ -1,40 +1,35 @@
|
|||||||
type BtcPrice {
|
type BtcPrice {
|
||||||
id: ID!,
|
id: ID!,
|
||||||
timestamp: String!,
|
timestamp: String!,
|
||||||
type: String,
|
type: String,
|
||||||
average_price: Float!,
|
average_price: Float!,
|
||||||
high_price: Float,
|
high_price: Float,
|
||||||
low_price: Float,
|
low_price: Float,
|
||||||
open_price: Float,
|
open_price: Float,
|
||||||
close_price: Float,
|
close_price: Float,
|
||||||
volume: Float
|
volume: Float
|
||||||
}
|
}
|
||||||
|
|
||||||
type sentimentModel {
|
type sentimentModel {
|
||||||
id: ID!,
|
id: ID!,
|
||||||
timestamp: String!,
|
timestamp: String!,
|
||||||
rawTweet: String,
|
rawTweet: String,
|
||||||
sentimentScore: Float!,
|
sentimentScore: Float!,
|
||||||
positiveScore: Float,
|
positiveScore: Float,
|
||||||
neutralScore: Float,
|
neutralScore: Float,
|
||||||
negativeScore: Float,
|
negativeScore: Float,
|
||||||
compoundScore: Float!
|
compoundScore: Float!
|
||||||
}
|
}
|
||||||
|
|
||||||
type Query {
|
type Query {
|
||||||
allPrices(count: Int):[BtcPrice],
|
allPrices(count: Int):[BtcPrice],
|
||||||
pricesBetweenCounts(startCount: Int, endCount: Int):[BtcPrice]
|
pricesBetweenCounts(startCount: Int, endCount: Int):[BtcPrice]
|
||||||
latest:BtcPrice,
|
latest:BtcPrice,
|
||||||
priceForCreatedDate(createdDate: String):BtcPrice,
|
priceForCreatedDate(createdDate: String):BtcPrice,
|
||||||
priceBetweenDates(startDate: String, endDate: String):[BtcPrice],
|
priceBetweenDates(startDate: String, endDate: String):[BtcPrice],
|
||||||
################################################################
|
################################################################
|
||||||
currentTweet:sentimentModel,
|
currentTweet:sentimentModel,
|
||||||
allTweets(count: Int):[sentimentModel],
|
allTweets(count: Int):[sentimentModel],
|
||||||
tweetsForDay(startDate: String, endDate: String):[sentimentModel],
|
tweetsForDay(startDate: String, endDate: String):[sentimentModel],
|
||||||
tweetsForPeriod(startDate: String, endDate: String):[sentimentModel]
|
tweetsForPeriod(startDate: String, endDate: String):[sentimentModel]
|
||||||
}
|
|
||||||
|
|
||||||
type Mutation {
|
|
||||||
createBtc(createdDate: String!, type: String!, average_price: Float!, high_price: Float, low_price: Float, open_price: Float, close_price: Float, volume: Float):BtcPrice
|
|
||||||
createTweet(createdDate: String!, rawTweet: String!, sentimentScore: Float!, positiveScore: Float, neutralScore: Float, negativeScore: Float, compoundScore: Float!):sentimentModel
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user