1 17 package org.alfresco.repo.search; 18 19 import org.alfresco.service.cmr.dictionary.DictionaryService; 20 import org.alfresco.service.cmr.search.NamedQueryParameterDefinition; 21 import org.alfresco.service.cmr.search.QueryParameterDefinition; 22 import org.alfresco.service.namespace.NamespaceService; 23 import org.alfresco.service.namespace.QName; 24 import org.dom4j.Element; 25 import org.dom4j.Namespace; 26 27 public class QueryParameterRefImpl implements NamedQueryParameterDefinition 28 { 29 30 private static final org.dom4j.QName ELEMENT_QNAME = new org.dom4j.QName("parameter-ref", new Namespace(NamespaceService.ALFRESCO_PREFIX, NamespaceService.ALFRESCO_URI)); 31 32 private static final org.dom4j.QName DEF_QNAME = new org.dom4j.QName("qname", new Namespace(NamespaceService.ALFRESCO_PREFIX, NamespaceService.ALFRESCO_URI)); 33 34 private QName qName; 35 36 private QueryCollection container; 37 38 public QueryParameterRefImpl(QName qName, QueryCollection container) 39 { 40 super(); 41 this.qName = qName; 42 this.container = container; 43 } 44 45 public QName getQName() 46 { 47 return qName; 48 } 49 50 public static NamedQueryParameterDefinition createParameterReference(Element element, DictionaryService dictionaryService, QueryCollection container) 51 { 52 53 if (element.getQName().getName().equals(ELEMENT_QNAME.getName())) 54 { 55 QName qName = null; 56 Element qNameElement = element.element(DEF_QNAME.getName()); 57 if(qNameElement != null) 58 { 59 qName = QName.createQName(qNameElement.getText(), container.getNamespacePrefixResolver()); 60 } 61 62 return new QueryParameterRefImpl(qName, container); 63 } 64 else 65 { 66 return null; 67 } 68 } 69 70 public static org.dom4j.QName getElementQName() 71 { 72 return ELEMENT_QNAME; 73 } 74 75 public QueryParameterDefinition getQueryParameterDefinition() 76 { 77 return container.getParameterDefinition(getQName()); 78 } 79 80 } 81 | Popular Tags |