Example #1
0
        private static void ApplyQueryString(MemberSearchCriteria criteria, string queryString)
        {
            // Parse the returned Lucene query string.

            var queryParser = new QueryParser(LuceneVersion.LUCENE_29, string.Empty, new SimpleAnalyzer());
            var query       = queryParser.parse(queryString);

            // Arrange terms by field.

            var terms = new java.util.LinkedHashSet(); // preserves order

            query.extractTerms(terms);

            var coll = new NameValueCollection();

            for (var iter = terms.iterator(); iter.hasNext();)
            {
                var term = (Term)iter.next();
                coll.Add(term.field(), term.text());
            }

            // Extarct criteria parts.

            string allKeywords = null;
            var    values      = coll.GetValues("AllKeywords");

            if (values != null)
            {
                allKeywords = string.Join(" ", values);
            }

            string anyKeywords = null;

            values = coll.GetValues("AnyKeywords");
            if (values != null)
            {
                anyKeywords = string.Join(" ", values);
            }

            string exactPhrase = null;

            values = coll.GetValues("ExactPhrase");
            if (values != null)
            {
                exactPhrase = string.Join(" ", values);
            }

            criteria.SetKeywords(allKeywords, exactPhrase, anyKeywords, null);

            values = coll.GetValues("CompanyKeywords");
            if (values != null)
            {
                criteria.CompanyKeywords = string.Join(" ", values);
            }

            values = coll.GetValues("EducationKeywords");
            if (values != null)
            {
                criteria.EducationKeywords = string.Join(" ", values);
            }

            values = coll.GetValues("JobTitle");
            if (values != null)
            {
                criteria.JobTitle = string.Join(" ", values);
            }
        }
Example #2
0
        /**
         * Performs all changes collected in this ChangeSet on the input stream and
         * streams the result to the output stream. Perform may be called more than once.
         *
         * This method finishes the stream, no other entries should be added
         * after that.
         *
         * @param in
         *            the InputStream to perform the changes on
         * @param out
         *            the resulting OutputStream with all modifications
         * @throws IOException
         *             if an read/write error occurs
         * @return the results of this operation
         */
        public ChangeSetResults perform(ArchiveInputStream inJ, ArchiveOutputStream outJ)
        //throws IOException
        {
            ChangeSetResults results = new ChangeSetResults();

            java.util.Set <Change> workingSet = new java.util.LinkedHashSet <Change>(changes);

            for (java.util.Iterator <Change> it = workingSet.iterator(); it.hasNext();)
            {
                Change change = it.next();

                if (change.type() == Change.TYPE_ADD && change.isReplaceMode())
                {
                    copyStream(change.getInput(), outJ, change.getEntry());
                    it.remove();
                    results.addedFromChangeSet(change.getEntry().getName());
                }
            }

            ArchiveEntry entry = null;

            while ((entry = inJ.getNextEntry()) != null)
            {
                bool copy = true;

                for (java.util.Iterator <Change> it = workingSet.iterator(); it.hasNext();)
                {
                    Change change = it.next();

                    int    type = change.type();
                    String name = entry.getName();
                    if (type == Change.TYPE_DELETE && name != null)
                    {
                        if (name.equals(change.targetFile()))
                        {
                            copy = false;
                            it.remove();
                            results.deleted(name);
                            break;
                        }
                    }
                    else if (type == Change.TYPE_DELETE_DIR && name != null)
                    {
                        if (name.StartsWith(change.targetFile() + "/"))
                        {
                            copy = false;
                            results.deleted(name);
                            break;
                        }
                    }
                }

                if (copy)
                {
                    if (!isDeletedLater(workingSet, entry) && !results.hasBeenAdded(entry.getName()))
                    {
                        copyStream(inJ, outJ, entry);
                        results.addedFromStream(entry.getName());
                    }
                }
            }

            // Adds files which hasn't been added from the original and do not have replace mode on
            for (java.util.Iterator <Change> it = workingSet.iterator(); it.hasNext();)
            {
                Change change = it.next();

                if (change.type() == Change.TYPE_ADD &&
                    !change.isReplaceMode() &&
                    !results.hasBeenAdded(change.getEntry().getName()))
                {
                    copyStream(change.getInput(), outJ, change.getEntry());
                    it.remove();
                    results.addedFromChangeSet(change.getEntry().getName());
                }
            }
            outJ.finish();
            return(results);
        }