id
stringlengths
36
36
text
stringlengths
1
1.25M
0041cf6f-54e2-4e6c-b11f-ccf0227215a7
public String getEsrbRating() { return this.esrbRating; }
871ba284-5939-4482-85c8-6aef897b8367
public void setEsrbRating(String esrbRating) { this.esrbRating = esrbRating; }
000f269e-fe78-4669-a384-e3e309cd5e6e
public String getGenre() { return this.genre; }
0fce8932-7fc2-4715-aae8-04965ddadb5e
public void setGenre(String genre) { this.genre = genre; }
9603e2cf-eb6b-44a3-876a-c9f47b7891d3
public String getImageUrl() { return this.imageUrl; }
e1a6bf97-0ee8-4c87-81e2-66cb2ca6044c
public void setImageUrl(String imageUrl) { this.imageUrl = imageUrl; }
8171908d-afb3-4c34-8abf-2b8bbb9b0f99
public boolean getIsOut() { return this.isOut; }
430d34d9-ad5f-43f9-8293-47e10acffc27
public void setIsOut(boolean isOut) { this.isOut = isOut; }
40899567-6494-4522-babc-5c9cc3021ef3
public String getMpaaRating() { return this.mpaaRating; }
b77a8136-5566-4034-91a2-4820660212ee
public void setMpaaRating(String mpaaRating) { this.mpaaRating = mpaaRating; }
abe81aa7-3fcc-4c5d-9cb2-396a208ce249
public String getPlatform() { return this.platform; }
3be17200-d7fd-494c-883c-cba9719ca4b8
public void setPlatform(String platform) { this.platform = platform; }
248aa0af-de58-47fb-95d7-3aaadfbb84c2
public int getReferenceNumber() { return this.referenceNumber; }
f9ca0127-a949-4f19-905b-c990ccb1803e
public void setReferenceNumber(int referenceNumber) { this.referenceNumber = referenceNumber; }
87767de2-4d56-4d6e-8adc-fd90d073fcef
public int getReleaseYear() { return this.releaseYear; }
0c1e9a5b-79c5-41c1-a02b-00a7ac61a014
public void setReleaseYear(int releaseYear) { this.releaseYear = releaseYear; }
5f7198f3-75b3-4ee8-ab1e-c535b0e991c8
public String getSynopsis() { return this.synopsis; }
6f62fac7-de39-4c98-a569-da2c7b7618a2
public void setSynopsis(String synopsis) { this.synopsis = synopsis; }
204709de-921d-4614-a0be-de70902d8892
public String getTitle() { return this.title; }
3288b0df-3eca-4dbf-b3cf-cd1b2b1bb7b9
public void setTitle(String title) { this.title = title; }
16de0ec8-475f-45b1-93a3-393f346ba9f2
public String getTrailerUrl() { return this.trailerUrl; }
cc80424d-7024-4274-8aa6-82c73ee67bbb
public void setTrailerUrl(String trailerUrl) { this.trailerUrl = trailerUrl; }
f330d990-0365-4461-b826-36c3339d203e
public String getType() { return this.type; }
5f78486c-81d9-4c02-9580-3a16961e4c79
public void setType(String type) { this.type = type; }
15373a10-8ff6-449e-aa2c-e2c16051f4bc
public int getUserRating() { return this.userRating; }
cf572dd6-b53f-44d4-8a11-35f3b650ef4d
public void setUserRating(int userRating) { this.userRating = userRating; }
29a7d6fa-06fb-4a2b-928f-9ae3f6830711
public Set<BundleEntity> getBundleEntities() { return this.bundleEntities; }
206729ad-ec94-4e42-824a-ec2cfd48b5cf
public void setBundleEntities(Set<BundleEntity> bundleEntities) { this.bundleEntities = bundleEntities; }
20fc7e9b-713e-43f6-a9d2-29734c60a90e
public BundleEntity() { }
aadaa156-6907-4c6d-b2d5-286f432a7000
public BundleEntityPK getId() { return this.id; }
214f43db-05c2-4c25-b323-9e7b3d4d6fc8
public void setId(BundleEntityPK id) { this.id = id; }
7dd690fd-d2d5-4d61-ba3c-b0c8f392c15c
public Date getReturnedDate() { return this.returnedDate; }
2f212581-21e2-4283-aa21-d50f8a3c18a6
public void setReturnedDate(Date returnedDate) { this.returnedDate = returnedDate; }
09101069-34c0-4260-9d7d-be3fbda7989b
public int getUserRating() { return this.userRating; }
4e9488a5-248d-45ea-96e8-f91b38193720
public void setUserRating(int userRating) { this.userRating = userRating; }
726fc7e2-af55-4b87-a9a0-039d680ece8f
public ItemEntity getItemEntity() { return this.itemEntity; }
9d753452-44f5-4f74-a0c5-b978292a7f7c
public void setItemEntity(ItemEntity itemEntity) { this.itemEntity = itemEntity; }
0105cab0-43f4-43aa-8f36-1e07ae80c5e6
public UserEntity getUserEntity() { return this.userEntity; }
1916ed1b-6085-4237-958a-c24b88d924da
public void setUserEntity(UserEntity userEntity) { this.userEntity = userEntity; }
50b17b7e-edd9-4c89-89e0-0260f4fb8c12
public UserController(){ if(em == null){ em = (EntityManager) Persistence.createEntityManagerFactory("g5.ambience").createEntityManager(); } setUser(new UserEntity()); }
9bf2b1a8-7b7f-45a5-9403-2099f197d09d
private UserEntity getUserByUsernameAndPassword(String username, String password){ try{ UserEntity user = em.find(UserEntity.class, username); String hash = Auth.hash_password(password); if(user.getPasswordHash().equals(hash)){ //em.flush(); return user; } } catch (Exception e) { e.printStackTrace(); } finally { } return null; }
f8ff862b-2ffe-40b0-a4fd-cead87a6cfb7
private void createUser(String username, String password, String email, String firstName, String lastName, String role){ try { String hash = null; hash = Auth.hash_password(password); UserEntity user = new UserEntity(username, hash, email, firstName, lastName, role); em.getTransaction().begin(); em.persist(user); em.getTransaction().commit(); } catch (Exception e) { e.printStackTrace(); } finally { //blank } }
8da1a664-e4f2-498a-b893-42f7e81706fc
private void updateUser(String username, String password, String email, String firstName, String lastName, String role){ try { String hash = null; hash = Auth.hash_password(password); UserEntity user = new UserEntity(username, hash, email, firstName, lastName, role); em.getTransaction().begin(); em.merge(user); em.flush(); em.getTransaction().commit(); } catch (Exception e) { e.printStackTrace(); } finally { //blank } }
640c63f2-f93e-4eac-af9b-a873ecb30246
public String registerUser(){ createUser(this.getUsername(), this.getPassword(), this.getEmail(), this.getFirstName(), this.getLastName(), "member"); return "profile"; }
7df8f78c-ed8d-461e-a097-5b19a525a0c3
public String update(){ updateUser(this.getUsername(), this.getPassword(), this.getEmail(), this.getFirstName(), this.getLastName(), "member"); return "profile"; }
9612b776-8f08-4c96-ad19-c30ecf1ef224
public String login(){ try{ if(getUserByUsernameAndPassword(this.getUsername(), this.getPassword()) != null){ user = getUserByUsernameAndPassword(this.username, this.password); setLoggedIn(true); if(getUserByUsernameAndPassword(this.getUsername(), this.getPassword()).getRole().equals("admin")){ setDashOrProfile("dashboard"); return "dashboard"; } else if(getUserByUsernameAndPassword(this.getUsername(), this.getPassword()).getRole().equals("member")) { setDashOrProfile("profile"); return "profile"; } } else { // Actually this goes off if the username is correct, but the password is not. // The message is the same for security reasons. message("Invalid credentials!", "login_btn"); } } catch(NullPointerException e) { message("Invalid credentials!", "login_btn"); System.err.println(e.getMessage()); } return null; }
7a32d014-bd48-4e1e-8ab8-619cbad2ce6b
public String logout(){ if(isLoggedIn){ FacesContext.getCurrentInstance().getExternalContext().invalidateSession(); } return "index"; }
26b8743d-4f71-40e6-b4e7-9093924ba41c
public void addItemToBundle(ItemEntity item){ System.out.println(item.getTitle()); try { em.getTransaction().begin(); UserEntity user = em.find(UserEntity.class, this.username); BundleEntity bundle = new BundleEntity(); BundleEntityPK compositePk = new BundleEntityPK(); compositePk.setCheckedOutDate(new Date()); compositePk.setItemId(item.getItemId()); compositePk.setUsername(user.getUsername()); bundle.setId(compositePk); Set<BundleEntity> bundles = new HashSet<BundleEntity>(); bundles.add(bundle); user.setBundleEntities(bundles); em.persist(bundle); em.persist(user); em.flush(); em.getTransaction().commit(); } finally { } }
a07523b8-f349-4944-ba36-f07cd186d503
public String addToBundle(){ try { addItemToBundle(item); } catch (NullPointerException e) { System.err.println(e.getMessage()); } return null; }
b6f06ff4-0335-4913-bed0-1c40d17fa965
public List<ItemEntity> findUsersBundleItems(String username){ TypedQuery<ItemEntity> query = em.createQuery("SELECT i FROM UserEntity o, BundleEntity x, ItemEntity i WHERE o.username = :username AND x.userEntity = o AND x.itemEntity = i", ItemEntity.class); query.setParameter("username", username); return query.getResultList(); }
57e675c2-2e14-45ce-839b-9949ab430113
public ItemEntity getItemFromBundle(BundleEntity bundle){ item = bundle.getItemEntity(); return item; }
56bb3274-adb1-45ee-8af4-55fa64bfcf6f
public List<UserEntity> findAllMembers(int limit){ TypedQuery<UserEntity> query; if(limit > 0){ query = em.createQuery("SELECT m FROM UserEntity m WHERE m.role = 'member'", UserEntity.class); query.setMaxResults(limit); } else { query = em.createQuery("SELECT m FROM UserEntity m WHERE m.role = 'member'", UserEntity.class); } return query.getResultList(); }
9a8e4ca4-1fa7-4728-98bf-5ee25b4d75ba
public void message(String message, String id){ FacesContext facesContext = FacesContext.getCurrentInstance(); Flash flash = facesContext.getExternalContext().getFlash(); flash.setKeepMessages(false); FacesMessage facesMessage = new FacesMessage(message); facesContext.addMessage(id, facesMessage); }
57290d32-766b-4e7c-9008-9b74610d7450
public String profile(){ return "profile"; }
3227488a-d169-496c-8e82-d0434df9b845
public boolean isLoggedIn() { return isLoggedIn; }
bd7042a1-6cae-4467-89a6-91e3b984563d
public void setLoggedIn(boolean isLoggedIn) { this.isLoggedIn = isLoggedIn; }
2202827d-fd8f-4497-b544-fd1c943fac5e
public ItemEntity getItem() { return item; }
180a810d-fcd4-4ec3-9a96-2eff56b9c03e
public void setItem(ItemEntity item) { this.item = item; }
0e3c5199-577e-47a2-ac47-84bada0ebdd6
public String getPassword() { return password; }
e3450d59-5e9a-4bef-a3e3-734248797f23
public void setPassword(String password) { this.password = password; }
80a2253f-650e-47c9-8d22-e0de420837bb
public String getUsername() { return username; }
2900f506-8e05-476f-a2f1-1fa62272cfb5
public void setUsername(String username) { this.username = username; }
75407512-f786-4aca-bab2-8e7c8c32bed0
public String getFirstName() { return firstName; }
774252c2-0bb0-41b1-9556-c0304abdb61b
public void setFirstName(String firstName) { this.firstName = firstName; }
7c7b9538-b828-4ccf-9af8-428a744bb6be
public String getLastName() { return lastName; }
a37be702-473d-4e99-9138-6c9801e1b8b9
public void setLastName(String lastName) { this.lastName = lastName; }
275eb157-8b90-46a6-af5e-b08871483606
public String getEmail() { return email; }
c20e5cdb-6c41-4169-a3cf-fd04ec61f15b
public void setEmail(String email) { this.email = email; }
5d9d7208-bbd0-4d08-a941-29cbe359a293
public UserEntity getUser() { return user; }
221b2632-551c-47e2-b9be-78a55f9d5525
public void setUser(UserEntity user) { this.user = user; }
c865ebfc-3894-48ff-9c6c-dba477e9e07f
public String getLoginLogout() { return loginLogout; }
bb157f2f-26e7-469d-9a6b-a041fc621f8c
public void setLoginLogout(String loginLogout) { this.loginLogout = loginLogout; }
9e914cb3-f95a-48d6-bfcf-78d80c1381e6
public List<UserEntity> getMembers() { return members = findAllMembers(0); }
8317130b-4ae8-4fd2-8f92-5d825e558579
public void setMembers(List<UserEntity> members) { this.members = members; }
040a780f-b6c4-4891-b97c-ec49cfc9d153
public String getDashOrProfile() { return dashOrProfile; }
a307a7ca-6bcf-448b-9612-fa6ff606ed3e
public void setDashOrProfile(String dashOrProfile) { this.dashOrProfile = dashOrProfile; }
8b171d8d-a873-4b1d-8957-c260d2803732
public List<ItemEntity> getBundleItems() { return bundleItems = findUsersBundleItems(username); }
249b3fba-2d05-46df-935b-194e3de66e72
public void setBundleItems(List<ItemEntity> bundleItems) { this.bundleItems = bundleItems; }
388e8774-43af-4b8f-b3dc-728c45254c60
public ItemController(){ if(em == null){ em = (EntityManager) Persistence.createEntityManagerFactory("g5.ambience").createEntityManager(); } }
a44017e7-7eed-48bc-b0e6-e695ec4a8e9e
private void createMovie(int itemId, String title, int releaseYear, String type, String platform, String genre, boolean isOut, int userRating, int referenceNumber, String director, String trailerUrl, String synopsis, String imageUrl, String mpaaRating){ try { String esrbRating = "N/A"; String developer = "N/A"; ItemEntity item = new ItemEntity(itemId, title, releaseYear, type, platform, genre, isOut, userRating, esrbRating, referenceNumber, director, trailerUrl, synopsis, imageUrl, developer, mpaaRating); em.getTransaction().begin(); em.persist(item); em.getTransaction().commit(); } catch (Exception e) { System.err.println(e.getMessage()); } finally { //blank } }
f7df79cf-a06a-48df-a4bb-4b74c7dce252
private void createGame(int itemId, String title, int releaseYear, String type, String platform, String genre, boolean isOut, int userRating, String esrbRating, int referenceNumber, String trailerUrl, String synopsis, String imageUrl, String developer){ try { String mpaaRating = "N/A"; String director = "N/A"; ItemEntity item = new ItemEntity(itemId, title, releaseYear, type, platform, genre, isOut, userRating, esrbRating, referenceNumber, director, trailerUrl, synopsis, imageUrl, developer, mpaaRating); em.getTransaction().begin(); em.persist(item); em.getTransaction().commit(); } catch (Exception e) { System.err.println(e.getMessage()); } finally { //blank } }
5ec6e3e7-2ba9-4744-a108-91d84aedd216
public void deleteItem(int itemId) { try { ItemEntity item = em.find(ItemEntity.class, itemId); em.getTransaction().begin(); em.remove(item); em.getTransaction().commit(); } catch (Exception e) { System.err.println(e.getMessage()); } finally { } }
9fada5df-75f8-44c8-a7f3-df970f5f1434
public void updateItem(int itemId, String title, int releaseYear, String type, String platform, String genre, boolean isOut, int userRating, String esrbRating, int referenceNumber, String director, String trailerUrl, String synopsis, String imageUrl, String developer, String mpaaRating) { try { ItemEntity item = em.find(ItemEntity.class, itemId); em.getTransaction().begin(); em.merge(item); em.getTransaction().commit(); } catch (Exception e) { System.err.println(e.getMessage()); } finally { } }
f85bca23-0cb4-46c9-84a2-2ffb11a84cba
public List<ItemEntity> searchItem(int itemId) { try { TypedQuery<ItemEntity> query = em.createQuery("SELECT o FROM ItemEntity o WHERE o.itemId = :itemId", ItemEntity.class); query.setParameter("itemId", itemId); return (List<ItemEntity>)query.getResultList(); } catch (Exception e) { System.err.println(e.getMessage()); } finally { } return null; }
48deba02-8655-47d3-a181-27acf6228c0b
public List<ItemEntity> searchItem(String title) { try { TypedQuery<ItemEntity> query = em.createQuery("SELECT o FROM ItemEntity o WHERE o.title = :title", ItemEntity.class); query.setParameter("title", title); return (List<ItemEntity>)query.getResultList(); } catch (Exception e) { System.err.println(e.getMessage()); } finally { } return null; }
3fe92236-428b-4f99-a05c-df068d062b96
public List<ItemEntity> findAllItems() { TypedQuery<ItemEntity> query = em.createQuery("SELECT o FROM ItemEntity o", ItemEntity.class); return (List<ItemEntity>)query.getResultList(); }
8d8174f5-f213-4ccd-ad6a-639ad7cb6db1
public List<ItemEntity> findItemsWithRatingGreaterThan(int value) { TypedQuery<ItemEntity> query = em.createQuery("SELECT o FROM ItemEntity o WHERE o.userRating > :value", ItemEntity.class); query.setParameter("value", value); return (List<ItemEntity>)query.getResultList(); }
1f25cbc1-1cae-4bd8-a7d7-7f2eb4be2deb
public List<ItemEntity> findAllItems(String type) { TypedQuery<ItemEntity> query = em.createQuery("SELECT o FROM ItemEntity o WHERE o.type = :type", ItemEntity.class); query.setParameter("type", type); return (List<ItemEntity>)query.getResultList(); }
6d444a3e-fc67-4384-a8bf-c6014952a044
public List<ItemEntity> findUniqueItemsByType(String type, int numItems){ TypedQuery<ItemEntity> query = em.createQuery("SELECT o FROM ItemEntity o WHERE o.type = :type", ItemEntity.class); if(numItems > 0){ query.setParameter("type", type).setMaxResults(numItems); } else { query.setParameter("type", type); } return (List<ItemEntity>)query.getResultList(); }
e1150e52-d181-49b6-9460-be707cf571ab
public String item(){ return "item"; }
c55de3aa-4fb0-4760-b57d-3e128c35e3a1
public int getItemId() { return itemId; }
d19d48e2-b643-4637-ba3d-ca42ac3cd09e
public void setItemId(int itemId) { this.itemId = itemId; }
a102e59d-bc14-454e-b535-e6c8be46d211
public String getDeveloper() { return developer; }
710728d9-c018-4046-bda2-405fe9ecfff4
public void setDeveloper(String developer) { this.developer = developer; }
8e9ac7b4-e3f2-4b9d-b0f8-5c2200a599ef
public String getDirector() { return director; }
ebd6fc62-5606-4387-851e-10ad233604e5
public void setDirector(String director) { this.director = director; }
3ca6c8f0-c6af-4a97-9ada-860749589a34
public String getEsrbRating() { return esrbRating; }
b152172a-8646-4fdd-96e2-ce2561658664
public void setEsrbRating(String esrbRating) { this.esrbRating = esrbRating; }
1ac29e60-454b-40ef-b11d-ba01006bd7d1
public String getGenre() { return genre; }
ffdeb0b4-ced5-413f-8b28-0d0a520505fd
public void setGenre(String genre) { this.genre = genre; }