use of org.geosdi.geoplatform.core.model.GPUser in project geo-platform by geosdi.
the class GPAccountDAOImpl method findByEmail.
/**
* @param email
* @return {@link GPUser}
* @throws Exception
*/
@Override
public GPUser findByEmail(String email) throws GPDAOException {
checkArgument((email != null) && !(email.trim().isEmpty()), "The Parameter email must not be null or an empty String.");
try {
CriteriaBuilder builder = super.criteriaBuilder();
CriteriaQuery<GPAccount> criteriaQuery = super.createCriteriaQuery();
Root<GPAccount> root = criteriaQuery.from(this.persistentClass);
Root<GPUser> userRoot = builder.treat(root, GPUser.class);
criteriaQuery.select(root);
criteriaQuery.where(super.criteriaBuilder().equal(userRoot.get("emailAddress"), email));
List<GPAccount> accounts = this.entityManager.createQuery(criteriaQuery).getResultList();
return ((accounts != null) && !(accounts.isEmpty()) ? (GPUser) accounts.get(0) : null);
} catch (Exception ex) {
ex.printStackTrace();
throw new GPDAOException(ex);
}
}
use of org.geosdi.geoplatform.core.model.GPUser in project geo-platform by geosdi.
the class GPAccountDAOImpl method searchPagebleUsersByOrganization.
/**
* @param page
* @param size
* @param organizationName
* @param userID
* @param nameLike
* @return {@link List<GPAccount>}
* @throws GPDAOException
*/
@Override
public List<GPAccount> searchPagebleUsersByOrganization(Integer page, Integer size, String organizationName, Long userID, String nameLike) throws GPDAOException {
checkArgument((organizationName != null) && !(organizationName.trim().isEmpty()), "The Paramater organizationName must not be null or an Empty String.");
checkArgument(userID != null, "The Parameter userID must not be null.");
try {
CriteriaBuilder builder = super.criteriaBuilder();
CriteriaQuery<GPAccount> criteriaQuery = super.createCriteriaQuery();
Root<GPAccount> root = criteriaQuery.from(this.persistentClass);
Root<GPUser> userRoot = builder.treat(root, GPUser.class);
criteriaQuery.select(root);
List<Predicate> predicates = Lists.newArrayList();
if ((nameLike != null) && !(nameLike.trim().isEmpty()))
predicates.add(builder.like(builder.lower(userRoot.get("username")), nameLike.toLowerCase()));
predicates.add(builder.equal(root.join("organization").get("name"), organizationName));
predicates.add(builder.notEqual(root.get("id"), userID));
predicates.add(builder.isNotNull(userRoot.get("username")));
criteriaQuery.where(predicates.stream().toArray(s -> new Predicate[s])).orderBy(builder.asc(userRoot.get("username")));
Query typedQuery = this.entityManager.createQuery(criteriaQuery);
Integer firstResult = (page == 0) ? 0 : ((page * size));
typedQuery.setFirstResult(firstResult);
typedQuery.setMaxResults(size);
return typedQuery.getResultList();
} catch (Exception ex) {
ex.printStackTrace();
throw new GPDAOException(ex);
}
}
use of org.geosdi.geoplatform.core.model.GPUser in project geo-platform by geosdi.
the class TestXmppMessage method setUp.
@Before
public void setUp() {
this.gpUser = new GPUser();
this.gpUser.setUsername("user");
}
use of org.geosdi.geoplatform.core.model.GPUser in project geo-platform by geosdi.
the class EmailJob method execute.
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
logger.debug("\n*** START send email job ***");
GPUser user = (GPUser) context.getTrigger().getJobDataMap().get(USER);
if (user == null) {
logger.trace("\n\n*** Warning there are no GPUser in Quarz trigger to send email {}", user);
} else {
logger.trace("\n\n*** {}", user);
}
this.sendEmail(user, context);
logger.debug("\n*** STOP send email job ***");
}
use of org.geosdi.geoplatform.core.model.GPUser in project geo-platform by geosdi.
the class ShortAccountDTOFactoryMassiveTest method createGPUser.
private GPUser createGPUser(int i) {
GPUser user = new GPUser();
user.setId(new Long(i));
user.setName("TEST" + i);
user.setUsername("TEST" + i);
user.setEmailAddress("user@test.it");
user.setSendEmail(Boolean.FALSE);
user.setOrganization(new GPOrganization("ORGANIZATION_TEST"));
user.setName("USER_TEST" + i);
return user;
}
Aggregations