Package gruppe2.imagingapplication
Class ContentManager
- java.lang.Object
-
- gruppe2.imagingapplication.ContentManager
-
public class ContentManager extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private javax.persistence.EntityManagerFactory
entityManagerFactory
private java.util.Map<java.lang.String,ImageData>
images
A local HashMap for storing the ImageData class locally(package private) org.slf4j.Logger
logger
private java.util.Map<java.lang.String,ImageData>
searchResults
-
Constructor Summary
Constructors Constructor Description ContentManager()
Constructs a new content manager object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addImageToDB(java.lang.String absolutePath, java.util.List<java.lang.String> tags, java.lang.String name)
Method for adding images to the DB with it's path.void
editDatabaseFilename(java.lang.String absolutePath, java.lang.String name)
Method for editing an existing image.void
editDatabaseTags(java.lang.String absolutePath, java.util.List<java.lang.String> tags)
Method for editing the tags of an existing image.java.util.Map<java.lang.String,ImageData>
fullSearch(java.lang.String searchTerm)
Method that combines tagSearch and imageNameSearch and searches for both.java.util.Map<java.lang.String,ImageData>
getImages()
Returns the images field.java.util.Map<java.lang.String,ImageData>
getSearchResults()
Returns the search result.private java.util.Map<java.lang.String,ImageData>
imageNameSearch(java.lang.String searchTerm)
Method that searches by image names and returns a hashmap with all matches.private java.util.Map<java.lang.String,ImageData>
metadataSearch(java.lang.String searchTerm)
Method that searches by image names and returns a Map with all matches.void
performSearch(java.lang.String searchTerm)
Takes a search term and performs a search.void
readFromDB()
This method reads the image data from the database, and puts them in the images HashMap.void
removeImage(java.lang.String path)
Removes an image from images by using the image path.private java.util.Map<java.lang.String,ImageData>
tagSearch(java.lang.String searchTerm)
Method that searches by tags and returns a hashmap with all matches.
-
-
-
Field Detail
-
entityManagerFactory
private javax.persistence.EntityManagerFactory entityManagerFactory
-
logger
org.slf4j.Logger logger
-
images
private java.util.Map<java.lang.String,ImageData> images
A local HashMap for storing the ImageData class locally
-
searchResults
private java.util.Map<java.lang.String,ImageData> searchResults
-
-
Method Detail
-
readFromDB
public void readFromDB()
This method reads the image data from the database, and puts them in the images HashMap.
-
getImages
public java.util.Map<java.lang.String,ImageData> getImages()
Returns the images field.- Returns:
- Returns it as HashMap<>
-
addImageToDB
public void addImageToDB(java.lang.String absolutePath, java.util.List<java.lang.String> tags, java.lang.String name)
Method for adding images to the DB with it's path.- Parameters:
absolutePath
- The absolute path of the image to addtags
- User-defined tags to describe image, set null for no tags
-
editDatabaseFilename
public void editDatabaseFilename(java.lang.String absolutePath, java.lang.String name)
Method for editing an existing image.- Parameters:
absolutePath
- The absolute path of the image you want to editname
- The new filename
-
editDatabaseTags
public void editDatabaseTags(java.lang.String absolutePath, java.util.List<java.lang.String> tags)
Method for editing the tags of an existing image.- Parameters:
absolutePath
- The absolute path of the image you want to edittags
- A list of the new tags
-
removeImage
public void removeImage(java.lang.String path)
Removes an image from images by using the image path.- Parameters:
path
- The path of the image as a String
-
fullSearch
public java.util.Map<java.lang.String,ImageData> fullSearch(java.lang.String searchTerm)
Method that combines tagSearch and imageNameSearch and searches for both.- Parameters:
searchTerm
- String to search for- Returns:
- Matching results in a HashMap
-
tagSearch
private java.util.Map<java.lang.String,ImageData> tagSearch(java.lang.String searchTerm)
Method that searches by tags and returns a hashmap with all matches.- Parameters:
searchTerm
- String to search for- Returns:
- Matching results in a HashMap
-
imageNameSearch
private java.util.Map<java.lang.String,ImageData> imageNameSearch(java.lang.String searchTerm)
Method that searches by image names and returns a hashmap with all matches.- Parameters:
searchTerm
- String to search for- Returns:
- Matching results in a HashMap
-
metadataSearch
private java.util.Map<java.lang.String,ImageData> metadataSearch(java.lang.String searchTerm)
Method that searches by image names and returns a Map with all matches.- Parameters:
searchTerm
- String to search for- Returns:
- Matching results in a Map
-
performSearch
public void performSearch(java.lang.String searchTerm)
Takes a search term and performs a search.- Parameters:
searchTerm
- Takes a search term as String
-
getSearchResults
public java.util.Map<java.lang.String,ImageData> getSearchResults()
Returns the search result.- Returns:
- Returns the result as HashMap<>
-
-