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
77475a5f
Commit
77475a5f
authored
5 years ago
by
Lars Brodin Østby
Browse files
Options
Downloads
Patches
Plain Diff
Add Image repository
parent
3dc57c47
No related branches found
Branches containing commit
No related tags found
2 merge requests
!30
Weekly merge to master
,
!24
Image repository
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/NTNU/IDATT1002/repository/ImageRepository.java
+59
-0
59 additions, 0 deletions
src/main/java/NTNU/IDATT1002/repository/ImageRepository.java
with
59 additions
and
0 deletions
src/main/java/NTNU/IDATT1002/repository/ImageRepository.java
0 → 100644
+
59
−
0
View file @
77475a5f
package
NTNU.IDATT1002.repository
;
import
java.awt.Image
;
import
java.util.Optional
;
import
javax.persistence.EntityManager
;
import
java.util.List
;
public
class
ImageRepository
implements
Repository
<
Image
,
Long
>
{
private
EntityManager
entityManager
;
public
Optional
<
Image
>
save
(
Image
image
){
try
{
persist
(
image
);
return
Optional
.
of
(
image
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
return
Optional
.
empty
();
}
private
void
persist
(
Image
image
){
entityManager
.
getTransaction
().
begin
();
entityManager
.
persist
(
image
);
entityManager
.
getTransaction
().
commit
();
}
public
Optional
<
Image
>
update
(
Image
image
){
return
Optional
.
empty
();
}
public
List
<
Image
>
findAll
(){
return
entityManager
.
createQuery
(
"from Image"
).
getResultList
();
}
public
Optional
<
Image
>
findById
(
Long
id
){
Image
image
=
entityManager
.
find
(
Image
.
class
,
id
);
return
image
!=
null
?
Optional
.
of
(
image
)
:
Optional
.
empty
();
}
public
void
delete
(
Image
entity
){
}
public
void
deleteById
(
Long
aLong
){
}
public
long
count
(){
return
0
;
}
@Override
public
boolean
exists
(
Image
entity
)
{
return
false
;
}
}
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