1 17 package org.alfresco.repo.action.evaluator; 18 19 import org.alfresco.repo.action.ActionConditionDefinitionImpl; 20 import org.alfresco.repo.action.ParameterizedItemAbstractBase; 21 import org.alfresco.service.cmr.action.ActionCondition; 22 import org.alfresco.service.cmr.action.ActionConditionDefinition; 23 import org.alfresco.service.cmr.repository.NodeRef; 24 25 30 public abstract class ActionConditionEvaluatorAbstractBase extends ParameterizedItemAbstractBase implements ActionConditionEvaluator 31 { 32 35 private boolean publicCondition = true; 36 37 40 protected ActionConditionDefinition actionConditionDefinition; 41 42 45 public void init() 46 { 47 if (this.publicCondition == true) 48 { 49 this.runtimeActionService.registerActionConditionEvaluator(this); 51 } 52 } 53 54 59 public void setPublicCondition(boolean publicCondition) 60 { 61 this.publicCondition = publicCondition; 62 } 63 64 69 public ActionConditionDefinition getActionConditionDefintion() 70 { 71 if (this.actionConditionDefinition == null) 72 { 73 this.actionConditionDefinition = new ActionConditionDefinitionImpl(this.name); 74 ((ActionConditionDefinitionImpl)this.actionConditionDefinition).setTitleKey(getTitleKey()); 75 ((ActionConditionDefinitionImpl)this.actionConditionDefinition).setDescriptionKey(getDescriptionKey()); 76 ((ActionConditionDefinitionImpl)this.actionConditionDefinition).setAdhocPropertiesAllowed(getAdhocPropertiesAllowed()); 77 ((ActionConditionDefinitionImpl)this.actionConditionDefinition).setConditionEvaluator(this.name); 78 ((ActionConditionDefinitionImpl)this.actionConditionDefinition).setParameterDefinitions(getParameterDefintions()); 79 } 80 return this.actionConditionDefinition; 81 } 82 83 86 public boolean evaluate(ActionCondition actionCondition, NodeRef actionedUponNodeRef) 87 { 88 checkMandatoryProperties(actionCondition, getActionConditionDefintion()); 89 boolean result = evaluateImpl(actionCondition, actionedUponNodeRef); 90 if (actionCondition.getInvertCondition() == true) 91 { 92 result = !result; 93 } 94 return result; 95 } 96 97 104 protected abstract boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef); 105 } 106 | Popular Tags |