mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Switch some new services to using a tagging service method, rather than doing the work internally
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29535 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -125,53 +125,6 @@ public class CalendarServiceImpl implements CalendarService
|
||||
siteService, transactionService, taggingService);
|
||||
}
|
||||
|
||||
private void handleTags(CalendarEntry entry)
|
||||
{
|
||||
NodeRef nodeRef = entry.getNodeRef();
|
||||
|
||||
List<String> currentTags = taggingService.getTags(nodeRef);
|
||||
List<String> newTags = entry.getTags();
|
||||
|
||||
if(currentTags.size() == 0 && newTags.size() == 0)
|
||||
{
|
||||
// No tags, easy
|
||||
return;
|
||||
}
|
||||
|
||||
// Figure out what (if anything) changed
|
||||
Set<String> toAdd = new HashSet<String>(newTags);
|
||||
Set<String> toDel = new HashSet<String>(currentTags);
|
||||
for(String tag : currentTags)
|
||||
{
|
||||
if(toAdd.contains(tag))
|
||||
{
|
||||
toAdd.remove(tag);
|
||||
}
|
||||
}
|
||||
for(String tag : newTags)
|
||||
{
|
||||
if(toDel.contains(tag))
|
||||
{
|
||||
toDel.remove(tag);
|
||||
}
|
||||
}
|
||||
|
||||
if(toDel.size() == 0 && toAdd.size() == 0)
|
||||
{
|
||||
// No changes
|
||||
}
|
||||
|
||||
// Make the changes
|
||||
for(String tag : toDel)
|
||||
{
|
||||
taggingService.removeTag(nodeRef, tag);
|
||||
}
|
||||
for(String tag : toAdd)
|
||||
{
|
||||
taggingService.addTag(nodeRef, tag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CalendarEntry getCalendarEntry(String siteShortName, String entryName)
|
||||
{
|
||||
@@ -237,7 +190,7 @@ public class CalendarServiceImpl implements CalendarService
|
||||
}
|
||||
|
||||
// Tag it
|
||||
handleTags(entryImpl);
|
||||
taggingService.setTags(nodeRef, entry.getTags());
|
||||
|
||||
// All done
|
||||
return entryImpl;
|
||||
@@ -267,7 +220,7 @@ public class CalendarServiceImpl implements CalendarService
|
||||
nodeService.setProperties(entry.getNodeRef(), properties);
|
||||
|
||||
// Update the tags
|
||||
handleTags(entry);
|
||||
taggingService.setTags(entry.getNodeRef(), entry.getTags());
|
||||
|
||||
// Nothing was changed on the entry itself
|
||||
return entry;
|
||||
|
@@ -22,10 +22,8 @@ import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.query.CannedQueryFactory;
|
||||
@@ -138,53 +136,6 @@ public class LinksServiceImpl implements LinksService
|
||||
siteService, transactionService, taggingService);
|
||||
}
|
||||
|
||||
private void handleTags(LinkInfo link)
|
||||
{
|
||||
NodeRef nodeRef = link.getNodeRef();
|
||||
|
||||
List<String> currentTags = taggingService.getTags(nodeRef);
|
||||
List<String> newTags = link.getTags();
|
||||
|
||||
if(currentTags.size() == 0 && newTags.size() == 0)
|
||||
{
|
||||
// No tags, easy
|
||||
return;
|
||||
}
|
||||
|
||||
// Figure out what (if anything) changed
|
||||
Set<String> toAdd = new HashSet<String>(newTags);
|
||||
Set<String> toDel = new HashSet<String>(currentTags);
|
||||
for(String tag : currentTags)
|
||||
{
|
||||
if(toAdd.contains(tag))
|
||||
{
|
||||
toAdd.remove(tag);
|
||||
}
|
||||
}
|
||||
for(String tag : newTags)
|
||||
{
|
||||
if(toDel.contains(tag))
|
||||
{
|
||||
toDel.remove(tag);
|
||||
}
|
||||
}
|
||||
|
||||
if(toDel.size() == 0 && toAdd.size() == 0)
|
||||
{
|
||||
// No changes
|
||||
}
|
||||
|
||||
// Make the changes
|
||||
for(String tag : toDel)
|
||||
{
|
||||
taggingService.removeTag(nodeRef, tag);
|
||||
}
|
||||
for(String tag : toAdd)
|
||||
{
|
||||
taggingService.addTag(nodeRef, tag);
|
||||
}
|
||||
}
|
||||
|
||||
private LinkInfo buildLink(NodeRef nodeRef, NodeRef container, String name)
|
||||
{
|
||||
LinkInfoImpl link = new LinkInfoImpl(nodeRef, container, name);
|
||||
@@ -313,7 +264,7 @@ public class LinksServiceImpl implements LinksService
|
||||
}
|
||||
|
||||
// Now do the tags
|
||||
handleTags(link);
|
||||
taggingService.setTags(nodeRef, link.getTags());
|
||||
|
||||
// All done
|
||||
return link;
|
||||
|
Reference in New Issue
Block a user