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
Commits
ef37d75c
Commit
ef37d75c
authored
5 years ago
by
Stian Fjæran Mogen
Browse files
Options
Downloads
Patches
Plain Diff
updated album removed imagealbum
added the changes in previous imagealbum to album, now up to date with dev
parent
fa0864df
No related branches found
No related tags found
1 merge request
!92
Namedquery search
Pipeline
#78527
passed
5 years ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/NTNU/IDATT1002/models/Album.java
+7
-1
7 additions, 1 deletion
src/main/java/NTNU/IDATT1002/models/Album.java
src/main/java/NTNU/IDATT1002/models/ImageAlbum.java
+0
-180
0 additions, 180 deletions
src/main/java/NTNU/IDATT1002/models/ImageAlbum.java
with
7 additions
and
181 deletions
src/main/java/NTNU/IDATT1002/models/Album.java
+
7
−
1
View file @
ef37d75c
...
...
@@ -22,7 +22,13 @@ import java.util.stream.Collectors;
@Table
(
name
=
"album"
)
@NamedQueries
({
@NamedQuery
(
name
=
"Album.findAllByUsername"
,
query
=
"SELECT ia from Album ia WHERE ia.user.username = :username"
)
query
=
"SELECT ia from Album ia WHERE ia.user.username = :username"
),
@NamedQuery
(
name
=
"Album.findByTags"
,
query
=
"SELECT ia from Album ia "
+
"join ia.tags tg "
+
"where tg.name = :name"
),
@NamedQuery
(
name
=
"Image.findByTitle"
,
query
=
"SELECT ia from Album ia WHERE ia.title = :title"
)
})
public
class
Album
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/NTNU/IDATT1002/models/ImageAlbum.java
deleted
100644 → 0
+
0
−
180
View file @
fa0864df
package
NTNU.IDATT1002.models
;
import
org.hibernate.annotations.CreationTimestamp
;
import
org.hibernate.annotations.UpdateTimestamp
;
import
javax.persistence.*
;
import
javax.validation.constraints.NotBlank
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Objects
;
/**
* Class ImageAlbum representing an image album. Contains {@link Image}s and the creator ({@link User})
*
* @author Eirik Steira
* @version 1.1 19.03.20
* */
@Entity
@Table
(
name
=
"image_album"
)
@NamedQueries
({
@NamedQuery
(
name
=
"ImageAlbum.findAllByUsername"
,
query
=
"SELECT ia from ImageAlbum ia WHERE ia.user.username = :username"
),
@NamedQuery
(
name
=
"ImageAlbum.findByTags"
,
query
=
"SELECT ia from ImageAlbum ia "
+
"join ia.tags tg "
+
"where tg.name = :name"
),
@NamedQuery
(
name
=
"Image.findByTitle"
,
query
=
"SELECT ia from ImageAlbum ia WHERE ia.title = :title"
)
})
public
class
ImageAlbum
{
@Id
@GeneratedValue
private
Long
id
;
@NotBlank
(
message
=
"Title may not be blank"
)
private
String
title
;
@ManyToOne
(
fetch
=
FetchType
.
LAZY
)
private
User
user
;
@ManyToMany
(
fetch
=
FetchType
.
LAZY
)
private
List
<
Image
>
images
=
new
ArrayList
<>();;
@ManyToMany
(
fetch
=
FetchType
.
LAZY
)
private
List
<
Tag
>
tags
=
new
ArrayList
<>();;
private
String
description
;
@CreationTimestamp
private
Date
createdAt
;
@UpdateTimestamp
private
Date
updatedAt
;
public
ImageAlbum
()
{
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
Long
getId
()
{
return
id
;
}
public
String
getTitle
()
{
return
title
;
}
public
User
getUser
()
{
return
user
;
}
public
List
<
Image
>
getImages
()
{
return
images
;
}
public
String
getDescription
()
{
return
description
;
}
public
Date
getCreatedAt
()
{
return
createdAt
;
}
public
Date
getUpdatedAt
()
{
return
updatedAt
;
}
public
List
<
Tag
>
getTags
()
{
return
tags
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
void
setUser
(
User
user
)
{
this
.
user
=
user
;
}
public
void
setTags
(
List
<
Tag
>
tags
)
{
this
.
tags
=
tags
;
}
public
void
setImages
(
List
<
Image
>
images
)
{
this
.
images
=
images
;
}
public
void
setCreatedAt
(
Date
createdAt
)
{
this
.
createdAt
=
createdAt
;
}
/**
* Add given image to this album.
*
* @param image the image to add
*/
public
void
addImage
(
Image
image
)
{
image
.
addImageAlbum
(
this
);
images
.
add
(
image
);
}
/**
* Remove given image from the album.
*
* @param image the image to add
*/
public
void
removeImage
(
Image
image
)
{
image
.
removeImageAlbum
(
this
);
images
.
remove
(
image
);
}
/**
* Add given tag to this album
*
* @param tag the tag to add
*/
public
void
addTag
(
Tag
tag
)
{
tags
.
add
(
tag
);
}
/**
* Remove given tag to this album
*
* @param tag the tag to add
*/
public
void
removeTag
(
Tag
tag
)
{
tags
.
remove
(
tag
);
}
/**
* Check if this and given entity are equal.
* The two are defined as equal if all individual fields are equal.
*
* @param o object to check for equality against
* @return true if this is equal to given object, else false
*/
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
ImageAlbum
that
=
(
ImageAlbum
)
o
;
return
id
.
equals
(
that
.
id
)
&&
title
.
equals
(
that
.
title
)
&&
user
.
equals
(
that
.
user
)
&&
Objects
.
equals
(
images
,
that
.
images
)
&&
Objects
.
equals
(
description
,
that
.
description
)
&&
createdAt
.
equals
(
that
.
createdAt
)
&&
updatedAt
.
equals
(
that
.
updatedAt
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment