Update of 
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/person
In directory james.mmbase.org:/tmp/cvs-serv18890/services/community/person

Modified Files:
        Person.java PersonHibernateService.java PersonService.java 
Log Message:
CMSC-899,Check and improve all lists according to guideline,delete tab character


See also: 
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/person
See also: http://www.mmbase.org/jira/browse/CMSC-899


Index: Person.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/person/Person.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- Person.java 30 Jul 2008 09:52:38 -0000      1.4
+++ Person.java 23 Sep 2008 07:12:57 -0000      1.5
@@ -1,12 +1,11 @@
 /*
-
-OSI Certified is a certification mark of the Open Source Initiative.
-This software is OSI Certified Open Source Software.
-
-The license (Mozilla version 1.0) can be read at the MMBase site.
-See http://www.MMBase.org/license
-
-*/
+ * 
+ * OSI Certified is a certification mark of the Open Source Initiative. This 
software is OSI Certified Open Source
+ * Software.
+ * 
+ * The license (Mozilla version 1.0) can be read at the MMBase site. See 
http://www.MMBase.org/license
+ * 
+ */
 package com.finalist.cmsc.services.community.person;
 
 import javax.persistence.Entity;
@@ -37,48 +36,63 @@
    public Long getId() {
       return id;
        }
+
        public void setId(Long id) {
                this.id = id;
        }
+
        public Long getAuthenticationId() {
                return authenticationId;
        }
+
        public void setAuthenticationId(Long authenticationId) {
                this.authenticationId = authenticationId;
        }
+
        public String getFirstName() {
                return firstName;
        }
+
        public void setFirstName(String firstName) {
                this.firstName = firstName;
        }
+
        public String getLastName() {
                return lastName;
        }
+
        public void setLastName(String lastName) {
                this.lastName = lastName;
        }
+
        public String getInfix() {
                return infix;
        }
+
        public void setInfix(String infix) {
                this.infix = infix;
        }
+
        public String getNickname() {
                return nickname;
        }
+
        public void setNickname(String nickname) {
                this.nickname = nickname;
        }
+
        public String getEmail() {
                return email;
        }
+
        public void setEmail(String email) {
                this.email = email;
        }
+
        public String getUri() {
                return uri;
        }
+
        public void setUri(String uri) {
                this.uri = uri;
        }
@@ -87,41 +101,31 @@
        public int hashCode() {
                final int prime = 31;
                int result = 1;
-               result = prime * result
-                               + ((firstName == null) ? 0 : 
firstName.hashCode());
+      result = prime * result + ((firstName == null) ? 0 : 
firstName.hashCode());
                result = prime * result + ((infix == null) ? 0 : 
infix.hashCode());
-               result = prime * result
-                               + ((lastName == null) ? 0 : 
lastName.hashCode());
+      result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
                return result;
        }
+
        @Override
        public boolean equals(Object obj) {
-               if (this == obj)
-                       return true;
-               if (obj == null)
-                       return false;
-               if (getClass() != obj.getClass())
-                       return false;
+      if (this == obj) return true;
+      if (obj == null) return false;
+      if (getClass() != obj.getClass()) return false;
                final Person other = (Person) obj;
                if (firstName == null) {
-                       if (other.firstName != null)
-                               return false;
-               } else if (!firstName.equals(other.firstName))
-                       return false;
+         if (other.firstName != null) return false;
+      } else if (!firstName.equals(other.firstName)) return false;
                if (infix == null) {
-                       if (other.infix != null)
-                               return false;
-               } else if (!infix.equals(other.infix))
-                       return false;
+         if (other.infix != null) return false;
+      } else if (!infix.equals(other.infix)) return false;
                if (lastName == null) {
-                       if (other.lastName != null)
-                               return false;
-               } else if (!lastName.equals(other.lastName))
-                       return false;
+         if (other.lastName != null) return false;
+      } else if (!lastName.equals(other.lastName)) return false;
                return true;
        }
 
-   public String getFullName(){
-      return this.getFirstName() + " " +this.getLastName();
+   public String getFullName() {
+      return this.getFirstName() + " " + this.getLastName();
    }
 }


Index: PersonHibernateService.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/person/PersonHibernateService.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- PersonHibernateService.java 22 Sep 2008 07:23:48 -0000      1.22
+++ PersonHibernateService.java 23 Sep 2008 07:12:57 -0000      1.23
@@ -1,11 +1,10 @@
 /*
-
- This software is OSI Certified Open Source Software.
- OSI Certified is a certification mark of the Open Source Initiative.
-
- The license (Mozilla version 1.0) can be read at the MMBase site.
- See http://www.MMBase.org/license
-
+ * 
+ * This software is OSI Certified Open Source Software. OSI Certified is a 
certification mark of the Open Source
+ * Initiative.
+ * 
+ * The license (Mozilla version 1.0) can be read at the MMBase site. See 
http://www.MMBase.org/license
+ * 
  */
 package com.finalist.cmsc.services.community.person;
 
@@ -58,12 +57,12 @@
         */
        @Transactional
        @SuppressWarnings("unchecked")
-       public List<Person> getPersons(Person example) {
+   public List < Person > getPersons(Person example) {
                if (example == null) {
                        return Collections.emptyList();
                }
 
-               List<Person> personList = 
getSession().createCriteria(Person.class).add(Example.create(example)).list();
+      List < Person > personList = 
getSession().createCriteria(Person.class).add(Example.create(example)).list();
                return personList;
 
        }
@@ -72,16 +71,13 @@
         * [EMAIL PROTECTED]
         */
        @Transactional
-       public List<Person> getLikePersons(Person example) {
+   public List < Person > getLikePersons(Person example) {
                if (example == null) {
                        return Collections.emptyList();
                }
 
-      Example userExample = Example.create(example).
-            enableLike(MatchMode.ANYWHERE).
-            excludeZeroes().
-            ignoreCase();
-               List<Person> personList = 
getSession().createCriteria(Person.class).add(userExample).list();
+      Example userExample = 
Example.create(example).enableLike(MatchMode.ANYWHERE).excludeZeroes().ignoreCase();
+      List < Person > personList = 
getSession().createCriteria(Person.class).add(userExample).list();
                return personList;
        }
 
@@ -119,12 +115,12 @@
        }
 
        @Transactional
-       public List<Person> getAllPeople() {
+   public List < Person > getAllPeople() {
                return getAssociatedPersons(null);
        }
 
        @Transactional
-       public List<Person> getAllPersons() {
+   public List < Person > getAllPersons() {
                Criteria criteria = getSession().createCriteria(Person.class);
                return criteria.list();
        }
@@ -157,7 +153,7 @@
 
        @SuppressWarnings("unchecked")
        private Person findPersonByCriteria(Criteria criteria) {
-               List<Person> personList = criteria.list();
+      List < Person > personList = criteria.list();
                return personList.size() > 0 ? personList.get(0) : null;
        }
 
@@ -173,7 +169,8 @@
        public Person getPersonByAuthenticationId(Long authenticationId) {
                Person person = null;
                if (authenticationId != null) {
-                       Criteria criteria = 
getSession().createCriteria(Person.class).add(Restrictions.eq("authenticationId",
 authenticationId));
+         Criteria criteria = getSession().createCriteria(Person.class).add(
+               Restrictions.eq("authenticationId", authenticationId));
                        person = findPersonByCriteria(criteria);
                }
                return person;
@@ -191,7 +188,7 @@
 
        @Transactional
        public void batchClean() {
-               List<Person> persons = getAllPersons();
+      List < Person > persons = getAllPersons();
                for (Person tempPerson : persons) {
                        if (null != tempPerson) {
                                long authId = tempPerson.getAuthenticationId();
@@ -217,8 +214,8 @@
                person.setAuthenticationId(authentication.getId());
                updatePerson(person);
                String userId = xperson.getAuthentication().getUserId();
-               List<Preference> preferences = xperson.getPreferences();
-               if (preferences.size()>0) {
+      List < Preference > preferences = xperson.getPreferences();
+      if (preferences.size() > 0) {
                        for (Preference preference : preferences) {
                                preferenceService.createPreference(preference, 
userId);
                        }
@@ -226,9 +223,9 @@
        }
 
        @Transactional(readOnly = true)
-       public List<PersonExportImportVO> getPersonExportImportVO() {
-               List<PersonExportImportVO> XPersons = new 
ArrayList<PersonExportImportVO>();
-               List<Person> persons = getAllPersons();
+   public List < PersonExportImportVO > getPersonExportImportVO() {
+      List < PersonExportImportVO > XPersons = new ArrayList < 
PersonExportImportVO >();
+      List < Person > persons = getAllPersons();
                if (null == persons) {
                        return null;
                }
@@ -256,7 +253,7 @@
                authentication = 
authenticationService.getAuthenticationById(authenticationId);
                authentication.setAuthorities(null);
                String userId = authentication.getUserId();
-               List<Preference> preferences = 
preferenceService.getListPreferencesByUserId(userId);
+      List < Preference > preferences = 
preferenceService.getListPreferencesByUserId(userId);
                converPersonPropertis(tempPerson, o);
                o.setAuthentication(authentication);
                o.setPreferences(preferences);
@@ -264,7 +261,7 @@
        }
 
        @Transactional(readOnly = true)
-       public List<Person> getAssociatedPersons(Map conditions) {
+   public List < Person > getAssociatedPersons(Map conditions) {
                PagingStatusHolder holder = PagingUtils.getStatusHolder();
                StringBuffer strb = new StringBuffer();
                basicGetAssociatedPersons(conditions, strb);
@@ -274,11 +271,11 @@
                return q.list();
        }
 
-       private void basicGetAssociatedPersons(Map<String, String> conditions, 
StringBuffer strb) {
+   private void basicGetAssociatedPersons(Map < String , String > conditions, 
StringBuffer strb) {
 
-      strb.append("select distinct person from Person person , Authentication 
authentication ").
-            append("left join authentication.authorities authority ").
-            append("where person.authenticationId = authentication.id");
+      strb.append("select distinct person from Person person , Authentication 
authentication ").append(
+            "left join authentication.authorities authority ").append(
+            "where person.authenticationId = authentication.id");
 
                if (conditions.size() < 1) {
                        return;
@@ -287,22 +284,18 @@
                if (conditions.containsKey("fullname")) {
                        String[] names = 
conditions.get("fullname").toString().split(" ");
                        if (names.length == 2) {
-            strb.append(" and ((person.firstName like '%" + names[0]
-                  + "%' and person.lastName like '%" + names[1] + "%')"
-                  + " or person.firstName like '%" + names[0] + " " + names[1]
-                  + "%'" + "or person.lastName like '%" + names[0] + " "
-                                               + names[1] + "%')");
-         }
-         else if (names.length == 1) {
-            strb.append(" and (person.firstName like '%" + names[0]
-                  + "%' or person.lastName like '%" + names[0] + "%')");
+            strb.append(" and ((person.firstName like '%" + names[0] + "%' and 
person.lastName like '%" + names[1]
+                  + "%')" + " or person.firstName like '%" + names[0] + " " + 
names[1] + "%'"
+                  + "or person.lastName like '%" + names[0] + " " + names[1] + 
"%')");
+         } else if (names.length == 1) {
+            strb.append(" and (person.firstName like '%" + names[0] + "%' or 
person.lastName like '%" + names[0]
+                  + "%')");
                        }
                }
 
                strb.append(condition("and upper(authentication.userId) like 
'[EMAIL PROTECTED]'", "username", conditions));
                strb.append(condition("and upper(person.email) like '[EMAIL 
PROTECTED]'", "email", conditions));
 
-
                if (conditions.containsKey("group")) {
                        if (!conditions.containsKey("strict")) {
                                String[] groups = 
conditions.get("group").split(" ");
@@ -310,20 +303,16 @@
                                        return;
                                }
                                strb.append(" and (");
-            strb.append("upper(authority.name)like '%"
-                  + groups[0].toUpperCase() + "%'");
+            strb.append("upper(authority.name)like '%" + 
groups[0].toUpperCase() + "%'");
                                for (int i = 1; i < groups.length; i++) {
-               strb.append(" or upper(authority.name)like '%"
-                     + groups[i].toUpperCase() + "%'");
+               strb.append(" or upper(authority.name)like '%" + 
groups[i].toUpperCase() + "%'");
                                }
                                strb.append(")");
-         }
-         else if("strict".equals(conditions.get("strict"))){
+         } else if ("strict".equals(conditions.get("strict"))) {
                                String groups = 
conditions.get("group").toString();
                                strb.append(" and authority.name='" + groups + 
"'");
-         }
-         else {
-                String exceptNames=conditions.get("strict").toString();
+         } else {
+            String exceptNames = conditions.get("strict").toString();
              strb.append(" and authentication.userId not in ('" + exceptNames 
+ "')");
                        }
                }
@@ -331,14 +320,14 @@
        }
 
        @Transactional(readOnly = true)
-       public int getAssociatedPersonsNum(Map<String, String> conditions) {
+   public int getAssociatedPersonsNum(Map < String , String > conditions) {
                StringBuffer strb = new StringBuffer();
                basicGetAssociatedPersons(conditions, strb);
                Query q = getSession().createQuery(strb.toString());
                return q.list().size();
        }
 
-       private static String condition(String query, String name, Map<String, 
String> conditions) {
+   private static String condition(String query, String name, Map < String , 
String > conditions) {
                String condition = "";
 
                if (conditions.containsKey(name)) {
@@ -355,8 +344,8 @@
        }
 
        @Transactional
-       public List<Person> getPersonsByAuthenticationIds(Set<Integer> 
authenticationIds, String name, String email) {
-               List<Person> persons = null;
+   public List < Person > getPersonsByAuthenticationIds(Set < Integer > 
authenticationIds, String name, String email) {
+      List < Person > persons = null;
                if (authenticationIds.size() > 0) {
                        StringBuffer stb = new StringBuffer("select distinct 
person from Person person");
                        stb.append(" where person.authenticationId in (");
@@ -381,47 +370,48 @@
                        persons = q.list();
                }
                return persons;
-}
+   }
        
        @Transactional(propagation = Propagation.REQUIRED)
        private void updateRelationRecord(Person oldDataPerson, 
PersonExportImportVO importPerson) {
-               Session session=getSession();
+      Session session = getSession();
                Authentication activedAuthentication = 
importPerson.getAuthentication();
-               Authentication dbAuthentication=(Authentication) 
session.load(Authentication.class,oldDataPerson.getId());
+      Authentication dbAuthentication = (Authentication) 
session.load(Authentication.class, oldDataPerson.getId());
                converPersonPropertis(importPerson, oldDataPerson);
                converAuthenticationPropertis(activedAuthentication, 
dbAuthentication);
-               parsePreferences(importPerson, session, 
activedAuthentication,dbAuthentication);
+      parsePreferences(importPerson, session, activedAuthentication, 
dbAuthentication);
        }
 
-       private void parsePreferences(PersonExportImportVO importPerson,Session 
session, Authentication activedAuthentication,
-                       Authentication dbAuthentication) {
-               List<Preference> 
importPreferences=importPerson.getPreferences();
-               List<Preference> 
dbPreferences=preferenceService.getListPreferencesByUserId(activedAuthentication.getUserId());
-               Map<Long,Preference> util=new HashMap();
-               for(Preference iPreference:importPreferences){
+   private void parsePreferences(PersonExportImportVO importPerson, Session 
session,
+         Authentication activedAuthentication, Authentication 
dbAuthentication) {
+      List < Preference > importPreferences = importPerson.getPreferences();
+      List < Preference > dbPreferences = 
preferenceService.getListPreferencesByUserId(activedAuthentication
+            .getUserId());
+      Map < Long , Preference > util = new HashMap();
+      for (Preference iPreference : importPreferences) {
                        
iPreference.setAuthenticationId(dbAuthentication.getId());
                        util.put(iPreference.getId(), iPreference);     
                }
                for (Preference dbPreference : dbPreferences) {
-                       Preference 
activePreference=util.get(dbPreference.getId());
-                       if (null!=activePreference) {
+         Preference activePreference = util.get(dbPreference.getId());
+         if (null != activePreference) {
                                converPreferencePropertis(activePreference, 
dbPreference);      
                                util.remove(dbPreference.getId());
                        } 
                }
-          for (Map.Entry<Long,Preference> entry : util.entrySet()) {
+      for (Map.Entry < Long , Preference > entry : util.entrySet()) {
                        session.save(entry.getValue());
                }
        }       
 
-       private void converPreferencePropertis(Preference 
iPreference,Preference dbPreference) {
+   private void converPreferencePropertis(Preference iPreference, Preference 
dbPreference) {
                
dbPreference.setAuthenticationId(iPreference.getAuthenticationId());
                dbPreference.setKey(iPreference.getKey());
                dbPreference.setModule(iPreference.getModule());
                dbPreference.setValue(iPreference.getValue());
        }
 
-       private void converAuthenticationPropertis(     Authentication 
activedAuthentication,Authentication dbAuthentication) {
+   private void converAuthenticationPropertis(Authentication 
activedAuthentication, Authentication dbAuthentication) {
                
dbAuthentication.setAuthorities(activedAuthentication.getAuthorities());
                dbAuthentication.setEnabled(activedAuthentication.isEnabled());
                
dbAuthentication.setPassword(activedAuthentication.getPassword());
@@ -431,10 +421,10 @@
        @Transactional
        public void addRelationRecord(String level, PersonExportImportVO 
importPerson) {
                Person p = 
getPersonByUserId(importPerson.getAuthentication().getUserId());
-               if(null!=p&&"over".equals(level)){
-                       updateRelationRecord(p,importPerson);                   
+      if (null != p && "over".equals(level)) {
+         updateRelationRecord(p, importPerson);
                }
-               if(null==p){
+      if (null == p) {
                    // only add new users
                        creatRelationRecord(importPerson);
                }


Index: PersonService.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/person/PersonService.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- PersonService.java  22 Sep 2008 07:25:30 -0000      1.15
+++ PersonService.java  23 Sep 2008 07:12:57 -0000      1.16
@@ -1,11 +1,10 @@
 /*
-
-This software is OSI Certified Open Source Software.
-OSI Certified is a certification mark of the Open Source Initiative.
-
-The license (Mozilla version 1.0) can be read at the MMBase site.
-See http://www.MMBase.org/license
-
+ * 
+ * This software is OSI Certified Open Source Software. OSI Certified is a 
certification mark of the Open Source
+ * Initiative.
+ * 
+ * The license (Mozilla version 1.0) can be read at the MMBase site. See 
http://www.MMBase.org/license
+ * 
  */
 package com.finalist.cmsc.services.community.person;
 
@@ -13,13 +12,13 @@
 import java.util.Map;
 import java.util.Set;
 import com.finalist.cmsc.services.community.domain.PersonExportImportVO;
+
 /**
  * This service encapsulates the management of people and groups.
  *
- * People and groups may be managed entirely in the repository or entirely in
- * some other implementation such as LDAP or via NTLM. Some properties may in
- * the repository and some in another store. Individual properties may or may
- * not be mutable.
+ * People and groups may be managed entirely in the repository or entirely in 
some other implementation such as LDAP or
+ * via NTLM. Some properties may in the repository and some in another store. 
Individual properties may or may not be
+ * mutable.
  *
  * @author Remco Bos
  */
@@ -28,24 +27,24 @@
    Person getPersonByUserId(String userId);
 
    /**
-    * Get a list of matching persons that match the given example. The fields
-    * that are set on the example Person are the criteria for the search.
+    * Get a list of matching persons that match the given example. The fields 
that are set on the example Person are the
+    * criteria for the search.
     *
     * @param example
     *           the example person
     * @return a list of persons that match the given example.
     */
-   List<Person> getPersons(Person example);
+   List < Person > getPersons(Person example);
 
    /**
-    * Get a list of matching persons that like the given example. The fields
-    * that are set on the example Person are the criteria for the search.
+    * Get a list of matching persons that like the given example. The fields 
that are set on the example Person are the
+    * criteria for the search.
     *
     * @param example
     *           the example person
     * @return a list of persons that like the given example.
     */
-   List<Person> getLikePersons(Person example);
+   List < Person > getLikePersons(Person example);
 
    Person getPersonByAuthenticationId(Long authenticationId);
    
@@ -58,9 +57,9 @@
     */
    void updatePerson(Person person);
 
-   List<Person> getAllPersons();
+   List < Person > getAllPersons();
    
-   public List<Person> getAllPeople();
+   public List < Person > getAllPeople();
    
    public int countAllPersons();
 
@@ -72,12 +71,13 @@
 
    public void creatRelationRecord(PersonExportImportVO xperson);
     
-   public List<PersonExportImportVO> getPersonExportImportVO();
+   public List < PersonExportImportVO > getPersonExportImportVO();
+
+   public List < Person > getAssociatedPersons(Map conditions);
    
-   public List<Person> getAssociatedPersons(Map conditions);
+   public int getAssociatedPersonsNum(Map < String , String > map);
 
-   public int getAssociatedPersonsNum(Map<String,String> map);
+   public List < Person > getPersonsByAuthenticationIds(Set < Integer > 
authenticationIds, String name, String email);
    
-   public List<Person> getPersonsByAuthenticationIds(Set<Integer> 
authenticationIds, String name, String email);
    public void addRelationRecord(String level, PersonExportImportVO 
importPerson);
 }
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to