Examples of QPropertyDefinitionBuilder


Examples of org.apache.jackrabbit.spi.commons.nodetype.QPropertyDefinitionBuilder

     * @return
     * @throws RepositoryException
     */
    static QPropertyDefinition createQPropertyDefinition(Name declaringNodeType, Element pdefElement,
                                                  NamePathResolver resolver, QValueFactory qValueFactory) throws RepositoryException {
        QPropertyDefinitionBuilder builder = new QPropertyDefinitionBuilder();

        buildQItemDefinition(declaringNodeType, pdefElement, resolver, builder);

        if (pdefElement.hasAttribute(REQUIREDTYPE_ATTRIBUTE)) {
            builder.setRequiredType(PropertyType.valueFromName(pdefElement.getAttribute(REQUIREDTYPE_ATTRIBUTE)));
        }

        if (pdefElement.hasAttribute(MULTIPLE_ATTRIBUTE)) {
            builder.setMultiple(Boolean.valueOf(pdefElement.getAttribute(MULTIPLE_ATTRIBUTE)));
        }

        if (pdefElement.hasAttribute(FULL_TEXT_SEARCHABLE_ATTRIBUTE)) {
            builder.setFullTextSearchable(Boolean.valueOf(pdefElement.getAttribute(FULL_TEXT_SEARCHABLE_ATTRIBUTE)));
        }
        if (pdefElement.hasAttribute(QUERY_ORDERABLE_ATTRIBUTE)) {
            builder.setQueryOrderable(Boolean.valueOf(pdefElement.getAttribute(QUERY_ORDERABLE_ATTRIBUTE)));
        }

        int requiredType = builder.getRequiredType();               
        Element child = DomUtil.getChildElement(pdefElement, DEFAULTVALUES_ELEMENT, null);
        if (child != null) {
            ElementIterator it = DomUtil.getChildren(child, DEFAULTVALUE_ELEMENT, null);
            while (it.hasNext()) {
                String jcrVal = DomUtil.getText(it.nextElement());
                if (jcrVal == null) {
                    jcrVal = "";
                }
                QValue qValue;
                if (requiredType == PropertyType.BINARY) {
                    // TODO: improve
                    Value v = new ValueFactoryQImpl(qValueFactory, resolver).createValue(jcrVal, requiredType);
                    qValue = ValueFormat.getQValue(v, resolver, qValueFactory);
                } else {
                    qValue = ValueFormat.getQValue(jcrVal, requiredType, resolver, qValueFactory);
                }
                builder.addDefaultValue(qValue);
            }
        } // else: no default values defined.

        child = DomUtil.getChildElement(pdefElement, VALUECONSTRAINTS_ELEMENT, null);
        if (child != null) {
            ElementIterator it = DomUtil.getChildren(child, VALUECONSTRAINT_ELEMENT, null);
            while (it.hasNext()) {
                String qValue = DomUtil.getText(it.nextElement());
                // in case of name and path constraint, the value must be
                // converted to SPI values
                // TODO: tobefixed. path-constraint may contain trailing *
                builder.addValueConstraint(ValueConstraint.create(requiredType, qValue, resolver));
            }
        }

        child = DomUtil.getChildElement(pdefElement, AVAILABLE_QUERY_OPERATORS_ELEMENT, null);
        if (child == null) {
            builder.setAvailableQueryOperators(new String[0]);
        } else {
            List<String> names = new ArrayList<String>();
            ElementIterator it = DomUtil.getChildren(child, AVAILABLE_QUERY_OPERATOR_ELEMENT, null);
            while (it.hasNext()) {
                String str = DomUtil.getText(it.nextElement());
                names.add(str);
            }
            builder.setAvailableQueryOperators(names.toArray(new String[names.size()]));
        }

        return builder.build();
    }
View Full Code Here

Examples of org.apache.jackrabbit.spi.commons.nodetype.QPropertyDefinitionBuilder


        final QNodeTypeDefinitionBuilder document = new QNodeTypeDefinitionBuilder();
        document.setName(nameFactory.create("", "Document"));
        document.setSupertypes(new Name[]{cmsObject.getName()});
        QPropertyDefinitionBuilder sizeProp = new QPropertyDefinitionBuilder();
        sizeProp.setName(nameFactory.create("", "size"));
        sizeProp.setRequiredType(PropertyType.LONG);
        sizeProp.setDeclaringNodeType(document.getName());
        document.setPropertyDefs(new QPropertyDefinition[]{sizeProp.build()});


        folder.setSupertypes(new Name[]{cmsObject.getName()});

        QNodeDefinitionBuilder folders = new QNodeDefinitionBuilder();
View Full Code Here

Examples of org.apache.jackrabbit.spi.commons.nodetype.QPropertyDefinitionBuilder

     * @return
     * @throws RepositoryException
     */
    static QPropertyDefinition createQPropertyDefinition(Name declaringNodeType, Element pdefElement,
                                                  NamePathResolver resolver, QValueFactory qValueFactory) throws RepositoryException {
        QPropertyDefinitionBuilder builder = new QPropertyDefinitionBuilder();

        buildQItemDefinition(declaringNodeType, pdefElement, resolver, builder);

        if (pdefElement.hasAttribute(REQUIREDTYPE_ATTRIBUTE)) {
            builder.setRequiredType(PropertyType.valueFromName(pdefElement.getAttribute(REQUIREDTYPE_ATTRIBUTE)));
        }

        if (pdefElement.hasAttribute(MULTIPLE_ATTRIBUTE)) {
            builder.setMultiple(Boolean.valueOf(pdefElement.getAttribute(MULTIPLE_ATTRIBUTE)));
        }

        if (pdefElement.hasAttribute(FULL_TEXT_SEARCHABLE_ATTRIBUTE)) {
            builder.setFullTextSearchable(Boolean.valueOf(pdefElement.getAttribute(FULL_TEXT_SEARCHABLE_ATTRIBUTE)));
        }
        if (pdefElement.hasAttribute(QUERY_ORDERABLE_ATTRIBUTE)) {
            builder.setQueryOrderable(Boolean.valueOf(pdefElement.getAttribute(QUERY_ORDERABLE_ATTRIBUTE)));
        }

        int requiredType = builder.getRequiredType();               
        Element child = DomUtil.getChildElement(pdefElement, DEFAULTVALUES_ELEMENT, null);
        if (child != null) {
            ElementIterator it = DomUtil.getChildren(child, DEFAULTVALUE_ELEMENT, null);
            while (it.hasNext()) {
                String jcrVal = DomUtil.getText(it.nextElement());
                if (jcrVal == null) {
                    jcrVal = "";
                }
                QValue qValue;
                if (requiredType == PropertyType.BINARY) {
                    // TODO: improve
                    Value v = new ValueFactoryQImpl(qValueFactory, resolver).createValue(jcrVal, requiredType);
                    qValue = ValueFormat.getQValue(v, resolver, qValueFactory);
                } else {
                    qValue = ValueFormat.getQValue(jcrVal, requiredType, resolver, qValueFactory);
                }
                builder.addDefaultValue(qValue);
            }
        } // else: no default values defined.

        child = DomUtil.getChildElement(pdefElement, VALUECONSTRAINTS_ELEMENT, null);
        if (child != null) {
            ElementIterator it = DomUtil.getChildren(child, VALUECONSTRAINT_ELEMENT, null);
            while (it.hasNext()) {
                String qValue = DomUtil.getText(it.nextElement());
                // in case of name and path constraint, the value must be
                // converted to SPI values
                // TODO: tobefixed. path-constraint may contain trailing *
                builder.addValueConstraint(ValueConstraint.create(requiredType, qValue, resolver));
            }
        }

        child = DomUtil.getChildElement(pdefElement, AVAILABLE_QUERY_OPERATORS_ELEMENT, null);
        if (child == null) {
            builder.setAvailableQueryOperators(new String[0]);
        } else {
            List<String> names = new ArrayList<String>();
            ElementIterator it = DomUtil.getChildren(child, AVAILABLE_QUERY_OPERATOR_ELEMENT, null);
            while (it.hasNext()) {
                String str = DomUtil.getText(it.nextElement());
                names.add(str);
            }
            builder.setAvailableQueryOperators(names.toArray(new String[names.size()]));
        }

        return builder.build();
    }
View Full Code Here

Examples of org.apache.jackrabbit.spi.commons.nodetype.QPropertyDefinitionBuilder

        }

        // property definitions
        List<QPropertyDefinition> properties = new ArrayList<QPropertyDefinition>();
        while (walker.iterateElements(Constants.PROPERTYDEFINITION_ELEMENT)) {
            QPropertyDefinitionBuilder def = getPropDef();
            def.setDeclaringNodeType(type.getName());
            properties.add(def.build());
        }
        type.setPropertyDefs(properties.toArray(new QPropertyDefinition[properties.size()]));

        // child node definitions
        List<QNodeDefinition> nodes = new ArrayList<QNodeDefinition>();
        while (walker.iterateElements(Constants.CHILDNODEDEFINITION_ELEMENT)) {
            QNodeDefinitionBuilder def = getChildNodeDef();
            def.setDeclaringNodeType(type.getName());
            nodes.add(def.build());
        }
        type.setChildNodeDefs(nodes.toArray(new QNodeDefinition[nodes.size()]));

        return type.build();
    }
View Full Code Here

Examples of org.apache.jackrabbit.spi.commons.nodetype.QPropertyDefinitionBuilder

     *                                     illegal name
     * @throws NamespaceException if a namespace is not defined
     */
    private QPropertyDefinitionBuilder getPropDef()
            throws InvalidNodeTypeDefException, NameException, NamespaceException {
        QPropertyDefinitionBuilder def = new QPropertyDefinitionBuilder();
        String name = walker.getAttribute(Constants.NAME_ATTRIBUTE);
        if (name.equals("*")) {
            def.setName(NameConstants.ANY_NAME);
        } else {
            def.setName(resolver.getQName(name));
        }

        // simple attributes
        def.setAutoCreated(Boolean.valueOf(
                walker.getAttribute(Constants.AUTOCREATED_ATTRIBUTE)));
        def.setMandatory(Boolean.valueOf(
                walker.getAttribute(Constants.MANDATORY_ATTRIBUTE)));
        def.setProtected(Boolean.valueOf(
                walker.getAttribute(Constants.PROTECTED_ATTRIBUTE)));
        def.setOnParentVersion(OnParentVersionAction.valueFromName(
                walker.getAttribute(Constants.ONPARENTVERSION_ATTRIBUTE)));
        def.setMultiple(Boolean.valueOf(
                walker.getAttribute(Constants.MULTIPLE_ATTRIBUTE)));
        def.setFullTextSearchable(Boolean.valueOf(
                walker.getAttribute(Constants.ISFULLTEXTSEARCHABLE_ATTRIBUTE)));
        def.setQueryOrderable(Boolean.valueOf(
                walker.getAttribute(Constants.ISQUERYORDERABLE_ATTRIBUTE)));
        String s = walker.getAttribute(Constants.AVAILABLEQUERYOPERATORS_ATTRIBUTE);
        if (s != null && s.length() > 0) {
            String[] ops = s.split(" ");
            List<String> queryOps = new ArrayList<String>();
            for (String op1 : ops) {
                String op = op1.trim();
                if (op.equals(Constants.EQ_ENTITY)) {
                    queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO);
                } else if (op.equals(Constants.NE_ENTITY)) {
                    queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_NOT_EQUAL_TO);
                } else if (op.equals(Constants.LT_ENTITY)) {
                    queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN);
                } else if (op.equals(Constants.LE_ENTITY)) {
                    queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO);
                } else if (op.equals(Constants.GT_ENTITY)) {
                    queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN);
                } else if (op.equals(Constants.GE_ENTITY)) {
                    queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO);
                } else if (op.equals(Constants.LIKE_ENTITY)) {
                    queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_LIKE);
                } else {
                    throw new InvalidNodeTypeDefException("'" + op + "' is not a valid query operator");
                }
            }
            def.setAvailableQueryOperators(queryOps.toArray(new String[queryOps.size()]));

        }
        def.setRequiredType(PropertyType.valueFromName(
                walker.getAttribute(Constants.REQUIREDTYPE_ATTRIBUTE)));

        // value constraints
        if (walker.enterElement(Constants.VALUECONSTRAINTS_ELEMENT)) {
            List<QValueConstraint> constraints = new ArrayList<QValueConstraint>();
            int type = def.getRequiredType();
            while (walker.iterateElements(Constants.VALUECONSTRAINT_ELEMENT)) {
                String constraint = walker.getContent();
                try {
                    constraints.add(ValueConstraint.create(
                            type, constraint.trim(), resolver));
                } catch (InvalidConstraintException e) {
                    throw new InvalidNodeTypeDefException(
                            "Invalid value constraint " + constraint, e);
                }
            }
            def.setValueConstraints(constraints.toArray(
                    new QValueConstraint[constraints.size()]));
            walker.leaveElement();
        }

        // default values
        if (walker.enterElement(Constants.DEFAULTVALUES_ELEMENT)) {
            List<InternalValue> values = new ArrayList<InternalValue>();
            int type = def.getRequiredType();
            if (type == PropertyType.UNDEFINED) {
                type = PropertyType.STRING;
            }
            while (walker.iterateElements(Constants.DEFAULTVALUE_ELEMENT)) {
                String value = walker.getContent();
                try {
                    Value v = ValueHelper.convert(value, type, valueFactory);
                    values.add((InternalValue) ValueFormat.getQValue(v, resolver, qValueFactory));
                } catch (RepositoryException e) {
                    throw new InvalidNodeTypeDefException(
                            "Unable to create default value: " + value, e);
                }
            }
            def.setDefaultValues(values.toArray(new InternalValue[values.size()]));
            walker.leaveElement();
        }

        return def;
    }
View Full Code Here

Examples of org.apache.jackrabbit.spi.commons.nodetype.compact.QNodeTypeDefinitionsBuilder.QPropertyDefinitionBuilder

    private void doItemDefs(QNodeTypeDefinitionBuilder ntd) throws ParseException {
        List propertyDefinitions = new ArrayList();
        List nodeDefinitions = new ArrayList();
        while (currentTokenEquals(Lexer.PROPERTY_DEFINITION) || currentTokenEquals(Lexer.CHILD_NODE_DEFINITION)) {
            if (currentTokenEquals(Lexer.PROPERTY_DEFINITION)) {
                QPropertyDefinitionBuilder pd = ntd.newQPropertyDefinition();

                pd.setAutoCreated(false);
                pd.setDeclaringNodeType(ntd.getName());
                pd.setDefaultValues(null);
                pd.setMandatory(false);
                pd.setMultiple(false);
                pd.setOnParentVersion(OnParentVersionAction.COPY);
                pd.setProtected(false);
                pd.setRequiredType(PropertyType.STRING);
                pd.setValueConstraints(EMPTY_VALUE_CONSTRAINTS);

                nextToken();
                doPropertyDefinition(pd, ntd);
                propertyDefinitions.add(pd.build());

            } else if (currentTokenEquals(Lexer.CHILD_NODE_DEFINITION)) {
                QNodeDefinitionBuilder nd = ntd.newQNodeDefinitionBuilder();

                nd.setAllowsSameNameSiblings(false);
View Full Code Here

Examples of org.apache.jackrabbit.spi.commons.nodetype.compact.QNodeTypeDefinitionsBuilder.QPropertyDefinitionBuilder

    private void doItemDefs(QNodeTypeDefinitionBuilder ntd) throws ParseException {
        List propertyDefinitions = new ArrayList();
        List nodeDefinitions = new ArrayList();
        while (currentTokenEquals(Lexer.PROPERTY_DEFINITION) || currentTokenEquals(Lexer.CHILD_NODE_DEFINITION)) {
            if (currentTokenEquals(Lexer.PROPERTY_DEFINITION)) {
                QPropertyDefinitionBuilder pd = ntd.newQPropertyDefinition();

                pd.setAutoCreated(false);
                pd.setDeclaringNodeType(ntd.getName());
                pd.setDefaultValues(null);
                pd.setMandatory(false);
                pd.setMultiple(false);
                pd.setOnParentVersion(OnParentVersionAction.COPY);
                pd.setProtected(false);
                pd.setRequiredType(PropertyType.STRING);
                pd.setValueConstraints(EMPTY_VALUE_CONSTRAINTS);

                nextToken();
                doPropertyDefinition(pd, ntd);
                propertyDefinitions.add(pd.build());

            } else if (currentTokenEquals(Lexer.CHILD_NODE_DEFINITION)) {
                QNodeDefinitionBuilder nd = ntd.newQNodeDefinitionBuilder();

                nd.setAllowsSameNameSiblings(false);
View Full Code Here

Examples of org.apache.jackrabbit.spi.commons.nodetype.compact.QNodeTypeDefinitionsBuilder.QPropertyDefinitionBuilder

    private void doItemDefs(QNodeTypeDefinitionBuilder ntd) throws ParseException {
        List<QPropertyDefinition> propertyDefinitions = new LinkedList<QPropertyDefinition>();
        List<QNodeDefinition> nodeDefinitions = new LinkedList<QNodeDefinition>();
        while (currentTokenEquals(Lexer.PROPERTY_DEFINITION) || currentTokenEquals(Lexer.CHILD_NODE_DEFINITION)) {
            if (currentTokenEquals(Lexer.PROPERTY_DEFINITION)) {
                QPropertyDefinitionBuilder pd = ntd.newQPropertyDefinition();

                pd.setAutoCreated(false);
                pd.setDeclaringNodeType(ntd.getName());
                pd.setDefaultValues(null);
                pd.setMandatory(false);
                pd.setMultiple(false);
                pd.setOnParentVersion(OnParentVersionAction.COPY);
                pd.setProtected(false);
                pd.setRequiredType(PropertyType.STRING);
                pd.setValueConstraints(QValueConstraint.EMPTY_ARRAY);
                pd.setFullTextSearchable(true);
                pd.setQueryOrderable(true);
                pd.setAvailableQueryOperators(Operator.getAllQueryOperators());

                nextToken();
                doPropertyDefinition(pd, ntd);
                propertyDefinitions.add(pd.build());

            } else if (currentTokenEquals(Lexer.CHILD_NODE_DEFINITION)) {
                QNodeDefinitionBuilder nd = ntd.newQNodeDefinitionBuilder();

                nd.setAllowsSameNameSiblings(false);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.