-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Oppdatert config #deploy-test-dolly-backend
- Loading branch information
Showing
11 changed files
with
131 additions
and
56 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
5 changes: 4 additions & 1 deletion
5
apps/dolly-backend/src/main/java/no/nav/dolly/DollyBackendApplicationStarter.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
29 changes: 18 additions & 11 deletions
29
apps/dolly-backend/src/main/java/no/nav/dolly/config/ElasticSearchConfig.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 |
---|---|---|
@@ -1,34 +1,41 @@ | ||
package no.nav.dolly.config; | ||
|
||
import org.opensearch.client.RestHighLevelClient; | ||
import org.opensearch.data.client.orhlc.AbstractOpenSearchConfiguration; | ||
import org.opensearch.data.client.orhlc.ClientConfiguration; | ||
import org.opensearch.data.client.orhlc.RestClients; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.data.elasticsearch.client.ClientConfiguration; | ||
import org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchConfiguration; | ||
|
||
import java.time.Duration; | ||
|
||
@Profile({"prod", "dev"}) | ||
@Profile("!test") | ||
@Configuration | ||
public class ElasticSearchConfig extends ReactiveElasticsearchConfiguration { | ||
public class ElasticSearchConfig extends AbstractOpenSearchConfiguration { | ||
|
||
@Value("${OPEN_SEARCH_USERNAME}") | ||
@Value("${open.search.username}") | ||
private String username; | ||
|
||
@Value("${OPEN_SEARCH_PASSWORD}") | ||
@Value("${open.search.password}") | ||
private String password; | ||
|
||
@Value("${OPEN_SEARCH_URI}") | ||
@Value("${open.search.uri}") | ||
private String uri; | ||
|
||
@Value("${open.search.port}") | ||
private String port; | ||
|
||
@Override | ||
public ClientConfiguration clientConfiguration() { | ||
return ClientConfiguration.builder() | ||
.connectedTo(uri.replace("https://", "")) | ||
public RestHighLevelClient opensearchClient() { | ||
|
||
return RestClients.create(ClientConfiguration.builder() | ||
.connectedTo(String.format("%s:%s", uri, port)) | ||
.usingSsl() | ||
.withBasicAuth(username, password) | ||
.withConnectTimeout(Duration.ofSeconds(10)) | ||
.withSocketTimeout(Duration.ofSeconds(5)) | ||
.build(); | ||
.build()) | ||
.rest(); | ||
} | ||
} |
24 changes: 0 additions & 24 deletions
24
apps/dolly-backend/src/main/java/no/nav/dolly/config/ElasticSearchLocalConfig.java
This file was deleted.
Oops, something went wrong.
5 changes: 2 additions & 3 deletions
5
apps/dolly-backend/src/main/java/no/nav/dolly/elastic/BestillingElasticRepository.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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package no.nav.dolly.elastic; | ||
|
||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; | ||
|
||
public interface BestillingElasticRepository extends ElasticsearchRepository<ElasticBestilling, Long> { | ||
public interface BestillingElasticRepository { | ||
// public interface BestillingElasticRepository extends ElasticsearchRepository<ElasticBestilling, Long> { | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
apps/dolly-backend/src/main/java/no/nav/dolly/provider/api/ElasticController.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,48 @@ | ||
package no.nav.dolly.provider.api; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.RequiredArgsConstructor; | ||
import no.nav.dolly.domain.jpa.Bestilling; | ||
import no.nav.dolly.domain.resultset.RsDollyBestilling; | ||
import no.nav.dolly.service.ElasticService; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/elastic") | ||
@RequiredArgsConstructor | ||
public class ElasticController { | ||
|
||
private final ElasticService elasticService; | ||
|
||
@Deprecated | ||
@PostMapping | ||
public void lagreBestilling(@RequestBody Wrapper bestilling) { | ||
|
||
elasticService.lagreBestillingMedStatus(bestilling.getDollyBestilling(), bestilling.getBestillingStatus()); | ||
} | ||
|
||
@GetMapping | ||
public List<String> getIdenter() { | ||
|
||
return null; | ||
} | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Wrapper { | ||
|
||
private RsDollyBestilling dollyBestilling; | ||
private Bestilling bestillingStatus; | ||
} | ||
} |
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
46 changes: 46 additions & 0 deletions
46
apps/dolly-backend/src/main/java/no/nav/dolly/service/ElasticService.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,46 @@ | ||
package no.nav.dolly.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import ma.glasnost.orika.MapperFacade; | ||
import no.nav.dolly.domain.jpa.Bestilling; | ||
import no.nav.dolly.domain.jpa.BestillingProgress; | ||
import no.nav.dolly.domain.resultset.RsDollyBestilling; | ||
import no.nav.dolly.elastic.ElasticBestilling; | ||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
import static org.apache.commons.lang3.StringUtils.isBlank; | ||
|
||
@Slf4j | ||
@Service | ||
@RequiredArgsConstructor | ||
public class ElasticService { | ||
|
||
private final MapperFacade mapperFacade; | ||
// private final ElasticsearchRepository elasticsearchRepository; | ||
private final ElasticsearchOperations elasticsearchOperations; | ||
|
||
public void lagreBestillingMedStatus(RsDollyBestilling dollyBestilling, Bestilling bestillingMedStatus) { | ||
|
||
var elasticBestilling = mapperFacade.map(dollyBestilling, ElasticBestilling.class); | ||
elasticBestilling.setIdenter(bestillingMedStatus.getProgresser().stream() | ||
.filter(BestillingProgress::isIdentGyldig) | ||
.filter(progress -> isBlank(progress.getFeil())) | ||
.map(BestillingProgress::getIdent) | ||
.toList()); | ||
|
||
// var resultat = elasticsearchRepository.save(elasticBestilling); | ||
// | ||
// log.info("Elastic search record lagret {}", resultat); | ||
} | ||
|
||
public List<String> getIdenterForBestilling() { | ||
|
||
|
||
// elasticsearchOperations.search() | ||
return null; | ||
} | ||
} |
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