mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-16 17:55:15 +00:00
Tagging bootstrap and model. Javascript API tag cloud function
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@7479 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
1e89a663ef
commit
dbc7863a45
@ -1100,9 +1100,21 @@
|
||||
|
||||
</cm:category>
|
||||
|
||||
<!-- Tags -->
|
||||
<cm:category>
|
||||
<view:acl>
|
||||
<view:ace view:access="ALLOWED">
|
||||
<view:authority>GROUP_EVERYONE</view:authority>
|
||||
<view:permission>Contributor</view:permission>
|
||||
</view:ace>
|
||||
</view:acl>
|
||||
<cm:name>Tags</cm:name>
|
||||
</cm:category>
|
||||
|
||||
</cm:subcategories>
|
||||
|
||||
</cm:category>
|
||||
|
||||
</cm:categories>
|
||||
</cm:category_root>
|
||||
|
||||
|
14
config/alfresco/bootstrap/tagRootCategory.xml
Normal file
14
config/alfresco/bootstrap/tagRootCategory.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0"
|
||||
xmlns:sys="http://www.alfresco.org/model/system/1.0"
|
||||
xmlns:cm="http://www.alfresco.org/model/content/1.0">
|
||||
<cm:category view:childName="cm:taggable">
|
||||
<view:acl view:inherit="false">
|
||||
<view:ace view:access="ALLOWED">
|
||||
<view:authority>GROUP_EVERYONE</view:authority>
|
||||
<view:permission>Collaborator</view:permission>
|
||||
</view:ace>
|
||||
</view:acl>
|
||||
<cm:name>Tags</cm:name>
|
||||
<sys:node-uuid>tag:tag-root</sys:node-uuid>
|
||||
</cm:category>
|
||||
</view:view>
|
@ -189,3 +189,5 @@ patch.avmFormPropertyIdentifier.result=Reindexed wca:webform to make wca:formnam
|
||||
|
||||
patch.formsFolder.description=Adds 'Forms' folder to Data Dictionary
|
||||
|
||||
patch.tagRootCategory.description=Adds 'Tags' as new top-level category root
|
||||
|
||||
|
@ -682,6 +682,24 @@
|
||||
</properties>
|
||||
</aspect>
|
||||
|
||||
<aspect name="cm:taggable">
|
||||
<title>Taggable</title>
|
||||
<parent>cm:classifiable</parent>
|
||||
<properties>
|
||||
<property name="cm:taggable">
|
||||
<title>Tags</title>
|
||||
<type>d:category</type>
|
||||
<mandatory>false</mandatory>
|
||||
<multiple>true</multiple>
|
||||
<index enabled="true">
|
||||
<atomic>true</atomic>
|
||||
<stored>true</stored>
|
||||
<tokenised>false</tokenised>
|
||||
</index>
|
||||
</property>
|
||||
</properties>
|
||||
</aspect>
|
||||
|
||||
<aspect name="cm:attachable">
|
||||
<title>Attachable</title>
|
||||
<associations>
|
||||
|
@ -1145,4 +1145,25 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="patch.tagRootCategory" class="org.alfresco.repo.admin.patch.impl.GenericBootstrapPatch" parent="basePatch" >
|
||||
<property name="id"><value>patch.tagRootCategory</value></property>
|
||||
<property name="description"><value>patch.tagRootCategory.description</value></property>
|
||||
<property name="fixesFromSchema"><value>0</value></property>
|
||||
<property name="fixesToSchema"><value>113</value></property>
|
||||
<property name="targetSchema"><value>114</value></property>
|
||||
<!-- bootstrap view -->
|
||||
<property name="importerBootstrap">
|
||||
<ref bean="spacesBootstrap" />
|
||||
</property>
|
||||
<property name="checkPath">
|
||||
<value>/cm:categoryRoot/cm:taggable</value>
|
||||
</property>
|
||||
<property name="bootstrapView">
|
||||
<props>
|
||||
<prop key="path">/cm:categoryRoot</prop>
|
||||
<prop key="location">alfresco/bootstrap/tagRootCategory.xml</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
@ -25,12 +25,15 @@
|
||||
package org.alfresco.repo.jscript;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.CategoryService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.mozilla.javascript.Context;
|
||||
import org.mozilla.javascript.Scriptable;
|
||||
|
||||
@ -124,6 +127,26 @@ public final class Classification extends BaseScopableProcessorExtension
|
||||
return Context.getCurrentContext().newArray(getScope(), cats);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category usage count.
|
||||
*
|
||||
* @param aspect
|
||||
* @param maxCount
|
||||
* @return
|
||||
*/
|
||||
public Scriptable getCategoryUsage(String aspect, int maxCount)
|
||||
{
|
||||
List<Pair<NodeRef, Integer>> topCats = services.getCategoryService().getTopCategories(storeRef, createQName(aspect), maxCount);
|
||||
Object[] tags = new Object[topCats.size()];
|
||||
int i = 0;
|
||||
for (Pair<NodeRef, Integer> topCat : topCats)
|
||||
{
|
||||
tags[i++] = new Tag(new CategoryNode(topCat.getFirst(), this.services, getScope()), topCat.getSecond());
|
||||
}
|
||||
|
||||
return Context.getCurrentContext().newArray(getScope(), tags);
|
||||
}
|
||||
|
||||
private Object[] buildCategoryNodes(Collection<ChildAssociationRef> cars)
|
||||
{
|
||||
Object[] categoryNodes = new Object[cars.size()];
|
||||
@ -148,4 +171,33 @@ public final class Classification extends BaseScopableProcessorExtension
|
||||
}
|
||||
return qname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tag class returned from getCategoryUsage().
|
||||
*
|
||||
* @param CategoryNode
|
||||
* @param frequency
|
||||
* @return
|
||||
*/
|
||||
public final class Tag
|
||||
{
|
||||
private CategoryNode categoryNode;
|
||||
private int frequency = 0;
|
||||
|
||||
public Tag(CategoryNode categoryNode, int frequency)
|
||||
{
|
||||
this.categoryNode = categoryNode;
|
||||
this.frequency = frequency;
|
||||
}
|
||||
|
||||
public CategoryNode getCategory()
|
||||
{
|
||||
return categoryNode;
|
||||
}
|
||||
|
||||
public int getFrequency()
|
||||
{
|
||||
return frequency;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user