Merged DEV/SWIFT to HEAD

25466: ALF-5260 - MyBatis: partial - initially Activities (-> MySQL)
   Note: Subsystem changes and new feed methods resolved


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28001 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2011-05-24 03:36:53 +00:00
parent 00b8f4a002
commit a42c7cf11a
13 changed files with 238 additions and 271 deletions

View File

@@ -386,6 +386,8 @@ public abstract class FeedTaskProcessor
public abstract void commitTransaction() throws SQLException;
public abstract void rollbackTransaction() throws SQLException;
public abstract void endTransaction() throws SQLException;
public abstract List<ActivityPostEntity> selectPosts(ActivityPostEntity selector) throws SQLException;

View File

@@ -55,8 +55,6 @@ import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import com.ibatis.sqlmap.client.SqlMapClient;
import freemarker.template.Configuration;
import freemarker.template.DefaultObjectWrapper;
@@ -80,12 +78,8 @@ public class LocalFeedTaskProcessor extends FeedTaskProcessor implements Applica
private String defaultEncoding;
private List<String> templateSearchPaths;
private boolean useRemoteCallbacks;
private ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
private ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
// used to start/end/commit transaction
// note: currently assumes that all dao services are configured with this mapper / data source
private SqlMapClient sqlMapper;
public void setPostDAO(ActivityPostDAO postDAO)
{
this.postDAO = postDAO;
@@ -136,29 +130,29 @@ public class LocalFeedTaskProcessor extends FeedTaskProcessor implements Applica
this.useRemoteCallbacks = useRemoteCallbacks;
}
public void setSqlMapClient(SqlMapClient sqlMapper)
{
this.sqlMapper = sqlMapper;
}
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
{
this.resolver = applicationContext;
}
public void startTransaction() throws SQLException
{
sqlMapper.startTransaction();
// NOOP
}
public void commitTransaction() throws SQLException
{
sqlMapper.commitTransaction();
// NOOP
}
public void rollbackTransaction() throws SQLException
{
// NOOP
}
public void endTransaction() throws SQLException
{
sqlMapper.endTransaction();
// NOOP
}
public List<ActivityPostEntity> selectPosts(ActivityPostEntity selector) throws SQLException

View File

@@ -29,5 +29,7 @@ public interface ActivitiesDAO
public void commitTransaction() throws SQLException;
public void rollbackTransaction() throws SQLException;
public void endTransaction() throws SQLException;
}

View File

@@ -21,35 +21,27 @@ package org.alfresco.repo.domain.activities.ibatis;
import java.sql.SQLException;
import org.alfresco.repo.domain.activities.ActivitiesDAO;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import com.ibatis.sqlmap.client.SqlMapClient;
public class IBatisSqlMapper implements ActivitiesDAO
public class ActivitiesSqlSessionDaoSupport extends SqlSessionDaoSupport implements ActivitiesDAO
{
private SqlMapClient sqlMapper;
public void setSqlMapClient(SqlMapClient sqlMapper)
{
this.sqlMapper = sqlMapper;
}
public SqlMapClient getSqlMapClient()
{
return this.sqlMapper;
}
public void startTransaction() throws SQLException
{
sqlMapper.startTransaction();
// NOOP
}
public void commitTransaction() throws SQLException
{
sqlMapper.commitTransaction();
// NOOP
}
public void rollbackTransaction() throws SQLException
{
// NOOP
}
public void endTransaction() throws SQLException
{
sqlMapper.endTransaction();
// NOOP
}
}

View File

@@ -1,19 +1,19 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.domain.activities.ibatis;
@@ -27,20 +27,20 @@ import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.domain.activities.ActivityFeedDAO;
import org.alfresco.repo.domain.activities.ActivityFeedEntity;
import org.alfresco.repo.domain.activities.ActivityFeedQueryEntity;
import org.apache.ibatis.session.RowBounds;
import com.ibatis.sqlmap.engine.execution.SqlExecutor;
public class ActivityFeedDAOImpl extends IBatisSqlMapper implements ActivityFeedDAO
public class ActivityFeedDAOImpl extends ActivitiesSqlSessionDaoSupport implements ActivityFeedDAO
{
public long insertFeedEntry(ActivityFeedEntity activityFeed) throws SQLException
{
Long id = (Long)getSqlMapClient().insert("alfresco.activities.insert_activity_feed", activityFeed);
getSqlSession().insert("alfresco.activities.insert.insert_activity_feed", activityFeed);
Long id = activityFeed.getId();
return (id != null ? id : -1);
}
public int deleteFeedEntries(Date keepDate) throws SQLException
{
return getSqlMapClient().delete("alfresco.activities.delete_activity_feed_entries_older_than_date", keepDate);
return getSqlSession().delete("alfresco.activities.delete_activity_feed_entries_older_than_date", keepDate);
}
public int deleteSiteFeedEntries(String siteId) throws SQLException
@@ -48,7 +48,7 @@ public class ActivityFeedDAOImpl extends IBatisSqlMapper implements ActivityFeed
ActivityFeedEntity params = new ActivityFeedEntity();
params.setSiteNetwork(siteId);
return getSqlMapClient().delete("alfresco.activities.delete_activity_feed_for_site_entries", params);
return getSqlSession().delete("alfresco.activities.delete_activity_feed_for_site_entries", params);
}
public int deleteSiteFeedEntries(String siteId, String format, Date keepDate) throws SQLException
@@ -58,7 +58,7 @@ public class ActivityFeedDAOImpl extends IBatisSqlMapper implements ActivityFeed
params.setActivitySummaryFormat(format);
params.setPostDate(keepDate);
return getSqlMapClient().delete("alfresco.activities.delete_activity_feed_for_site_entries_older_than_date", params);
return getSqlSession().delete("alfresco.activities.delete_activity_feed_for_site_entries_older_than_date", params);
}
@@ -69,7 +69,7 @@ public class ActivityFeedDAOImpl extends IBatisSqlMapper implements ActivityFeed
params.setActivitySummaryFormat(format);
params.setPostDate(keepDate);
return getSqlMapClient().delete("alfresco.activities.delete_activity_feed_for_feeduser_entries_older_than_date", params);
return getSqlSession().delete("alfresco.activities.delete_activity_feed_for_feeduser_entries_older_than_date", params);
}
public int deleteUserFeedEntries(String feedUserId) throws SQLException
@@ -77,13 +77,13 @@ public class ActivityFeedDAOImpl extends IBatisSqlMapper implements ActivityFeed
ActivityFeedEntity params = new ActivityFeedEntity();
params.setFeedUserId(feedUserId);
return getSqlMapClient().delete("alfresco.activities.delete_activity_feed_for_feeduser_entries", params);
return getSqlSession().delete("alfresco.activities.delete_activity_feed_for_feeduser_entries", params);
}
@SuppressWarnings("unchecked")
public List<ActivityFeedEntity> selectFeedsToClean(int maxFeedSize) throws SQLException
{
return (List<ActivityFeedEntity>)getSqlMapClient().queryForList("alfresco.activities.select_activity_feed_greater_than_max", maxFeedSize);
return (List<ActivityFeedEntity>)getSqlSession().selectList("alfresco.activities.select_activity_feed_greater_than_max", maxFeedSize);
}
@SuppressWarnings("unchecked")
@@ -98,10 +98,8 @@ public class ActivityFeedDAOImpl extends IBatisSqlMapper implements ActivityFeed
params.setMinId(minFeedId);
}
if (maxFeedSize < 0)
{
maxFeedSize = SqlExecutor.NO_MAXIMUM_RESULTS;
}
int rowLimit = maxFeedSize < 0 ? RowBounds.NO_ROW_LIMIT : maxFeedSize;
RowBounds rowBounds = new RowBounds(RowBounds.NO_ROW_OFFSET, rowLimit);
if (siteId != null)
{
@@ -116,17 +114,17 @@ public class ActivityFeedDAOImpl extends IBatisSqlMapper implements ActivityFeed
if ((!excludeThisUser) && (!excludeOtherUsers))
{
// no excludes => everyone => where feed user is me
return (List<ActivityFeedEntity>)getSqlMapClient().queryForList("alfresco.activities.select_activity_feed_for_feeduser_and_site", params, 0, maxFeedSize);
return (List<ActivityFeedEntity>)getSqlSession().selectList("alfresco.activities.select_activity_feed_for_feeduser_and_site", params, rowBounds);
}
else if ((excludeThisUser) && (!excludeOtherUsers))
{
// exclude feed user => others => where feed user is me and post user is not me
return (List<ActivityFeedEntity>)getSqlMapClient().queryForList("alfresco.activities.select_activity_feed_for_feeduser_others_and_site", params, 0, maxFeedSize);
return (List<ActivityFeedEntity>)getSqlSession().selectList("alfresco.activities.select_activity_feed_for_feeduser_others_and_site", params, rowBounds);
}
else if ((excludeOtherUsers) && (!excludeThisUser))
{
// exclude others => me => where feed user is me and post user is me
return (List<ActivityFeedEntity>)getSqlMapClient().queryForList("alfresco.activities.select_activity_feed_for_feeduser_me_and_site", params, 0, maxFeedSize);
return (List<ActivityFeedEntity>)getSqlSession().selectList("alfresco.activities.select_activity_feed_for_feeduser_me_and_site", params, rowBounds);
}
}
else
@@ -141,17 +139,17 @@ public class ActivityFeedDAOImpl extends IBatisSqlMapper implements ActivityFeed
if (!excludeThisUser && !excludeOtherUsers)
{
// no excludes => everyone => where feed user is me
return (List<ActivityFeedEntity>)getSqlMapClient().queryForList("alfresco.activities.select_activity_feed_for_feeduser", params, 0, maxFeedSize);
return (List<ActivityFeedEntity>)getSqlSession().selectList("alfresco.activities.select_activity_feed_for_feeduser", params, rowBounds);
}
else if (excludeThisUser)
{
// exclude feed user => others => where feed user is me and post user is not me
return (List<ActivityFeedEntity>)getSqlMapClient().queryForList("alfresco.activities.select_activity_feed_for_feeduser_others", params, 0, maxFeedSize);
return (List<ActivityFeedEntity>)getSqlSession().selectList("alfresco.activities.select_activity_feed_for_feeduser_others", params, rowBounds);
}
else if (excludeOtherUsers)
{
// exclude others => me => where feed user is me and post user is me
return (List<ActivityFeedEntity>)getSqlMapClient().queryForList("alfresco.activities.select_activity_feed_for_feeduser_me", params, 0, maxFeedSize);
return (List<ActivityFeedEntity>)getSqlSession().selectList("alfresco.activities.select_activity_feed_for_feeduser_me", params, rowBounds);
}
}
@@ -166,12 +164,10 @@ public class ActivityFeedDAOImpl extends IBatisSqlMapper implements ActivityFeed
params.setSiteNetwork(siteId);
params.setActivitySummaryFormat(format);
if (maxFeedSize < 0)
{
maxFeedSize = SqlExecutor.NO_MAXIMUM_RESULTS;
}
int rowLimit = maxFeedSize < 0 ? RowBounds.NO_ROW_LIMIT : maxFeedSize;
RowBounds rowBounds = new RowBounds(RowBounds.NO_ROW_OFFSET, rowLimit);
// for given site
return (List<ActivityFeedEntity>)getSqlMapClient().queryForList("alfresco.activities.select_activity_feed_for_site", params, 0, maxFeedSize);
return (List<ActivityFeedEntity>)getSqlSession().selectList("alfresco.activities.select_activity_feed_for_site", params, rowBounds);
}
}

View File

@@ -1,19 +1,19 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.domain.activities.ibatis;
@@ -26,7 +26,7 @@ import java.util.List;
import org.alfresco.repo.domain.activities.ActivityPostDAO;
import org.alfresco.repo.domain.activities.ActivityPostEntity;
public class ActivityPostDAOImpl extends IBatisSqlMapper implements ActivityPostDAO
public class ActivityPostDAOImpl extends ActivitiesSqlSessionDaoSupport implements ActivityPostDAO
{
@SuppressWarnings("unchecked")
public List<ActivityPostEntity> selectPosts(ActivityPostEntity activityPost) throws SQLException
@@ -36,11 +36,11 @@ public class ActivityPostDAOImpl extends IBatisSqlMapper implements ActivityPost
(activityPost.getMaxId() != -1) &&
(activityPost.getStatus() != null))
{
return (List<ActivityPostEntity>)getSqlMapClient().queryForList("alfresco.activities.select_activity_posts", activityPost);
return (List<ActivityPostEntity>)getSqlSession().selectList("alfresco.activities.select_activity_posts", activityPost);
}
else if (activityPost.getStatus() != null)
{
return (List<ActivityPostEntity>)getSqlMapClient().queryForList("alfresco.activities.select_activity_posts_by_status_only", activityPost);
return (List<ActivityPostEntity>)getSqlSession().selectList("alfresco.activities.select_activity_posts_by_status_only", activityPost);
}
else
{
@@ -50,17 +50,17 @@ public class ActivityPostDAOImpl extends IBatisSqlMapper implements ActivityPost
public Long getMaxActivitySeq() throws SQLException
{
return (Long)getSqlMapClient().queryForObject("alfresco.activities.select_activity_post_max_seq");
return (Long)getSqlSession().selectOne("alfresco.activities.select_activity_post_max_seq");
}
public Long getMinActivitySeq() throws SQLException
{
return (Long)getSqlMapClient().queryForObject("alfresco.activities.select_activity_post_min_seq");
return (Long)getSqlSession().selectOne("alfresco.activities.select_activity_post_min_seq");
}
public Integer getMaxNodeHash() throws SQLException
{
return (Integer)getSqlMapClient().queryForObject("alfresco.activities.select_activity_post_max_jobtasknode");
return (Integer)getSqlSession().selectOne("alfresco.activities.select_activity_post_max_jobtasknode");
}
public int updatePost(long id, String siteNetwork, String activityData, ActivityPostEntity.STATUS status) throws SQLException
@@ -72,7 +72,7 @@ public class ActivityPostDAOImpl extends IBatisSqlMapper implements ActivityPost
post.setStatus(status.toString());
post.setLastModified(new Date());
return getSqlMapClient().update("alfresco.activities.update_activity_post_data", post);
return getSqlSession().update("alfresco.activities.update_activity_post_data", post);
}
public int updatePostStatus(long id, ActivityPostEntity.STATUS status) throws SQLException
@@ -82,7 +82,7 @@ public class ActivityPostDAOImpl extends IBatisSqlMapper implements ActivityPost
post.setStatus(status.toString());
post.setLastModified(new Date());
return getSqlMapClient().update("alfresco.activities.update_activity_post_status", post);
return getSqlSession().update("alfresco.activities.update_activity_post_status", post);
}
public int deletePosts(Date keepDate, ActivityPostEntity.STATUS status) throws SQLException
@@ -91,12 +91,13 @@ public class ActivityPostDAOImpl extends IBatisSqlMapper implements ActivityPost
params.setPostDate(keepDate);
params.setStatus(status.toString());
return getSqlMapClient().delete("alfresco.activities.delete_activity_posts_older_than_date", params);
return getSqlSession().delete("alfresco.activities.delete_activity_posts_older_than_date", params);
}
public long insertPost(ActivityPostEntity activityPost) throws SQLException
{
Long id = (Long)getSqlMapClient().insert("alfresco.activities.insert_activity_post", activityPost);
getSqlSession().insert("alfresco.activities.insert.insert_activity_post", activityPost);
Long id = activityPost.getId();
return (id != null ? id : -1);
}
}

View File

@@ -1,19 +1,19 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.domain.activities.ibatis;
@@ -24,17 +24,18 @@ import java.util.List;
import org.alfresco.repo.domain.activities.FeedControlDAO;
import org.alfresco.repo.domain.activities.FeedControlEntity;
public class FeedControlDAOImpl extends IBatisSqlMapper implements FeedControlDAO
public class FeedControlDAOImpl extends ActivitiesSqlSessionDaoSupport implements FeedControlDAO
{
public long insertFeedControl(FeedControlEntity activityFeedControl) throws SQLException
{
Long id = (Long)getSqlMapClient().insert("alfresco.activities.insert_activity_feedcontrol", activityFeedControl);
getSqlSession().insert("alfresco.activities.insert.insert_activity_feedcontrol", activityFeedControl);
Long id = activityFeedControl.getId();
return (id != null ? id : -1);
}
public int deleteFeedControl(FeedControlEntity activityFeedControl) throws SQLException
{
return getSqlMapClient().delete("alfresco.activities.delete_activity_feedcontrol", activityFeedControl);
return getSqlSession().delete("alfresco.activities.delete_activity_feedcontrol", activityFeedControl);
}
@SuppressWarnings("unchecked")
@@ -42,12 +43,12 @@ public class FeedControlDAOImpl extends IBatisSqlMapper implements FeedControlDA
{
FeedControlEntity params = new FeedControlEntity(feedUserId);
return (List<FeedControlEntity>)getSqlMapClient().queryForList("alfresco.activities.select_activity_feedcontrols_for_user", params);
return (List<FeedControlEntity>)getSqlSession().selectList("alfresco.activities.select_activity_feedcontrols_for_user", params);
}
public long selectFeedControl(FeedControlEntity activityFeedControl) throws SQLException
{
Long id = (Long)getSqlMapClient().queryForObject("alfresco.activities.select_activity_feedcontrol", activityFeedControl);
Long id = (Long)getSqlSession().selectOne("alfresco.activities.select_activity_feedcontrol", activityFeedControl);
return (id != null ? id : -1);
}
}