Created
March 29, 2016 04:32
-
-
Save cosbor11/48be0970cd4f6e538c94 to your computer and use it in GitHub Desktop.
Populate test data and build out the object graph
This file contains hidden or 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
| // Populate some test data | |
| Series theSopranos = new Series(); | |
| theSopranos.seriesId = "SOPRANOS"; | |
| Season firstSeason = new Season(1, 1999); | |
| Season secondSeason = new Season(2, 2000); | |
| Season thirdSeason = new Season(3, 2001); | |
| Season fourthSeason = new Season(4, 2002); | |
| // Add the seasons to the sopranos | |
| theSopranos.seasons = new ArrayList(); | |
| theSopranos.seasons.add(firstSeason); | |
| theSopranos.seasons.add(secondSeason); | |
| theSopranos.seasons.add(thirdSeason); | |
| theSopranos.seasons.add(fourthSeason); | |
| firstSeason.episodes = new ArrayList(); | |
| firstSeason.episodes.add(new Episode("s01e01", 1)); | |
| firstSeason.episodes.add(new Episode("s01e02", 2)); | |
| firstSeason.episodes.add(new Episode("s01e03", 3)); | |
| firstSeason.episodes.add(new Episode("s01e04", 4)); | |
| firstSeason.episodes.add(new Episode("s01e05", 5)); | |
| secondSeason.episodes = new ArrayList(); | |
| secondSeason.episodes.add(new Episode("s02e01", 6)); | |
| secondSeason.episodes.add(new Episode("s03e02", 7)); | |
| secondSeason.episodes.add(new Episode("s04e03", 8)); | |
| secondSeason.episodes.add(new Episode("s05e04", 9)); | |
| secondSeason.episodes.add(new Episode("s06e05", 10)); | |
| //... | |
| Actor james = new Actor(); | |
| james.firstName = "James"; | |
| james.lastName = "Gandolfini"; | |
| Actor steve = new Actor(); | |
| james.firstName = "Steve"; | |
| james.lastName = "Buscemi"; | |
| for(Season season : theSopranos.seasons) | |
| { | |
| if(season.episodes != null) { | |
| for (Episode episode : season.episodes) { | |
| episode.actors = new ArrayList(); | |
| episode.actors.add(james); | |
| episode.actors.add(steve); | |
| } | |
| } | |
| } | |
| // Save the Series. Note: This will persist the entire object graph | |
| manager.saveEntity(theSopranos); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment