mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-9156 Start on the backing ibatis/sql for the Calendar multi-site event listing canned query
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29005 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -75,6 +75,9 @@ Inbound settings from iBatis
|
||||
<!-- Blog CQ -->
|
||||
<typeAlias alias="Blog" type="org.alfresco.repo.blog.cannedqueries.BlogEntity"/>
|
||||
|
||||
<!-- Calendar CQ -->
|
||||
<typeAlias alias="Calendar" type="org.alfresco.repo.calendar.cannedqueries.CalendarEntity"/>
|
||||
|
||||
<!-- Copy CQ -->
|
||||
<typeAlias alias="CopyParameters" type="org.alfresco.repo.copy.query.CopyParametersEntity"/>
|
||||
|
||||
@@ -190,6 +193,7 @@ Inbound settings from iBatis
|
||||
<mapper resource="alfresco/ibatis/#resource.dialect#/query-usages-common-SqlMap.xml"/>
|
||||
<mapper resource="alfresco/ibatis/#resource.dialect#/query-authorities-common-SqlMap.xml"/>
|
||||
<mapper resource="alfresco/ibatis/#resource.dialect#/query-blogs-common-SqlMap.xml"/>
|
||||
<mapper resource="alfresco/ibatis/#resource.dialect#/query-calendar-common-SqlMap.xml"/>
|
||||
<mapper resource="alfresco/ibatis/#resource.dialect#/query-copy-common-SqlMap.xml"/>
|
||||
</mappers>
|
||||
|
||||
|
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="alfresco.query.calendar">
|
||||
|
||||
<!-- -->
|
||||
<!-- Result Maps -->
|
||||
<!-- -->
|
||||
|
||||
<resultMap id="result_Calendar" type="Calendar">
|
||||
<id property="id" column="id" jdbcType="BIGINT" javaType="java.lang.Long"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR" javaType="java.lang.String"/>
|
||||
<result property="fromDate" column="from_date" jdbcType="VARCHAR" javaType="java.lang.String"/>
|
||||
<result property="toDate" column="from_date" jdbcType="VARCHAR" javaType="java.lang.String"/>
|
||||
<association property="node" resultMap="alfresco.node.result_Node"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- GetCalendarEntries Canned Query (model-specific) - note: date properties are stored as ISO 8061 string -->
|
||||
|
||||
<select id="select_GetCalendarEntriesCannedQuery" parameterType="Calendar" resultMap="result_Calendar">
|
||||
select
|
||||
childNode.id as id,
|
||||
childStore.protocol as protocol,
|
||||
childStore.identifier as identifier,
|
||||
childNode.uuid as uuid,
|
||||
childNode.audit_created as audit_created,
|
||||
childNode.audit_creator as audit_creator,
|
||||
prop_fromdate.string_value as from_date,
|
||||
prop_todate.string_value as to_date,
|
||||
prop_name.string_value as name
|
||||
from
|
||||
alf_child_assoc assoc
|
||||
join alf_node childNode on (childNode.id = assoc.child_node_id)
|
||||
join alf_store childStore on (childStore.id = childNode.store_id)
|
||||
left join alf_node_properties prop_fromdate on (prop_fromdate.node_id = childNode.id and prop_fromdate.qname_id = #{fromDateQNameId})
|
||||
left join alf_node_properties prop_todate on (prop_todate.node_id = childNode.id and prop_todate.qname_id = #{toDateQNameId})
|
||||
left join alf_node_properties prop_name on (prop_name.node_id = childNode.id and prop_name.qname_id = #{nameQNameId})
|
||||
where
|
||||
assoc.parent_node_id IN <foreach item="nodeRef" index="index" collection="sitesContainerNodeIds" open="(" separator="," close=")">#{nodeRef}</foreach>
|
||||
and childNode.type_qname_id = #{contentTypeQNameId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
@@ -42,7 +42,6 @@ import org.alfresco.service.cmr.calendar.CalendarEntry;
|
||||
import org.alfresco.service.cmr.calendar.CalendarService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.alfresco.service.cmr.tagging.TaggingService;
|
||||
@@ -119,7 +118,7 @@ public class CalendarServiceImpl implements CalendarService
|
||||
/**
|
||||
* Fetches the Calendar Container on a site, creating as required if requested.
|
||||
*/
|
||||
private NodeRef getSiteCalendarContainer(final String siteShortName, boolean create)
|
||||
protected NodeRef getSiteCalendarContainer(final String siteShortName, boolean create)
|
||||
{
|
||||
if(! siteService.hasContainer(siteShortName, CALENDAR_COMPONENT))
|
||||
{
|
||||
@@ -406,6 +405,13 @@ public class CalendarServiceImpl implements CalendarService
|
||||
List<NodeRef> containersL = new ArrayList<NodeRef>();
|
||||
for(String siteShortName : siteShortNames)
|
||||
{
|
||||
// Ensure the site exists, skip if not
|
||||
if(siteService.getSite(siteShortName) == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Grab the container for this site
|
||||
NodeRef container = getSiteCalendarContainer(siteShortName, false);
|
||||
if(container != null)
|
||||
{
|
||||
|
@@ -125,7 +125,11 @@ public class CalendarServiceImplTest
|
||||
{
|
||||
CalendarEntry entry;
|
||||
|
||||
// TODO List to check there aren't any yet
|
||||
// Nothing to start with
|
||||
PagingResults<CalendarEntry> results =
|
||||
CALENDAR_SERVICE.listCalendarEntries(CALENDAR_SITE.getShortName(), new PagingRequest(10));
|
||||
assertEquals(0, results.getPage().size());
|
||||
|
||||
|
||||
// Get with an arbitrary name gives nothing
|
||||
entry = CALENDAR_SERVICE.getCalendarEntry(CALENDAR_SITE.getShortName(), "madeUp");
|
||||
@@ -436,7 +440,7 @@ public class CalendarServiceImplTest
|
||||
{
|
||||
PagingRequest paging = new PagingRequest(10);
|
||||
|
||||
// Nothing to start
|
||||
// Nothing to start with
|
||||
PagingResults<CalendarEntry> results =
|
||||
CALENDAR_SERVICE.listCalendarEntries(CALENDAR_SITE.getShortName(), paging);
|
||||
assertEquals(0, results.getPage().size());
|
||||
@@ -488,7 +492,43 @@ public class CalendarServiceImplTest
|
||||
|
||||
@Test public void calendarMultiSiteListing() throws Exception
|
||||
{
|
||||
// TODO
|
||||
PagingRequest paging = new PagingRequest(10);
|
||||
PagingResults<CalendarEntry> results;
|
||||
|
||||
|
||||
// Nothing to start
|
||||
results = CALENDAR_SERVICE.listCalendarEntries(CALENDAR_SITE.getShortName(), paging);
|
||||
assertEquals(0, results.getPage().size());
|
||||
results = CALENDAR_SERVICE.listCalendarEntries(ALTERNATE_CALENDAR_SITE.getShortName(), paging);
|
||||
assertEquals(0, results.getPage().size());
|
||||
|
||||
results = CALENDAR_SERVICE.listCalendarEntries(new String[] {
|
||||
CALENDAR_SITE.getShortName(), ALTERNATE_CALENDAR_SITE.getShortName()}, paging);
|
||||
assertEquals(0, results.getPage().size());
|
||||
|
||||
|
||||
// You can pass invalid names in too, won't affect things
|
||||
results = CALENDAR_SERVICE.listCalendarEntries(new String[] {
|
||||
CALENDAR_SITE.getShortName(), ALTERNATE_CALENDAR_SITE.getShortName(),
|
||||
"MadeUpNumber1", "MadeUpTwo", "MadeUp3"}, paging);
|
||||
assertEquals(0, results.getPage().size());
|
||||
|
||||
|
||||
// Now add some events to one site
|
||||
|
||||
// Check
|
||||
|
||||
// Add to the other site, won't show up due to permissions
|
||||
|
||||
// Make a member of the site, show up
|
||||
|
||||
// Filter by start date
|
||||
|
||||
// Filter by end date
|
||||
|
||||
// Filter by both
|
||||
|
||||
// Filter on just one site, won't see from the other
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -587,6 +627,8 @@ public class CalendarServiceImplTest
|
||||
|
||||
private static void createTestSites() throws Exception
|
||||
{
|
||||
final CalendarServiceImpl privateCalendarService = (CalendarServiceImpl)testContext.getBean("calendarService");
|
||||
|
||||
CALENDAR_SITE = TRANSACTION_HELPER.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<SiteInfo>()
|
||||
{
|
||||
@Override
|
||||
@@ -598,6 +640,7 @@ public class CalendarServiceImplTest
|
||||
"test site title", "test site description",
|
||||
SiteVisibility.PUBLIC
|
||||
);
|
||||
privateCalendarService.getSiteCalendarContainer(site.getShortName(), true);
|
||||
CLASS_TEST_NODES_TO_TIDY.add(site.getNodeRef());
|
||||
return site;
|
||||
}
|
||||
@@ -616,9 +659,7 @@ public class CalendarServiceImplTest
|
||||
"alternate site title", "alternate site description",
|
||||
SiteVisibility.PRIVATE
|
||||
);
|
||||
SITE_SERVICE.createContainer(
|
||||
site.getShortName(), CalendarServiceImpl.CALENDAR_COMPONENT, null, null
|
||||
);
|
||||
privateCalendarService.getSiteCalendarContainer(site.getShortName(), true);
|
||||
CLASS_TEST_NODES_TO_TIDY.add(site.getNodeRef());
|
||||
return site;
|
||||
}
|
||||
|
@@ -43,6 +43,9 @@ public class CalendarEntity
|
||||
// Supplemental query-related parameters
|
||||
private Long parentNodeId;
|
||||
private Long nameQNameId;
|
||||
private Long contentTypeQNameId;
|
||||
private Long fromDateQNameId;
|
||||
private Long toDateQNameId;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
@@ -51,10 +54,14 @@ public class CalendarEntity
|
||||
{
|
||||
}
|
||||
|
||||
public CalendarEntity(Long parentNodeId, Long nameQNameId)
|
||||
public CalendarEntity(Long parentNodeId, Long nameQNameId, Long contentTypeQNameId,
|
||||
Long fromDateQNameId, Long toDateQNameId)
|
||||
{
|
||||
this.parentNodeId = parentNodeId;
|
||||
this.nameQNameId = nameQNameId;
|
||||
this.contentTypeQNameId = contentTypeQNameId;
|
||||
this.fromDateQNameId = fromDateQNameId;
|
||||
this.toDateQNameId = toDateQNameId;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
@@ -127,6 +134,7 @@ public class CalendarEntity
|
||||
this.toDate = toISO8061;
|
||||
}
|
||||
|
||||
|
||||
// Supplemental query-related parameters
|
||||
|
||||
public Long getParentNodeId()
|
||||
@@ -138,4 +146,19 @@ public class CalendarEntity
|
||||
{
|
||||
return nameQNameId;
|
||||
}
|
||||
|
||||
public Long getContentTypeQNameId()
|
||||
{
|
||||
return contentTypeQNameId;
|
||||
}
|
||||
|
||||
public Long getFromDateQNameId()
|
||||
{
|
||||
return fromDateQNameId;
|
||||
}
|
||||
|
||||
public Long getToDateQNameId()
|
||||
{
|
||||
return toDateQNameId;
|
||||
}
|
||||
}
|
||||
|
@@ -128,7 +128,13 @@ public class GetCalendarEntriesCannedQueryFactory extends AbstractCannedQueryFac
|
||||
|
||||
//FIXME Need tenant service like for GetChildren?
|
||||
GetCalendarEntriesCannedQueryParams paramBean = new GetCalendarEntriesCannedQueryParams(
|
||||
containerIds, getQNameId(ContentModel.PROP_NAME), fromDate, toDate
|
||||
containerIds,
|
||||
getQNameId(ContentModel.PROP_NAME),
|
||||
getQNameId(CalendarModel.TYPE_EVENT),
|
||||
getQNameId(CalendarModel.PROP_FROM_DATE),
|
||||
getQNameId(CalendarModel.PROP_TO_DATE),
|
||||
fromDate,
|
||||
toDate
|
||||
);
|
||||
|
||||
CannedQueryPageDetails cqpd = createCQPageDetails(pagingReq);
|
||||
|
@@ -28,25 +28,28 @@ import java.util.Date;
|
||||
*/
|
||||
public class GetCalendarEntriesCannedQueryParams extends CalendarEntity
|
||||
{
|
||||
private final Long[] siteContainerNodeIds;
|
||||
private final Long[] sitesContainerNodeIds;
|
||||
private final Date entriesFromDate;
|
||||
private final Date entriesToDate;
|
||||
|
||||
public GetCalendarEntriesCannedQueryParams(Long[] siteContainerNodeIds,
|
||||
public GetCalendarEntriesCannedQueryParams(Long[] sitesContainerNodeIds,
|
||||
Long nameQNameId,
|
||||
Long contentTypeQNameId,
|
||||
Long fromDateQNameId,
|
||||
Long toDateQNameId,
|
||||
Date entriesFromDate,
|
||||
Date entriesToDate)
|
||||
{
|
||||
super(null, nameQNameId);
|
||||
super(null, nameQNameId, contentTypeQNameId, fromDateQNameId, toDateQNameId);
|
||||
|
||||
this.siteContainerNodeIds = siteContainerNodeIds;
|
||||
this.sitesContainerNodeIds = sitesContainerNodeIds;
|
||||
this.entriesFromDate = entriesFromDate;
|
||||
this.entriesToDate = entriesToDate;
|
||||
}
|
||||
|
||||
public Long[] getSiteContainerNodeIds()
|
||||
public Long[] getSitesContainerNodeIds()
|
||||
{
|
||||
return siteContainerNodeIds;
|
||||
return sitesContainerNodeIds;
|
||||
}
|
||||
|
||||
public Date getEntriesFromDate()
|
||||
|
Reference in New Issue
Block a user