Update of
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/preferences
In directory james.mmbase.org:/tmp/cvs-serv18890/services/community/preferences
Modified Files:
Preference.java PreferenceHibernateService.java
PreferenceService.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/preferences
See also: http://www.mmbase.org/jira/browse/CMSC-899
Index: Preference.java
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/preferences/Preference.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- Preference.java 30 Jan 2008 16:00:15 -0000 1.3
+++ Preference.java 23 Sep 2008 07:12:57 -0000 1.4
@@ -1,12 +1,11 @@
/*
-
-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.preferences;
import javax.persistence.Column;
@@ -93,33 +92,22 @@
@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 Preference other = (Preference) obj;
if (key == null) {
- if (other.key != null)
- return false;
- } else if (!key.equals(other.key))
- return false;
+ if (other.key != null) return false;
+ } else if (!key.equals(other.key)) return false;
if (module == null) {
- if (other.module != null)
- return false;
- } else if (!module.equals(other.module))
- return false;
+ if (other.module != null) return false;
+ } else if (!module.equals(other.module)) return false;
if (authenticationId == null) {
- if (other.authenticationId != null)
- return false;
- } else if (!authenticationId.equals(other.authenticationId))
- return false;
+ if (other.authenticationId != null) return false;
+ } else if (!authenticationId.equals(other.authenticationId)) return
false;
if (value == null) {
- if (other.value != null)
- return false;
- } else if (!value.equals(other.value))
- return false;
+ if (other.value != null) return false;
+ } else if (!value.equals(other.value)) return false;
return true;
}
}
Index: PreferenceHibernateService.java
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/preferences/PreferenceHibernateService.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- PreferenceHibernateService.java 22 Sep 2008 07:25:30 -0000 1.12
+++ PreferenceHibernateService.java 23 Sep 2008 07:12:57 -0000 1.13
@@ -1,12 +1,11 @@
/*
-
-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.preferences;
import java.util.ArrayList;
@@ -38,16 +37,16 @@
/** [EMAIL PROTECTED] */
@Transactional(readOnly = true)
@SuppressWarnings("unchecked")
- public Map<Long, Map<String, String>> getPreferencesByModule(String
module) {
+ public Map < Long , Map < String , String >> getPreferencesByModule(String
module) {
Criteria criteria = getSession().createCriteria(Preference.class);
criteria.add(Restrictions.eq("module", module));
List preferenceList = criteria.list();
- Map<Long, Map<String, String>> userPreferenceMap = new HashMap<Long,
Map<String, String>>();
+ Map < Long , Map < String , String >> userPreferenceMap = new HashMap <
Long , Map < String , String >>();
for (Iterator iter = preferenceList.iterator(); iter.hasNext();) {
Preference p = (Preference) iter.next();
- Map<String, String> preferenceMap =
userPreferenceMap.get(p.getAuthenticationId());
+ Map < String , String > preferenceMap =
userPreferenceMap.get(p.getAuthenticationId());
if (preferenceMap == null) {
- preferenceMap = new HashMap<String, String>();
+ preferenceMap = new HashMap < String , String >();
userPreferenceMap.put(p.getAuthenticationId(), preferenceMap);
}
preferenceMap.put(p.getKey(), p.getValue());
@@ -58,33 +57,34 @@
/** [EMAIL PROTECTED] */
@Transactional(readOnly = true)
@SuppressWarnings("unchecked")
- public Map<String, Map<String, String>> getPreferencesByUserId(String
userId) {
+ public Map < String , Map < String , String >>
getPreferencesByUserId(String userId) {
Long authenticationId =
authenticationService.getAuthenticationIdForUserId(userId);
Criteria criteria = getSession().createCriteria(Preference.class);
criteria.add(Restrictions.eq("authenticationId", authenticationId));
List preferenceList = criteria.list();
- Map<String, Map<String, String>> modulePreferenceMap = new
HashMap<String, Map<String, String>>();
+ Map < String , Map < String , String >> modulePreferenceMap = new
HashMap < String , Map < String , String >>();
for (Iterator iter = preferenceList.iterator(); iter.hasNext();) {
Preference p = (Preference) iter.next();
- Map<String, String> preferenceMap =
modulePreferenceMap.get(p.getModule());
+ Map < String , String > preferenceMap =
modulePreferenceMap.get(p.getModule());
if (preferenceMap == null) {
- preferenceMap = new HashMap<String, String>();
+ preferenceMap = new HashMap < String , String >();
modulePreferenceMap.put(p.getModule(), preferenceMap);
}
preferenceMap.put(p.getKey(), p.getValue());
}
return modulePreferenceMap;
}
+
/** [EMAIL PROTECTED] */
@Transactional(readOnly = true)
- public List<Preference> getListPreferencesByUserId(String userId){
+ public List < Preference > getListPreferencesByUserId(String userId) {
Long authenticationId =
authenticationService.getAuthenticationIdForUserId(userId);
Criteria criteria = getSession().createCriteria(Preference.class);
criteria.add(Restrictions.eq("authenticationId", authenticationId));
List List = criteria.list();
- List<Preference> preferenceList = new ArrayList<Preference>();
+ List < Preference > preferenceList = new ArrayList < Preference >();
for (Iterator iter = List.iterator(); iter.hasNext();) {
- Preference p =new Preference();
+ Preference p = new Preference();
p = (Preference) iter.next();
preferenceList.add(p);
}
@@ -93,7 +93,7 @@
/** [EMAIL PROTECTED] */
@Transactional(readOnly = true)
- public Map<String, String> getPreferences(String module, String userId)
{
+ public Map < String , String > getPreferences(String module, String userId)
{
Long authenticationId =
authenticationService.getAuthenticationIdForUserId(userId);
Criteria criteria = getSession().createCriteria(Preference.class);
criteria.add(Restrictions.eq("module", module));
@@ -104,14 +104,14 @@
/** [EMAIL PROTECTED] */
@SuppressWarnings("unchecked")
@Transactional(readOnly = true)
- public List<String> getPreferenceValues(String module, String userId,
String key) {
+ public List < String > getPreferenceValues(String module, String userId,
String key) {
Long authenticationId =
authenticationService.getAuthenticationIdForUserId(userId);
Criteria criteria = getSession().createCriteria(Preference.class);
criteria.add(Restrictions.eq("module", module));
criteria.add(Restrictions.eq("authenticationId", authenticationId));
criteria.add(Restrictions.eq("key", key));
- List<String> result = new ArrayList<String>();
+ List < String > result = new ArrayList < String >();
for (Iterator iter = criteria.list().iterator(); iter.hasNext();) {
Preference p = (Preference) iter.next();
result.add(p.getValue());
@@ -120,9 +120,9 @@
}
@SuppressWarnings("unchecked")
- private Map<String, String> gePreferencesMap(Criteria criteria) {
+ private Map < String , String > gePreferencesMap(Criteria criteria) {
List userPreferenceList = criteria.list();
- Map<String, String> preferenceMap = new HashMap<String, String>();
+ Map < String , String > preferenceMap = new HashMap < String , String
>();
for (Iterator iter = userPreferenceList.iterator(); iter.hasNext();) {
Preference p = (Preference) iter.next();
preferenceMap.put(p.getKey(), p.getValue());
@@ -142,7 +142,6 @@
getSession().save(preference);
}
-
/** [EMAIL PROTECTED] */
@Transactional
@SuppressWarnings("unchecked")
@@ -152,12 +151,12 @@
criteria.add(Restrictions.eq("module", module));
criteria.add(Restrictions.eq("authenticationId", authenticationId));
criteria.add(Restrictions.eq("key", key));
- if(oldvalue != null) {
+ if (oldvalue != null) {
criteria.add(Restrictions.eq("value", oldvalue));
}
List preferences = criteria.list();
if (preferences.size() == 1) {
- Preference p = (Preference)preferences.get(0);
+ Preference p = (Preference) preferences.get(0);
p.setValue(newValue);
}
}
@@ -174,7 +173,7 @@
criteria.add(Restrictions.eq("value", value));
List preferences = criteria.list();
if (preferences.size() == 1) {
- Preference p = (Preference)preferences.get(0);
+ Preference p = (Preference) preferences.get(0);
getSession().delete(p);
}
}
@@ -185,74 +184,72 @@
}
@Transactional(readOnly = true)
- public List<PreferenceVO> getPreferences(PreferenceVO preference,int
offset,int pageSize,String orderBy,String direction){
+ public List < PreferenceVO > getPreferences(PreferenceVO preference, int
offset, int pageSize, String orderBy,
+ String direction) {
- List<PreferenceVO> preferences = new ArrayList<PreferenceVO>();
+ List < PreferenceVO > preferences = new ArrayList < PreferenceVO >();
Criteria criteria = getSession().createCriteria(Preference.class);
- if(preference != null) {
+ if (preference != null) {
- if(StringUtils.isNotBlank(preference.getUserId())) {
+ if (StringUtils.isNotBlank(preference.getUserId())) {
Criteria authentication =
getSession().createCriteria(Authentication.class);
- authentication.add(Restrictions.ilike("userId",
"%"+preference.getUserId()+"%"));
- List<Authentication> authentications = authentication.list();
- List<Long> authenticationIds = new ArrayList<Long>();
- for(Authentication authe : authentications) {
+ authentication.add(Restrictions.ilike("userId", "%" +
preference.getUserId() + "%"));
+ List < Authentication > authentications = authentication.list();
+ List < Long > authenticationIds = new ArrayList < Long >();
+ for (Authentication authe : authentications) {
authenticationIds.add(authe.getId());
}
- if(authenticationIds.size() > 0) {
+ if (authenticationIds.size() > 0) {
criteria.add(Restrictions.in("authenticationId",
authenticationIds));
}
}
- if(StringUtils.isNotBlank(preference.getModule())) {
- criteria.add(Restrictions.ilike("module",
"%"+preference.getModule()+"%"));
+ if (StringUtils.isNotBlank(preference.getModule())) {
+ criteria.add(Restrictions.ilike("module", "%" +
preference.getModule() + "%"));
}
- if(StringUtils.isNotBlank(preference.getKey())) {
- criteria.add(Restrictions.ilike("key",
"%"+preference.getKey()+"%"));
+ if (StringUtils.isNotBlank(preference.getKey())) {
+ criteria.add(Restrictions.ilike("key", "%" + preference.getKey() +
"%"));
}
- if(StringUtils.isNotBlank(preference.getValue())) {
- criteria.add(Restrictions.ilike("value",
"%"+preference.getValue()+"%"));
+ if (StringUtils.isNotBlank(preference.getValue())) {
+ criteria.add(Restrictions.ilike("value", "%" +
preference.getValue() + "%"));
}
}
criteria.setFirstResult(offset);
criteria.setMaxResults(pageSize);
- if(StringUtils.isNotEmpty(orderBy)) {
- if(StringUtils.isEmpty(direction) ||
direction.equalsIgnoreCase("down")) {
+ if (StringUtils.isNotEmpty(orderBy)) {
+ if (StringUtils.isEmpty(direction) ||
direction.equalsIgnoreCase("down")) {
criteria.addOrder(Order.desc(orderBy));
- }
- else {
+ } else {
criteria.addOrder(Order.asc(orderBy));
}
- }
- else {
+ } else {
criteria.addOrder(Order.desc("id"));
}
- copyPropertiesToVO(preferences,criteria.list());
+ copyPropertiesToVO(preferences, criteria.list());
return preferences;
}
@Transactional(readOnly = true)
- public List<PreferenceVO> getPreferences(int offset,int pageSize,String
orderBy,String direction){
- return getPreferences(null,offset,pageSize,orderBy,direction);
+ public List < PreferenceVO > getPreferences(int offset, int pageSize,
String orderBy, String direction) {
+ return getPreferences(null, offset, pageSize, orderBy, direction);
}
@Transactional
public void createPreference(PreferenceVO preference) {
-
createPreference(preference.getModule(),preference.getUserId(),preference.getKey(),preference.getValue());
+ createPreference(preference.getModule(), preference.getUserId(),
preference.getKey(), preference.getValue());
}
@Transactional
- public void createPreference(Preference preference,String userId) {
-
createPreference(preference.getModule(),userId,preference.getKey(),preference.getValue());
+ public void createPreference(Preference preference, String userId) {
+ createPreference(preference.getModule(), userId, preference.getKey(),
preference.getValue());
}
@Transactional
public void updatePreference(PreferenceVO preferenceVO) {
try {
- Preference preference = (Preference) getSession().load(
- Preference.class,
Long.parseLong(preferenceVO.getId()));
+ Preference preference = (Preference)
getSession().load(Preference.class, Long.parseLong(preferenceVO.getId()));
preference.setKey(preferenceVO.getKey());
preference.setValue(preferenceVO.getValue());
getSession().saveOrUpdate(preference);
@@ -263,22 +260,19 @@
@Transactional
public void deletePreference(String number) {
- Preference preference = (Preference)
getSession().get(Preference.class,
- Long.parseLong(number));
+ Preference preference = (Preference) getSession().get(Preference.class,
Long.parseLong(number));
getSession().delete(preference);
}
public void deletePreference(long number) {
- Preference preference = (Preference)
getSession().get(Preference.class,
- number);
+ Preference preference = (Preference) getSession().get(Preference.class,
number);
getSession().delete(preference);
}
@Transactional(readOnly = true)
- public List<String> getAllUserIds() {
- List<Authentication> authentications = authenticationService
- .findAuthentications();
- List<String> userIds = new ArrayList<String>();
+ public List < String > getAllUserIds() {
+ List < Authentication > authentications =
authenticationService.findAuthentications();
+ List < String > userIds = new ArrayList < String >();
for (Authentication authentication : authentications) {
userIds.add(authentication.getUserId());
}
@@ -291,41 +285,35 @@
if (preference != null) {
if (StringUtils.isNotBlank(preference.getUserId())) {
- Criteria authentication =
getSession().createCriteria(
- Authentication.class);
- authentication.add(Restrictions.ilike("userId",
"%"
- + preference.getUserId() +
"%"));
- List<Authentication> authentications =
authentication.list();
- List<Long> authenticationIds = new
ArrayList<Long>();
+ Criteria authentication =
getSession().createCriteria(Authentication.class);
+ authentication.add(Restrictions.ilike("userId", "%" +
preference.getUserId() + "%"));
+ List < Authentication > authentications = authentication.list();
+ List < Long > authenticationIds = new ArrayList < Long >();
for (Authentication authe : authentications) {
authenticationIds.add(authe.getId());
}
if (authenticationIds.size() > 0) {
-
criteria.add(Restrictions.in("authenticationId",
- authenticationIds));
+ criteria.add(Restrictions.in("authenticationId",
authenticationIds));
}
}
if (StringUtils.isNotBlank(preference.getModule())) {
- criteria.add(Restrictions.ilike("module", "%"
- + preference.getModule() +
"%"));
+ criteria.add(Restrictions.ilike("module", "%" +
preference.getModule() + "%"));
}
if (StringUtils.isNotBlank(preference.getKey())) {
- criteria.add(Restrictions.ilike("key", "%"
- + preference.getKey() + "%"));
+ criteria.add(Restrictions.ilike("key", "%" + preference.getKey() +
"%"));
}
if (StringUtils.isNotBlank(preference.getValue())) {
- criteria.add(Restrictions.ilike("value", "%"
- + preference.getValue() + "%"));
+ criteria.add(Restrictions.ilike("value", "%" +
preference.getValue() + "%"));
}
}
return criteria.list().size();
}
- private void copyPropertiesToVO(List<PreferenceVO> dest,List<Preference>
src) {
- if(src == null || src.size() == 0) {
+ private void copyPropertiesToVO(List < PreferenceVO > dest, List <
Preference > src) {
+ if (src == null || src.size() == 0) {
return;
}
- for(Preference preference:src ) {
+ for (Preference preference : src) {
PreferenceVO preferenceVO = new PreferenceVO();
preferenceVO.setId(String.valueOf(preference.getId()));
preferenceVO.setKey(preference.getKey());
@@ -338,7 +326,7 @@
}
@Transactional
- private String getUserIdByAuthenticationId(Long authenticationId){
+ private String getUserIdByAuthenticationId(Long authenticationId) {
Authentication authentication =
authenticationService.getAuthenticationById(authenticationId);
return authentication.getUserId();
}
Index: PreferenceService.java
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/preferences/PreferenceService.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- PreferenceService.java 15 Jul 2008 04:39:16 -0000 1.5
+++ PreferenceService.java 23 Sep 2008 07:12:57 -0000 1.6
@@ -1,12 +1,11 @@
/*
-
-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.preferences;
import java.util.List;
@@ -14,7 +13,6 @@
import com.finalist.cmsc.services.community.domain.PreferenceVO;
-
/**
* @author Remco Bos
*/
@@ -23,50 +21,68 @@
/**
* Returns all preferences by module
*
- * @param module Module name
+ * @param module
+ * Module name
* @return map A map with preferences for a module, grouped by
autenticationId
*/
-// Map<Long, Map<String, String>> getPreferencesByModule(String module);
-
+ // Map<Long, Map<String, String>> getPreferencesByModule(String module);
/**
* Returns all preferences by userId
*
- * @param user User id
+ * @param user
+ * User id
* @return map A map with preferences for a userId, grouped by module
*/
-// Map<String, Map<String, String>> getPreferencesByUserId(String userId);
-
+ // Map<String, Map<String, String>> getPreferencesByUserId(String userId);
/**
* Returns all preferences by module and user
+ *
* @param module
* @param userId
* @return map A map with preferences for a module and userId
*/
-// Map<String, String> getPreferences(String module, String userId);
-
+ // Map<String, String> getPreferences(String module, String userId);
/**
* Returns all preferences by module, userId and key
+ *
* @param module
* @param userId
* @param key
* @return map A map with preferences for a module, userId and key
*/
-// Map<String, String> getPreferences(String module, String userId, String
key);
- Map<Long, Map<String, String>> getPreferencesByModule(String module);
- Map<String, Map<String, String>> getPreferencesByUserId(String userId);
- List<String> getPreferenceValues(String module, String userId, String key);
+ // Map<String, String> getPreferences(String module, String userId, String
key);
+ Map < Long , Map < String , String >> getPreferencesByModule(String module);
+
+ Map < String , Map < String , String >> getPreferencesByUserId(String
userId);
+
+ List < String > getPreferenceValues(String module, String userId, String
key);
+
void createPreference(String module, String userId, String key, String
value);
+
void updatePreference(String module, String userId, String key, String
oldValue, String newValue);
+
void deletePreference(String module, String userId, String key, String
value);
- public List<PreferenceVO> getPreferences(PreferenceVO preference,int
offset,int pageSize,String orderBy,String direction);
- public List<PreferenceVO> getPreferences(int offset,int
pageSize,String orderBy,String direction);
- public void createPreference(PreferenceVO preference) ;
+
+ public List < PreferenceVO > getPreferences(PreferenceVO preference, int
offset, int pageSize, String orderBy,
+ String direction);
+
+ public List < PreferenceVO > getPreferences(int offset, int pageSize,
String orderBy, String direction);
+
+ public void createPreference(PreferenceVO preference);
+
public void updatePreference(PreferenceVO preferenceVO);
- public void deletePreference(String number) ;
- public List<String> getAllUserIds();
+
+ public void deletePreference(String number);
+
+ public List < String > getAllUserIds();
+
public int getTotalCount(PreferenceVO preference);
- List<Preference> getListPreferencesByUserId(String userId);
+
+ List < Preference > getListPreferencesByUserId(String userId);
+
void createPreference(Preference preferences, String userId);
+
void deletePreference(long number);
+
void batchCleanByAuthenticationId(long authenticationId);
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs