agave-systems/systems-core/src/main/java/org/iplantc/service/systems/dao/SystemDao.java
/**
     * Returns the system of the specified type that the user set as
     * their default. This will not include public systems that are
     * global defaults. These need to be manually added if missing.
     *
     * @param type
     * @return RemoteSystem
     */
Returns the system of the specified type that the user set as
their default. This will not include public systems that are
global defaults. These need to be manually added if missing.

@param type
@return RemoteSystem
Returns the system of the specified type that the user set as their default . This will not include public systems that are global defaults . These need to be manually added if missing . @param type @return RemoteSystem
public RemoteSystem findUserDefaultSystem(String apiUsername, RemoteSystemType type) {
        try {
            Session session = getSession();
            session.clear();
            String hql = "SELECT s "
                    + "FROM RemoteSystem s "
                    + "WHERE s.type = :type "
                    + "AND s.available = :available "
                    + "AND s.publiclyAvailable = :publiclyAvail "
                    + "AND s.globalDefault = :globalDefault "
                    + "AND :username in elements( s.usersUsingAsDefault) ";
            RemoteSystem defaultSystem = (RemoteSystem) session.createQuery(hql)
                    .setString("username", apiUsername)
                    .setParameter("type", type)
                    .setBoolean("available", true)
                    .setBoolean("publiclyAvail", false)
                    .setBoolean("globalDefault", false)
                    .setMaxResults(1)
                    .uniqueResult();
            session.flush();
            return defaultSystem;
        } catch (ObjectNotFoundException ex) {
            return null;
        } catch (HibernateException ex) {
            throw ex;
        } finally {
            try {
                HibernateUtil.commitTransaction();
            } catch (Exception ignored) {
            }
        }
    }
public RemoteSystem findUserDefaultSystem ( String apiUsername , RemoteSystemType type ) { try { Session session = getSession ( ) ; session . clear ( ) ; String hql = "SELECT s " + "FROM RemoteSystem s " + "WHERE s.type = :type " + "AND s.available = :available " + "AND s.publiclyAvailable = :publiclyAvail " + "AND s.globalDefault = :globalDefault " + "AND :username in elements( s.usersUsingAsDefault) " ; RemoteSystem defaultSystem = ( RemoteSystem ) session . createQuery ( hql ) . setString ( "username" , apiUsername ) . setParameter ( "type" , type ) . setBoolean ( "available" , true ) . setBoolean ( "publiclyAvail" , false ) . setBoolean ( "globalDefault" , false ) . setMaxResults ( 1 ) . uniqueResult ( ) ; session . flush ( ) ; return defaultSystem ; } catch ( ObjectNotFoundException ex ) { return null ; } catch ( HibernateException ex ) { throw ex ; } finally { try { HibernateUtil . commitTransaction ( ) ; } catch ( Exception ignored ) { } } }
Returns the system of the specified type that the user set as
 their default.
Returns the system of the specified type that the user set as their default .