2 * Copyright © 2019 IBM.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.repository
19 import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
20 import org.springframework.stereotype.Service
21 import reactor.core.publisher.Flux
22 import reactor.core.publisher.Mono
23 import reactor.core.scheduler.Schedulers
24 // TODO("Convert into coroutines")
26 * ModelTypeReactRepository.
28 * @author Brinda Santh
31 open class ModelTypeReactRepository(private val modelTypeRepository: ModelTypeRepository) {
33 fun save(modelType: ModelType): Mono<ModelType> {
34 return Mono.justOrEmpty(modelTypeRepository.save(modelType))
37 fun findByModelName(modelName: String): Mono<ModelType> {
38 return Mono.justOrEmpty(modelTypeRepository.findByModelName(modelName))
41 fun findByModelNameIn(modelNames: List<String>): Flux<ModelType> {
42 return Flux.fromIterable(modelTypeRepository.findByModelNameIn(modelNames))
43 .subscribeOn(Schedulers.elastic())
46 fun findByDerivedFrom(derivedFrom: String): Flux<ModelType> {
47 return Flux.fromIterable(modelTypeRepository.findByDerivedFrom(derivedFrom))
48 .subscribeOn(Schedulers.elastic())
51 fun findByDerivedFromIn(derivedFroms: List<String>): Flux<ModelType> {
52 return Flux.fromIterable(modelTypeRepository.findByDerivedFromIn(derivedFroms))
53 .subscribeOn(Schedulers.elastic())
56 fun findByDefinitionType(definitionType: String): Flux<ModelType> {
57 return Flux.fromIterable(modelTypeRepository.findByDefinitionType(definitionType))
58 .subscribeOn(Schedulers.elastic())
61 fun findByDefinitionTypeIn(definitionTypes: List<String>): Flux<ModelType> {
62 return Flux.fromIterable(modelTypeRepository.findByDefinitionTypeIn(definitionTypes))
63 .subscribeOn(Schedulers.elastic())
66 fun findByTagsContainingIgnoreCase(tags: String): Flux<ModelType> {
67 return Flux.fromIterable(modelTypeRepository.findByTagsContainingIgnoreCase(tags))
68 .subscribeOn(Schedulers.elastic())
71 fun deleteByModelName(modelName: String): Mono<Void> {
72 modelTypeRepository.deleteByModelName(modelName)