Handle element collection attribute.

@param translator
the translator
@param attribute
the attribute
@param typeQueryBuilder
the type query builder
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);

    }
40728
<S, T> Converter<S, T> converterForClass(String attribute, Class<S> sourceClass, Class<T> destinationClass) {
        List<Converter> list = attributeConverters.get(attribute);
        if (list != null) {
            for (Converter converter : list) {
                if (converter.canConvert(sourceClass, destinationClass)) {
                    return converter;
                }
            }
        }
        return null;
    }
1011249
private void performTransform(String xslt, Document document,
                                  Result result)
        throws TransformerException, ConfigurationException, XpathException {
        try {
            StreamSource source = new StreamSource(new StringReader(xslt));
            TransformerFactory tf = XMLUnit.newTransformerFactory();
            ErrorListener el = new ErrorListener() {
                    public void error(TransformerException ex)
                        throws TransformerException {
                        // any error in our simple stylesheet must be fatal
                        throw ex;
                    }
                    public void fatalError(TransformerException ex)
                        throws TransformerException {
                        throw ex;
                    }
                    public void warning(TransformerException ex) {
                        // there shouldn't be any warning
                        ex.printStackTrace();
                    }
                };
            tf.setErrorListener(el);
            Transformer transformer = tf.newTransformer(source);
            // Issue 1985229 says Xalan-J 2.7.0 may return null for
            // illegal input
            if (transformer == null) {
                throw new XpathException("failed to obtain an XSLT transformer"
                                         + " for XPath expression.");
            }
            transformer.setErrorListener(el);
            transformer.transform(new DOMSource(document), result);
        } catch (javax.xml.transform.TransformerConfigurationException ex) {
            throw new ConfigurationException(ex);
        }
    }
1187874
protected void handleNodeAttributes(Object node, Map attributes) {
        // first, short circuit
        if (node == null) {
            return;
        }

        for (Closure attrDelegate : getProxyBuilder().getAttributeDelegates()) {
            FactoryBuilderSupport builder = this;
            if (attrDelegate.getOwner() instanceof FactoryBuilderSupport) {
                builder = (FactoryBuilderSupport) attrDelegate.getOwner();
            } else if (attrDelegate.getDelegate() instanceof FactoryBuilderSupport) {
                builder = (FactoryBuilderSupport) attrDelegate.getDelegate();
            }

            attrDelegate.call(builder, node, attributes);
        }

        if (getProxyBuilder().getCurrentFactory().onHandleNodeAttributes(getProxyBuilder().getChildBuilder(), node, attributes)) {
            getProxyBuilder().setNodeAttributes(node, attributes);
        }
    }
431289
function transformSpecialAttribute(name, attribute) {
        if (t.isJSXExpressionContainer(attribute.value)) {
            let value = attribute.value.expression;
            switch (name) {
                case "ui5ControlData":
                    renderer.renderControlData(value);
                    break;
                case "ui5ElementData":
                    renderer.renderElementData(value);
                    break;
                case "ui5AccessibilityData":
                    renderer.handleAccessibilityData(value);
                    break;
                default:
                    error(attribute, "Unknown special attribute: '" + name + "'.");
            }
        } else {
            error(attribute, "Only expressions supported in special attributes.");
        }
    }
682485
public void setElementType (Class type, String fieldName, Class elementType) {
		ObjectMap<String, FieldMetadata> fields = getFields(type);
		FieldMetadata metadata = fields.get(fieldName);
		if (metadata == null) throw new JsonException("Field not found: " + fieldName + " (" + type.getName() + ")");
		metadata.elementType = elementType;
	}
218876
protected void setIntToRangeElement(String attribute, Integer val) {
        Element ele = $(rangeInputElement).asElement();
        if (ele != null) {
            ele.setPropertyInt(attribute, val);
        }
    }
685681
public static void doParse(Element element, BeanDefinitionBuilder builder) {
        Element messageSelectorElement = DomUtils.getChildElementByTagName(element, "selector");
        if (messageSelectorElement != null) {
            Element selectorStringElement = DomUtils.getChildElementByTagName(messageSelectorElement, "value");
            if (selectorStringElement != null) {
                builder.addPropertyValue("messageSelector", DomUtils.getTextValue(selectorStringElement));
            }

            Map<String, String> messageSelectorMap = new HashMap<>();
            List<?> messageSelectorElements = DomUtils.getChildElementsByTagName(messageSelectorElement, "element");
            for (Iterator<?> iter = messageSelectorElements.iterator(); iter.hasNext();) {
                Element selectorElement = (Element) iter.next();
                messageSelectorMap.put(selectorElement.getAttribute("name"), selectorElement.getAttribute("value"));
            }
            builder.addPropertyValue("messageSelectorMap", messageSelectorMap);
        }
    }
1337069
public void execute(
          TransformerImpl transformer)
            throws TransformerException
  {
    try
    {
      // Note the content model is:
      // <!ENTITY % instructions "
      // %char-instructions;
      // | xsl:processing-instruction
      // | xsl:comment
      // | xsl:element
      // | xsl:attribute
      // ">
      String data = transformer.transformToString(this);

      transformer.getResultTreeHandler().comment(data);
    }
    catch(org.xml.sax.SAXException se)
    {
      throw new TransformerException(se);
    }
  }
605143
function translateElement(element, locale) {
    var $element = $(element),
        keyPath = $element.data('translate');

    var translation = getTranslation(keyPath, locale);
    if(translation) {
      $(element).text(translation);
    }
  }
1278915
private void parseEntSubAttributes(final Entity ent, final Node node) throws ResourceXMLParserException {
        final Element node1 = (Element) node;
        //load all sub elements called "attribute" as properties
        for (final Object attribute : node1.selectNodes(ATTRIBUTE_TAG)) {
            Element attr=(Element) attribute;
            if(null==attr.selectSingleNode("@" + ATTRIBUTE_NAME_ATTR)) {
                throw new ResourceXMLParserException(
                    ATTRIBUTE_TAG + " element has no '" + ATTRIBUTE_NAME_ATTR + "' attribute: "
                    + reportNodeErrorLocation(attr));
            }
            String attrname = attr.selectSingleNode("@" + ATTRIBUTE_NAME_ATTR).getStringValue();

            String attrvalue;
            //look for "value" attribute
            if(null!=attr.selectSingleNode("@"+ATTRIBUTE_VALUE_ATTR)) {
                attrvalue = attr.selectSingleNode("@" + ATTRIBUTE_VALUE_ATTR).getStringValue();
            }else if(null!= attr.getText()) {
                //look for text content
                attrvalue = attr.getText();
            }else {
                throw new ResourceXMLParserException(
                    ATTRIBUTE_TAG + " element has no '" + ATTRIBUTE_VALUE_ATTR + "' attribute or text content: "
                    + reportNodeErrorLocation(attr));
            }

            ent.properties.setProperty(attrname, attrvalue);
        }
    }
765752
private void resolveTypesUsingImports(Expression expression) {
    if (expression instanceof NodeWithType) {
      NodeWithType<?, ?> nodeWithType = ((NodeWithType<?, ?>) expression);
      nodeWithType.setType(getQualifiedName(nodeWithType.getType()));
    }

    // Recurse downward in the expression
    expression
        .getChildNodes()
        .stream()
        .filter(Expression.class::isInstance)
        .map(Expression.class::cast)
        .forEach(this::resolveTypesUsingImports);
  }
314186
private List<DataElementInfo> processDataElements(TypeElement type, TemplateSelector templateSelector,
            org.jsoup.nodes.Element root) {
        List<DataElementInfo> dataElements = new ArrayList<>();

        // fields
        ElementFilter.fieldsIn(type.getEnclosedElements()).stream()
                .filter(field -> MoreElements.isAnnotationPresent(field, DataElement.class))
                .forEach(field -> {

                    // verify the field
                    if (field.getModifiers().contains(Modifier.PRIVATE)) {
                        abortWithError(field, "@%s member must not be private", DataElement.class.getSimpleName());
                    }
                    if (field.getModifiers().contains(Modifier.STATIC)) {
                        abortWithError(field, "@%s member must not be static", DataElement.class.getSimpleName());
                    }
                    Kind kind = getDataElementInfoKind(field.asType());
                    if (kind == Kind.Custom) {
                        warning(field, "Unknown type %s. Consider using one of %s.", field.asType(),
                                EnumSet.complementOf(EnumSet.of(Kind.Custom)));
                    }

                    // verify the selector
                    String selector = getSelector(field);
                    verifySelector(selector, field, templateSelector, root);

                    // verify the HTMLElement type
                    String typeName = MoreTypes.asTypeElement(field.asType()).getQualifiedName().toString();
                    if (kind == Kind.HTMLElement) {
                        verifyHTMLElement(typeName, selector, field, templateSelector, root);
                    }

                    // create info class for template processing
                    dataElements.add(new DataElementInfo(typeName, field.getSimpleName().toString(), selector,
                            kind, false));
                });

        // methods
        ElementFilter.methodsIn(type.getEnclosedElements()).stream()
                .filter(method -> MoreElements.isAnnotationPresent(method, DataElement.class))
                .forEach(method -> {

                    // verify method
                    if (method.getModifiers().contains(Modifier.PRIVATE)) {
                        abortWithError(method, "@%s method must not be private", DataElement.class.getSimpleName());
                    }
                    if (method.getModifiers().contains(Modifier.STATIC)) {
                        abortWithError(method, "@%s method must not be static", DataElement.class.getSimpleName());
                    }
                    Kind kind = getDataElementInfoKind(method.getReturnType());
                    if (kind == Kind.Custom) {
                        warning(method, "Unknown return type %s. Consider using one of %s.", method.getReceiverType(),
                                EnumSet.complementOf(EnumSet.of(Kind.Custom)));
                    }
                    if (!method.getParameters().isEmpty()) {
                        abortWithError(method, "@%s method must not have parameters",
                                DataElement.class.getSimpleName());
                    }

                    // verify the selector
                    String selector = getSelector(method);
                    verifySelector(selector, method, templateSelector, root);

                    // verify the HTMLElement type
                    String typeName = MoreTypes.asTypeElement(method.getReturnType())
                            .getQualifiedName().toString();
                    if (kind == Kind.HTMLElement) {
                        verifyHTMLElement(typeName, selector, method, templateSelector, root);
                    }
                    // create info class for template processing
                    dataElements.add(new DataElementInfo(typeName, method.getSimpleName().toString(), selector,
                            kind, true));
                });

        return dataElements;
    }
843202
function transformAttribute(attribute) {
        if (t.isJSXAttribute(attribute)) {
            transfromPlainAttribute(attribute);
        } else if (t.isJSXSpreadAttribute(attribute)) {
            renderer.handleSpreadAttribute(attribute.argument);
        } else {
            error(attribute, "Unable to process attribute.");
        }
    }
1160065
static <S> String translate(CriteriaQuery criteriaQuery)
    {
        QueryBuilder builder = new CriteriaQueryTranslator.QueryBuilder();

        // validate if criteria query is valid

        /**
         * select, from clause is mandatory
         * 
         * multiple from clause not support where clause is optional
         * 
         */

        Selection<S> select = criteriaQuery.getSelection();

        if (select != null)
        {
            builder.appendSelectClause();

        }

        if (select.getClass().isAssignableFrom(DefaultCompoundSelection.class)
                && ((CompoundSelection) select).isCompoundSelection())
        {
            List<Selection<?>> selections = ((CompoundSelection) select).getCompoundSelectionItems();
            builder.appendMultiSelect(selections);
        }
        else if (select instanceof AggregateExpression)
        {
            builder.appendAggregate(((AggregateExpression) select).getAggregation());
        }
        else
        {
            String alias = select.getAlias();

            if (!StringUtils.isEmpty(alias))
            {
                builder.appendAlias(alias);
            }

            Attribute attribute = ((DefaultPath) select).getAttribute();

            if (attribute != null)
            {
                builder.appendAttribute(attribute);
            }
        }
        Class<? extends S> clazzType = select.getJavaType();

        Set<Root<?>> roots = criteriaQuery.getRoots();

        Root<?> from = roots.iterator().next();

        Class entityClazz = from.getJavaType();

        builder.appendFromClause();

        // select.alias(paramString)
        builder.appendFrom(entityClazz);
        builder.appendAlias(from.getAlias() != null ? from.getAlias() : select.getAlias());
        Predicate where = criteriaQuery.getRestriction(); // this could be null.
        if (where != null)
        {
            builder.appendWhereClause();
            List<Expression<Boolean>> expressions = where.getExpressions();
            for (Expression expr : expressions)
            {
                builder.appendWhere(expr, from.getAlias());
            }

        }

        List<Order> orderings = criteriaQuery.getOrderList();

        if (orderings != null && !orderings.isEmpty())
        {
            builder.appendOrderClause(where == null);
            String alias = from.getAlias() != null ? from.getAlias() : select.getAlias();
            builder.appendMultiOrdering(orderings, alias);
        }
        return builder.getQuery();

        // check that roots has to be one. multiple clause not yet supported

    }
1314563
public function scopeWhereExtensionAttribute(Builder $query, $type, $key, $value)
    {
        // We do this for querying, searching and sorting with source attributes
        $this->setNodeTypeName($type);

        return $query->whereHas('nodeSourceExtensions', function (Builder $query) use ($key, $value)
        {
            $query->where(source_table_name($this->getNodeTypeName()) . '.' . $key, $value);
        });
    }
504060
public static void translate(Syntax syntax, Definition source, Definition target) throws GenericException {
        List<Definition> targets;
        IntBitSet stopper;

        targets = new ArrayList<Definition>();
        targets.add(target);
        stopper = new IntBitSet();
        stopper.add(target.getAttribute().symbol);
        translate(syntax, ISOLATED, source, targets, new int[] {}, new IntBitSet[] { stopper });
    }