KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > action > evaluator > IsSubTypeEvaluator


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.action.evaluator;
18
19 import java.util.List JavaDoc;
20
21 import org.alfresco.repo.action.ParameterDefinitionImpl;
22 import org.alfresco.service.cmr.action.ActionCondition;
23 import org.alfresco.service.cmr.action.ParameterDefinition;
24 import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
25 import org.alfresco.service.cmr.dictionary.DictionaryService;
26 import org.alfresco.service.cmr.repository.NodeRef;
27 import org.alfresco.service.cmr.repository.NodeService;
28 import org.alfresco.service.namespace.QName;
29
30 /**
31  * No condition evaluator implmentation.
32  *
33  * @author Roy Wetherall
34  */

35 public class IsSubTypeEvaluator extends ActionConditionEvaluatorAbstractBase
36 {
37     /**
38      * Evaluator constants
39      */

40     public static final String JavaDoc NAME = "is-subtype";
41     public static final String JavaDoc PARAM_TYPE = "type";
42     
43     /**
44      * The node service
45      */

46     private NodeService nodeService;
47     
48     /**
49      * The dictionary service
50      */

51     private DictionaryService dictionaryService;
52     
53     /**
54      * Set node service
55      *
56      * @param nodeService the node service
57      */

58     public void setNodeService(NodeService nodeService)
59     {
60         this.nodeService = nodeService;
61     }
62     
63     /**
64      * Set dictionary service
65      *
66      * @param dictionaryService the dictionary service
67      */

68     public void setDictionaryService(DictionaryService dictionaryService)
69     {
70         this.dictionaryService = dictionaryService;
71     }
72     
73     /**
74      * @see org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase#evaluateImpl(org.alfresco.service.cmr.action.ActionCondition, org.alfresco.service.cmr.repository.NodeRef)
75      */

76     public boolean evaluateImpl(ActionCondition ruleCondition, NodeRef actionedUponNodeRef)
77     {
78         boolean result = false;
79         
80         if (this.nodeService.exists(actionedUponNodeRef) == true)
81         {
82             // TODO: Move this type check into its own Class Evaluator
83
QName nodeType = nodeService.getType(actionedUponNodeRef);
84             if (dictionaryService.isSubClass(nodeType, (QName)ruleCondition.getParameterValue(PARAM_TYPE)))
85             {
86                 result = true;
87             }
88         }
89         
90         return result;
91     }
92
93     /**
94      * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefintions(java.util.List)
95      */

96     @Override JavaDoc
97     protected void addParameterDefintions(List JavaDoc<ParameterDefinition> paramList)
98     {
99         paramList.add(new ParameterDefinitionImpl(PARAM_TYPE, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_TYPE)));
100     }
101
102 }
103
Popular Tags