struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [05/10] struts-examples git commit: Added comments and general code cleanup
Date Fri, 07 Jul 2017 05:34:05 GMT
Added comments and general code cleanup

Project: http://git-wip-us.apache.org/repos/asf/struts-examples/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts-examples/commit/192b912a
Tree: http://git-wip-us.apache.org/repos/asf/struts-examples/tree/192b912a
Diff: http://git-wip-us.apache.org/repos/asf/struts-examples/diff/192b912a

Branch: refs/heads/master
Commit: 192b912a89a11e63c39fd98ad9b473be98c34ddf
Parents: c436897
Author: phillips1021 <phillips1021@hotmail.com>
Authored: Fri Apr 18 15:11:18 2014 -0500
Committer: phillips1021 <phillips1021@hotmail.com>
Committed: Fri Apr 18 15:11:18 2014 -0500

----------------------------------------------------------------------
 .../apache/struts/crud/action/PersonAction.java | 31 ++++++++++++++------
 .../apache/struts/crud/dao/MemoryPersonDao.java |  6 ++--
 .../struts/crud/dao/MemoryPersonSupportDao.java | 15 ++++------
 .../org/apache/struts/crud/dao/PersonDao.java   |  3 ++
 .../struts/crud/dao/PersonSupportDao.java       |  4 +--
 .../org/apache/struts/crud/model/Country.java   |  2 +-
 .../struts/crud/service/PersonService.java      |  5 ++++
 7 files changed, 42 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts-examples/blob/192b912a/crud/src/main/java/org/apache/struts/crud/action/PersonAction.java
----------------------------------------------------------------------
diff --git a/crud/src/main/java/org/apache/struts/crud/action/PersonAction.java b/crud/src/main/java/org/apache/struts/crud/action/PersonAction.java
index d3fa555..6096be8 100755
--- a/crud/src/main/java/org/apache/struts/crud/action/PersonAction.java
+++ b/crud/src/main/java/org/apache/struts/crud/action/PersonAction.java
@@ -1,20 +1,17 @@
 package org.apache.struts.crud.action;
 
 import static com.opensymphony.xwork2.Action.SUCCESS;
-
-//import org.apache.log4j.Logger;
-import org.apache.struts.crud.model.Person;
-import org.apache.struts.crud.model.Country;
-import org.apache.struts.crud.service.PersonService;
-import org.apache.struts.crud.service.DefaultPersonService;
-
 import com.opensymphony.xwork2.ActionSupport;
 import com.opensymphony.xwork2.Preparable;
+import org.apache.log4j.Logger;
+import org.apache.struts.crud.model.Country;
+import org.apache.struts.crud.model.Person;
+import org.apache.struts.crud.service.DefaultPersonService;
+import org.apache.struts.crud.service.PersonService;
 
 /**
  * Acts as a controller to handle actions related to editing a Person.
  * 
- * TODO add comments to all code in the project
  * TODO display country name instead of code
  * TODO logging
  * TODO prepareInput 
@@ -23,7 +20,8 @@ import com.opensymphony.xwork2.Preparable;
  * @author antonio sánchez
  */
 public class PersonAction extends ActionSupport implements Preparable {
-//    private static Logger log = Logger.getLogger(PersonAction.class.getName());
+    
+    private static final Logger LOGGER = Logger.getLogger(PersonAction.class.getName());
     private PersonService personService = new DefaultPersonService();
     private Person person;
     private Person[] persons;
@@ -34,6 +32,8 @@ public class PersonAction extends ActionSupport implements Preparable {
 
     @Override
     public void prepare() throws Exception {
+        
+        LOGGER.info("In prepare method");
         carModelsAvailable = personService.getCarModels();
         sports = personService.getSports();
         countries = personService.getCountries();
@@ -44,11 +44,19 @@ public class PersonAction extends ActionSupport implements Preparable
{
         }
     }
 
+    /**
+     * Get all persons for display in the view.
+     * @return success
+     */
     public String list() {
         persons = personService.getAllPersons();
         return SUCCESS;
     }
     
+    /**
+     * Save the state of the Person object instance field.
+     * @return success
+     */
     public String save() {
         if (person.getPersonId() == null) {
             personService.insertPerson(person);
@@ -58,6 +66,11 @@ public class PersonAction extends ActionSupport implements Preparable {
         return SUCCESS;
     }
 
+    /**
+     * Delete from Person identified by the person
+     * instance field's personId value.
+     * @return 
+     */
     public String delete() {
         personService.deletePerson(person.getPersonId());
         return SUCCESS;

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/192b912a/crud/src/main/java/org/apache/struts/crud/dao/MemoryPersonDao.java
----------------------------------------------------------------------
diff --git a/crud/src/main/java/org/apache/struts/crud/dao/MemoryPersonDao.java b/crud/src/main/java/org/apache/struts/crud/dao/MemoryPersonDao.java
index 60a9e7e..5bc2576 100755
--- a/crud/src/main/java/org/apache/struts/crud/dao/MemoryPersonDao.java
+++ b/crud/src/main/java/org/apache/struts/crud/dao/MemoryPersonDao.java
@@ -5,15 +5,15 @@ import java.util.List;
 import org.apache.struts.crud.model.Person;
 
 /**
- *
+ *In memory data repository for Person objects.
  * @author antonio sanchez
  */
 public class MemoryPersonDao implements PersonDao {
 
-    private static List<Person> persons;
+    private final static List<Person> persons;
 
     static {
-        persons = new ArrayList<Person>();
+        persons = new ArrayList<>();
         persons.add(new Person(1, "Bruce", "Phillips", "basketball", "male", "US", true,
new String[]{"Ford", "Nissan"}, "bphillips@ku.edu", "123-456-9999"));
         persons.add(new Person(2, "Antonio", "Sanchez", "mtb", "male", "ES", true, new String[]{"Toyota",
"Seat"}, "asanchez@correoe.es", "555-999-8888"));
     }

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/192b912a/crud/src/main/java/org/apache/struts/crud/dao/MemoryPersonSupportDao.java
----------------------------------------------------------------------
diff --git a/crud/src/main/java/org/apache/struts/crud/dao/MemoryPersonSupportDao.java b/crud/src/main/java/org/apache/struts/crud/dao/MemoryPersonSupportDao.java
index cfdc330..429ff47 100755
--- a/crud/src/main/java/org/apache/struts/crud/dao/MemoryPersonSupportDao.java
+++ b/crud/src/main/java/org/apache/struts/crud/dao/MemoryPersonSupportDao.java
@@ -10,11 +10,11 @@ import org.apache.struts.crud.model.Country;
  * @author antonio sanchez
  */
 public class MemoryPersonSupportDao implements PersonSupportDao {
-    private static Country[] countries;
-    private static Map<String, Country> countriesMap;
-    private static String[] genders = {"male", "female"};
-    private static String[] sports = {"football", "baseball", "basketball", "mtb" };
-    private static String [] carModelsAvailable = {"Ford", "Chrysler", "Toyota", "Nissan",
"Seat"};
+    private static final Country[] countries;
+    private static final Map<String, Country> countriesMap;
+    private static final String[] genders = {"male", "female"};
+    private static final String[] sports = {"football", "baseball", "basketball", "mtb" };
+    private static final String [] carModelsAvailable = {"Ford", "Chrysler", "Toyota", "Nissan",
"Seat"};
 
     static {
         countries = new Country[] {new Country("ES", "Spain"),
@@ -29,10 +29,7 @@ public class MemoryPersonSupportDao implements PersonSupportDao {
         }
     }
 
-//    @Override
-//    public Map<String, Country> getCountriesMap() {
-//        return countriesMap;
-//    }
+
 
     @Override
     public String[] getCarModels() {

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/192b912a/crud/src/main/java/org/apache/struts/crud/dao/PersonDao.java
----------------------------------------------------------------------
diff --git a/crud/src/main/java/org/apache/struts/crud/dao/PersonDao.java b/crud/src/main/java/org/apache/struts/crud/dao/PersonDao.java
index 700c522..79ace0e 100755
--- a/crud/src/main/java/org/apache/struts/crud/dao/PersonDao.java
+++ b/crud/src/main/java/org/apache/struts/crud/dao/PersonDao.java
@@ -3,6 +3,9 @@ package org.apache.struts.crud.dao;
 import org.apache.struts.crud.model.Person;
 
 /**
+ * Data access methods that a PersonDao class
+ * must define to provide information about
+ * a Person or collection of Person objects.
  * @author antonio sanchez
  */
 public interface PersonDao {

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/192b912a/crud/src/main/java/org/apache/struts/crud/dao/PersonSupportDao.java
----------------------------------------------------------------------
diff --git a/crud/src/main/java/org/apache/struts/crud/dao/PersonSupportDao.java b/crud/src/main/java/org/apache/struts/crud/dao/PersonSupportDao.java
index d3d3e40..2a38bc6 100755
--- a/crud/src/main/java/org/apache/struts/crud/dao/PersonSupportDao.java
+++ b/crud/src/main/java/org/apache/struts/crud/dao/PersonSupportDao.java
@@ -4,13 +4,13 @@ package org.apache.struts.crud.dao;
 import org.apache.struts.crud.model.Country;
 
 /**
+ * Methods a PersonSupportDao class must implement to provide
+ * additional information related to a Person.
  * @author antonio sanchez
  */
 public interface PersonSupportDao {
 
     Country[] getCountries();
-
-//    Map<String, Country> getCountriesMap();
     
     String[] getCarModels();
     

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/192b912a/crud/src/main/java/org/apache/struts/crud/model/Country.java
----------------------------------------------------------------------
diff --git a/crud/src/main/java/org/apache/struts/crud/model/Country.java b/crud/src/main/java/org/apache/struts/crud/model/Country.java
index f99b2f7..b8289bb 100755
--- a/crud/src/main/java/org/apache/struts/crud/model/Country.java
+++ b/crud/src/main/java/org/apache/struts/crud/model/Country.java
@@ -1,7 +1,7 @@
 package org.apache.struts.crud.model;
 
 /**
- * TODO rename 'Abbr'
+ * Model a country.
  * 
  * @author antonio sánchez
  */

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/192b912a/crud/src/main/java/org/apache/struts/crud/service/PersonService.java
----------------------------------------------------------------------
diff --git a/crud/src/main/java/org/apache/struts/crud/service/PersonService.java b/crud/src/main/java/org/apache/struts/crud/service/PersonService.java
index e05c06b..bc369ba 100755
--- a/crud/src/main/java/org/apache/struts/crud/service/PersonService.java
+++ b/crud/src/main/java/org/apache/struts/crud/service/PersonService.java
@@ -3,6 +3,11 @@ package org.apache.struts.crud.service;
 import org.apache.struts.crud.model.Country;
 import org.apache.struts.crud.model.Person;
 
+/**
+ * Define methods a PersonService must implement
+ * to provide services related to a Person class.
+ * @author bphillips
+ */
 public interface PersonService {
 
     Person getPerson(Integer id);


Mime
View raw message