Find entity entries in a result set

 @param results [Typhoeus::Response]
 @return [Nokogiri::XML::NodeSet]
770796
def find_entities(results)
      document = ::Nokogiri::XML(results.body)
      document.remove_namespaces!
      document.xpath('//entry')
    end
727342
private static List<String> getResultIds(JsonNode result)
  {
    JsonNode resultIds = result.path("data").path("resultIds");
    if (resultIds.isNull() ||
        resultIds.isMissingNode() ||
        resultIds.asText().isEmpty())
    {
      return Collections.emptyList();
    }
    return new ArrayList<>(Arrays.asList(resultIds.asText().split(",")));
  }
367893
private List<Tuple> tuplesResult(EntityKey[] keys, TupleContext tupleContext, ClosableIterator<NodeWithEmbeddedNodes> nodes) {
		// The list is initialized with null because some keys might not have a corresponding node
		Tuple[] tuples = new Tuple[keys.length];
		Transaction tx = transaction( tupleContext );
		while ( nodes.hasNext() ) {
			NodeWithEmbeddedNodes node = nodes.next();
			for ( int i = 0; i < keys.length; i++ ) {
				if ( RemoteNeo4jHelper.matches( node.getOwner().asMap(), keys[i].getColumnNames(), keys[i].getColumnValues() ) ) {
					EntityKeyMetadata metadata = keys[i].getMetadata();
					EntityKey key = keys[i];
					BoltNeo4jEntityQueries entityQueries = getEntityQueries( key.getMetadata(), tupleContext );
					Map<String, Node> toOneEntities = BoltNeo4jAssociatedNodesHelper.findAssociatedNodes( tx, node, metadata,
							tupleContext.getTupleTypeContext(), entityQueries );
					tuples[i] = new Tuple(
							new BoltNeo4jTupleSnapshot(
									node,
									metadata,
									toOneEntities,
									tupleContext.getTupleTypeContext() ),
							SnapshotType.UPDATE );
					// We assume there are no duplicated keys
					break;
				}
			}
		}
		return Arrays.asList( tuples );
	}
589494
public function setResults($results)
    {
        // hydrate model
        foreach ($results as $entry) {
            /** @var EntityDataModel $model */
            $model = $this->getModel();
            $model->setEntityManager($this->getEntityManager());

            // check for json
            if (array_key_exists('[json]', $entry)) {
                $entry = json_decode($entry['[json]']);
            }

            $model = $this->populate($entry, $model);

            $this->collection[] = $model;
        }

        $this->setCount(count($this->collection));

        return $this;
    }
1178441
private List iterateAndReturn(ResultSet rSet, EntityMetadata metadata) {
        MetamodelImpl metaModel =
            (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(metadata.getPersistenceUnit());
        EntityType entityType = metaModel.entity(metadata.getEntityClazz());

        Iterator<Row> rowIter = rSet.iterator();
        List results = new ArrayList();

        Map<String, Object> relationalValues = new HashMap<String, Object>();

        while (rowIter.hasNext()) {
            Object entity = null;
            Row row = rowIter.next();
            populateObjectFromRow(metadata, metaModel, entityType, results, relationalValues, entity, row);
        }
        return results;
    }
405747
private List<Tuple> tuplesResult(EntityKey[] keys, TupleContext tupleContext, ClosableIterator<NodeWithEmbeddedNodes> nodes, Long txId, HttpNeo4jEntityQueries queries) {
		// The list is initialized with null because some keys might not have a corresponding node
		Tuple[] tuples = new Tuple[keys.length];
		while ( nodes.hasNext() ) {
			NodeWithEmbeddedNodes node = nodes.next();
			for ( int i = 0; i < keys.length; i++ ) {
				String[] keyNames = keys[i].getColumnNames();
				Object[] keyValues = keys[i].getColumnValues();
				Map<String, Object> nodeProperties = node.getOwner().getProperties();
				if ( RemoteNeo4jHelper.matches( nodeProperties, keyNames, keyValues ) ) {
					EntityKeyMetadata metadata = keys[i].getMetadata();
					Map<String, Node> toOneEntities = HttpNeo4jAssociatedNodesHelper.findAssociatedNodes( client, txId, node, metadata,
							tupleContext.getTupleTypeContext(), queries );
					tuples[i] = new Tuple(
							new HttpNeo4jTupleSnapshot(
									node,
									metadata,
									toOneEntities,
									tupleContext.getTupleTypeContext() ),
							SnapshotType.UPDATE );
					// We assume there are no duplicated keys
					break;
				}
			}
		}
		return Arrays.asList( tuples );
	}
704467
@SuppressWarnings("unchecked")
    private <T extends IEntity> List<T> getResultEntities(List<IntuitMessage> intuitMessages) {
        List<T> resultEntities = new ArrayList<T>();
        int i = 0;
        for(IntuitMessage intuitMessage : intuitMessages) {
            if(!isContainResponse(intuitMessage, i)) {
                LOG.warn("Response object with index="+i+" was expected, got nothing.");
            } else {
                resultEntities.add((T) getReturnEntity(intuitMessage, i));
            }
            i++;
        }

        return resultEntities;
    }
961258
@SuppressWarnings("unchecked")
    public static final List<Map<String, Object>> getDocuments(Map<String, Object> result) {
        if (MapUtils.isNotEmpty(result) && result.containsKey(RESPONSE_KEY)) {
            Map<String, Object> response = (Map<String, Object>)result.get(RESPONSE_KEY);
            if (MapUtils.isNotEmpty(response) && response.containsKey(DOCUMENTS_KEY)) {
                return  (List<Map<String, Object>>)response.get(DOCUMENTS_KEY);
            }
        }

        return null;
    }
379476
public List<ENTITY> find(Match... matches) {
        return find(Arrays.asList(matches), new ArrayList<Order>(0));
    }
761739
public static <T extends Node> List<T> findNodes(List<Node> nodes, Class<T> cls) {
        List<T> results = new ArrayList<>();
        findNodes(nodes, cls, results);
        return results;
    }
1052344
public static Collection<SearchResultDTO> searchResultDTOs(SearchResults results) {
        return Lists.newArrayList(Iterables.transform(results, new Function<SearchResults.Result, SearchResultDTO>() {
            @Override
            public SearchResultDTO apply(Result input) {
                return new SearchResultDTO(
                        new ResourceDTO(input.getResource().getId(), unwrapMap(input.getResource().getAttributes())),
                        input.getMetrics());
            }
        }));
    }
1361297
protected void extractResult(Session session, Health.Builder builder)
			throws Exception {
		Result result = session.query(CYPHER, Collections.emptyMap());
		builder.up().withDetail("nodes",
				result.queryResults().iterator().next().get("nodes"));
	}
138986
public void setResults(java.util.Collection<SearchRecord> results) {
        if (results == null) {
            this.results = null;
            return;
        }

        this.results = new java.util.ArrayList<SearchRecord>(results);
    }
1309420
def select(*queries, **kwargs):
    
    def make_query(*args):
        def simple_query(nodes):
            if len(args) == 0:
                return nodes
            pred = args[0]
            results = []
            if isinstance(pred, list):
                funcs = [make_query(q) for q in pred]
                return __or(funcs, nodes)
            elif isinstance(pred, tuple):
                name, attrs = pred[0], pred[1:]
                name_pred = __make_name_pred(name)
                attrs_pred = __make_attrs_pred(attrs)
                for n in nodes:
                    if name_pred(n.name) and attrs_pred(n.attrs):
                        results.append(n)
            else:
                name_pred = __make_name_pred(pred)
                for n in nodes:
                    if name_pred(n.name):
                        results.append(n)
            return results
        if len(args) > 1:
            return __compose(make_query(*args[1:]), simple_query)
        return simple_query

    def deep_query(query, nodes):
        """ Slide the query down the branches. """
        def inner(children):
            results = []
            for c in children:
                if query([c]):
                    results.append(c)
                results.extend(inner(c.children))
            return results
        return inner(nodes)

    def unique(roots):
        seen = set()
        results = []
        for r in roots:
            if r not in seen:
                seen.add(r)
                results.append(r)
        return results

    def compiled_query(nodes):
        """
        This is the compiled query that can be run against a configuration.
        """
        query = make_query(*queries)

        roots = kwargs.get("roots", True)
        if kwargs.get("deep", False):
            results = deep_query(query, nodes)
            if roots:
                results = unique([r.root for r in results])
        elif roots:
            results = unique([n.root for n in query(nodes)])
        else:
            results = query(nodes)

        one = kwargs.get("one")
        if one is None:
            return SearchResult(children=results)
        return results[one] if results else None
    return compiled_query
884330
protected function cacheResults(array $results)
    {
        $mapper = $this->mapper;

        // When hydrating EmbeddedValue object, they'll likely won't
        // have a primary key set.
        if ($mapper->getEntityMap()->getKeyName() !== null) {
            $mapper->getEntityCache()->add($results);
        }
    }
638093
public static Document getResultSetAsXML(ResultSet rs, String tableName, String keyName) throws Exception {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document doc = builder.newDocument();
        Element results = doc.createElement("Results");
        doc.appendChild(results);

        ResultSetMetaData rsmd = rs.getMetaData();
        // add the name of the table
        Element tableNameElement = doc.createElement("table");
        tableNameElement.setAttribute("name", tableName);
        tableNameElement.setAttribute("key", keyName);
        results.appendChild(tableNameElement);

        int colCount = rsmd.getColumnCount();

        while (rs.next()) {
            Element row = doc.createElement("Row");
            tableNameElement.appendChild(row);
            for (int i = 1; i <= colCount; i++) {
                String columnName = rsmd.getColumnName(i);
                Object value = rs.getObject(i);
                // If the value is null, don't put it in the XML Document
                if (value != null) {
                    String colType = rsmd.getColumnTypeName(i);
                    Element node = doc.createElement(columnName);
                    if (colType.equals("bytea")) {
                        String byteaStr = "";
                        byte[] imgBytes = rs.getBytes(i);
                        for (int byteIndex = 0; byteIndex < imgBytes.length; byteIndex++) {
                            if (byteIndex != 0) {
                                byteaStr = byteaStr + ";" + Byte.toString(imgBytes[byteIndex]);
                            } else {
                                byteaStr = Byte.toString(imgBytes[byteIndex]);
                            }
                        }
                        node.appendChild(doc.createTextNode(byteaStr));
                    } else {
                        node.appendChild(doc.createTextNode(value.toString()));
                    }
                    row.appendChild(node);
                }
            }
        }
        return doc;
    }
553431
def build_list_result(results, xml):
    
    xml_count = xml.xpath('//div[@class="paginator"]/span[@class="count"]/text()')
    xml_next = xml.xpath('//div[@class="paginator"]/span[@class="next"]/a/@href')
    count = int(re.search(r'\d+', xml_count[0]).group()) if xml_count else len(results)
    next_start = int(re.search(r'start=(\d+)', xml_next[0]).groups()[0]) if xml_next else None
    return {'results': results, 'count': count, 'next_start': next_start}