/*
(non-Javadoc)

@see ca.uhn.fhir.jpa.dao.ISearchParamExtractor#extractSearchParamDates(ca.uhn.fhir.jpa.entity.ResourceTable, ca.uhn.fhir.model.api.IBaseResource)
486627
@Override
	public Set<ResourceIndexedSearchParamDate> extractSearchParamDates(ResourceTable theEntity, IBaseResource theResource) {
		HashSet<ResourceIndexedSearchParamDate> retVal = new HashSet<>();

		Collection<RuntimeSearchParam> searchParams = getSearchParams(theResource);
		for (RuntimeSearchParam nextSpDef : searchParams) {
			if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.DATE) {
				continue;
			}

			String nextPath = nextSpDef.getPath();
			if (isBlank(nextPath)) {
				continue;
			}

			boolean multiType = false;
			if (nextPath.endsWith("[x]")) {
				multiType = true;
			}

			for (Object nextObject : extractValues(nextPath, theResource)) {
				if (nextObject == null) {
					continue;
				}

				ResourceIndexedSearchParamDate nextEntity;
				if (nextObject instanceof BaseDateTimeType) {
					BaseDateTimeType nextValue = (BaseDateTimeType) nextObject;
					if (nextValue.isEmpty()) {
						continue;
					}
					nextEntity = new ResourceIndexedSearchParamDate(nextSpDef.getName(), nextValue.getValue(), nextValue.getValue(), nextValue.getValueAsString());
				} else if (nextObject instanceof Period) {
					Period nextValue = (Period) nextObject;
					if (nextValue.isEmpty()) {
						continue;
					}
					nextEntity = new ResourceIndexedSearchParamDate(nextSpDef.getName(), nextValue.getStart(), nextValue.getEnd(), nextValue.getStartElement().getValueAsString());
				} else if (nextObject instanceof Timing) {
					Timing nextValue = (Timing) nextObject;
					if (nextValue.isEmpty()) {
						continue;
					}
					TreeSet<Date> dates = new TreeSet<>();
					String firstValue = null;
					for (DateTimeType nextEvent : nextValue.getEvent()) {
						if (nextEvent.getValue() != null) {
							dates.add(nextEvent.getValue());
							if (firstValue == null) {
								firstValue = nextEvent.getValueAsString();
							}
						}
					}
					if (dates.isEmpty()) {
						continue;
					}

					nextEntity = new ResourceIndexedSearchParamDate(nextSpDef.getName(), dates.first(), dates.last(), firstValue);
				} else if (nextObject instanceof StringType) {
					// CarePlan.activitydate can be a string
					continue;
				} else {
					if (!multiType) {
						throw new ConfigurationException("Search param " + nextSpDef.getName() + " is of unexpected datatype: " + nextObject.getClass());
					} else {
						continue;
					}
				}
				if (nextEntity != null) {
					nextEntity.setResource(theEntity);
					retVal.add(nextEntity);
				}
			}
		}

		return retVal;
	}
754926
public Map<String, String> getUriVariablesForSearch(BullhornEntityInfo entityInfo, String query, Set<String> fieldSet, SearchParams params) {

		Map<String, String> uriVariables = params.getParameterMap();

		this.addCommonUriVariables(fieldSet, entityInfo, uriVariables);
		uriVariables.put(QUERY, query);

		return uriVariables;
	}
663902
@Override
    public boolean parseParameters(Object params)
    {
        if (params == null || !(params instanceof BuildBattleDecorator))
            return false;

        this.params = (BuildBattleDecorator) params;

        this.sourceBounds = this.params.getGoalStructureBounds();
        this.destBounds = this.params.getPlayerStructureBounds();
        this.delta = new Vec3i(destBounds.getMin().getX() - sourceBounds.getMin().getX(),
                               destBounds.getMin().getY() - sourceBounds.getMin().getY(),
                               destBounds.getMin().getZ() - sourceBounds.getMin().getZ());
        
        this.structureVolume = volumeOfBounds(this.sourceBounds);
        assert(this.structureVolume == volumeOfBounds(this.destBounds));
        this.dest = new ArrayList<IBlockState>(Collections.nCopies(this.structureVolume, (IBlockState)null));
        this.source = new ArrayList<IBlockState>(Collections.nCopies(this.structureVolume, (IBlockState)null));
        
        DrawBlockBasedObjectType tickBlock = this.params.getBlockTypeOnCorrectPlacement();
        DrawBlockBasedObjectType crossBlock = this.params.getBlockTypeOnIncorrectPlacement();

        this.blockTypeOnCorrectPlacement = (tickBlock != null) ? new XMLBlockState(tickBlock.getType(), tickBlock.getColour(), tickBlock.getFace(), tickBlock.getVariant()) : null;
        this.blockTypeOnIncorrectPlacement = (crossBlock != null) ? new XMLBlockState(crossBlock.getType(), crossBlock.getColour(), crossBlock.getFace(), crossBlock.getVariant()) : null;
        return true;
    }
911447
public List<String> extractIdList(SearchResponse searchResponse) {
        return Arrays.stream(searchResponse.getHits().getHits())
                .map(SearchHit::getId).collect(toList());
    }
1171682
@SuppressWarnings("deprecation")
    private List<CmsResource> searchResources() {

        getReport().println(
            Messages.get().container(Messages.RPT_SOURCESEARCH_START_COLLECTING_FILES_TO_SEARCH_IN_0),
            I_CmsReport.FORMAT_HEADLINE);

        List<CmsResource> resources = new ArrayList<CmsResource>();
        if (m_settings.isSolrSearch()) {
            CmsSolrIndex index = OpenCms.getSearchManager().getIndexSolr(m_settings.getSource());
            if (index != null) {
                CmsSolrQuery query = new CmsSolrQuery(
                    null,
                    CmsRequestUtil.createParameterMap(m_settings.getQuery() + "&fl=path,type"));
                List<String> rootPaths = new ArrayList<>(m_settings.getPaths().size());
                String siteRoot = getCms().getRequestContext().getSiteRoot();
                for (String path : m_settings.getPaths()) {
                    rootPaths.add(path.startsWith(siteRoot) ? path : getCms().addSiteRoot(path));
                }
                query.setSearchRoots(rootPaths);
                if ((m_settings.getTypesArray() != null) && (m_settings.getTypesArray().length > 0)) {
                    query.setResourceTypes(m_settings.getTypesArray());
                }
                query.setRows(new Integer(MAX_PROCESSED_SOLR_RESULTS));
                query.ensureParameters();
                try {
                    resources.addAll(
                        index.search(getCms(), query, true, null, false, null, MAX_PROCESSED_SOLR_RESULTS));
                } catch (CmsSearchException e) {
                    LOG.error(e.getMessage(), e);
                }
            }
        } else {
            CmsResourceFilter filter = CmsResourceFilter.ALL.addExcludeState(
                CmsResource.STATE_DELETED).addRequireVisible();
            List<CmsResourceFilter> filterList = new ArrayList<CmsResourceFilter>();
            if ((m_settings.getTypesArray() != null) && (m_settings.getTypesArray().length > 0)) {
                for (String resTypeName : m_settings.getTypesArray()) {
                    try {
                        int typeId = OpenCms.getResourceManager().getResourceType(resTypeName).getTypeId();
                        filterList.add(((CmsResourceFilter)filter.clone()).addRequireType(typeId));
                    } catch (CmsLoaderException e) {
                        // noop
                    } catch (NullPointerException e) {
                        // noop
                    }
                }
            }
            if (filterList.size() == 1) {
                filter = filterList.get(0);
            }

            // iterate over all selected paths
            Iterator<String> iterPaths = m_settings.getPaths().iterator();

            if (!m_settings.getType().isPropertySearch()) {
                filter = filter.addRequireFile();
            }
            while (iterPaths.hasNext()) {
                String path = iterPaths.next();
                try {
                    if (m_settings.getType().isPropertySearch()) {
                        resources.addAll(
                            getCms().readResourcesWithProperty(path, m_settings.getProperty().getName(), null, filter));
                    } else {
                        // only read resources which are files and not deleted, which are in the current time range window and where the current
                        // user has the sufficient permissions to read them

                        List<CmsResource> tmpResources = getCms().readResources(path, filter);
                        List<String> subsites = null;
                        if (m_settings.ignoreSubSites()) {
                            subsites = OpenCms.getADEManager().getSubSitePaths(getCms(), path);
                            subsites.remove(
                                OpenCms.getADEManager().getSubSiteRoot(
                                    getCms(),
                                    getCms().readResource(path).getRootPath()));
                        }
                        Iterator<CmsResource> iterator = tmpResources.iterator();
                        while (iterator.hasNext()) {
                            CmsResource r = iterator.next();
                            boolean remove = true;
                            if (filterList.size() > 1) {
                                for (CmsResourceFilter f : filterList) {
                                    if (f.isValid(getCms().getRequestContext(), r)) {
                                        remove = false;
                                    }
                                }
                            } else {
                                remove = false;
                            }
                            if ((subsites != null) & !remove) {
                                if (subsites.contains(
                                    OpenCms.getADEManager().getSubSiteRoot(getCms(), r.getRootPath()))) {
                                    remove = true;
                                }
                            }
                            if (remove) {
                                iterator.remove();
                            }
                        }

                        if ((tmpResources != null) && !tmpResources.isEmpty()) {
                            resources.addAll(tmpResources);
                        }
                    }
                } catch (CmsException e) {
                    // an error occured
                    LOG.error(Messages.get().container(Messages.RPT_SOURCESEARCH_ERROR_READING_RESOURCES_1, path), e);
                    getReport().println(
                        Messages.get().container(Messages.RPT_SOURCESEARCH_ERROR_READING_RESOURCES_1, path),
                        I_CmsReport.FORMAT_ERROR);
                }
            }
        }
        return resources;
    }
675682
def filter(self, resource_manager, **params):
        """"""
        m = self.resolve(resource_manager.resource_type)
        client = local_session(self.session_factory).client(m.service)

        enum_op, path, extra_args = m.enum_spec
        if extra_args:
            params.update(extra_args)

        parent_type, parent_key, annotate_parent = m.parent_spec
        parents = self.manager.get_resource_manager(parent_type)
        parent_ids = [p[parents.resource_type.id] for p in parents.resources()]

        # Bail out with no parent ids...
        existing_param = parent_key in params
        if not existing_param and len(parent_ids) == 0:
            return []

        # Handle a query with parent id
        if existing_param:
            return self._invoke_client_enum(client, enum_op, params, path)

        # Have to query separately for each parent's children.
        results = []
        for parent_id in parent_ids:
            merged_params = self.get_parent_parameters(params, parent_id, parent_key)
            subset = self._invoke_client_enum(
                client, enum_op, merged_params, path, retry=self.manager.retry)
            if annotate_parent:
                for r in subset:
                    r[self.parent_key] = parent_id
            if subset and self.capture_parent_id:
                results.extend([(parent_id, s) for s in subset])
            elif subset:
                results.extend(subset)
        return results
92555
@Override
	public Set<ResourceIndexedSearchParamQuantity> extractSearchParamQuantity(ResourceTable theEntity, IBaseResource theResource) {
		HashSet<ResourceIndexedSearchParamQuantity> retVal = new HashSet<ResourceIndexedSearchParamQuantity>();

		Collection<RuntimeSearchParam> searchParams = getSearchParams(theResource);
		for (RuntimeSearchParam nextSpDef : searchParams) {
			if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.QUANTITY) {
				continue;
			}

			String nextPath = nextSpDef.getPath();
			if (isBlank(nextPath)) {
				continue;
			}

			for (Object nextObject : extractValues(nextPath, theResource)) {
				if (nextObject == null || ((IBase) nextObject).isEmpty()) {
					continue;
				}

				String resourceName = nextSpDef.getName();
				boolean multiType = false;
				if (nextPath.endsWith("[x]")) {
					multiType = true;
				}

				if (nextObject instanceof Quantity) {
					Quantity nextValue = (Quantity) nextObject;
					addQuantity(theEntity, retVal, resourceName, nextValue);
				} else if (nextObject instanceof Range) {
					Range nextValue = (Range) nextObject;
					addQuantity(theEntity, retVal, resourceName, nextValue.getLow());
					addQuantity(theEntity, retVal, resourceName, nextValue.getHigh());
				} else if (nextObject instanceof LocationPositionComponent) {
					continue;
				} else {
					if (!multiType) {
						throw new ConfigurationException("Search param " + resourceName + " is of unexpected datatype: " + nextObject.getClass());
					} else {
						continue;
					}
				}
			}
		}

		return retVal;
	}
928074
private CmsSearchWorkplaceBean getSearchParams() {

        if ((m_searchParams == null) && (getSettings().getDialogObject() instanceof Map<?, ?>)) {
            Map<?, ?> dialogObject = (Map<?, ?>)getSettings().getDialogObject();
            if (dialogObject.get(CmsSearchDialog.class.getName()) instanceof CmsSearchWorkplaceBean) {
                m_searchParams = (CmsSearchWorkplaceBean)dialogObject.get(CmsSearchDialog.class.getName());
            }
        }
        return m_searchParams;
    }
846501
@Override
	public ResourceList<T> findAll(Iterable<I> ids, QuerySpec querySpec) {
		RegistryEntry entry = resourceRegistry.findEntry(resourceClass);
		String idName = entry.getResourceInformation().getIdField().getUnderlyingName();

		QuerySpec idQuerySpec = querySpec.duplicate();
		idQuerySpec.addFilter(new FilterSpec(Arrays.asList(idName), FilterOperator.EQ, ids));
		return findAll(idQuerySpec);
	}
134478
private CmsSearch getSearchBean(Map<String, String> params) {

        if (m_searchBean == null) {
            m_searchBean = new CmsSearch();
            m_searchBean.init(getWp().getCms());
            m_searchBean.setParameters(getSearchParameters(params));
            if (CmsStringUtil.isEmptyOrWhitespaceOnly(m_searchBean.getIndex())) {
                m_searchBean.setIndex(getWp().getSettings().getUserSettings().getWorkplaceSearchIndexName());
            }
            m_searchBean.setMatchesPerPage(getWp().getSettings().getUserSettings().getExplorerFileEntries());
            m_searchBean.setSearchPage(Integer.parseInt(params.get(I_CmsListResourceCollector.PARAM_PAGE)));
            // set search roots
            List<String> resources = getResourceNamesFromParam(params);
            String[] searchRoots = new String[resources.size()];
            resources.toArray(searchRoots);
            for (int i = 0; i < searchRoots.length; i++) {
                searchRoots[i] = getWp().getCms().addSiteRoot(searchRoots[i]);
            }
            m_searchBean.setSearchRoots(searchRoots);
        } else {
            int page = Integer.parseInt(params.get(I_CmsListResourceCollector.PARAM_PAGE));
            if (m_searchBean.getSearchPage() != page) {
                m_searchBean.setSearchPage(page);
                m_searchResults = null;
            }
        }
        return m_searchBean;
    }
182213
@SuppressWarnings("unchecked")
    public <T> List<Serializable> findId(Class<T> clazz, SearchParameters sp, List<SingularAttribute<?, ?>> availableProperties) {
        //log.info("Searching {} with terms : {} with available Properties: {}", new Object[]{clazz.getSimpleName(), sp.getTerms(), availableProperties});
        FullTextEntityManager fullTextEntityManager = getFullTextEntityManager(entityManager);
        Query query = sp.getLuceneQueryBuilder().build(fullTextEntityManager, sp, availableProperties);

        if (query == null) {
            return null;
        }

        FullTextQuery ftq = fullTextEntityManager.createFullTextQuery( //
                query, clazz);
        ftq.setProjection("id");
        if (sp.getMaxResults() > 0) {
            ftq.setMaxResults(sp.getMaxResults());
        }
        List<Serializable> ids = newArrayList();
        List<Object[]> resultList = ftq.getResultList();
        for (Object[] result : resultList) {
            ids.add((Serializable) result[0]);
        }
        return ids;
    }
1068926
@Override
	public Set<BaseResourceIndexedSearchParam> extractSearchParamTokens(ResourceTable theEntity, IBaseResource theResource) {
		HashSet<BaseResourceIndexedSearchParam> retVal = new HashSet<BaseResourceIndexedSearchParam>();

		String useSystem = null;
		if (theResource instanceof ValueSet) {
			ValueSet vs = (ValueSet) theResource;
			useSystem = vs.getCodeSystem().getSystem();
		}

		Collection<RuntimeSearchParam> searchParams = getSearchParams(theResource);
		for (RuntimeSearchParam nextSpDef : searchParams) {
			if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.TOKEN) {
				continue;
			}

			String nextPath = nextSpDef.getPath();
			if (isBlank(nextPath)) {
				continue;
			}

			boolean multiType = false;
			if (nextPath.endsWith("[x]")) {
				multiType = true;
			}

			List<String> systems = new ArrayList<String>();
			List<String> codes = new ArrayList<String>();

			String needContactPointSystem = null;
			if (nextPath.endsWith("(system=phone)")) {
				nextPath = nextPath.substring(0, nextPath.length() - "(system=phone)".length());
				needContactPointSystem = "phone";
			}
			if (nextPath.endsWith("(system=email)")) {
				nextPath = nextPath.substring(0, nextPath.length() - "(system=email)".length());
				needContactPointSystem = "email";
			}

			for (Object nextObject : extractValues(nextPath, theResource)) {

				// Patient:language
				if (nextObject instanceof Patient.Communication) {
					Communication nextValue = (Patient.Communication) nextObject;
					nextObject = nextValue.getLanguage();
				}

				if (nextObject instanceof IdentifierDt) {
					IdentifierDt nextValue = (IdentifierDt) nextObject;
					if (nextValue.isEmpty()) {
						continue;
					}
					String system = StringUtils.defaultIfBlank(nextValue.getSystemElement().getValueAsString(), null);
					String value = nextValue.getValueElement().getValue();
					if (isNotBlank(value)) {
						systems.add(system);
						codes.add(value);
					}

					if (isNotBlank(nextValue.getType().getText())) {
						addStringParam(theEntity, retVal, nextSpDef, nextValue.getType().getText());
					}

				} else if (nextObject instanceof ContactPointDt) {
					ContactPointDt nextValue = (ContactPointDt) nextObject;
					if (nextValue.isEmpty()) {
						continue;
					}
					if (isNotBlank(needContactPointSystem)) {
						if (!needContactPointSystem.equals(nextValue.getSystemElement().getValueAsString())) {
							continue;
						}
					}
					systems.add(nextValue.getSystemElement().getValueAsString());
					codes.add(nextValue.getValueElement().getValue());
				} else if (nextObject instanceof BoundCodeDt) {
					BoundCodeDt<?> obj = (BoundCodeDt<?>) nextObject;
					String system = extractSystem(obj);
					String code = obj.getValue();
					if (isNotBlank(code)) {
						systems.add(system);
						codes.add(code);
					}
				} else if (nextObject instanceof IPrimitiveDatatype<?>) {
					IPrimitiveDatatype<?> nextValue = (IPrimitiveDatatype<?>) nextObject;
					if (nextValue.isEmpty()) {
						continue;
					}
					if ("ValueSet.codeSystem.concept.code".equals(nextPath)) {
						systems.add(useSystem);
					} else {
						systems.add(null);
					}
					codes.add(nextValue.getValueAsString());
				} else if (nextObject instanceof CodingDt) {
					CodingDt nextValue = (CodingDt) nextObject;
					extractTokensFromCoding(systems, codes, theEntity, retVal, nextSpDef, nextValue);
				} else if (nextObject instanceof CodeableConceptDt) {
					CodeableConceptDt nextCC = (CodeableConceptDt) nextObject;
					if (!nextCC.getTextElement().isEmpty()) {
						addStringParam(theEntity, retVal, nextSpDef, nextCC.getTextElement().getValue());
					}

					extractTokensFromCodeableConcept(systems, codes, nextCC, theEntity, retVal, nextSpDef);
				} else if (nextObject instanceof RestSecurity) {
					// Conformance.security search param points to something kind of useless right now - This should probably
					// be fixed.
					RestSecurity sec = (RestSecurity) nextObject;
					for (BoundCodeableConceptDt<RestfulSecurityServiceEnum> nextCC : sec.getService()) {
						extractTokensFromCodeableConcept(systems, codes, nextCC, theEntity, retVal, nextSpDef);
					}
				} else if (nextObject instanceof Location.Position) {
					ourLog.warn("Position search not currently supported, not indexing location");
					continue;
				} else {
					if (!multiType) {
						throw new ConfigurationException("Search param " + nextSpDef.getName() + " is of unexpected datatype: " + nextObject.getClass());
					} else {
						continue;
					}
				}
			}

			assert systems.size() == codes.size() : "Systems contains " + systems + ", codes contains: " + codes;

			Set<Pair<String, String>> haveValues = new HashSet<Pair<String, String>>();
			for (int i = 0; i < systems.size(); i++) {
				String system = systems.get(i);
				String code = codes.get(i);
				if (isBlank(system) && isBlank(code)) {
					continue;
				}

				if (system != null && system.length() > ResourceIndexedSearchParamToken.MAX_LENGTH) {
					system = system.substring(0, ResourceIndexedSearchParamToken.MAX_LENGTH);
				}
				if (code != null && code.length() > ResourceIndexedSearchParamToken.MAX_LENGTH) {
					code = code.substring(0, ResourceIndexedSearchParamToken.MAX_LENGTH);
				}

				Pair<String, String> nextPair = Pair.of(system, code);
				if (haveValues.contains(nextPair)) {
					continue;
				}
				haveValues.add(nextPair);

				ResourceIndexedSearchParamToken nextEntity;
				nextEntity = new ResourceIndexedSearchParamToken(nextSpDef.getName(), system, code);
				nextEntity.setResource(theEntity);
				retVal.add(nextEntity);

			}

		}

		return retVal;
	}
536118
private String prepareQueryParameters(Map<J4pQueryParameter, String> pProcessingOptions) {
        if (pProcessingOptions != null && pProcessingOptions.size() > 0) {
            StringBuilder queryParams = new StringBuilder();
            for (Map.Entry<J4pQueryParameter,String> entry : pProcessingOptions.entrySet()) {
                queryParams.append(entry.getKey().getParam()).append("=").append(entry.getValue()).append("&");
            }
            return queryParams.substring(0,queryParams.length() - 1);
        } else {
            return null;
        }
    }
465482
@Override
    public List<SearchResult> search(EntityMetadata m, String persistenceUnit, ConsistencyLevel consistencyLevel,
            Map<Boolean, List<IndexClause>> indexClauseMap)
    {

        return super.search(m, persistenceUnit, consistencyLevel, indexClauseMap);
    }
1091672
@Override
	public Set<ResourceIndexedSearchParamString> extractSearchParamStrings(ResourceTable theEntity, IBaseResource theResource) {
		HashSet<ResourceIndexedSearchParamString> retVal = new HashSet<>();

		String resourceName = getContext().getResourceDefinition(theResource).getName();

		Collection<RuntimeSearchParam> searchParams = getSearchParams(theResource);
		for (RuntimeSearchParam nextSpDef : searchParams) {
			if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.STRING) {
				continue;
			}

			String nextPath = nextSpDef.getPath();
			String nextSpName = nextSpDef.getName();

			if (isBlank(nextPath)) {

				// // TODO: implement phonetic, and any others that have no path
				//
				// // TODO: do we still need this check?
				// if ("Questionnaire".equals(nextSpName) && nextSpDef.getName().equals("title")) {
				// Questionnaire q = (Questionnaire) theResource;
				// String title = "";// q.getGroup().getTitle();
				// addSearchTerm(theEntity, retVal, nextSpName, title);
				// }

				continue;
			}

			for (Object nextObject : extractValues(nextPath, theResource)) {
				if (nextObject == null || ((IBase) nextObject).isEmpty()) {
					continue;
				}

				boolean multiType = false;
				if (nextPath.endsWith("[x]")) {
					multiType = true;
				}

				if (nextObject instanceof IPrimitiveType<?>) {
					IPrimitiveType<?> nextValue = (IPrimitiveType<?>) nextObject;
					String searchTerm = nextValue.getValueAsString();
					addSearchTerm(theEntity, retVal, nextSpName, searchTerm);
				} else {
					if (nextObject instanceof HumanName) {
						ArrayList<StringType> allNames = new ArrayList<>();
						HumanName nextHumanName = (HumanName) nextObject;
						if (isNotBlank(nextHumanName.getFamily())) {
							allNames.add(nextHumanName.getFamilyElement());
						}
						allNames.addAll(nextHumanName.getGiven());
						for (StringType nextName : allNames) {
							addSearchTerm(theEntity, retVal, nextSpName, nextName.getValue());
						}
					} else if (nextObject instanceof Address) {
						ArrayList<StringType> allNames = new ArrayList<>();
						Address nextAddress = (Address) nextObject;
						allNames.addAll(nextAddress.getLine());
						allNames.add(nextAddress.getCityElement());
						allNames.add(nextAddress.getStateElement());
						allNames.add(nextAddress.getCountryElement());
						allNames.add(nextAddress.getPostalCodeElement());
						for (StringType nextName : allNames) {
							addSearchTerm(theEntity, retVal, nextSpName, nextName.getValue());
						}
					} else if (nextObject instanceof ContactPoint) {
						ContactPoint nextContact = (ContactPoint) nextObject;
						if (nextContact.getValueElement().isEmpty() == false) {
							addSearchTerm(theEntity, retVal, nextSpName, nextContact.getValue());
						}
					} else if (nextObject instanceof Quantity) {
						BigDecimal value = ((Quantity) nextObject).getValue();
						if (value != null) {
							addSearchTerm(theEntity, retVal, nextSpName, value.toPlainString());
						}
					} else if (nextObject instanceof Range) {
						Quantity low = ((Range) nextObject).getLow();
						if (low != null) {
							BigDecimal value = low.getValue();
							if (value != null) {
								addSearchTerm(theEntity, retVal, nextSpName, value.toPlainString());
							}
						}
					} else {
						if (!multiType) {
							throw new ConfigurationException("Search param " + nextSpName + " is of unexpected datatype: " + nextObject.getClass());
						}
					}
				}
			}
		}

		return retVal;
	}
300979
@Override
	public ConstrainedResultSet<ID> findIdsByUriQuery(final WebQuery query)
	{
		return (ConstrainedResultSet<ID>) find(query, JPASearchStrategy.ID);
	}
643334
private void searchAndAddToResults(EntityMetadata m, String persistenceUnit, ConsistencyLevel consistencyLevel,
            String columnFamilyName, List<SearchResult> searchResults, IndexExpression expression, boolean isRowKeyQuery)
    {
        SearchResult searchResult = new SearchResult();

        byte[] superColumnName = expression.getValue();
        String superColumnNameStr = null;
        String rowKey = null;
        try
        {
            rowKey = ByteBufferUtil.string(ByteBuffer.wrap(expression.getColumn_name()),
                    Charset.forName(Constants.CHARSET_UTF8));
            superColumnNameStr = new String(expression.getValue(), Charset.forName(Constants.CHARSET_UTF8));
        }
        catch (CharacterCodingException e)
        {
            log.error("Error while retrieving records {}, Caused by:", e);
            throw new PersistenceException(e);
        }
        Object pk = PropertyAccessorHelper.getObject(m.getIdAttribute().getJavaType(), superColumnName);
        IndexOperator condition = expression.getOp();

        if (log.isInfoEnabled())
        {
            log.info("RowKey: {} ; Super column Name: {} on condition.", rowKey, superColumnNameStr, condition);
        }

        // TODO: Second check unnecessary but unavoidable as filter clause
        // property is incorrectly passed as column name

        // Search based on Primary key
        if (isRowKeyQuery
                && (rowKey.equals(m.getIdAttribute().getName()) || rowKey.equals(((DefaultSingularAttribute) m
                        .getIdAttribute()).getJPAColumnName())))
        {
            if (searchResults.isEmpty())
            {
                searchResult.setPrimaryKey(pk);
                searchResults.add(searchResult);
            }
            else
            {
                SearchResult existing = searchResults.get(0);
                if (existing.getPrimaryKey() != null && existing.getPrimaryKey().equals(superColumnNameStr))
                {
                    searchResults.add(searchResult);
                }
                else
                {
                    searchResults.remove(0);
                }
            }
        }
        else
        {
            // Search results in the form of thrift super columns
            List<SuperColumn> thriftSuperColumns = new ArrayList<SuperColumn>();

            switch (condition)
            {
            // EQUAL Operator
            case EQ:
                SuperColumn thriftSuperColumn = getSuperColumnForRow(consistencyLevel, columnFamilyName, rowKey,
                        superColumnName, persistenceUnit);

                if (thriftSuperColumn != null)
                    thriftSuperColumns.add(thriftSuperColumn);
                break;

            // LIKE operation not available
            // Greater than operator
            case GT:
                searchSuperColumnsInRange(columnFamilyName, consistencyLevel, persistenceUnit, rowKey, superColumnName,
                        thriftSuperColumns, superColumnName, new byte[0]);
                break;
            // Less than Operator
            case LT:
                searchSuperColumnsInRange(columnFamilyName, consistencyLevel, persistenceUnit, rowKey, superColumnName,
                        thriftSuperColumns, new byte[0], superColumnName);
                break;
            // Greater than-equals to operator
            case GTE:
                searchSuperColumnsInRange(columnFamilyName, consistencyLevel, persistenceUnit, rowKey, superColumnName,
                        thriftSuperColumns, superColumnName, new byte[0]);
                break;
            // Less than equal to operator
            case LTE:
                searchSuperColumnsInRange(columnFamilyName, consistencyLevel, persistenceUnit, rowKey, superColumnName,
                        thriftSuperColumns, new byte[0], superColumnName);
                break;

            default:
                throw new QueryHandlerException(condition
                        + " comparison operator not supported currently for Cassandra Inverted Index.");
            }

            // Construct search results out of these thrift columns
            for (SuperColumn thriftSuperColumn : thriftSuperColumns)
            {

                for (Column column : thriftSuperColumn.getColumns())
                {
                    byte[] columnName = column.getName();
                    searchResult.setPrimaryKey(PropertyAccessorHelper.getObject(m.getIdAttribute().getJavaType(),
                            columnName));
                    byte[] columnValue = column.getValue();
                    String ecValue = UTF8Type.instance.compose(ByteBuffer.wrap(columnValue));

                    if (ecValue != null && !"".equals(ecValue.trim()))
                    {
                        searchResult.setEmbeddedColumnName(rowKey.substring(0,
                                rowKey.indexOf(Constants.INDEX_TABLE_ROW_KEY_DELIMITER)));
                        searchResult.addEmbeddedColumnValue(ecValue);
                    }
                }

                if (searchResults.isEmpty())
                {
                    searchResults.add(searchResult);
                }
                else
                {
                    SearchResult existing = searchResults.get(0);
                    if (existing.getPrimaryKey() != null
                            && existing.getPrimaryKey().equals(searchResult.getPrimaryKey()))
                    {
                        searchResults.add(searchResult);
                    }
                    else
                    {
                        searchResults.remove(0);
                    }
                }

            }
        }
    }