Search in sources :

Example 21 with GPUser

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);
    }
}
Also used : GPAccount(org.geosdi.geoplatform.core.model.GPAccount) GPUser(org.geosdi.geoplatform.core.model.GPUser) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)

Example 22 with GPUser

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);
    }
}
Also used : GPAccount(org.geosdi.geoplatform.core.model.GPAccount) GPUser(org.geosdi.geoplatform.core.model.GPUser) Query(javax.persistence.Query) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)

Example 23 with GPUser

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");
}
Also used : GPUser(org.geosdi.geoplatform.core.model.GPUser) Before(org.junit.Before)

Example 24 with GPUser

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 ***");
}
Also used : GPUser(org.geosdi.geoplatform.core.model.GPUser)

Example 25 with GPUser

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;
}
Also used : GPUser(org.geosdi.geoplatform.core.model.GPUser) GPOrganization(org.geosdi.geoplatform.core.model.GPOrganization)

Aggregations

GPUser (org.geosdi.geoplatform.core.model.GPUser)33 Test (org.junit.Test)15 GPAccount (org.geosdi.geoplatform.core.model.GPAccount)8 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)7 InsertAccountRequest (org.geosdi.geoplatform.request.InsertAccountRequest)7 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)6 GPDAOException (org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)6 GPOrganization (org.geosdi.geoplatform.core.model.GPOrganization)4 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)4 UserDTO (org.geosdi.geoplatform.response.UserDTO)4 Query (javax.persistence.Query)3 ClientErrorException (javax.ws.rs.ClientErrorException)3 GPRestExceptionMessage (org.geosdi.geoplatform.exception.rs.GPRestExceptionMessage)3 PaginatedSearchRequest (org.geosdi.geoplatform.request.PaginatedSearchRequest)3 SearchRequest (org.geosdi.geoplatform.request.SearchRequest)3 ArrayList (java.util.ArrayList)2 GPApplication (org.geosdi.geoplatform.core.model.GPApplication)2 GPSessionTimeout (org.geosdi.geoplatform.gui.utility.GPSessionTimeout)2 UserDTOResponse (org.geosdi.geoplatform.response.UserDTOResponse)2 BasePagingLoadResult (com.extjs.gxt.ui.client.data.BasePagingLoadResult)1