org.hibernate.type.BooleanType Java Examples

The following examples show how to use org.hibernate.type.BooleanType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProfileDaoImpl.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
	 * {@inheritDoc}
	 */
@Override
public ProfileFriend getPendingConnection(final String userId, final String friendId) {
	
	if(userId == null || friendId == null){
  		throw new IllegalArgumentException("Null Argument in getPendingConnection"); 
  	}
	
	final HibernateCallback<ProfileFriend> hcb = session -> {
           final Query q = session.getNamedQuery(QUERY_GET_FRIEND_REQUEST);
           q.setParameter(USER_UUID, userId, StringType.INSTANCE);
           q.setParameter(FRIEND_UUID, friendId, StringType.INSTANCE);
           q.setParameter(CONFIRMED, false, BooleanType.INSTANCE);
           q.setMaxResults(1);
           return (ProfileFriend) q.uniqueResult();
     };

	return getHibernateTemplate().execute(hcb);
}
 
Example #2
Source File: ProfileDaoImpl.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
	 * {@inheritDoc}
	 */
@Override
public ProfileFriend getPendingConnection(final String userId, final String friendId) {
	
	if(userId == null || friendId == null){
  		throw new IllegalArgumentException("Null Argument in getPendingConnection"); 
  	}
	
	final HibernateCallback<ProfileFriend> hcb = session -> {
           final Query q = session.getNamedQuery(QUERY_GET_FRIEND_REQUEST);
           q.setParameter(USER_UUID, userId, StringType.INSTANCE);
           q.setParameter(FRIEND_UUID, friendId, StringType.INSTANCE);
           q.setParameter(CONFIRMED, false, BooleanType.INSTANCE);
           q.setMaxResults(1);
           return (ProfileFriend) q.uniqueResult();
     };

	return getHibernateTemplate().execute(hcb);
}
 
Example #3
Source File: PermissionManagerImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public ControlPermissions getAreaControlPermissionByRoleAndType(final String roleId, final String typeId, final boolean defaultValue) {
    log.debug("getAreaControlPermissionByRole executing for current user: " + getCurrentUser());
    final Area area = areaManager.getAreaByContextIdAndTypeId(typeId);
    if (area == null) {
        return null;
    }
    HibernateCallback<ControlPermissions> hcb = session -> {
        Query q = session.getNamedQuery(QUERY_CP_BY_ROLE);
        q.setParameter("roleId", roleId, StringType.INSTANCE);
        q.setParameter("areaId", area.getId().toString(), StringType.INSTANCE);
        q.setParameter("defaultValue", defaultValue, BooleanType.INSTANCE);
        return (ControlPermissions) q.uniqueResult();
    };
    return getHibernateTemplate().execute(hcb);
}
 
Example #4
Source File: PermissionManagerImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public MessagePermissions getAreaMessagePermissionByRoleAndType(final String roleId, final String typeId, final boolean defaultValue) {
    log.debug("getAreaMessagePermissionByRole executing for current user: " + getCurrentUser());
    final Area area = areaManager.getAreaByContextIdAndTypeId(typeId);
    if (area == null) {
        return null;
    }
    HibernateCallback<MessagePermissions> hcb = session -> {
        Query q = session.getNamedQuery(QUERY_MP_BY_ROLE);
        q.setParameter("roleId", roleId, StringType.INSTANCE);
        q.setParameter("areaId", area.getId().toString(), StringType.INSTANCE);
        q.setParameter("defaultValue", Boolean.valueOf(defaultValue), BooleanType.INSTANCE);
        return (MessagePermissions) q.uniqueResult();
    };
    return getHibernateTemplate().execute(hcb);
}
 
Example #5
Source File: PermissionManagerImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
private MessagePermissions getMessagePermissionByKeyValue(final String roleId, final String key, final String value, final boolean defaultValue) {
    log.debug("getAreaMessagePermissionByRole executing for current user: " + getCurrentUser());
    HibernateCallback<MessagePermissions> hcb = session -> {
        String queryString = "forumId".equals(key) ? QUERY_MP_BY_FORUM : QUERY_MP_BY_TOPIC;
        Query q = session.getNamedQuery(queryString);
        q.setParameter("roleId", roleId, StringType.INSTANCE);
        q.setParameter(key, value, StringType.INSTANCE);
        q.setParameter("defaultValue", defaultValue, BooleanType.INSTANCE);
        return (MessagePermissions) q.uniqueResult();
    };
    return getHibernateTemplate().execute(hcb);
}
 
Example #6
Source File: PermissionManagerImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
private ControlPermissions getControlPermissionByKeyValue(final String roleId, final String key, final String value, final boolean defaultValue) {
    log.debug("getAreaControlPermissionByRole executing for current user: " + getCurrentUser());
    HibernateCallback<ControlPermissions> hcb = session -> {
        String queryString = "forumId".equals(key) ? QUERY_CP_BY_FORUM : QUERY_CP_BY_TOPIC;
        Query q = session.getNamedQuery(queryString);
        q.setParameter("roleId", roleId, StringType.INSTANCE);
        q.setParameter(key, value, StringType.INSTANCE);
        q.setParameter("defaultValue", defaultValue, BooleanType.INSTANCE);
        return (ControlPermissions) q.uniqueResult();
    };
    return getHibernateTemplate().execute(hcb);
}
 
Example #7
Source File: PermissionManagerImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public ControlPermissions getAreaControlPermissionByRoleAndType(final String roleId, final String typeId, final boolean defaultValue) {
    log.debug("getAreaControlPermissionByRole executing for current user: " + getCurrentUser());
    final Area area = areaManager.getAreaByContextIdAndTypeId(typeId);
    if (area == null) {
        return null;
    }
    HibernateCallback<ControlPermissions> hcb = session -> {
        Query q = session.getNamedQuery(QUERY_CP_BY_ROLE);
        q.setParameter("roleId", roleId, StringType.INSTANCE);
        q.setParameter("areaId", area.getId().toString(), StringType.INSTANCE);
        q.setParameter("defaultValue", defaultValue, BooleanType.INSTANCE);
        return (ControlPermissions) q.uniqueResult();
    };
    return getHibernateTemplate().execute(hcb);
}
 
Example #8
Source File: SessionRestore.java    From unitime with Apache License 2.0 5 votes vote down vote up
protected Object get(Class clazz, String id) {
	if (clazz.equals(String.class) || clazz.equals(StringType.class)) return id;
	if (clazz.equals(Character.class) || clazz.equals(CharacterType.class)) return (id == null || id.isEmpty() ? null : id.charAt(0));
	if (clazz.equals(Byte.class) || clazz.equals(ByteType.class)) return Byte.valueOf(id);
	if (clazz.equals(Short.class) || clazz.equals(ShortType.class)) return Short.valueOf(id);
	if (clazz.equals(Integer.class) || clazz.equals(IntegerType.class)) return Integer.valueOf(id);
	if (clazz.equals(Long.class) || clazz.equals(LongType.class)) return Long.valueOf(id);
	if (clazz.equals(Float.class) || clazz.equals(FloatType.class)) return Float.valueOf(id);
	if (clazz.equals(Double.class) || clazz.equals(DoubleType.class)) return Double.valueOf(id);
	if (clazz.equals(Boolean.class) || clazz.equals(BooleanType.class)) return Boolean.valueOf(id);
	
	Map<String, Entity> entities = iEntities.get(clazz.getName());
	if (entities != null) {
		Entity entity = entities.get(id);
		if (entity != null) return entity.getObject();
	}
       for (Map.Entry<String, Map<String, Entity>> entry: iEntities.entrySet()) {
       	Entity o = entry.getValue().get(id);
       	if (o != null && clazz.isInstance(o.getObject())) return o.getObject();
	}
       if (clazz.equals(Session.class))
       	return ((Entity)iEntities.get(Session.class.getName()).values().iterator().next()).getObject();
       if (clazz.equals(Student.class))
       	return checkUnknown(clazz, id, iStudents.get(id));
       if (iIsClone)
       	return checkUnknown(clazz, id,
       			iHibSession.get(clazz, clazz.equals(ItypeDesc.class) ? (Serializable) Integer.valueOf(id) : (Serializable) Long.valueOf(id)));
       return checkUnknown(clazz, id, null);
}
 
Example #9
Source File: PermissionManagerImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public MessagePermissions getAreaMessagePermissionByRoleAndType(final String roleId, final String typeId, final boolean defaultValue) {
    log.debug("getAreaMessagePermissionByRole executing for current user: " + getCurrentUser());
    final Area area = areaManager.getAreaByContextIdAndTypeId(typeId);
    if (area == null) {
        return null;
    }
    HibernateCallback<MessagePermissions> hcb = session -> {
        Query q = session.getNamedQuery(QUERY_MP_BY_ROLE);
        q.setParameter("roleId", roleId, StringType.INSTANCE);
        q.setParameter("areaId", area.getId().toString(), StringType.INSTANCE);
        q.setParameter("defaultValue", Boolean.valueOf(defaultValue), BooleanType.INSTANCE);
        return (MessagePermissions) q.uniqueResult();
    };
    return getHibernateTemplate().execute(hcb);
}
 
Example #10
Source File: PermissionManagerImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
private MessagePermissions getMessagePermissionByKeyValue(final String roleId, final String key, final String value, final boolean defaultValue) {
    log.debug("getAreaMessagePermissionByRole executing for current user: " + getCurrentUser());
    HibernateCallback<MessagePermissions> hcb = session -> {
        String queryString = "forumId".equals(key) ? QUERY_MP_BY_FORUM : QUERY_MP_BY_TOPIC;
        Query q = session.getNamedQuery(queryString);
        q.setParameter("roleId", roleId, StringType.INSTANCE);
        q.setParameter(key, value, StringType.INSTANCE);
        q.setParameter("defaultValue", defaultValue, BooleanType.INSTANCE);
        return (MessagePermissions) q.uniqueResult();
    };
    return getHibernateTemplate().execute(hcb);
}
 
Example #11
Source File: PermissionManagerImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
private ControlPermissions getControlPermissionByKeyValue(final String roleId, final String key, final String value, final boolean defaultValue) {
    log.debug("getAreaControlPermissionByRole executing for current user: " + getCurrentUser());
    HibernateCallback<ControlPermissions> hcb = session -> {
        String queryString = "forumId".equals(key) ? QUERY_CP_BY_FORUM : QUERY_CP_BY_TOPIC;
        Query q = session.getNamedQuery(queryString);
        q.setParameter("roleId", roleId, StringType.INSTANCE);
        q.setParameter(key, value, StringType.INSTANCE);
        q.setParameter("defaultValue", defaultValue, BooleanType.INSTANCE);
        return (ControlPermissions) q.uniqueResult();
    };
    return getHibernateTemplate().execute(hcb);
}
 
Example #12
Source File: PostgreSQLFTSFunction.java    From blog-tutorials with MIT License 4 votes vote down vote up
@Override
public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
	return new BooleanType();
}
 
Example #13
Source File: BooleanLiteralNode.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public BooleanType getTypeInternal() {
	return ( BooleanType ) getDataType();
}
 
Example #14
Source File: PostgreSQLPlainToTSQueryFunction.java    From JuniperBot with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Type getReturnType(Type columnType, Mapping mapping)
        throws QueryException {
    return BooleanType.INSTANCE;
}
 
Example #15
Source File: VoteUsrAttemptDAO.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
   @SuppressWarnings("unchecked")
   /**
    * Gets the details about an open text entry. Either sessionUid or toolContentId must be supplied - if sessionUid is
    * supplied
    * then it will be restricted to that session. Due to the large number of fields needed, a DTO will be returned.
    *
    * Will return List<OpenTextAnswerDTO>
    */
   public List<OpenTextAnswerDTO> getUserOpenTextAttemptsForTablesorter(Long sessionUid, Long toolContentId, int page,
    int size, int sorting, String searchStringVote, String searchStringUsername,
    IUserManagementService userManagementService) {
String sortingOrder;
switch (sorting) {
    case VoteAppConstants.SORT_BY_NAME_ASC:
	sortingOrder = "user.fullname ASC";
	break;
    case VoteAppConstants.SORT_BY_NAME_DESC:
	sortingOrder = "user.fullname DESC";
	break;
    case VoteAppConstants.SORT_BY_DATE_ASC:
	sortingOrder = "attempt.attempt_time ASC";
	break;
    case VoteAppConstants.SORT_BY_DATE_DESC:
	sortingOrder = "attempt.attempt_time DESC";
	break;
    case VoteAppConstants.SORT_BY_ENTRY_ASC:
	sortingOrder = "attempt.userEntry ASC";
	break;
    case VoteAppConstants.SORT_BY_ENTRY_DESC:
	sortingOrder = "attempt.userEntry DESC";
	break;
    case VoteAppConstants.SORT_BY_VISIBLE_ASC:
	sortingOrder = "attempt.visible ASC";
	break;
    case VoteAppConstants.SORT_BY_VISIBLE_DESC:
	sortingOrder = "attempt.visible DESC";
	break;
    default:
	sortingOrder = "user.uid";
}

String[] portraitStrings = userManagementService.getPortraitSQL("user.user_id");

// Basic select for the user records
StringBuilder queryText = new StringBuilder(FIND_USER_OPEN_TEXT_SELECT).append(portraitStrings[0])
	.append(FIND_USER_OPEN_TEXT_FROM);

if (sessionUid != null) {
    queryText.append(FIND_USER_OPEN_TEXT_SESSION_UID_ADD);
} else {
    queryText.append(FIND_USER_OPEN_TEXT_CONTENT_UID_ADD);
}
queryText.append(portraitStrings[1]);

// If filtering by name/entry add a where clause
buildCombinedSearch(searchStringVote, searchStringUsername, queryText);

// Now specify the sort based on the switch statement above.
queryText.append(" ORDER BY " + sortingOrder);

NativeQuery<OpenTextAnswerDTO> query = getSession().createSQLQuery(queryText.toString());
query.addScalar("userUid", LongType.INSTANCE).addScalar("login", StringType.INSTANCE)
	.addScalar("fullName", StringType.INSTANCE).addScalar("userEntryUid", LongType.INSTANCE)
	.addScalar("userEntry", StringType.INSTANCE).addScalar("attemptTime", TimestampType.INSTANCE)
	.addScalar("visible", BooleanType.INSTANCE).addScalar("portraitId", LongType.INSTANCE)
	.setFirstResult(page * size).setMaxResults(size)
	.setResultTransformer(Transformers.aliasToBean(OpenTextAnswerDTO.class));

if (sessionUid != null) {
    query.setParameter("sessionUid", sessionUid);
} else {
    query.setParameter("toolContentId", toolContentId);
}

return query.list();
   }
 
Example #16
Source File: Query.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Bind a named boolean-valued parameter.
 *
 * @param name The parameter name
 * @param val The bind value
 *
 * @return {@code this}, for method chaining
 *
 * @deprecated (since 5.2) use {@link #setParameter(String, Object)} or {@link #setParameter(String, Object, Type)}
 * instead
 */
@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setBoolean(String name, boolean val) {
	setParameter( name, val, determineProperBooleanType( name, val, BooleanType.INSTANCE ) );
	return this;
}
 
Example #17
Source File: Query.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Bind a positional boolean-valued parameter.
 *
 * @param position The parameter position
 * @param val The bind value
 *
 * @return {@code this}, for method chaining
 *
 * @deprecated (since 5.2) use {@link #setParameter(int, Object)} or {@link #setParameter(int, Object, Type)}
 * instead
 */
@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setBoolean(int position, boolean val) {
	setParameter( position, val, determineProperBooleanType( position, val, BooleanType.INSTANCE ) );
	return this;
}
 
Example #18
Source File: Query.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Bind a named boolean-valued parameter.
 *
 * @param name The parameter name
 * @param val The bind value
 *
 * @return {@code this}, for method chaining
 *
 * @deprecated (since 5.2) use {@link #setParameter(int, Object)} or {@link #setParameter(int, Object, Type)}
 * instead
 */
@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setBoolean(String name, boolean val) {
	setParameter( name, val, determineProperBooleanType( name, val, BooleanType.INSTANCE ) );
	return this;
}
 
Example #19
Source File: Query.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Bind a positional boolean-valued parameter.
 *
 * @param position The parameter position
 * @param val The bind value
 *
 * @return {@code this}, for method chaining
 *
 * @deprecated (since 5.2) use {@link #setParameter(int, Object)} or {@link #setParameter(int, Object, Type)}
 * instead
 */
@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setBoolean(int position, boolean val) {
	setParameter( position, val, determineProperBooleanType( position, val, BooleanType.INSTANCE ) );
	return this;
}