Skip to content

Commit 071f420

Browse files
committed
chore: create initial structure code
Signed-off-by: Otavio Santana <[email protected]>
1 parent 8932ca0 commit 071f420

16 files changed

+586
-23
lines changed

.gitignore

+14-23
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
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
6-
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*
10+
.classpath
11+
-project
12+
/.resourceCache
13+
/.project
14+
/.idea
15+
.settings/

pom.xml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
13+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
14+
<modelVersion>4.0.0</modelVersion>
15+
<artifactId>arangodb</artifactId>
16+
<name>JNoSQL Demo using Java SE arangodb</name>
17+
18+
<parent>
19+
<groupId>org.eclipse.jnosql.mapping</groupId>
20+
<artifactId>mapping-demo-java-se</artifactId>
21+
<version>1.1.4</version>
22+
</parent>
23+
24+
<properties>
25+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
26+
</properties>
27+
28+
<dependencies>
29+
<dependency>
30+
<groupId>net.datafaker</groupId>
31+
<artifactId>datafaker</artifactId>
32+
<version>2.0.2</version>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.eclipse.jnosql.databases</groupId>
36+
<artifactId>jnosql-arangodb</artifactId>
37+
<version>1.1.4</version>
38+
</dependency>
39+
</dependencies>
40+
41+
</project>
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
package org.jnosql.demo.se;
13+
14+
15+
import jakarta.enterprise.inject.se.SeContainer;
16+
import jakarta.enterprise.inject.se.SeContainerInitializer;
17+
import net.datafaker.Faker;
18+
import org.eclipse.jnosql.mapping.document.DocumentTemplate;
19+
20+
import java.util.List;
21+
22+
public class App {
23+
24+
public static void main(String[] args) {
25+
26+
try (SeContainer container = SeContainerInitializer.newInstance().initialize()) {
27+
var faker = new Faker();
28+
var template = container.select(DocumentTemplate.class).get();
29+
30+
Hero hero = template.insert(Hero.of(faker));
31+
32+
List<Hero> heroes = template.select(Hero.class)
33+
.where("name").eq(hero.name()).result();
34+
System.out.println(heroes);
35+
36+
}
37+
}
38+
39+
private App() {
40+
}
41+
}
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
package org.jnosql.demo.se;
13+
14+
15+
import jakarta.enterprise.inject.se.SeContainer;
16+
import jakarta.enterprise.inject.se.SeContainerInitializer;
17+
import net.datafaker.Faker;
18+
import org.eclipse.jnosql.databases.arangodb.mapping.ArangoDBTemplate;
19+
20+
import java.util.Collections;
21+
import java.util.List;
22+
import java.util.stream.Collectors;
23+
24+
import static org.eclipse.jnosql.communication.semistructured.SelectQuery.select;
25+
26+
27+
public class App1 {
28+
29+
30+
public static void main(String[] args) {
31+
32+
try (SeContainer container = SeContainerInitializer.newInstance().initialize()) {
33+
34+
var faker = new Faker();
35+
36+
ArangoDBTemplate template = container.select(ArangoDBTemplate.class).get();
37+
Hero hero = template.insert(Hero.of(faker));
38+
39+
var query = select().from("Hero").where("_key").eq("iron_man").build();
40+
List<Hero> heroes = template.<Hero>select(query).collect(Collectors.toList());
41+
List<Hero> aql = template.<Hero>aql("FOR h IN Hero FILTER h.name == @id RETURN h", Collections.singletonMap("id", hero.name()))
42+
.collect(Collectors.toList());
43+
System.out.println(heroes);
44+
System.out.println(aql);
45+
46+
47+
48+
}
49+
}
50+
private App1() {
51+
}
52+
}
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
package org.jnosql.demo.se;
13+
14+
15+
import jakarta.enterprise.inject.se.SeContainer;
16+
import jakarta.enterprise.inject.se.SeContainerInitializer;
17+
import net.datafaker.Faker;
18+
19+
public class App2 {
20+
21+
22+
23+
public static void main(String[] args) {
24+
25+
try (SeContainer container = SeContainerInitializer.newInstance().initialize()) {
26+
var faker = new Faker();
27+
28+
HeroRepository repository = container.select(HeroRepository.class).get();
29+
Hero hero = repository.save(Hero.of(faker));
30+
31+
System.out.println(repository.findByName("iron_man"));
32+
System.out.println(repository.find("Tony Stark"));
33+
34+
}
35+
}
36+
37+
private App2() {
38+
}
39+
}
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
package org.jnosql.demo.se;
13+
14+
15+
import jakarta.enterprise.inject.se.SeContainer;
16+
import jakarta.enterprise.inject.se.SeContainerInitializer;
17+
18+
public class App3 {
19+
20+
21+
public static void main(String[] args) {
22+
23+
try (SeContainer container = SeContainerInitializer.newInstance().initialize()) {
24+
Villain lock = new Villain();
25+
lock.setId("lock");
26+
lock.setName("Lock");
27+
28+
VillainService service = container.select(VillainService.class).get();
29+
service.put(lock);
30+
System.out.println(service.get("lock"));
31+
32+
}
33+
}
34+
35+
private App3() {
36+
}
37+
}
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
package org.jnosql.demo.se;
13+
14+
15+
import jakarta.enterprise.inject.se.SeContainer;
16+
import jakarta.enterprise.inject.se.SeContainerInitializer;
17+
import org.eclipse.jnosql.mapping.DatabaseQualifier;
18+
19+
public class App4 {
20+
21+
22+
public static void main(String[] args) {
23+
24+
try (SeContainer container = SeContainerInitializer.newInstance().initialize()) {
25+
Villain lock = new Villain();
26+
lock.setId("lock");
27+
lock.setName("Lock");
28+
29+
Villain doom = new Villain();
30+
doom.setId("doom");
31+
doom.setName("Dc Doom");
32+
33+
VillainRepository repository = container.select(VillainRepository.class, DatabaseQualifier.ofKeyValue()).get();
34+
35+
repository.save(lock);
36+
repository.save(doom);
37+
System.out.println(repository.findById("lock"));
38+
System.out.println(repository.findById("doom"));
39+
40+
}
41+
}
42+
43+
private App4() {
44+
}
45+
}
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
package org.jnosql.demo.se;
13+
14+
15+
import jakarta.enterprise.inject.se.SeContainer;
16+
import jakarta.enterprise.inject.se.SeContainerInitializer;
17+
import org.eclipse.jnosql.mapping.document.DocumentTemplate;
18+
19+
import java.util.List;
20+
import java.util.Map;
21+
22+
public class App5 {
23+
24+
25+
public static void main(String[] args) {
26+
27+
try (SeContainer container = SeContainerInitializer.newInstance().initialize()) {
28+
Form form = new Form();
29+
form.setId("form");
30+
form.setOption("option_1");
31+
form.setQuestions(Map.of("question_1", "Duke", "question_2", false, "question_3",
32+
Map.of("question_3_1", "Java", "question_3_2", "Jakarta EE")));
33+
34+
var template = container.select(DocumentTemplate.class).get();
35+
template.delete(Form.class).execute();
36+
template.insert(form);
37+
List<Form> forms = template.select(Form.class).result();
38+
System.out.println(forms);
39+
40+
}
41+
}
42+
43+
private App5() {
44+
}
45+
}
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package org.jnosql.demo.se;
2+
3+
import jakarta.nosql.Column;
4+
import jakarta.nosql.Entity;
5+
import jakarta.nosql.Id;
6+
7+
import java.util.Map;
8+
9+
@Entity
10+
public class Form {
11+
12+
@Id
13+
private String id;
14+
15+
@Column
16+
private String option;
17+
18+
@Column
19+
private Map<String, Object> questions;
20+
21+
public String getId() {
22+
return id;
23+
}
24+
25+
public void setId(String id) {
26+
this.id = id;
27+
}
28+
29+
public Map<String, Object> getQuestions() {
30+
return questions;
31+
}
32+
33+
public void setQuestions(Map<String, Object> questions) {
34+
this.questions = questions;
35+
}
36+
37+
public String getOption() {
38+
return option;
39+
}
40+
41+
public void setOption(String option) {
42+
this.option = option;
43+
}
44+
45+
@Override
46+
public String toString() {
47+
return "Form{" +
48+
"id='" + id + '\'' +
49+
", option='" + option + '\'' +
50+
", questions=" + questions +
51+
'}';
52+
}
53+
}

0 commit comments

Comments
 (0)