Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Team 14 - IDATT1002
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eirik Steira
Team 14 - IDATT1002
Merge requests
!68
Add LoadDatabase to load test data into the database
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add LoadDatabase to load test data into the database
load-database
into
dev
Overview
0
Commits
3
Pipelines
2
Changes
5
Merged
Eirik Steira
requested to merge
load-database
into
dev
5 years ago
Overview
0
Commits
3
Pipelines
2
Changes
5
Expand
0
0
Merge request reports
Compare
dev
version 2
5ba02b2f
5 years ago
version 1
1781a6fc
5 years ago
dev (base)
and
latest version
latest version
5f7e4057
3 commits,
5 years ago
version 2
5ba02b2f
2 commits,
5 years ago
version 1
1781a6fc
1 commit,
5 years ago
5 files
+
214
−
10
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
5
Search (e.g. *.vue) (Ctrl+P)
src/main/java/NTNU/IDATT1002/database/LoadDatabase.java
0 → 100644
+
185
−
0
Options
package
NTNU.IDATT1002.database
;
import
NTNU.IDATT1002.models.Image
;
import
NTNU.IDATT1002.models.Tag
;
import
NTNU.IDATT1002.models.User
;
import
NTNU.IDATT1002.service.ImageAlbumService
;
import
NTNU.IDATT1002.service.ImageService
;
import
NTNU.IDATT1002.service.UserService
;
import
java.io.File
;
import
java.util.Arrays
;
import
java.util.Date
;
/**
* Loads test data into the database.
*/
public
class
LoadDatabase
{
private
static
UserService
userService
;
private
static
ImageAlbumService
imageAlbumService
;
private
static
ImageService
imageService
;
static
{
userService
=
new
UserService
();
imageAlbumService
=
new
ImageAlbumService
();
imageService
=
new
ImageService
();
}
public
static
void
load
()
{
User
user
=
userService
.
createUser
(
"LarseKaren@mail.com"
,
"LarseKaren"
,
"Larse"
,
"Karen"
,
"+47"
,
"00000000"
,
new
Date
(),
"123"
)
.
get
();
Image
image
=
imageService
.
createImage
(
user
,
new
File
(
"t14-test-images/1.jpg"
)).
get
();
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#winter"
));
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#nature"
));
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#mountains"
));
imageAlbumService
.
createImageAlbum
(
"First"
,
"Lorem Ipsum"
,
user
,
Arrays
.
asList
(
new
Tag
(
"#winter"
),
new
Tag
(
"#nature"
),
new
Tag
(
"#mountains"
)),
Arrays
.
asList
(
image
));
image
=
imageService
.
createImage
(
user
,
new
File
(
"t14-test-images/7.jpg"
)).
get
();
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#winter"
));
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#nature"
));
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#ice"
));
imageAlbumService
.
createImageAlbum
(
"Seventh"
,
"Lorem Ipsum"
,
user
,
Arrays
.
asList
(
new
Tag
(
"#winter"
),
new
Tag
(
"#nature"
),
new
Tag
(
"#ice"
)),
Arrays
.
asList
(
image
));
user
=
userService
.
createUser
(
"SteiraGuten@mail.com"
,
"SteiraGuten"
,
"Steira"
,
"Guten"
,
"+47"
,
"00000000"
,
new
Date
(),
"123"
)
.
get
();
image
=
imageService
.
createImage
(
user
,
new
File
(
"t14-test-images/2.jpg"
)).
get
();
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#mountains"
));
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#water"
));
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#nature"
));
imageAlbumService
.
createImageAlbum
(
"Second"
,
"Lorem Ipsum"
,
user
,
Arrays
.
asList
(
new
Tag
(
"#mountains"
),
new
Tag
(
"#water"
),
new
Tag
(
"#nature"
)),
Arrays
.
asList
(
image
));
image
=
imageService
.
createImage
(
user
,
new
File
(
"t14-test-images/10.jpg"
)).
get
();
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#fjords"
));
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#nature"
));
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#mountains"
));
imageAlbumService
.
createImageAlbum
(
"Tenth"
,
"Lorem Ipsum"
,
user
,
Arrays
.
asList
(
new
Tag
(
"#fjords"
),
new
Tag
(
"#nature"
),
new
Tag
(
"#mountains"
)),
Arrays
.
asList
(
image
));
user
=
userService
.
createUser
(
"MogenBogen@mail.com"
,
"MogenBogen"
,
"Mogen"
,
"Bogen"
,
"+47"
,
"00000000"
,
new
Date
(),
"123"
)
.
get
();
image
=
imageService
.
createImage
(
user
,
new
File
(
"t14-test-images/3.jpg"
)).
get
();
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#mountains"
));
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#water"
));
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#nature"
));
imageAlbumService
.
createImageAlbum
(
"Third"
,
"Lorem Ipsum"
,
user
,
Arrays
.
asList
(
new
Tag
(
"#mountains"
),
new
Tag
(
"#water"
),
new
Tag
(
"#nature"
)),
Arrays
.
asList
(
image
));
image
=
imageService
.
createImage
(
user
,
new
File
(
"t14-test-images/9.jpg"
)).
get
();
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#art"
));
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#nature"
));
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#river"
));
imageAlbumService
.
createImageAlbum
(
"Ninth"
,
"Lorem Ipsum"
,
user
,
Arrays
.
asList
(
new
Tag
(
"#art"
),
new
Tag
(
"#nature"
),
new
Tag
(
"#river"
)),
Arrays
.
asList
(
image
));
user
=
userService
.
createUser
(
"Nicolaysen@mail.com"
,
"Nicolaysen"
,
"Nicolai"
,
"Sen"
,
"+47"
,
"00000000"
,
new
Date
(),
"123"
)
.
get
();
image
=
imageService
.
createImage
(
user
,
new
File
(
"t14-test-images/4.jpg"
)).
get
();
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#mountains"
));
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#grass"
));
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#nature"
));
imageAlbumService
.
createImageAlbum
(
"Fourth"
,
"Lorem Ipsum"
,
user
,
Arrays
.
asList
(
new
Tag
(
"#mountains"
),
new
Tag
(
"#grass"
),
new
Tag
(
"#nature"
)),
Arrays
.
asList
(
image
));
image
=
imageService
.
createImage
(
user
,
new
File
(
"t14-test-images/5.jpg"
)).
get
();
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#mountains"
));
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#water"
));
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#dock"
));
imageAlbumService
.
createImageAlbum
(
"Fifth"
,
"Lorem Ipsum"
,
user
,
Arrays
.
asList
(
new
Tag
(
"#mountains"
),
new
Tag
(
"#water"
),
new
Tag
(
"#dock"
)),
Arrays
.
asList
(
image
));
user
=
userService
.
createUser
(
"MaseMads@mail.com"
,
"MaseMads"
,
"Mase"
,
"Mads"
,
"+47"
,
"00000000"
,
new
Date
(),
"123"
)
.
get
();
image
=
imageService
.
createImage
(
user
,
new
File
(
"t14-test-images/6.jpg"
)).
get
();
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#mountains"
));
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#waterfall"
));
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#nature"
));
imageAlbumService
.
createImageAlbum
(
"Sixth"
,
"Lorem Ipsum"
,
user
,
Arrays
.
asList
(
new
Tag
(
"#mountains"
),
new
Tag
(
"#waterfall"
),
new
Tag
(
"#nature"
)),
Arrays
.
asList
(
image
));
user
=
userService
.
createUser
(
"JensenMannen@mail.com"
,
"JensenMannen"
,
"Jense"
,
"Mannen"
,
"+47"
,
"00000000"
,
new
Date
(),
"123"
)
.
get
();
image
=
imageService
.
createImage
(
user
,
new
File
(
"t14-test-images/8.jpg"
)).
get
();
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#winter"
));
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#nature"
));
imageService
.
addTagToImage
(
image
,
new
Tag
(
"#mountains"
));
imageAlbumService
.
createImageAlbum
(
"Eighth"
,
"Lorem Ipsum"
,
user
,
Arrays
.
asList
(
new
Tag
(
"#winter"
),
new
Tag
(
"#nature"
),
new
Tag
(
"#mountains"
)),
Arrays
.
asList
(
image
));
}
}
Loading