1 17 package org.alfresco.repo.search.impl.lucene; 18 19 import java.io.Serializable ; 20 import java.util.Map ; 21 22 import org.alfresco.model.ContentModel; 23 import org.alfresco.repo.search.AbstractResultSetRow; 24 import org.alfresco.service.cmr.repository.ChildAssociationRef; 25 import org.alfresco.service.cmr.repository.NodeRef; 26 import org.alfresco.service.cmr.repository.Path; 27 import org.alfresco.service.namespace.QName; 28 import org.apache.lucene.document.Document; 29 import org.apache.lucene.document.Field; 30 31 37 public class LuceneResultSetRow extends AbstractResultSetRow 38 { 39 42 private Document document; 43 44 50 public LuceneResultSetRow(LuceneResultSet resultSet, int index) 51 { 52 super(resultSet, index); 53 } 54 55 60 public Document getDocument() 61 { 62 if (document == null) 63 { 64 document = ((LuceneResultSet) getResultSet()).getDocument(getIndex()); 65 } 66 return document; 67 } 68 69 72 73 protected Map <QName, Serializable > getDirectProperties() 74 { 75 LuceneResultSet lrs = (LuceneResultSet) getResultSet(); 76 return lrs.getNodeService().getProperties(lrs.getNodeRef(getIndex())); 77 } 78 79 public Serializable getValue(Path path) 80 { 81 throw new UnsupportedOperationException (); 84 } 85 86 public QName getQName() 87 { 88 Field field = getDocument().getField("QNAME"); 89 if (field != null) 90 { 91 String qname = field.stringValue(); 92 if((qname == null) || (qname.length() == 0)) 93 { 94 return null; 95 } 96 else 97 { 98 return QName.createQName(qname); 99 } 100 } 101 else 102 { 103 return null; 104 } 105 } 106 107 public QName getPrimaryAssocTypeQName() 108 { 109 110 Field field = getDocument().getField("PRIMARYASSOCTYPEQNAME"); 111 if (field != null) 112 { 113 String qname = field.stringValue(); 114 return QName.createQName(qname); 115 } 116 else 117 { 118 return ContentModel.ASSOC_CHILDREN; 119 } 120 } 121 122 public ChildAssociationRef getChildAssocRef() 123 { 124 Field field = getDocument().getField("PRIMARYPARENT"); 125 String primaryParent = null; 126 if (field != null) 127 { 128 primaryParent = field.stringValue(); 129 } 130 NodeRef childNodeRef = getNodeRef(); 131 NodeRef parentNodeRef = primaryParent == null ? null : new NodeRef(primaryParent); 132 return new ChildAssociationRef(getPrimaryAssocTypeQName(), parentNodeRef, getQName(), childNodeRef); 133 } 134 135 } 136 | Popular Tags |