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
package io.biznet.event.handler | |
import io.biznet.event.EventHandlerProperties | |
import io.biznet.event.IdentifiedApplicationEvent | |
import mu.KLogging | |
import org.springframework.context.ApplicationListener | |
import reactor.core.publisher.Flux | |
import reactor.core.publisher.Mono | |
import reactor.core.publisher.Sinks | |
import reactor.core.scheduler.Scheduler |
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
override fun transformRequestObjectNodeReactive( | |
requestBody: ObjectNode | |
): Mono<ObjectNode> { | |
return if (requestBody.get("periods").isArray) { | |
val periods = (requestBody.get("periods") as ArrayNode).elements().asSequence().joinToString(",") | |
webClient | |
.get() | |
.uri("http://localhost/periods?code=${periods}") | |
.retrieve() | |
.bodyToMono<ArrayNode>() |
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
override fun transformRequestObjectNode( | |
requestBody: ObjectNode | |
): ObjectNode = requestBody.renameProperty("era","periods") | |
override fun transformResponseObjectNode( | |
responseBody: ObjectNode | |
): ObjectNode = responseBody.renameProperty("periods","era") | |
override fun transformRequestQueryParam( | |
queryParams: MultiValueMap<String, String> |
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
override fun transformRequestObjectNode(requestBody: ObjectNode): ObjectNode { | |
val eras = objectMapper.createArrayNode() | |
if (requestBody["era"].isNotNull()) { | |
val era = requestBody["era"] as ObjectNode | |
eras.add(era) | |
} | |
requestBody.remove("era") | |
requestBody.set<ArrayNode>("era", eras) | |
return requestBody |
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
import com.fasterxml.jackson.databind.JsonNode | |
import com.fasterxml.jackson.databind.ObjectMapper | |
import com.fasterxml.jackson.databind.node.ArrayNode | |
import com.fasterxml.jackson.databind.node.ObjectNode | |
import mu.KLogging | |
import org.springframework.stereotype.Service | |
import org.springframework.web.reactive.function.client.WebClient | |
import org.springframework.web.reactive.function.client.bodyToMono | |
import org.springframework.web.server.ServerWebExchange | |
import reactor.core.publisher.Mono |
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
interface VersionTransformer { | |
fun sourceVersionNumber(): ApiVersion | |
fun accept(exchange: ServerWebExchange): Boolean | |
fun transformRequestQueryParam(queryParams: MultiValueMap<String, String>): MultiValueMap<String, String> = queryParams | |
fun transformResponseObjectNode(responseBody: ObjectNode): ObjectNode = responseBody |
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
interface VersionTransformer { | |
fun sourceVersionNumber(): ApiVersion | |
fun accept(exchange: ServerWebExchange): Boolean | |
fun transformRequestQueryParam(queryParams: MultiValueMap<String, String>): MultiValueMap<String, String> = queryParams | |
fun transformResponseObjectNode(responseBody: ObjectNode): ObjectNode |
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
@Repository | |
class PersonRepositoryImpl implements PersonRepositoryCustom { | |
@Autowired | |
MongoTemplate mongoTemplate | |
@Override | |
List<Person> findByIdsOrFirstNameOrLastName(List<String> personIds, String firstName, String lastName){ | |
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
List<Person> listPersons(PersonListCommand command) { | |
return personRepository.findByIdsOrFirstNameOrLastName(command.personIds,command.firstName, command.lastName) | |
} | |
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
List<Person> listPersons(PersonListCommand command) { | |
List<Person> persons | |
if (command.personIds && command.firstName && command.lastName) { | |
persons = personRepository.findByIdInAndFirstNameAndLastName(command.personIds, command.firstName, command.lastName) | |
} else if (command.personIds && command.firstName) { | |
persons = personRepository.findByIdInAndFirstName(command.personIds, command.firstName) | |
} else if (command.personIds && command.lastName) { |
NewerOlder