Skip to content

Commit

Permalink
Merge branch 'save-basket-with-name' into issue_981-send-to-market-fo…
Browse files Browse the repository at this point in the history
…r-basket-trades-fake-oms
  • Loading branch information
heswell committed Nov 22, 2023
2 parents 84afb30 + 1645da0 commit 320c324
Show file tree
Hide file tree
Showing 176 changed files with 7,249 additions and 1,548 deletions.
1 change: 1 addition & 0 deletions .semgrepignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ example/order/src/main/scala/org/finos/vuu/provider/simulation/SimulatedBigInstr
vuu/src/main/scala/org/finos/vuu/provider/simulation/SimulatedBigInstrumentsProvider.scala
vuu-ui/packages/vuu-data/src/array-data-source/group-utils.ts
vuu-ui/packages/vuu-datagrid-extras/src/column-expression-input/column-language-parser/walkExpressionTree.ts
vuu-ui/packages/vuu-layout/src/layout-persistence/RemoteLayoutPersistenceManager.ts
vuu-ui/packages/vuu-popups/src/menu/useContextMenu.tsx
vuu-ui/packages/vuu-table-extras/src/cell-edit-validators/PatternValidator.ts
vuu-ui/packages/vuu-ui-controls/src/list/Highlighter.tsx
Expand Down
78 changes: 78 additions & 0 deletions layout-server/pom.xml
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>
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");
}
}
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);
}

}
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;
}
}
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);
}
}
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);
}
}
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;
}
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;
}
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;
}
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;
}
}
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;
}
Loading

0 comments on commit 320c324

Please sign in to comment.