Tagging Service: fixed issue when using scriptNode.save() with tagging API

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9722 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2008-07-10 14:24:32 +00:00
parent 743a2e0ee6
commit 5cab4a5e9c
2 changed files with 19 additions and 1 deletions

View File

@@ -2034,6 +2034,7 @@ public class ScriptNode implements Serializable, Scopeable
public void clearTags() public void clearTags()
{ {
this.services.getTaggingService().clearTags(this.nodeRef); this.services.getTaggingService().clearTags(this.nodeRef);
updateTagProperty();
} }
/** /**
@@ -2044,6 +2045,7 @@ public class ScriptNode implements Serializable, Scopeable
public void addTag(String tag) public void addTag(String tag)
{ {
this.services.getTaggingService().addTag(this.nodeRef, tag); this.services.getTaggingService().addTag(this.nodeRef, tag);
updateTagProperty();
} }
/** /**
@@ -2054,6 +2056,7 @@ public class ScriptNode implements Serializable, Scopeable
public void addTags(String[] tags) public void addTags(String[] tags)
{ {
this.services.getTaggingService().addTags(this.nodeRef, Arrays.asList(tags)); this.services.getTaggingService().addTags(this.nodeRef, Arrays.asList(tags));
updateTagProperty();
} }
/** /**
@@ -2064,6 +2067,7 @@ public class ScriptNode implements Serializable, Scopeable
public void removeTag(String tag) public void removeTag(String tag)
{ {
this.services.getTaggingService().removeTag(this.nodeRef, tag); this.services.getTaggingService().removeTag(this.nodeRef, tag);
updateTagProperty();
} }
/** /**
@@ -2074,6 +2078,7 @@ public class ScriptNode implements Serializable, Scopeable
public void removeTags(String[] tags) public void removeTags(String[] tags)
{ {
this.services.getTaggingService().removeTags(this.nodeRef, Arrays.asList(tags)); this.services.getTaggingService().removeTags(this.nodeRef, Arrays.asList(tags));
updateTagProperty();
} }
/** /**
@@ -2096,6 +2101,16 @@ public class ScriptNode implements Serializable, Scopeable
public void setTags(String[] tags) public void setTags(String[] tags)
{ {
this.services.getTaggingService().setTags(this.nodeRef, Arrays.asList(tags)); this.services.getTaggingService().setTags(this.nodeRef, Arrays.asList(tags));
updateTagProperty();
}
private void updateTagProperty()
{
Serializable tags = this.services.getNodeService().getProperty(this.nodeRef, ContentModel.PROP_TAGS);
if (this.properties != null)
{
this.properties.put(ContentModel.PROP_TAGS.toString(), getValueConverter().convertValueForScript(ContentModel.PROP_TAGS, tags));
}
} }
/** /**

View File

@@ -16,9 +16,11 @@ function testAddRemoveTag()
test.assertNotNull(tags); test.assertNotNull(tags);
test.assertEquals(0, tags.length); test.assertEquals(0, tags.length);
document.properties.title = "A change is as good as a rest!";
document.addTag("mouse"); document.addTag("mouse");
document.addTag("snake"); document.addTag("snake");
document.addTag("snail"); document.addTag("snail");
document.save();
tags = document.tags; tags = document.tags;
test.assertNotNull(tags); test.assertNotNull(tags);
@@ -32,7 +34,8 @@ function testAddRemoveTag()
test.assertEquals(2, tags.length); test.assertEquals(2, tags.length);
document.tags = ["moo", "quack", "squeak"]; document.tags = ["moo", "quack", "squeak"];
document.properties.title = "A change is as good as a rest!";
document.save();
tags = document.tags; tags = document.tags;
test.assertNotNull(tags); test.assertNotNull(tags);
test.assertEquals(3, tags.length); test.assertEquals(3, tags.length);