⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 personalizationdataimpl.java

📁 esri的ArcGIS Server超级学习模板程序(for java)
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            LOG.error(ERROR_NULL_CURRENT_USER_OBJECT);
            throw new IllegalStateException(ERROR_NULL_CURRENT_USER_OBJECT);
        }

        List<IQuery> queries = new ArrayList<IQuery>();

        try {
            IQueryDAO dao = m_daoProfile.getQueryDAO();

            if (dao == null) {
                LOG.error(ERROR_NULL_QUERY_DAO_OBJECT);
                throw new IllegalArgumentException(ERROR_NULL_QUERY_DAO_OBJECT);
            }

            PageInfo pageInfo = new PageInfo();
            pageInfo.setPageIndex(page);
            pageInfo.setPageSize(pageSize);

            Criteria criteria = new Criteria();
            criteria.setUser(m_currentUser.getId().getUsername());

            List<QueryInfoRecord> records = dao.selectPage(criteria, pageInfo);

            if (records != null) {
                for (QueryInfoRecord record : records) {
                    queries.add(createQuery(record));
                }
            }

            return queries;
        } catch (PersonalizationDAOException e) {
            throw new PersonalizationException(PersonalizationException.Code.RETRIEVE_DATA_ERROR,
                e);
        }
    }

    /*
     * (non-Javadoc)
     * @see com.esri.solutions.jitk.personalization.data.IPersonalizationData#getQuery(java.util.UUID)
     */
    public IQuery getQuery(UUID id) throws PersonalizationException {
        if (id == null) {
            throw new NullPointerException();
        }

        if (m_daoProfile == null) {
            LOG.error(ERROR_NULL_PROFILE_OBJECT);
            throw new IllegalStateException(ERROR_NULL_PROFILE_OBJECT);
        }

        if (m_currentUser == null) {
            LOG.error(ERROR_NULL_CURRENT_USER_OBJECT);
            throw new IllegalStateException(ERROR_NULL_CURRENT_USER_OBJECT);
        }

        IQueryDAO dao = null;
        IQuery query = null;
        QueryInfoRecord rec = null;

        try {
            dao = m_daoProfile.getQueryDAO();

            if (dao == null) {
                LOG.error(ERROR_NULL_QUERY_DAO_OBJECT);
                throw new IllegalArgumentException(ERROR_NULL_QUERY_DAO_OBJECT);
            }

            rec = dao.selectOne(id.toString());
            query = createQuery(rec);

            return query;
        } catch (PersonalizationDAOException e) {
            throw new PersonalizationException(PersonalizationException.Code.RETRIEVE_DATA_ERROR,
                e);
        }
    }

    /*
     * (non-Javadoc)
     * @see com.esri.solutions.jitk.personalization.data.IPersonalizationData#getQueryCount()
     */
    public long getQueryCount() throws PersonalizationException {
        if (m_daoProfile == null) {
            LOG.error(ERROR_NULL_PROFILE_OBJECT);
            throw new IllegalStateException(ERROR_NULL_PROFILE_OBJECT);
        }

        if (m_currentUser == null) {
            LOG.error(ERROR_NULL_CURRENT_USER_OBJECT);
            throw new IllegalStateException(ERROR_NULL_CURRENT_USER_OBJECT);
        }

        try {
            IQueryDAO dao = m_daoProfile.getQueryDAO();

            if (dao == null) {
                LOG.error(ERROR_NULL_QUERY_DAO_OBJECT);
                throw new IllegalArgumentException(ERROR_NULL_QUERY_DAO_OBJECT);
            }

            Criteria criteria = null;
            criteria = new Criteria();
            criteria.setUser(m_currentUser.getId().getUsername());

            return dao.selectAllCount(criteria);
        } catch (PersonalizationDAOException e) {
            throw new PersonalizationException(PersonalizationException.Code.RETRIEVE_DATA_ERROR,
                e);
        }
    }

    /*
     * (non-Javadoc)
     * @see com.esri.solutions.jitk.personalization.data.IPersonalizationData#getCurrentUser()
     */
    public IUser getCurrentUser() {
        return m_currentUser;
    }

    /**
     * Sets the bean that manages the group of DAOs that will be used
     * to persist Personalization Data.  This bean will have a reference
     * to each DAO object (one for each personalization data type).
     *
     * @param profile Group of DAOs to use for persistence, cannot be <code>null</code>.
     * @throws NullPointerException                Thrown if the <code>profile</code>
     *                                                                         argument is <code>null</code>.
     */
    public void setPersonalizationDAOProfile(IPersonalizationDAOProfile profile) {
        if (profile == null) {
            throw new NullPointerException();
        }

        m_daoProfile = profile;
    }

    /**
     * Sets the User that should be associated with this Personalization Data.
     *
     * @param user
     *
     * @throws NullPointerException                Thrown if the <code>user</code> argument
     *                                                                         is <code>null</code>.
     */
    public void setCurrentUser(IUser user) {
        if (user == null) {
            throw new NullPointerException();
        }

        m_currentUser = user;
    }

    /*
     * (non-Javadoc)
     * @see com.esri.solutions.jitk.personalization.data.IDataFactory#createBookmark(com.esri.solutions.jitk.personalization.dao.BookmarkInfoRecord)
     */
    public IBookmark createBookmark(BookmarkInfoRecord rec)
        throws PersonalizationException {
        if (rec == null) {
            throw new NullPointerException();
        }

        if (m_daoProfile == null) {
            LOG.error(ERROR_NULL_PROFILE_OBJECT);
            throw new IllegalStateException(ERROR_NULL_PROFILE_OBJECT);
        }

        if (m_currentUser == null) {
            LOG.error(ERROR_NULL_CURRENT_USER_OBJECT);
            throw new IllegalStateException(ERROR_NULL_CURRENT_USER_OBJECT);
        }

        BookmarkImpl bookmark = new BookmarkImpl();
        bookmark.setBookmarkInfoRecord(rec);
        bookmark.setNew(false);
        bookmark.setPersonalizationDAOProfile(m_daoProfile);
        bookmark.setCurrentUser(m_currentUser);
        
        if ((rec.getMapCompositionId() != null) &&
                (rec.getMapCompositionId().trim().length() != 0)) {
            try {
                IMapCompositionDAO dao = m_daoProfile.getMapCompositionDAO();
                MapCompositionInfoRecord mcRec = dao.selectOne(rec.getMapCompositionId());

                if (mcRec != null) {
                    MapCompositionImpl mc = createMapCompositionImpl(mcRec);
                    bookmark.setMapComposition(mc);
                }
            } catch (PersonalizationDAOException e) {
                LOG.warn("", e);
            }
        }

        return bookmark;
    }

    /*
     * (non-Javadoc)
     * @see com.esri.solutions.jitk.personalization.data.IDataFactory#createQuery(com.esri.solutions.jitk.personalization.dao.QueryInfoRecord)
     */
    public IQuery createQuery(QueryInfoRecord rec)
        throws PersonalizationException {
        if (rec == null) {
            throw new NullPointerException();
        }

        if (m_daoProfile == null) {
            LOG.error(ERROR_NULL_PROFILE_OBJECT);
            throw new IllegalStateException(ERROR_NULL_PROFILE_OBJECT);
        }

        if (m_currentUser == null) {
            LOG.error(ERROR_NULL_CURRENT_USER_OBJECT);
            throw new IllegalStateException(ERROR_NULL_CURRENT_USER_OBJECT);
        }

        QueryImpl query = new QueryImpl();
        query.setQueryInfoRecord(rec);
        query.setNew(false);
        query.setPersonalizationDAOProfile(m_daoProfile);

        if (rec.getQueryType() == 0) {
            query.setType(IQuery.Type.FEATURE);
        } else if (rec.getQueryType() == 1) {
            query.setType(IQuery.Type.CATALOG);
        }

        query.setCurrentUser(m_currentUser);

        if ((rec.getMapCompositionId() != null) &&
                (rec.getMapCompositionId().trim().length() != 0)) {
            try {
                IMapCompositionDAO dao = m_daoProfile.getMapCompositionDAO();
                MapCompositionInfoRecord mcRec = dao.selectOne(rec.getMapCompositionId());

                MapCompositionImpl mc = createMapCompositionImpl(mcRec);
                query.setMapComposition(mc);
            } catch (PersonalizationDAOException e) {
                String msg = java.text.MessageFormat.format(WARN_UNABLE_TO_RETRIEVE_QUERY_MAP_COMP,
                        rec.getMapCompositionId(), rec.getId());

                LOG.warn(msg, e);
            }
        }

        return query;
    }

    /*
     * (non-Javadoc)
     * @see com.esri.solutions.jitk.personalization.data.IDataFactory#createBookmark(com.esri.solutions.jitk.personalization.data.IMapComposition)
     */
    public IBookmark createBookmark(IMapComposition mc)
        throws PersonalizationException {
        if (mc == null) {
            throw new NullPointerException();
        }

        if (m_daoProfile == null) {
            LOG.error(ERROR_NULL_PROFILE_OBJECT);
            throw new IllegalStateException(ERROR_NULL_PROFILE_OBJECT);
        }

        if (m_currentUser == null) {
            LOG.error(ERROR_NULL_CURRENT_USER_OBJECT);
            throw new IllegalStateException(ERROR_NULL_CURRENT_USER_OBJECT);
        }

        BookmarkImpl bookmark = null;

        bookmark = new BookmarkImpl();
        bookmark.setNew(true);
        bookmark.setMapComposition((MapCompositionImpl) mc);
        bookmark.setPersonalizationDAOProfile(m_daoProfile);
        bookmark.setCurrentUser(m_currentUser);

        return bookmark;
    }

    /*
     * (non-Javadoc)
     * @see com.esri.solutions.jitk.personalization.data.IDataFactory#createQuery(com.esri.solutions.jitk.personalization.data.IMapComposition)
     */
    public IQuery createQuery(IMapComposition mc, IQuery.Type type)
        throws PersonalizationException {
        if (mc == null) {
            throw new NullPointerException();
        }

        if (m_daoProfile == null) {
            LOG.error(ERROR_NULL_PROFILE_OBJECT);
            throw new IllegalStateException(ERROR_NULL_PROFILE_OBJECT);
        }

        if (m_currentUser == null) {
            LOG.error(ERROR_NULL_CURRENT_USER_OBJECT);
            throw new IllegalStateException(ERROR_NULL_CURRENT_USER_OBJECT);
        }

        QueryImpl query = null;

        query = new QueryImpl();
        query.setNew(true);
        query.setMapComposition((MapCompositionImpl) mc);
        query.setPersonalizationDAOProfile(m_daoProfile);
        query.setCurrentUser(m_currentUser);
        query.setType(type);

        return query;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -