-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'save-basket-with-name' into issue_981-send-to-market-fo…
…r-basket-trades-fake-oms
- Loading branch information
Showing
176 changed files
with
7,249 additions
and
1,548 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.7.16</version> | ||
<relativePath/> <!-- lookup parent fromEntity repository --> | ||
</parent> | ||
<groupId>org.finos.vuu</groupId> | ||
<artifactId>layout-server</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>layout-server</name> | ||
<description>A remote server to persist layouts for the Vuu client</description> | ||
<properties> | ||
<java.version>11</java.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-validation</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-jpa</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.h2database</groupId> | ||
<artifactId>h2</artifactId> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springdoc</groupId> | ||
<artifactId>springdoc-openapi-ui</artifactId> | ||
<version>1.6.12</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.modelmapper</groupId> | ||
<artifactId>modelmapper</artifactId> | ||
<version>3.1.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jetbrains</groupId> | ||
<artifactId>annotations</artifactId> | ||
<version>13.0</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
20 changes: 20 additions & 0 deletions
20
layout-server/src/main/java/org/finos/vuu/layoutserver/CorsConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.finos.vuu.layoutserver; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.servlet.config.annotation.CorsRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
@Configuration | ||
public class CorsConfig implements WebMvcConfigurer { | ||
@Override | ||
public void addCorsMappings(CorsRegistry registry) { | ||
registry.addMapping("/**") | ||
.allowedOrigins( | ||
"http://127.0.0.1:5173", | ||
"https://127.0.0.1:5173", | ||
"http://127.0.0.1:8443/", | ||
"https://127.0.0.1:8443/" | ||
) | ||
.allowedMethods("GET", "POST", "PUT", "DELETE"); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
layout-server/src/main/java/org/finos/vuu/layoutserver/LayoutServerApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.finos.vuu.layoutserver; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class LayoutServerApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(LayoutServerApplication.class, args); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
layout-server/src/main/java/org/finos/vuu/layoutserver/config/MappingConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.finos.vuu.layoutserver.config; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.finos.vuu.layoutserver.dto.request.LayoutRequestDto; | ||
import org.finos.vuu.layoutserver.model.Layout; | ||
import org.modelmapper.ModelMapper; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@RequiredArgsConstructor | ||
@Configuration | ||
public class MappingConfig { | ||
|
||
@Bean | ||
public ModelMapper modelMapper() { | ||
ModelMapper mapper = new ModelMapper(); | ||
|
||
mapper.typeMap(LayoutRequestDto.class, Layout.class) | ||
.addMappings(m -> m.skip(Layout::setId)); | ||
|
||
return mapper; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...rver/src/main/java/org/finos/vuu/layoutserver/controller/ApplicationLayoutController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package org.finos.vuu.layoutserver.controller; | ||
|
||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import lombok.RequiredArgsConstructor; | ||
import org.finos.vuu.layoutserver.dto.response.ApplicationLayoutDto; | ||
import org.finos.vuu.layoutserver.service.ApplicationLayoutService; | ||
import org.modelmapper.ModelMapper; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
@RequestMapping("/application-layouts") | ||
public class ApplicationLayoutController { | ||
|
||
private final ApplicationLayoutService service; | ||
private final ModelMapper mapper; | ||
|
||
/** | ||
* Gets the persisted application layout for the requesting user. If the requesting user does not have an | ||
* application layout persisted, a default layout with a null username is returned instead. No more than one | ||
* application layout can be persisted for a given user. | ||
* | ||
* @return the application layout | ||
*/ | ||
@ResponseStatus(HttpStatus.OK) | ||
@GetMapping | ||
public ApplicationLayoutDto getApplicationLayout(@RequestHeader("username") String username) { | ||
return mapper.map(service.getApplicationLayout(username), ApplicationLayoutDto.class); | ||
} | ||
|
||
/** | ||
* Creates or updates the unique application layout for the requesting user. | ||
* | ||
* @param layoutDefinition JSON representation of the application layout to be created | ||
* @param username the user making the request | ||
*/ | ||
@ResponseStatus(HttpStatus.CREATED) | ||
@PutMapping | ||
public void persistApplicationLayout(@RequestHeader("username") String username, @RequestBody ObjectNode layoutDefinition) { | ||
service.persistApplicationLayout(username, layoutDefinition); | ||
} | ||
|
||
/** | ||
* Deletes the application layout for the requesting user. A 404 will be returned if there is no existing | ||
* application layout. | ||
* | ||
* @param username the user making the request | ||
*/ | ||
@ResponseStatus(HttpStatus.NO_CONTENT) | ||
@DeleteMapping | ||
public void deleteApplicationLayout(@RequestHeader("username") String username) { | ||
service.deleteApplicationLayout(username); | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
layout-server/src/main/java/org/finos/vuu/layoutserver/controller/LayoutController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package org.finos.vuu.layoutserver.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.finos.vuu.layoutserver.dto.request.LayoutRequestDto; | ||
import org.finos.vuu.layoutserver.dto.response.LayoutResponseDto; | ||
import org.finos.vuu.layoutserver.dto.response.MetadataResponseDto; | ||
import org.finos.vuu.layoutserver.model.Layout; | ||
import org.finos.vuu.layoutserver.service.LayoutService; | ||
import org.finos.vuu.layoutserver.service.MetadataService; | ||
import org.modelmapper.ModelMapper; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import javax.validation.Valid; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
@RequestMapping("/layouts") | ||
@Validated | ||
public class LayoutController { | ||
|
||
private final LayoutService layoutService; | ||
private final MetadataService metadataService; | ||
private final ModelMapper mapper; | ||
|
||
/** | ||
* Gets the specified layout | ||
* | ||
* @param id ID of the layout to get | ||
* @return the layout | ||
*/ | ||
@ResponseStatus(HttpStatus.OK) | ||
@GetMapping("/{id}") | ||
public LayoutResponseDto getLayout(@PathVariable UUID id) { | ||
return mapper.map(layoutService.getLayout(id), LayoutResponseDto.class); | ||
} | ||
|
||
/** | ||
* Gets metadata for all layouts | ||
* | ||
* @return the metadata | ||
*/ | ||
@ResponseStatus(HttpStatus.OK) | ||
@GetMapping("/metadata") | ||
public List<MetadataResponseDto> getMetadata() { | ||
|
||
return metadataService.getMetadata() | ||
.stream() | ||
.map(metadata -> mapper.map(metadata, MetadataResponseDto.class)) | ||
.collect(java.util.stream.Collectors.toList()); | ||
} | ||
|
||
/** | ||
* Creates a new layout | ||
* | ||
* @param layoutToCreate the layout to be created | ||
* @return the layout that has been created, with the autogenerated ID and created date | ||
*/ | ||
@ResponseStatus(HttpStatus.CREATED) | ||
@PostMapping | ||
public LayoutResponseDto createLayout(@RequestBody @Valid LayoutRequestDto layoutToCreate) { | ||
Layout layout = mapper.map(layoutToCreate, Layout.class); | ||
|
||
return mapper.map(layoutService.createLayout(layout), LayoutResponseDto.class); | ||
} | ||
|
||
/** | ||
* Updates the specified layout | ||
* | ||
* @param id ID of the layout to update | ||
* @param layout the new layout | ||
*/ | ||
@ResponseStatus(HttpStatus.NO_CONTENT) | ||
@PutMapping("/{id}") | ||
public void updateLayout(@PathVariable UUID id, @RequestBody @Valid LayoutRequestDto layout) { | ||
Layout newLayout = mapper.map(layout, Layout.class); | ||
|
||
layoutService.updateLayout(id, newLayout); | ||
} | ||
|
||
/** | ||
* Deletes the specified layout | ||
* | ||
* @param id ID of the layout to delete | ||
*/ | ||
@ResponseStatus(HttpStatus.NO_CONTENT) | ||
@DeleteMapping("/{id}") | ||
public void deleteLayout(@PathVariable UUID id) { | ||
layoutService.deleteLayout(id); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
layout-server/src/main/java/org/finos/vuu/layoutserver/dto/request/LayoutRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.finos.vuu.layoutserver.dto.request; | ||
|
||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import lombok.Data; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
@Data | ||
public class LayoutRequestDto { | ||
|
||
/** | ||
* The definition of the layout as an arbitrary JSON structure, describing all required components | ||
*/ | ||
@NotNull(message = "Definition must not be null") | ||
private ObjectNode definition; | ||
|
||
@NotNull(message = "Metadata must not be null") | ||
private MetadataRequestDto metadata; | ||
} |
12 changes: 12 additions & 0 deletions
12
layout-server/src/main/java/org/finos/vuu/layoutserver/dto/request/MetadataRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.finos.vuu.layoutserver.dto.request; | ||
|
||
import com.fasterxml.jackson.annotation.JsonUnwrapped; | ||
import lombok.Data; | ||
import org.finos.vuu.layoutserver.model.BaseMetadata; | ||
|
||
@Data | ||
public class MetadataRequestDto { | ||
|
||
@JsonUnwrapped | ||
BaseMetadata baseMetadata; | ||
} |
10 changes: 10 additions & 0 deletions
10
...ut-server/src/main/java/org/finos/vuu/layoutserver/dto/response/ApplicationLayoutDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.finos.vuu.layoutserver.dto.response; | ||
|
||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class ApplicationLayoutDto { | ||
private String username; | ||
private ObjectNode definition; | ||
} |
24 changes: 24 additions & 0 deletions
24
layout-server/src/main/java/org/finos/vuu/layoutserver/dto/response/ErrorResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.finos.vuu.layoutserver.dto.response; | ||
|
||
import lombok.Data; | ||
import org.springframework.http.HttpStatus; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
@Data | ||
public class ErrorResponse { | ||
private LocalDate timestamp = LocalDate.now(); | ||
private int status; | ||
private String error; | ||
private List<String> messages; | ||
private String path; | ||
|
||
public ErrorResponse(HttpServletRequest request, List<String> messages, HttpStatus status) { | ||
this.status = status.value(); | ||
this.error = status.getReasonPhrase(); | ||
this.path = request.getRequestURI(); | ||
this.messages = messages; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
layout-server/src/main/java/org/finos/vuu/layoutserver/dto/response/LayoutResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.finos.vuu.layoutserver.dto.response; | ||
|
||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import lombok.Data; | ||
|
||
import java.util.UUID; | ||
|
||
@Data | ||
public class LayoutResponseDto { | ||
|
||
private UUID id; | ||
|
||
/** | ||
* The definition of the layout as an arbitrary JSON structure, describing all required components | ||
*/ | ||
private ObjectNode definition; | ||
|
||
private MetadataResponseDto metadata; | ||
} |
Oops, something went wrong.