Skip to content

Commit 59e81d8

Browse files
committed
chore: update projecton on oracle nosql
Signed-off-by: Otavio Santana <[email protected]>
1 parent 8a81aa5 commit 59e81d8

File tree

22 files changed

+591
-24
lines changed

22 files changed

+591
-24
lines changed

.gitignore

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
1-
# Compiled class file
2-
*.class
3-
4-
# Log file
1+
target/
2+
pom.xml.tag
3+
pom.xml.releaseBackup
4+
pom.xml.versionsBackup
5+
pom.xml.next
6+
test-output/
7+
/doc
8+
*.iml
59
*.log
10+
.classpath
11+
-project
12+
/.resourceCache
13+
/.project
14+
/.idea
15+
.settings/
616

7-
# BlueJ files
8-
*.ctxt
9-
10-
# Mobile Tools for Java (J2ME)
11-
.mtj.tmp/
12-
13-
# Package Files #
14-
*.jar
15-
*.war
16-
*.nar
17-
*.ear
18-
*.zip
19-
*.tar.gz
20-
*.rar
21-
22-
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23-
hs_err_pid*
24-
replay_pid*
17+
.DS_Store

README.md

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package org.soujava.demos.mongodb.document;
2+
3+
public enum CleanStatus {
4+
CLEAN,
5+
DIRTY,
6+
INSPECTION_NEEDED
7+
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
package org.soujava.demos.mongodb.document;
2+
3+
import jakarta.nosql.Column;
4+
import jakarta.nosql.Convert;
5+
import jakarta.nosql.Entity;
6+
import jakarta.nosql.Id;
7+
import org.eclipse.jnosql.databases.mongodb.mapping.ObjectIdConverter;
8+
9+
import java.util.Objects;
10+
11+
@Entity
12+
public class Room {
13+
14+
@Id
15+
@Convert(ObjectIdConverter.class)
16+
private String id;
17+
18+
@Column
19+
private int number;
20+
21+
@Column
22+
private RoomType type;
23+
24+
@Column
25+
private RoomStatus status;
26+
27+
@Column
28+
private CleanStatus cleanStatus;
29+
30+
@Column
31+
private boolean smokingAllowed;
32+
33+
@Column
34+
private boolean underMaintenance;
35+
36+
37+
public Room() {
38+
}
39+
40+
public Room(String id, int number,
41+
RoomType type, RoomStatus status,
42+
CleanStatus cleanStatus,
43+
boolean smokingAllowed, boolean underMaintenance) {
44+
this.id = id;
45+
this.number = number;
46+
this.type = type;
47+
this.status = status;
48+
this.cleanStatus = cleanStatus;
49+
this.smokingAllowed = smokingAllowed;
50+
this.underMaintenance = underMaintenance;
51+
}
52+
53+
public String getId() {
54+
return id;
55+
}
56+
57+
public int getNumber() {
58+
return number;
59+
}
60+
61+
public RoomType getType() {
62+
return type;
63+
}
64+
65+
public RoomStatus getStatus() {
66+
return status;
67+
}
68+
69+
public CleanStatus getCleanStatus() {
70+
return cleanStatus;
71+
}
72+
73+
public boolean isSmokingAllowed() {
74+
return smokingAllowed;
75+
}
76+
77+
public boolean isUnderMaintenance() {
78+
return underMaintenance;
79+
}
80+
81+
public void update(RoomStatus newStatus) {
82+
this.status = newStatus;
83+
}
84+
85+
@Override
86+
public boolean equals(Object o) {
87+
if (o == null || getClass() != o.getClass()) {
88+
return false;
89+
}
90+
Room room = (Room) o;
91+
return Objects.equals(id, room.id);
92+
}
93+
94+
@Override
95+
public int hashCode() {
96+
return Objects.hashCode(id);
97+
}
98+
99+
@Override
100+
public String toString() {
101+
return "Room{" +
102+
"id='" + id + '\'' +
103+
", roomNumber=" + number +
104+
", type=" + type +
105+
", status=" + status +
106+
", cleanStatus=" + cleanStatus +
107+
", smokingAllowed=" + smokingAllowed +
108+
", underMaintenance=" + underMaintenance +
109+
'}';
110+
}
111+
112+
113+
public static RoomBuilder builder() {
114+
return new RoomBuilder();
115+
}
116+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package org.soujava.demos.mongodb.document;
2+
3+
public class RoomBuilder {
4+
private String id;
5+
private int roomNumber;
6+
private RoomType type;
7+
private RoomStatus status;
8+
private CleanStatus cleanStatus;
9+
private boolean smokingAllowed;
10+
private boolean underMaintenance;
11+
12+
public RoomBuilder id(String id) {
13+
this.id = id;
14+
return this;
15+
}
16+
17+
public RoomBuilder number(int roomNumber) {
18+
this.roomNumber = roomNumber;
19+
return this;
20+
}
21+
22+
public RoomBuilder type(RoomType type) {
23+
this.type = type;
24+
return this;
25+
}
26+
27+
public RoomBuilder status(RoomStatus status) {
28+
this.status = status;
29+
return this;
30+
}
31+
32+
public RoomBuilder cleanStatus(CleanStatus cleanStatus) {
33+
this.cleanStatus = cleanStatus;
34+
return this;
35+
}
36+
37+
public RoomBuilder smokingAllowed(boolean smokingAllowed) {
38+
this.smokingAllowed = smokingAllowed;
39+
return this;
40+
}
41+
42+
public RoomBuilder underMaintenance(boolean underMaintenance) {
43+
this.underMaintenance = underMaintenance;
44+
return this;
45+
}
46+
47+
public Room build() {
48+
return new Room(id, roomNumber, type, status, cleanStatus, smokingAllowed, underMaintenance);
49+
}
50+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.soujava.demos.mongodb.document;
2+
3+
import jakarta.data.repository.Query;
4+
import jakarta.data.repository.Repository;
5+
import jakarta.data.repository.Save;
6+
7+
import java.util.List;
8+
import java.util.Optional;
9+
10+
@Repository
11+
public interface RoomRepository {
12+
13+
@Query("FROM Room")
14+
List<Room> findAll();
15+
16+
@Save
17+
Room save(Room room);
18+
void deleteBy();
19+
20+
Optional<Room> findByNumber(Integer number);
21+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.soujava.demos.mongodb.document;
2+
3+
public enum RoomStatus {
4+
AVAILABLE,
5+
RESERVED,
6+
UNDER_MAINTENANCE,
7+
OUT_OF_SERVICE
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.soujava.demos.mongodb.document;
2+
3+
public enum RoomType {
4+
STANDARD,
5+
DELUXE,
6+
SUITE,
7+
VIP_SUITE
8+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!--
2+
~ Copyright (c) 2022 Contributors to the Eclipse Foundation
3+
~ All rights reserved. This program and the accompanying materials
4+
~ are made available under the terms of the Eclipse Public License v1.0
5+
~ and Apache License v2.0 which accompanies this distribution.
6+
~ The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7+
~ and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
8+
~
9+
~ You may elect to redistribute this code under either of these licenses.
10+
-->
11+
12+
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
13+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
14+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
15+
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
16+
bean-discovery-mode="annotated">
17+
</beans>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Copyright (c) 2022 Contributors to the Eclipse Foundation
3+
# All rights reserved. This program and the accompanying materials
4+
# are made available under the terms of the Eclipse Public License v1.0
5+
# and Apache License v2.0 which accompanies this distribution.
6+
# The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7+
# and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
8+
#
9+
# You may elect to redistribute this code under either of these licenses.
10+
#
11+
jnosql.mongodb.url=mongodb://localhost:27017
12+
# mandatory define the database name
13+
jnosql.document.database=hotels

0 commit comments

Comments
 (0)