Gitlab - Argos ALM by PALO IT
Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
poc-measure-internal-rest
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Eder Yair Ramon Martinez
poc-measure-internal-rest
Commits
c79acb03
Commit
c79acb03
authored
Jul 29, 2023
by
Andres Isaac Garcia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve upgrading and homologate BD
parent
e017f1e1
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
19 additions
and
15 deletions
+19
-15
src/main/java/com/br/cardif/pocmeasureinternalrest/in/controller/dto/MeasureDTO.java
.../pocmeasureinternalrest/in/controller/dto/MeasureDTO.java
+1
-0
src/main/java/com/br/cardif/pocmeasureinternalrest/in/controller/model/MeasureRequest.java
...asureinternalrest/in/controller/model/MeasureRequest.java
+1
-1
src/main/java/com/br/cardif/pocmeasureinternalrest/in/controller/model/MeasureResponse.java
...sureinternalrest/in/controller/model/MeasureResponse.java
+1
-1
src/main/java/com/br/cardif/pocmeasureinternalrest/in/controller/service/MeasureService.java
...ureinternalrest/in/controller/service/MeasureService.java
+5
-2
src/main/java/com/br/cardif/pocmeasureinternalrest/out/mongo/MeasureDocument.java
...dif/pocmeasureinternalrest/out/mongo/MeasureDocument.java
+2
-1
src/main/java/com/br/cardif/pocmeasureinternalrest/out/mongo/adapter/MeasureMongoAdapter.java
...reinternalrest/out/mongo/adapter/MeasureMongoAdapter.java
+4
-0
src/main/java/com/br/cardif/pocmeasureinternalrest/out/mongo/repo/MeasureMongoRepository.java
...reinternalrest/out/mongo/repo/MeasureMongoRepository.java
+3
-0
src/main/resources/application-local.properties
src/main/resources/application-local.properties
+2
-2
src/main/resources/application.properties
src/main/resources/application.properties
+0
-8
No files found.
src/main/java/com/br/cardif/pocmeasureinternalrest/in/controller/dto/MeasureDTO.java
View file @
c79acb03
...
@@ -8,6 +8,7 @@ import lombok.NoArgsConstructor;
...
@@ -8,6 +8,7 @@ import lombok.NoArgsConstructor;
@Data
@Data
@NoArgsConstructor
@NoArgsConstructor
public
class
MeasureDTO
{
public
class
MeasureDTO
{
private
String
id
;
private
String
deviceId
;
private
String
deviceId
;
private
String
value
;
private
String
value
;
private
Instant
date
;
private
Instant
date
;
...
...
src/main/java/com/br/cardif/pocmeasureinternalrest/in/controller/model/MeasureRequest.java
View file @
c79acb03
...
@@ -2,6 +2,6 @@ package com.br.cardif.pocmeasureinternalrest.in.controller.model;
...
@@ -2,6 +2,6 @@ package com.br.cardif.pocmeasureinternalrest.in.controller.model;
import
java.time.Instant
;
import
java.time.Instant
;
public
record
MeasureRequest
(
String
deviceId
,
String
value
,
Instant
date
)
{
public
record
MeasureRequest
(
String
id
,
String
deviceId
,
String
value
,
Instant
date
)
{
}
}
src/main/java/com/br/cardif/pocmeasureinternalrest/in/controller/model/MeasureResponse.java
View file @
c79acb03
...
@@ -3,6 +3,6 @@ package com.br.cardif.pocmeasureinternalrest.in.controller.model;
...
@@ -3,6 +3,6 @@ package com.br.cardif.pocmeasureinternalrest.in.controller.model;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.time.Instant
;
import
java.time.Instant
;
public
record
MeasureResponse
(
String
deviceId
,
String
value
,
Instant
date
)
implements
Serializable
{
public
record
MeasureResponse
(
String
id
,
String
deviceId
,
String
value
,
Instant
date
)
implements
Serializable
{
}
}
src/main/java/com/br/cardif/pocmeasureinternalrest/in/controller/service/MeasureService.java
View file @
c79acb03
...
@@ -8,9 +8,11 @@ import com.br.cardif.pocmeasureinternalrest.out.mongo.MeasureDocument;
...
@@ -8,9 +8,11 @@ import com.br.cardif.pocmeasureinternalrest.out.mongo.MeasureDocument;
import
com.br.cardif.pocmeasureinternalrest.out.mongo.adapter.MeasureMongoAdapter
;
import
com.br.cardif.pocmeasureinternalrest.out.mongo.adapter.MeasureMongoAdapter
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
@Service
@Service
@RequiredArgsConstructor
@RequiredArgsConstructor
@Slf4j
public
class
MeasureService
{
public
class
MeasureService
{
private
final
MeasureMongoAdapter
measureMongoAdapter
;
private
final
MeasureMongoAdapter
measureMongoAdapter
;
...
@@ -18,12 +20,13 @@ public class MeasureService {
...
@@ -18,12 +20,13 @@ public class MeasureService {
public
MeasureDTO
updateMeasure
(
MeasureDTO
measure
){
public
MeasureDTO
updateMeasure
(
MeasureDTO
measure
){
MeasureDocument
document
=
mapper
.
documentFromDto
(
measure
);
MeasureDocument
document
=
mapper
.
documentFromDto
(
measure
);
MeasureDocument
documentResult
=
measureMongoAdapter
.
save
(
document
);
MeasureDocument
documentResult
=
measureMongoAdapter
.
save
(
document
);
return
mapper
.
dtoFromDocument
(
documentResult
);
return
mapper
.
dtoFromDocument
(
documentResult
);
}
}
public
MeasureDTO
getMeasure
(
String
deviceId
){
public
MeasureDTO
getMeasure
(
String
deviceId
){
MeasureDocument
document
=
measureMongoAdapter
.
findById
(
deviceId
);
MeasureDocument
document
=
measureMongoAdapter
.
findByDeviceId
(
deviceId
);
log
.
info
(
"Measure Id recovered from BD {}"
,
document
.
getId
());
return
mapper
.
dtoFromDocument
(
document
);
return
mapper
.
dtoFromDocument
(
document
);
}
}
}
}
src/main/java/com/br/cardif/pocmeasureinternalrest/out/mongo/MeasureDocument.java
View file @
c79acb03
...
@@ -10,13 +10,14 @@ import lombok.Getter;
...
@@ -10,13 +10,14 @@ import lombok.Getter;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.Setter
;
@Document
@Document
(
collection
=
"measure"
)
@Setter
@Setter
@Getter
@Getter
@NoArgsConstructor
@NoArgsConstructor
public
class
MeasureDocument
public
class
MeasureDocument
{
{
@Id
@Id
private
String
id
;
private
String
deviceId
;
private
String
deviceId
;
private
String
value
;
private
String
value
;
private
Instant
date
;
private
Instant
date
;
...
...
src/main/java/com/br/cardif/pocmeasureinternalrest/out/mongo/adapter/MeasureMongoAdapter.java
View file @
c79acb03
...
@@ -23,5 +23,9 @@ public class MeasureMongoAdapter {
...
@@ -23,5 +23,9 @@ public class MeasureMongoAdapter {
return
repository
.
findById
(
deviceId
).
orElseThrow
(()
->
new
HttpClientErrorException
(
HttpStatus
.
NOT_FOUND
));
return
repository
.
findById
(
deviceId
).
orElseThrow
(()
->
new
HttpClientErrorException
(
HttpStatus
.
NOT_FOUND
));
}
}
public
MeasureDocument
findByDeviceId
(
String
deviceId
)
{
return
repository
.
findByDeviceId
(
deviceId
).
orElseThrow
(()
->
new
HttpClientErrorException
(
HttpStatus
.
NOT_FOUND
));
}
}
}
src/main/java/com/br/cardif/pocmeasureinternalrest/out/mongo/repo/MeasureMongoRepository.java
View file @
c79acb03
package
com.br.cardif.pocmeasureinternalrest.out.mongo.repo
;
package
com.br.cardif.pocmeasureinternalrest.out.mongo.repo
;
import
java.util.Optional
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
com.br.cardif.pocmeasureinternalrest.out.mongo.MeasureDocument
;
import
com.br.cardif.pocmeasureinternalrest.out.mongo.MeasureDocument
;
public
interface
MeasureMongoRepository
extends
MongoRepository
<
MeasureDocument
,
String
>
{
public
interface
MeasureMongoRepository
extends
MongoRepository
<
MeasureDocument
,
String
>
{
Optional
<
MeasureDocument
>
findByDeviceId
(
String
deviceId
);
}
}
src/main/resources/application-local.properties
View file @
c79acb03
...
@@ -5,10 +5,10 @@ management.endpoint.health.show-components=always
...
@@ -5,10 +5,10 @@ management.endpoint.health.show-components=always
management.endpoint.health.show-details
=
always
management.endpoint.health.show-details
=
always
# MongoDB
# MongoDB
spring.data.mongodb.uri
=
mongodb://user:
pa55word@localhost/petstor
e?authSource=admin
spring.data.mongodb.uri
=
mongodb://user:
myPasswordMongo21c@localhost:27017/carrefur-databas
e?authSource=admin
#logs
#logs
logging.pattern.level
:
"%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]"
logging.pattern.level
=
%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]
# Actuator
# Actuator
...
...
src/main/resources/application.properties
View file @
c79acb03
...
@@ -23,11 +23,3 @@ spring.jackson.visibility.field=any
...
@@ -23,11 +23,3 @@ spring.jackson.visibility.field=any
spring.jackson.visibility.getter
=
none
spring.jackson.visibility.getter
=
none
spring.jackson.visibility.setter
=
none
spring.jackson.visibility.setter
=
none
spring.jackson.visibility.is-getter
=
none
spring.jackson.visibility.is-getter
=
none
spring.cloud.function.definition
=
measureConsumer
#Producer
spring.cloud.stream.bindings.measureProducer.destination
=
measure
# MongoDB
spring.data.mongodb.uri
=
mongodb://user:pa55word@localhost/petstore?authSource=admin
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment