New Custom Evaluator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2014 05:11 AM
What I need to achieve is like below :
- Where ever in document library, I have folder with some specific names eg: flder named as "Extranet" or "Published", I need to show one extra custom action of Bulk operation.
Currently I can see that action to every folders instead specific folder named as such..
I have created an evaluator in my share jar in the package "org.alfresco.web.evaluator.doclib.action" named as NameEqualsEvaluator.java. And in the share cnfig i have defined an action for the folders and evaluator id is given as "evaluator.doclib.action.isInstanceType". So, in Custom-slinshot-applicaton.xml, i have defined this id with parent as "org.alfresco.web.evaluator.doclib.action.NameEqualsEvaluator". I build this jar and laced it in "C:\alfresco\tomcat\webapps\share\WEB-INF\lib". I also have another utils jar which am keeping in "C:\alfresco\tomcat\webapps\alfresco\WEB-INF\lib". The problem is while starting the server, it is giving errr as:
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'evaluator.doclib.action.isInstanceType' defined in URL [jar:file:/C:/Alfresco/tomcat/webapps/share/WEB-INF/lib/SkandiaShare.jar!/alfresco/web-extension/custom-slingshot-application-context.xml]: Could not resolve parent bean definition 'org.alfresco.web.evaluator.doclib.action.NameEqualsEvaluator'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.alfresco.web.evaluator.doclib.action.NameEqualsEvaluator' is defined
I am not getting why this class is not being loaded but every webscripts which i have in utils jar are working fine.
Please suggest me how to reslve this issue.
this way my Evaluator not working.
Anyone have achieved like this in alfresco share 4?
Thanks in advance
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2014 06:34 AM
If I understand well, you did that :
<bean id="evaluator.doclib.action.isInstanceType" parent="org.alfresco.web.evaluator.doclib.action.NameEqualsEvaluator" />
Whereas you should do that :
<bean id="evaluator.doclib.action.isInstanceType" class="org.alfresco.web.evaluator.doclib.action.NameEqualsEvaluator" />or<bean id="evaluator.doclib.action.isInstanceType" parent="evaluator.doclib.action.nameEquals" /><bean id="evaluator.doclib.action.nameEquals" class="org.alfresco.web.evaluator.doclib.action.NameEqualsEvaluator" />
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2014 09:42 AM
Many many thanks Tony!!! Thanks for your rely. It really helped me. Now i could load my evaluator class. Can you help me how to write this evaluator class s that i could get this acton only on some f the specific folder names in alfresco depending on their names. Like in predefined evaluator they did it for types, i want to write this evaluator and add a property which can have a list of values of names of flders on which this action can be shown. I am trying it but if you could suggest me then that will really help me speed up my work.
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2014 10:54 AM
Just look at the source code of the org.alfresco.web.evaluator.HasAspectEvaluator evaluator for example. You just have to retrieve the evaluated node name from the jsonModel, compare it to the names you passed as evaluator properties, and return true or false.
Don't hesitate to ask specific questions if you have some
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2014 05:41 AM
my java class is like this as below:
package org.alfresco.web.evaluator.doclib.action;
import java.util.List;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase;
import org.alfresco.service.cmr.action.ActionCondition;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.ui.common.component.evaluator.BaseEvaluator;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.repo.action.ParameterizedItemAbstractBase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.extensions.surf.util.I18NUtil;
import com.skandia.wcm.models.SkandiaContentModel;
public class NameEqualsEvaluator extends BaseEvaluator {
ParameterizedItemAbstractBase base ;
public static final String NAME = "has-name";
public static final String PARAM_NAME = "name";
private static final Log logger = LogFactory.getLog(NameEqualsEvaluator.class);
private NodeService nodeService;
public NodeService getNodeService() {
return nodeService;
}
public void setNodeService(NodeService nodeService) {
this.nodeService = nodeService;
}
public boolean evaluateImpl(ActionCondition ruleCondition, NodeRef actionedUponNodeRef)
{
boolean result = false;
if (this.nodeService.exists(actionedUponNodeRef) == true)
{
if (this.hasName(actionedUponNodeRef, (QName)ruleCondition.getParameterValue("name")) == true)
{
result = true;
}
}
return result;
}
private boolean hasName(NodeRef actionedUponNodeRef, QName parameterValue) {
boolean value = false;
String name = nodeService.getProperty(actionedUponNodeRef, SkandiaContentModel.QTYPE_NAME_KEY).toString();
System.out.println("name is:-"+name);
if(name.equals(parameterValue)){
System.out.println("parameterValue is:-"+parameterValue);
value = true;
}
return value;
}
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
paramList.add(new ParameterDefinitionImpl("name", DataTypeDefinition.QNAME, true, getParamDisplayLabel("name"), true, "name"));
}
protected String getParamDisplayLabel(String paramName)
{
return I18NUtil.getMessage(this.PARAM_NAME + "." + paramName + "." + "display-label");
}
@Override
public boolean evaluate() {
logger.info("evaluator initiated");
return true;
}
}
and bean defined in custom slingshot is as in the attachment.
It is giving error as bean property with name as "name" not defined
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2014 08:23 AM
You should be able to retreive the node name like this (getProperty() is a method inherited from the BaseEvaluator) :
@Overridepublic boolean evaluate(JSONObject jsonObject){ String nodeName = getProperty(jsonObject, "cm:name"); …}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2014 09:05 AM
Thanks Again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2014 09:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2014 10:03 AM
Thanks again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2014 01:49 AM