mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-10318 Update CalendarEntry to hold the created and modified at dates
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30601 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -24,6 +24,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.service.cmr.calendar.CalendarEntry;
|
import org.alfresco.service.cmr.calendar.CalendarEntry;
|
||||||
import org.alfresco.service.cmr.calendar.CalendarEntryDTO;
|
import org.alfresco.service.cmr.calendar.CalendarEntryDTO;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
@@ -93,7 +94,7 @@ public class CalendarEntryImpl extends CalendarEntryDTO
|
|||||||
properties.put(CalendarModel.PROP_DOC_FOLDER, entry.getSharePointDocFolder());
|
properties.put(CalendarModel.PROP_DOC_FOLDER, entry.getSharePointDocFolder());
|
||||||
|
|
||||||
// properties.put(CalendarModel.PROP_COLOR, entry.getColor();
|
// properties.put(CalendarModel.PROP_COLOR, entry.getColor();
|
||||||
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,6 +118,19 @@ public class CalendarEntryImpl extends CalendarEntryDTO
|
|||||||
entry.setOutlookUID((String)properties.get(CalendarModel.PROP_OUTLOOK_UID));
|
entry.setOutlookUID((String)properties.get(CalendarModel.PROP_OUTLOOK_UID));
|
||||||
|
|
||||||
//entry.setColor(properties.get(CalendarModel.PROP_COLOR));
|
//entry.setColor(properties.get(CalendarModel.PROP_COLOR));
|
||||||
|
|
||||||
|
// If the auditable properties are available and the type is correct, record them
|
||||||
|
if(entry instanceof CalendarEntryDTO)
|
||||||
|
{
|
||||||
|
if(properties.containsKey(ContentModel.PROP_CREATED))
|
||||||
|
{
|
||||||
|
((CalendarEntryDTO)entry).setCreatedAt((Date)properties.get(ContentModel.PROP_CREATED));
|
||||||
|
}
|
||||||
|
if(properties.containsKey(ContentModel.PROP_MODIFIED))
|
||||||
|
{
|
||||||
|
((CalendarEntryDTO)entry).setModifiedAt((Date)properties.get(ContentModel.PROP_MODIFIED));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -39,6 +39,7 @@ import org.alfresco.repo.node.getchildren.GetChildrenCannedQuery;
|
|||||||
import org.alfresco.repo.node.getchildren.GetChildrenCannedQueryFactory;
|
import org.alfresco.repo.node.getchildren.GetChildrenCannedQueryFactory;
|
||||||
import org.alfresco.repo.site.SiteServiceImpl;
|
import org.alfresco.repo.site.SiteServiceImpl;
|
||||||
import org.alfresco.service.cmr.calendar.CalendarEntry;
|
import org.alfresco.service.cmr.calendar.CalendarEntry;
|
||||||
|
import org.alfresco.service.cmr.calendar.CalendarEntryDTO;
|
||||||
import org.alfresco.service.cmr.calendar.CalendarService;
|
import org.alfresco.service.cmr.calendar.CalendarService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
@@ -143,6 +144,10 @@ public class CalendarServiceImpl implements CalendarService
|
|||||||
}
|
}
|
||||||
|
|
||||||
NodeRef event = nodeService.getChildByName(container, ContentModel.ASSOC_CONTAINS, entryName);
|
NodeRef event = nodeService.getChildByName(container, ContentModel.ASSOC_CONTAINS, entryName);
|
||||||
|
return getCalendarEntry(event, entryName, container);
|
||||||
|
}
|
||||||
|
private CalendarEntry getCalendarEntry(NodeRef event, String entryName, NodeRef container)
|
||||||
|
{
|
||||||
if (event != null)
|
if (event != null)
|
||||||
{
|
{
|
||||||
CalendarEntryImpl entry = new CalendarEntryImpl(event, container, entryName);
|
CalendarEntryImpl entry = new CalendarEntryImpl(event, container, entryName);
|
||||||
@@ -196,6 +201,11 @@ public class CalendarServiceImpl implements CalendarService
|
|||||||
entryImpl.setTags(entry.getTags());
|
entryImpl.setTags(entry.getTags());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the auditable properties on it
|
||||||
|
Date createdAt = (Date)nodeService.getProperty(nodeRef, ContentModel.PROP_CREATED);
|
||||||
|
entryImpl.setCreatedAt(createdAt);
|
||||||
|
entryImpl.setModifiedAt(createdAt);
|
||||||
|
|
||||||
// Tag it
|
// Tag it
|
||||||
taggingService.setTags(nodeRef, entry.getTags());
|
taggingService.setTags(nodeRef, entry.getTags());
|
||||||
|
|
||||||
@@ -230,8 +240,22 @@ public class CalendarServiceImpl implements CalendarService
|
|||||||
// Update the tags
|
// Update the tags
|
||||||
taggingService.setTags(entry.getNodeRef(), entry.getTags());
|
taggingService.setTags(entry.getNodeRef(), entry.getTags());
|
||||||
|
|
||||||
// Nothing was changed on the entry itself
|
// Update the auditable properties
|
||||||
return entry;
|
if(entry instanceof CalendarEntryDTO)
|
||||||
|
{
|
||||||
|
((CalendarEntryDTO)entry).setModifiedAt(
|
||||||
|
(Date)nodeService.getProperty(entry.getNodeRef(), ContentModel.PROP_MODIFIED)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Return the same object
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Need to change the modified date, but we can't
|
||||||
|
// Re-fetch to pick up the change
|
||||||
|
return getCalendarEntry(entry.getNodeRef(), entry.getSystemName(), entry.getContainerNodeRef());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -185,6 +185,9 @@ public class CalendarServiceImplTest
|
|||||||
NodeRef site = NODE_SERVICE.getPrimaryParent(container).getParentRef();
|
NodeRef site = NODE_SERVICE.getPrimaryParent(container).getParentRef();
|
||||||
assertEquals(CALENDAR_SITE.getNodeRef(), site);
|
assertEquals(CALENDAR_SITE.getNodeRef(), site);
|
||||||
|
|
||||||
|
// Tell the test system about it, for tidying later
|
||||||
|
testNodesToTidy.add(entry.getNodeRef());
|
||||||
|
|
||||||
|
|
||||||
// Check the details on the object
|
// Check the details on the object
|
||||||
assertEquals("Title", entry.getTitle());
|
assertEquals("Title", entry.getTitle());
|
||||||
@@ -197,6 +200,10 @@ public class CalendarServiceImplTest
|
|||||||
assertEquals(true, entry.isOutlook());
|
assertEquals(true, entry.isOutlook());
|
||||||
assertEquals("12345LookOut!", entry.getOutlookUID());
|
assertEquals("12345LookOut!", entry.getOutlookUID());
|
||||||
|
|
||||||
|
// Check that auditable properties turned up
|
||||||
|
assertNotNull(entry.getCreatedAt());
|
||||||
|
assertNotNull(entry.getModifiedAt());
|
||||||
|
|
||||||
|
|
||||||
// Fetch it, and check the details
|
// Fetch it, and check the details
|
||||||
entry = CALENDAR_SERVICE.getCalendarEntry(CALENDAR_SITE.getShortName(), entry.getSystemName());
|
entry = CALENDAR_SERVICE.getCalendarEntry(CALENDAR_SITE.getShortName(), entry.getSystemName());
|
||||||
@@ -210,9 +217,9 @@ public class CalendarServiceImplTest
|
|||||||
assertEquals(true, entry.isOutlook());
|
assertEquals(true, entry.isOutlook());
|
||||||
assertEquals("12345LookOut!", entry.getOutlookUID());
|
assertEquals("12345LookOut!", entry.getOutlookUID());
|
||||||
|
|
||||||
|
// Check that auditable properties turned up
|
||||||
// Mark it as done with
|
assertNotNull(entry.getCreatedAt());
|
||||||
testNodesToTidy.add(entry.getNodeRef());
|
assertNotNull(entry.getModifiedAt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void createUpdateDeleteEntry() throws Exception
|
@Test public void createUpdateDeleteEntry() throws Exception
|
||||||
|
@@ -159,4 +159,14 @@ public interface CalendarEntry extends Serializable, PermissionCheckValue
|
|||||||
* @return the Tags associated with the event
|
* @return the Tags associated with the event
|
||||||
*/
|
*/
|
||||||
List<String> getTags();
|
List<String> getTags();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the creation date and time
|
||||||
|
*/
|
||||||
|
Date getCreatedAt();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the modification date and time
|
||||||
|
*/
|
||||||
|
Date getModifiedAt();
|
||||||
}
|
}
|
||||||
|
@@ -52,6 +52,8 @@ public class CalendarEntryDTO implements CalendarEntry, Serializable
|
|||||||
private String sharePointDocFolder;
|
private String sharePointDocFolder;
|
||||||
private boolean isOutlook = false;
|
private boolean isOutlook = false;
|
||||||
private String outlookUID;
|
private String outlookUID;
|
||||||
|
private Date createdAt;
|
||||||
|
private Date modifiedAt;
|
||||||
private List<String> tags = new ArrayList<String>();
|
private List<String> tags = new ArrayList<String>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -269,7 +271,31 @@ public class CalendarEntryDTO implements CalendarEntry, Serializable
|
|||||||
{
|
{
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets when this entry was created
|
||||||
|
*/
|
||||||
|
public Date getCreatedAt()
|
||||||
|
{
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
public void setCreatedAt(Date createdAt)
|
||||||
|
{
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets when this entry was modified
|
||||||
|
*/
|
||||||
|
public Date getModifiedAt()
|
||||||
|
{
|
||||||
|
return modifiedAt;
|
||||||
|
}
|
||||||
|
public void setModifiedAt(Date modifiedAt)
|
||||||
|
{
|
||||||
|
this.modifiedAt = modifiedAt;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does the given {@link CalendarEntry} define an all-day
|
* Does the given {@link CalendarEntry} define an all-day
|
||||||
* event?
|
* event?
|
||||||
|
Reference in New Issue
Block a user