Skip to content

Commit

Permalink
Renamed the 'oraface-api' to 'oracle-data-api' throughout the project…
Browse files Browse the repository at this point in the history
… to keep the same naming convention as a standard
  • Loading branch information
karahanb committed Apr 13, 2022
1 parent 7c3446a commit a6979d9
Show file tree
Hide file tree
Showing 36 changed files with 3,642 additions and 3,616 deletions.
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>jag-traffic-courts-online</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
7 changes: 7 additions & 0 deletions .settings/.jsdtscope
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="src" path=""/>
<classpathentry kind="output" path=""/>
</classpath>
1 change: 1 addition & 0 deletions .settings/org.eclipse.wst.jsdt.ui.superType.container
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.JRE_CONTAINER
1 change: 1 addition & 0 deletions .settings/org.eclipse.wst.jsdt.ui.superType.name
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Global
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ services:
- "${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro"

#############################################################################################
### Oracle Interface API ###
### Oracle Data API ###
#############################################################################################
oraface-api:
container_name: oraface-api
oracle-data-api:
container_name: oracle-data-api
build:
context: ./src/backend/oracle-data-interface
context: ./src/backend/oracle-data-api
args:
- SKIP_TESTS=true
- SPLUNK_URL=${SPLUNK_URL:-http://splunk:8088}
Expand All @@ -70,7 +70,7 @@ services:
- REDIS_PASSWORD=password
- CODETABLE_REFRESH_ENABLED=${CODETABLE_REFRESH_ENABLED:-true}
- CODETABLE_REFRESH_CRON=${CODETABLE_REFRESH_CRON:-0 * * * * *}
- JAVA_OPTS=${JAVA_OPTS:--Dlogging.level.ca.bc.gov.open.jag.tco.oracledatainterface=DEBUG}
- JAVA_OPTS=${JAVA_OPTS:--Dlogging.level.ca.bc.gov.open.jag.tco.oracledataapi=DEBUG}
depends_on:
- redis
ports:
Expand Down
10 changes: 5 additions & 5 deletions src/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ After running `docker-compose up` from the project root, these services should b

| Name | URL | Notes
| --------------------- | -------------------------------------------- | --------------------------------------------
| oracle-data-interface | http://localhost:5010/swagger-ui/index.html |
| oracle-data-api | http://localhost:5010/swagger-ui/index.html |
| TrafficCourts | http://localhost:5000/swagger/index.html |
| Splunk | http://localhost:8000 | login with admin/password

## Description

### oracle-data-interface
### oracle-data-api
An API that acts as an interface between Oracle and the TrafficCourts API

#### Configuration
Expand Down Expand Up @@ -43,7 +43,7 @@ An API that acts as an interface between Oracle and the TrafficCourts API
| REDIS_SENTINAL_NODES | When redis is configured in a master-slave-sentinel configuration, a comma-separated list of host:port sentinal nodes. ie "redis-sentinel-1:26379,redis-sentinel-2:26380,redis-sentinel-3:26381"
| SPLUNK_URL |
| SPLUNK_TOKEN |
| JAVA_OPTS | JVM parameters to be passed to the container. ie, "-Dlogging.level.ca.bc.gov.open.jag.tco.oracledatainterface=DEBUG"
| JAVA_OPTS | JVM parameters to be passed to the container. ie, "-Dlogging.level.ca.bc.gov.open.jag.tco.oracledataapi=DEBUG"

Note: Redis Standalone and Sentinel modes are mutually exclusive. Either use host/port variables or master/nodes.

Expand Down Expand Up @@ -87,6 +87,6 @@ Local object store example. Run `docker-compose up minio createbuckets`
### Splunk
A logging collector tool to capture, index, and correlate logs in a searchable repository.

A sample query might be (to find all logs produced from the Oracle Interface API:
`source="oracle-data-interface"`
A sample query might be (to find all logs produced from the Oracle Data API:
`source="oracle-data-api"`

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace TrafficCourts.Workflow.Service.Configuration
{
public class OracleInterfaceApiConfiguration
public class OracleDataApiConfiguration
{
public string? Host { get; set; }
public int Port { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ namespace TrafficCourts.Workflow.Service.Consumers
public class SubmitDisputeConsumer : IConsumer<SubmitDispute>
{
private readonly ILogger<SubmitDisputeConsumer> _logger;
private readonly IOracleInterfaceService _oracleInterfaceService;
private readonly IOracleDataApiService _oracleDataApiService;

public SubmitDisputeConsumer(ILogger<SubmitDisputeConsumer> logger, IOracleInterfaceService oracleInterfaceService)
public SubmitDisputeConsumer(ILogger<SubmitDisputeConsumer> logger, IOracleDataApiService oracleDataApiService)
{
_logger = logger;
_oracleInterfaceService = oracleInterfaceService;
_oracleDataApiService = oracleDataApiService;
}

public async Task Consume(ConsumeContext<SubmitDispute> context)
Expand Down Expand Up @@ -64,7 +64,7 @@ public async Task Consume(ConsumeContext<SubmitDispute> context)

_logger.LogDebug("TRY CREATING DISPUTE: {Dispute}", dispute.ToString());

var disputeId = await _oracleInterfaceService.CreateDisputeAsync(dispute);
var disputeId = await _oracleDataApiService.CreateDisputeAsync(dispute);

if (disputeId != -1)
{
Expand Down
4 changes: 2 additions & 2 deletions src/backend/TrafficCourts/Workflow.Service/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
builder.Services.AddSwaggerGen();

builder.Services.Configure<ArcApiConfiguration>(builder.Configuration.GetRequiredSection("ArcApiConfiguration"));
builder.Services.Configure<OracleInterfaceApiConfiguration>(builder.Configuration.GetRequiredSection("OracleInterfaceApiConfiguration"));
builder.Services.Configure<OracleDataApiConfiguration>(builder.Configuration.GetRequiredSection("OracleDataApiConfiguration"));

builder.Services.AddTransient<IOracleInterfaceService, OracleInterfaceService>();
builder.Services.AddTransient<IOracleDataApiService, OracleDataApiService>();
builder.Services.AddTransient<ISubmitDisputeToArcService, SubmitDisputeToArcService>();

builder.Services.AddMassTransit(cfg =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace TrafficCourts.Workflow.Service.Services
{
public interface IOracleInterfaceService
public interface IOracleDataApiService
{
Task<int> CreateDisputeAsync(Dispute disputeToSubmit);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@

namespace TrafficCourts.Workflow.Service.Services
{
public class OracleInterfaceService : IOracleInterfaceService
public class OracleDataApiService : IOracleDataApiService
{
private readonly ILogger<OracleInterfaceService> _logger;
private readonly OracleInterfaceApiConfiguration _oracleInterfaceApiConfiguration;
private readonly ILogger<OracleDataApiService> _logger;
private readonly OracleDataApiConfiguration _oracleDataApiConfiguration;

public OracleInterfaceService(ILogger<OracleInterfaceService> logger, IOptions<OracleInterfaceApiConfiguration> oracleInterfaceApiConfiguration)
public OracleDataApiService(ILogger<OracleDataApiService> logger, IOptions<OracleDataApiConfiguration> oracleDataApiConfiguration)
{
_logger = logger;
_oracleInterfaceApiConfiguration = oracleInterfaceApiConfiguration.Value;
_oracleDataApiConfiguration = oracleDataApiConfiguration.Value;
}

public async Task<int> CreateDisputeAsync(Dispute disputeToSubmit)
{
// Formatting all dispute class properties to camel case since oracle data interface api
// Formatting all dispute class properties to camel case since oracle data api
// accepts camel case only after serialization
var formatter = new JsonMediaTypeFormatter();
formatter.SerializerSettings = new JsonSerializerSettings
Expand All @@ -31,8 +31,8 @@ public async Task<int> CreateDisputeAsync(Dispute disputeToSubmit)

using (var httpClient = new HttpClient())
{
var orafaceBaseUri = $"http://{_oracleInterfaceApiConfiguration.Host}:{_oracleInterfaceApiConfiguration.Port}";
httpClient.BaseAddress = new Uri(orafaceBaseUri);
var oracleDataApiBaseUri = $"http://{_oracleDataApiConfiguration.Host}:{_oracleDataApiConfiguration.Port}";
httpClient.BaseAddress = new Uri(oracleDataApiBaseUri);
using (var response = await httpClient.PostAsync("dispute", disputeToSubmit, formatter))
{
if (response.IsSuccessStatusCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"Host": "localhost",
"Port": "5300"
},
"OracleInterfaceApiConfiguration": {
"OracleDataApiConfiguration": {
"Host": "localhost",
"Port": "5010"
},
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN mvn verify clean --fail-never
# Compile codebase to a single jar
COPY . .
RUN mvn -B clean package \
-Dtarget.fileName=oraface-api \
-Dtarget.fileName=oracle-data-api \
-Dmaven.test.skip=${SKIP_TESTS}

#############################################################################################
Expand Down Expand Up @@ -48,7 +48,7 @@ ENV CODETABLE_REFRESH_ENABLED=${CODETABLE_REFRESH_ENABLED}
ENV CODETABLE_REFRESH_CRON=${CODETABLE_REFRESH_CRON}
ENV JAVA_OPTS=${JAVA_OPTS}

COPY --from=build ./target/oraface-api.jar /app/service.jar
COPY --from=build ./target/oracle-data-api.jar /app/service.jar

CMD java $JAVA_OPTS -jar /app/service.jar
#############################################################################################
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
</dependencies>

<build>
<finalName>oraface-api</finalName>
<finalName>oracle-data-api</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ca.bc.gov.open.jag.tco.oracledatainterface;
package ca.bc.gov.open.jag.tco.oracledataapi;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -8,12 +8,12 @@

@SpringBootApplication
@EnableScheduling
public class OracleDataInterfaceApplication {
public class OracleDataApiApplication {

private static Logger logger = LoggerFactory.getLogger(OracleDataInterfaceApplication.class);
private static Logger logger = LoggerFactory.getLogger(OracleDataApiApplication.class);

public static void main(String[] args) {
SpringApplication.run(OracleDataInterfaceApplication.class, args);
SpringApplication.run(OracleDataApiApplication.class, args);

logger.info("Application up. Log level set to '{}'", ((ch.qos.logback.classic.Logger)logger).getEffectiveLevel());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package ca.bc.gov.open.jag.tco.oracledatainterface.config;

import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ApplicationConfig {

/**
* Group all APIs with `v1.0` in the path
*/
@Bean
GroupedOpenApi v1_0Apis() {
return GroupedOpenApi.builder().group("v1.0").pathsToMatch("/**/api/v1.0/**").build();
}

}
package ca.bc.gov.open.jag.tco.oracledataapi.config;

import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ApplicationConfig {

/**
* Group all APIs with `v1.0` in the path
*/
@Bean
GroupedOpenApi v1_0Apis() {
return GroupedOpenApi.builder().group("v1.0").pathsToMatch("/**/api/v1.0/**").build();
}

}
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
package ca.bc.gov.open.jag.tco.oracledatainterface.config;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;

@Configuration
public class RedisConfig {

private Logger logger = LoggerFactory.getLogger(RedisConfig.class);

@Bean
public LettuceConnectionFactory redisConnectionFactory(RedisProperties redisProperties) {
// Normally Spring automatically handles and builds a RedisConnectionFactory, but in seems Sentinel and Standalone
// modes are mutually exclusive. If spring.redis.sentinel.master configuration is set (or blank) then Spring auto-configures
// redis to be in Sentinel mode. But Sentinel mode does not work for local development. For development, redis must be
// in Standalone mode. Here we are manually creating one or the other based on if master is set or not.

// Sentinel mode (for deployments)
if (redisProperties.getSentinel() != null && !StringUtils.isBlank(redisProperties.getSentinel().getMaster())) {
logger.debug("Configuring Redis to run in sentinal mode.");
RedisSentinelConfiguration config = new RedisSentinelConfiguration();
config.master(redisProperties.getSentinel().getMaster());
for(String node : redisProperties.getSentinel().getNodes()) {
String[] props = node.split(":");
config.sentinel(props[0], Integer.parseInt(props[1]));
}
config.setPassword(redisProperties.getPassword());
return new LettuceConnectionFactory(config);
}

// Standalone mode (for local development)
else {
logger.debug("Configuring Redis to run in standalone mode.");
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration(redisProperties.getHost(), redisProperties.getPort());
config.setPassword(redisProperties.getPassword());
return new LettuceConnectionFactory(config);
}
}

}
package ca.bc.gov.open.jag.tco.oracledataapi.config;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;

@Configuration
public class RedisConfig {

private Logger logger = LoggerFactory.getLogger(RedisConfig.class);

@Bean
public LettuceConnectionFactory redisConnectionFactory(RedisProperties redisProperties) {
// Normally Spring automatically handles and builds a RedisConnectionFactory, but in seems Sentinel and Standalone
// modes are mutually exclusive. If spring.redis.sentinel.master configuration is set (or blank) then Spring auto-configures
// redis to be in Sentinel mode. But Sentinel mode does not work for local development. For development, redis must be
// in Standalone mode. Here we are manually creating one or the other based on if master is set or not.

// Sentinel mode (for deployments)
if (redisProperties.getSentinel() != null && !StringUtils.isBlank(redisProperties.getSentinel().getMaster())) {
logger.debug("Configuring Redis to run in sentinal mode.");
RedisSentinelConfiguration config = new RedisSentinelConfiguration();
config.master(redisProperties.getSentinel().getMaster());
for(String node : redisProperties.getSentinel().getNodes()) {
String[] props = node.split(":");
config.sentinel(props[0], Integer.parseInt(props[1]));
}
config.setPassword(redisProperties.getPassword());
return new LettuceConnectionFactory(config);
}

// Standalone mode (for local development)
else {
logger.debug("Configuring Redis to run in standalone mode.");
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration(redisProperties.getHost(), redisProperties.getPort());
config.setPassword(redisProperties.getPassword());
return new LettuceConnectionFactory(config);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ca.bc.gov.open.jag.tco.oracledatainterface.controller.v1_0;
package ca.bc.gov.open.jag.tco.oracledataapi.controller.v1_0;

import java.util.Date;
import java.util.List;
Expand All @@ -15,9 +15,9 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import ca.bc.gov.open.jag.tco.oracledatainterface.model.Dispute;
import ca.bc.gov.open.jag.tco.oracledatainterface.service.DisputeService;
import ca.bc.gov.open.jag.tco.oracledatainterface.service.LookupService;
import ca.bc.gov.open.jag.tco.oracledataapi.model.Dispute;
import ca.bc.gov.open.jag.tco.oracledataapi.service.DisputeService;
import ca.bc.gov.open.jag.tco.oracledataapi.service.LookupService;
import io.swagger.v3.oas.annotations.Operation;

@RestController()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ca.bc.gov.open.jag.tco.oracledatainterface.model;
package ca.bc.gov.open.jag.tco.oracledataapi.model;

import java.sql.Date;
import java.util.List;
Expand Down
Loading

0 comments on commit a6979d9

Please sign in to comment.