Skip to content

Commit

Permalink
SAK-45804 Profile2: Deprecated Query setString, setBoolean => setPara…
Browse files Browse the repository at this point in the history
  • Loading branch information
axxter99 authored Jul 14, 2021
1 parent 0f5be91 commit 0d606e9
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package org.sakaiproject.profile2.logic;

import org.sakaiproject.profile2.model.ProfilePrivacy;
import org.sakaiproject.profile2.types.PreferenceType;
import org.sakaiproject.profile2.types.PrivacyType;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public Optional<List<BullhornData>> handleEvent(Event e) {
transactionTemplate.execute(status -> {

sessionFactory.getCurrentSession().createQuery("delete BullhornAlert where event = :event and fromUser = :fromUser")
.setString("event", ProfileConstants.EVENT_FRIEND_REQUEST)
.setString("fromUser", to).executeUpdate();
.setParameter("event", ProfileConstants.EVENT_FRIEND_REQUEST)
.setParameter("fromUser", to).executeUpdate();
return null;
});
} catch (Exception e1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public Optional<List<BullhornData>> handleEvent(Event e) {
transactionTemplate.execute(status -> {

sessionFactory.getCurrentSession().createQuery("delete BullhornAlert where event = :event and fromUser = :fromUser")
.setString("event", ProfileConstants.EVENT_FRIEND_REQUEST)
.setString("fromUser", to).executeUpdate();
.setParameter("event", ProfileConstants.EVENT_FRIEND_REQUEST)
.setParameter("fromUser", to).executeUpdate();
return null;
});
} catch (Exception e1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.sakaiproject.profile2.util.ProfileConstants;
import org.sakaiproject.profile2.util.ProfileUtils;

import com.opencsv.bean.CsvToBean;
import com.opencsv.bean.CsvToBeanBuilder;
import com.opencsv.bean.HeaderColumnNameTranslateMappingStrategy;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public List<String> getRequestedConnectionUserIdsForUser(final String userId) {
final HibernateCallback<List<String>> hcb = session -> {
final Query q = session.getNamedQuery(QUERY_GET_FRIEND_REQUESTS_FOR_USER);
q.setParameter(USER_UUID, userId, StringType.INSTANCE);
q.setBoolean("false", Boolean.FALSE);
q.setParameter("false", Boolean.FALSE);
//q.setResultTransformer(Transformers.aliasToBean(Friend.class));

return q.list();
Expand All @@ -92,8 +92,8 @@ public List<String> getOutgoingConnectionUserIdsForUser(final String userId) {
//updated: now just returns a List of Strings
final HibernateCallback<List<String>> hcb = session -> {
final Query q = session.getNamedQuery(QUERY_GET_OUTGOING_FRIEND_REQUESTS_FOR_USER);
q.setString(USER_UUID, userId);
q.setBoolean("false", Boolean.FALSE);
q.setParameter(USER_UUID, userId);
q.setParameter("false", Boolean.FALSE);

return q.list();
};
Expand All @@ -111,7 +111,7 @@ public List<String> getConfirmedConnectionUserIdsForUser(final String userId) {
final HibernateCallback<List<String>> hcb = session -> {
final Query q = session.getNamedQuery(QUERY_GET_CONFIRMED_FRIEND_USERIDS_FOR_USER);
q.setParameter(USER_UUID, userId, StringType.INSTANCE);
q.setBoolean("true", Boolean.TRUE);
q.setParameter("true", Boolean.TRUE);
return q.list();
};

Expand Down Expand Up @@ -779,7 +779,7 @@ public int getAllUnreadMessagesCount(final String userId) {
final HibernateCallback<Number> hcb = session -> {
final Query q = session.getNamedQuery(QUERY_GET_ALL_UNREAD_MESSAGES_COUNT);
q.setParameter(UUID, userId, StringType.INSTANCE);
q.setBoolean("false", Boolean.FALSE);
q.setParameter("false", Boolean.FALSE);
return (Number) q.uniqueResult();
};

Expand All @@ -795,7 +795,7 @@ public int getThreadsWithUnreadMessagesCount(final String userId) {
final HibernateCallback<Number> hcb = session -> {
final Query q = session.getNamedQuery(QUERY_GET_THREADS_WITH_UNREAD_MESSAGES_COUNT);
q.setParameter(UUID, userId, StringType.INSTANCE);
q.setBoolean("false", Boolean.FALSE);
q.setParameter("false", Boolean.FALSE);
return (Number) q.uniqueResult();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,28 @@

package org.sakaiproject.profile2.logic;

import java.io.Reader;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.sakaiproject.api.common.edu.person.SakaiPerson;
import org.sakaiproject.api.common.edu.person.SakaiPersonManager;
import org.sakaiproject.component.api.ServerConfigurationService;
import org.sakaiproject.entity.api.Entity;
import org.sakaiproject.entity.api.Reference;
import org.sakaiproject.event.api.Event;
import org.sakaiproject.profile2.logic.ProfilePrivacyLogic;
import org.sakaiproject.profile2.model.ProfilePrivacy;
import org.sakaiproject.profile2.util.ProfileConstants;
import org.sakaiproject.search.api.EntityContentProducer;
import org.sakaiproject.search.api.EntityContentProducerEvents;
import org.sakaiproject.search.api.SearchIndexBuilder;
import org.sakaiproject.search.api.SearchService;
import org.sakaiproject.search.api.SearchUtils;
import org.sakaiproject.search.model.SearchBuilderItem;
import org.sakaiproject.user.api.User;
import org.sakaiproject.user.api.UserDirectoryService;
import org.sakaiproject.user.api.UserNotDefinedException;

import java.io.Reader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public Person getPerson(User user) {
*/
@Override
public List<Person> getPersons(List<User> users) {
List<Person> list = new ArrayList();
List<Person> list = new ArrayList<>();
for (User u : users) {
list.add(getPerson(u));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import org.sakaiproject.profile2.logic.ProfileConnectionsLogic;
import org.sakaiproject.profile2.model.Person;

import org.sakaiproject.profile2.service.ProfileService;

/**
* A facade on the various logic component methods to improve backwards compatibility with
* clients of the older Profile2 apis. See PRFL-551.
Expand Down

0 comments on commit 0d606e9

Please sign in to comment.