-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b85ef72
commit e65012f
Showing
11 changed files
with
266 additions
and
195 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
06-graph/src/main/java/expert/os/labs/persistence/persistence/Animal.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
30 changes: 0 additions & 30 deletions
30
06-graph/src/main/java/expert/os/labs/persistence/persistence/AnimalApp.java
This file was deleted.
Oops, something went wrong.
11 changes: 10 additions & 1 deletion
11
06-graph/src/main/java/expert/os/labs/persistence/persistence/AnimalService.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
52 changes: 52 additions & 0 deletions
52
06-graph/src/main/java/expert/os/labs/persistence/persistence/AppAnimal.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,52 @@ | ||
/* | ||
* Copyright (c) 2022 Contributors to the Eclipse Foundation | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Apache License v2.0 which accompanies this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. | ||
* | ||
* You may elect to redistribute this code under either of these licenses. | ||
*/ | ||
package expert.os.labs.persistence.persistence; | ||
|
||
import jakarta.enterprise.inject.se.SeContainer; | ||
import jakarta.enterprise.inject.se.SeContainerInitializer; | ||
import org.eclipse.jnosql.mapping.graph.EntityTree; | ||
|
||
import java.util.List; | ||
|
||
public class AppAnimal { | ||
|
||
public static void main(String[] args) { | ||
try (SeContainer container = SeContainerInitializer.newInstance().initialize()) { | ||
|
||
AnimalService service = container.select(AnimalService.class).get(); | ||
|
||
// Create and establish "eats" relationships between animals | ||
Animal grass = service.animal("grass"); | ||
Animal grasshopper = service.animal("grasshopper"); | ||
Animal frog = service.animal("frog"); | ||
Animal snake = service.animal("snake"); | ||
Animal eagle = service.animal("eagle"); | ||
|
||
// Use the service method eats() to define which animal can eat another one based on the chain food | ||
service.eats(eagle, snake); | ||
service.eats(snake, frog); | ||
service.eats(frog, grasshopper); | ||
service.eats(grasshopper, grass); | ||
|
||
// Retrieve and printout the list of animals that eats twice | ||
List<Animal> animalEatsTwice = service.eatsTwice(); | ||
System.out.println("The animals that eat twice: " + animalEatsTwice); | ||
|
||
// Retrieve and printout the list of animals that eats grass | ||
List<Animal> animalEatGrass = service.untilGrass(); | ||
System.out.println("The animals that eat until grass: " + animalEatGrass); | ||
|
||
// Retrieve the entity tree and print it out | ||
EntityTree entityTree = service.entityTree(); | ||
System.out.println("At the top of the entity tree: " + entityTree.getLeaf().toList()); | ||
} | ||
} | ||
} |
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
11 changes: 10 additions & 1 deletion
11
06-graph/src/main/java/expert/os/labs/persistence/persistence/BookService.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
10 changes: 10 additions & 0 deletions
10
06-graph/src/main/java/expert/os/labs/persistence/persistence/LibraryLabels.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
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
10 changes: 10 additions & 0 deletions
10
06-graph/src/main/java/expert/os/labs/persistence/persistence/PersonService.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
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
Oops, something went wrong.