Package org.apache.jetspeed.search

Examples of org.apache.jetspeed.search.ParsedObject


            SolrDocumentList docList = rsp.getResults();
            List<ParsedObject> resultList = new ArrayList<ParsedObject>();
           
            for (SolrDocument doc : docList)
            {
                ParsedObject result = new BaseParsedObject();
               
                addFieldsToParsedObject(doc, result);
               
                Object type = doc.getFirstValue(ParsedObject.FIELDNAME_TYPE);
                if(type != null)
                {
                    result.setType(type.toString());
                }
               
                Object key = doc.getFirstValue(ParsedObject.FIELDNAME_KEY);
                if(key != null)
                {
                    result.setKey(key.toString());
                }
               
                Object description = doc.getFirstValue(ParsedObject.FIELDNAME_DESCRIPTION);
                if(description != null)
                {
                    result.setDescription(description.toString());
                }
               
                Object title = doc.getFirstValue(ParsedObject.FIELDNAME_TITLE);
                if(title != null)
                {
                    result.setTitle(title.toString());
                }
               
                Object content = doc.getFirstValue(ParsedObject.FIELDNAME_CONTENT);
                if(content != null)
                {
                    result.setContent(content.toString());
                }
               
                Object language = doc.getFirstValue(ParsedObject.FIELDNAME_LANGUAGE);
                if (language != null)
                {
                    result.setLanguage(language.toString());
                }
               
                Object classname = doc.getFirstValue(ParsedObject.FIELDNAME_CLASSNAME);
                if (classname != null)
                {
                    result.setClassName(classname.toString());
                }
               
                Object url = doc.getFirstValue(ParsedObject.FIELDNAME_URL);
                if (url != null)
                {
                    result.setURL(new URL(url.toString()));
                }
               
                Collection<Object> keywords = doc.getFieldValues(ParsedObject.FIELDNAME_KEYWORDS);
                if(keywords != null)
                {
                    String[] keywordArray = new String[keywords.size()];
                    int index = 0;
                   
                    for (Object keyword : keywords)
                    {
                        keywordArray[index++] = keyword.toString();
                    }
                   
                    result.setKeywords(keywordArray);
                }
               
                resultList.add(result);
            }
           
View Full Code Here


                    log.error("Failed to create hanlder for object " + o.getClass().getName());
                    continue;
                }
   
                // Parse the object
                ParsedObject parsedObject = handler.parseObject(o);
               
                String key = parsedObject.getKey();
                // if there's an existing one with the same key, then remove it first.
                if (parsedObject.getKey() != null)
                {
                    SolrQuery query = new SolrQuery();
                    String queryString = new StringBuilder(40).append(ParsedObject.FIELDNAME_KEY).append(':').append(ClientUtils.escapeQueryChars(key)).toString();
                    query.setQuery(queryString);
                    QueryResponse qrsp = server.query(query);
                   
                    if (!qrsp.getResults().isEmpty())
                    {
                        UpdateResponse ursp = server.deleteByQuery(queryString);
                       
                        if (ursp.getStatus() < 300)
                        {
                            server.commit();
                        }
                    }
                }
               
                String type = parsedObject.getType();
                String title = parsedObject.getTitle();
                String description = parsedObject.getDescription();
                String content = parsedObject.getContent();
                String language = parsedObject.getLanguage();
                URL url = parsedObject.getURL();
                String className = parsedObject.getClassName();
               
                // Create document
                SolrInputDocument doc = new SolrInputDocument();
               
                // Populate document from the parsed object
                if (key != null)
                {
                    doc.addField(ParsedObject.FIELDNAME_KEY, key, 1.0f);
                }
                if (type != null)
                {
                    doc.addField(ParsedObject.FIELDNAME_TYPE, type, 1.0f);
                }
                if (title != null)
                {
                    doc.addField(ParsedObject.FIELDNAME_TITLE, title, 1.0f);
                }
                if (description != null)
                {
                    doc.addField(ParsedObject.FIELDNAME_DESCRIPTION, description, 1.0f);
                }
                if (content != null)
                {
                    doc.addField(ParsedObject.FIELDNAME_CONTENT, content, 1.0f);
                }
                if (language != null)
                {
                    doc.addField(ParsedObject.FIELDNAME_LANGUAGE, language, 1.0f);
                }
                if (url != null)
                {
                    String urlString = url.toString();
                    doc.addField(ParsedObject.FIELDNAME_URL, urlString, 1.0f);
                }
                if (className != null)
                {
                    doc.addField(ParsedObject.FIELDNAME_CLASSNAME, className, 1.0f);
                }
               
                String[] keywordArray = parsedObject.getKeywords();
                if(keywordArray != null)
                {
                    for(int i=0; i<keywordArray.length; ++i)
                    {
                        String keyword = keywordArray[i];
                        doc.addField(ParsedObject.FIELDNAME_KEYWORDS, keyword, 1.0f);
                    }
                }
               
                Map keywords = parsedObject.getKeywordsMap();
                addFieldsToDocument(doc, keywords);
               
                Map fields = parsedObject.getFields();
                addFieldsToDocument(doc, fields);
               
                List<String> syntheticField = new ArrayList<String>();
                for (Map.Entry<String, SolrInputField> entry : doc.entrySet())
                {
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.search.ParsedObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.