Package org.apache.jackrabbit.spi

Examples of org.apache.jackrabbit.spi.QPropertyDefinition


                } else if (type != values[i].getType()) {
                    // inhomogeneous types
                    return false;
                }
            }
            QPropertyDefinition def;
            try {
                // try to get definition that matches the given value type
                def = getApplicablePropDef(name, type, true);
            } catch (ConstraintViolationException cve) {
                // fallback: ignore type
                def = getApplicablePropDef(name, PropertyType.UNDEFINED, true);
            }

            if (def.isProtected()) {
                return false;
            }
            if (!def.isMultiple()) {
                return false;
            }
            // determine target type
            int targetType;
            if (def.getRequiredType() != PropertyType.UNDEFINED
                    && def.getRequiredType() != type) {
                // type conversion required
                targetType = def.getRequiredType();
            } else {
                // no type conversion required
                targetType = type;
            }
View Full Code Here


                        }
                        // check ambiguous definitions
                        if (qDef.definesNode() == qItemDef.definesNode()) {
                            if (!qDef.definesNode()) {
                                // property definition
                                QPropertyDefinition pd = (QPropertyDefinition) qDef;
                                QPropertyDefinition epd = (QPropertyDefinition) qItemDef;
                                // compare type & multiValued flag
                                if (pd.getRequiredType() == epd.getRequiredType()
                                        && pd.isMultiple() == epd.isMultiple()) {
                                    // conflict
                                    String msg = "The property definition for '"
                                            + name + "' in node type '"
                                            + qDef.getDeclaringNodeType()
                                            + "' conflicts with the one of node type '"
                                            + qItemDef.getDeclaringNodeType()
                                            + "': ambiguous property definition. "
                                            + "they must differ in required type "
                                            + "or cardinality.";
                                    log.debug(msg);
                                    throw new ConstraintViolationException(msg);
                                }
                            } else {
                                // child node definition
                                // conflict
                                String msg = "The child node definition for '"
                                        + name + "' in node type '"
                                        + qDef.getDeclaringNodeType()
                                        + "' conflicts with the one of node type '"
                                        + qItemDef.getDeclaringNodeType()
                                        + "': ambiguous child node definition. name must differ.";
                                log.debug(msg);
                                throw new ConstraintViolationException(msg);
                            }
                        }
                    }
                }
            } else {
                existingDefs = new ArrayList<QItemDefinition>();
                namedItemDefs.put(name, existingDefs);
            }
            existingDefs.add(qDef);
        }

        // residual item definitions
        defs = other.getUnnamedItemDefs();
        for (int i = 0; i < defs.length; i++) {
            QItemDefinition qDef = defs[i];
            if (includesNodeType(qDef.getDeclaringNodeType())) {
                // ignore redundant definitions
                continue;
            }
            for (QItemDefinition existing : unnamedItemDefs) {
                // compare with existing definition
                if (qDef.definesNode() == existing.definesNode()) {
                    if (!qDef.definesNode()) {
                        // property definition
                        QPropertyDefinition pd = (QPropertyDefinition) qDef;
                        QPropertyDefinition epd = (QPropertyDefinition) existing;
                        // compare type & multiValued flag
                        if (pd.getRequiredType() == epd.getRequiredType()
                                && pd.isMultiple() == epd.isMultiple()
                                && pd.getOnParentVersion() == epd.getOnParentVersion()) {
                            // conflict
                            // TODO: need to take more aspects into account
                            // TODO: getMatchingPropDef needs to check this as well
                            String msg = "A property definition in node type '"
                                    + qDef.getDeclaringNodeType()
View Full Code Here

    public QPropertyDefinition getQPropertyDefinition(Name[] parentNodeTypeNames,
                                                      Name propertyName,
                                                      int propertType,
                                                      boolean isMultiValued,
                                                      PropertyId propertyId) throws RepositoryException {
        QPropertyDefinition definition;
        try {
            EffectiveNodeType ent = entProvider.getEffectiveNodeType(parentNodeTypeNames);
            definition = getQPropertyDefinition(ent, propertyName, propertType, isMultiValued, true);
        } catch (RepositoryException e) {
            log.debug("Cannot determine property defintion of {}: {}", propertyId, e);
View Full Code Here

                                                              Name name, int type,
                                                              boolean multiValued, boolean throwWhenAmbiguous)
           throws ConstraintViolationException {
        // try named property definitions first
        QPropertyDefinition[] defs = ent.getNamedQPropertyDefinitions(name);
        QPropertyDefinition match = getMatchingPropDef(defs, type, multiValued, throwWhenAmbiguous);
        if (match != null) {
            return match;
        }

        // no item with that name defined;
View Full Code Here

                case Operation.STATUS_PERSISTED:
                    // for autocreated/protected props, mark to be reloaded
                    // upon next access.
                    PropertyState addedState = (PropertyState) ((PropertyEntryImpl) pe).internalGetItemState();
                    addedState.setStatus(Status.EXISTING);
                    QPropertyDefinition pd = addedState.getDefinition();
                    if (pd.isAutoCreated() || pd.isProtected()) {
                        pe.invalidate(true);
                    } // else: assume added property is up to date.
                    break;
                case Operation.STATUS_UNDO:
                    pe.revert();
View Full Code Here

                ntName[0] = NameConstants.NT_BASE;
            }
            NodeTypeImpl nt = session.getNodeTypeManager().getNodeType(ntName[0]);
            PropertyDefinition[] propDefs = nt.getPropertyDefinitions();
            for (PropertyDefinition pd : propDefs) {
                QPropertyDefinition propDef = ((PropertyDefinitionImpl) pd).unwrap();
                if (!propDef.definesResidual() && !propDef.isMultiple()) {
                    columns.put(propDef.getName(), columnForName(propDef.getName()));
                }
            }
        }

        // add jcr:path and jcr:score if not selected already
View Full Code Here

            throws RepositoryException {

        // create a new property state
        PropertyState propState;
        try {
            QPropertyDefinition propDef = def.unwrap();
            if (def.getRequiredType() != PropertyType.UNDEFINED) {
                type = def.getRequiredType();
            }
            propState =
                    stateMgr.createTransientPropertyState(getNodeId(), name,
                            ItemState.STATUS_NEW);
            propState.setType(type);
            propState.setMultiValued(propDef.isMultiple());
            // compute system generated values if necessary
            String userId = sessionContext.getSessionImpl().getUserID();
            new NodeTypeInstanceHandler(userId).setDefaultValues(
                    propState, data.getNodeState(), propDef);
        } catch (ItemStateException ise) {
View Full Code Here

    protected PropertyDefinitionImpl getApplicablePropertyDefinition(Name propertyName,
                                                                     int type,
                                                                     boolean multiValued,
                                                                     boolean exactTypeMatch)
            throws ConstraintViolationException, RepositoryException {
        QPropertyDefinition pd;
        if (exactTypeMatch || type == PropertyType.UNDEFINED) {
            pd = getEffectiveNodeType().getApplicablePropertyDef(
                    propertyName, type, multiValued);
        } else {
            try {
View Full Code Here

    public QPropertyDefinition getQPropertyDefinition(Name[] parentNodeTypeNames,
                                                      Name propertyName,
                                                      int propertyType,
                                                      boolean isMultiValued,
                                                      PropertyId propertyId) throws RepositoryException {
        QPropertyDefinition definition;
        try {
            EffectiveNodeType ent = entProvider.getEffectiveNodeType(parentNodeTypeNames);
            definition = getQPropertyDefinition(ent, propertyName, propertyType, isMultiValued, true);
        } catch (RepositoryException e) {
            log.debug("Cannot determine property definition of {}: {}", propertyId, e);
View Full Code Here

                                                              Name name, int type,
                                                              boolean multiValued, boolean throwWhenAmbiguous)
           throws ConstraintViolationException {
        // try named property definitions first
        QPropertyDefinition[] defs = ent.getNamedQPropertyDefinitions(name);
        QPropertyDefinition match = getMatchingPropDef(defs, type, multiValued, throwWhenAmbiguous);
        if (match != null) {
            return match;
        }

        // no item with that name defined;
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.spi.QPropertyDefinition

Copyright © 2018 www.massapicom. 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.