Skip to content
This repository
Browse code

Comments added to PersistenceImpl, User and Status

  • Loading branch information...
commit 2edaa31ed91fd01a9ec38afb6af2d4e4ba764d68 1 parent 0930886
authored May 15, 2012
44  TheatreProjectWeb/src/theatreProject/server/PersistenceImpl.java
@@ -63,8 +63,8 @@ public String getEmail(){
63 63
 	
64 64
 
65 65
 	@Override
66  
-	public InventoryObject getInventoryObject(String ID) {
67  
-		try{
  66
+	public InventoryObject getInventoryObject(String ID) {			//Returns the InventoryObject assosicated
  67
+		try{														//with a specific ID
68 68
 			return pm.getObjectById(InventoryObject.class, ID);
69 69
 		} catch(JDOObjectNotFoundException e){
70 70
 			return null;
@@ -77,11 +77,11 @@ public PersistenceImpl() {
77 77
 	}
78 78
 
79 79
 	@Override
80  
-	public void saveObject(InventoryObject object) {
  80
+	public void saveObject(InventoryObject object) {		//Takes an InventoryObject and makes persistence
81 81
 		pm.makePersistent(object);
82 82
 	}
83 83
 	
84  
-	public void deleteObject(InventoryObject object) {
  84
+	public void deleteObject(InventoryObject object) {		//Removes an InventoryObject from persistence
85 85
 		Transaction tx = pm.currentTransaction();
86 86
 		try {
87 87
 			tx.begin();
@@ -97,7 +97,7 @@ public void deleteObject(InventoryObject object) {
97 97
 		}
98 98
 	}
99 99
 	
100  
-	public void deleteUser(User user){
  100
+	public void deleteUser(User user){						//Removes an User from persistence
101 101
 		Transaction tx = pm.currentTransaction();
102 102
 		try {
103 103
 			tx.begin();
@@ -112,18 +112,18 @@ public void deleteUser(User user){
112 112
 			}
113 113
 		}	}
114 114
 	
115  
-	public List<InventoryObject> returnAll() {
116  
-		Query query = pm.newQuery(InventoryObject.class);
  115
+	public List<InventoryObject> returnAll() {				//Returns a List consisting of all InventoryObjects 
  116
+		Query query = pm.newQuery(InventoryObject.class);	//in persistence
117 117
 		return (List<InventoryObject>) query.execute();
118 118
 	}
119 119
 
120  
-	public ArrayList<User> returnAllUser(){
121  
-		Query query = pm.newQuery(User.class);
  120
+	public ArrayList<User> returnAllUser(){					//Returns a List consisting of all Users
  121
+		Query query = pm.newQuery(User.class);				//in persistence
122 122
 		return (ArrayList<User>) query.execute();
123 123
 	}
124 124
 	
125  
-	public String getUserInfoByName(String name){
126  
-		User theUser = null;
  125
+	public String getUserInfoByName(String name){			//Returns the ExtraInfo of an User associated with 
  126
+		User theUser = null;								//a specific User name
127 127
 		ArrayList<User> allUsers = this.returnAllUser();
128 128
 		for (User user: allUsers){
129 129
 			if (user.getName() == name){
@@ -134,13 +134,13 @@ public String getUserInfoByName(String name){
134 134
 		return null;
135 135
 	}
136 136
 	
137  
-	public ArrayList<InventoryObject> search(String parameter) {
138  
-
139  
-		ArrayList<InventoryObject> found = new ArrayList<InventoryObject>(); 
140  
-		String[] words = parameter.split(" ");
141  
-		List<InventoryObject> database = returnAll();
142  
-		for (InventoryObject obj : database) {
143  
-			if (obj.description.indexOf(words[0])!=-1) {
  137
+	public ArrayList<InventoryObject> search(String parameter) {	
  138
+																																					
  139
+		ArrayList<InventoryObject> found = new ArrayList<InventoryObject>();	//Search function - Returns an ArrayList of 
  140
+		String[] words = parameter.split(" ");									//found InventoryObjects.
  141
+		List<InventoryObject> database = returnAll();							//InventoryObject considered "found" if
  142
+		for (InventoryObject obj : database) {									//if all the in parameter can be found in the
  143
+			if (obj.description.indexOf(words[0])!=-1) {						//the description of the object	
144 144
 				found.add(obj);
145 145
 			}
146 146
 		}
@@ -156,10 +156,10 @@ public String getUserInfoByName(String name){
156 156
 		return found;
157 157
 	}
158 158
 
159  
-	public ArrayList<InventoryObject> checkOutList() {
160  
-		ArrayList<InventoryObject> outObjects = new ArrayList<InventoryObject>();
161  
-		List<InventoryObject> database = returnAll();
162  
-		for (InventoryObject obj : database) {
  159
+	public ArrayList<InventoryObject> checkOutList() {								//Returns an ArryaList of all InventoryObjects
  160
+		ArrayList<InventoryObject> outObjects = new ArrayList<InventoryObject>();	//currently checked out
  161
+		List<InventoryObject> database = returnAll();								//If location variable in the InventoryObject's
  162
+		for (InventoryObject obj : database) {										//is not "warehouse" then object is checked out
163 163
 			String place = obj.getStatus().getLocation();
164 164
 			if (!place.equals("warehouse")) outObjects.add(obj);
165 165
 		}
8  TheatreProjectWeb/src/theatreProject/shared/Status.java
@@ -3,7 +3,11 @@
3 3
 
4 4
 import theatreProject.shared.InventoryObject;
5 5
 
6  
-
  6
+	/*
  7
+		Status is an object that contains all the infomation and methods pertaining to the status
  8
+		of an inventoryObject.
  9
+	*/
  10
+	
7 11
 public class Status implements Serializable {
8 12
 	
9 13
 	private String renter;
@@ -50,7 +54,7 @@ public void setReturnDate(String returnDate) {
50 54
 	}
51 55
 	
52 56
 	@Override
53  
-	public boolean equals(Object o){
  57
+	public boolean equals(Object o){				//Check if an instance of Status is equal to another object
54 58
 		if(!(o instanceof Status))
55 59
 			return false;
56 60
 		Status other = (Status) o;
6  TheatreProjectWeb/src/theatreProject/shared/User.java
@@ -7,6 +7,10 @@
7 7
 import javax.jdo.annotations.Persistent;
8 8
 import javax.jdo.annotations.PrimaryKey;
9 9
 
  10
+/*
  11
+		User class is an object that holds all the infomation needed to characterize someone who is
  12
+		logged in to our system.
  13
+*/
10 14
 
11 15
 @PersistenceCapable(identityType=IdentityType.APPLICATION)
12 16
 public class User implements Serializable{
@@ -65,7 +69,7 @@ public void setExtraInfo(String extraInfo) {
65 69
 	}
66 70
 
67 71
 	@Override
68  
-	public boolean equals(Object o){
  72
+	public boolean equals(Object o){				//Check if an instance of User is equal to another object
69 73
 		if(!(o instanceof User))
70 74
 			return false;
71 75
 		User other = (User) o;

0 notes on commit 2edaa31

Please sign in to comment.
Something went wrong with that request. Please try again.