A helper function to explain each of the matched attributes returned by the explain-API

@param attribute The attribute found
@param collectExpandedQueryMap ?
@param query the query used to find the attribute
@return Set of explained query strings
778843
public Set<ExplainedQueryString> convertAttributeToExplainedAttribute(
      Attribute attribute, Map<String, String> collectExpandedQueryMap, Query<Entity> query) {
    EntityType attributeMetaData = dataService.getEntityType(ATTRIBUTE_META_DATA);
    String attributeID = attribute.getIdentifier();
    Explanation explanation =
        elasticSearchExplainService.explain(query, attributeMetaData, attributeID);
    return elasticSearchExplainService.findQueriesFromExplanation(
        collectExpandedQueryMap, explanation);
  }
343617
public List<Extensions> queryByExtension(String extensionName)
			throws SQLException {

		QueryBuilder<Extensions, Void> qb = queryBuilder();

		setUniqueWhere(qb.where(), extensionName, false, null, false, null);

		List<Extensions> extensions = qb.query();

		return extensions;
	}
752478
private void _deserializeQueryField(Query query, Element field) throws PageException, ConverterException {
	String name = field.getAttribute("name");
	NodeList list = field.getChildNodes();
	int len = list.getLength();
	int count = 0;
	for (int i = 0; i < len; i++) {
	    Node node = list.item(i);
	    if (node instanceof Element) {
		query.setAt(KeyImpl.init(name), ++count, _deserialize((Element) node));
	    }
	}

    }
999702
Set<String> findMatchedWords(Explanation explanation) {
    Set<String> words = new HashSet<>();
    String description = explanation.getDescription();
    if (description.startsWith(Options.SUM_OF.toString())
        || description.startsWith(Options.PRODUCT_OF.toString())) {
      if (newArrayList(explanation.getDetails()).stream().allMatch(this::reachLastLevel)) {
        words.add(extractMatchedWords(explanation.getDetails()));
      } else {
        for (Explanation subExplanation : explanation.getDetails()) {
          words.addAll(findMatchedWords(subExplanation));
        }
      }
    } else if (description.startsWith(Options.MAX_OF.toString())) {
      Explanation maxExplanation =
          newArrayList(explanation.getDetails())
              .stream()
              .max(
                  (explanation1, explanation2) ->
                      Float.compare(explanation1.getValue(), explanation2.getValue()))
              .orElseThrow(
                  () ->
                      new IllegalStateException(
                          "explanation.getDetails() shouldn't return an empty array"));
      words.addAll(findMatchedWords(maxExplanation));
    } else if (description.startsWith(Options.WEIGHT.toString())) {
      words.add(getMatchedWord(description));
    }
    return words;
  }
755577
private Map<String, Object> parseInsertIntoQuery(String query)
    {
        Map<String, Object> persistDetails = new HashMap<String, Object>();
        String insertReg = "(?i)^insert\\s+into\\s+(\\S+)\\s+(?:as\\s+(\\S+)\\s+)?FROM\\s+\\((.*)\\)$";
        Pattern r = Pattern.compile(insertReg);

        Matcher m = r.matcher(query);
        if (m.find())
        {
            try
            {
                parsePersistClause(m.group(1), persistDetails);
                persistDetails.put("format", m.group(2));
                persistDetails.put("fetchQuery", m.group(3));
            }
            catch (Exception e)
            {
                throw new KunderaException("Invalid Query");
            }
        }
        else
        {
            throw new KunderaException("Invalid Query");
        }

        return persistDetails;
    }
1151113
private Map<UUID, Long> getExtendedAttributes(AttributeUpdaterOperation operation) {
        Collection<AttributeUpdate> updates = operation.getAttributeUpdates();
        if (updates == null) {
            return Collections.emptyMap();
        }

        return updates.stream()
                .filter(au -> !Attributes.isCoreAttribute(au.getAttributeId()))
                .collect(Collectors.toMap(AttributeUpdate::getAttributeId, AttributeUpdate::getValue));
    }
398802
@Override
    public ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern, String attributeNamePattern) throws SQLException
    {
        checkClosed();
        throw SQLError.noSupport();
    }
871768
private void analyzeAutoGeneratedQueries(long corpusID)
  {
    // read the example queries from the staging area
    List<ExampleQuery> exampleQueries = getJdbcTemplate().query(
      "SELECT * FROM _" + EXAMPLE_QUERIES_TAB, new RowMapper<ExampleQuery>()
      {
        @Override
        public ExampleQuery mapRow(ResultSet rs, int i) throws SQLException
        {
          ExampleQuery eQ = new ExampleQuery();
          eQ.setExampleQuery(rs.getString("example_query"));
          return eQ;
        }
      });

    // count the nodes of the aql Query
    countExampleQueryNodes(exampleQueries);

    // fetch the operators
    getOperators(exampleQueries, "\\.(\\*)?|\\>|\\>\\*|_i_");

    writeAmountOfNodesBack(exampleQueries);
  }
825965
@Override
    public <K, V> MapAttribute<? super X, K, V> getMap(String paramName, Class<K> keyClazz, Class<V> valueClazz)
    {
        PluralAttribute<X, ?, ?> declaredAttrib = getDeclaredPluralAttribute(paramName);

        if (onCheckMapAttribute(declaredAttrib, valueClazz))
        {
            if (valueClazz != null && valueClazz.equals(((MapAttribute<X, K, V>) declaredAttrib).getKeyJavaType()))
            {
                return (MapAttribute<X, K, V>) declaredAttrib;

            }
        }

        PluralAttribute<? super X, ?, ?> superAttrib = getPluralAttriute(paramName);

        if (onCheckMapAttribute(superAttrib, valueClazz))
        {
            if (valueClazz != null && valueClazz.equals(((MapAttribute<? super X, K, V>) superAttrib).getKeyJavaType()))
            {
                return (MapAttribute<? super X, K, V>) superAttrib;

            }
        }

        throw new IllegalArgumentException(
                "attribute of the given name and type is not present in the managed MapAttribute type, for name:"
                        + paramName + " , value type:" + valueClazz + "key tpye:" + keyClazz);
    }
838929
@Override
    @SuppressWarnings("unchecked")
    public <T> List<T> getResultList(JPAQuery<T> query, Expression<T> projection) {
        Query jpaQuery = query.createQuery();

        if (jpaQuery instanceof QueryImpl) {
            QueryImpl casted = (QueryImpl) jpaQuery;
            if (casted.getDatabaseQuery() instanceof ObjectLevelReadQuery) {
                Field f = ReflectionUtils.findField(ObjectLevelReadQuery.class, "joinedAttributeManager");
                f.setAccessible(true);
                JoinedAttributeManager old = (JoinedAttributeManager) ReflectionUtils.getField(f, casted.getDatabaseQuery());
                if (old != null) {
                    FixedJoinerAttributeManager newManager = new FixedJoinerAttributeManager(old.getDescriptor(), old.getBaseExpressionBuilder(),
                            old.getBaseQuery());
                    newManager.copyFrom(old);
                    ReflectionUtils.setField(f, casted.getDatabaseQuery(), newManager);
                }
            }
        }

        if (projection instanceof FactoryExpression) {
            FactoryExpression factoryExpression = (FactoryExpression) projection;

            List<?> results = jpaQuery.getResultList();
            List<Object> rv = new ArrayList<>(results.size());
            for (Object o : results) {
                if (o != null) {
                    if (!o.getClass().isArray()) {
                        o = new Object[]{o};
                    }
                    rv.add(factoryExpression.newInstance((Object[]) o));
                } else {
                    rv.add(null);
                }
            }
            return (List<T>) rv;
        } else {
            return jpaQuery.getResultList();
        }
    }
761888
private void handleElementCollectionAttribute(CQLTranslator translator, Attribute attribute,
            StringBuilder typeQueryBuilder)
    {
        String dataType = CassandraValidationClassMapper.getValidationClass(attribute.getJavaType(), true);

        // CQL Type of collection column
        String collectionCqlType = translator.getCQLType(dataType);

        // Collection Column Name
        String collectionColumnName = new String(((AbstractAttribute) attribute).getJPAColumnName());

        // Generic Type list
        StringBuilder genericTypesBuilder = null;
        List<Class<?>> genericClasses = PropertyAccessorHelper.getGenericClasses((Field) attribute.getJavaMember());
        if (!genericClasses.isEmpty())
        {
            genericTypesBuilder = new StringBuilder();
            if (MapType.class.getSimpleName().equals(dataType) && genericClasses.size() == 2)
            {
                genericTypesBuilder.append(Constants.STR_LT);
                if (genericClasses.get(0).getAnnotation(Embeddable.class) != null)
                {
                    String frozenKey = CQLTranslator.FROZEN + Constants.STR_LT + Constants.ESCAPE_QUOTE
                            + genericClasses.get(0).getSimpleName() + Constants.ESCAPE_QUOTE + Constants.STR_GT;
                    genericTypesBuilder.append(frozenKey);
                }
                else
                {
                    String keyDataType = CassandraValidationClassMapper.getValidationClass(genericClasses.get(0), true);
                    genericTypesBuilder.append(translator.getCQLType(keyDataType));
                }
                genericTypesBuilder.append(Constants.SPACE_COMMA);
                if (genericClasses.get(1).getAnnotation(Embeddable.class) != null)
                {
                    String frozenKey = CQLTranslator.FROZEN + Constants.STR_LT + Constants.ESCAPE_QUOTE
                            + genericClasses.get(1).getSimpleName() + Constants.ESCAPE_QUOTE + Constants.STR_GT;
                    genericTypesBuilder.append(frozenKey);
                }
                else
                {
                    String keyDataType = CassandraValidationClassMapper.getValidationClass(genericClasses.get(1), true);
                    genericTypesBuilder.append(translator.getCQLType(keyDataType));
                }
                genericTypesBuilder.append(Constants.STR_GT);
            }
            else if ((ListType.class.getSimpleName().equals(dataType) || SetType.class.getSimpleName().equals(dataType))
                    && genericClasses.size() == 1)
            {
                genericTypesBuilder.append(Constants.STR_LT);
                if (genericClasses.get(0).getAnnotation(Embeddable.class) != null)
                {
                    String frozenKey = CQLTranslator.FROZEN + Constants.STR_LT + Constants.ESCAPE_QUOTE
                            + genericClasses.get(0).getSimpleName() + Constants.ESCAPE_QUOTE + Constants.STR_GT;
                    genericTypesBuilder.append(frozenKey);
                }
                else
                {
                    String keyDataType = CassandraValidationClassMapper.getValidationClass(genericClasses.get(0), true);
                    genericTypesBuilder.append(translator.getCQLType(keyDataType));
                }
                genericTypesBuilder.append(Constants.STR_GT);
            }
            else
            {
                throw new SchemaGenerationException("Incorrect collection field definition for "
                        + ((AbstractAttribute) attribute).getJPAColumnName()
                        + ". Generic Types must be defined correctly.");
            }
        }

        if (genericTypesBuilder != null)
        {
            collectionCqlType += genericTypesBuilder.toString();
        }

        translator.appendColumnName(typeQueryBuilder, collectionColumnName, collectionCqlType);
        typeQueryBuilder.append(Constants.SPACE_COMMA);

    }
1018657
public AttributeQuery getAttributeQuery(final String _attributeName)
    {
        if (this.query == null) {
            try {
                final String attribute = getAttr4Select(_attributeName);
                this.query = new AttributeQuery(this.typeUUID, attribute.isEmpty() ? _attributeName : attribute)
                                    .setCompanyDependent(isCompanyDependent());
                prepareQuery();
            } catch (final EFapsException e) {
                QueryBuilder.LOG.error("Could not open AttributeQuery for uuid: {}", this.typeUUID);
            }
        }
        return (AttributeQuery) this.query;
    }
1085801
def query_string_attribute(self, target, display_mask, attr):
    """"""
    reply = NVCtrlQueryStringAttributeReplyRequest(display=self.display,
                                                   opcode=self.display.get_extension_major(extname),
                                                   target_id=target.id(),
                                                   target_type=target.type(),
                                                   display_mask=display_mask,
                                                   attr=attr)
    if not reply._data.get('flags'):
        return None
    return str(reply._data.get('string')).strip('\0')
629811
private Object getAttribute( DBCollection content,
                                 String fieldName ) {
        return content.findOne(HEADER_QUERY).get(fieldName);
    }
77410
public final Map<String, Object> fetchRelation(Class<?> clazz, String query)
    {
        // TODO: need to return list.
        return search(clazz, query, Constants.INVALID, Constants.INVALID, true);
    }
857244
def refine(query, description):
    

    for attribute, arguments in description.items():
        if hasattr(query, attribute):
            attribute = getattr(query, attribute)
        else:
            raise ValueError("Unknown query method: " + attribute)

        # query descriptions are often automatically generated, and
        # may include empty calls, which we skip
        if utils.isempty(arguments):
            continue

        if callable(attribute):
            method = attribute
            if isinstance(arguments, dict):
                query = method(**arguments)
            elif isinstance(arguments, list):
                query = method(*arguments)
            else:
                query = method(arguments)
        else:
            setattr(attribute, arguments)

    return query
1030842
@SuppressWarnings({ "unchecked" })
    private Predicate convertParametersToPredicate(Root<?> from, CriteriaQuery<?> query) {
        List<Predicate> predicates = new ArrayList<>();
        for (Map.Entry<String, Set<Object>> value : request.getParameters().entrySet()) {
            Subquery<JPAEntry> subquery = buildJPAEntrySubquery(value.getKey(), value.getValue(), from, query);
            predicates.add(builder.exists(subquery));
        }
        if (request.isAndJoined()) {
            return builder.and(Iterables.toArray(predicates, Predicate.class));
        } else {
            return builder.or(Iterables.toArray(predicates, Predicate.class));
        }
    }